@narangcia-oss/cryptic-auth-client-react
Version:
React hooks and components for cryptic-auth authentication with seamless OAuth2 integration
37 lines • 1.4 kB
TypeScript
import { ReactNode } from "react";
import { AuthTokens, AuthConfig, UserCredentials, AuthUser } from "@narangcia-oss/cryptic-auth-client-plain-ts";
export interface AuthState {
isAuthenticated: boolean;
isLoading: boolean;
user: AuthUser | null;
tokens: AuthTokens | null;
error: string | null;
}
export interface AuthContextValue extends AuthState {
login: (credentials: UserCredentials) => Promise<void>;
signup: (credentials: UserCredentials) => Promise<void>;
logout: () => void;
oauthLogin: (provider: string, scopes?: string[]) => Promise<void>;
refreshToken: () => Promise<void>;
clearError: () => void;
}
export interface AuthProviderProps {
children: ReactNode;
config: AuthConfig;
/**
* Whether to automatically handle OAuth callbacks on mount
* @default true
*/
autoHandleOAuthCallback?: boolean;
/**
* Custom error handler for authentication errors
*/
onError?: (error: Error) => void;
/**
* Custom success handler for authentication success
*/
onAuthSuccess?: (user: AuthUser, tokens: AuthTokens) => void;
}
export declare function AuthProvider({ children, config, autoHandleOAuthCallback, onError, onAuthSuccess, }: AuthProviderProps): import("react/jsx-runtime").JSX.Element;
export declare function useAuth(): AuthContextValue;
//# sourceMappingURL=AuthContext.d.ts.map