recovery-pending.ts
1// Session-storage flag set while the user has just created a vault and is2// reading their 12 recovery words but has not yet typed the 3 confirmation3// words. While the flag is set, lock-on-close and auto-lock are suppressed4// — locking would discard the derived key required to re-show the words on5// reopen, and the words cannot be recovered without it.6//7// Lives in chrome.storage.session (RAM-only; cleared on browser restart).8// If the browser closes before confirmation, the flag and the in-memory key9// are both lost together — the recovery words become unreachable, which is10// the same outcome the user would face with any unconfirmed-but-unsaved11// secret.1213const KEY = "peach_recovery_pending";1415export async function isRecoveryConfirmPending(): Promise<boolean> {16 try {17 if (!chrome.storage?.session) return false;18 const out = await chrome.storage.session.get(KEY);19 return out[KEY] === "1";20 } catch {21 return false;22 }23}2425export async function setRecoveryConfirmPending(): Promise<void> {26 try {27 await chrome.storage.session?.set({ [KEY]: "1" });28 } catch { /* best-effort */ }29}3031export async function clearRecoveryConfirmPending(): Promise<void> {32 try {33 await chrome.storage.session?.remove(KEY);34 } catch { /* best-effort */ }35}