import { AuthUser, AuthError, AuthMode, LoginMethods } from '../types/auth.js'; interface UseAuthOptions { /** * Override the auth base path. Default: auto-detect from `window.location.hostname` * via `resolveAuthBasePath()`. */ basePath?: string; /** * Called once a sign-in/sign-up/reset/verify completes successfully. * Use this to revalidate data, navigate, etc. The dialog auto-closes * separately via its own `onAuthenticated` prop. */ onAuthenticated?: (user: AuthUser) => void; /** Disable the initial GET /session probe (e.g. in SSR or tests). */ skipInitialSession?: boolean; /** Disable URL token detection (e.g. if the host page handles its own routing). */ skipUrlTokenDetection?: boolean; } interface UseAuthResult { /** Resolved auth base path (`/api/auth` or `/_bffless/auth`). */ basePath: string; /** Current signed-in user, or null. */ user: AuthUser | null; /** True until the initial session probe + URL detection finish. */ ready: boolean; /** True while any auth operation is in flight. */ loading: boolean; /** Last error from a failed operation. Cleared on next successful op. */ error: AuthError | null; /** Active mode — drives which form the dialog renders. */ mode: AuthMode; setMode: (mode: AuthMode) => void; /** Optional discovered login methods (e.g. for showing a Google button). */ loginMethods: LoginMethods | null; /** Token stashed from `?bffless_reset=` (only present when mode='reset'). */ resetToken: string | null; /** Token stashed from `?bffless_verify=` (only present when mode='verify'). */ verifyToken: string | null; /** Email captured from sign-up flow (used by verify-sent screen). */ pendingVerifyEmail: string | null; signIn: (email: string, password: string) => Promise; signUp: (email: string, password: string, redirectOverride?: string) => Promise; forgotPassword: (email: string) => Promise; resetPassword: (password: string, token?: string) => Promise; verifyEmail: (token?: string) => Promise; resendVerification: () => Promise; signOut: () => Promise; refresh: () => Promise; /** Clear the current error without changing other state. */ clearError: () => void; } declare function useAuth(opts?: UseAuthOptions): UseAuthResult; export { type UseAuthOptions, type UseAuthResult, useAuth };