/** * CODAI Authentication Provider * * React context provider for authentication state management. * Provides authentication context to the entire application. */ import React, { ReactNode } from 'react'; import type { AuthContextType } from './types'; declare const AuthContext: React.Context; export interface AuthProviderProps { children: ReactNode; /** * Custom API URL for authentication endpoints */ apiUrl?: string; /** * App identifier for multi-app authentication */ appId?: string; /** * Callback when authentication state changes */ onAuthStateChange?: (isAuthenticated: boolean, user: any) => void; /** * Callback when authentication errors occur */ onAuthError?: (error: any) => void; /** * Whether to automatically refresh tokens */ autoRefreshTokens?: boolean; /** * Whether to persist auth state across browser sessions */ persistSession?: boolean; /** * Configuration options */ config?: { enableDevMode?: boolean; }; } /** * Authentication Provider Component * * Wraps the application to provide authentication context. * Handles token refresh, session management, and auth state persistence. */ export declare function AuthProvider({ children, apiUrl, appId, onAuthStateChange, onAuthError, autoRefreshTokens, persistSession, config, }: AuthProviderProps): import("react/jsx-runtime").JSX.Element; /** * Hook to access authentication context * * Must be used within an AuthProvider component. * Provides access to authentication state and methods. */ export declare function useAuthContext(): AuthContextType; /** * Higher-order component for authentication protection * * Wraps a component to require authentication. * Redirects to login if user is not authenticated. */ export declare function withAuth

(Component: React.ComponentType

, options?: { redirectTo?: string; requiredRole?: string; requiredPermissions?: string[]; fallback?: React.ComponentType; showLoading?: boolean; }): { (props: P): import("react/jsx-runtime").JSX.Element; displayName: string; }; /** * Hook for authentication guards * * Provides utilities for checking authentication, roles, and permissions * within components. */ export declare function useAuthGuard(): { requireAuth: (redirectTo?: string) => boolean; requireRole: (role: string, fallback?: () => void) => boolean; requirePermissions: (permissions: string[], fallback?: () => void) => boolean; requireAnyPermission: (permissions: string[], fallback?: () => void) => boolean; isAuthenticated: boolean; isLoading: boolean; user: import("./types").User | null; hasRole: (role: import("./types").UserRole) => boolean; hasPermission: (permission: string) => boolean; }; /** * Route protection component * * Protects routes based on authentication, roles, or permissions. */ export interface ProtectedRouteProps { children: ReactNode; requireAuth?: boolean; requiredRole?: string; requiredPermissions?: string[]; requireAnyPermission?: boolean; fallback?: ReactNode; redirectTo?: string; showLoading?: boolean; } export declare function ProtectedRoute({ children, requireAuth, requiredRole, requiredPermissions, requireAnyPermission, fallback, redirectTo, showLoading, }: ProtectedRouteProps): string | number | bigint | true | import("react/jsx-runtime").JSX.Element | Iterable | Promise> | Iterable | null | undefined>; /** * Component for guest-only routes (login, register, etc.) */ interface GuestOnlyRouteProps { children: ReactNode; redirectTo?: string; } export declare function GuestOnlyRoute({ children, redirectTo, }: GuestOnlyRouteProps): import("react/jsx-runtime").JSX.Element | null; /** * Hook for requiring authentication */ export declare function useRequireAuth(options?: { redirectTo?: string; }): { isAuthenticated: boolean; isLoading: boolean; hasAccess: boolean; }; export { AuthContext }; export default AuthProvider; //# sourceMappingURL=provider.d.ts.map