UNPKG

n8n

Version:

n8n Workflow Automation Tool

36 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertPackageImportApiKeyScopes = assertPackageImportApiKeyScopes; exports.assertVariableWritesAllowed = assertVariableWritesAllowed; exports.assertTagWritesAllowed = assertTagWritesAllowed; const forbidden_error_1 = require("../../../errors/response-errors/forbidden.error"); function assertPackageImportApiKeyScopes(apiKeyScopes, required) { if (apiKeyScopes === undefined) return; for (const scope of required) { if (!apiKeyScopes.includes(scope)) { throw new forbidden_error_1.ForbiddenError('Forbidden'); } } } function assertVariableWritesAllowed(options) { const { licenseState, apiKeyScopes, hasCreations, hasOverwrites } = options; if (!hasCreations && !hasOverwrites) return; if (!licenseState.isVariablesLicensed()) { throw new forbidden_error_1.ForbiddenError('Your license does not allow variables. Importing a package that writes variables requires a license that supports variables.'); } if (hasCreations) assertPackageImportApiKeyScopes(apiKeyScopes, ['variable:create']); if (hasOverwrites) assertPackageImportApiKeyScopes(apiKeyScopes, ['variable:update']); } function assertTagWritesAllowed(apiKeyScopes, tagPlans) { if (tagPlans.some((plan) => plan.creations.length > 0)) { assertPackageImportApiKeyScopes(apiKeyScopes, ['tag:create']); } if (tagPlans.some((plan) => plan.renames.length > 0 || plan.reconciles.length > 0)) { assertPackageImportApiKeyScopes(apiKeyScopes, ['tag:update']); } } //# sourceMappingURL=import-gates.js.map