this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Migrate web auth store to SDK pending login methods

Use Opake.savePendingLogin/loadPendingLogin instead of raw
sessionStorage — gets the 10-minute TTL and auto-clear on read.

+8 -10
+8 -10
apps/web/src/stores/auth.ts
··· 9 9 10 10 import { create } from "zustand"; 11 11 import { immer } from "zustand/middleware/immer"; 12 - import type { Opake, PendingLogin, ResolvedIdentity } from "@opake/sdk"; 12 + import type { Opake, ResolvedIdentity } from "@opake/sdk"; 13 13 import type { IndexedDbStorage } from "@opake/sdk/storage/indexeddb"; 14 14 import { base64ToUint8Array } from "@/lib/encoding"; 15 15 import { loading } from "@/stores/app"; ··· 56 56 // --------------------------------------------------------------------------- 57 57 // Constants 58 58 // --------------------------------------------------------------------------- 59 - 60 - const PENDING_KEY = "opake:pendingLogin"; 61 59 62 60 function redirectUri(): string { 63 61 return `${window.location.origin}/devices/oauth-callback`; ··· 227 225 if (isDeadSessionError(err)) { 228 226 opakeInstance = null; 229 227 opake.destroy(); 230 - await s.clearSession(did).catch(() => {}); 228 + await s.clearSession(did).catch(() => { 229 + /* best effort */ 230 + }); 231 231 bootPromise = null; 232 232 set((draft) => { 233 233 draft.session = { status: "none" }; ··· 285 285 redirectUri: redirectUri(), 286 286 }); 287 287 288 - sessionStorage.setItem(PENDING_KEY, JSON.stringify(pending)); 288 + Opake.savePendingLogin(pending); 289 289 window.location.href = authUrl; 290 290 } catch (err) { 291 291 set((draft) => { ··· 300 300 }, 301 301 302 302 async completeLogin(code, state) { 303 - const raw = sessionStorage.getItem(PENDING_KEY); 304 - sessionStorage.removeItem(PENDING_KEY); 303 + const { Opake } = await loadSdk(); 304 + const pending = Opake.loadPendingLogin(); 305 305 306 - if (!raw) { 306 + if (!pending) { 307 307 set((draft) => { 308 308 draft.session = { 309 309 status: "error", ··· 315 315 316 316 const done = loading("complete-login"); 317 317 try { 318 - const { Opake } = await loadSdk(); 319 - const pending = JSON.parse(raw) as PendingLogin; 320 318 const s = await getStorage(); 321 319 322 320 await Opake.completeLogin(code, state, pending, {