/** * Declares the session's React context. `AuthProvider` fills it and `useAuth` * reads it; nothing else should touch it. * * @module */ import { createContext, type Dispatch, type SetStateAction } from "react"; import type { Session } from "../../utils/auth/storage.ts"; /** * Provided by `AuthProvider` to `useAuth`, which builds the session's API on * it. */ export interface AuthContextValue { authResponse: Session | null; /** * Replaces the session in memory only. Its callers store the new session * themselves, with `storeSession`, so other tabs follow. */ setAuthResponse: Dispatch>; } /** * The session's context. Its default, a signed-out session whose setter does * nothing, is only seen outside `AuthProvider`, as in some tests. */ export const AuthContext: React.Context = createContext< AuthContextValue >({ authResponse: null, setAuthResponse: () => {}, });