@mgcmnd/auth-client
Version:
Client-side authentication provider for mgcmnd.net services.
45 lines (41 loc) • 1.3 kB
TypeScript
import React from 'react';
interface AuthUser {
id: string;
email?: string;
name?: string;
picture?: string;
[key: string]: any;
}
interface AuthState {
isAuthenticated: boolean;
user: AuthUser | null;
isLoading: boolean;
error: string | null;
token: string | null;
}
interface AuthConfig {
authServerUrl?: string;
tokenStorageKey?: string;
redirectPath?: string;
onLoginSuccess?: (user: AuthUser, token: string) => void;
onLogoutSuccess?: () => void;
}
interface AuthContextType extends AuthState {
loginWithGoogle: (redirectPath?: string) => void;
loginWithGitHub: (redirectPath?: string) => void;
loginWithEmail: (email: string, redirectPath?: string) => Promise<void>;
logout: (redirectUrl?: string) => void;
handleCallback: () => void;
}
declare const AuthProvider: React.FC<{
children: React.ReactNode;
config?: AuthConfig;
}>;
declare const useAuth: () => AuthContextType;
interface AuthCallbackHandlerProps {
onSuccess?: () => void;
onError?: (error: string) => void;
loading?: React.ReactNode;
}
declare const AuthCallbackHandler: React.FC<AuthCallbackHandlerProps>;
export { AuthCallbackHandler, type AuthCallbackHandlerProps, type AuthConfig, AuthProvider, type AuthUser, useAuth };