import * as react_jsx_runtime from 'react/jsx-runtime'; import React from 'react'; interface AuthUser { id: string; email?: string; username?: string; [key: string]: unknown; } /** Best display label for a user: email, then username, then id. */ declare function userLabel(u: AuthUser | null | undefined): string; type AuthStatus = "checking" | "authed" | "guest"; interface AuthState { status: AuthStatus; user: AuthUser | null; } interface AuthContextValue extends AuthState { /** Identifier field in use ("email" | "username") — drives input type/labels. */ usernameField: string; /** Re-read the session (`GET {basePath}/me`) and update state. */ refresh: () => Promise; /** Resolves to null on success, or an error message on failure. */ signIn: (email: string, password: string) => Promise; signUp: (email: string, password: string) => Promise; signOut: () => Promise; changePassword: (currentPassword: string, newPassword: string) => Promise; } /** Endpoint configuration shared by the provider and the bare api helpers. */ interface AuthApiConfig { /** Base path the route handlers live under. Default "/api/auth". */ basePath?: string; } declare function AuthProvider({ children, basePath, usernameField, }: { children: React.ReactNode; /** Where the auth route handlers live. Same-origin by default. */ basePath?: string; /** Identifier field posted on login/register. "email" (default) or "username". */ usernameField?: string; }): react_jsx_runtime.JSX.Element; declare function useAuth(): AuthContextValue; interface AuthBarProps { basePath?: string; /** Identifier field for login/register. "email" (default) or "username". */ usernameField?: string; /** Called after any auth change (sign-in/up/out) — e.g. router.refresh(). */ onAuthChange?: () => void; } /** * Drop-in auth widget for a page header. Carries its own , so it * works anywhere — including inside server components — with no app-wide setup. */ declare const AuthBar: React.FC; interface RequireAuthProps { /** Shown while the session check is in flight. */ fallback?: React.ReactNode; /** Rendered for guests. Provide your own router redirect here. */ guest: React.ReactNode; children: React.ReactNode; } /** * Cookie-session route guard. Unlike a synchronous token check, the session is * verified async via the provider, so render `fallback` while `checking`. * * Router-agnostic: pass your framework's redirect as `guest`, e.g. * }>... */ declare const RequireAuth: React.FC; interface LoginProps { /** Called after a successful sign-in. */ onSuccess?: () => void; submitLabel?: string; } /** * Headless email/password sign-in form. Must be rendered inside an * . No router, no MUI — bring your own page/layout. */ declare const Login: React.FC; interface RegisterProps { onSuccess?: () => void; submitLabel?: string; /** Minimum password length enforced client-side. Default 6. */ minPasswordLength?: number; } /** Headless email/password registration form. Render inside . */ declare const Register: React.FC; declare const AbstractRegister: React.FC; interface LogoutButtonProps { onSuccess?: () => void; label?: string; style?: React.CSSProperties; } /** Headless logout button. Render inside . */ declare const Logout: React.FC; declare const AbstractLogout: React.FC; interface ChangePasswordProps { onSuccess?: () => void; submitLabel?: string; minPasswordLength?: number; } /** Headless change-password form. Render inside when signed in. */ declare const ChangePassword: React.FC; declare const AbstractChangePassword: React.FC; declare function fetchMe(basePath?: string): Promise<{ id: string; email?: string; [k: string]: unknown; } | null>; /** Sign in. Returns null on success, else an error message. */ declare function loginWithAbstract(identifier: string, password: string, basePath?: string, usernameField?: string): Promise; /** Register. Returns null on success, else an error message. */ declare function registerWithAbstract(identifier: string, password: string, basePath?: string, usernameField?: string): Promise; /** Sign out. Best-effort; never throws. */ declare function logoutUser(basePath?: string): Promise; /** Change password (must be signed in). Returns null on success, else error. */ declare function changePassword(currentPassword: string, newPassword: string, basePath?: string): Promise; export { AbstractChangePassword, AbstractLogout, AbstractRegister, AuthBar, AuthProvider, ChangePassword, Login, Logout, Register, RequireAuth, changePassword, fetchMe, loginWithAbstract, logoutUser, registerWithAbstract, useAuth, userLabel }; export type { AuthApiConfig, AuthBarProps, AuthContextValue, AuthState, AuthStatus, AuthUser, ChangePasswordProps, LoginProps, LogoutButtonProps, RegisterProps, RequireAuthProps };