@adcp/sdk 15.9.1 → 16.0.0-beta.2
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/bin/adcp-identity.js +74 -0
- package/bin/adcp.js +2 -0
- package/dist/lib/adapters/keyed-account-backend.d.mts +37 -0
- package/dist/lib/adapters/keyed-account-backend.d.ts +37 -0
- package/dist/lib/adapters/keyed-account-backend.js +121 -0
- package/dist/lib/adapters/keyed-account-backend.mjs +94 -0
- package/dist/lib/adapters/keyed-account-store.d.mts +28 -0
- package/dist/lib/adapters/keyed-account-store.d.ts +28 -0
- package/dist/lib/adapters/keyed-account-store.js +227 -0
- package/dist/lib/adapters/keyed-account-store.mjs +203 -0
- package/dist/lib/core/SingleAgentClient.d.mts +25 -2
- package/dist/lib/core/SingleAgentClient.d.ts +25 -2
- package/dist/lib/core/SingleAgentClient.js +280 -62
- package/dist/lib/core/SingleAgentClient.mjs +282 -57
- package/dist/lib/core/TaskExecutor.d.mts +6 -0
- package/dist/lib/core/TaskExecutor.d.ts +6 -0
- package/dist/lib/core/TaskExecutor.js +66 -5
- package/dist/lib/core/TaskExecutor.mjs +71 -5
- package/dist/lib/core/postgres-webhook-registration-store.js +32 -5
- package/dist/lib/core/postgres-webhook-registration-store.mjs +32 -5
- package/dist/lib/core/redis-webhook-registration-store.js +23 -1
- package/dist/lib/core/redis-webhook-registration-store.mjs +23 -1
- package/dist/lib/core/webhook-registration.d.mts +7 -1
- package/dist/lib/core/webhook-registration.d.ts +7 -1
- package/dist/lib/core/webhook-registration.js +24 -2
- package/dist/lib/core/webhook-registration.mjs +23 -2
- package/dist/lib/identity-3.3/generated-compat.d.mts +34 -0
- package/dist/lib/identity-3.3/generated-compat.d.ts +34 -0
- package/dist/lib/identity-3.3/generated-compat.js +16 -0
- package/dist/lib/identity-3.3/generated-compat.mjs +0 -0
- package/dist/lib/identity-3.3/index.d.mts +10 -0
- package/dist/lib/identity-3.3/index.d.ts +10 -0
- package/dist/lib/identity-3.3/index.js +79 -0
- package/dist/lib/identity-3.3/index.mjs +50 -0
- package/dist/lib/identity-3.3/lifecycle.d.mts +125 -0
- package/dist/lib/identity-3.3/lifecycle.d.ts +125 -0
- package/dist/lib/identity-3.3/lifecycle.js +294 -0
- package/dist/lib/identity-3.3/lifecycle.mjs +272 -0
- package/dist/lib/identity-3.3/revocation.d.mts +86 -0
- package/dist/lib/identity-3.3/revocation.d.ts +86 -0
- package/dist/lib/identity-3.3/revocation.js +308 -0
- package/dist/lib/identity-3.3/revocation.mjs +286 -0
- package/dist/lib/identity-3.3/schemas.draft.d.mts +2472 -0
- package/dist/lib/identity-3.3/schemas.draft.d.ts +2472 -0
- package/dist/lib/identity-3.3/schemas.draft.js +1448 -0
- package/dist/lib/identity-3.3/schemas.draft.mjs +1428 -0
- package/dist/lib/identity-3.3/server.d.mts +46 -0
- package/dist/lib/identity-3.3/server.d.ts +46 -0
- package/dist/lib/identity-3.3/server.js +279 -0
- package/dist/lib/identity-3.3/server.mjs +260 -0
- package/dist/lib/identity-3.3/store.d.mts +24 -0
- package/dist/lib/identity-3.3/store.d.ts +24 -0
- package/dist/lib/identity-3.3/store.js +191 -0
- package/dist/lib/identity-3.3/store.mjs +169 -0
- package/dist/lib/identity-3.3/trust.d.mts +155 -0
- package/dist/lib/identity-3.3/trust.d.ts +155 -0
- package/dist/lib/identity-3.3/trust.js +383 -0
- package/dist/lib/identity-3.3/trust.mjs +342 -0
- package/dist/lib/identity-3.3/types.d.mts +155 -0
- package/dist/lib/identity-3.3/types.d.ts +155 -0
- package/dist/lib/identity-3.3/types.js +16 -0
- package/dist/lib/identity-3.3/types.mjs +0 -0
- package/dist/lib/identity-3.3/validation.d.mts +2 -0
- package/dist/lib/identity-3.3/validation.d.ts +2 -0
- package/dist/lib/identity-3.3/validation.js +125 -0
- package/dist/lib/identity-3.3/validation.mjs +91 -0
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +2 -0
- package/dist/lib/protocols/index.d.mts +1 -1
- package/dist/lib/protocols/index.d.ts +1 -1
- package/dist/lib/protocols/index.js +2 -2
- package/dist/lib/protocols/index.mjs +2 -2
- package/dist/lib/reporting/azure/index.d.mts +5 -0
- package/dist/lib/reporting/azure/index.d.ts +5 -0
- package/dist/lib/reporting/azure/index.js +26 -7
- package/dist/lib/reporting/azure/index.mjs +26 -7
- package/dist/lib/reporting/bigquery/index.d.mts +39 -5
- package/dist/lib/reporting/bigquery/index.d.ts +39 -5
- package/dist/lib/reporting/bigquery/index.js +26 -20
- package/dist/lib/reporting/bigquery/index.mjs +26 -20
- package/dist/lib/reporting/gcs/adapter.d.mts +8 -1
- package/dist/lib/reporting/gcs/adapter.d.ts +8 -1
- package/dist/lib/reporting/gcs/errors.d.mts +6 -0
- package/dist/lib/reporting/gcs/errors.d.ts +6 -0
- package/dist/lib/reporting/gcs/fence.d.mts +5 -0
- package/dist/lib/reporting/gcs/fence.d.ts +5 -0
- package/dist/lib/reporting/gcs/index.d.mts +9 -0
- package/dist/lib/reporting/gcs/index.d.ts +9 -0
- package/dist/lib/reporting/gcs/reader.d.mts +27 -3
- package/dist/lib/reporting/gcs/reader.d.ts +27 -3
- package/dist/lib/reporting/gcs/row-provider.d.mts +7 -0
- package/dist/lib/reporting/gcs/row-provider.d.ts +7 -0
- package/dist/lib/reporting/gcs/row-provider.js +34 -14
- package/dist/lib/reporting/gcs/row-provider.mjs +34 -14
- package/dist/lib/reporting/ledger/change-feed.d.mts +22 -1
- package/dist/lib/reporting/ledger/change-feed.d.ts +22 -1
- package/dist/lib/reporting/ledger/index.d.mts +11 -0
- package/dist/lib/reporting/ledger/index.d.ts +11 -0
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +8 -0
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +8 -0
- package/dist/lib/reporting/ledger/managed-router.d.mts +27 -2
- package/dist/lib/reporting/ledger/managed-router.d.ts +27 -2
- package/dist/lib/reporting/ledger/managed.d.mts +86 -6
- package/dist/lib/reporting/ledger/managed.d.ts +86 -6
- package/dist/lib/reporting/ledger/notification-activity.d.mts +65 -3
- package/dist/lib/reporting/ledger/notification-activity.d.ts +65 -3
- package/dist/lib/reporting/ledger/object-writes.d.mts +64 -5
- package/dist/lib/reporting/ledger/object-writes.d.ts +64 -5
- package/dist/lib/reporting/ledger/postgres.d.mts +43 -9
- package/dist/lib/reporting/ledger/postgres.d.ts +43 -9
- package/dist/lib/reporting/ledger/postgres.js +43 -27
- package/dist/lib/reporting/ledger/postgres.mjs +43 -27
- package/dist/lib/reporting/ledger/row-encoding.d.mts +92 -6
- package/dist/lib/reporting/ledger/row-encoding.d.ts +92 -6
- package/dist/lib/reporting/ledger/row-encoding.js +8 -4
- package/dist/lib/reporting/ledger/row-encoding.mjs +6 -3
- package/dist/lib/reporting/ledger/row-storage-errors.d.mts +11 -1
- package/dist/lib/reporting/ledger/row-storage-errors.d.ts +11 -1
- package/dist/lib/reporting/ledger/row-storage-migration.d.mts +19 -1
- package/dist/lib/reporting/ledger/row-storage-migration.d.ts +19 -1
- package/dist/lib/reporting/ledger/row-storage-migration.js +133 -18
- package/dist/lib/reporting/ledger/row-storage-migration.mjs +133 -18
- package/dist/lib/reporting/ledger/row-storage-object.d.mts +103 -12
- package/dist/lib/reporting/ledger/row-storage-object.d.ts +103 -12
- package/dist/lib/reporting/ledger/row-storage-object.js +106 -31
- package/dist/lib/reporting/ledger/row-storage-object.mjs +104 -31
- package/dist/lib/reporting/ledger/row-storage.d.mts +87 -20
- package/dist/lib/reporting/ledger/row-storage.d.ts +87 -20
- package/dist/lib/reporting/ledger/row-storage.js +126 -66
- package/dist/lib/reporting/ledger/row-storage.mjs +129 -67
- package/dist/lib/reporting/ledger/schedule.d.mts +13 -0
- package/dist/lib/reporting/ledger/schedule.d.ts +13 -0
- package/dist/lib/reporting/ledger/schedule.js +24 -0
- package/dist/lib/reporting/ledger/schedule.mjs +23 -0
- package/dist/lib/reporting/ledger/types.d.mts +23 -1
- package/dist/lib/reporting/ledger/types.d.ts +23 -1
- package/dist/lib/reporting/s3/index.d.mts +5 -0
- package/dist/lib/reporting/s3/index.d.ts +5 -0
- package/dist/lib/reporting/s3/index.js +37 -14
- package/dist/lib/reporting/s3/index.mjs +37 -14
- package/dist/lib/reporting/service/index.d.mts +10 -0
- package/dist/lib/reporting/service/index.d.ts +10 -0
- package/dist/lib/reporting/service/maintenance.d.mts +28 -2
- package/dist/lib/reporting/service/maintenance.d.ts +28 -2
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/account-sync-contract.d.mts +14 -0
- package/dist/lib/server/account-sync-contract.d.ts +14 -0
- package/dist/lib/server/account-sync-contract.js +225 -0
- package/dist/lib/server/account-sync-contract.mjs +197 -0
- package/dist/lib/server/adcp-server.js +5 -0
- package/dist/lib/server/adcp-server.mjs +10 -0
- package/dist/lib/server/auth-signature.d.mts +15 -0
- package/dist/lib/server/auth-signature.d.ts +15 -0
- package/dist/lib/server/auth-signature.js +72 -2
- package/dist/lib/server/auth-signature.mjs +81 -2
- package/dist/lib/server/auth.d.mts +6 -0
- package/dist/lib/server/auth.d.ts +6 -0
- package/dist/lib/server/auth.js +6 -0
- package/dist/lib/server/auth.mjs +6 -0
- package/dist/lib/server/create-adcp-server.d.mts +19 -5
- package/dist/lib/server/create-adcp-server.d.ts +19 -5
- package/dist/lib/server/create-adcp-server.js +259 -19
- package/dist/lib/server/create-adcp-server.mjs +266 -10
- package/dist/lib/server/decisioning/account.d.mts +24 -1
- package/dist/lib/server/decisioning/account.d.ts +24 -1
- package/dist/lib/server/decisioning/index.d.mts +1 -1
- package/dist/lib/server/decisioning/index.d.ts +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.d.mts +0 -50
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +0 -50
- package/dist/lib/server/decisioning/runtime/from-platform.js +61 -11
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +65 -12
- package/dist/lib/server/index.d.mts +2 -0
- package/dist/lib/server/index.d.ts +2 -0
- package/dist/lib/server/index.js +12 -0
- package/dist/lib/server/index.mjs +12 -0
- package/dist/lib/server/notification-subscriptions/runtime.js +9 -1
- package/dist/lib/server/notification-subscriptions/runtime.mjs +9 -1
- package/dist/lib/server/notification-subscriptions/types.d.mts +5 -0
- package/dist/lib/server/notification-subscriptions/types.d.ts +5 -0
- package/dist/lib/server/principal/types.d.mts +1 -1
- package/dist/lib/server/principal/types.d.ts +1 -1
- package/dist/lib/server/serve.js +5 -0
- package/dist/lib/server/serve.mjs +5 -0
- package/dist/lib/server/webhook-delivery/recovery.d.mts +1 -0
- package/dist/lib/server/webhook-delivery/recovery.d.ts +1 -0
- package/dist/lib/server/webhook-delivery/recovery.js +4 -0
- package/dist/lib/server/webhook-delivery/recovery.mjs +4 -0
- package/dist/lib/server/webhook-emitter.d.mts +10 -0
- package/dist/lib/server/webhook-emitter.d.ts +10 -0
- package/dist/lib/server/webhook-emitter.js +22 -0
- package/dist/lib/server/webhook-emitter.mjs +22 -0
- package/dist/lib/signing/agent-context.d.mts +0 -5
- package/dist/lib/signing/agent-context.d.ts +0 -5
- package/dist/lib/signing/agent-context.js +9 -1
- package/dist/lib/signing/agent-context.mjs +9 -1
- package/dist/lib/signing/agent-fetch.js +27 -2
- package/dist/lib/signing/agent-fetch.mjs +32 -2
- package/dist/lib/signing/agent-resolver/canonicalize.d.mts +10 -15
- package/dist/lib/signing/agent-resolver/canonicalize.d.ts +10 -15
- package/dist/lib/signing/agent-resolver/canonicalize.js +17 -5
- package/dist/lib/signing/agent-resolver/canonicalize.mjs +16 -5
- package/dist/lib/signing/agent-resolver/index.d.mts +1 -0
- package/dist/lib/signing/agent-resolver/index.d.ts +1 -0
- package/dist/lib/signing/agent-resolver/index.js +5 -0
- package/dist/lib/signing/agent-resolver/index.mjs +3 -0
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +3 -2
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +3 -2
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +30 -3
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +30 -3
- package/dist/lib/signing/agent-resolver/strict-json.d.mts +2 -2
- package/dist/lib/signing/agent-resolver/strict-json.d.ts +2 -2
- package/dist/lib/signing/agent-resolver/strict-json.js +5 -3
- package/dist/lib/signing/agent-resolver/strict-json.mjs +5 -3
- package/dist/lib/signing/brand-jwks.d.mts +2 -2
- package/dist/lib/signing/brand-jwks.d.ts +2 -2
- package/dist/lib/signing/brand-jwks.js +4 -4
- package/dist/lib/signing/brand-jwks.mjs +4 -4
- package/dist/lib/signing/client.d.mts +1 -0
- package/dist/lib/signing/client.d.ts +1 -0
- package/dist/lib/signing/client.js +5 -0
- package/dist/lib/signing/client.mjs +3 -0
- package/dist/lib/signing/crypto.js +8 -0
- package/dist/lib/signing/crypto.mjs +9 -1
- package/dist/lib/signing/fetch-async.js +1 -1
- package/dist/lib/signing/fetch-async.mjs +1 -1
- package/dist/lib/signing/fetch.js +1 -1
- package/dist/lib/signing/fetch.mjs +1 -1
- package/dist/lib/signing/jwks-https.d.mts +1 -1
- package/dist/lib/signing/jwks-https.d.ts +1 -1
- package/dist/lib/signing/jwks-https.js +1 -1
- package/dist/lib/signing/jwks-https.mjs +1 -1
- package/dist/lib/signing/jwks.d.mts +11 -3
- package/dist/lib/signing/jwks.d.ts +11 -3
- package/dist/lib/signing/jwks.js +1 -1
- package/dist/lib/signing/jwks.mjs +1 -1
- package/dist/lib/signing/middleware.js +9 -0
- package/dist/lib/signing/middleware.mjs +14 -0
- package/dist/lib/signing/parser.d.mts +9 -6
- package/dist/lib/signing/parser.d.ts +9 -6
- package/dist/lib/signing/parser.js +82 -64
- package/dist/lib/signing/parser.mjs +83 -65
- package/dist/lib/signing/revocation.d.mts +4 -1
- package/dist/lib/signing/revocation.d.ts +4 -1
- package/dist/lib/signing/revocation.js +36 -3
- package/dist/lib/signing/revocation.mjs +34 -2
- package/dist/lib/signing/server.d.mts +1 -1
- package/dist/lib/signing/server.d.ts +1 -1
- package/dist/lib/signing/server.js +4 -0
- package/dist/lib/signing/server.mjs +4 -0
- package/dist/lib/signing/types.d.mts +3 -0
- package/dist/lib/signing/types.d.ts +3 -0
- package/dist/lib/signing/verifier.js +1 -1
- package/dist/lib/signing/verifier.mjs +1 -1
- package/dist/lib/signing/web-bot-auth.d.mts +191 -0
- package/dist/lib/signing/web-bot-auth.d.ts +191 -0
- package/dist/lib/signing/web-bot-auth.js +837 -0
- package/dist/lib/signing/web-bot-auth.mjs +796 -0
- package/dist/lib/signing/webhook-verifier.js +1 -1
- package/dist/lib/signing/webhook-verifier.mjs +1 -1
- package/dist/lib/testing/client.d.mts +1 -4
- package/dist/lib/testing/client.d.ts +1 -4
- package/dist/lib/testing/client.js +141 -20
- package/dist/lib/testing/client.mjs +137 -19
- package/dist/lib/testing/compliance/comply.js +29 -10
- package/dist/lib/testing/compliance/comply.mjs +37 -11
- package/dist/lib/testing/storyboard/account-sync-contract.d.mts +3 -0
- package/dist/lib/testing/storyboard/account-sync-contract.d.ts +3 -0
- package/dist/lib/testing/storyboard/account-sync-contract.js +79 -0
- package/dist/lib/testing/storyboard/account-sync-contract.mjs +55 -0
- package/dist/lib/testing/storyboard/default-invariants.js +2 -0
- package/dist/lib/testing/storyboard/default-invariants.mjs +2 -0
- package/dist/lib/testing/storyboard/runner.js +23 -8
- package/dist/lib/testing/storyboard/runner.mjs +24 -8
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/types/adcp.d.mts +4 -0
- package/dist/lib/types/adcp.d.ts +4 -0
- package/dist/lib/types/schemas.generated.d.ts +6 -6
- package/dist/lib/utils/capabilities.d.mts +1 -0
- package/dist/lib/utils/capabilities.d.ts +1 -0
- package/dist/lib/utils/capabilities.js +5 -0
- package/dist/lib/utils/capabilities.mjs +5 -0
- package/dist/lib/v2/projection/catalog-snapshot.js +3 -1
- package/dist/lib/v2/projection/catalog-snapshot.mjs +3 -1
- package/dist/lib/v2/projection/creative-delivery.d.mts +34 -10
- package/dist/lib/v2/projection/creative-delivery.d.ts +34 -10
- package/dist/lib/v2/projection/creative-delivery.js +26 -10
- package/dist/lib/v2/projection/creative-delivery.mjs +26 -10
- package/dist/lib/v2/projection/index.d.mts +1 -1
- package/dist/lib/v2/projection/index.d.ts +1 -1
- package/dist/lib/v2/projection/index.js +2 -0
- package/dist/lib/v2/projection/index.mjs +2 -0
- package/dist/lib/v2/projection/legacy-routes.d.mts +34 -2
- package/dist/lib/v2/projection/legacy-routes.d.ts +34 -2
- package/dist/lib/v2/projection/legacy-routes.js +35 -2
- package/dist/lib/v2/projection/legacy-routes.mjs +32 -2
- package/dist/lib/validation/schema-loader.d.mts +2 -0
- package/dist/lib/validation/schema-loader.d.ts +2 -0
- package/dist/lib/validation/schema-loader.js +43 -4
- package/dist/lib/validation/schema-loader.mjs +39 -3
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +2 -2
- package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +4 -0
- package/docs/guides/REPORTING-LEDGER-CUTOVER.md +1 -1
- package/docs/guides/REPORTING-LEDGER.md +99 -29
- package/docs/guides/REPORTING-OPERATIONS.md +29 -13
- package/docs/guides/REPORTING-STABILITY.md +76 -0
- package/docs/guides/account-resolution.md +101 -0
- package/docs/llms.txt +3 -2
- package/docs/migration-12-to-13.md +15 -0
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-agent-identity-3.3.md +494 -0
- package/docs/migration-agent-resolution-3.3.md +5 -0
- package/docs/migration-reporting-row-storage-alignment.md +137 -0
- package/examples/storyboards/account-sync-contract.yaml +57 -0
- package/package.json +17 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var account_sync_contract_exports = {};
|
|
20
|
+
__export(account_sync_contract_exports, {
|
|
21
|
+
checkSyncAccountRows: () => checkSyncAccountRows,
|
|
22
|
+
diagnoseAccountBilling: () => diagnoseAccountBilling,
|
|
23
|
+
existingSyncAccounts: () => existingSyncAccounts,
|
|
24
|
+
isolateAccountCallbackInput: () => isolateAccountCallbackInput,
|
|
25
|
+
projectAccountList: () => projectAccountList
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(account_sync_contract_exports);
|
|
28
|
+
var import_account_key = require('../core/account-key.js');
|
|
29
|
+
var import_account = require('./decisioning/account.js');
|
|
30
|
+
var import_async_outcome = require('./decisioning/async-outcome.js');
|
|
31
|
+
function isolateAccountCallbackInput(ctx) {
|
|
32
|
+
const descriptors = Object.getOwnPropertyDescriptors(ctx);
|
|
33
|
+
delete descriptors.input;
|
|
34
|
+
const copy = Object.defineProperties({}, descriptors);
|
|
35
|
+
if ("input" in ctx) {
|
|
36
|
+
let captured = false;
|
|
37
|
+
let input;
|
|
38
|
+
Object.defineProperty(copy, "input", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
get() {
|
|
42
|
+
if (!captured) {
|
|
43
|
+
const source = ctx.input;
|
|
44
|
+
input = source === void 0 ? void 0 : structuredClone(source);
|
|
45
|
+
captured = true;
|
|
46
|
+
}
|
|
47
|
+
return input;
|
|
48
|
+
},
|
|
49
|
+
set(value) {
|
|
50
|
+
input = value;
|
|
51
|
+
captured = true;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return copy;
|
|
56
|
+
}
|
|
57
|
+
function naturalRef(entry) {
|
|
58
|
+
const ref = entry.account ?? entry;
|
|
59
|
+
if (!ref || "account_id" in ref || !("brand" in ref) || !ref.brand || typeof ref.operator !== "string")
|
|
60
|
+
return void 0;
|
|
61
|
+
return ref;
|
|
62
|
+
}
|
|
63
|
+
async function lookup(accounts, ref, ctx, onUnsupported) {
|
|
64
|
+
try {
|
|
65
|
+
const account = await accounts.resolve(
|
|
66
|
+
structuredClone(ref),
|
|
67
|
+
isolateAccountCallbackInput({ ...ctx, provisioning: false })
|
|
68
|
+
);
|
|
69
|
+
if (account && "account_id" in ref && account.id !== ref.account_id) return null;
|
|
70
|
+
if (account && "brand" in ref) {
|
|
71
|
+
const identity = account;
|
|
72
|
+
const values = identity;
|
|
73
|
+
const known = Object.fromEntries(
|
|
74
|
+
["operator_unit", "currency", "timezone", "sandbox"].filter((field) => values[field] !== void 0).map((field) => [field, values[field]])
|
|
75
|
+
);
|
|
76
|
+
const projected = {
|
|
77
|
+
...ref,
|
|
78
|
+
...known,
|
|
79
|
+
brand: { ...ref.brand, ...identity.brand },
|
|
80
|
+
operator: identity.operator ?? ref.operator
|
|
81
|
+
};
|
|
82
|
+
if ((0, import_account_key.accountReferenceKey)(projected) !== (0, import_account_key.accountReferenceKey)(ref)) return null;
|
|
83
|
+
}
|
|
84
|
+
return account ? { ...account, billing: account.billing && { ...account.billing } } : null;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (error instanceof import_account.AccountNotFoundError || error instanceof import_async_outcome.AdcpError && error.code === "ACCOUNT_NOT_FOUND")
|
|
87
|
+
return null;
|
|
88
|
+
if (error instanceof import_async_outcome.AdcpError && ["INVALID_REQUEST", "UNSUPPORTED_FEATURE"].includes(error.code)) {
|
|
89
|
+
onUnsupported?.();
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function existingSyncAccounts(accounts, entries, ctx, logger) {
|
|
96
|
+
const existing = [];
|
|
97
|
+
for (const [index, entry] of entries.entries()) {
|
|
98
|
+
const ref = accounts.resolution === "derived" ? void 0 : naturalRef(entry);
|
|
99
|
+
const account = ref ? await lookup(accounts, ref, ctx, () => {
|
|
100
|
+
if (logger)
|
|
101
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_LOOKUP_UNSUPPORTED", toolName: "sync_accounts", index });
|
|
102
|
+
}) : null;
|
|
103
|
+
existing.push(
|
|
104
|
+
typeof account?.brand?.domain === "string" && account.brand.domain.length > 0 && typeof account.operator === "string" ? account : null
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return existing;
|
|
108
|
+
}
|
|
109
|
+
function diagnose(accounts, logger, diagnostic) {
|
|
110
|
+
if (process.env.NODE_ENV !== "production") safeWarn(logger, "Account store contract violation", { ...diagnostic });
|
|
111
|
+
try {
|
|
112
|
+
const pending = accounts.onDiagnostic?.(diagnostic);
|
|
113
|
+
if (pending) void Promise.resolve(pending).catch(() => safeWarn(logger, "Account diagnostic callback failed"));
|
|
114
|
+
} catch {
|
|
115
|
+
safeWarn(logger, "Account diagnostic callback failed");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function safeWarn(logger, message, data) {
|
|
119
|
+
try {
|
|
120
|
+
logger.warn(message, data);
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function diagnoseAccountBilling(accounts, logger, account, toolName, index) {
|
|
125
|
+
if (account.billing === "agent" && account.payment_terms === void 0) {
|
|
126
|
+
diagnose(accounts, logger, { code: "ACCOUNT_BILLING_FIELDS_MISSING", toolName, index });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function projectAccountList(accounts, items, ctx, logger) {
|
|
130
|
+
const rows = [];
|
|
131
|
+
for (const [index, account] of items.entries()) {
|
|
132
|
+
const row = (0, import_account.toWireAccount)(account);
|
|
133
|
+
if (row.billing === void 0 || row.payment_terms === void 0) {
|
|
134
|
+
const ref = accounts.resolution === "implicit" ? naturalRef(account) : { account_id: account.id };
|
|
135
|
+
if (ref) {
|
|
136
|
+
try {
|
|
137
|
+
const stored = await lookup(accounts, ref, ctx);
|
|
138
|
+
if (stored?.id === account.id) {
|
|
139
|
+
const wire = (0, import_account.toWireAccount)(stored);
|
|
140
|
+
row.billing ??= wire.billing;
|
|
141
|
+
row.payment_terms ??= wire.payment_terms;
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
safeWarn(logger, "Could not enrich listed account billing fields");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
diagnoseAccountBilling(accounts, logger, row, "list_accounts", index);
|
|
149
|
+
rows.push(row);
|
|
150
|
+
}
|
|
151
|
+
return rows;
|
|
152
|
+
}
|
|
153
|
+
async function checkSyncAccountRows(accounts, entries, existing, rows, indices, ctx, logger) {
|
|
154
|
+
const seen = /* @__PURE__ */ new Map();
|
|
155
|
+
const checked = [];
|
|
156
|
+
for (const [offset, inputRow] of rows.entries()) {
|
|
157
|
+
const entry = entries[offset];
|
|
158
|
+
const index = indices[offset];
|
|
159
|
+
const ref = naturalRef(entry);
|
|
160
|
+
const key = ref && (0, import_account_key.accountReferenceKey)(ref);
|
|
161
|
+
const priorId = existing[offset]?.id ?? (key ? seen.get(key) : void 0);
|
|
162
|
+
let row = { ...inputRow };
|
|
163
|
+
if (row.action === "failed") {
|
|
164
|
+
checked.push(row);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const idViolation = priorId !== void 0 && (row.account_id !== priorId || row.action === "created");
|
|
168
|
+
if (idViolation)
|
|
169
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_IDEMPOTENCY_VIOLATION", toolName: "sync_accounts", index });
|
|
170
|
+
const requestedRef = entry.account ?? entry;
|
|
171
|
+
const enrichmentRef = ref ?? ("account_id" in requestedRef && accounts.resolution !== "implicit" ? { account_id: requestedRef.account_id } : void 0);
|
|
172
|
+
let stored = null;
|
|
173
|
+
if (enrichmentRef && (row.billing === void 0 || row.payment_terms === void 0)) {
|
|
174
|
+
try {
|
|
175
|
+
stored = await lookup(accounts, enrichmentRef, ctx);
|
|
176
|
+
} catch {
|
|
177
|
+
safeWarn(logger, "Could not enrich account sync billing fields");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const source = stored?.id === row.account_id ? stored : existing[offset]?.id === row.account_id ? existing[offset] : null;
|
|
181
|
+
if (source) {
|
|
182
|
+
const wire = (0, import_account.toWireAccount)(source);
|
|
183
|
+
row.billing ??= wire.billing;
|
|
184
|
+
row.payment_terms ??= wire.payment_terms;
|
|
185
|
+
}
|
|
186
|
+
const missing = (entry.billing === "agent" || row.billing === "agent") && (row.billing === void 0 || row.payment_terms === void 0);
|
|
187
|
+
if (missing)
|
|
188
|
+
diagnose(accounts, logger, { code: "ACCOUNT_BILLING_FIELDS_MISSING", toolName: "sync_accounts", index });
|
|
189
|
+
const termsViolation = entry.payment_terms !== void 0 && row.status === "active" && row.payment_terms !== entry.payment_terms;
|
|
190
|
+
const billingViolation = entry.billing === "agent" && row.status === "active" && row.billing !== void 0 && row.billing !== "agent";
|
|
191
|
+
if (billingViolation)
|
|
192
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_BILLING_MISMATCH", toolName: "sync_accounts", index });
|
|
193
|
+
if (termsViolation)
|
|
194
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_PAYMENT_TERMS_MISMATCH", toolName: "sync_accounts", index });
|
|
195
|
+
if (key && row.account_id) seen.set(key, priorId ?? row.account_id);
|
|
196
|
+
if (accounts.strictIdempotency && (idViolation || termsViolation || billingViolation)) {
|
|
197
|
+
const error = new import_async_outcome.AdcpError(
|
|
198
|
+
termsViolation ? "PAYMENT_TERMS_NOT_SUPPORTED" : billingViolation ? "BILLING_NOT_SUPPORTED" : "SERVICE_UNAVAILABLE",
|
|
199
|
+
{
|
|
200
|
+
message: termsViolation ? "The seller did not accept the requested payment terms." : billingViolation ? "The seller did not accept agent billing." : "The account store did not preserve the existing account identity.",
|
|
201
|
+
recovery: termsViolation || billingViolation ? "correctable" : "transient",
|
|
202
|
+
field: `accounts[${index}]${termsViolation ? ".payment_terms" : billingViolation ? ".billing" : ""}`
|
|
203
|
+
}
|
|
204
|
+
).toStructuredError();
|
|
205
|
+
row = {
|
|
206
|
+
brand: row.brand,
|
|
207
|
+
operator: row.operator,
|
|
208
|
+
...priorId === row.account_id && priorId && { account_id: priorId },
|
|
209
|
+
action: "failed",
|
|
210
|
+
status: existing[offset]?.status ?? row.status,
|
|
211
|
+
errors: [error]
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
checked.push(row);
|
|
215
|
+
}
|
|
216
|
+
return checked;
|
|
217
|
+
}
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
checkSyncAccountRows,
|
|
221
|
+
diagnoseAccountBilling,
|
|
222
|
+
existingSyncAccounts,
|
|
223
|
+
isolateAccountCallbackInput,
|
|
224
|
+
projectAccountList
|
|
225
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { accountReferenceKey } from "../core/account-key.mjs";
|
|
2
|
+
import { AccountNotFoundError, toWireAccount } from "./decisioning/account.mjs";
|
|
3
|
+
import { AdcpError } from "./decisioning/async-outcome.mjs";
|
|
4
|
+
function isolateAccountCallbackInput(ctx) {
|
|
5
|
+
const descriptors = Object.getOwnPropertyDescriptors(ctx);
|
|
6
|
+
delete descriptors.input;
|
|
7
|
+
const copy = Object.defineProperties({}, descriptors);
|
|
8
|
+
if ("input" in ctx) {
|
|
9
|
+
let captured = false;
|
|
10
|
+
let input;
|
|
11
|
+
Object.defineProperty(copy, "input", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
get() {
|
|
15
|
+
if (!captured) {
|
|
16
|
+
const source = ctx.input;
|
|
17
|
+
input = source === void 0 ? void 0 : structuredClone(source);
|
|
18
|
+
captured = true;
|
|
19
|
+
}
|
|
20
|
+
return input;
|
|
21
|
+
},
|
|
22
|
+
set(value) {
|
|
23
|
+
input = value;
|
|
24
|
+
captured = true;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return copy;
|
|
29
|
+
}
|
|
30
|
+
function naturalRef(entry) {
|
|
31
|
+
const ref = entry.account ?? entry;
|
|
32
|
+
if (!ref || "account_id" in ref || !("brand" in ref) || !ref.brand || typeof ref.operator !== "string")
|
|
33
|
+
return void 0;
|
|
34
|
+
return ref;
|
|
35
|
+
}
|
|
36
|
+
async function lookup(accounts, ref, ctx, onUnsupported) {
|
|
37
|
+
try {
|
|
38
|
+
const account = await accounts.resolve(
|
|
39
|
+
structuredClone(ref),
|
|
40
|
+
isolateAccountCallbackInput({ ...ctx, provisioning: false })
|
|
41
|
+
);
|
|
42
|
+
if (account && "account_id" in ref && account.id !== ref.account_id) return null;
|
|
43
|
+
if (account && "brand" in ref) {
|
|
44
|
+
const identity = account;
|
|
45
|
+
const values = identity;
|
|
46
|
+
const known = Object.fromEntries(
|
|
47
|
+
["operator_unit", "currency", "timezone", "sandbox"].filter((field) => values[field] !== void 0).map((field) => [field, values[field]])
|
|
48
|
+
);
|
|
49
|
+
const projected = {
|
|
50
|
+
...ref,
|
|
51
|
+
...known,
|
|
52
|
+
brand: { ...ref.brand, ...identity.brand },
|
|
53
|
+
operator: identity.operator ?? ref.operator
|
|
54
|
+
};
|
|
55
|
+
if (accountReferenceKey(projected) !== accountReferenceKey(ref)) return null;
|
|
56
|
+
}
|
|
57
|
+
return account ? { ...account, billing: account.billing && { ...account.billing } } : null;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error instanceof AccountNotFoundError || error instanceof AdcpError && error.code === "ACCOUNT_NOT_FOUND")
|
|
60
|
+
return null;
|
|
61
|
+
if (error instanceof AdcpError && ["INVALID_REQUEST", "UNSUPPORTED_FEATURE"].includes(error.code)) {
|
|
62
|
+
onUnsupported?.();
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function existingSyncAccounts(accounts, entries, ctx, logger) {
|
|
69
|
+
const existing = [];
|
|
70
|
+
for (const [index, entry] of entries.entries()) {
|
|
71
|
+
const ref = accounts.resolution === "derived" ? void 0 : naturalRef(entry);
|
|
72
|
+
const account = ref ? await lookup(accounts, ref, ctx, () => {
|
|
73
|
+
if (logger)
|
|
74
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_LOOKUP_UNSUPPORTED", toolName: "sync_accounts", index });
|
|
75
|
+
}) : null;
|
|
76
|
+
existing.push(
|
|
77
|
+
typeof account?.brand?.domain === "string" && account.brand.domain.length > 0 && typeof account.operator === "string" ? account : null
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return existing;
|
|
81
|
+
}
|
|
82
|
+
function diagnose(accounts, logger, diagnostic) {
|
|
83
|
+
if (process.env.NODE_ENV !== "production") safeWarn(logger, "Account store contract violation", { ...diagnostic });
|
|
84
|
+
try {
|
|
85
|
+
const pending = accounts.onDiagnostic?.(diagnostic);
|
|
86
|
+
if (pending) void Promise.resolve(pending).catch(() => safeWarn(logger, "Account diagnostic callback failed"));
|
|
87
|
+
} catch {
|
|
88
|
+
safeWarn(logger, "Account diagnostic callback failed");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function safeWarn(logger, message, data) {
|
|
92
|
+
try {
|
|
93
|
+
logger.warn(message, data);
|
|
94
|
+
} catch {
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function diagnoseAccountBilling(accounts, logger, account, toolName, index) {
|
|
98
|
+
if (account.billing === "agent" && account.payment_terms === void 0) {
|
|
99
|
+
diagnose(accounts, logger, { code: "ACCOUNT_BILLING_FIELDS_MISSING", toolName, index });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function projectAccountList(accounts, items, ctx, logger) {
|
|
103
|
+
const rows = [];
|
|
104
|
+
for (const [index, account] of items.entries()) {
|
|
105
|
+
const row = toWireAccount(account);
|
|
106
|
+
if (row.billing === void 0 || row.payment_terms === void 0) {
|
|
107
|
+
const ref = accounts.resolution === "implicit" ? naturalRef(account) : { account_id: account.id };
|
|
108
|
+
if (ref) {
|
|
109
|
+
try {
|
|
110
|
+
const stored = await lookup(accounts, ref, ctx);
|
|
111
|
+
if (stored?.id === account.id) {
|
|
112
|
+
const wire = toWireAccount(stored);
|
|
113
|
+
row.billing ??= wire.billing;
|
|
114
|
+
row.payment_terms ??= wire.payment_terms;
|
|
115
|
+
}
|
|
116
|
+
} catch {
|
|
117
|
+
safeWarn(logger, "Could not enrich listed account billing fields");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
diagnoseAccountBilling(accounts, logger, row, "list_accounts", index);
|
|
122
|
+
rows.push(row);
|
|
123
|
+
}
|
|
124
|
+
return rows;
|
|
125
|
+
}
|
|
126
|
+
async function checkSyncAccountRows(accounts, entries, existing, rows, indices, ctx, logger) {
|
|
127
|
+
const seen = /* @__PURE__ */ new Map();
|
|
128
|
+
const checked = [];
|
|
129
|
+
for (const [offset, inputRow] of rows.entries()) {
|
|
130
|
+
const entry = entries[offset];
|
|
131
|
+
const index = indices[offset];
|
|
132
|
+
const ref = naturalRef(entry);
|
|
133
|
+
const key = ref && accountReferenceKey(ref);
|
|
134
|
+
const priorId = existing[offset]?.id ?? (key ? seen.get(key) : void 0);
|
|
135
|
+
let row = { ...inputRow };
|
|
136
|
+
if (row.action === "failed") {
|
|
137
|
+
checked.push(row);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const idViolation = priorId !== void 0 && (row.account_id !== priorId || row.action === "created");
|
|
141
|
+
if (idViolation)
|
|
142
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_IDEMPOTENCY_VIOLATION", toolName: "sync_accounts", index });
|
|
143
|
+
const requestedRef = entry.account ?? entry;
|
|
144
|
+
const enrichmentRef = ref ?? ("account_id" in requestedRef && accounts.resolution !== "implicit" ? { account_id: requestedRef.account_id } : void 0);
|
|
145
|
+
let stored = null;
|
|
146
|
+
if (enrichmentRef && (row.billing === void 0 || row.payment_terms === void 0)) {
|
|
147
|
+
try {
|
|
148
|
+
stored = await lookup(accounts, enrichmentRef, ctx);
|
|
149
|
+
} catch {
|
|
150
|
+
safeWarn(logger, "Could not enrich account sync billing fields");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const source = stored?.id === row.account_id ? stored : existing[offset]?.id === row.account_id ? existing[offset] : null;
|
|
154
|
+
if (source) {
|
|
155
|
+
const wire = toWireAccount(source);
|
|
156
|
+
row.billing ??= wire.billing;
|
|
157
|
+
row.payment_terms ??= wire.payment_terms;
|
|
158
|
+
}
|
|
159
|
+
const missing = (entry.billing === "agent" || row.billing === "agent") && (row.billing === void 0 || row.payment_terms === void 0);
|
|
160
|
+
if (missing)
|
|
161
|
+
diagnose(accounts, logger, { code: "ACCOUNT_BILLING_FIELDS_MISSING", toolName: "sync_accounts", index });
|
|
162
|
+
const termsViolation = entry.payment_terms !== void 0 && row.status === "active" && row.payment_terms !== entry.payment_terms;
|
|
163
|
+
const billingViolation = entry.billing === "agent" && row.status === "active" && row.billing !== void 0 && row.billing !== "agent";
|
|
164
|
+
if (billingViolation)
|
|
165
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_BILLING_MISMATCH", toolName: "sync_accounts", index });
|
|
166
|
+
if (termsViolation)
|
|
167
|
+
diagnose(accounts, logger, { code: "ACCOUNT_SYNC_PAYMENT_TERMS_MISMATCH", toolName: "sync_accounts", index });
|
|
168
|
+
if (key && row.account_id) seen.set(key, priorId ?? row.account_id);
|
|
169
|
+
if (accounts.strictIdempotency && (idViolation || termsViolation || billingViolation)) {
|
|
170
|
+
const error = new AdcpError(
|
|
171
|
+
termsViolation ? "PAYMENT_TERMS_NOT_SUPPORTED" : billingViolation ? "BILLING_NOT_SUPPORTED" : "SERVICE_UNAVAILABLE",
|
|
172
|
+
{
|
|
173
|
+
message: termsViolation ? "The seller did not accept the requested payment terms." : billingViolation ? "The seller did not accept agent billing." : "The account store did not preserve the existing account identity.",
|
|
174
|
+
recovery: termsViolation || billingViolation ? "correctable" : "transient",
|
|
175
|
+
field: `accounts[${index}]${termsViolation ? ".payment_terms" : billingViolation ? ".billing" : ""}`
|
|
176
|
+
}
|
|
177
|
+
).toStructuredError();
|
|
178
|
+
row = {
|
|
179
|
+
brand: row.brand,
|
|
180
|
+
operator: row.operator,
|
|
181
|
+
...priorId === row.account_id && priorId && { account_id: priorId },
|
|
182
|
+
action: "failed",
|
|
183
|
+
status: existing[offset]?.status ?? row.status,
|
|
184
|
+
errors: [error]
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
checked.push(row);
|
|
188
|
+
}
|
|
189
|
+
return checked;
|
|
190
|
+
}
|
|
191
|
+
export {
|
|
192
|
+
checkSyncAccountRows,
|
|
193
|
+
diagnoseAccountBilling,
|
|
194
|
+
existingSyncAccounts,
|
|
195
|
+
isolateAccountCallbackInput,
|
|
196
|
+
projectAccountList
|
|
197
|
+
};
|
|
@@ -225,6 +225,11 @@ function wrapMcpServer(inner, compliance, adcpVersion = import_version.ADCP_VERS
|
|
|
225
225
|
return handler({ method: request.method, params: request.params ?? {} }, extra);
|
|
226
226
|
};
|
|
227
227
|
const invoke = async (options2) => {
|
|
228
|
+
if (options2.authInfo?.extra?.identity33 || options2.authInfo?.extra?.webBotAuthAuthorization) {
|
|
229
|
+
const { getWebBotAuthAuthorizationFailure, webBotAuthToolFailure } = require('../signing/web-bot-auth.js');
|
|
230
|
+
const failure = getWebBotAuthAuthorizationFailure(options2.authInfo.extra);
|
|
231
|
+
if (failure) return webBotAuthToolFailure(failure, adcpVersion);
|
|
232
|
+
}
|
|
228
233
|
const tool = getRegisteredTool(mcp, options2.toolName);
|
|
229
234
|
if (!tool) {
|
|
230
235
|
throw new Error(`AdcpServer.invoke: tool "${options2.toolName}" is not registered`);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { fileURLToPath as __adcpFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __adcpDirname } from "node:path";
|
|
3
|
+
import { createRequire as __adcpCreateRequire } from "node:module";
|
|
4
|
+
const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
5
|
+
const require2 = __adcpCreateRequire(import.meta.url);
|
|
1
6
|
import { ADCP_VERSION } from "../version.mjs";
|
|
2
7
|
import {
|
|
3
8
|
applyStructuredContentTextFallback
|
|
@@ -175,6 +180,11 @@ function wrapMcpServer(inner, compliance, adcpVersion = ADCP_VERSION, options =
|
|
|
175
180
|
return handler({ method: request.method, params: request.params ?? {} }, extra);
|
|
176
181
|
};
|
|
177
182
|
const invoke = async (options2) => {
|
|
183
|
+
if (options2.authInfo?.extra?.identity33 || options2.authInfo?.extra?.webBotAuthAuthorization) {
|
|
184
|
+
const { getWebBotAuthAuthorizationFailure, webBotAuthToolFailure } = require2("../signing/web-bot-auth");
|
|
185
|
+
const failure = getWebBotAuthAuthorizationFailure(options2.authInfo.extra);
|
|
186
|
+
if (failure) return webBotAuthToolFailure(failure, adcpVersion);
|
|
187
|
+
}
|
|
178
188
|
const tool = getRegisteredTool(mcp, options2.toolName);
|
|
179
189
|
if (!tool) {
|
|
180
190
|
throw new Error(`AdcpServer.invoke: tool "${options2.toolName}" is not registered`);
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* `serve()` buffers `req.rawBody` before authentication runs.
|
|
39
39
|
*/
|
|
40
40
|
import type { IncomingMessage } from 'http';
|
|
41
|
+
import { type VerifiedWebBotSigner } from '../signing/web-bot-auth.mjs';
|
|
41
42
|
import type { JwksResolver } from '../signing/jwks.mjs';
|
|
42
43
|
import { type ReplayStore } from '../signing/replay.mjs';
|
|
43
44
|
import { type RevocationStore } from '../signing/revocation.mjs';
|
|
@@ -45,6 +46,20 @@ import type { VerifiedSigner, VerifierCapability } from '../signing/types.mjs';
|
|
|
45
46
|
import { type OperationResolutionInput, type ResolvedOperation } from '../signing/operation-resolution.mjs';
|
|
46
47
|
import { type AuthPrincipal, type Authenticator } from './auth.mjs';
|
|
47
48
|
export interface VerifySignatureAsAuthenticatorOptions {
|
|
49
|
+
/** Explicit experimental profile. Verification never creates a principal or fetches trust.json. */
|
|
50
|
+
webBotAuth?: {
|
|
51
|
+
directory: import('../signing/web-bot-auth.mjs').SignatureDirectoryResolver;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Revocation belongs to the identity layer: use
|
|
54
|
+
* `createIdentity33PrincipalResolver({ revocation })`. Required only when
|
|
55
|
+
* `resolvePrincipal` does not check revocation itself.
|
|
56
|
+
*/
|
|
57
|
+
isRevoked?: (origin: string, keyid: string) => Promise<boolean>;
|
|
58
|
+
/** Resolve only an existing audited binding; handle identity-established callers with anonymous scope. */
|
|
59
|
+
resolvePrincipal: (signers: readonly VerifiedWebBotSigner[], operation: ResolvedOperation) => Promise<AuthPrincipal>;
|
|
60
|
+
};
|
|
61
|
+
/** Refuse legacy credentials for an origin already bound to Web Bot Auth. */
|
|
62
|
+
assertLegacyOriginAllowed?: (agentUrl: string) => Promise<void>;
|
|
48
63
|
/** Verifier capability block. `required_for` is not enforced here — unsigned
|
|
49
64
|
* requests fall through to the next authenticator — so set it to whatever
|
|
50
65
|
* your `request_signing` capability claim advertises. */
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* `serve()` buffers `req.rawBody` before authentication runs.
|
|
39
39
|
*/
|
|
40
40
|
import type { IncomingMessage } from 'http';
|
|
41
|
+
import { type VerifiedWebBotSigner } from '../signing/web-bot-auth';
|
|
41
42
|
import type { JwksResolver } from '../signing/jwks';
|
|
42
43
|
import { type ReplayStore } from '../signing/replay';
|
|
43
44
|
import { type RevocationStore } from '../signing/revocation';
|
|
@@ -45,6 +46,20 @@ import type { VerifiedSigner, VerifierCapability } from '../signing/types';
|
|
|
45
46
|
import { type OperationResolutionInput, type ResolvedOperation } from '../signing/operation-resolution';
|
|
46
47
|
import { type AuthPrincipal, type Authenticator } from './auth';
|
|
47
48
|
export interface VerifySignatureAsAuthenticatorOptions {
|
|
49
|
+
/** Explicit experimental profile. Verification never creates a principal or fetches trust.json. */
|
|
50
|
+
webBotAuth?: {
|
|
51
|
+
directory: import('../signing/web-bot-auth').SignatureDirectoryResolver;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Revocation belongs to the identity layer: use
|
|
54
|
+
* `createIdentity33PrincipalResolver({ revocation })`. Required only when
|
|
55
|
+
* `resolvePrincipal` does not check revocation itself.
|
|
56
|
+
*/
|
|
57
|
+
isRevoked?: (origin: string, keyid: string) => Promise<boolean>;
|
|
58
|
+
/** Resolve only an existing audited binding; handle identity-established callers with anonymous scope. */
|
|
59
|
+
resolvePrincipal: (signers: readonly VerifiedWebBotSigner[], operation: ResolvedOperation) => Promise<AuthPrincipal>;
|
|
60
|
+
};
|
|
61
|
+
/** Refuse legacy credentials for an origin already bound to Web Bot Auth. */
|
|
62
|
+
assertLegacyOriginAllowed?: (agentUrl: string) => Promise<void>;
|
|
48
63
|
/** Verifier capability block. `required_for` is not enforced here — unsigned
|
|
49
64
|
* requests fall through to the next authenticator — so set it to whatever
|
|
50
65
|
* your `request_signing` capability claim advertises. */
|
|
@@ -26,7 +26,9 @@ __export(auth_signature_exports, {
|
|
|
26
26
|
verifySignatureAsAuthenticator: () => verifySignatureAsAuthenticator
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(auth_signature_exports);
|
|
29
|
+
var import_web_bot_auth = require('../signing/web-bot-auth.js');
|
|
29
30
|
var import_errors = require('../signing/errors.js');
|
|
31
|
+
var import_web_bot_auth2 = require('../signing/web-bot-auth.js');
|
|
30
32
|
var import_replay = require('../signing/replay.js');
|
|
31
33
|
var import_revocation = require('../signing/revocation.js');
|
|
32
34
|
var import_operation_resolution = require('../signing/operation-resolution.js');
|
|
@@ -35,6 +37,15 @@ var import_buyer_agent = require('./decisioning/buyer-agent.js');
|
|
|
35
37
|
var import_auth = require('./auth.js');
|
|
36
38
|
function verifySignatureAsAuthenticator(options) {
|
|
37
39
|
const replayStore = options.replayStore ?? new import_replay.InMemoryReplayStore();
|
|
40
|
+
const legacyOriginGate = options.assertLegacyOriginAllowed ?? (0, import_web_bot_auth.getWebBotAuthLegacyOriginGate)(options.webBotAuth?.resolvePrincipal);
|
|
41
|
+
if (options.webBotAuth && !legacyOriginGate)
|
|
42
|
+
throw new TypeError(
|
|
43
|
+
"Web Bot Auth requires an origin-binding migration fence; use createIdentity33PrincipalResolver or supply assertLegacyOriginAllowed"
|
|
44
|
+
);
|
|
45
|
+
if (options.webBotAuth && !options.webBotAuth.isRevoked && !(0, import_web_bot_auth2.isWebBotAuthRevocationChecked)(options.webBotAuth.resolvePrincipal))
|
|
46
|
+
throw new TypeError(
|
|
47
|
+
"Web Bot Auth requires origin revocation: use createIdentity33PrincipalResolver({ revocation }) or supply isRevoked"
|
|
48
|
+
);
|
|
38
49
|
const revocationStore = options.revocationStore ?? new import_revocation.InMemoryRevocationStore();
|
|
39
50
|
const authenticator = async (req) => {
|
|
40
51
|
if (!hasSignatureHeader(req)) return null;
|
|
@@ -48,6 +59,49 @@ function verifySignatureAsAuthenticator(options) {
|
|
|
48
59
|
};
|
|
49
60
|
let result;
|
|
50
61
|
try {
|
|
62
|
+
if ((0, import_web_bot_auth2.selectSignatureProfile)(requestLike) === "web-bot-auth") {
|
|
63
|
+
if (!options.getUrl && !(0, import_auth.getServeRequestContext)(req)?.publicUrl || !options.webBotAuth || !options.capability.profiles?.includes("web-bot-auth"))
|
|
64
|
+
throw new import_web_bot_auth2.WebBotAuthError(403, "profile_disabled");
|
|
65
|
+
if (req.method !== "GET" && req.rawBody === void 0)
|
|
66
|
+
throw new import_web_bot_auth2.WebBotAuthError(403, "raw_body_missing");
|
|
67
|
+
const signers = await (0, import_web_bot_auth2.verifyWebBotAuth)(requestLike, {
|
|
68
|
+
directory: options.webBotAuth.directory,
|
|
69
|
+
replayStore,
|
|
70
|
+
now: options.now,
|
|
71
|
+
...options.webBotAuth.isRevoked && { isRevoked: options.webBotAuth.isRevoked }
|
|
72
|
+
});
|
|
73
|
+
const operation = options.resolveOperation(req);
|
|
74
|
+
let principal2;
|
|
75
|
+
let deferredFailure;
|
|
76
|
+
try {
|
|
77
|
+
principal2 = await options.webBotAuth.resolvePrincipal(signers, operation);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (error instanceof import_web_bot_auth2.WebBotAuthError || error instanceof import_web_bot_auth2.WebBotAuthUnavailableError) throw error;
|
|
80
|
+
if (typeof operation !== "string") throw (0, import_web_bot_auth2.webBotAuthPrincipalFailureError)(error);
|
|
81
|
+
const deferred = (0, import_web_bot_auth2.deferWebBotAuthPrincipalFailure)(signers, error);
|
|
82
|
+
principal2 = { principal: deferred.principal };
|
|
83
|
+
deferredFailure = deferred.authorizationFailure;
|
|
84
|
+
}
|
|
85
|
+
const signer2 = signers[signers.length - 1];
|
|
86
|
+
req.verifiedSigner = {
|
|
87
|
+
keyid: signer2.keyid,
|
|
88
|
+
agent_url: signer2.origin,
|
|
89
|
+
verified_at: signer2.verified_at
|
|
90
|
+
};
|
|
91
|
+
const failed = signers.find((s) => s.authorizationFailure);
|
|
92
|
+
return {
|
|
93
|
+
...principal2,
|
|
94
|
+
extra: {
|
|
95
|
+
...principal2.extra,
|
|
96
|
+
webBotAuthAuthorization: {
|
|
97
|
+
signer: failed ?? signer2,
|
|
98
|
+
...(failed?.authorizationFailure ?? deferredFailure) && {
|
|
99
|
+
authorizationFailure: failed?.authorizationFailure ?? deferredFailure
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
51
105
|
result = await (0, import_verifier.verifyRequestSignature)(requestLike, {
|
|
52
106
|
capability: options.capability,
|
|
53
107
|
jwks: options.jwks,
|
|
@@ -58,7 +112,22 @@ function verifySignatureAsAuthenticator(options) {
|
|
|
58
112
|
operation: options.resolveOperation(req),
|
|
59
113
|
agentUrlForKeyid: options.agentUrlForKeyid
|
|
60
114
|
});
|
|
115
|
+
if (result.status === "verified" && legacyOriginGate) {
|
|
116
|
+
if (!result.agent_url)
|
|
117
|
+
throw new import_errors.RequestSignatureError(
|
|
118
|
+
"request_signature_key_unknown",
|
|
119
|
+
7,
|
|
120
|
+
"Legacy signer must resolve an agent origin when migration fencing is enabled"
|
|
121
|
+
);
|
|
122
|
+
await legacyOriginGate(result.agent_url);
|
|
123
|
+
}
|
|
61
124
|
} catch (err) {
|
|
125
|
+
if (err instanceof import_web_bot_auth2.WebBotAuthError)
|
|
126
|
+
throw new import_auth.AuthError(err.message, { cause: err, status: err.status, headers: err.headers, body: err.body });
|
|
127
|
+
if (err instanceof import_web_bot_auth2.WebBotAuthUnavailableError) {
|
|
128
|
+
const outage = (0, import_web_bot_auth2.webBotAuthUnavailableResponse)();
|
|
129
|
+
throw new import_auth.AuthError(err.message, { cause: err, ...outage });
|
|
130
|
+
}
|
|
62
131
|
if (err instanceof import_errors.RequestSignatureError) {
|
|
63
132
|
throw new import_auth.AuthError(`Signature rejected (${err.code}).`, { cause: err });
|
|
64
133
|
}
|
|
@@ -79,7 +148,8 @@ function verifySignatureAsAuthenticator(options) {
|
|
|
79
148
|
req.verifiedSigner = signer;
|
|
80
149
|
return principal;
|
|
81
150
|
};
|
|
82
|
-
|
|
151
|
+
const tagged = (0, import_auth.tagAuthenticatorNeedsRawBody)(authenticator);
|
|
152
|
+
return options.webBotAuth ? (0, import_auth.tagAuthenticatorPresenceGated)(tagged) : tagged;
|
|
83
153
|
}
|
|
84
154
|
function principalForVerifiedSigner(signer, makePrincipal) {
|
|
85
155
|
if (!SAFE_KEYID.test(signer.keyid)) {
|
|
@@ -206,7 +276,7 @@ function logUnresolvable(req) {
|
|
|
206
276
|
}
|
|
207
277
|
const SAFE_KEYID = /^[A-Za-z0-9._-]{1,256}$/;
|
|
208
278
|
function hasSignatureHeader(req) {
|
|
209
|
-
return nonEmptyHeader(req.headers["signature-input"]) || nonEmptyHeader(req.headers["signature"]);
|
|
279
|
+
return req.headers["signature-agent"] !== void 0 || nonEmptyHeader(req.headers["signature-input"]) || nonEmptyHeader(req.headers["signature"]);
|
|
210
280
|
}
|
|
211
281
|
function nonEmptyHeader(v) {
|
|
212
282
|
if (typeof v === "string") return v.length > 0;
|