UNPKG

@adonisjs/auth

Version:

Official authentication provider for Adonis framework

44 lines (43 loc) 1.29 kB
"use strict"; /* * @adonisjs/auth * * (c) Harminder Virk <virk@adonisjs.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.OpaqueToken = void 0; /** * Opaque token represents a persisted token generated for a given user * * Calling `opaqueToken.toJSON()` will give you an object, that you can send back * as response to share the token with the client. */ class OpaqueToken { constructor(name, // Name associated with the token token, // The raw token value. Only available for the first time user // The user for which the token is generated ) { this.name = name; this.token = token; this.user = user; /** * The type of the token. Always set to bearer */ this.type = 'bearer'; } /** * Shareable version of the token */ toJSON() { return { type: this.type, token: this.token, ...(this.expiresAt ? { expires_at: this.expiresAt.toISO() || undefined } : {}), ...(this.expiresIn ? { expires_in: this.expiresIn } : {}), }; } } exports.OpaqueToken = OpaqueToken;