recovery-pending.ts

1.1 KB · raw

1// Persistent flag set while the user has just created a vault and is reading2// their 12 recovery words but has not yet typed the 3 confirmation words.3// While the flag is set: (a) lock-on-close and auto-lock are suppressed so4// the in-memory key needed to re-derive the words survives a popup close, and5// (b) on the next successful unlock (even after a full browser restart), the6// popup re-routes to the recovery-words display instead of the entries view.7//8// Lives in chrome.storage.local so the flag survives browser restart. Cleared9// on confirmation success and on DESTROY_VAULT (storage.local.clear()).1011const KEY = "peach_recovery_pending";1213export async function isRecoveryConfirmPending(): Promise<boolean> {14  try {15    if (!chrome.storage?.local) return false;16    const out = await chrome.storage.local.get(KEY);17    return (out as Record<string, unknown>)[KEY] === "1";18  } catch {19    return false;20  }21}2223export async function setRecoveryConfirmPending(): Promise<void> {24  try {25    await chrome.storage.local?.set({ [KEY]: "1" });26  } catch { /* best-effort */ }27}