diff --git a/src/auth/tokenStore.ts b/src/auth/tokenStore.ts index 803c907..aa82b73 100644 --- a/src/auth/tokenStore.ts +++ b/src/auth/tokenStore.ts @@ -2,38 +2,14 @@ export type StoredTokens = { access_token: string; }; -const LS_KEY = "uhm_auth_tokens_v1"; - let cached: StoredTokens | null = null; -function safeParseTokens(raw: string | null): StoredTokens | null { - if (!raw) return null; - try { - const v = JSON.parse(raw) as Partial; - if (!v || typeof v !== "object") return null; - if (typeof v.access_token !== "string") return null; - if (!v.access_token.trim()) return null; - return { access_token: v.access_token }; - } catch { - return null; - } -} - export function getStoredTokens(): StoredTokens | null { - if (cached) return cached; - if (typeof window === "undefined") return null; - cached = safeParseTokens(window.localStorage.getItem(LS_KEY)); return cached; } export function setStoredTokens(tokens: StoredTokens | null): void { cached = tokens; - if (typeof window === "undefined") return; - if (!tokens) { - window.localStorage.removeItem(LS_KEY); - return; - } - window.localStorage.setItem(LS_KEY, JSON.stringify(tokens)); } export function getAccessToken(): string | null {