@reactit/auth
Version:
The ultimate token basted authentication solution for React
25 lines (24 loc) • 1.18 kB
TypeScript
import { ReactNode } from 'react';
import { AuthActionResult, AuthState } from './types';
import { Token } from './token';
import { StorageTypes } from '@reactit/hooks';
export interface AuthProviderProps<U, SI = any, RF = void, SO = void> {
authStorage?: StorageTypes;
authPrefix?: string;
devToken?: string;
devSignedIn?: boolean;
devUser?: U;
doSignIn?: (ctx: AuthState<U>, input: SI | undefined) => Promise<AuthActionResult<U>>;
doRenew?: (ctx: AuthState<U>, input: RF | undefined) => Promise<AuthActionResult<U>>;
doSignOut?: (ctx: AuthState<U>, input: SO | undefined) => Promise<void>;
onTokenChange?: (ctx: AuthState<U>, token: Token | undefined) => void;
renewOnMount?: boolean;
}
/**
* Authentication provider to wrap the entire application. This
* component does contain all the behavioural logic for the entire
* authentication workflow.
*/
export declare function AuthProvider<U, SI = any, RF = void, SO = void>({ authStorage, authPrefix, devToken, devSignedIn, devUser, doSignIn, doRenew, doSignOut, onTokenChange, renewOnMount, children, }: AuthProviderProps<U, SI, RF, SO> & {
children: ReactNode;
}): JSX.Element;