// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved. // Node module: @loopback/authentication-jwt // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {TokenService, UserService} from '@loopback/authentication'; import {BindingKey} from '@loopback/core'; import {User} from './models'; import {Credentials} from './services/user.service'; import {RefreshTokenService} from './types'; export namespace TokenServiceConstants { export const TOKEN_SECRET_VALUE = 'myjwts3cr3t'; export const TOKEN_EXPIRES_IN_VALUE = '21600'; } export namespace TokenServiceBindings { export const TOKEN_SECRET = BindingKey.create( 'authentication.jwt.secret', ); export const TOKEN_EXPIRES_IN = BindingKey.create( 'authentication.jwt.expires.in.seconds', ); export const TOKEN_SERVICE = BindingKey.create( 'services.authentication.jwt.tokenservice', ); } export namespace UserServiceBindings { export const USER_SERVICE = BindingKey.create>( 'services.user.service', ); export const DATASOURCE_NAME = 'jwtdb'; export const USER_REPOSITORY = 'repositories.UserRepository'; export const USER_CREDENTIALS_REPOSITORY = 'repositories.UserCredentialsRepository'; } /** * Constant values used when generating refresh token. */ export namespace RefreshTokenConstants { /** * The default secret used when generating refresh token. */ export const REFRESH_SECRET_VALUE = 'r3fr35htok3n'; /** * The default expiration time for refresh token. */ export const REFRESH_EXPIRES_IN_VALUE = '216000'; /** * The default issuer used when generating refresh token. */ export const REFRESH_ISSUER_VALUE = 'loopback4'; } /** * Bindings related to token refresh service. The omitted explanation can be * found in namespace `RefreshTokenConstants`. */ export namespace RefreshTokenServiceBindings { export const REFRESH_TOKEN_SERVICE = BindingKey.create( 'services.authentication.jwt.refresh.tokenservice', ); export const REFRESH_SECRET = BindingKey.create( 'authentication.jwt.refresh.secret', ); export const REFRESH_EXPIRES_IN = BindingKey.create( 'authentication.jwt.refresh.expires.in.seconds', ); export const REFRESH_ISSUER = BindingKey.create( 'authentication.jwt.refresh.issuer', ); /** * The backend datasource for refresh token's persistency. */ export const DATASOURCE_NAME = 'refreshdb'; /** * Key for the repository that stores the refresh token and its bound user * information */ export const REFRESH_REPOSITORY = 'repositories.RefreshTokenRepository'; }