import { createContext, useContext } from 'react'; import type { User } from '@/features/auth/services/types'; export type AuthStatus = 'loading' | 'authenticated' | 'guest'; export interface AuthContextValue { status: AuthStatus; user: User | null; /** Access token, kept only in memory (BR-U1-02). */ accessToken: string | null; expiresAt: string | null; isAuthenticated: boolean; login: (email: string, password: string) => Promise; logout: () => Promise; /** Performs a cookie-based silent refresh; resolves to the new token or null. */ refresh: () => Promise; } export const AuthContext = createContext(null); export function useAuth(): AuthContextValue { const ctx = useContext(AuthContext); if (ctx === null) { throw new Error('useAuth must be used within an AuthProvider'); } return ctx; }