@nestjs-cognito/core
Version:
Cognito Provider for NestJS
58 lines • 2.13 kB
JavaScript
;
var _CognitoJwtVerifier_props;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CognitoJwtVerifier = void 0;
const tslib_1 = require("tslib");
/**
* Represents a Cognito JWT Verifier.
*/
class CognitoJwtVerifier {
/**
* Creates a new instance of CognitoJwtVerifier.
* @param props - The properties for the CognitoJwtVerifier.
*/
constructor(props) {
_CognitoJwtVerifier_props.set(this, void 0);
tslib_1.__classPrivateFieldSet(this, _CognitoJwtVerifier_props, props, "f");
}
/**
* Creates a new instance of CognitoJwtVerifier.
* @param props - The properties for the CognitoJwtVerifier.
* @returns A new instance of CognitoJwtVerifier.
*/
static create(props) {
return new CognitoJwtVerifier(props);
}
/**
* Gets the JWT verifier.
* @returns The JWT verifier.
*/
get jwtVerifier() {
return tslib_1.__classPrivateFieldGet(this, _CognitoJwtVerifier_props, "f").jwtVerifier;
}
/**
* Gets the JWT RSA verifier.
* @returns The JWT RSA verifier.
*/
get jwtRsaVerifier() {
return tslib_1.__classPrivateFieldGet(this, _CognitoJwtVerifier_props, "f").jwtRsaVerifier;
}
/**
* Verifies the given token.
* @param token - The token to verify.
* @returns A promise that resolves to the verification result.
* @throws An error if no verifier is found.
*/
verify(token) {
if (tslib_1.__classPrivateFieldGet(this, _CognitoJwtVerifier_props, "f").jwtVerifier) {
return tslib_1.__classPrivateFieldGet(this, _CognitoJwtVerifier_props, "f").jwtVerifier.verify(token);
}
if (tslib_1.__classPrivateFieldGet(this, _CognitoJwtVerifier_props, "f").jwtRsaVerifier) {
return tslib_1.__classPrivateFieldGet(this, _CognitoJwtVerifier_props, "f").jwtRsaVerifier.verify(token);
}
throw new Error("No verifier found.");
}
}
exports.CognitoJwtVerifier = CognitoJwtVerifier;
_CognitoJwtVerifier_props = new WeakMap();
//# sourceMappingURL=cognito-jwt-verifier.adapter.js.map