From dfdc2925bb78e72abcb07303f9fa699beaab14a0 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 29 Jun 2025 14:27:12 -0400 Subject: [PATCH] Replace fingerprint wording with seed profile --- src/main.py | 58 +++++++++++++------------- src/password_manager/manager.py | 73 +++++++++++++++++---------------- 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/main.py b/src/main.py index 22889e4..b15bd72 100644 --- a/src/main.py +++ b/src/main.py @@ -79,70 +79,70 @@ def handle_switch_fingerprint(password_manager: PasswordManager): if not fingerprints: print( colored( - "No fingerprints available to switch. Please add a new fingerprint first.", + "No seed profiles available to switch. Please add a new seed profile first.", "yellow", ) ) return - print(colored("Available Fingerprints:", "cyan")) + print(colored("Available Seed Profiles:", "cyan")) for idx, fp in enumerate(fingerprints, start=1): print(colored(f"{idx}. {fp}", "cyan")) - choice = input("Select a fingerprint by number to switch: ").strip() + choice = input("Select a seed profile by number to switch: ").strip() if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): print(colored("Invalid selection.", "red")) return selected_fingerprint = fingerprints[int(choice) - 1] if password_manager.select_fingerprint(selected_fingerprint): - print(colored(f"Switched to fingerprint {selected_fingerprint}.", "green")) + print(colored(f"Switched to seed profile {selected_fingerprint}.", "green")) else: - print(colored("Failed to switch fingerprint.", "red")) + print(colored("Failed to switch seed profile.", "red")) except Exception as e: logging.error(f"Error during fingerprint switch: {e}") logging.error(traceback.format_exc()) - print(colored(f"Error: Failed to switch fingerprint: {e}", "red")) + print(colored(f"Error: Failed to switch seed profile: {e}", "red")) def handle_add_new_fingerprint(password_manager: PasswordManager): """ - Handles adding a new fingerprint. + Handles adding a new seed profile. :param password_manager: An instance of PasswordManager. """ try: password_manager.add_new_fingerprint() except Exception as e: - logging.error(f"Error adding new fingerprint: {e}") + logging.error(f"Error adding new seed profile: {e}") logging.error(traceback.format_exc()) - print(colored(f"Error: Failed to add new fingerprint: {e}", "red")) + print(colored(f"Error: Failed to add new seed profile: {e}", "red")) def handle_remove_fingerprint(password_manager: PasswordManager): """ - Handles removing an existing fingerprint. + Handles removing an existing seed profile. :param password_manager: An instance of PasswordManager. """ try: fingerprints = password_manager.fingerprint_manager.list_fingerprints() if not fingerprints: - print(colored("No fingerprints available to remove.", "yellow")) + print(colored("No seed profiles available to remove.", "yellow")) return - print(colored("Available Fingerprints:", "cyan")) + print(colored("Available Seed Profiles:", "cyan")) for idx, fp in enumerate(fingerprints, start=1): print(colored(f"{idx}. {fp}", "cyan")) - choice = input("Select a fingerprint by number to remove: ").strip() + choice = input("Select a seed profile by number to remove: ").strip() if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): print(colored("Invalid selection.", "red")) return selected_fingerprint = fingerprints[int(choice) - 1] confirm = confirm_action( - f"Are you sure you want to remove fingerprint {selected_fingerprint}? This will delete all associated data. (Y/N): " + f"Are you sure you want to remove seed profile {selected_fingerprint}? This will delete all associated data. (Y/N): " ) if confirm: if password_manager.fingerprint_manager.remove_fingerprint( @@ -150,39 +150,39 @@ def handle_remove_fingerprint(password_manager: PasswordManager): ): print( colored( - f"Fingerprint {selected_fingerprint} removed successfully.", + f"Seed profile {selected_fingerprint} removed successfully.", "green", ) ) else: - print(colored("Failed to remove fingerprint.", "red")) + print(colored("Failed to remove seed profile.", "red")) else: - print(colored("Fingerprint removal cancelled.", "yellow")) + print(colored("Seed profile removal cancelled.", "yellow")) except Exception as e: - logging.error(f"Error removing fingerprint: {e}") + logging.error(f"Error removing seed profile: {e}") logging.error(traceback.format_exc()) - print(colored(f"Error: Failed to remove fingerprint: {e}", "red")) + print(colored(f"Error: Failed to remove seed profile: {e}", "red")) def handle_list_fingerprints(password_manager: PasswordManager): """ - Handles listing all available fingerprints. + Handles listing all available seed profiles. :param password_manager: An instance of PasswordManager. """ try: fingerprints = password_manager.fingerprint_manager.list_fingerprints() if not fingerprints: - print(colored("No fingerprints available.", "yellow")) + print(colored("No seed profiles available.", "yellow")) return - print(colored("Available Fingerprints:", "cyan")) + print(colored("Available Seed Profiles:", "cyan")) for fp in fingerprints: print(colored(f"- {fp}", "cyan")) except Exception as e: - logging.error(f"Error listing fingerprints: {e}") + logging.error(f"Error listing seed profiles: {e}") logging.error(traceback.format_exc()) - print(colored(f"Error: Failed to list fingerprints: {e}", "red")) + print(colored(f"Error: Failed to list seed profiles: {e}", "red")) def handle_display_npub(password_manager: PasswordManager): @@ -408,10 +408,10 @@ def display_menu(password_manager: PasswordManager): 6. Retrieve Encrypted Index from Nostr 7. Display Nostr Public Key (npub) 8. Backup/Reveal Parent Seed - 9. Switch Fingerprint - 10. Add a New Fingerprint - 11. Remove an Existing Fingerprint - 12. List All Fingerprints + 9. Switch Seed Profile + 10. Add a New Seed Profile + 11. Remove an Existing Seed Profile + 12. List All Seed Profiles 13. Settings 14. Exit """ @@ -447,7 +447,7 @@ def display_menu(password_manager: PasswordManager): password_manager.handle_backup_reveal_parent_seed() elif choice == "9": if not password_manager.handle_switch_fingerprint(): - print(colored("Failed to switch fingerprint.", "red")) + print(colored("Failed to switch seed profile.", "red")) elif choice == "10": handle_add_new_fingerprint(password_manager) elif choice == "11": diff --git a/src/password_manager/manager.py b/src/password_manager/manager.py index b18a335..f9d71e6 100644 --- a/src/password_manager/manager.py +++ b/src/password_manager/manager.py @@ -122,36 +122,36 @@ class PasswordManager: Prompts the user to select an existing fingerprint or add a new one. """ try: - print(colored("\nAvailable Fingerprints:", "cyan")) + print(colored("\nAvailable Seed Profiles:", "cyan")) fingerprints = self.fingerprint_manager.list_fingerprints() for idx, fp in enumerate(fingerprints, start=1): print(colored(f"{idx}. {fp}", "cyan")) - print(colored(f"{len(fingerprints)+1}. Add a new fingerprint", "cyan")) + print(colored(f"{len(fingerprints)+1}. Add a new seed profile", "cyan")) - choice = input("Select a fingerprint by number: ").strip() + choice = input("Select a seed profile by number: ").strip() if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints) + 1): print(colored("Invalid selection. Exiting.", "red")) sys.exit(1) choice = int(choice) if choice == len(fingerprints) + 1: - # Add a new fingerprint + # Add a new seed profile self.add_new_fingerprint() else: - # Select existing fingerprint + # Select existing seed profile selected_fingerprint = fingerprints[choice - 1] self.select_fingerprint(selected_fingerprint) except Exception as e: - logger.error(f"Error during fingerprint selection: {e}") + logger.error(f"Error during seed profile selection: {e}") logger.error(traceback.format_exc()) - print(colored(f"Error: Failed to select fingerprint: {e}", "red")) + print(colored(f"Error: Failed to select seed profile: {e}", "red")) sys.exit(1) def add_new_fingerprint(self): """ - Adds a new fingerprint by generating it from a seed phrase. + Adds a new seed profile by generating it from a seed phrase. """ try: choice = input( @@ -169,15 +169,15 @@ class PasswordManager: self.fingerprint_manager.current_fingerprint = fingerprint print( colored( - f"New fingerprint '{fingerprint}' added and set as current.", + f"New seed profile '{fingerprint}' added and set as current.", "green", ) ) except Exception as e: - logger.error(f"Error adding new fingerprint: {e}") + logger.error(f"Error adding new seed profile: {e}") logger.error(traceback.format_exc()) - print(colored(f"Error: Failed to add new fingerprint: {e}", "red")) + print(colored(f"Error: Failed to add new seed profile: {e}", "red")) sys.exit(1) def select_fingerprint(self, fingerprint: str) -> None: @@ -189,7 +189,7 @@ class PasswordManager: if not self.fingerprint_dir: print( colored( - f"Error: Fingerprint directory for {fingerprint} not found.", + f"Error: Seed profile directory for {fingerprint} not found.", "red", ) ) @@ -203,12 +203,12 @@ class PasswordManager: self.sync_index_from_nostr_if_missing() print( colored( - f"Fingerprint {fingerprint} selected and managers initialized.", + f"Seed profile {fingerprint} selected and managers initialized.", "green", ) ) else: - print(colored(f"Error: Fingerprint {fingerprint} not found.", "red")) + print(colored(f"Error: Seed profile {fingerprint} not found.", "red")) sys.exit(1) def setup_encryption_manager( @@ -267,18 +267,18 @@ class PasswordManager: def handle_switch_fingerprint(self) -> bool: """ - Handles switching to a different fingerprint. + Handles switching to a different seed profile. Returns: bool: True if switch was successful, False otherwise. """ try: - print(colored("\nAvailable Fingerprints:", "cyan")) + print(colored("\nAvailable Seed Profiles:", "cyan")) fingerprints = self.fingerprint_manager.list_fingerprints() for idx, fp in enumerate(fingerprints, start=1): print(colored(f"{idx}. {fp}", "cyan")) - choice = input("Select a fingerprint by number to switch: ").strip() + choice = input("Select a seed profile by number to switch: ").strip() if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): print(colored("Invalid selection. Returning to main menu.", "red")) return False # Return False to indicate failure @@ -294,26 +294,26 @@ class PasswordManager: if not self.fingerprint_dir: print( colored( - f"Error: Fingerprint directory for {selected_fingerprint} not found.", + f"Error: Seed profile directory for {selected_fingerprint} not found.", "red", ) ) return False # Return False to indicate failure - # Prompt for master password for the selected fingerprint + # Prompt for master password for the selected seed profile password = prompt_existing_password("Enter your master password: ") - # Set up the encryption manager with the new password and fingerprint directory + # Set up the encryption manager with the new password and seed profile directory self.setup_encryption_manager(self.fingerprint_dir, password) - # Load the parent seed for the selected fingerprint + # Load the parent seed for the selected seed profile self.load_parent_seed(self.fingerprint_dir) # Initialize BIP85 and other managers self.initialize_bip85() self.initialize_managers() self.sync_index_from_nostr_if_missing() - print(colored(f"Switched to fingerprint {selected_fingerprint}.", "green")) + print(colored(f"Switched to seed profile {selected_fingerprint}.", "green")) # Re-initialize NostrClient with the new fingerprint try: @@ -322,7 +322,7 @@ class PasswordManager: fingerprint=self.current_fingerprint, ) logging.info( - f"NostrClient re-initialized with fingerprint {self.current_fingerprint}." + f"NostrClient re-initialized with seed profile {self.current_fingerprint}." ) except Exception as e: logging.error(f"Failed to re-initialize NostrClient: {e}") @@ -334,9 +334,9 @@ class PasswordManager: return True # Return True to indicate success except Exception as e: - logging.error(f"Error during fingerprint switching: {e}") + logging.error(f"Error during seed profile switching: {e}") logging.error(traceback.format_exc()) - print(colored(f"Error: Failed to switch fingerprints: {e}", "red")) + print(colored(f"Error: Failed to switch seed profiles: {e}", "red")) return False # Return False to indicate failure def handle_existing_seed(self) -> None: @@ -355,22 +355,22 @@ class PasswordManager: if not self.fingerprint_manager: self.initialize_fingerprint_manager() - # Prompt the user to select an existing fingerprint + # Prompt the user to select an existing seed profile fingerprints = self.fingerprint_manager.list_fingerprints() if not fingerprints: print( colored( - "No fingerprints available. Please add a fingerprint first.", + "No seed profiles available. Please add a seed profile first.", "red", ) ) sys.exit(1) - print(colored("Available Fingerprints:", "cyan")) + print(colored("Available Seed Profiles:", "cyan")) for idx, fp in enumerate(fingerprints, start=1): print(colored(f"{idx}. {fp}", "cyan")) - choice = input("Select a fingerprint by number: ").strip() + choice = input("Select a seed profile by number: ").strip() if not choice.isdigit() or not (1 <= int(choice) <= len(fingerprints)): print(colored("Invalid selection. Exiting.", "red")) sys.exit(1) @@ -381,7 +381,7 @@ class PasswordManager: selected_fingerprint ) if not fingerprint_dir: - print(colored("Error: Fingerprint directory not found.", "red")) + print(colored("Error: Seed profile directory not found.", "red")) sys.exit(1) # Initialize EncryptionManager with key and fingerprint_dir @@ -442,7 +442,7 @@ class PasswordManager: if not fingerprint: print( colored( - "Error: Failed to generate fingerprint for the provided seed.", + "Error: Failed to generate seed profile for the provided seed.", "red", ) ) @@ -454,7 +454,7 @@ class PasswordManager: if not fingerprint_dir: print( colored( - "Error: Failed to retrieve fingerprint directory.", "red" + "Error: Failed to retrieve seed profile directory.", "red" ) ) sys.exit(1) @@ -463,7 +463,7 @@ class PasswordManager: self.current_fingerprint = fingerprint self.fingerprint_manager.current_fingerprint = fingerprint self.fingerprint_dir = fingerprint_dir - logging.info(f"Current fingerprint set to {fingerprint}") + logging.info(f"Current seed profile set to {fingerprint}") # Initialize EncryptionManager with key and fingerprint_dir password = prompt_for_password() @@ -514,7 +514,8 @@ class PasswordManager: if not fingerprint: print( colored( - "Error: Failed to generate fingerprint for the new seed.", "red" + "Error: Failed to generate seed profile for the new seed.", + "red", ) ) sys.exit(1) @@ -524,14 +525,14 @@ class PasswordManager: ) if not fingerprint_dir: print( - colored("Error: Failed to retrieve fingerprint directory.", "red") + colored("Error: Failed to retrieve seed profile directory.", "red") ) sys.exit(1) # Set the current fingerprint in both PasswordManager and FingerprintManager self.current_fingerprint = fingerprint self.fingerprint_manager.current_fingerprint = fingerprint - logging.info(f"Current fingerprint set to {fingerprint}") + logging.info(f"Current seed profile set to {fingerprint}") # Now, save and encrypt the seed with the fingerprint_dir self.save_and_encrypt_seed(new_seed, fingerprint_dir)