UNPKG

react-laravel-sanctum

Version:

Easily integrate Laravel Sanctum and Breeze authentication into your React app.

46 lines (42 loc) 1.61 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { AxiosInstance } from 'axios'; import { ReactNode } from 'react'; interface AuthConfig { axiosInstance: AxiosInstance; signInRoute: string; signUpRoute?: string; authenticationCheckRoute: string; sendEmailVerificationRoute?: string; verifyEmailRoute?: (id: string, hash: string, expires: string, signature: string) => string; signOutRoute: string; } interface AuthContextType { user: Record<string, any> | null; authenticated: boolean | null; verified: boolean | null; loading: boolean; setUser: (user: Record<string, any> | null, authenticated: boolean, verified: boolean) => void; signIn: (credentials: Record<string, any>) => Promise<{ mustVerifyEmail: boolean; signedIn: boolean; user?: Record<string, any>; }>; signUp: (credentials: Record<string, any>) => Promise<{ mustVerifyEmail: boolean; signedIn: boolean; user?: Record<string, any>; }>; verifyEmail: (id: string, hash: string, expires: string, signature: string) => Promise<{}>; sendEmailVerification: () => Promise<void>; signOut: () => Promise<void>; handleSessionTimeout: (error: any) => void; } interface AuthProviderProps { children: ReactNode; emailVerification?: boolean; config: AuthConfig; onInitCheck?: boolean; } declare function AuthProvider({ children, emailVerification, config, onInitCheck, }: AuthProviderProps): react_jsx_runtime.JSX.Element; declare const useAuth: () => AuthContextType; export { AuthProvider, useAuth };