Download this file
| 1 | // The enrolment live-session fast path's DECISION, pure and dependency-free |
| 2 | // so it's unit-testable in Node (#1378; the harness style of serverlist.js). |
| 3 | // A candidate exists only when both halves of a live home session are present |
| 4 | // in the given store — the link token AND the tab-scoped DEK (home.js |
| 5 | // § session state; the DEK never outlives the tab by design). The caller |
| 6 | // (enroll.js trySessionReuse) still validates both against the server — fetch |
| 7 | // the blob, unseal it — before trusting them; this only decides whether |
| 8 | // there's anything to try instead of a fresh passkey ceremony. |
| 9 | export function reuseCandidate(store) { |
| 10 | try { |
| 11 | const token = (store && store.getItem("home_token")) || ""; |
| 12 | const dek = (store && store.getItem("home_dek")) || ""; |
| 13 | return token && dek ? { token, dek } : null; |
| 14 | } catch { |
| 15 | return null; // storage unavailable (private mode) — ceremony it is |
| 16 | } |
| 17 | } |
| 18 | |