mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-09 14:22:26 +00:00
perf: Cache derived TOTP secrets in display loops
Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
8cdf1c523d
commit
b0c3a97ce3
7 files changed
+67
-15
No files matched your search
@@ -694,6 +694,26 @@ class EntryManager:
|
||||
seed_index = int(entry.get("index", index))
|
||||
return derive_seed_phrase(bip85, seed_index, words)
|
||||
|
||||
def get_totp_secret(
|
||||
self,
|
||||
index: int,
|
||||
parent_seed: str | bytes | None = None,
|
||||
) -> str:
|
||||
"""Return the TOTP secret for the specified entry."""
|
||||
entry = self.retrieve_entry(index)
|
||||
etype = entry.get("type") if entry else None
|
||||
kind = entry.get("kind") if entry else None
|
||||
if not entry or (
|
||||
etype != EntryType.TOTP.value and kind != EntryType.TOTP.value
|
||||
):
|
||||
raise ValueError("Entry is not a TOTP entry")
|
||||
if entry.get("deterministic", False) or "secret" not in entry:
|
||||
if parent_seed is None:
|
||||
raise ValueError("Seed required for derived TOTP")
|
||||
totp_index = int(entry.get("index", 0))
|
||||
return TotpManager.derive_secret(parent_seed, totp_index)
|
||||
return entry["secret"]
|
||||
|
||||
def get_totp_code(
|
||||
self,
|
||||
index: int,
|
||||
|
||||
Reference in new issue
Block a user