import { createContext, useContext } from 'react' import type { AuthSession } from '../lib/auth-storage' export type AuthContextValue = { session: AuthSession | null isAuthed: boolean login: (centerApiBase: string, email: string, password: string) => Promise adoptSession: (session: AuthSession) => void logout: () => Promise ensureFreshToken: () => Promise refreshGuilds: () => Promise updateName: (name: string) => 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 }