UNPKG

lbx-jwt

Version:

Provides JWT authentication for loopback applications. Includes storing roles inside tokens and handling refreshing. Built-in reuse detection.

42 lines (41 loc) 1.34 kB
import { Model } from '@loopback/repository'; import { BiometricCredentials, Jwt } from '../../models'; /** * The authentication data that is send to the user. * This is needed eg. To Display navigation elements only if the user has the required role. */ export declare class AuthData<RoleType extends string> extends Model { /** * The token used for authenticating requests. * Consists of the string value and the expirationDate value. */ accessToken: Jwt; /** * The token used for refreshing the access token. * Consists of the string value and the expirationDate value. */ refreshToken: Jwt; /** * All roles of the currently logged in user. * Consists of an displayName and the actual string value. */ roles: RoleType[]; /** * Whether or not two factor authentication is enabled. */ twoFactorEnabled: boolean; /** * The biometric credentials of the user. * This is an array because a user might have multiple devices with a fingerprint sensor. */ biometricCredentials: BiometricCredentials[]; /** * The id of the currently logged in user. */ userId: string; /** * Helper for defining the roles open api. */ private readonly roleValues; constructor(data?: Partial<AuthData<RoleType>>); }