Types
Last updated
This page lists every TypeScript interface the package exports.
AuthData
The user data signed into tokens and stored in refresh data.
- interface AuthData {
- id: string;
- name: string;
- email: string;
- thumbnail?: string;
- level?: number;
- role?: string;
- scope?: string[];
- }
id is passed to checkUserExists(). The whole object is serialized into Redis and returned unchanged as VerifyResult.data after a refresh.VerifyResult
The return value of
VerifyJWT(); see Verification Results for the flags.- interface VerifyResult {
- data?: AuthData;
- isAuth: boolean;
- isError: boolean;
- isGuest: boolean;
- }
TokenResult
The return value of
CreateJWT().- interface TokenResult {
- token: string;
- refresh_id: string;
- }
RefreshData
The JSON stored at
refresh:<refresh_id>.- interface RefreshData {
- data: AuthData;
- version: number;
- fp: string;
- expires_at: Date;
- issued_at: Date;
- }
JWTPayload
The fields of a decoded Access Token:
AuthData plus fp and refresh_id. Tokens issued by a refresh also carry version.- interface JWTPayload {
- id: string;
- name: string;
- email: string;
- thumbnail?: string;
- level?: number;
- role?: string;
- scope?: string[];
- fp: string;
- refresh_id: string;
- }
Config
The
init() argument; see Configuration for each field and its default.- interface Config {
- publicKeyPath?: string;
- privateKeyPath?: string;
- publicKey?: string;
- privateKey?: string;
- accessTokenExpires: number;
- refreshTokenExpires: number;
- isProd: boolean;
- domain?: string;
- redis: {
- host: string;
- port: number;
- password?: string;
- db?: number;
- };
- checkUserExists: (userId: string) => Promise<boolean>;
- AccessTokenCookieKey: string;
- RefreshTokenCookieKey: string;
- }