@nestjs-mod/sso
Version:
NestJS SDK for Single Sign-On on NestJS and Angular with webhooks and social authorization (Wrapper for https://www.npmjs.com/package/@nestjs-mod/sso-rest-sdk)
40 lines • 1.72 kB
JavaScript
;
var SsoExceptionsFilter_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SsoExceptionsFilter = void 0;
const tslib_1 = require("tslib");
const common_1 = require("@nestjs/common");
const core_1 = require("@nestjs/core");
const sso_environments_1 = require("./sso.environments");
const sso_errors_1 = require("./sso.errors");
let SsoExceptionsFilter = SsoExceptionsFilter_1 = class SsoExceptionsFilter extends core_1.BaseExceptionFilter {
constructor(ssoStaticEnvironments) {
super();
this.ssoStaticEnvironments = ssoStaticEnvironments;
this.logger = new common_1.Logger(SsoExceptionsFilter_1.name);
}
catch(exception, host) {
if (!this.ssoStaticEnvironments.useFilters) {
super.catch(exception, host);
return;
}
if (exception instanceof sso_errors_1.SsoError) {
this.logger.error(exception, exception.stack);
super.catch(new common_1.HttpException({
code: sso_errors_1.SsoErrorEnum.FORBIDDEN,
message: exception.message,
}, common_1.HttpStatus.BAD_REQUEST), host);
}
else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.logger.error(exception, exception?.stack);
super.catch(exception, host);
}
}
};
exports.SsoExceptionsFilter = SsoExceptionsFilter;
exports.SsoExceptionsFilter = SsoExceptionsFilter = SsoExceptionsFilter_1 = tslib_1.__decorate([
(0, common_1.Catch)(sso_errors_1.SsoError),
tslib_1.__metadata("design:paramtypes", [sso_environments_1.SsoStaticEnvironments])
], SsoExceptionsFilter);
//# sourceMappingURL=sso.filter.js.map