UNPKG

caplib

Version:

Credentialless Authentication Protocol Library for Web Applications

85 lines (82 loc) 2.12 kB
import { ReactNode } from 'react'; interface User { wallet_address: string; first_name?: string; last_name?: string; entity_name?: string; account_type: 'human' | 'entity'; email?: string; role: string; created_at: string; } interface NewUserData { wallet_address: string; first_name?: string; last_name?: string; entity_name?: string; account_type?: 'human' | 'entity'; email?: string; role?: string; } interface UserDetails { first_name: string; last_name: string; entity_name: string; email: string; role: string; } interface CapAuthConfig { appName: string; appDescription: string; theme?: { primary: string; secondary: string; }; logo?: { src: string; width: number; height: number; }; customStyles?: { container?: string; card?: string; button?: string; input?: string; select?: string; }; redirectPath?: string; refreshPageOnAuth?: boolean; modalMode?: boolean; timeouts?: { authentication?: number; polling?: number; }; encryptionKey?: string; enableMobileWallet?: boolean; mobileWalletScheme?: string; debug?: boolean; } interface AuthHandlerConfig { customValidation?: (walletAddress: string) => Promise<boolean>; validateUser?: (walletAddress: string) => Promise<User | null>; onNewUser?: (user: NewUserData) => Promise<void>; dbPath?: string; } interface CapAuthProps { onAuthenticated: (user: User) => void; config: CapAuthConfig; onError?: (error: Error) => void; } interface AuthProviderProps { children: ReactNode; config?: Partial<CapAuthConfig>; onAuthSuccess?: (user: User) => void; onAuthError?: (error: Error) => void; } interface AuthResponse { authenticated: boolean; userAddress?: string; user?: User; error?: string; } export type { AuthResponse as A, CapAuthConfig as C, NewUserData as N, User as U, UserDetails as a, AuthProviderProps as b, CapAuthProps as c, AuthHandlerConfig as d };