UNPKG

1.28 kBTypeScriptView Raw
1import { DateTime } from 'luxon';
2import { OpaqueTokenContract } from '@ioc:Adonis/Addons/Auth';
3/**
4 * Opaque token represents a persisted token generated for a given user
5 *
6 * Calling `opaqueToken.toJSON()` will give you an object, that you can send back
7 * as response to share the token with the client.
8 */
9export declare class OpaqueToken implements OpaqueTokenContract<any> {
10 name: string;
11 token: string;
12 user: any;
13 /**
14 * The type of the token. Always set to bearer
15 */
16 type: "bearer";
17 /**
18 * The datetime in which the token will expire
19 */
20 expiresAt?: DateTime;
21 /**
22 * Time left until token gets expired
23 */
24 expiresIn?: number;
25 /**
26 * Any meta data attached to the token
27 */
28 meta: any;
29 /**
30 * Hash of the token saved inside the database. Make sure to never share
31 * this with the client
32 */
33 tokenHash: string;
34 constructor(name: string, // Name associated with the token
35 token: string, // The raw token value. Only available for the first time
36 user: any);
37 /**
38 * Shareable version of the token
39 */
40 toJSON(): {
41 expires_in?: number | undefined;
42 expires_at?: string | undefined;
43 type: "bearer";
44 token: string;
45 };
46}