@n8n/n8n-nodes-langchain
Version:
25 lines • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.requireTenantId = requireTenantId;
const n8n_workflow_1 = require("n8n-workflow");
const MULTI_TENANT_ALIASES = new Set(['common', 'organizations', 'consumers']);
const TENANT_ID_GUID = /^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/;
const TENANT_ID_DOMAIN = /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)*$/;
function requireTenantId(node, tenantId) {
const value = tenantId?.trim() ?? '';
if (!value) {
throw new n8n_workflow_1.NodeOperationError(node, 'Tenant ID is missing in the selected Microsoft Foundry (Entra ID) credential');
}
if (MULTI_TENANT_ALIASES.has(value.toLowerCase())) {
throw new n8n_workflow_1.NodeOperationError(node, `Tenant ID cannot be "${value}"`, {
description: 'The node signs in as the application, and Entra issues an app-only token for one named tenant. Use the Directory (tenant) ID of the app registration.',
});
}
if (!TENANT_ID_GUID.test(value) && !TENANT_ID_DOMAIN.test(value)) {
throw new n8n_workflow_1.NodeOperationError(node, 'Tenant ID is not a Directory ID or a domain', {
description: 'Use the Directory (tenant) ID of the app registration.',
});
}
return value;
}
//# sourceMappingURL=requireTenantId.js.map