UNPKG

balena-auth

Version:
79 lines (78 loc) 1.72 kB
/** * @module api-key */ import type { Token } from './token'; import { TokenType } from './token'; export declare class APIKey implements Token { /** * @member type * @summary Get the type of token * @public * * @returns {TokenType} the type of token * * @example * console.log(token.type) */ readonly type = TokenType.APIKey; /** * @member key * @summary Get the original string key * @public * * @returns {string} string * * @example * console.log(token.key()) */ readonly key: string; constructor(key: string); /** * @member isValid * @summary Check if a token is valid * @function * @public * * @returns {boolean} is valid * * @example * console.log(token.isValid()); */ isValid: () => boolean; /** * @member getAge * @summary Get the token age * @function * @public * * @returns {number | undefined} * * @example * console.log(token.getAge()); */ getAge: () => number | undefined; /** * @member isExpired * @summary Check whether the token has expired * @function * @public * * @returns {boolean} * * @example * console.log(token.isExpired()); */ isExpired: () => boolean; /** * @member get2FAStatus * @summary Gets whether passing a 2FA challenge is pending, passed or not required. * @function * @public * * @returns {'not_required'|'pending'|'passed'} * * @example * console.log(token.get2FAStatus()) */ get2FAStatus: () => 'not_required' | 'pending' | 'passed'; }