/** * Per-account key for the "I've saved my recovery code" flag. * * It MUST be namespaced by pubkey: a device-global flag let account A's * confirmation suppress the backup reminder for account B created later on the * same device — leaving B's only key unrecovered. */ export function backupConfirmedKey(pubkey: string | undefined): string { return `backup-confirmed:${pubkey ?? 'anon'}`; } /** * Record that this account's key was saved. * * ⚠️ Call this with the **real** pubkey (e.g. derived from the freshly minted * nsec), NOT `useCurrentUser().pubkey` during signup — at that moment `user` is * still settling, so the write landed on `backup-confirmed:anon` and the * post-signup reminder never learned the key was saved (it nagged every session). * Mirrors `useLocalStorage`'s JSON encoding so the hook reads it back. */ export function markBackupConfirmed(pubkey: string | undefined): void { if (!pubkey) return; try { localStorage.setItem(backupConfirmedKey(pubkey), JSON.stringify(true)); } catch { // localStorage can throw in strict privacy modes — safe to ignore. } }