From 6335c8442ec400a986886803af045d083f194fa9 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 7 Jul 2025 20:48:18 -0400 Subject: [PATCH] Add managed_account entry type and handle in code --- docs/json_entries.md | 15 +++++++++++++++ src/password_manager/entry_management.py | 13 ++++++++++--- src/password_manager/entry_types.py | 1 + src/password_manager/manager.py | 10 ++++++++-- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/docs/json_entries.md b/docs/json_entries.md index 263f0ea..6e723ef 100644 --- a/docs/json_entries.md +++ b/docs/json_entries.md @@ -252,6 +252,21 @@ Each entry is stored within `seedpass_entries_db.json.enc` under the `entries` d } ``` +#### 8. Managed Account + +```json +{ + "entry_num": 7, + "fingerprint": "a1b2c3d4", + "kind": "managed_account", + "data": { + "account": "alice@example.com", + "password": "" + }, + "timestamp": "2024-04-27T12:41:56Z" +} +``` + The `key` field is purely descriptive, while `value` holds the sensitive string such as an API token. Notes and custom fields may also be included alongside the standard metadata. diff --git a/src/password_manager/entry_management.py b/src/password_manager/entry_management.py index 5a2149b..1732f21 100644 --- a/src/password_manager/entry_management.py +++ b/src/password_manager/entry_management.py @@ -533,7 +533,11 @@ class EntryManager: if entry: etype = entry.get("type", entry.get("kind")) - if etype in (EntryType.PASSWORD.value, EntryType.KEY_VALUE.value): + if etype in ( + EntryType.PASSWORD.value, + EntryType.KEY_VALUE.value, + EntryType.MANAGED_ACCOUNT.value, + ): entry.setdefault("custom_fields", []) logger.debug(f"Retrieved entry at index {index}: {entry}") return entry @@ -620,7 +624,10 @@ class EntryManager: if url is not None: entry["url"] = url logger.debug(f"Updated URL to '{url}' for index {index}.") - elif entry_type == EntryType.KEY_VALUE.value: + elif entry_type in ( + EntryType.KEY_VALUE.value, + EntryType.MANAGED_ACCOUNT.value, + ): if value is not None: entry["value"] = value logger.debug(f"Updated value for index {index}.") @@ -837,7 +844,7 @@ class EntryManager: entry.get("archived", entry.get("blacklisted", False)), ) ) - elif etype == EntryType.KEY_VALUE.value: + elif etype in (EntryType.KEY_VALUE.value, EntryType.MANAGED_ACCOUNT.value): value_field = str(entry.get("value", "")) custom_fields = entry.get("custom_fields", []) custom_match = any( diff --git a/src/password_manager/entry_types.py b/src/password_manager/entry_types.py index 24aa9e7..da5bd15 100644 --- a/src/password_manager/entry_types.py +++ b/src/password_manager/entry_types.py @@ -14,3 +14,4 @@ class EntryType(str, Enum): PGP = "pgp" NOSTR = "nostr" KEY_VALUE = "key_value" + MANAGED_ACCOUNT = "managed_account" diff --git a/src/password_manager/manager.py b/src/password_manager/manager.py index 4698272..358846b 100644 --- a/src/password_manager/manager.py +++ b/src/password_manager/manager.py @@ -1629,7 +1629,10 @@ class PasswordManager: pause() return - if entry_type == EntryType.KEY_VALUE.value: + if entry_type in ( + EntryType.KEY_VALUE.value, + EntryType.MANAGED_ACCOUNT.value, + ): label = entry.get("label", "") value = entry.get("value", "") notes = entry.get("notes", "") @@ -1904,7 +1907,10 @@ class PasswordManager: digits=new_digits, custom_fields=custom_fields, ) - elif entry_type == EntryType.KEY_VALUE.value: + elif entry_type in ( + EntryType.KEY_VALUE.value, + EntryType.MANAGED_ACCOUNT.value, + ): label = entry.get("label", "") value = entry.get("value", "") blacklisted = entry.get("archived", False)