import { createContext, useContext } from 'react' import type { AuthSession } from '../lib/auth-storage' export type AuthContextValue = { session: AuthSession | null isAuthed: boolean login: (email: string, password: string) => Promise logout: () => Promise ensureFreshToken: () => Promise } export const AuthContext = createContext(null) export function useAuth() { const ctx = useContext(AuthContext) if (!ctx) throw new Error('useAuth must be used inside ') return ctx }