UNPKG

@gsarthak783/accesskit-react

Version:

React SDK for AccessKit Authentication System

53 lines (49 loc) 1.85 kB
import React, { ReactNode } from 'react'; import { AuthConfig, TokenStorage, User, AuthClient } from '@gsarthak783/accesskit-auth'; export { ApiResponse, AuthConfig, AuthResponse, CreateUserData, LoginCredentials, TokenStorage, UpdateUserData, User } from '@gsarthak783/accesskit-auth'; interface AuthContextType { user: User | null; isLoading: boolean; isAuthenticated: boolean; login: (email: string, password: string) => Promise<void>; register: (userData: { email: string; password: string; firstName: string; lastName: string; username?: string; customFields?: Record<string, any>; }) => Promise<void>; logout: () => Promise<void>; updateProfile: (userData: Partial<User>) => Promise<void>; updatePassword: (currentPassword: string, newPassword: string) => Promise<void>; updateEmail: (newEmail: string, password: string) => Promise<{ email: string; isVerified: boolean; }>; reauthenticateWithCredential: (password: string) => Promise<{ authenticated: boolean; authenticatedAt: string; }>; requestPasswordReset: (email: string) => Promise<void>; resetPassword: (token: string, password: string) => Promise<void>; verifyEmail: (token: string) => Promise<void>; client: AuthClient; } interface AuthProviderProps { children: ReactNode; config: AuthConfig; storage?: TokenStorage; } declare const AuthProvider: React.FC<AuthProviderProps>; declare const useAuth: () => AuthContextType; interface LoginFormProps { onSuccess?: () => void; onError?: (error: Error) => void; className?: string; buttonText?: string; showSignupLink?: boolean; onSignupClick?: () => void; } declare const LoginForm: React.FC<LoginFormProps>; export { AuthProvider, LoginForm, useAuth };