@reactit/auth
Version:
The ultimate token basted authentication solution for React
26 lines (25 loc) • 880 B
TypeScript
import { Token, TokenBundle } from './token';
export interface AuthState<U> {
initialized: boolean;
auth?: TokenBundle;
renew?: TokenBundle;
user?: U;
}
export interface AuthActionResult<U> {
token: Token;
tokenExpiration: number | Date | undefined;
renew?: Token;
renewExpiration?: number | Date | undefined;
user?: U;
}
export interface AuthActions<U, SI = any, RF = void, SO = void> {
signIn: (input?: SI) => void;
renewToken: (input?: RF) => void;
signOut: (input?: SO) => void;
signInAsync: (input?: SI) => Promise<AuthActionResult<U>>;
renewTokenAsync: (input?: RF) => Promise<AuthActionResult<U>>;
signOutAsync: (input?: SO) => Promise<void>;
setAuth: (value: AuthActionResult<U>) => void;
}
export interface AuthContext<U, SI = any, RF = void, SO = void> extends AuthActions<U, SI, RF, SO>, AuthState<U> {
}