@xeedware/cognito-jwt
Version:
AWS Cognito AccessToken and IdToken classes.
75 lines • 1.89 kB
JavaScript
;
// https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccessToken = void 0;
const JsonWebToken_1 = require("./JsonWebToken");
/** @class */
class AccessToken extends JsonWebToken_1.JsonWebToken {
/**
* Constructs a new CognitoJwtToken object
* @param token The JWT token.
* @param {string} [pem]
* @param {VerifyOptions} [options]
*/
constructor(token, pem, options) {
super(token, pem, options);
}
/**
* Get the JWT payload
* @returns {AccessTokenPayload}
*/
getAccessTokenPayload() {
return super.getJwtPayload();
}
/**
* Get the issuer.
* @returns {string}
*/
get iss() {
return this.getAccessTokenPayload().iss;
}
/**
* Get the subject.
* @returns {string}
*/
get sub() {
return this.getAccessTokenPayload().sub;
}
/**
* Get the intended audience.
* @returns {string}
*/
get aud() {
return this.getAccessTokenPayload().aud;
}
/**
* Get the expiration datetime (seconds since the Epoch).
* @returns {number}
*/
get exp() {
return this.getAccessTokenPayload().exp;
}
/**
* Get the datetime this access token should not be used until (seconds since the Epoch).
* @returns {number}
*/
get nbf() {
return this.getAccessTokenPayload().nbf;
}
/**
* Get the datetime the token was issued (seconds since the Epoch).
* @returns {number}
*/
get iat() {
return this.getAccessTokenPayload().iat;
}
/**
* Get the JWT ID.
* @returns {string}
*/
get jti() {
return this.getAccessTokenPayload().jti;
}
}
exports.AccessToken = AccessToken;
//# sourceMappingURL=AccessToken.js.map