UNPKG

@ouim/simple-logto

Version:

A simpler way to use @logto/react with prebuilt UI components and hooks for fast authentication setup

50 lines (49 loc) 1.37 kB
import type { LogtoConfig } from '@logto/react'; export type LogtoUser = { id: string; name?: string; email?: string; avatar?: string; [key: string]: any; }; export type AuthMiddleware = 'auth' | 'guest' | undefined; export interface NavigationOptions { replace?: boolean; force?: boolean; } export interface AuthOptions { middleware?: AuthMiddleware; redirectTo?: string; redirectIfAuthenticated?: string; navigationOptions?: NavigationOptions; } export interface AuthContextType { user: LogtoUser | null; isLoadingUser: boolean; signIn: (callbackUrl?: string, usePopup?: boolean) => Promise<void>; signOut: (options?: { callbackUrl?: string; global?: boolean; }) => Promise<void>; refreshAuth: () => Promise<void>; enablePopupSignIn?: boolean; } export interface AuthProviderProps { children: React.ReactNode; config: LogtoConfig; callbackUrl?: string; customNavigate?: (url: string, options?: NavigationOptions) => void; enablePopupSignIn?: boolean; } export interface CallbackPageProps { className?: string; loadingComponent?: React.ReactNode; successComponent?: React.ReactNode; onSuccess?: () => void; onError?: (error: Error) => void; } export interface AdditionalPage { link: string; text: string; icon?: React.ReactNode; }