@adcp/sdk 15.9.0 → 16.0.0-beta.1
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 +16 -2
- package/dist/lib/core/SingleAgentClient.d.ts +16 -2
- package/dist/lib/core/SingleAgentClient.js +259 -62
- package/dist/lib/core/SingleAgentClient.mjs +261 -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/index.d.mts +10 -0
- package/dist/lib/identity-3.3/index.d.ts +10 -0
- package/dist/lib/identity-3.3/index.js +75 -0
- package/dist/lib/identity-3.3/index.mjs +46 -0
- package/dist/lib/identity-3.3/lifecycle.d.mts +113 -0
- package/dist/lib/identity-3.3/lifecycle.d.ts +113 -0
- package/dist/lib/identity-3.3/lifecycle.js +267 -0
- package/dist/lib/identity-3.3/lifecycle.mjs +240 -0
- package/dist/lib/identity-3.3/revocation.d.mts +50 -0
- package/dist/lib/identity-3.3/revocation.d.ts +50 -0
- package/dist/lib/identity-3.3/revocation.js +238 -0
- package/dist/lib/identity-3.3/revocation.mjs +216 -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 +34 -0
- package/dist/lib/identity-3.3/server.d.ts +34 -0
- package/dist/lib/identity-3.3/server.js +219 -0
- package/dist/lib/identity-3.3/server.mjs +194 -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 +94 -0
- package/dist/lib/identity-3.3/trust.d.ts +94 -0
- package/dist/lib/identity-3.3/trust.js +278 -0
- package/dist/lib/identity-3.3/trust.mjs +239 -0
- package/dist/lib/identity-3.3/types.d.mts +127 -0
- package/dist/lib/identity-3.3/types.d.ts +127 -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/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 +80 -25
- package/dist/lib/reporting/bigquery/index.d.ts +80 -25
- package/dist/lib/reporting/bigquery/index.js +184 -81
- package/dist/lib/reporting/bigquery/index.mjs +182 -80
- 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 +10 -0
- package/dist/lib/server/auth-signature.d.ts +10 -0
- package/dist/lib/server/auth-signature.js +61 -2
- package/dist/lib/server/auth-signature.mjs +65 -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 +238 -19
- package/dist/lib/server/create-adcp-server.mjs +240 -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/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/parser.d.mts +1 -1
- package/dist/lib/signing/parser.d.ts +1 -1
- package/dist/lib/signing/parser.js +5 -3
- package/dist/lib/signing/parser.mjs +6 -4
- package/dist/lib/signing/revocation.d.mts +4 -1
- package/dist/lib/signing/revocation.d.ts +4 -1
- package/dist/lib/signing/revocation.js +33 -3
- package/dist/lib/signing/revocation.mjs +31 -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/web-bot-auth.d.mts +117 -0
- package/dist/lib/signing/web-bot-auth.d.ts +117 -0
- package/dist/lib/signing/web-bot-auth.js +660 -0
- package/dist/lib/signing/web-bot-auth.mjs +624 -0
- 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/creative-delivery.d.mts +3 -1
- package/dist/lib/v2/projection/creative-delivery.d.ts +3 -1
- 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/legacy-routes.d.mts +24 -2
- package/dist/lib/v2/projection/legacy-routes.d.ts +24 -2
- package/dist/lib/v2/projection/legacy-routes.js +28 -2
- package/dist/lib/v2/projection/legacy-routes.mjs +26 -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 +132 -46
- package/docs/guides/REPORTING-OPERATIONS.md +25 -4
- 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 +7 -0
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-agent-identity-3.3.md +355 -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 +15 -1
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import { getWebBotAuthLegacyOriginGate } from "../signing/web-bot-auth.mjs";
|
|
2
|
+
import {
|
|
3
|
+
isIdentity33SchemaScope,
|
|
4
|
+
withIdentity33SchemaScope,
|
|
5
|
+
bindIdentity33SchemaScope
|
|
6
|
+
} from "../validation/schema-loader.mjs";
|
|
7
|
+
import { validateAgentOnboarding } from "../identity-3.3/lifecycle.mjs";
|
|
8
|
+
import { isIdentity33UnboundContext } from "../identity-3.3/server.mjs";
|
|
9
|
+
import {
|
|
10
|
+
WEB_BOT_AUTH_DRAFT_REVISION,
|
|
11
|
+
getWebBotAuthAuthorizationFailure,
|
|
12
|
+
webBotAuthToolFailure,
|
|
13
|
+
selectSignatureProfile,
|
|
14
|
+
verifyWebBotAuth,
|
|
15
|
+
WebBotAuthError
|
|
16
|
+
} from "../signing/web-bot-auth.mjs";
|
|
17
|
+
import { validateIdentity33Payload } from "../identity-3.3/validation.mjs";
|
|
18
|
+
import { IdentityAuthorizationError } from "../identity-3.3/trust.mjs";
|
|
1
19
|
import { z } from "zod";
|
|
2
20
|
import {
|
|
3
21
|
COMPATIBLE_ADCP_VERSIONS,
|
|
@@ -752,10 +770,12 @@ function restoreSyncAccountEnvelopeErrorIndices(response, acceptedIndices) {
|
|
|
752
770
|
syncContentJsonText(restored, restored.structuredContent, mirrorsStructuredContent);
|
|
753
771
|
return restored;
|
|
754
772
|
}
|
|
755
|
-
function validateFrameworkPayload(toolName, direction, payload, version, proposalCapabilities) {
|
|
773
|
+
function validateFrameworkPayload(toolName, direction, payload, version, proposalCapabilities, identity33 = false) {
|
|
756
774
|
if (toolName === "sync_reporting_status" && direction === "request") {
|
|
757
775
|
return validateSyncReportingStatusEnvelope(payload, version);
|
|
758
776
|
}
|
|
777
|
+
if (identity33 && toolName !== "refine_proposals" && toolName !== "sync_reporting_status")
|
|
778
|
+
return validateIdentity33Payload(toolName, direction, payload, version);
|
|
759
779
|
if (toolName !== "refine_proposals") {
|
|
760
780
|
return direction === "request" ? validateRequest(toolName, payload, version) : validateResponse(toolName, payload, version);
|
|
761
781
|
}
|
|
@@ -1491,6 +1511,11 @@ function resolveEffectiveSignedRequestPolicy(signedRequests, capabilityRequestSi
|
|
|
1491
1511
|
};
|
|
1492
1512
|
}
|
|
1493
1513
|
function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning, adcpVersion) {
|
|
1514
|
+
const legacyOriginGate = signedRequests.assertLegacyOriginAllowed ?? getWebBotAuthLegacyOriginGate(signedRequests.webBotAuth?.resolvePrincipal);
|
|
1515
|
+
if (signedRequests.webBotAuth && !legacyOriginGate)
|
|
1516
|
+
throw new Error(
|
|
1517
|
+
"Web Bot Auth requires an origin-binding migration fence; use createIdentity33PrincipalResolver or supply assertLegacyOriginAllowed"
|
|
1518
|
+
);
|
|
1494
1519
|
const requiredFor = effectiveRequestSigning.required_for ?? [];
|
|
1495
1520
|
const verifier = createExpressVerifier({
|
|
1496
1521
|
capability: {
|
|
@@ -1512,6 +1537,53 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
|
|
|
1512
1537
|
return async function adcpPreTransport(req, res) {
|
|
1513
1538
|
const serveContext = getServeRequestContext(req);
|
|
1514
1539
|
const canonicalPublicUrl = serveContext?.publicUrl ? new URL(serveContext.publicUrl) : void 0;
|
|
1540
|
+
if (selectSignatureProfile({ headers: req.headers }) === "web-bot-auth") {
|
|
1541
|
+
try {
|
|
1542
|
+
if (!signedRequests.webBotAuth || !canonicalPublicUrl) throw new WebBotAuthError(403, "profile_disabled");
|
|
1543
|
+
if (req.method !== "GET" && req.rawBody === void 0) throw new WebBotAuthError(403, "raw_body_missing");
|
|
1544
|
+
const requestTarget = canonicalPublicUrl.origin + (req.url?.startsWith("/") ? req.url : "/" + (req.url ?? ""));
|
|
1545
|
+
const signers = await verifyWebBotAuth(
|
|
1546
|
+
{ method: req.method ?? "POST", url: requestTarget, headers: req.headers, body: req.rawBody ?? "" },
|
|
1547
|
+
{
|
|
1548
|
+
directory: signedRequests.webBotAuth.directory,
|
|
1549
|
+
deferAuthorizationErrors: typeof resolveRequestOperation({ rawBody: req.rawBody, method: req.method, url: req.url }) === "string",
|
|
1550
|
+
replayStore: signedRequests.replayStore,
|
|
1551
|
+
isRevoked: signedRequests.webBotAuth.isRevoked,
|
|
1552
|
+
requireFreshRevocation: ![
|
|
1553
|
+
"get_adcp_capabilities",
|
|
1554
|
+
"get_principal",
|
|
1555
|
+
"list_creative_formats",
|
|
1556
|
+
"list_accounts"
|
|
1557
|
+
].includes(String(resolveRequestOperation({ rawBody: req.rawBody, method: req.method, url: req.url })))
|
|
1558
|
+
}
|
|
1559
|
+
);
|
|
1560
|
+
const operation = resolveRequestOperation({ rawBody: req.rawBody, method: req.method, url: req.url });
|
|
1561
|
+
const principal = await signedRequests.webBotAuth.resolvePrincipal(signers, operation);
|
|
1562
|
+
const signer = signers[signers.length - 1];
|
|
1563
|
+
const failed = signers.find((s) => s.authorizationFailure);
|
|
1564
|
+
const guardedPrincipal = {
|
|
1565
|
+
...principal,
|
|
1566
|
+
extra: {
|
|
1567
|
+
...principal.extra,
|
|
1568
|
+
webBotAuthAuthorization: {
|
|
1569
|
+
signer: failed ?? signer,
|
|
1570
|
+
...failed && { authorizationFailure: failed.authorizationFailure }
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
attachVerifiedSignerAuth(req, guardedPrincipal, {
|
|
1575
|
+
keyid: signer.keyid,
|
|
1576
|
+
agent_url: signer.origin,
|
|
1577
|
+
verified_at: signer.verified_at
|
|
1578
|
+
});
|
|
1579
|
+
return false;
|
|
1580
|
+
} catch (error) {
|
|
1581
|
+
const rejected = error instanceof WebBotAuthError ? error : new WebBotAuthError(403, "identity_rejected");
|
|
1582
|
+
res.writeHead(rejected.status, { ...rejected.headers, "Content-Type": "application/json" });
|
|
1583
|
+
res.end(JSON.stringify(rejected.body));
|
|
1584
|
+
return true;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1515
1587
|
const reqShim = {
|
|
1516
1588
|
method: req.method ?? "POST",
|
|
1517
1589
|
url: req.url ?? "/mcp",
|
|
@@ -1555,6 +1627,7 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
|
|
|
1555
1627
|
resolve();
|
|
1556
1628
|
};
|
|
1557
1629
|
res.once("finish", () => {
|
|
1630
|
+
verifierCompleted = true;
|
|
1558
1631
|
if (res.writableEnded) handled = true;
|
|
1559
1632
|
done();
|
|
1560
1633
|
});
|
|
@@ -1562,8 +1635,7 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
|
|
|
1562
1635
|
if (!verifierCompleted) handled = true;
|
|
1563
1636
|
done();
|
|
1564
1637
|
});
|
|
1565
|
-
verifier(reqShim, resShim, (err) => {
|
|
1566
|
-
verifierCompleted = true;
|
|
1638
|
+
verifier(reqShim, resShim, async (err) => {
|
|
1567
1639
|
if (err) {
|
|
1568
1640
|
const errName = err.name || "Error";
|
|
1569
1641
|
const errCode = err.code ?? "unknown";
|
|
@@ -1578,6 +1650,11 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
|
|
|
1578
1650
|
const verifiedSigner = reqShim.verifiedSigner;
|
|
1579
1651
|
if (!err && verifiedSigner) {
|
|
1580
1652
|
try {
|
|
1653
|
+
if (legacyOriginGate) {
|
|
1654
|
+
if (!verifiedSigner.agent_url)
|
|
1655
|
+
throw new AuthError("Legacy signer origin is required for migration fencing");
|
|
1656
|
+
await legacyOriginGate(verifiedSigner.agent_url);
|
|
1657
|
+
}
|
|
1581
1658
|
const principal = principalForVerifiedSigner(verifiedSigner, signedRequests.makePrincipal);
|
|
1582
1659
|
attachVerifiedSignerAuth(req, principal, verifiedSigner);
|
|
1583
1660
|
} catch (identityError) {
|
|
@@ -1597,6 +1674,7 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
|
|
|
1597
1674
|
handled = true;
|
|
1598
1675
|
}
|
|
1599
1676
|
}
|
|
1677
|
+
verifierCompleted = true;
|
|
1600
1678
|
if (res.writableEnded) handled = true;
|
|
1601
1679
|
done();
|
|
1602
1680
|
});
|
|
@@ -1929,6 +2007,11 @@ function isAuthDerivedAccountNotFound(err) {
|
|
|
1929
2007
|
return err instanceof AdcpError && err.code === "ACCOUNT_NOT_FOUND";
|
|
1930
2008
|
}
|
|
1931
2009
|
function createAdcpServer(config) {
|
|
2010
|
+
if (Boolean(config.identity33) !== isIdentity33SchemaScope())
|
|
2011
|
+
return withIdentity33SchemaScope(() => {
|
|
2012
|
+
const instance = createAdcpServer(config);
|
|
2013
|
+
return config.identity33 ? bindIdentity33SchemaScope(instance) : instance;
|
|
2014
|
+
}, Boolean(config.identity33));
|
|
1932
2015
|
const {
|
|
1933
2016
|
name,
|
|
1934
2017
|
version,
|
|
@@ -2020,7 +2103,7 @@ function createAdcpServer(config) {
|
|
|
2020
2103
|
}
|
|
2021
2104
|
const credentialPolicyPatterns = credentialPolicy === void 0 || typeof credentialPolicy === "string" ? void 0 : credentialPolicy.patterns;
|
|
2022
2105
|
const adcpVersion = resolveAdcpVersion(
|
|
2023
|
-
configuredAdcpVersion ?? (config.proposalNegotiation ? ADCP_VERSION : void 0)
|
|
2106
|
+
configuredAdcpVersion ?? (config.identity33 ? "3.3" : config.proposalNegotiation ? ADCP_VERSION : void 0)
|
|
2024
2107
|
);
|
|
2025
2108
|
const toolVersionRanges = parseToolVersionRanges(config.toolVersions);
|
|
2026
2109
|
const toolAvailableForRelease = (toolName, release) => toolIsAvailableInRelease(toolVersionRanges, toolName, release);
|
|
@@ -2093,6 +2176,23 @@ function createAdcpServer(config) {
|
|
|
2093
2176
|
})();
|
|
2094
2177
|
const protocolTaskRelease = parseAdcpRelease(protocolBundleKey);
|
|
2095
2178
|
const supportsProtocolTaskTools = protocolTaskRelease !== void 0 && (protocolTaskRelease.major > 3 || protocolTaskRelease.major === 3 && protocolTaskRelease.minor >= 1);
|
|
2179
|
+
const identityOnboarding = capConfig?.account?.agent_onboarding ?? capConfig?.account?.agentOnboarding;
|
|
2180
|
+
if (identityOnboarding) {
|
|
2181
|
+
if (!config.identity33) throw new Error("agent_onboarding requires the identity33 experiment");
|
|
2182
|
+
validateAgentOnboarding(
|
|
2183
|
+
identityOnboarding,
|
|
2184
|
+
{ sandbox: capConfig?.account?.sandbox, supported_billing: capConfig?.account?.supportedBilling },
|
|
2185
|
+
capConfig?.overrides?.experimental_features ?? []
|
|
2186
|
+
);
|
|
2187
|
+
}
|
|
2188
|
+
if (signedRequests?.webBotAuth && (!config.identity33 || !(capConfig?.overrides?.request_signing?.profiles ?? capConfig?.request_signing?.profiles)?.includes(
|
|
2189
|
+
"web-bot-auth"
|
|
2190
|
+
)))
|
|
2191
|
+
throw new Error("Web Bot Auth verifier requires identity33 and request_signing.profiles advertisement");
|
|
2192
|
+
if (config.webhooks?.signingProfile === "web-bot-auth")
|
|
2193
|
+
throw new Error("Select Web Bot Auth on each trusted webhook registration, not as a server-wide default");
|
|
2194
|
+
if (config.webhooks?.webBotAuth && !config.identity33)
|
|
2195
|
+
throw new Error("Web Bot Auth webhook signing requires the identity33 experiment");
|
|
2096
2196
|
const toolsWithErrorArm = getToolsWithErrorArm(adcpVersion);
|
|
2097
2197
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2098
2198
|
const requestValidationMode = validationConfig?.requests ?? (isProduction ? "off" : "strict");
|
|
@@ -2651,6 +2751,10 @@ function createAdcpServer(config) {
|
|
|
2651
2751
|
const hasAccount = "account" in schema.shape;
|
|
2652
2752
|
const wrap = meta?.wrap ?? ((data, summary) => genericResponse(toolName, data, summary));
|
|
2653
2753
|
const toolHandler = async (params, extra) => {
|
|
2754
|
+
const authorizationFailure = getWebBotAuthAuthorizationFailure(extra?.authInfo?.extra);
|
|
2755
|
+
if (authorizationFailure) return webBotAuthToolFailure(authorizationFailure, servedAdcpVersion);
|
|
2756
|
+
if (config.identity33 && !isIdentity33SchemaScope())
|
|
2757
|
+
return withIdentity33SchemaScope(() => toolHandler(params, extra));
|
|
2654
2758
|
const callRequestValidationMode = effectiveRequestValidationMode(extra);
|
|
2655
2759
|
let notificationFailureRows = /* @__PURE__ */ new Map();
|
|
2656
2760
|
const releaseSelection = selectServedAdcpRelease(params, capConfig, adcpVersion, defaultAdcpVersion);
|
|
@@ -2705,6 +2809,22 @@ function createAdcpServer(config) {
|
|
|
2705
2809
|
})
|
|
2706
2810
|
);
|
|
2707
2811
|
}
|
|
2812
|
+
for (const field of ["push_notification_config", "reporting_webhook", "artifact_webhook"]) {
|
|
2813
|
+
const registration = params[field];
|
|
2814
|
+
if (!registration || typeof registration !== "object" || Array.isArray(registration)) continue;
|
|
2815
|
+
const selectedProfile = registration.signing_profile;
|
|
2816
|
+
if (selectedProfile === void 0) continue;
|
|
2817
|
+
const offered = capabilitiesData.webhook_signing?.profiles ?? [
|
|
2818
|
+
"adcp/webhook-signing/v1"
|
|
2819
|
+
];
|
|
2820
|
+
if (typeof selectedProfile !== "string" || !offered.includes(selectedProfile) || selectedProfile === "web-bot-auth" && (!config.identity33 || !isAdcpVersionAtLeast(requestRelease.wireVersion, "3.3")) || selectedProfile === "web-bot-auth" && registration.authentication !== void 0)
|
|
2821
|
+
return finalize(
|
|
2822
|
+
adcpError("INVALID_REQUEST", {
|
|
2823
|
+
message: "Unsupported or ambiguous webhook signing profile",
|
|
2824
|
+
field: `${field}.signing_profile`
|
|
2825
|
+
})
|
|
2826
|
+
);
|
|
2827
|
+
}
|
|
2708
2828
|
const operationIdError = pushOperationIdError(params, requestRelease);
|
|
2709
2829
|
if (operationIdError) return finalize(operationIdError);
|
|
2710
2830
|
if (toolName === "list_account_changes" && Object.hasOwn(params, "cursor") && Object.hasOwn(params, "starting_position")) {
|
|
@@ -2884,7 +3004,8 @@ function createAdcpServer(config) {
|
|
|
2884
3004
|
"request",
|
|
2885
3005
|
params,
|
|
2886
3006
|
requestRelease.validationVersion,
|
|
2887
|
-
proposalRefinementCapabilities
|
|
3007
|
+
proposalRefinementCapabilities,
|
|
3008
|
+
!!config.identity33 && isAdcpVersionAtLeast(requestRelease.wireVersion, "3.3")
|
|
2888
3009
|
);
|
|
2889
3010
|
if (!outcome.valid) {
|
|
2890
3011
|
if ("refinementError" in outcome && outcome.refinementError?.code === "UNSUPPORTED_FEATURE") {
|
|
@@ -2939,6 +3060,21 @@ function createAdcpServer(config) {
|
|
|
2939
3060
|
}
|
|
2940
3061
|
}
|
|
2941
3062
|
}
|
|
3063
|
+
if (config.identity33) {
|
|
3064
|
+
try {
|
|
3065
|
+
await config.identity33.authorize(ctx, toolName, params);
|
|
3066
|
+
} catch (error) {
|
|
3067
|
+
if (error instanceof IdentityAuthorizationError)
|
|
3068
|
+
return finalize(
|
|
3069
|
+
adcpError("PERMISSION_DENIED", {
|
|
3070
|
+
message: error.message,
|
|
3071
|
+
...error.details && { details: { ...error.details } }
|
|
3072
|
+
})
|
|
3073
|
+
);
|
|
3074
|
+
if (error instanceof AdcpError) return finalize(projectThrownAdcpError(error));
|
|
3075
|
+
return finalize(adcpError("PERMISSION_DENIED", { message: "Agent authorization failed" }));
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
2942
3078
|
let unresolvedAccountPassThrough = false;
|
|
2943
3079
|
const suppliedAccountRef = hasAccount && params.account != null && !(strictAccountReferences && toolName === "list_accounts");
|
|
2944
3080
|
if (suppliedAccountRef && toolName === "list_accounts") {
|
|
@@ -3130,7 +3266,7 @@ function createAdcpServer(config) {
|
|
|
3130
3266
|
);
|
|
3131
3267
|
}
|
|
3132
3268
|
}
|
|
3133
|
-
const callerScopedResolver = toolName === "sync_agent_notification_configs" ? config.protocol?.resolveScope : toolName === "get_principal" || toolName === "sync_principal" ? config.protocol?.resolvePrincipalScope : void 0;
|
|
3269
|
+
const callerScopedResolver = config.identity33 && (toolName === "get_principal" || toolName === "sync_principal" && params.dry_run === true) && isIdentity33UnboundContext(ctx) ? void 0 : toolName === "sync_agent_notification_configs" ? config.protocol?.resolveScope : toolName === "get_principal" || toolName === "sync_principal" ? config.protocol?.resolvePrincipalScope : void 0;
|
|
3134
3270
|
if (callerScopedResolver || toolName === "report_plan_adjustment") {
|
|
3135
3271
|
if (ctx.authInfo === void 0 && ctx.agent === void 0) {
|
|
3136
3272
|
return finalize(
|
|
@@ -3334,7 +3470,18 @@ function createAdcpServer(config) {
|
|
|
3334
3470
|
if (webhookEmitter) {
|
|
3335
3471
|
const tenantScope = webhookTenantScopeForContext(ctx);
|
|
3336
3472
|
const scopedEmitter = tenantScope === void 0 ? configuredWebhookEmitter : webhookEmitter.forTenantScope(tenantScope);
|
|
3337
|
-
|
|
3473
|
+
const profileBindings = ["push_notification_config", "reporting_webhook", "artifact_webhook"].flatMap(
|
|
3474
|
+
(field) => {
|
|
3475
|
+
const value = params[field];
|
|
3476
|
+
return value?.url && value.signing_profile ? [{ url: value.url, profile: value.signing_profile }] : [];
|
|
3477
|
+
}
|
|
3478
|
+
);
|
|
3479
|
+
ctx.emitWebhook = (delivery) => scopedEmitter.emit({
|
|
3480
|
+
...delivery,
|
|
3481
|
+
...delivery.signingProfile === void 0 && profileBindings.some((binding) => binding.url === delivery.url) && {
|
|
3482
|
+
signingProfile: profileBindings.find((binding) => binding.url === delivery.url).profile
|
|
3483
|
+
}
|
|
3484
|
+
});
|
|
3338
3485
|
}
|
|
3339
3486
|
const handlerParams = notificationFailureRows.size === 0 ? params : {
|
|
3340
3487
|
...params,
|
|
@@ -3812,7 +3959,14 @@ function createAdcpServer(config) {
|
|
|
3812
3959
|
}
|
|
3813
3960
|
if (responseValidationMode !== "off" && !isErrorResponse(formatted)) {
|
|
3814
3961
|
const payload = formatted.structuredContent;
|
|
3815
|
-
const outcome = validateFrameworkPayload(
|
|
3962
|
+
const outcome = validateFrameworkPayload(
|
|
3963
|
+
toolName,
|
|
3964
|
+
"response",
|
|
3965
|
+
payload,
|
|
3966
|
+
requestRelease.validationVersion,
|
|
3967
|
+
void 0,
|
|
3968
|
+
!!config.identity33 && isAdcpVersionAtLeast(requestRelease.wireVersion, "3.3")
|
|
3969
|
+
);
|
|
3816
3970
|
if (!outcome.valid) {
|
|
3817
3971
|
logger.warn(
|
|
3818
3972
|
`Schema validation warning (response) for ${toolName}: ${formatIssues(outcome.issues, 3, { rootSchemaId: outcome.schemaId })}`,
|
|
@@ -4097,6 +4251,8 @@ function createAdcpServer(config) {
|
|
|
4097
4251
|
_meta: frameworkToolMeta
|
|
4098
4252
|
},
|
|
4099
4253
|
(async (params, extra) => {
|
|
4254
|
+
const identityError = await authorizeAuxiliaryIdentityTool("get_task_status", params, extra);
|
|
4255
|
+
if (identityError) return finalizeProtocolTaskToolResponse("get_task_status", params ?? {}, identityError);
|
|
4100
4256
|
const credentialError = taskToolCredentialPolicyError("get_task_status", params ?? {}, extra);
|
|
4101
4257
|
if (credentialError) {
|
|
4102
4258
|
return finalizeProtocolTaskToolResponse("get_task_status", params ?? {}, credentialError, {
|
|
@@ -4183,6 +4339,8 @@ function createAdcpServer(config) {
|
|
|
4183
4339
|
_meta: frameworkToolMeta
|
|
4184
4340
|
},
|
|
4185
4341
|
(async (params, extra) => {
|
|
4342
|
+
const identityError = await authorizeAuxiliaryIdentityTool("list_tasks", params, extra);
|
|
4343
|
+
if (identityError) return finalizeProtocolTaskToolResponse("list_tasks", params ?? {}, identityError);
|
|
4186
4344
|
const credentialError = taskToolCredentialPolicyError("list_tasks", params ?? {}, extra);
|
|
4187
4345
|
if (credentialError) {
|
|
4188
4346
|
return finalizeProtocolTaskToolResponse("list_tasks", params ?? {}, credentialError, { echoContext: false });
|
|
@@ -4299,6 +4457,8 @@ function createAdcpServer(config) {
|
|
|
4299
4457
|
);
|
|
4300
4458
|
};
|
|
4301
4459
|
const wrappedHandler = (async (...args) => {
|
|
4460
|
+
const identityError = await authorizeAuxiliaryIdentityTool(customName, args[0], args[args.length - 1]);
|
|
4461
|
+
if (identityError) return finalizeCustomResponse(identityError);
|
|
4302
4462
|
const params = isPlainObject(args[0]) ? args[0] : {};
|
|
4303
4463
|
const selectedRelease = selectServedAdcpRelease(params, capConfig, adcpVersion, defaultAdcpVersion);
|
|
4304
4464
|
if (isMcpToolResponse(selectedRelease)) return finalizeCustomResponse(selectedRelease);
|
|
@@ -4417,6 +4577,7 @@ function createAdcpServer(config) {
|
|
|
4417
4577
|
...capConfig.account.defaultBilling && { default_billing: capConfig.account.defaultBilling },
|
|
4418
4578
|
required_for_products: capConfig.account.requiredForProducts ?? false,
|
|
4419
4579
|
sandbox: capConfig.account.sandbox ?? false,
|
|
4580
|
+
...identityOnboarding && { agent_onboarding: identityOnboarding },
|
|
4420
4581
|
...capConfig.account.changeFeed !== void 0 && { change_feed: capConfig.account.changeFeed }
|
|
4421
4582
|
};
|
|
4422
4583
|
}
|
|
@@ -4458,7 +4619,15 @@ function createAdcpServer(config) {
|
|
|
4458
4619
|
...capabilitiesData.webhook_signing,
|
|
4459
4620
|
supported: true,
|
|
4460
4621
|
profile,
|
|
4461
|
-
algorithms: [
|
|
4622
|
+
algorithms: [
|
|
4623
|
+
.../* @__PURE__ */ new Set([
|
|
4624
|
+
algorithm,
|
|
4625
|
+
...webhooks.webBotAuth ? [
|
|
4626
|
+
("privateKey" in webhooks.webBotAuth.key ? webhooks.webBotAuth.key.privateKey.crv : webhooks.webBotAuth.key.publicKey.crv) === "P-256" ? "ecdsa-p256-sha256" : "ed25519"
|
|
4627
|
+
] : []
|
|
4628
|
+
])
|
|
4629
|
+
],
|
|
4630
|
+
...webhooks.webBotAuth && { profiles: ["adcp/webhook-signing/v1", "web-bot-auth"] },
|
|
4462
4631
|
legacy_hmac_fallback: capabilitiesData.webhook_signing?.legacy_hmac_fallback ?? false,
|
|
4463
4632
|
delivery_retry_horizon_seconds: webhooks.deliveryRetryHorizonSeconds ?? 86400
|
|
4464
4633
|
};
|
|
@@ -4504,6 +4673,34 @@ function createAdcpServer(config) {
|
|
|
4504
4673
|
];
|
|
4505
4674
|
}
|
|
4506
4675
|
capabilitiesData.library_version = `@adcp/client@${LIBRARY_VERSION}`;
|
|
4676
|
+
async function authorizeAuxiliaryIdentityTool(toolName, params, extra) {
|
|
4677
|
+
const failure = getWebBotAuthAuthorizationFailure(extra?.authInfo?.extra);
|
|
4678
|
+
if (failure) return webBotAuthToolFailure(failure, servedAdcpVersion);
|
|
4679
|
+
if (!config.identity33) return void 0;
|
|
4680
|
+
try {
|
|
4681
|
+
await config.identity33.authorize(
|
|
4682
|
+
withImmutableServedAdcpVersion(
|
|
4683
|
+
{ toolName, stateStore, authInfo: extra?.authInfo, logger },
|
|
4684
|
+
adcpVersion
|
|
4685
|
+
),
|
|
4686
|
+
toolName,
|
|
4687
|
+
params
|
|
4688
|
+
);
|
|
4689
|
+
} catch (error) {
|
|
4690
|
+
if (error instanceof IdentityAuthorizationError)
|
|
4691
|
+
return adcpError("PERMISSION_DENIED", {
|
|
4692
|
+
message: error.message,
|
|
4693
|
+
...error.details && { details: { ...error.details } }
|
|
4694
|
+
});
|
|
4695
|
+
if (error instanceof AdcpError) return projectThrownAdcpError(error);
|
|
4696
|
+
return adcpError("PERMISSION_DENIED", { message: "Agent authorization failed" });
|
|
4697
|
+
}
|
|
4698
|
+
return void 0;
|
|
4699
|
+
}
|
|
4700
|
+
for (const field of ["request_signing", "webhook_signing"]) {
|
|
4701
|
+
const signing = capabilitiesData[field];
|
|
4702
|
+
if (signing?.profiles?.includes("web-bot-auth")) signing.wba_draft_revision = WEB_BOT_AUTH_DRAFT_REVISION;
|
|
4703
|
+
}
|
|
4507
4704
|
server.registerTool(
|
|
4508
4705
|
"get_adcp_capabilities",
|
|
4509
4706
|
{
|
|
@@ -4512,6 +4709,10 @@ function createAdcpServer(config) {
|
|
|
4512
4709
|
_meta: frameworkToolMeta
|
|
4513
4710
|
},
|
|
4514
4711
|
(async (params, extra = {}) => {
|
|
4712
|
+
const authorizationFailure = getWebBotAuthAuthorizationFailure(extra.authInfo?.extra);
|
|
4713
|
+
if (authorizationFailure) return webBotAuthToolFailure(authorizationFailure, servedAdcpVersion);
|
|
4714
|
+
const identityError = await authorizeAuxiliaryIdentityTool("get_adcp_capabilities", params, extra);
|
|
4715
|
+
if (identityError) return identityError;
|
|
4515
4716
|
const callRequestValidationMode = effectiveRequestValidationMode(extra);
|
|
4516
4717
|
const requestParams = isPlainObject(params) ? params : {};
|
|
4517
4718
|
const releaseSelection = selectServedAdcpRelease(requestParams, capConfig, adcpVersion, defaultAdcpVersion);
|
|
@@ -4646,7 +4847,12 @@ function createAdcpServer(config) {
|
|
|
4646
4847
|
delete validationPayload.media_buy.proposal_refinement;
|
|
4647
4848
|
delete validationPayload.media_buy.lifecycle_tools;
|
|
4648
4849
|
}
|
|
4649
|
-
const responseOutcome =
|
|
4850
|
+
const responseOutcome = config.identity33 && isAdcpVersionAtLeast(release.wireVersion, "3.3") ? validateIdentity33Payload(
|
|
4851
|
+
"get_adcp_capabilities",
|
|
4852
|
+
"response",
|
|
4853
|
+
validationPayload,
|
|
4854
|
+
release.validationVersion
|
|
4855
|
+
) : validateResponse("get_adcp_capabilities", validationPayload, release.validationVersion);
|
|
4650
4856
|
if (!responseOutcome.valid) {
|
|
4651
4857
|
logger.warn(
|
|
4652
4858
|
`Schema validation warning (response) for get_adcp_capabilities: ${formatIssues(responseOutcome.issues, 3, { rootSchemaId: responseOutcome.schemaId })}`,
|
|
@@ -4872,6 +5078,30 @@ function createAdcpServer(config) {
|
|
|
4872
5078
|
protocols,
|
|
4873
5079
|
signedRequests: signedRequestsState
|
|
4874
5080
|
});
|
|
5081
|
+
if (config.identity33) {
|
|
5082
|
+
for (const method of [
|
|
5083
|
+
"initialize",
|
|
5084
|
+
"tools/list",
|
|
5085
|
+
"tools/call",
|
|
5086
|
+
"resources/list",
|
|
5087
|
+
"resources/read",
|
|
5088
|
+
"prompts/list",
|
|
5089
|
+
"prompts/get",
|
|
5090
|
+
"tasks/get",
|
|
5091
|
+
"tasks/list",
|
|
5092
|
+
"tasks/cancel",
|
|
5093
|
+
"tasks/result"
|
|
5094
|
+
])
|
|
5095
|
+
wrapSdkRequestHandler(
|
|
5096
|
+
server,
|
|
5097
|
+
method,
|
|
5098
|
+
(original, request, extra) => withIdentity33SchemaScope(() => original(request, extra))
|
|
5099
|
+
);
|
|
5100
|
+
}
|
|
5101
|
+
wrapSdkRequestHandler(server, "tools/call", (original, request, extra) => {
|
|
5102
|
+
const failure = getWebBotAuthAuthorizationFailure(extra?.authInfo?.extra);
|
|
5103
|
+
return failure ? webBotAuthToolFailure(failure, servedAdcpVersion) : original(request, extra);
|
|
5104
|
+
});
|
|
4875
5105
|
return wrapped;
|
|
4876
5106
|
}
|
|
4877
5107
|
export {
|
|
@@ -340,6 +340,8 @@ export interface ResolveContext {
|
|
|
340
340
|
* before the platform method runs; treat fields the buyer sent as
|
|
341
341
|
* authoritative, but expect framework-injected entities (e.g.
|
|
342
342
|
* hydrated product / media-buy refs) to be visible here too.
|
|
343
|
+
* Account-sync guard lookups and upsert receive independent input
|
|
344
|
+
* copies so callback normalization cannot rewrite framework checks.
|
|
343
345
|
* - **Buyer-controlled untrusted data.** Free-text fields (`brief`,
|
|
344
346
|
* `message`, creative snippets, etc.) are attacker-controlled.
|
|
345
347
|
* Don't log `ctx.input` wholesale — secret fields like
|
|
@@ -374,6 +376,18 @@ export interface AccountToolContext<TCtxMeta = Record<string, unknown>> extends
|
|
|
374
376
|
/** Resolved Account from `accounts.resolve()`. Populated by the framework before dispatch. */
|
|
375
377
|
account: Account<TCtxMeta>;
|
|
376
378
|
}
|
|
379
|
+
/** Pre-write snapshots aligned with the accepted entries passed to `upsert`. */
|
|
380
|
+
export interface AccountUpsertContext<TCtxMeta = Record<string, unknown>> extends ResolveContext {
|
|
381
|
+
/** Null for an unresolved or ID-keyed entry. Lookup uses `provisioning: false`. */
|
|
382
|
+
readonly existing?: readonly (Account<TCtxMeta> | null)[];
|
|
383
|
+
}
|
|
384
|
+
/** A sync/list contract violation, delivered only to the seller. */
|
|
385
|
+
export interface AccountSyncDiagnostic {
|
|
386
|
+
readonly code: 'ACCOUNT_SYNC_IDEMPOTENCY_VIOLATION' | 'ACCOUNT_SYNC_PAYMENT_TERMS_MISMATCH' | 'ACCOUNT_SYNC_BILLING_MISMATCH' | 'ACCOUNT_SYNC_LOOKUP_UNSUPPORTED' | 'ACCOUNT_BILLING_FIELDS_MISSING';
|
|
387
|
+
readonly toolName: 'sync_accounts' | 'list_accounts';
|
|
388
|
+
/** Original request index for sync; page index for list. */
|
|
389
|
+
readonly index: number;
|
|
390
|
+
}
|
|
377
391
|
/**
|
|
378
392
|
* Request context for tools that can omit an `account` field —
|
|
379
393
|
* `preview_creative`, `list_creative_formats` (optional since rc.7), and
|
|
@@ -469,6 +483,15 @@ export declare function normalizeAccountResolution(resolution: AccountResolution
|
|
|
469
483
|
*/
|
|
470
484
|
export declare function isAccountResolutionMode(value: unknown): value is AccountResolutionMode;
|
|
471
485
|
export interface AccountStore<TCtxMeta = Record<string, unknown>> {
|
|
486
|
+
/**
|
|
487
|
+
* Convert sync contract violations to per-row failures. Default: diagnostics only.
|
|
488
|
+
* This is post-write response validation, not a transaction or rollback.
|
|
489
|
+
* For accept-or-reject guarantees, upsert must check these contracts before
|
|
490
|
+
* committing too (createKeyedAccountStore does so for its own backend).
|
|
491
|
+
*/
|
|
492
|
+
readonly strictIdempotency?: boolean;
|
|
493
|
+
/** Server-side diagnostics; never includes credentials or account metadata. Async hooks are fire-and-forget, with failures isolated from dispatch. */
|
|
494
|
+
readonly onDiagnostic?: (diagnostic: AccountSyncDiagnostic) => void;
|
|
472
495
|
/**
|
|
473
496
|
* How buyers reference accounts on this platform. Three onboarding models,
|
|
474
497
|
* aligned with the account-reference taxonomy clarified upstream in
|
|
@@ -640,7 +663,7 @@ export interface AccountStore<TCtxMeta = Record<string, unknown>> {
|
|
|
640
663
|
* verified `agent_url` from `credential.kind === 'http_sig'` when
|
|
641
664
|
* `agentRegistry` is not configured).
|
|
642
665
|
*/
|
|
643
|
-
upsert?(refs: AccountReference[], ctx?:
|
|
666
|
+
upsert?(refs: AccountReference[], ctx?: AccountUpsertContext<TCtxMeta>): Promise<SyncAccountsHandlerResult>;
|
|
644
667
|
/**
|
|
645
668
|
* sync_governance API surface. Buyers register governance agent endpoints
|
|
646
669
|
* per-account; the seller persists the binding and consults the agents
|
|
@@ -340,6 +340,8 @@ export interface ResolveContext {
|
|
|
340
340
|
* before the platform method runs; treat fields the buyer sent as
|
|
341
341
|
* authoritative, but expect framework-injected entities (e.g.
|
|
342
342
|
* hydrated product / media-buy refs) to be visible here too.
|
|
343
|
+
* Account-sync guard lookups and upsert receive independent input
|
|
344
|
+
* copies so callback normalization cannot rewrite framework checks.
|
|
343
345
|
* - **Buyer-controlled untrusted data.** Free-text fields (`brief`,
|
|
344
346
|
* `message`, creative snippets, etc.) are attacker-controlled.
|
|
345
347
|
* Don't log `ctx.input` wholesale — secret fields like
|
|
@@ -374,6 +376,18 @@ export interface AccountToolContext<TCtxMeta = Record<string, unknown>> extends
|
|
|
374
376
|
/** Resolved Account from `accounts.resolve()`. Populated by the framework before dispatch. */
|
|
375
377
|
account: Account<TCtxMeta>;
|
|
376
378
|
}
|
|
379
|
+
/** Pre-write snapshots aligned with the accepted entries passed to `upsert`. */
|
|
380
|
+
export interface AccountUpsertContext<TCtxMeta = Record<string, unknown>> extends ResolveContext {
|
|
381
|
+
/** Null for an unresolved or ID-keyed entry. Lookup uses `provisioning: false`. */
|
|
382
|
+
readonly existing?: readonly (Account<TCtxMeta> | null)[];
|
|
383
|
+
}
|
|
384
|
+
/** A sync/list contract violation, delivered only to the seller. */
|
|
385
|
+
export interface AccountSyncDiagnostic {
|
|
386
|
+
readonly code: 'ACCOUNT_SYNC_IDEMPOTENCY_VIOLATION' | 'ACCOUNT_SYNC_PAYMENT_TERMS_MISMATCH' | 'ACCOUNT_SYNC_BILLING_MISMATCH' | 'ACCOUNT_SYNC_LOOKUP_UNSUPPORTED' | 'ACCOUNT_BILLING_FIELDS_MISSING';
|
|
387
|
+
readonly toolName: 'sync_accounts' | 'list_accounts';
|
|
388
|
+
/** Original request index for sync; page index for list. */
|
|
389
|
+
readonly index: number;
|
|
390
|
+
}
|
|
377
391
|
/**
|
|
378
392
|
* Request context for tools that can omit an `account` field —
|
|
379
393
|
* `preview_creative`, `list_creative_formats` (optional since rc.7), and
|
|
@@ -469,6 +483,15 @@ export declare function normalizeAccountResolution(resolution: AccountResolution
|
|
|
469
483
|
*/
|
|
470
484
|
export declare function isAccountResolutionMode(value: unknown): value is AccountResolutionMode;
|
|
471
485
|
export interface AccountStore<TCtxMeta = Record<string, unknown>> {
|
|
486
|
+
/**
|
|
487
|
+
* Convert sync contract violations to per-row failures. Default: diagnostics only.
|
|
488
|
+
* This is post-write response validation, not a transaction or rollback.
|
|
489
|
+
* For accept-or-reject guarantees, upsert must check these contracts before
|
|
490
|
+
* committing too (createKeyedAccountStore does so for its own backend).
|
|
491
|
+
*/
|
|
492
|
+
readonly strictIdempotency?: boolean;
|
|
493
|
+
/** Server-side diagnostics; never includes credentials or account metadata. Async hooks are fire-and-forget, with failures isolated from dispatch. */
|
|
494
|
+
readonly onDiagnostic?: (diagnostic: AccountSyncDiagnostic) => void;
|
|
472
495
|
/**
|
|
473
496
|
* How buyers reference accounts on this platform. Three onboarding models,
|
|
474
497
|
* aligned with the account-reference taxonomy clarified upstream in
|
|
@@ -640,7 +663,7 @@ export interface AccountStore<TCtxMeta = Record<string, unknown>> {
|
|
|
640
663
|
* verified `agent_url` from `credential.kind === 'http_sig'` when
|
|
641
664
|
* `agentRegistry` is not configured).
|
|
642
665
|
*/
|
|
643
|
-
upsert?(refs: AccountReference[], ctx?:
|
|
666
|
+
upsert?(refs: AccountReference[], ctx?: AccountUpsertContext<TCtxMeta>): Promise<SyncAccountsHandlerResult>;
|
|
644
667
|
/**
|
|
645
668
|
* sync_governance API surface. Buyers register governance agent endpoints
|
|
646
669
|
* per-account; the seller persists the binding and consults the agents
|
|
@@ -19,7 +19,7 @@ export type { CursorPage, CursorRequest } from './pagination.mjs';
|
|
|
19
19
|
export { publishStatusChange, setStatusChangeBus, getStatusChangeBus, createInMemoryStatusChangeBus, type StatusChange, type StatusChangeBus, type StatusChangeResourceType, type StatusChangeListener, type PublishStatusChangeOpts, } from './status-changes.mjs';
|
|
20
20
|
export type { DecisioningCapabilities, ComplianceTestingCapabilities, CreativeAgentRef, TargetingCapabilities, TargetingPostalAreaSupport, ReportingCapabilities, } from './capabilities.mjs';
|
|
21
21
|
export { normalizePostalAreaSupport, normalizeTargetingCapabilities } from './capabilities.mjs';
|
|
22
|
-
export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountToolContext, ResolvedAuthInfo, } from './account.mjs';
|
|
22
|
+
export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountUpsertContext, AccountSyncDiagnostic, AccountToolContext, ResolvedAuthInfo, } from './account.mjs';
|
|
23
23
|
export { AccountNotFoundError, isAccountResolutionMode, normalizeAccountResolution, refAccountId, refHasNaturalKey, } from './account.mjs';
|
|
24
24
|
export { createTenantStore, narrowAccountRef } from './tenant-store.mjs';
|
|
25
25
|
export type { TenantStoreConfig } from './tenant-store.mjs';
|
|
@@ -19,7 +19,7 @@ export type { CursorPage, CursorRequest } from './pagination';
|
|
|
19
19
|
export { publishStatusChange, setStatusChangeBus, getStatusChangeBus, createInMemoryStatusChangeBus, type StatusChange, type StatusChangeBus, type StatusChangeResourceType, type StatusChangeListener, type PublishStatusChangeOpts, } from './status-changes';
|
|
20
20
|
export type { DecisioningCapabilities, ComplianceTestingCapabilities, CreativeAgentRef, TargetingCapabilities, TargetingPostalAreaSupport, ReportingCapabilities, } from './capabilities';
|
|
21
21
|
export { normalizePostalAreaSupport, normalizeTargetingCapabilities } from './capabilities';
|
|
22
|
-
export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountToolContext, ResolvedAuthInfo, } from './account';
|
|
22
|
+
export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountUpsertContext, AccountSyncDiagnostic, AccountToolContext, ResolvedAuthInfo, } from './account';
|
|
23
23
|
export { AccountNotFoundError, isAccountResolutionMode, normalizeAccountResolution, refAccountId, refHasNaturalKey, } from './account';
|
|
24
24
|
export { createTenantStore, narrowAccountRef } from './tenant-store';
|
|
25
25
|
export type { TenantStoreConfig } from './tenant-store';
|
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build an `AdcpServer` from a `DecisioningPlatform` impl.
|
|
3
|
-
*
|
|
4
|
-
* v6.0 alpha entry point. Translates the per-specialism platform interface
|
|
5
|
-
* into the framework's existing handler-style config and delegates to
|
|
6
|
-
* `createAdcpServer()`. This means every framework primitive — idempotency,
|
|
7
|
-
* RFC 9421 signing, governance, schema validation, state store, MCP/A2A
|
|
8
|
-
* wire mapping, sandbox boundary — applies unchanged. The new code is the
|
|
9
|
-
* adapter shim, not a forked runtime.
|
|
10
|
-
*
|
|
11
|
-
* **Adopter shape (unified hybrid):** each HITL-eligible tool is a single
|
|
12
|
-
* method. The method returns the wire success arm (sync fast path) OR
|
|
13
|
-
* `ctx.handoffToTask(fn)` to promote the call to a background task (HITL
|
|
14
|
-
* slow path). Adopters branch per-call; framework detects the `TaskHandoff`
|
|
15
|
-
* marker and dispatches accordingly:
|
|
16
|
-
*
|
|
17
|
-
* - Sync path: framework awaits the return value in foreground; projects
|
|
18
|
-
* it to the wire success arm. `throw new AdcpError(...)` projects to
|
|
19
|
-
* the wire `adcp_error` envelope.
|
|
20
|
-
* - HITL path: framework detects the `TaskHandoff` marker, allocates
|
|
21
|
-
* `taskId`, returns the submitted envelope to the buyer immediately,
|
|
22
|
-
* then runs the handoff function in background. The function's return
|
|
23
|
-
* value becomes the task's terminal `result`; `taskCtx.reject(...)`
|
|
24
|
-
* becomes a business `rejected` result, and thrown `AdcpError` becomes
|
|
25
|
-
* the terminal `error`.
|
|
26
|
-
*
|
|
27
|
-
* Generic thrown errors (`Error`, `TypeError`) fall through to the
|
|
28
|
-
* framework's `SERVICE_UNAVAILABLE` mapping.
|
|
29
|
-
*
|
|
30
|
-
* **Wired surface (6.0):** `SalesPlatform` (14 tools — 3 required core +
|
|
31
|
-
* 11 optional; unified hybrid on `create_media_buy` / `sync_creatives`),
|
|
32
|
-
* `CreativeBuilderPlatform` (build_creative / sync_creatives unified
|
|
33
|
-
* hybrid, optional preview_creative sync-only, optional refineCreative),
|
|
34
|
-
* `AudiencePlatform.syncAudiences`, `SignalsPlatform` (get_signals /
|
|
35
|
-
* activate_signal), `AccountStore` (reportUsage, getAccountFinancials),
|
|
36
|
-
* `ContentStandardsPlatform`, `CampaignGovernancePlatform`,
|
|
37
|
-
* `TenantRegistry` (multi-tenant health), `createPostgresTaskRegistry`,
|
|
38
|
-
* `tasks/get` wire handler, per-server + module-level `publishStatusChange`.
|
|
39
|
-
*
|
|
40
|
-
* **Still deferred (rc.1+):** MCP Resources subscription projection for
|
|
41
|
-
* `publishStatusChange`. The no-account tool surface (`preview_creative`,
|
|
42
|
-
* `list_creative_formats`, `provide_performance_feedback`) is now typed
|
|
43
|
-
* via `NoAccountCtx<TCtxMeta>` — handlers receive `ctx.account: Account |
|
|
44
|
-
* undefined` and must narrow before reading `ctx_metadata`.
|
|
45
|
-
*
|
|
46
|
-
* Status: Preview / 6.0. Exported from the canonical `@adcp/sdk/server`
|
|
47
|
-
* entry point; the decisioning implementation remains preview until GA.
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
1
|
import type { AdcpServer } from '../../adcp-server.mjs';
|
|
52
2
|
import { type AdcpServerConfig, type HandlerContext } from '../../create-adcp-server.mjs';
|
|
53
3
|
import type { DecisioningPlatform, RequiredPlatformsFor, RequiredCapabilitiesFor } from '../platform.mjs';
|