@reactit/auth
Version:
The ultimate token basted authentication solution for React
29 lines (28 loc) • 1.06 kB
TypeScript
import { AuthContext } from './types';
import { Token } from './token';
/**
* Provide access to all the authentication functionalities
*/
export interface UseAuthReturn<U, SI = any, RF = void, SO = void> extends Omit<AuthContext<U, SI, RF, SO>, 'auth' | 'renew'> {
isAuthenticated: boolean;
isRenewEnabled: boolean;
}
export declare function useAuth<U, SI = any, RF = void, SO = void>(): UseAuthReturn<U, SI, RF, SO>;
/**
* Returns true if there is an active authentication ongoing
*/
export declare function useIsAuthenticated(): boolean;
/**
* Returns the authenticated user (as returned by the last
* doSignIn or doRenew
*/
export declare function useAuthUser<U>(): U | undefined;
/**
* Returns the latest authentication token if present
*/
export declare function useAuthToken(): Token | undefined;
/**
* Effect called when the authentication state changes due to
* any reason.
*/
export declare function useAuthChangeEffect<U, SI = any, RF = void, SO = void>(effect: (context: AuthContext<U, SI, RF, SO>) => (void | (() => void))): void;