mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 07:48:57 +00:00
Merge pull request #384 from PR0M3TH3AN/codex/modify-terminal_utils.py-for-fingerprints
Improve fingerprint header handling
This commit is contained in:
64
src/main.py
64
src/main.py
@@ -587,10 +587,16 @@ def handle_toggle_secret_mode(pm: PasswordManager) -> None:
|
|||||||
def handle_profiles_menu(password_manager: PasswordManager) -> None:
|
def handle_profiles_menu(password_manager: PasswordManager) -> None:
|
||||||
"""Submenu for managing seed profiles."""
|
"""Submenu for managing seed profiles."""
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = getattr(
|
||||||
|
password_manager,
|
||||||
|
"header_fingerprint_args",
|
||||||
|
(getattr(password_manager, "current_fingerprint", None), None, None),
|
||||||
|
)
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(password_manager, "header_fingerprint", None)
|
fp,
|
||||||
or getattr(password_manager, "current_fingerprint", None),
|
|
||||||
"Main Menu > Settings > Profiles",
|
"Main Menu > Settings > Profiles",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(color_text("\nProfiles:", "menu"))
|
print(color_text("\nProfiles:", "menu"))
|
||||||
print(color_text("1. Switch Seed Profile", "menu"))
|
print(color_text("1. Switch Seed Profile", "menu"))
|
||||||
@@ -627,10 +633,16 @@ def handle_nostr_menu(password_manager: PasswordManager) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = getattr(
|
||||||
|
password_manager,
|
||||||
|
"header_fingerprint_args",
|
||||||
|
(getattr(password_manager, "current_fingerprint", None), None, None),
|
||||||
|
)
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(password_manager, "header_fingerprint", None)
|
fp,
|
||||||
or getattr(password_manager, "current_fingerprint", None),
|
|
||||||
"Main Menu > Settings > Nostr",
|
"Main Menu > Settings > Nostr",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(color_text("\nNostr Settings:", "menu"))
|
print(color_text("\nNostr Settings:", "menu"))
|
||||||
print(color_text("1. Backup to Nostr", "menu"))
|
print(color_text("1. Backup to Nostr", "menu"))
|
||||||
@@ -665,10 +677,16 @@ def handle_nostr_menu(password_manager: PasswordManager) -> None:
|
|||||||
def handle_settings(password_manager: PasswordManager) -> None:
|
def handle_settings(password_manager: PasswordManager) -> None:
|
||||||
"""Interactive settings menu with submenus for profiles and Nostr."""
|
"""Interactive settings menu with submenus for profiles and Nostr."""
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = getattr(
|
||||||
|
password_manager,
|
||||||
|
"header_fingerprint_args",
|
||||||
|
(getattr(password_manager, "current_fingerprint", None), None, None),
|
||||||
|
)
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(password_manager, "header_fingerprint", None)
|
fp,
|
||||||
or getattr(password_manager, "current_fingerprint", None),
|
|
||||||
"Main Menu > Settings",
|
"Main Menu > Settings",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(color_text("\nSettings:", "menu"))
|
print(color_text("\nSettings:", "menu"))
|
||||||
print(color_text("1. Profiles", "menu"))
|
print(color_text("1. Profiles", "menu"))
|
||||||
@@ -760,10 +778,16 @@ def display_menu(
|
|||||||
display_fn()
|
display_fn()
|
||||||
pause()
|
pause()
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = getattr(
|
||||||
|
password_manager,
|
||||||
|
"header_fingerprint_args",
|
||||||
|
(getattr(password_manager, "current_fingerprint", None), None, None),
|
||||||
|
)
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(password_manager, "header_fingerprint", None)
|
fp,
|
||||||
or getattr(password_manager, "current_fingerprint", None),
|
|
||||||
"Main Menu",
|
"Main Menu",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
if time.time() - password_manager.last_activity > inactivity_timeout:
|
if time.time() - password_manager.last_activity > inactivity_timeout:
|
||||||
print(colored("Session timed out. Vault locked.", "yellow"))
|
print(colored("Session timed out. Vault locked.", "yellow"))
|
||||||
@@ -803,10 +827,20 @@ def display_menu(
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
if choice == "1":
|
if choice == "1":
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = getattr(
|
||||||
|
password_manager,
|
||||||
|
"header_fingerprint_args",
|
||||||
|
(
|
||||||
|
getattr(password_manager, "current_fingerprint", None),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
)
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(password_manager, "header_fingerprint", None)
|
fp,
|
||||||
or getattr(password_manager, "current_fingerprint", None),
|
|
||||||
"Main Menu > Add Entry",
|
"Main Menu > Add Entry",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(color_text("\nAdd Entry:", "menu"))
|
print(color_text("\nAdd Entry:", "menu"))
|
||||||
print(color_text("1. Password", "menu"))
|
print(color_text("1. Password", "menu"))
|
||||||
@@ -852,10 +886,16 @@ def display_menu(
|
|||||||
elif choice == "2":
|
elif choice == "2":
|
||||||
password_manager.update_activity()
|
password_manager.update_activity()
|
||||||
password_manager.handle_retrieve_entry()
|
password_manager.handle_retrieve_entry()
|
||||||
|
fp, parent_fp, child_fp = getattr(
|
||||||
|
password_manager,
|
||||||
|
"header_fingerprint_args",
|
||||||
|
(getattr(password_manager, "current_fingerprint", None), None, None),
|
||||||
|
)
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(password_manager, "header_fingerprint", None)
|
fp,
|
||||||
or getattr(password_manager, "current_fingerprint", None),
|
|
||||||
"Main Menu",
|
"Main Menu",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
elif choice == "3":
|
elif choice == "3":
|
||||||
password_manager.update_activity()
|
password_manager.update_activity()
|
||||||
|
@@ -185,6 +185,16 @@ class PasswordManager:
|
|||||||
header += f" > Managed Account > {fp}"
|
header += f" > Managed Account > {fp}"
|
||||||
return header
|
return header
|
||||||
|
|
||||||
|
@property
|
||||||
|
def header_fingerprint_args(self) -> tuple[str | None, str | None, str | None]:
|
||||||
|
"""Return fingerprint parameters for header display."""
|
||||||
|
if not getattr(self, "current_fingerprint", None):
|
||||||
|
return (None, None, None)
|
||||||
|
if not self.profile_stack:
|
||||||
|
return (self.current_fingerprint, None, None)
|
||||||
|
parent_fp = self.profile_stack[-1][0]
|
||||||
|
return (None, parent_fp, self.current_fingerprint)
|
||||||
|
|
||||||
def update_activity(self) -> None:
|
def update_activity(self) -> None:
|
||||||
"""Record the current time as the last user activity."""
|
"""Record the current time as the last user activity."""
|
||||||
self.last_activity = time.time()
|
self.last_activity = time.time()
|
||||||
@@ -956,9 +966,12 @@ class PasswordManager:
|
|||||||
|
|
||||||
def handle_add_password(self) -> None:
|
def handle_add_password(self) -> None:
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > Password",
|
"Main Menu > Add Entry > Password",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
website_name = input("Enter the label or website name: ").strip()
|
website_name = input("Enter the label or website name: ").strip()
|
||||||
if not website_name:
|
if not website_name:
|
||||||
@@ -1046,9 +1059,12 @@ class PasswordManager:
|
|||||||
def handle_add_totp(self) -> None:
|
def handle_add_totp(self) -> None:
|
||||||
"""Add a TOTP entry either derived from the seed or imported."""
|
"""Add a TOTP entry either derived from the seed or imported."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > 2FA (TOTP)",
|
"Main Menu > Add Entry > 2FA (TOTP)",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
while True:
|
while True:
|
||||||
print("\nAdd TOTP:")
|
print("\nAdd TOTP:")
|
||||||
@@ -1153,9 +1169,12 @@ class PasswordManager:
|
|||||||
def handle_add_ssh_key(self) -> None:
|
def handle_add_ssh_key(self) -> None:
|
||||||
"""Add an SSH key pair entry and display the derived keys."""
|
"""Add an SSH key pair entry and display the derived keys."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > SSH Key",
|
"Main Menu > Add Entry > SSH Key",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
label = input("Label: ").strip()
|
label = input("Label: ").strip()
|
||||||
if not label:
|
if not label:
|
||||||
@@ -1198,9 +1217,12 @@ class PasswordManager:
|
|||||||
def handle_add_seed(self) -> None:
|
def handle_add_seed(self) -> None:
|
||||||
"""Add a derived BIP-39 seed phrase entry."""
|
"""Add a derived BIP-39 seed phrase entry."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > Seed Phrase",
|
"Main Menu > Add Entry > Seed Phrase",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
label = input("Label: ").strip()
|
label = input("Label: ").strip()
|
||||||
if not label:
|
if not label:
|
||||||
@@ -1257,9 +1279,12 @@ class PasswordManager:
|
|||||||
def handle_add_pgp(self) -> None:
|
def handle_add_pgp(self) -> None:
|
||||||
"""Add a PGP key entry and display the generated key."""
|
"""Add a PGP key entry and display the generated key."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > PGP Key",
|
"Main Menu > Add Entry > PGP Key",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
label = input("Label: ").strip()
|
label = input("Label: ").strip()
|
||||||
if not label:
|
if not label:
|
||||||
@@ -1313,9 +1338,12 @@ class PasswordManager:
|
|||||||
def handle_add_nostr_key(self) -> None:
|
def handle_add_nostr_key(self) -> None:
|
||||||
"""Add a Nostr key entry and display the derived keys."""
|
"""Add a Nostr key entry and display the derived keys."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > Nostr Key Pair",
|
"Main Menu > Add Entry > Nostr Key Pair",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
label = input("Label: ").strip()
|
label = input("Label: ").strip()
|
||||||
if not label:
|
if not label:
|
||||||
@@ -1360,9 +1388,12 @@ class PasswordManager:
|
|||||||
def handle_add_key_value(self) -> None:
|
def handle_add_key_value(self) -> None:
|
||||||
"""Add a generic key/value entry."""
|
"""Add a generic key/value entry."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > Key/Value",
|
"Main Menu > Add Entry > Key/Value",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
label = input("Label: ").strip()
|
label = input("Label: ").strip()
|
||||||
if not label:
|
if not label:
|
||||||
@@ -1422,9 +1453,12 @@ class PasswordManager:
|
|||||||
def handle_add_managed_account(self) -> None:
|
def handle_add_managed_account(self) -> None:
|
||||||
"""Add a managed account seed entry."""
|
"""Add a managed account seed entry."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Add Entry > Managed Account",
|
"Main Menu > Add Entry > Managed Account",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
label = input("Label: ").strip()
|
label = input("Label: ").strip()
|
||||||
if not label:
|
if not label:
|
||||||
@@ -1519,9 +1553,12 @@ class PasswordManager:
|
|||||||
and displaying the corresponding password and associated details.
|
and displaying the corresponding password and associated details.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Retrieve Entry",
|
"Main Menu > Retrieve Entry",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
index_input = input(
|
index_input = input(
|
||||||
"Enter the index number of the entry to retrieve: "
|
"Enter the index number of the entry to retrieve: "
|
||||||
@@ -1956,9 +1993,12 @@ class PasswordManager:
|
|||||||
and new details to update.
|
and new details to update.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Modify Entry",
|
"Main Menu > Modify Entry",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
index_input = input(
|
index_input = input(
|
||||||
"Enter the index number of the entry to modify: "
|
"Enter the index number of the entry to modify: "
|
||||||
@@ -2284,9 +2324,12 @@ class PasswordManager:
|
|||||||
def handle_search_entries(self) -> None:
|
def handle_search_entries(self) -> None:
|
||||||
"""Prompt for a query, list matches and optionally show details."""
|
"""Prompt for a query, list matches and optionally show details."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Search Entries",
|
"Main Menu > Search Entries",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
query = input("Enter search string: ").strip()
|
query = input("Enter search string: ").strip()
|
||||||
if not query:
|
if not query:
|
||||||
@@ -2301,9 +2344,12 @@ class PasswordManager:
|
|||||||
return
|
return
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Search Entries",
|
"Main Menu > Search Entries",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(colored("\n[+] Search Results:\n", "green"))
|
print(colored("\n[+] Search Results:\n", "green"))
|
||||||
for idx, label, username, _url, _b in results:
|
for idx, label, username, _url, _b in results:
|
||||||
@@ -2414,9 +2460,12 @@ class PasswordManager:
|
|||||||
"""List entries and optionally show details."""
|
"""List entries and optionally show details."""
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > List Entries",
|
"Main Menu > List Entries",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(color_text("\nList Entries:", "menu"))
|
print(color_text("\nList Entries:", "menu"))
|
||||||
print(color_text("1. All", "menu"))
|
print(color_text("1. All", "menu"))
|
||||||
@@ -2456,9 +2505,12 @@ class PasswordManager:
|
|||||||
if not summaries:
|
if not summaries:
|
||||||
continue
|
continue
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > List Entries",
|
"Main Menu > List Entries",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(colored("\n[+] Entries:\n", "green"))
|
print(colored("\n[+] Entries:\n", "green"))
|
||||||
for idx, etype, label in summaries:
|
for idx, etype, label in summaries:
|
||||||
@@ -2545,9 +2597,12 @@ class PasswordManager:
|
|||||||
pause()
|
pause()
|
||||||
return
|
return
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Archived Entries",
|
"Main Menu > Archived Entries",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(colored("\n[+] Archived Entries:\n", "green"))
|
print(colored("\n[+] Archived Entries:\n", "green"))
|
||||||
for idx, label, _username, _url, _ in archived:
|
for idx, label, _username, _url, _ in archived:
|
||||||
@@ -2599,9 +2654,12 @@ class PasswordManager:
|
|||||||
def handle_display_totp_codes(self) -> None:
|
def handle_display_totp_codes(self) -> None:
|
||||||
"""Display all stored TOTP codes with a countdown progress bar."""
|
"""Display all stored TOTP codes with a countdown progress bar."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > 2FA Codes",
|
"Main Menu > 2FA Codes",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
data = self.entry_manager.vault.load_index()
|
data = self.entry_manager.vault.load_index()
|
||||||
entries = data.get("entries", {})
|
entries = data.get("entries", {})
|
||||||
@@ -2622,9 +2680,12 @@ class PasswordManager:
|
|||||||
totp_list.sort(key=lambda t: t[0].lower())
|
totp_list.sort(key=lambda t: t[0].lower())
|
||||||
print(colored("Press Enter to return to the menu.", "cyan"))
|
print(colored("Press Enter to return to the menu.", "cyan"))
|
||||||
while True:
|
while True:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > 2FA Codes",
|
"Main Menu > 2FA Codes",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(colored("Press Enter to return to the menu.", "cyan"))
|
print(colored("Press Enter to return to the menu.", "cyan"))
|
||||||
generated = [t for t in totp_list if not t[3]]
|
generated = [t for t in totp_list if not t[3]]
|
||||||
@@ -2680,9 +2741,12 @@ class PasswordManager:
|
|||||||
Handles verifying the script's checksum against the stored checksum to ensure integrity.
|
Handles verifying the script's checksum against the stored checksum to ensure integrity.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Settings > Verify Script Checksum",
|
"Main Menu > Settings > Verify Script Checksum",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
current_checksum = calculate_checksum(__file__)
|
current_checksum = calculate_checksum(__file__)
|
||||||
try:
|
try:
|
||||||
@@ -2718,9 +2782,12 @@ class PasswordManager:
|
|||||||
print(colored("Operation cancelled.", "yellow"))
|
print(colored("Operation cancelled.", "yellow"))
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Settings > Generate Script Checksum",
|
"Main Menu > Settings > Generate Script Checksum",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
script_path = Path(__file__).resolve()
|
script_path = Path(__file__).resolve()
|
||||||
if update_checksum_file(str(script_path), str(SCRIPT_CHECKSUM_FILE)):
|
if update_checksum_file(str(script_path), str(SCRIPT_CHECKSUM_FILE)):
|
||||||
@@ -2831,9 +2898,12 @@ class PasswordManager:
|
|||||||
) -> Path | None:
|
) -> Path | None:
|
||||||
"""Export the current database to an encrypted portable file."""
|
"""Export the current database to an encrypted portable file."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Settings > Export database",
|
"Main Menu > Settings > Export database",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
path = export_backup(
|
path = export_backup(
|
||||||
self.vault,
|
self.vault,
|
||||||
@@ -2851,9 +2921,12 @@ class PasswordManager:
|
|||||||
def handle_import_database(self, src: Path) -> None:
|
def handle_import_database(self, src: Path) -> None:
|
||||||
"""Import a portable database file, replacing the current index."""
|
"""Import a portable database file, replacing the current index."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Settings > Import database",
|
"Main Menu > Settings > Import database",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
import_backup(
|
import_backup(
|
||||||
self.vault,
|
self.vault,
|
||||||
@@ -2869,9 +2942,12 @@ class PasswordManager:
|
|||||||
def handle_export_totp_codes(self) -> Path | None:
|
def handle_export_totp_codes(self) -> Path | None:
|
||||||
"""Export all 2FA codes to a JSON file for other authenticator apps."""
|
"""Export all 2FA codes to a JSON file for other authenticator apps."""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Settings > Export 2FA codes",
|
"Main Menu > Settings > Export 2FA codes",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
data = self.entry_manager.vault.load_index()
|
data = self.entry_manager.vault.load_index()
|
||||||
entries = data.get("entries", {})
|
entries = data.get("entries", {})
|
||||||
@@ -2932,9 +3008,12 @@ class PasswordManager:
|
|||||||
Handles the backup and reveal of the parent seed.
|
Handles the backup and reveal of the parent seed.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
fp, parent_fp, child_fp = self.header_fingerprint_args
|
||||||
clear_and_print_fingerprint(
|
clear_and_print_fingerprint(
|
||||||
getattr(self, "header_fingerprint", None),
|
fp,
|
||||||
"Main Menu > Settings > Backup Parent Seed",
|
"Main Menu > Settings > Backup Parent Seed",
|
||||||
|
parent_fingerprint=parent_fp,
|
||||||
|
child_fingerprint=child_fp,
|
||||||
)
|
)
|
||||||
print(colored("\n=== Backup Parent Seed ===", "yellow"))
|
print(colored("\n=== Backup Parent Seed ===", "yellow"))
|
||||||
print(
|
print(
|
||||||
|
@@ -12,12 +12,22 @@ def clear_screen() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def clear_and_print_fingerprint(
|
def clear_and_print_fingerprint(
|
||||||
fingerprint: str | None, breadcrumb: str | None = None
|
fingerprint: str | None = None,
|
||||||
|
breadcrumb: str | None = None,
|
||||||
|
parent_fingerprint: str | None = None,
|
||||||
|
child_fingerprint: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Clear the screen and optionally display the current fingerprint and path."""
|
"""Clear the screen and optionally display the current fingerprint and path."""
|
||||||
clear_screen()
|
clear_screen()
|
||||||
if fingerprint:
|
header_fp = None
|
||||||
header = f"Seed Profile: {fingerprint}"
|
if parent_fingerprint and child_fingerprint:
|
||||||
|
header_fp = f"{parent_fingerprint} > Managed Account > {child_fingerprint}"
|
||||||
|
elif fingerprint:
|
||||||
|
header_fp = fingerprint
|
||||||
|
elif parent_fingerprint or child_fingerprint:
|
||||||
|
header_fp = parent_fingerprint or child_fingerprint
|
||||||
|
if header_fp:
|
||||||
|
header = f"Seed Profile: {header_fp}"
|
||||||
if breadcrumb:
|
if breadcrumb:
|
||||||
header += f" > {breadcrumb}"
|
header += f" > {breadcrumb}"
|
||||||
print(colored(header, "green"))
|
print(colored(header, "green"))
|
||||||
|
Reference in New Issue
Block a user