UNPKG

@xeedware/cognito-jwt

Version:

AWS Cognito AccessToken and IdToken classes.

110 lines 2.74 kB
"use strict"; // Open ID Connect specification: http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims Object.defineProperty(exports, "__esModule", { value: true }); exports.CognitoIdToken = void 0; // tslint:disable:max-line-length const IdToken_1 = require("./IdToken"); /** @class */ class CognitoIdToken extends IdToken_1.IdToken { /** * Constructs a new CognitoJwtToken object * @param {string} token The JWT token. * @param {string} [pem] * @param {VerifyOptions} [options] */ constructor(token, pem, options) { super(token, pem, options); this.pem = pem; } /** * Get the JWT payload * @returns {CognitoIdTokenPayload} */ getCognitoIdTokenPayload() { return super.getJwtPayload(); } /** * Audience * @returns {string} */ get aud() { return this.getCognitoIdTokenPayload().aud; } /** * Authorization Time * @returns {number} */ get auth_time() { return this.getCognitoIdTokenPayload().auth_time; } /** * Cognito user pool groups to which authenticated user belongs. * @returns {string[]} */ get cognito_groups() { return this.getCognitoIdTokenPayload()['cognito:groups']; } /** * Cognito user pool username * @returns {string} */ get cognito_username() { return this.getCognitoIdTokenPayload()['cognito:username']; } /** * Event ID * @returns {string} */ get event_id() { return this.getCognitoIdTokenPayload().event_id; } /** * Expiration (in number of seconds since the Epoch). * @returns {number} */ get exp() { return this.getCognitoIdTokenPayload().exp; } /** * Issuer * @returns {string} */ get iss() { return this.getCognitoIdTokenPayload().iss; } /** * Issued At (in number of seconds since the Epoch). * @returns {number} */ get iat() { return this.getCognitoIdTokenPayload().iat; } /** * Intended scope. * @returns {string} */ get scope() { return this.getCognitoIdTokenPayload().scope; } /** * Intended token use. * * @deprecated since version 1.2.0. * Will be deleted in version 2.0.0. * Use token_use instead. * * @returns {string} */ get tokenUse() { return this.getCognitoIdTokenPayload().token_use; } /** * Intended token use. * @returns {string} */ get token_use() { return this.getCognitoIdTokenPayload().token_use; } } exports.CognitoIdToken = CognitoIdToken; //# sourceMappingURL=CognitoIdToken.js.map