n8n
Version:
n8n Workflow Automation Tool
57 lines • 2.55 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedactionContextHook = void 0;
const decorators_1 = require("@n8n/decorators");
const instance_redaction_enforcement_service_1 = require("./instance-redaction-enforcement.service");
function deriveEnforcedPolicy(enforcement) {
const { manual, production } = enforcement;
if (manual && production)
return 'all';
if (!manual && production)
return 'non-manual';
if (manual && !production)
return 'manual-only';
return 'none';
}
let RedactionContextHook = class RedactionContextHook {
constructor(instanceRedactionEnforcementService) {
this.instanceRedactionEnforcementService = instanceRedactionEnforcementService;
this.hookDescription = {
name: 'RedactionContextHook',
};
}
isApplicableToTriggerNode(_nodeType) {
return false;
}
async execute(options) {
const context = await this.instanceRedactionEnforcementService.buildContext();
const policy = context?.enforcement.enforced
? deriveEnforcedPolicy(context.enforcement)
: (options.workflow.settings?.redactionPolicy ?? 'none');
return {
contextUpdate: {
redaction: {
version: 1,
policy,
},
},
};
}
};
exports.RedactionContextHook = RedactionContextHook;
exports.RedactionContextHook = RedactionContextHook = __decorate([
(0, decorators_1.ContextEstablishmentHook)({
alwaysExecute: true,
}),
__metadata("design:paramtypes", [instance_redaction_enforcement_service_1.InstanceRedactionEnforcementService])
], RedactionContextHook);
//# sourceMappingURL=redaction-context-hook.js.map