import React from 'react'; export interface FlavoUser { email: string; displayName: string; avatar: string; authProvider: string; meta?: Record; } export interface FlavoAuthState { user: FlavoUser | null; isLoading: boolean; isAuthenticated: boolean; /** Initiate login. Redirects to the Flavo login page where the user picks their provider. */ login: () => void; logout: () => void; } export interface FlavoAuthConfig { enabled: boolean; /** The app/conversation ID. Required for shared-backend (direct login) mode. */ appId?: string; /** Override the login redirect URL. Defaults to https://flavo.ai */ loginBaseUrl?: string; /** Override the validate endpoint URL. Defaults to the Fastfold server's own proxy, or Flavo directly. */ validateUrl?: string; /** Called after successful login. */ onLogin?: (user: FlavoUser) => void; /** Called after logout. */ onLogout?: () => void; } /** * Hook to access Flavo auth state and actions. * Must be used within a FlavoAuthProvider. * * @example * function MyComponent() { * const { user, isAuthenticated, login, logout } = useFlavoAuth(); * if (!isAuthenticated) return ; * return
Welcome, {user?.displayName}!
; * } */ export declare function useFlavoAuth(): FlavoAuthState; /** * Context provider that manages the Flavo auth lifecycle: * - Resolves the session from the httpOnly cookie on mount (via `/api/auth/me`) * - Provides login/logout actions * * @example * * * */ export declare function FlavoAuthProvider({ children, config, }: { children: React.ReactNode; config?: Partial; }): React.FunctionComponentElement>; /** * Drop-in component for the OAuth callback route (/auth). Waits for the * provider to resolve the session cookie, then redirects to `redirectTo` on * success or `/login?error=auth_failed` on failure. * * Renders `loadingComponent` (or nothing, by default) while the session is * being validated. Style it to match the app's own theme so the transient * paint looks native to the app. * * @example * // In your router: * } />} /> */ export declare function FlavoAuthCallback({ redirectTo, loadingComponent, }: { redirectTo?: string; loadingComponent?: React.ReactNode; }): React.ReactElement | null; /** * Wraps children and only renders them when the user is authenticated. * * While the session is being validated, renders `loadingComponent` — or * nothing at all if the caller didn't pass one. Style it to match the app's * own theme; a skeleton that mirrors the authenticated shell usually works * best because the refresh paint becomes a still frame of the real page. * * When unauthenticated with no `fallback`, triggers `login()` and renders * `loadingComponent` (or nothing) while the browser navigates to the Flavo * login page. * * @example * } loadingComponent={}> * * * * @example * // Auto-redirect to login when unauthenticated * }> * * */ export declare function ProtectedRoute({ children, fallback, loadingComponent, }: { children: React.ReactNode; fallback?: React.ReactNode; loadingComponent?: React.ReactNode; }): React.ReactElement> | null; //# sourceMappingURL=auth.d.ts.map