export interface AuthServerOptions { accessToken: AuthAccessToken; refreshToken?: AuthRefreshToken; } export interface AuthAccessToken { /** * Name of the cookie for the accessToken */ cookie?: string; /** * Returns the cookie options that will be used before creating or removing an * accessToken as a cookie * @param accessToken will be an empty string when removing the cookie */ cookieOptions?: CookieOptions | ((accessToken: string) => CookieOptions); /** * Scope that will be used by the accessToken */ scope?: AuthScope; /** * Creates a payload based in some data */ getPayload?(data: StringAnyMap): StringAnyMap; /** * Creates the accessToken */ create?(payload: StringAnyMap): string; /** * Verifies an accessToken and returns its payload */ verify?(accessToken: string): StringAnyMap; } export interface AuthRefreshToken { /** * Name of the cookie for the refreshToken */ cookie?: string; /** * Returns the cookie options that will be used before creating or removing an * refreshToken as a cookie * @param refreshToken will be an empty string when removing the cookie */ cookieOptions?: CookieOptions | ((refreshToken: string) => CookieOptions); /** * Returns the payload in a refreshToken that can be used to create an * accessToken * @param reset Refresh the cookie of a refreshToken */ getPayload( refreshToken: string, reset: () => void ): Promise; /** * Creates the refreshToken */ create(data: StringAnyMap): Promise; /** * Removes the refreshToken */ remove(refreshToken: string): Promise | boolean; } export interface AuthScope { create(scope: string[]): string; parse(scope: string): string[]; has(scope: string[], perm: string | string[]): boolean; } export interface AuthPayload { create(payload: StringAnyMap): StringAnyMap; parse(reversePayload: StringAnyMap): StringAnyMap; } export interface StringStringMap { [key: string]: string; } export interface StringAnyMap { [key: string]: any; }