@xeedware/cognito-jwt
Version:
AWS Cognito AccessToken and IdToken classes.
102 lines • 2.97 kB
JavaScript
;
// https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32
Object.defineProperty(exports, "__esModule", { value: true });
exports.CognitoAccessToken = void 0;
const AccessToken_1 = require("./AccessToken");
/** @class */
class CognitoAccessToken extends AccessToken_1.AccessToken {
/**
* Constructs a new CognitoAccessToken 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 {CognitoAccessTokenPayload}
*/
getCognitoAccessTokenPayload() {
return super.getJwtPayload();
}
/**
* Authentication Time: Time when the authentication occurred.
* The number of seconds from 1970-01-01T0:0:0Z as measured in UTC.
*/
get auth_time() {
return this.getCognitoAccessTokenPayload().auth_time;
}
/**
* Client ID: The AWS Cognito User Pool Application Client ID the token was issued to.
*/
get client_id() {
return this.getCognitoAccessTokenPayload().client_id;
}
/**
* Cognito user pool groups to which authenticated user belongs.
* @returns {string[]}
*/
get cognito_groups() {
return super.getJwtPayload()['cognito:groups'];
}
/**
* Device Key: Key assigned to device being used by the authenticated user.
*/
get device_key() {
return this.getCognitoAccessTokenPayload().device_key;
}
/**
* Email: Preferred email address of the authenticated user.
*/
get email() {
return this.getCognitoAccessTokenPayload().email;
}
/**
* Email Verified: A true or false value indicating if the user's
* email address has been verified.
*/
get email_verified() {
return this.getCognitoAccessTokenPayload().email_verified;
}
/**
* Event ID
* @returns {string}
*/
get event_id() {
return super.getJwtPayload().event_id;
}
/**
* String containing a space-separated list of scopes associated with this token.
*/
get scope() {
return this.getCognitoAccessTokenPayload().scope;
}
/**
* Token Use: 'access' or 'id'.
*
* @deprecated since version 1.2.0.
* Will be deleted in version 2.0.0.
* Use token_use instead.
*
*/
get tokenUse() {
return this.getCognitoAccessTokenPayload().token_use;
}
/**
* Token Use: 'access' or 'id'.
*/
get token_use() {
return this.getCognitoAccessTokenPayload().token_use;
}
/**
* The username of the authenticated AWS Cognito User Pool user.
*/
get username() {
return this.getCognitoAccessTokenPayload().username;
}
}
exports.CognitoAccessToken = CognitoAccessToken;
//# sourceMappingURL=CognitoAccessToken.js.map