@oondemand/oon-core-back 0.4.13 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/utils/instanceActivation.js +18 -0
- package/src/index.js +2 -0
package/package.json
CHANGED
|
@@ -416,6 +416,23 @@ function operationalIdentity(instance) {
|
|
|
416
416
|
return instance?.deploymentId || instance?.instanceId;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
+
async function operationalRequestHeaders(options = {}, dependencies = {}) {
|
|
420
|
+
const loadInstance = dependencies.ensureInstance || ensureInstance;
|
|
421
|
+
const buildHeaders = dependencies.instanceHeaders || instanceHeaders;
|
|
422
|
+
const instance = await loadInstance();
|
|
423
|
+
if (!operationalIdentity(instance) || !instance?.credentialEncrypted) {
|
|
424
|
+
throw new GenericError("Credencial operacional do deployment indisponível.", {
|
|
425
|
+
statusCode: 423,
|
|
426
|
+
code: "OPERATIONAL_CREDENTIAL_REQUIRED",
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
...buildHeaders(instance),
|
|
431
|
+
...(options.tenantId ? { "x-oon-tenant-id": String(options.tenantId) } : {}),
|
|
432
|
+
...(options.correlationId ? { "x-correlation-id": String(options.correlationId) } : {}),
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
|
|
419
436
|
function validateUrl(value) {
|
|
420
437
|
const url = new URL(value);
|
|
421
438
|
if (!["http:", "https:"].includes(url.protocol)) throw new Error();
|
|
@@ -513,6 +530,7 @@ module.exports = {
|
|
|
513
530
|
decrypt,
|
|
514
531
|
instanceHeaders,
|
|
515
532
|
operationalIdentity,
|
|
533
|
+
operationalRequestHeaders,
|
|
516
534
|
validateParams,
|
|
517
535
|
providerPost,
|
|
518
536
|
providerPayload,
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const rbacPolicy = require("./core/rbac/policy");
|
|
|
13
13
|
const omieModule = require("./modules/omie");
|
|
14
14
|
const integrations = require("./modules/integrations");
|
|
15
15
|
const capabilities = require("./capabilities");
|
|
16
|
+
const { operationalRequestHeaders } = require("./core/utils/instanceActivation");
|
|
16
17
|
const appManifest = require("./manifest/appManifest");
|
|
17
18
|
const domainManifest = require("./manifest/domainManifest");
|
|
18
19
|
const domainRules = require("./manifest/domainRules");
|
|
@@ -86,6 +87,7 @@ module.exports = {
|
|
|
86
87
|
enqueueIntegration: integrations.enqueueIntegration,
|
|
87
88
|
receiveIntegrationWebhook: integrations.receiveWebhook,
|
|
88
89
|
capabilities,
|
|
90
|
+
operationalRequestHeaders,
|
|
89
91
|
PdfRenderingError: capabilities.PdfRenderingError,
|
|
90
92
|
GenericError, registry,
|
|
91
93
|
};
|