// Client-side helpers for the HF OAuth flow. The token is owned by // AuthProvider (src/context/auth-context.tsx); these read-only helpers exist // so non-React fetch utilities can attach `Authorization: Bearer ` // without going through React. const STORAGE_KEY = "lerobot-viz-oauth"; export function getAuthToken(): string | null { if (typeof window === "undefined") return null; try { const stored = window.localStorage.getItem(STORAGE_KEY); if (!stored) return null; const parsed = JSON.parse(stored) as { accessToken?: string }; return parsed.accessToken ?? null; } catch { return null; } } export function authHeaders(): Record { const token = getAuthToken(); return token ? { Authorization: `Bearer ${token}` } : {}; } export const AUTH_STORAGE_KEY = STORAGE_KEY; // Native