@adcp/sdk 14.0.0-beta.11 → 14.0.0-beta.13
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-storyboard-sandbox.js +16 -0
- package/bin/adcp.js +28 -30
- package/dist/lib/index.d.mts +3 -3
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +3 -1
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/schemas/index.d.mts +385 -1
- package/dist/lib/schemas/index.d.ts +385 -1
- package/dist/lib/schemas/index.d.ts.map +1 -1
- package/dist/lib/schemas/index.js +13 -0
- package/dist/lib/schemas/index.js.map +1 -1
- package/dist/lib/schemas/index.mjs +11 -0
- package/dist/lib/schemas/index.mjs.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/create-adcp-server.d.mts +2 -2
- package/dist/lib/server/create-adcp-server.d.ts +2 -2
- package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
- package/dist/lib/server/create-adcp-server.js +6 -1
- package/dist/lib/server/create-adcp-server.js.map +1 -1
- package/dist/lib/server/create-adcp-server.mjs +6 -1
- package/dist/lib/server/create-adcp-server.mjs.map +1 -1
- package/dist/lib/server/decisioning/index.d.mts +3 -3
- package/dist/lib/server/decisioning/index.d.ts +3 -3
- package/dist/lib/server/decisioning/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.js.map +1 -1
- package/dist/lib/server/decisioning/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.d.mts +24 -17
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +24 -17
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +71 -42
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +75 -43
- package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.mts +15 -21
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts +15 -21
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.js +100 -30
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs +100 -30
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/task-registry.d.mts +30 -16
- package/dist/lib/server/decisioning/runtime/task-registry.d.ts +30 -16
- package/dist/lib/server/decisioning/runtime/task-registry.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/task-registry.js +40 -20
- package/dist/lib/server/decisioning/runtime/task-registry.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/task-registry.mjs +38 -19
- package/dist/lib/server/decisioning/runtime/task-registry.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.d.mts +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.d.ts +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.js +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.mjs +2 -2
- package/dist/lib/server/decisioning/runtime/to-context.mjs.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.mts +3 -2
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +3 -2
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative.d.mts +10 -10
- package/dist/lib/server/decisioning/specialisms/creative.d.ts +10 -10
- package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -1
- package/dist/lib/server/index.d.mts +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/server/index.mjs.map +1 -1
- package/dist/lib/signing/agent-context.d.mts +1 -0
- package/dist/lib/signing/agent-context.d.ts +1 -0
- package/dist/lib/signing/agent-context.d.ts.map +1 -1
- package/dist/lib/signing/agent-context.js +37 -2
- package/dist/lib/signing/agent-context.js.map +1 -1
- package/dist/lib/signing/agent-context.mjs +38 -3
- package/dist/lib/signing/agent-context.mjs.map +1 -1
- package/dist/lib/signing/agent-fetch.d.mts +1 -2
- package/dist/lib/signing/agent-fetch.d.ts +1 -2
- package/dist/lib/signing/agent-fetch.d.ts.map +1 -1
- package/dist/lib/signing/agent-fetch.js +2 -0
- package/dist/lib/signing/agent-fetch.js.map +1 -1
- package/dist/lib/signing/agent-fetch.mjs +2 -0
- package/dist/lib/signing/agent-fetch.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/etld.js.map +1 -1
- package/dist/lib/signing/agent-resolver/etld.mjs.map +1 -1
- package/dist/lib/testing/client.d.mts +6 -0
- package/dist/lib/testing/client.d.ts +6 -0
- package/dist/lib/testing/client.d.ts.map +1 -1
- package/dist/lib/testing/client.js +76 -4
- package/dist/lib/testing/client.js.map +1 -1
- package/dist/lib/testing/client.mjs +75 -4
- package/dist/lib/testing/client.mjs.map +1 -1
- package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
- package/dist/lib/testing/compliance/comply.js +6 -0
- package/dist/lib/testing/compliance/comply.js.map +1 -1
- package/dist/lib/testing/compliance/comply.mjs +7 -1
- package/dist/lib/testing/compliance/comply.mjs.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.js +11 -2
- package/dist/lib/testing/storyboard/default-invariants.js.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.mjs +11 -2
- package/dist/lib/testing/storyboard/default-invariants.mjs.map +1 -1
- package/dist/lib/testing/storyboard/index.d.mts +1 -1
- package/dist/lib/testing/storyboard/index.d.ts +1 -1
- package/dist/lib/testing/storyboard/index.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/index.js.map +1 -1
- package/dist/lib/testing/storyboard/index.mjs.map +1 -1
- package/dist/lib/testing/storyboard/loader.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/loader.js +14 -0
- package/dist/lib/testing/storyboard/loader.js.map +1 -1
- package/dist/lib/testing/storyboard/loader.mjs +14 -0
- package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/phase-condition.d.mts +41 -0
- package/dist/lib/testing/storyboard/phase-condition.d.ts +42 -0
- package/dist/lib/testing/storyboard/phase-condition.d.ts.map +1 -0
- package/dist/lib/testing/storyboard/phase-condition.js +215 -0
- package/dist/lib/testing/storyboard/phase-condition.js.map +1 -0
- package/dist/lib/testing/storyboard/phase-condition.mjs +189 -0
- package/dist/lib/testing/storyboard/phase-condition.mjs.map +1 -0
- package/dist/lib/testing/storyboard/request-builder.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.js +15 -2
- package/dist/lib/testing/storyboard/request-builder.js.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.mjs +15 -2
- package/dist/lib/testing/storyboard/request-builder.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.d.mts +15 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.d.ts +16 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.d.ts.map +1 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.js +106 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.js.map +1 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.mjs +82 -0
- package/dist/lib/testing/storyboard/request-signing/functional-dispatch.mjs.map +1 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.d.mts +15 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.d.ts +15 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/test-kit.js +58 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.js.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/test-kit.mjs +58 -0
- package/dist/lib/testing/storyboard/request-signing/test-kit.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js +7 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +6 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +67 -24
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.mjs +67 -24
- package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
- package/dist/lib/testing/storyboard/task-map.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/task-map.js +6 -2
- package/dist/lib/testing/storyboard/task-map.js.map +1 -1
- package/dist/lib/testing/storyboard/task-map.mjs +6 -2
- package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
- package/dist/lib/testing/storyboard/types.d.mts +5 -4
- package/dist/lib/testing/storyboard/types.d.ts +5 -4
- package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/types.js.map +1 -1
- package/dist/lib/testing/storyboard/types.mjs.map +1 -1
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/webhook-assertions.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/webhook-assertions.js +60 -4
- package/dist/lib/testing/storyboard/webhook-assertions.js.map +1 -1
- package/dist/lib/testing/storyboard/webhook-assertions.mjs +60 -4
- package/dist/lib/testing/storyboard/webhook-assertions.mjs.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.d.mts +15 -0
- package/dist/lib/testing/storyboard/webhook-receiver.d.ts +15 -0
- package/dist/lib/testing/storyboard/webhook-receiver.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.js +57 -6
- package/dist/lib/testing/storyboard/webhook-receiver.js.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.mjs +57 -6
- package/dist/lib/testing/storyboard/webhook-receiver.mjs.map +1 -1
- package/dist/lib/testing/types.d.mts +12 -0
- package/dist/lib/testing/types.d.ts +12 -0
- package/dist/lib/testing/types.d.ts.map +1 -1
- package/dist/lib/testing/types.js.map +1 -1
- package/dist/lib/types/comply-test-controller.d.ts +1 -14
- package/dist/lib/types/core.generated.d.mts +6 -3
- package/dist/lib/types/core.generated.d.ts +6 -3
- package/dist/lib/types/core.generated.d.ts.map +1 -1
- package/dist/lib/types/core.generated.js.map +1 -1
- package/dist/lib/types/get-products.d.ts +1 -14
- package/dist/lib/types/index.d.mts +1 -1
- package/dist/lib/types/index.d.ts +1 -1
- package/dist/lib/types/index.d.ts.map +1 -1
- package/dist/lib/types/index.js.map +1 -1
- package/dist/lib/types/index.mjs.map +1 -1
- package/dist/lib/types/list-transformers.d.ts +9 -5
- package/dist/lib/types/schemas.generated.d.ts +23 -352
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +7 -4
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/schemas.generated.mjs +6 -4
- package/dist/lib/types/schemas.generated.mjs.map +1 -1
- package/dist/lib/types/server-payload-aliases.d.mts +2 -1
- package/dist/lib/types/server-payload-aliases.d.ts +2 -1
- package/dist/lib/types/server-payload-aliases.d.ts.map +1 -1
- package/dist/lib/types/server-payload-aliases.js.map +1 -1
- package/dist/lib/types/tools.generated.d.mts +6 -3
- package/dist/lib/types/tools.generated.d.ts +6 -3
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/types/tools.generated.js.map +1 -1
- package/dist/lib/utils/build-creative-return-builders.d.mts +5 -1
- package/dist/lib/utils/build-creative-return-builders.d.ts +5 -1
- package/dist/lib/utils/build-creative-return-builders.d.ts.map +1 -1
- package/dist/lib/utils/build-creative-return-builders.js +9 -3
- package/dist/lib/utils/build-creative-return-builders.js.map +1 -1
- package/dist/lib/utils/build-creative-return-builders.mjs +7 -2
- package/dist/lib/utils/build-creative-return-builders.mjs.map +1 -1
- package/dist/lib/utils/response-unwrapper.js +1 -1
- package/dist/lib/utils/response-unwrapper.js.map +1 -1
- package/dist/lib/utils/response-unwrapper.mjs +1 -1
- package/dist/lib/utils/response-unwrapper.mjs.map +1 -1
- package/dist/lib/validation/schema-loader.d.ts.map +1 -1
- package/dist/lib/validation/schema-loader.js +16 -7
- package/dist/lib/validation/schema-loader.js.map +1 -1
- package/dist/lib/validation/schema-loader.mjs +16 -7
- package/dist/lib/validation/schema-loader.mjs.map +1 -1
- 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.js.map +1 -1
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/version.mjs.map +1 -1
- package/docs/llms.txt +2 -2
- package/docs/migration-5.x-to-6.x.md +3 -2
- package/docs/migration-task-registry-scoping.md +61 -0
- package/examples/hello_seller_adapter_guaranteed.ts +1 -1
- package/package.json +5 -5
- package/skills/build-decisioning-creative-template/SKILL.md +2 -2
- package/skills/build-decisioning-platform/SKILL.md +4 -2
- package/skills/build-decisioning-platform/advanced/REFERENCE.md +7 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/server/index.ts"],"sourcesContent":["export { adcpError } from './errors';\nexport type { AdcpErrorOptions, AdcpErrorPayload, AdcpErrorResponse } from './errors';\n\nexport { normalizeError, normalizeErrors } from './normalize-errors';\nexport type { NormalizedError } from './normalize-errors';\n\nexport { pickSafeDetails } from './pick-safe-details';\nexport type { PickSafeDetailsOptions } from './pick-safe-details';\n\nexport { wrapEnvelope } from './wrap-envelope';\nexport type { WrapEnvelopeOptions } from './wrap-envelope';\n\nexport {\n ERROR_ENVELOPE_FIELD_ALLOWLIST,\n DEFAULT_ERROR_ENVELOPE_FIELDS,\n ADCP_ERROR_FIELD_ALLOWLIST,\n CONFLICT_ADCP_ERROR_ALLOWLIST,\n} from './envelope-allowlist';\n\nexport { scanArgsForCredentials, DEFAULT_CREDENTIAL_PATTERNS } from './credential-policy';\nexport type {\n CredentialPolicy,\n CredentialPolicyMode,\n CredentialPolicyConfig,\n CredentialPatternsConfig,\n} from './credential-policy';\n\nexport { createDynamicRegistry } from './dynamic-registry';\nexport type {\n DynamicRegistry,\n DynamicRegistryConfig,\n DynamicRegistryRegisterOptions,\n PendingRegistries,\n RegistryShape,\n} from './dynamic-registry';\n\nexport { defineOperationalPlatform } from './operational-platform';\nexport type { OperationalPlatform, OperationalContext } from './operational-platform';\n\nexport { pickWireSpecFields, scrubExtensions, WIRE_SPEC_FIELDS } from './wire-safe';\nexport type { WireSafe, WireSpecRequestName, ScrubExtensionsOptions } from './wire-safe';\nexport type { RequireCacheScopeWhenProducts, ServerPayload } from '../types/server-payload';\nexport type {\n ActivateSignalPayload,\n AcquireRightsAcquiredPayload as LegacyAcquireRightsAcquiredPayload,\n AcquireRightsPayload as LegacyAcquireRightsPayload,\n AcquireRightsPendingApprovalPayload as LegacyAcquireRightsPendingApprovalPayload,\n AcquireRightsRejectedPayload as LegacyAcquireRightsRejectedPayload,\n BuildCreativeMultiPayload as LegacyBuildCreativeMultiPayload,\n BuildCreativePayload as LegacyBuildCreativePayload,\n CalibrateContentPayload as LegacyCalibrateContentPayload,\n CheckGovernancePayload,\n CreateCollectionListPayload,\n CreateContentStandardsPayload as LegacyCreateContentStandardsPayload,\n CreateMediaBuyPayload as LegacyCreateMediaBuyPayload,\n CreatePropertyListPayload,\n CreativeApprovalPayload,\n CreativeApprovedPayload,\n CreativePendingReviewPayload,\n CreativeRejectedPayload,\n DeleteCollectionListPayload,\n DeletePropertyListPayload,\n GetAccountFinancialsPayload,\n GetAccountFinancialsSuccessPayload,\n GetAdCPCapabilitiesPayload,\n GetBrandIdentityPayload,\n GetCollectionListPayload,\n GetContentStandardsPayload as LegacyGetContentStandardsPayload,\n GetCreativeDeliveryPayload as LegacyGetCreativeDeliveryPayload,\n GetCreativeFeaturesPayload as LegacyGetCreativeFeaturesPayload,\n GetMediaBuyArtifactsPayload as LegacyGetMediaBuyArtifactsPayload,\n GetMediaBuyDeliveryPayload as LegacyGetMediaBuyDeliveryPayload,\n GetMediaBuysPayload as LegacyGetMediaBuysPayload,\n GetPlanAuditLogsPayload,\n GetProductsPayload as LegacyGetProductsPayload,\n GetPropertyListPayload,\n GetRightsPayload as LegacyGetRightsPayload,\n GetRightsResponsePayload as LegacyGetRightsResponsePayload,\n GetSignalsPayload,\n ListAccountsPayload,\n ListCollectionListsPayload,\n ListContentStandardsPayload as LegacyListContentStandardsPayload,\n ListCreativeFormatsPayload as LegacyListCreativeFormatsPayload,\n ListCreativeFormatsResponsePayload as LegacyListCreativeFormatsResponsePayload,\n ListCreativeFormatsServerPayload as LegacyListCreativeFormatsServerPayload,\n ListCreativesPayload as LegacyListCreativesPayload,\n ListPropertyListsPayload,\n LogEventPayload,\n CanonicalPreviewCreativePayload,\n PreviewCreativePayload as LegacyPreviewCreativePayload,\n ProvidePerformanceFeedbackPayload,\n ReportPlanOutcomePayload,\n ReportUsagePayload,\n SIGetOfferingPayload,\n SIInitiateSessionPayload,\n SISendMessagePayload,\n SITerminateSessionPayload,\n SyncAccountsPayload,\n SyncAccountsSuccessPayload,\n SyncAudiencesPayload,\n SyncCatalogsPayload,\n SyncCreativesErrorPayload,\n SyncCreativesPayload,\n SyncCreativesSuccessPayload,\n SyncEventSourcesPayload,\n SyncGovernancePayload,\n SyncGovernanceSuccessPayload,\n SyncPlansPayload,\n UpdateCollectionListPayload,\n UpdateContentStandardsPayload as LegacyUpdateContentStandardsPayload,\n UpdateMediaBuyPayload as LegacyUpdateMediaBuyPayload,\n UpdatePropertyListPayload,\n UpdateRightsPayload as LegacyUpdateRightsPayload,\n ValidateContentDeliveryPayload as LegacyValidateContentDeliveryPayload,\n} from '../types/server-payload-aliases';\n\nexport { assertNoExampleTlds } from './example-tld-guard';\nexport type { AssertNoExampleTldsOptions } from './example-tld-guard';\n\n// Raw wire response builders remain available only through explicit\n// `legacy*` aliases on this primary barrel. The legacy/v5 subpath preserves\n// their historical names for handler-bag adopters.\nexport {\n capabilitiesResponse as legacyCapabilitiesResponse,\n productsResponse as legacyProductsResponse,\n mediaBuyResponse as legacyMediaBuyResponse,\n deliveryResponse as legacyDeliveryResponse,\n listAccountsResponse as legacyListAccountsResponse,\n listCreativeFormatsResponse as legacyListCreativeFormatsResponse,\n updateMediaBuyResponse as legacyUpdateMediaBuyResponse,\n getMediaBuysResponse as legacyGetMediaBuysResponse,\n performanceFeedbackResponse as legacyPerformanceFeedbackResponse,\n buildCreativeResponse as legacyBuildCreativeResponse,\n buildCreativeMultiResponse as legacyBuildCreativeMultiResponse,\n previewCreativeResponse as legacyPreviewCreativeResponse,\n creativeDeliveryResponse as legacyCreativeDeliveryResponse,\n listCreativesResponse as legacyListCreativesResponse,\n listPropertyListsResponse as legacyListPropertyListsResponse,\n listCollectionListsResponse as legacyListCollectionListsResponse,\n listContentStandardsResponse as legacyListContentStandardsResponse,\n getPlanAuditLogsResponse as legacyGetPlanAuditLogsResponse,\n syncCreativesResponse as legacySyncCreativesResponse,\n getSignalsResponse as legacyGetSignalsResponse,\n activateSignalResponse as legacyActivateSignalResponse,\n cancelMediaBuyResponse as legacyCancelMediaBuyResponse,\n acquireRightsResponse as legacyAcquireRightsResponse,\n acquireRightsAcquired as legacyAcquireRightsAcquired,\n acquireRightsPendingApproval as legacyAcquireRightsPendingApproval,\n acquireRightsRejected as legacyAcquireRightsRejected,\n updateRightsResponse as legacyUpdateRightsResponse,\n updateRightsSuccess as legacyUpdateRightsSuccess,\n creativeApprovalResponse as legacyCreativeApprovalResponse,\n creativeApprovalApproved as legacyCreativeApprovalApproved,\n creativeApprovalRejected as legacyCreativeApprovalRejected,\n creativeApprovalPendingReview as legacyCreativeApprovalPendingReview,\n creativeApprovalError as legacyCreativeApprovalError,\n syncAccountsResponse as legacySyncAccountsResponse,\n syncGovernanceResponse as legacySyncGovernanceResponse,\n reportUsageResponse as legacyReportUsageResponse,\n toStructuredContent,\n} from './responses';\nexport type { McpToolResponse } from './responses';\n\nexport { validActionsForStatus } from './media-buy-helpers';\nexport type { ValidAction, CancelMediaBuyInput } from './media-buy-helpers';\nexport { assertUpdateMediaBuyAllowed } from './media-buy-actions';\nexport type { AssertUpdateMediaBuyAllowedOptions } from './media-buy-actions';\n\nexport { createMediaBuyStore, DEFAULT_MEDIA_BUY_STORE_COLLECTION } from './media-buy-store';\nexport type {\n MediaBuyStore,\n CreateMediaBuyStoreOptions,\n CreateMediaBuyInputForStore,\n CreateMediaBuyResultForStore,\n UpdateMediaBuyInputForStore,\n GetMediaBuysResultForStore,\n} from './media-buy-store';\n\nexport {\n MEDIA_BUY_TRANSITIONS,\n CREATIVE_ASSET_TRANSITIONS,\n isLegalMediaBuyTransition,\n isLegalCreativeTransition,\n assertMediaBuyTransition,\n assertCreativeTransition,\n} from './state-machine';\n\nexport { getAccountMode, isSandboxOrMockAccount, assertSandboxAccount } from './account-mode';\nexport type { AccountMode } from './account-mode';\n\nexport {\n taskToolResponse,\n registerAdcpTaskTool,\n createTaskCapableServer,\n InMemoryTaskStore,\n isTerminal,\n} from './tasks';\nexport type {\n AdcpTaskToolConfig,\n TaskStore,\n TaskMessageQueue,\n CreateTaskOptions,\n ToolTaskHandler,\n CreateTaskRequestHandlerExtra,\n TaskRequestHandlerExtra,\n CreateTaskResult,\n GetTaskResult,\n Task,\n} from './tasks';\n\nexport {\n PostgresTaskStore,\n cleanupExpiredTasks,\n getMcpTasksMigration,\n MCP_TASKS_MIGRATION,\n} from './postgres-task-store';\nexport type { PgQueryable, PostgresTaskStoreOptions } from './postgres-task-store';\n\nexport {\n registerTestController,\n handleTestControllerRequest,\n TestControllerError,\n toMcpResponse,\n TOOL_INPUT_SHAPE,\n CONTROLLER_SCENARIOS,\n DISCOVERY_ARM_SCENARIOS,\n SEED_SCENARIOS,\n SEED_MESSAGES,\n SESSION_ENTRY_CAP,\n enforceMapCap,\n createSeedFixtureCache,\n} from './test-controller';\nexport type {\n TestControllerStore,\n TestControllerStoreFactory,\n TestControllerStoreOrFactory,\n ControllerScenario,\n SeedScenario,\n SeedFixtureCache,\n} from './test-controller';\n\nexport { serve, taskScopeFromPrincipal, UnknownHostError, hostname, resolveHost } from './serve';\nexport type { ServeContext, ServeOptions, ProtectedResourceMetadata } from './serve';\n\nexport { createExpressAdapter } from './express-adapter';\nexport type { ExpressAdapter, ExpressAdapterOptions } from './express-adapter';\n\nexport {\n verifyApiKey,\n verifyBearer,\n anyOf,\n extractBearerToken,\n respondUnauthorized,\n signatureErrorCodeFromCause,\n AuthError,\n AUTH_NEEDS_RAW_BODY,\n tagAuthenticatorNeedsRawBody,\n authenticatorNeedsRawBody,\n AUTH_PRESENCE_GATED,\n tagAuthenticatorPresenceGated,\n isAuthenticatorPresenceGated,\n ADCP_SERVE_REQUEST_CONTEXT,\n getServeRequestContext,\n DEFAULT_JWT_ALGORITHMS,\n DEFAULT_JWT_CLOCK_TOLERANCE_SECONDS,\n} from './auth';\nexport type {\n Authenticator,\n AuthPrincipal,\n AuthResult,\n VerifyApiKeyOptions,\n VerifyBearerOptions,\n RespondUnauthorizedOptions,\n ServeRequestContext,\n} from './auth';\n\nexport { verifyIntrospection } from './auth-introspection';\nexport type {\n VerifyIntrospectionOptions,\n IntrospectionCacheOptions,\n IntrospectionResponse,\n} from './auth-introspection';\n\nexport {\n verifySignatureAsAuthenticator,\n requireSignatureWhenPresent,\n requireAuthenticatedOrSigned,\n mcpToolNameResolver,\n} from './auth-signature';\nexport type {\n VerifySignatureAsAuthenticatorOptions,\n RequireSignatureWhenPresentOptions,\n RequireAuthenticatedOrSignedOptions,\n} from './auth-signature';\n\nexport {\n InMemoryStateStore,\n StateError,\n PatchConflictError,\n DEFAULT_MAX_DOCUMENT_BYTES,\n SESSION_KEY_FIELD,\n createSessionedStore,\n scopedStore,\n patchWithRetry,\n isPutIfMatchConflict,\n validateCollection,\n validateId,\n validatePayloadSize,\n validateWrite,\n} from './state-store';\nexport type {\n AdcpStateStore,\n InMemoryStateStoreOptions,\n ListOptions,\n ListResult,\n PatchWithRetryOptions,\n PutIfMatchResult,\n StateErrorCode,\n VersionedDocument,\n} from './state-store';\n\nexport { PostgresStateStore, getAdcpStateMigration, ADCP_STATE_MIGRATION } from './postgres-state-store';\nexport type { PostgresStateStoreOptions } from './postgres-state-store';\n\nexport { structuredSerialize, structuredDeserialize } from './structured-serialize';\n\nexport { MCP_APP_RESOURCE_MIME_TYPE } from './mcp-app';\nexport type {\n AdcpMcpResourceDefinition,\n McpAppResourceCsp,\n McpAppResourcePermissions,\n McpAppResourceUiMeta,\n McpAppResourceMeta,\n McpAppResourceReadContext,\n} from './mcp-app';\n\n// `createAdcpServer` is NOT re-exported from `@adcp/sdk/server` anymore —\n// LLMs scaffolding from skills consistently latched onto it as the canonical\n// entry point despite the @deprecated JSDoc. Removing the top-level export\n// forces new code to either reach for `createAdcpServerFromPlatform` (the v6\n// canonical) or import from `@adcp/sdk/server/legacy/v5` (mid-migration /\n// escape-hatch only). Breaking change: v5 adopters see a hard import error\n// and update their import path. The migration is one line; the LLM-output\n// quality win is significant. See `docs/migration-5.x-to-6.x.md`.\nexport {\n requireSessionKey,\n ADCP_PRE_TRANSPORT,\n ADCP_SIGNED_REQUESTS_STATE,\n ADCP_INSTRUCTIONS_FN,\n} from './create-adcp-server';\nexport type { SessionContext, OnInstructionsError, MaybePromise, BridgeMarker } from './create-adcp-server';\nexport type {\n AdcpServer,\n AdcpServerComplianceApi,\n AdcpServerTransport,\n AdcpTestRequest,\n AdcpTestToolsCallRequest,\n AdcpTestResponse,\n} from './adcp-server';\n// Handler-bag types describe the raw v5 server surface. Primary-barrel names\n// are explicit Legacy aliases; the legacy/v5 subpath retains the originals.\nexport type {\n AdcpServerConfig as LegacyAdcpServerConfig,\n WebhooksConfig,\n AdcpToolMap as LegacyAdcpToolMap,\n AdcpServerToolName,\n AdcpCapabilitiesConfig,\n AdcpCapabilitiesOverrides,\n AdcpCustomToolConfig as LegacyAdcpCustomToolConfig,\n McpAppUiMeta,\n McpAppMeta,\n AdcpLogger,\n SignedRequestsConfig,\n AdcpPreTransport,\n AdcpSignedRequestsState,\n HandlerContext as LegacyHandlerContext,\n SessionKeyContext,\n MediaBuyHandlers as LegacyMediaBuyHandlers,\n ProposalNegotiationHandlers as LegacyProposalNegotiationHandlers,\n SignalsHandlers as LegacySignalsHandlers,\n CreativeHandlers as LegacyCreativeHandlers,\n GovernanceHandlers as LegacyGovernanceHandlers,\n AccountHandlers as LegacyAccountHandlers,\n EventTrackingHandlers as LegacyEventTrackingHandlers,\n SponsoredIntelligenceHandlers as LegacySponsoredIntelligenceHandlers,\n ResolveAccountContext as LegacyResolveAccountContext,\n} from './create-adcp-server';\n\nexport { DEFAULT_REPORTING_CAPABILITIES } from './product-defaults';\n\nexport {\n isSandboxRequest,\n mergeSeededProductsIntoResponse,\n filterValidSeededProducts,\n filterValidSeededCreatives,\n filterValidSeededMediaBuys,\n filterValidSeededAccounts,\n filterValidSeededAccountFinancials,\n filterValidSeededCreativeFormats,\n mergeSeededCreativesIntoResponse,\n mergeSeededMediaBuysIntoResponse,\n mergeSeededAccountsIntoResponse,\n mergeSeededCreativeFormatsIntoResponse,\n pickSeededAccountFinancialsForRequest,\n replaceAccountFinancialsIfSeeded,\n bridgeFromTestControllerStore,\n bridgeFromSessionStore,\n} from './test-controller-bridge';\nexport type {\n TestControllerBridge,\n TestControllerBridgeContext,\n BridgeFromSessionStoreOptions,\n SeededCreative,\n SeededMediaBuy,\n SeededAccountFinancials,\n} from './test-controller-bridge';\n\nexport {\n createIdempotencyStore,\n probeIdempotencyStore,\n memoryBackend,\n pgBackend,\n getIdempotencyMigration,\n IDEMPOTENCY_MIGRATION,\n cleanupExpiredIdempotency,\n redisBackend,\n createLazyBackend,\n hashPayload,\n IdempotencyClaimOwnershipError,\n} from './idempotency';\nexport type {\n IdempotencyStore,\n IdempotencyStoreConfig,\n IdempotencyBackend,\n IdempotencyCacheEntry,\n IdempotencyCheckResult,\n MemoryBackendOptions,\n PgBackendOptions,\n RedisBackendOptions,\n RedisBackendClient,\n RedisLikeClient,\n LazyBackendFactory,\n LazyBackendOptions,\n} from './idempotency';\n\nexport { createA2AAdapter, A2AInvocationError } from './a2a-adapter';\nexport type {\n A2AAdapter,\n A2AAdapterOptions,\n A2AAgentCardOverrides,\n A2AAgentCapabilitiesOverride,\n A2AAgentSkillOverride,\n A2AMountOptions,\n ExpressAppLike,\n LegacyHttpSecurityScheme,\n LegacySecurityScheme,\n} from './a2a-adapter';\n\nexport { createWebhookEmitter, memoryWebhookDeliveryStore, memoryWebhookKeyStore } from './webhook-emitter';\nexport {\n pgWebhookDeliveryStore,\n pgWebhookDeliveryRecoveryBackend,\n redisWebhookDeliveryStore,\n redisWebhookDeliveryRecoveryBackend,\n getWebhookDeliveryMigration,\n getWebhookDeliveryRecoveryMigration,\n WEBHOOK_DELIVERY_MIGRATION,\n WEBHOOK_DELIVERY_RECOVERY_MIGRATION,\n createWebhookDeliveryRecovery,\n pollWebhookDeliveryRecovery,\n memoryWebhookDeliveryRecoveryBackend,\n WebhookDeliveryTerminalError,\n isWebhookDeliveryTerminalError,\n} from './webhook-delivery';\nexport type {\n PgWebhookDeliveryStoreOptions,\n PgWebhookDeliveryRecoveryOptions,\n RedisWebhookDeliveryStoreOptions,\n RedisWebhookDeliveryRecoveryOptions,\n ProtectedWebhookAuthentication,\n WebhookAuthenticationAdapter,\n WebhookAuthenticationContext,\n StoredWebhookDeliverySnapshot,\n WebhookRecoveryRecord,\n WebhookRecoveryLease,\n WebhookRecoveryCheckpointResult,\n WebhookRecoveryCheckpointOutcome,\n WebhookDeliveryRecoveryBackend,\n DurableWebhookDeliveryRecovery,\n CreateWebhookDeliveryRecoveryOptions,\n PollWebhookDeliveryRecoveryOptions,\n} from './webhook-delivery';\nexport type {\n WebhookEmitter,\n RecoverableWebhookEmitter,\n WebhookEmitterOptions,\n WebhookEmitParams,\n WebhookEmitResult,\n WebhookRecoveredDelivery,\n WebhookEmitAttempt,\n WebhookEmitAttemptResult,\n WebhookDeliveryBinding,\n WebhookDeliveryRetired,\n WebhookDeliveryRecord,\n WebhookDeliveryKey,\n WebhookDeliveryProposal,\n WebhookDeliverySnapshot,\n WebhookDeliveryRecovery,\n WebhookDeliveryRecoveryClaim,\n WebhookDeliveryStore,\n WebhookIdempotencyKeyStore,\n WebhookRetryOptions,\n WebhookAuthentication,\n} from './webhook-emitter';\nexport type { SigningProvider } from '../signing/provider';\n\nexport { createPinAndBindFetch, WEBHOOK_SSRF_POLICY, LOOPBACK_OK_WEBHOOK_SSRF_POLICY } from './pin-and-bind-fetch';\nexport type { PinAndBindFetchOptions, DnsLookupAll } from './pin-and-bind-fetch';\n\nexport {\n checkGovernance,\n createAdcpGovernanceEnforcementMiddleware,\n governanceDeniedError,\n governanceUnavailableError,\n} from './governance';\nexport type {\n AdcpGovernanceEnforcementMiddleware,\n CheckGovernanceOptions,\n GovernanceCallResult,\n GovernanceApproved,\n GovernanceDenied,\n GovernanceConditions,\n} from './governance';\n\nexport {\n GovernanceAuthorizationError,\n GovernanceReplayStoreAdapter,\n InMemoryGovernanceReplayStore,\n buildGovernanceExecutionCommitment,\n buildGovernanceExecutionRequest,\n computeGovernedPayloadHash,\n createGovernanceEnforcementMiddleware,\n verifyGovernanceAuthorization,\n} from '../governance';\nexport type {\n BuildGovernanceExecutionRequestInput,\n GovernanceAuthorizationClaims,\n GovernanceAuthorizationErrorCode,\n GovernanceAuthorizationResult,\n GovernanceAuthorizationSuccess,\n GovernanceCommitment,\n GovernanceEnforcementMiddleware,\n GovernanceEnforcementMiddlewareConfig,\n GovernanceEnforcementMiddlewareInput,\n GovernanceReplayStore,\n GovernanceReplayBinding,\n GovernanceRevocationResolver,\n GovernanceRevocationStatus,\n VerifyGovernanceAuthorizationOptions,\n} from '../governance';\n\nexport {\n clearDefaultResolvedListCache,\n createResolvedListCache,\n DEFAULT_RESOLVE_LIST_PAGE_SIZE,\n defaultResolvedListCache,\n resolvePropertyList,\n resolveCollectionList,\n resolvedListCacheKey,\n matchesPropertyList,\n matchesCollectionList,\n} from './targeting-helpers';\nexport type {\n ResolvedListCache,\n ResolvedListCacheEntry,\n ResolvedListCacheValue,\n ResolvedListKind,\n ResolvedPropertyList,\n ResolvedCollectionList,\n ResolvedCollection,\n ResolveListCallTool,\n ResolveListOptions,\n} from './targeting-helpers';\n\n// ---------------------------------------------------------------------------\n// Platform-shaped server entry point (recommended for new agents)\n// ---------------------------------------------------------------------------\n//\n// `createAdcpServerFromPlatform` wraps `createAdcpServer` (the lower-level\n// handler-bag entry above) with compile-time specialism enforcement\n// (`RequiredPlatformsFor<S>`), capability projection, idempotency wiring,\n// async tasks, status normalization, multi-tenant routing, and async task\n// completion webhooks. Synchronous terminal responses remain inline by\n// default. Adopters declare a typed `DecisioningPlatform` per-specialism\n// and the framework wires the rest. See `docs/migration-5.x-to-6.x.md` and\n// `skills/build-decisioning-platform/` for the full walkthrough.\n//\n// Both `createAdcpServer` and `createAdcpServerFromPlatform` live on the\n// same import path so adopters discover them as siblings; pick the\n// function shape that matches your agent. The platform path internally\n// builds an `AdcpServerConfig` and calls `createAdcpServer` — they're\n// not adjacent surfaces, they're parent-child layers of the same SDK.\n//\n// **Pin to v5 long-term?** Import from `@adcp/sdk/server/legacy/v5`\n// instead. The subpath is the stable home for the v5 handler-bag\n// constructor; the top-level re-export here may be removed in a\n// future major. New code should not pin against `legacy/v5` either —\n// reach for `createAdcpServerFromPlatform` first.\nexport * from './decisioning';\nexport {\n createProposalRefinementHandler,\n createProposalSuccessor,\n proposalRefinementScopeFromContext,\n classifyProposalRefinementFailure,\n defineProposalRefinementCapabilities,\n ProposalSellerPreflightError,\n} from '../negotiation/seller';\nexport { proposalTermsDigest, verifyProposalTermsDigest } from '../negotiation/verification';\nexport type {\n ProposalCommercialEvaluator,\n ProposalFailureClassification,\n ProposalEvaluationContext,\n ProposalRefinementHandler,\n ProposalRefinementHandlerOptions,\n ProposalRefinementStore,\n ProposalRefinementTransaction,\n ProposalRefinementScope,\n ProposalSourceExpectation,\n ProposalSourceSnapshot,\n ProposalSuccessorInput,\n} from '../negotiation/seller';\nexport type {\n CanonicalProposal,\n ProposalCommercialTerms,\n ProposalRefinementCapabilities,\n ProposalRefinementResult,\n RefineProposalsRequest,\n RefineProposalsResponse,\n} from '../negotiation/types';\n\n// ---------------------------------------------------------------------------\n// Ctx-metadata store — opaque-blob round-trip for adapter-internal state\n// ---------------------------------------------------------------------------\n//\n// Publishers attach platform-specific opaque blobs to any returned resource\n// (product, media_buy, package, creative, audience, signal, rights_grant);\n// the framework persists by `(account_id, kind, id)`, strips from buyer-\n// facing wire payloads, threads back into the publisher's request context\n// on subsequent calls referencing the same resource ID. See\n// `docs/proposals/decisioning-platform-v6-1-ctx-metadata.md`.\nexport {\n createCtxMetadataStore,\n memoryCtxMetadataStore,\n pgCtxMetadataStore,\n redisCtxMetadataStore,\n getCtxMetadataMigration,\n cleanupExpiredCtxMetadata,\n CTX_METADATA_MIGRATION,\n CtxMetadataValidationError,\n ADCP_INTERNAL_TAG,\n DEFAULT_MAX_VALUE_BYTES,\n MAX_TTL_SECONDS,\n stripCtxMetadata,\n hasCtxMetadata,\n stripImplementationConfig,\n hasImplementationConfig,\n ctxMetadataResultKey,\n scopeCtxMetadataKey,\n} from './ctx-metadata';\nexport type {\n CtxMetadataStore,\n CtxMetadataStoreConfig,\n CtxMetadataBackend,\n CtxMetadataEntry,\n CtxMetadataRef,\n ResourceKind as CtxMetadataResourceKind,\n MemoryCtxMetadataStoreOptions,\n PgCtxMetadataBackendOptions,\n RedisCtxMetadataBackendOptions,\n CtxMetadataRedisBackendClient,\n CtxMetadataRedisLikeClient,\n WireShape,\n} from './ctx-metadata';\n\nexport { createTranslationMap, createUpstreamHttpClient } from './upstream-helpers';\nexport type {\n TranslationMap,\n UpstreamAuth,\n AuthContext,\n UpstreamCallOptions,\n UpstreamHttpClientOptions,\n UpstreamHttpClient,\n UpstreamHttpResult,\n} from './upstream-helpers';\n\n// ---------------------------------------------------------------------------\n// Server-side adapters\n// ---------------------------------------------------------------------------\nexport {\n InMemoryImplicitAccountStore,\n defaultImplicitKeyFn,\n type ImplicitAccountStoreOptions,\n} from '../adapters/implicit-account-store';\n\nexport {\n createOAuthPassthroughResolver,\n type OAuthPassthroughResolverOptions,\n} from '../adapters/oauth-passthrough-resolver';\n\nexport { createRosterAccountStore, type RosterAccountStoreOptions } from '../adapters/roster-account-store';\n\nexport { createDerivedAccountStore, type DerivedAccountStoreOptions } from '../adapters/derived-account-store';\n\n// ---------------------------------------------------------------------------\n// Socket Mode — outbound WebSocket bridge for adopter dev environments\n// ---------------------------------------------------------------------------\nexport {\n ConformanceClient,\n WebSocketTransport,\n type ConformanceClientOptions,\n type ConformanceStatus,\n} from './socket-mode';\n"],"mappings":"AAAA,SAAS,iBAAiB;AAG1B,SAAS,gBAAgB,uBAAuB;AAGhD,SAAS,uBAAuB;AAGhC,SAAS,oBAAoB;AAG7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB,mCAAmC;AAQpE,SAAS,6BAA6B;AAStC,SAAS,iCAAiC;AAG1C,SAAS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,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAqCP,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB,iCAAiC;AAiC/D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgBP,SAAS,sBAAsB,gCAAgC;AAc/D;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,gCAAgE;AAEzE,SAAS,iCAAkE;AAK3E;AAAA,EACE;AAAA,EACA;AAAA,OAGK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/server/index.ts"],"sourcesContent":["export { adcpError } from './errors';\nexport type { AdcpErrorOptions, AdcpErrorPayload, AdcpErrorResponse } from './errors';\n\nexport { normalizeError, normalizeErrors } from './normalize-errors';\nexport type { NormalizedError } from './normalize-errors';\n\nexport { pickSafeDetails } from './pick-safe-details';\nexport type { PickSafeDetailsOptions } from './pick-safe-details';\n\nexport { wrapEnvelope } from './wrap-envelope';\nexport type { WrapEnvelopeOptions } from './wrap-envelope';\n\nexport {\n ERROR_ENVELOPE_FIELD_ALLOWLIST,\n DEFAULT_ERROR_ENVELOPE_FIELDS,\n ADCP_ERROR_FIELD_ALLOWLIST,\n CONFLICT_ADCP_ERROR_ALLOWLIST,\n} from './envelope-allowlist';\n\nexport { scanArgsForCredentials, DEFAULT_CREDENTIAL_PATTERNS } from './credential-policy';\nexport type {\n CredentialPolicy,\n CredentialPolicyMode,\n CredentialPolicyConfig,\n CredentialPatternsConfig,\n} from './credential-policy';\n\nexport { createDynamicRegistry } from './dynamic-registry';\nexport type {\n DynamicRegistry,\n DynamicRegistryConfig,\n DynamicRegistryRegisterOptions,\n PendingRegistries,\n RegistryShape,\n} from './dynamic-registry';\n\nexport { defineOperationalPlatform } from './operational-platform';\nexport type { OperationalPlatform, OperationalContext } from './operational-platform';\n\nexport { pickWireSpecFields, scrubExtensions, WIRE_SPEC_FIELDS } from './wire-safe';\nexport type { WireSafe, WireSpecRequestName, ScrubExtensionsOptions } from './wire-safe';\nexport type { RequireCacheScopeWhenProducts, ServerPayload } from '../types/server-payload';\nexport type {\n ActivateSignalPayload,\n AcquireRightsAcquiredPayload as LegacyAcquireRightsAcquiredPayload,\n AcquireRightsPayload as LegacyAcquireRightsPayload,\n AcquireRightsPendingApprovalPayload as LegacyAcquireRightsPendingApprovalPayload,\n AcquireRightsRejectedPayload as LegacyAcquireRightsRejectedPayload,\n BuildCreativeMultiPayload as LegacyBuildCreativeMultiPayload,\n BuildCreativePayload as LegacyBuildCreativePayload,\n BuildCreativeVariantPayload as LegacyBuildCreativeVariantPayload,\n CalibrateContentPayload as LegacyCalibrateContentPayload,\n CheckGovernancePayload,\n CreateCollectionListPayload,\n CreateContentStandardsPayload as LegacyCreateContentStandardsPayload,\n CreateMediaBuyPayload as LegacyCreateMediaBuyPayload,\n CreatePropertyListPayload,\n CreativeApprovalPayload,\n CreativeApprovedPayload,\n CreativePendingReviewPayload,\n CreativeRejectedPayload,\n DeleteCollectionListPayload,\n DeletePropertyListPayload,\n GetAccountFinancialsPayload,\n GetAccountFinancialsSuccessPayload,\n GetAdCPCapabilitiesPayload,\n GetBrandIdentityPayload,\n GetCollectionListPayload,\n GetContentStandardsPayload as LegacyGetContentStandardsPayload,\n GetCreativeDeliveryPayload as LegacyGetCreativeDeliveryPayload,\n GetCreativeFeaturesPayload as LegacyGetCreativeFeaturesPayload,\n GetMediaBuyArtifactsPayload as LegacyGetMediaBuyArtifactsPayload,\n GetMediaBuyDeliveryPayload as LegacyGetMediaBuyDeliveryPayload,\n GetMediaBuysPayload as LegacyGetMediaBuysPayload,\n GetPlanAuditLogsPayload,\n GetProductsPayload as LegacyGetProductsPayload,\n GetPropertyListPayload,\n GetRightsPayload as LegacyGetRightsPayload,\n GetRightsResponsePayload as LegacyGetRightsResponsePayload,\n GetSignalsPayload,\n ListAccountsPayload,\n ListCollectionListsPayload,\n ListContentStandardsPayload as LegacyListContentStandardsPayload,\n ListCreativeFormatsPayload as LegacyListCreativeFormatsPayload,\n ListCreativeFormatsResponsePayload as LegacyListCreativeFormatsResponsePayload,\n ListCreativeFormatsServerPayload as LegacyListCreativeFormatsServerPayload,\n ListCreativesPayload as LegacyListCreativesPayload,\n ListPropertyListsPayload,\n LogEventPayload,\n CanonicalPreviewCreativePayload,\n PreviewCreativePayload as LegacyPreviewCreativePayload,\n ProvidePerformanceFeedbackPayload,\n ReportPlanOutcomePayload,\n ReportUsagePayload,\n SIGetOfferingPayload,\n SIInitiateSessionPayload,\n SISendMessagePayload,\n SITerminateSessionPayload,\n SyncAccountsPayload,\n SyncAccountsSuccessPayload,\n SyncAudiencesPayload,\n SyncCatalogsPayload,\n SyncCreativesErrorPayload,\n SyncCreativesPayload,\n SyncCreativesSuccessPayload,\n SyncEventSourcesPayload,\n SyncGovernancePayload,\n SyncGovernanceSuccessPayload,\n SyncPlansPayload,\n UpdateCollectionListPayload,\n UpdateContentStandardsPayload as LegacyUpdateContentStandardsPayload,\n UpdateMediaBuyPayload as LegacyUpdateMediaBuyPayload,\n UpdatePropertyListPayload,\n UpdateRightsPayload as LegacyUpdateRightsPayload,\n ValidateContentDeliveryPayload as LegacyValidateContentDeliveryPayload,\n} from '../types/server-payload-aliases';\n\nexport { assertNoExampleTlds } from './example-tld-guard';\nexport type { AssertNoExampleTldsOptions } from './example-tld-guard';\n\n// Raw wire response builders remain available only through explicit\n// `legacy*` aliases on this primary barrel. The legacy/v5 subpath preserves\n// their historical names for handler-bag adopters.\nexport {\n capabilitiesResponse as legacyCapabilitiesResponse,\n productsResponse as legacyProductsResponse,\n mediaBuyResponse as legacyMediaBuyResponse,\n deliveryResponse as legacyDeliveryResponse,\n listAccountsResponse as legacyListAccountsResponse,\n listCreativeFormatsResponse as legacyListCreativeFormatsResponse,\n updateMediaBuyResponse as legacyUpdateMediaBuyResponse,\n getMediaBuysResponse as legacyGetMediaBuysResponse,\n performanceFeedbackResponse as legacyPerformanceFeedbackResponse,\n buildCreativeResponse as legacyBuildCreativeResponse,\n buildCreativeMultiResponse as legacyBuildCreativeMultiResponse,\n previewCreativeResponse as legacyPreviewCreativeResponse,\n creativeDeliveryResponse as legacyCreativeDeliveryResponse,\n listCreativesResponse as legacyListCreativesResponse,\n listPropertyListsResponse as legacyListPropertyListsResponse,\n listCollectionListsResponse as legacyListCollectionListsResponse,\n listContentStandardsResponse as legacyListContentStandardsResponse,\n getPlanAuditLogsResponse as legacyGetPlanAuditLogsResponse,\n syncCreativesResponse as legacySyncCreativesResponse,\n getSignalsResponse as legacyGetSignalsResponse,\n activateSignalResponse as legacyActivateSignalResponse,\n cancelMediaBuyResponse as legacyCancelMediaBuyResponse,\n acquireRightsResponse as legacyAcquireRightsResponse,\n acquireRightsAcquired as legacyAcquireRightsAcquired,\n acquireRightsPendingApproval as legacyAcquireRightsPendingApproval,\n acquireRightsRejected as legacyAcquireRightsRejected,\n updateRightsResponse as legacyUpdateRightsResponse,\n updateRightsSuccess as legacyUpdateRightsSuccess,\n creativeApprovalResponse as legacyCreativeApprovalResponse,\n creativeApprovalApproved as legacyCreativeApprovalApproved,\n creativeApprovalRejected as legacyCreativeApprovalRejected,\n creativeApprovalPendingReview as legacyCreativeApprovalPendingReview,\n creativeApprovalError as legacyCreativeApprovalError,\n syncAccountsResponse as legacySyncAccountsResponse,\n syncGovernanceResponse as legacySyncGovernanceResponse,\n reportUsageResponse as legacyReportUsageResponse,\n toStructuredContent,\n} from './responses';\nexport type { McpToolResponse } from './responses';\n\nexport { validActionsForStatus } from './media-buy-helpers';\nexport type { ValidAction, CancelMediaBuyInput } from './media-buy-helpers';\nexport { assertUpdateMediaBuyAllowed } from './media-buy-actions';\nexport type { AssertUpdateMediaBuyAllowedOptions } from './media-buy-actions';\n\nexport { createMediaBuyStore, DEFAULT_MEDIA_BUY_STORE_COLLECTION } from './media-buy-store';\nexport type {\n MediaBuyStore,\n CreateMediaBuyStoreOptions,\n CreateMediaBuyInputForStore,\n CreateMediaBuyResultForStore,\n UpdateMediaBuyInputForStore,\n GetMediaBuysResultForStore,\n} from './media-buy-store';\n\nexport {\n MEDIA_BUY_TRANSITIONS,\n CREATIVE_ASSET_TRANSITIONS,\n isLegalMediaBuyTransition,\n isLegalCreativeTransition,\n assertMediaBuyTransition,\n assertCreativeTransition,\n} from './state-machine';\n\nexport { getAccountMode, isSandboxOrMockAccount, assertSandboxAccount } from './account-mode';\nexport type { AccountMode } from './account-mode';\n\nexport {\n taskToolResponse,\n registerAdcpTaskTool,\n createTaskCapableServer,\n InMemoryTaskStore,\n isTerminal,\n} from './tasks';\nexport type {\n AdcpTaskToolConfig,\n TaskStore,\n TaskMessageQueue,\n CreateTaskOptions,\n ToolTaskHandler,\n CreateTaskRequestHandlerExtra,\n TaskRequestHandlerExtra,\n CreateTaskResult,\n GetTaskResult,\n Task,\n} from './tasks';\n\nexport {\n PostgresTaskStore,\n cleanupExpiredTasks,\n getMcpTasksMigration,\n MCP_TASKS_MIGRATION,\n} from './postgres-task-store';\nexport type { PgQueryable, PostgresTaskStoreOptions } from './postgres-task-store';\n\nexport {\n registerTestController,\n handleTestControllerRequest,\n TestControllerError,\n toMcpResponse,\n TOOL_INPUT_SHAPE,\n CONTROLLER_SCENARIOS,\n DISCOVERY_ARM_SCENARIOS,\n SEED_SCENARIOS,\n SEED_MESSAGES,\n SESSION_ENTRY_CAP,\n enforceMapCap,\n createSeedFixtureCache,\n} from './test-controller';\nexport type {\n TestControllerStore,\n TestControllerStoreFactory,\n TestControllerStoreOrFactory,\n ControllerScenario,\n SeedScenario,\n SeedFixtureCache,\n} from './test-controller';\n\nexport { serve, taskScopeFromPrincipal, UnknownHostError, hostname, resolveHost } from './serve';\nexport type { ServeContext, ServeOptions, ProtectedResourceMetadata } from './serve';\n\nexport { createExpressAdapter } from './express-adapter';\nexport type { ExpressAdapter, ExpressAdapterOptions } from './express-adapter';\n\nexport {\n verifyApiKey,\n verifyBearer,\n anyOf,\n extractBearerToken,\n respondUnauthorized,\n signatureErrorCodeFromCause,\n AuthError,\n AUTH_NEEDS_RAW_BODY,\n tagAuthenticatorNeedsRawBody,\n authenticatorNeedsRawBody,\n AUTH_PRESENCE_GATED,\n tagAuthenticatorPresenceGated,\n isAuthenticatorPresenceGated,\n ADCP_SERVE_REQUEST_CONTEXT,\n getServeRequestContext,\n DEFAULT_JWT_ALGORITHMS,\n DEFAULT_JWT_CLOCK_TOLERANCE_SECONDS,\n} from './auth';\nexport type {\n Authenticator,\n AuthPrincipal,\n AuthResult,\n VerifyApiKeyOptions,\n VerifyBearerOptions,\n RespondUnauthorizedOptions,\n ServeRequestContext,\n} from './auth';\n\nexport { verifyIntrospection } from './auth-introspection';\nexport type {\n VerifyIntrospectionOptions,\n IntrospectionCacheOptions,\n IntrospectionResponse,\n} from './auth-introspection';\n\nexport {\n verifySignatureAsAuthenticator,\n requireSignatureWhenPresent,\n requireAuthenticatedOrSigned,\n mcpToolNameResolver,\n} from './auth-signature';\nexport type {\n VerifySignatureAsAuthenticatorOptions,\n RequireSignatureWhenPresentOptions,\n RequireAuthenticatedOrSignedOptions,\n} from './auth-signature';\n\nexport {\n InMemoryStateStore,\n StateError,\n PatchConflictError,\n DEFAULT_MAX_DOCUMENT_BYTES,\n SESSION_KEY_FIELD,\n createSessionedStore,\n scopedStore,\n patchWithRetry,\n isPutIfMatchConflict,\n validateCollection,\n validateId,\n validatePayloadSize,\n validateWrite,\n} from './state-store';\nexport type {\n AdcpStateStore,\n InMemoryStateStoreOptions,\n ListOptions,\n ListResult,\n PatchWithRetryOptions,\n PutIfMatchResult,\n StateErrorCode,\n VersionedDocument,\n} from './state-store';\n\nexport { PostgresStateStore, getAdcpStateMigration, ADCP_STATE_MIGRATION } from './postgres-state-store';\nexport type { PostgresStateStoreOptions } from './postgres-state-store';\n\nexport { structuredSerialize, structuredDeserialize } from './structured-serialize';\n\nexport { MCP_APP_RESOURCE_MIME_TYPE } from './mcp-app';\nexport type {\n AdcpMcpResourceDefinition,\n McpAppResourceCsp,\n McpAppResourcePermissions,\n McpAppResourceUiMeta,\n McpAppResourceMeta,\n McpAppResourceReadContext,\n} from './mcp-app';\n\n// `createAdcpServer` is NOT re-exported from `@adcp/sdk/server` anymore —\n// LLMs scaffolding from skills consistently latched onto it as the canonical\n// entry point despite the @deprecated JSDoc. Removing the top-level export\n// forces new code to either reach for `createAdcpServerFromPlatform` (the v6\n// canonical) or import from `@adcp/sdk/server/legacy/v5` (mid-migration /\n// escape-hatch only). Breaking change: v5 adopters see a hard import error\n// and update their import path. The migration is one line; the LLM-output\n// quality win is significant. See `docs/migration-5.x-to-6.x.md`.\nexport {\n requireSessionKey,\n ADCP_PRE_TRANSPORT,\n ADCP_SIGNED_REQUESTS_STATE,\n ADCP_INSTRUCTIONS_FN,\n} from './create-adcp-server';\nexport type { SessionContext, OnInstructionsError, MaybePromise, BridgeMarker } from './create-adcp-server';\nexport type {\n AdcpServer,\n AdcpServerComplianceApi,\n AdcpServerTransport,\n AdcpTestRequest,\n AdcpTestToolsCallRequest,\n AdcpTestResponse,\n} from './adcp-server';\n// Handler-bag types describe the raw v5 server surface. Primary-barrel names\n// are explicit Legacy aliases; the legacy/v5 subpath retains the originals.\nexport type {\n AdcpServerConfig as LegacyAdcpServerConfig,\n WebhooksConfig,\n AdcpToolMap as LegacyAdcpToolMap,\n AdcpServerToolName,\n AdcpCapabilitiesConfig,\n AdcpCapabilitiesOverrides,\n AdcpCustomToolConfig as LegacyAdcpCustomToolConfig,\n McpAppUiMeta,\n McpAppMeta,\n AdcpLogger,\n SignedRequestsConfig,\n AdcpPreTransport,\n AdcpSignedRequestsState,\n HandlerContext as LegacyHandlerContext,\n SessionKeyContext,\n MediaBuyHandlers as LegacyMediaBuyHandlers,\n ProposalNegotiationHandlers as LegacyProposalNegotiationHandlers,\n SignalsHandlers as LegacySignalsHandlers,\n CreativeHandlers as LegacyCreativeHandlers,\n GovernanceHandlers as LegacyGovernanceHandlers,\n AccountHandlers as LegacyAccountHandlers,\n EventTrackingHandlers as LegacyEventTrackingHandlers,\n SponsoredIntelligenceHandlers as LegacySponsoredIntelligenceHandlers,\n ResolveAccountContext as LegacyResolveAccountContext,\n} from './create-adcp-server';\n\nexport { DEFAULT_REPORTING_CAPABILITIES } from './product-defaults';\n\nexport {\n isSandboxRequest,\n mergeSeededProductsIntoResponse,\n filterValidSeededProducts,\n filterValidSeededCreatives,\n filterValidSeededMediaBuys,\n filterValidSeededAccounts,\n filterValidSeededAccountFinancials,\n filterValidSeededCreativeFormats,\n mergeSeededCreativesIntoResponse,\n mergeSeededMediaBuysIntoResponse,\n mergeSeededAccountsIntoResponse,\n mergeSeededCreativeFormatsIntoResponse,\n pickSeededAccountFinancialsForRequest,\n replaceAccountFinancialsIfSeeded,\n bridgeFromTestControllerStore,\n bridgeFromSessionStore,\n} from './test-controller-bridge';\nexport type {\n TestControllerBridge,\n TestControllerBridgeContext,\n BridgeFromSessionStoreOptions,\n SeededCreative,\n SeededMediaBuy,\n SeededAccountFinancials,\n} from './test-controller-bridge';\n\nexport {\n createIdempotencyStore,\n probeIdempotencyStore,\n memoryBackend,\n pgBackend,\n getIdempotencyMigration,\n IDEMPOTENCY_MIGRATION,\n cleanupExpiredIdempotency,\n redisBackend,\n createLazyBackend,\n hashPayload,\n IdempotencyClaimOwnershipError,\n} from './idempotency';\nexport type {\n IdempotencyStore,\n IdempotencyStoreConfig,\n IdempotencyBackend,\n IdempotencyCacheEntry,\n IdempotencyCheckResult,\n MemoryBackendOptions,\n PgBackendOptions,\n RedisBackendOptions,\n RedisBackendClient,\n RedisLikeClient,\n LazyBackendFactory,\n LazyBackendOptions,\n} from './idempotency';\n\nexport { createA2AAdapter, A2AInvocationError } from './a2a-adapter';\nexport type {\n A2AAdapter,\n A2AAdapterOptions,\n A2AAgentCardOverrides,\n A2AAgentCapabilitiesOverride,\n A2AAgentSkillOverride,\n A2AMountOptions,\n ExpressAppLike,\n LegacyHttpSecurityScheme,\n LegacySecurityScheme,\n} from './a2a-adapter';\n\nexport { createWebhookEmitter, memoryWebhookDeliveryStore, memoryWebhookKeyStore } from './webhook-emitter';\nexport {\n pgWebhookDeliveryStore,\n pgWebhookDeliveryRecoveryBackend,\n redisWebhookDeliveryStore,\n redisWebhookDeliveryRecoveryBackend,\n getWebhookDeliveryMigration,\n getWebhookDeliveryRecoveryMigration,\n WEBHOOK_DELIVERY_MIGRATION,\n WEBHOOK_DELIVERY_RECOVERY_MIGRATION,\n createWebhookDeliveryRecovery,\n pollWebhookDeliveryRecovery,\n memoryWebhookDeliveryRecoveryBackend,\n WebhookDeliveryTerminalError,\n isWebhookDeliveryTerminalError,\n} from './webhook-delivery';\nexport type {\n PgWebhookDeliveryStoreOptions,\n PgWebhookDeliveryRecoveryOptions,\n RedisWebhookDeliveryStoreOptions,\n RedisWebhookDeliveryRecoveryOptions,\n ProtectedWebhookAuthentication,\n WebhookAuthenticationAdapter,\n WebhookAuthenticationContext,\n StoredWebhookDeliverySnapshot,\n WebhookRecoveryRecord,\n WebhookRecoveryLease,\n WebhookRecoveryCheckpointResult,\n WebhookRecoveryCheckpointOutcome,\n WebhookDeliveryRecoveryBackend,\n DurableWebhookDeliveryRecovery,\n CreateWebhookDeliveryRecoveryOptions,\n PollWebhookDeliveryRecoveryOptions,\n} from './webhook-delivery';\nexport type {\n WebhookEmitter,\n RecoverableWebhookEmitter,\n WebhookEmitterOptions,\n WebhookEmitParams,\n WebhookEmitResult,\n WebhookRecoveredDelivery,\n WebhookEmitAttempt,\n WebhookEmitAttemptResult,\n WebhookDeliveryBinding,\n WebhookDeliveryRetired,\n WebhookDeliveryRecord,\n WebhookDeliveryKey,\n WebhookDeliveryProposal,\n WebhookDeliverySnapshot,\n WebhookDeliveryRecovery,\n WebhookDeliveryRecoveryClaim,\n WebhookDeliveryStore,\n WebhookIdempotencyKeyStore,\n WebhookRetryOptions,\n WebhookAuthentication,\n} from './webhook-emitter';\nexport type { SigningProvider } from '../signing/provider';\n\nexport { createPinAndBindFetch, WEBHOOK_SSRF_POLICY, LOOPBACK_OK_WEBHOOK_SSRF_POLICY } from './pin-and-bind-fetch';\nexport type { PinAndBindFetchOptions, DnsLookupAll } from './pin-and-bind-fetch';\n\nexport {\n checkGovernance,\n createAdcpGovernanceEnforcementMiddleware,\n governanceDeniedError,\n governanceUnavailableError,\n} from './governance';\nexport type {\n AdcpGovernanceEnforcementMiddleware,\n CheckGovernanceOptions,\n GovernanceCallResult,\n GovernanceApproved,\n GovernanceDenied,\n GovernanceConditions,\n} from './governance';\n\nexport {\n GovernanceAuthorizationError,\n GovernanceReplayStoreAdapter,\n InMemoryGovernanceReplayStore,\n buildGovernanceExecutionCommitment,\n buildGovernanceExecutionRequest,\n computeGovernedPayloadHash,\n createGovernanceEnforcementMiddleware,\n verifyGovernanceAuthorization,\n} from '../governance';\nexport type {\n BuildGovernanceExecutionRequestInput,\n GovernanceAuthorizationClaims,\n GovernanceAuthorizationErrorCode,\n GovernanceAuthorizationResult,\n GovernanceAuthorizationSuccess,\n GovernanceCommitment,\n GovernanceEnforcementMiddleware,\n GovernanceEnforcementMiddlewareConfig,\n GovernanceEnforcementMiddlewareInput,\n GovernanceReplayStore,\n GovernanceReplayBinding,\n GovernanceRevocationResolver,\n GovernanceRevocationStatus,\n VerifyGovernanceAuthorizationOptions,\n} from '../governance';\n\nexport {\n clearDefaultResolvedListCache,\n createResolvedListCache,\n DEFAULT_RESOLVE_LIST_PAGE_SIZE,\n defaultResolvedListCache,\n resolvePropertyList,\n resolveCollectionList,\n resolvedListCacheKey,\n matchesPropertyList,\n matchesCollectionList,\n} from './targeting-helpers';\nexport type {\n ResolvedListCache,\n ResolvedListCacheEntry,\n ResolvedListCacheValue,\n ResolvedListKind,\n ResolvedPropertyList,\n ResolvedCollectionList,\n ResolvedCollection,\n ResolveListCallTool,\n ResolveListOptions,\n} from './targeting-helpers';\n\n// ---------------------------------------------------------------------------\n// Platform-shaped server entry point (recommended for new agents)\n// ---------------------------------------------------------------------------\n//\n// `createAdcpServerFromPlatform` wraps `createAdcpServer` (the lower-level\n// handler-bag entry above) with compile-time specialism enforcement\n// (`RequiredPlatformsFor<S>`), capability projection, idempotency wiring,\n// async tasks, status normalization, multi-tenant routing, and async task\n// completion webhooks. Synchronous terminal responses remain inline by\n// default. Adopters declare a typed `DecisioningPlatform` per-specialism\n// and the framework wires the rest. See `docs/migration-5.x-to-6.x.md` and\n// `skills/build-decisioning-platform/` for the full walkthrough.\n//\n// Both `createAdcpServer` and `createAdcpServerFromPlatform` live on the\n// same import path so adopters discover them as siblings; pick the\n// function shape that matches your agent. The platform path internally\n// builds an `AdcpServerConfig` and calls `createAdcpServer` — they're\n// not adjacent surfaces, they're parent-child layers of the same SDK.\n//\n// **Pin to v5 long-term?** Import from `@adcp/sdk/server/legacy/v5`\n// instead. The subpath is the stable home for the v5 handler-bag\n// constructor; the top-level re-export here may be removed in a\n// future major. New code should not pin against `legacy/v5` either —\n// reach for `createAdcpServerFromPlatform` first.\nexport * from './decisioning';\nexport {\n createProposalRefinementHandler,\n createProposalSuccessor,\n proposalRefinementScopeFromContext,\n classifyProposalRefinementFailure,\n defineProposalRefinementCapabilities,\n ProposalSellerPreflightError,\n} from '../negotiation/seller';\nexport { proposalTermsDigest, verifyProposalTermsDigest } from '../negotiation/verification';\nexport type {\n ProposalCommercialEvaluator,\n ProposalFailureClassification,\n ProposalEvaluationContext,\n ProposalRefinementHandler,\n ProposalRefinementHandlerOptions,\n ProposalRefinementStore,\n ProposalRefinementTransaction,\n ProposalRefinementScope,\n ProposalSourceExpectation,\n ProposalSourceSnapshot,\n ProposalSuccessorInput,\n} from '../negotiation/seller';\nexport type {\n CanonicalProposal,\n ProposalCommercialTerms,\n ProposalRefinementCapabilities,\n ProposalRefinementResult,\n RefineProposalsRequest,\n RefineProposalsResponse,\n} from '../negotiation/types';\n\n// ---------------------------------------------------------------------------\n// Ctx-metadata store — opaque-blob round-trip for adapter-internal state\n// ---------------------------------------------------------------------------\n//\n// Publishers attach platform-specific opaque blobs to any returned resource\n// (product, media_buy, package, creative, audience, signal, rights_grant);\n// the framework persists by `(account_id, kind, id)`, strips from buyer-\n// facing wire payloads, threads back into the publisher's request context\n// on subsequent calls referencing the same resource ID. See\n// `docs/proposals/decisioning-platform-v6-1-ctx-metadata.md`.\nexport {\n createCtxMetadataStore,\n memoryCtxMetadataStore,\n pgCtxMetadataStore,\n redisCtxMetadataStore,\n getCtxMetadataMigration,\n cleanupExpiredCtxMetadata,\n CTX_METADATA_MIGRATION,\n CtxMetadataValidationError,\n ADCP_INTERNAL_TAG,\n DEFAULT_MAX_VALUE_BYTES,\n MAX_TTL_SECONDS,\n stripCtxMetadata,\n hasCtxMetadata,\n stripImplementationConfig,\n hasImplementationConfig,\n ctxMetadataResultKey,\n scopeCtxMetadataKey,\n} from './ctx-metadata';\nexport type {\n CtxMetadataStore,\n CtxMetadataStoreConfig,\n CtxMetadataBackend,\n CtxMetadataEntry,\n CtxMetadataRef,\n ResourceKind as CtxMetadataResourceKind,\n MemoryCtxMetadataStoreOptions,\n PgCtxMetadataBackendOptions,\n RedisCtxMetadataBackendOptions,\n CtxMetadataRedisBackendClient,\n CtxMetadataRedisLikeClient,\n WireShape,\n} from './ctx-metadata';\n\nexport { createTranslationMap, createUpstreamHttpClient } from './upstream-helpers';\nexport type {\n TranslationMap,\n UpstreamAuth,\n AuthContext,\n UpstreamCallOptions,\n UpstreamHttpClientOptions,\n UpstreamHttpClient,\n UpstreamHttpResult,\n} from './upstream-helpers';\n\n// ---------------------------------------------------------------------------\n// Server-side adapters\n// ---------------------------------------------------------------------------\nexport {\n InMemoryImplicitAccountStore,\n defaultImplicitKeyFn,\n type ImplicitAccountStoreOptions,\n} from '../adapters/implicit-account-store';\n\nexport {\n createOAuthPassthroughResolver,\n type OAuthPassthroughResolverOptions,\n} from '../adapters/oauth-passthrough-resolver';\n\nexport { createRosterAccountStore, type RosterAccountStoreOptions } from '../adapters/roster-account-store';\n\nexport { createDerivedAccountStore, type DerivedAccountStoreOptions } from '../adapters/derived-account-store';\n\n// ---------------------------------------------------------------------------\n// Socket Mode — outbound WebSocket bridge for adopter dev environments\n// ---------------------------------------------------------------------------\nexport {\n ConformanceClient,\n WebSocketTransport,\n type ConformanceClientOptions,\n type ConformanceStatus,\n} from './socket-mode';\n"],"mappings":"AAAA,SAAS,iBAAiB;AAG1B,SAAS,gBAAgB,uBAAuB;AAGhD,SAAS,uBAAuB;AAGhC,SAAS,oBAAoB;AAG7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB,mCAAmC;AAQpE,SAAS,6BAA6B;AAStC,SAAS,iCAAiC;AAG1C,SAAS,oBAAoB,iBAAiB,wBAAwB;AA8EtE,SAAS,2BAA2B;AAMpC;AAAA,EAC0B;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACI;AAAA,EACO;AAAA,EACL;AAAA,EACF;AAAA,EACO;AAAA,EACN;AAAA,EACK;AAAA,EACH;AAAA,EACC;AAAA,EACH;AAAA,EACI;AAAA,EACE;AAAA,EACC;AAAA,EACJ;AAAA,EACH;AAAA,EACH;AAAA,EACI;AAAA,EACA;AAAA,EACD;AAAA,EACA;AAAA,EACO;AAAA,EACP;AAAA,EACD;AAAA,EACD;AAAA,EACK;AAAA,EACA;AAAA,EACA;AAAA,EACK;AAAA,EACR;AAAA,EACD;AAAA,EACE;AAAA,EACH;AAAA,EACvB;AAAA,OACK;AAGP,SAAS,6BAA6B;AAEtC,SAAS,mCAAmC;AAG5C,SAAS,qBAAqB,0CAA0C;AAUxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,gBAAgB,wBAAw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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgBP,SAAS,kBAAkB,0BAA0B;AAarD,SAAS,sBAAsB,4BAA4B,6BAA6B;AACxF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA2CP,SAAS,uBAAuB,qBAAqB,uCAAuC;AAG5F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAqCP,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB,iCAAiC;AAiC/D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgBP,SAAS,sBAAsB,gCAAgC;AAc/D;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,gCAAgE;AAEzE,SAAS,iCAAkE;AAK3E;AAAA,EACE;AAAA,EACA;AAAA,OAGK;","names":[]}
|
|
@@ -13,6 +13,7 @@ import type { AdcpSignAlg } from './types.mjs';
|
|
|
13
13
|
export interface AgentSigningIdentitySnapshot {
|
|
14
14
|
keyid: string;
|
|
15
15
|
algorithm: AdcpSignAlg;
|
|
16
|
+
adcpUse?: string;
|
|
16
17
|
/** Defensively hashed disambiguator — see {@link buildAgentSigningContext}. */
|
|
17
18
|
fingerprint: string;
|
|
18
19
|
}
|
|
@@ -13,6 +13,7 @@ import type { AdcpSignAlg } from './types';
|
|
|
13
13
|
export interface AgentSigningIdentitySnapshot {
|
|
14
14
|
keyid: string;
|
|
15
15
|
algorithm: AdcpSignAlg;
|
|
16
|
+
adcpUse?: string;
|
|
16
17
|
/** Defensively hashed disambiguator — see {@link buildAgentSigningContext}. */
|
|
17
18
|
fingerprint: string;
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-context.d.ts","sourceRoot":"","sources":["../../../src/lib/signing/agent-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAEL,eAAe,EAEf,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-context.d.ts","sourceRoot":"","sources":["../../../src/lib/signing/agent-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAEL,eAAe,EAEf,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAK3C;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,WAAW,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,OAAO,EAAE,yBAAyB,CAAC;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,EAAE,4BAA4B,CAAC;IACvC,gIAAgI;IAChI,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,aAAa,EAAE,MAAM,gBAAgB,GAAG,SAAS,CAAC;IAClD,yEAAyE;IACzE,KAAK,EAAE,eAAe,CAAC;IACvB,iEAAiE;IACjE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,UAAU,IAAI,IAAI,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,0EAA6E,CAAC;AAEhH;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,eAAe,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9D,mBAAmB,GAAG,SAAS,CAmCjC"}
|
|
@@ -26,6 +26,7 @@ var import_node_crypto = require("node:crypto");
|
|
|
26
26
|
var import_global_async_local_storage = require('../utils/global-async-local-storage.js');
|
|
27
27
|
var import_capability_cache = require('./capability-cache.js');
|
|
28
28
|
var import_version = require('../version.js');
|
|
29
|
+
const CAPABILITY_SCOPE_SALT = (0, import_node_crypto.randomBytes)(32);
|
|
29
30
|
const signingContextStorage = (0, import_global_async_local_storage.globalAsyncLocalStorage)("signingContext");
|
|
30
31
|
function buildAgentSigningContext(agent, options = {}) {
|
|
31
32
|
const signing = agent.request_signing;
|
|
@@ -34,7 +35,12 @@ function buildAgentSigningContext(agent, options = {}) {
|
|
|
34
35
|
const identity = snapshotIdentity(signing);
|
|
35
36
|
const cacheFingerprint = deriveCacheFingerprint(identity);
|
|
36
37
|
const adcpVersion = options.adcpVersion ?? import_version.ADCP_VERSION;
|
|
37
|
-
const capabilityCacheKey = (0, import_capability_cache.buildCapabilityCacheKey)(
|
|
38
|
+
const capabilityCacheKey = (0, import_capability_cache.buildCapabilityCacheKey)(
|
|
39
|
+
agent.agent_uri,
|
|
40
|
+
capabilityPrincipalScope(agent),
|
|
41
|
+
cacheFingerprint,
|
|
42
|
+
adcpVersion
|
|
43
|
+
);
|
|
38
44
|
const cacheKey = `sig=${cacheFingerprint};adcp=${adcpVersion}`;
|
|
39
45
|
const provider = signing.kind === "provider" ? signing.provider : void 0;
|
|
40
46
|
return {
|
|
@@ -49,23 +55,52 @@ function buildAgentSigningContext(agent, options = {}) {
|
|
|
49
55
|
invalidate: () => cache.invalidate(capabilityCacheKey)
|
|
50
56
|
};
|
|
51
57
|
}
|
|
58
|
+
function capabilityPrincipalScope(agent) {
|
|
59
|
+
const credentials = agent.oauth_client_credentials;
|
|
60
|
+
const headers = agent.headers ? Object.fromEntries(
|
|
61
|
+
Object.entries(agent.headers).map(([name, value]) => [name.toLowerCase(), value]).sort(([a], [b]) => a.localeCompare(b))
|
|
62
|
+
) : void 0;
|
|
63
|
+
const scope = {
|
|
64
|
+
protocol: agent.protocol,
|
|
65
|
+
authToken: agent.auth_token,
|
|
66
|
+
oauthAccessToken: agent.oauth_tokens?.access_token,
|
|
67
|
+
oauthClientId: agent.oauth_client?.client_id,
|
|
68
|
+
oauthResource: agent.oauth_resource,
|
|
69
|
+
oauthClientCredentials: credentials ? {
|
|
70
|
+
tokenEndpoint: credentials.token_endpoint,
|
|
71
|
+
clientId: credentials.client_id,
|
|
72
|
+
scope: credentials.scope,
|
|
73
|
+
resource: credentials.resource,
|
|
74
|
+
audience: credentials.audience
|
|
75
|
+
} : void 0,
|
|
76
|
+
headers
|
|
77
|
+
};
|
|
78
|
+
return capabilityScopeDisambiguator(JSON.stringify(scope));
|
|
79
|
+
}
|
|
80
|
+
function capabilityScopeDisambiguator(value) {
|
|
81
|
+
return Buffer.from((0, import_node_crypto.hkdfSync)("sha256", value, CAPABILITY_SCOPE_SALT, "adcp-signing-capability-cache", 32)).toString(
|
|
82
|
+
"hex"
|
|
83
|
+
);
|
|
84
|
+
}
|
|
52
85
|
function snapshotIdentity(signing) {
|
|
53
86
|
if (signing.kind === "provider") {
|
|
54
87
|
const provider = signing.provider;
|
|
55
88
|
return {
|
|
56
89
|
keyid: provider.keyid,
|
|
57
90
|
algorithm: provider.algorithm,
|
|
91
|
+
...provider.adcpUse !== void 0 && { adcpUse: provider.adcpUse },
|
|
58
92
|
fingerprint: provider.fingerprint
|
|
59
93
|
};
|
|
60
94
|
}
|
|
61
95
|
return {
|
|
62
96
|
keyid: signing.kid,
|
|
63
97
|
algorithm: signing.alg,
|
|
98
|
+
...typeof signing.private_key.adcp_use === "string" && { adcpUse: signing.private_key.adcp_use },
|
|
64
99
|
fingerprint: inlineFingerprint(signing.kid, signing.private_key.d)
|
|
65
100
|
};
|
|
66
101
|
}
|
|
67
102
|
function deriveCacheFingerprint(identity) {
|
|
68
|
-
return (0, import_node_crypto.createHash)("sha256").update(identity.algorithm).update("\0").update(identity.keyid).update("\0").update(identity.fingerprint).digest("hex").slice(0, 16);
|
|
103
|
+
return (0, import_node_crypto.createHash)("sha256").update(identity.algorithm).update("\0").update(identity.keyid).update("\0").update(identity.adcpUse ?? "").update("\0").update(identity.fingerprint).digest("hex").slice(0, 16);
|
|
69
104
|
}
|
|
70
105
|
function inlineFingerprint(kid, d) {
|
|
71
106
|
if (!d) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/signing/agent-context.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { globalAsyncLocalStorage } from '../utils/global-async-local-storage';\nimport type { AgentConfig, AgentRequestSigningConfig } from '../types/adcp';\nimport {\n buildCapabilityCacheKey,\n CapabilityCache,\n defaultCapabilityCache,\n type CachedCapability,\n} from './capability-cache';\nimport type { SigningProvider } from './provider';\nimport type { AdcpSignAlg } from './types';\nimport { ADCP_VERSION } from '../version';\n\n/**\n * Snapshot of the signing identity captured at context-build time. The\n * transport layer reads from this snapshot rather than from `provider.*`\n * directly so a provider object whose fields drift between context build\n * and outbound request can't desynchronize the on-wire `keyid` from the\n * cache key the connection was bound to. TypeScript's `readonly` modifier\n * is compile-time only; the snapshot is the runtime defense.\n */\nexport interface AgentSigningIdentitySnapshot {\n keyid: string;\n algorithm: AdcpSignAlg;\n /** Defensively hashed disambiguator — see {@link buildAgentSigningContext}. */\n fingerprint: string;\n}\n\n/**\n * Per-call signing context passed down to the MCP/A2A transport layer. Built\n * at `ProtocolClient.callTool` and consumed by the signing fetch wrapper\n * attached to the transport. Opaque to the transport helpers — they only\n * use `cacheKey` (to disambiguate connection-cache entries per signing\n * identity), `getCapability` (to read the cached seller advertisement on\n * each outbound request), and `signing` (to produce the signer key or\n * provider).\n */\nexport interface AgentSigningContext {\n /** Signing config copied from AgentConfig.request_signing. */\n signing: AgentRequestSigningConfig;\n /** Provider when `signing.kind === 'provider'`; undefined for inline keys. */\n provider?: SigningProvider;\n /** Snapshot of identity fields read from the provider at build time. */\n identity: AgentSigningIdentitySnapshot;\n /** Suffix to append to transport connection-cache keys so agents with different signing identities don't share a connection. */\n cacheKey: string;\n /** Lazy accessor for the currently cached capability for this agent. */\n getCapability: () => CachedCapability | undefined;\n /** Capability cache backing this context (for external invalidation). */\n cache: CapabilityCache;\n /** Stable cache key used against the capability cache itself. */\n capabilityCacheKey: string;\n /** Trusted SDK/endpoint pin used to select the request-signing wire profile. */\n adcpVersion: string;\n /**\n * Evict this context's capability entry so the next outbound call\n * re-primes `get_adcp_capabilities`. Use after a seller-side rotation\n * signal — or on a 401 / protocol-signature error — without having to\n * rebuild the cache key from the agent's identifying fields.\n */\n invalidate(): void;\n}\n\n/**\n * AsyncLocalStorage carrying the signing context across the transport layer.\n * Top-level protocol entries (`callMCPTool`, `callA2ATool`, etc.) push a\n * context onto this storage for the duration of the call; internal helpers\n * (`withCachedConnection`, `connectMCPWithFallback`, `buildFetchImpl`) read\n * it when building cache keys and signing-fetch wrappers, avoiding the need\n * to thread `signingContext` through every intermediate signature.\n *\n * The top-level entries always call `run()` — including with `undefined` —\n * so a non-signing call cannot inherit a stale context from an enclosing\n * scope.\n */\nexport const signingContextStorage = globalAsyncLocalStorage<AgentSigningContext | undefined>('signingContext');\n\n/**\n * Build an `AgentSigningContext` from an `AgentConfig` when signing is\n * configured. Returns `undefined` when the agent has no `request_signing`\n * block — callers use this to branch into the no-op fast path.\n */\nexport function buildAgentSigningContext(\n agent: AgentConfig,\n options: { cache?: CapabilityCache; adcpVersion?: string } = {}\n): AgentSigningContext | undefined {\n const signing = agent.request_signing;\n if (!signing) return undefined;\n\n const cache = options.cache ?? defaultCapabilityCache;\n const identity = snapshotIdentity(signing);\n const cacheFingerprint = deriveCacheFingerprint(identity);\n const adcpVersion = options.adcpVersion ?? ADCP_VERSION;\n const capabilityCacheKey = buildCapabilityCacheKey(agent.agent_uri, agent.auth_token, cacheFingerprint, adcpVersion);\n // Transport-connection cache-key suffix binds to the defensively hashed\n // identity, not just the advertised `kid`. Two tenants that misconfigure\n // the same `kid` string but hold distinct keys must not collide on a\n // shared cached transport — that would sign one tenant's outbound\n // requests with the other tenant's key (same `kid`, different material),\n // an impersonation. The hash includes `algorithm` so an Ed25519/P-256\n // swap on the same `kid+fingerprint` doesn't alias either.\n const cacheKey = `sig=${cacheFingerprint};adcp=${adcpVersion}`;\n const provider = signing.kind === 'provider' ? signing.provider : undefined;\n\n return {\n signing,\n provider,\n identity,\n cacheKey,\n cache,\n capabilityCacheKey,\n adcpVersion,\n getCapability: () => cache.get(capabilityCacheKey),\n invalidate: () => cache.invalidate(capabilityCacheKey),\n };\n}\n\n/**\n * Snapshot the signing identity at context-build time. For provider configs,\n * reads `keyid` / `algorithm` / `fingerprint` once and freezes them. For\n * inline configs, derives a fingerprint from the private scalar — same\n * 64-bit cache disambiguator the SDK has always used.\n */\nfunction snapshotIdentity(signing: AgentRequestSigningConfig): AgentSigningIdentitySnapshot {\n if (signing.kind === 'provider') {\n const provider = signing.provider;\n return {\n keyid: provider.keyid,\n algorithm: provider.algorithm,\n fingerprint: provider.fingerprint,\n };\n }\n return {\n keyid: signing.kid,\n algorithm: signing.alg,\n fingerprint: inlineFingerprint(signing.kid, signing.private_key.d),\n };\n}\n\n/**\n * Defensively hash the snapshot before composing cache keys. A\n * provider-supplied `fingerprint` is treated as untrusted input — a\n * confused integrator could return a constant, an empty string, or a\n * tenant-controlled value, any of which would re-enable cross-tenant\n * collisions on the same `kid`. Including `algorithm` in the digest\n * prevents an Ed25519/P-256 swap on identical `kid+fingerprint` from\n * aliasing.\n *\n * Truncated to 16 hex chars — a 64-bit collision-resistance budget against\n * random keys is plenty for a cache disambiguator, and we never rely on\n * this value as a security boundary.\n */\nfunction deriveCacheFingerprint(identity: AgentSigningIdentitySnapshot): string {\n return createHash('sha256')\n .update(identity.algorithm)\n .update('\\0')\n .update(identity.keyid)\n .update('\\0')\n .update(identity.fingerprint)\n .digest('hex')\n .slice(0, 16);\n}\n\nfunction inlineFingerprint(kid: string, d: string | undefined): string {\n if (!d) {\n throw new TypeError(\n `AgentRequestSigningConfig (kind: 'inline', kid='${kid}') is missing 'private_key.d' — JWK must include the private scalar.`\n );\n }\n return createHash('sha256').update(kid).update('\\0').update(d).digest('hex').slice(0, 16);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,wCAAwC;AAExC,8BAKO;AAGP,qBAA6B;AAgEtB,MAAM,4BAAwB,2DAAyD,gBAAgB;AAOvG,SAAS,yBACd,OACA,UAA6D,CAAC,GAC7B;AACjC,QAAM,UAAU,MAAM;AACtB,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,QAAQ,QAAQ,SAAS;AAC/B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AE;AAC1F;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/signing/agent-context.ts"],"sourcesContent":["import { createHash, hkdfSync, randomBytes } from 'node:crypto';\nimport { globalAsyncLocalStorage } from '../utils/global-async-local-storage';\nimport type { AgentConfig, AgentRequestSigningConfig } from '../types/adcp';\nimport {\n buildCapabilityCacheKey,\n CapabilityCache,\n defaultCapabilityCache,\n type CachedCapability,\n} from './capability-cache';\nimport type { SigningProvider } from './provider';\nimport type { AdcpSignAlg } from './types';\nimport { ADCP_VERSION } from '../version';\n\nconst CAPABILITY_SCOPE_SALT = randomBytes(32);\n\n/**\n * Snapshot of the signing identity captured at context-build time. The\n * transport layer reads from this snapshot rather than from `provider.*`\n * directly so a provider object whose fields drift between context build\n * and outbound request can't desynchronize the on-wire `keyid` from the\n * cache key the connection was bound to. TypeScript's `readonly` modifier\n * is compile-time only; the snapshot is the runtime defense.\n */\nexport interface AgentSigningIdentitySnapshot {\n keyid: string;\n algorithm: AdcpSignAlg;\n adcpUse?: string;\n /** Defensively hashed disambiguator — see {@link buildAgentSigningContext}. */\n fingerprint: string;\n}\n\n/**\n * Per-call signing context passed down to the MCP/A2A transport layer. Built\n * at `ProtocolClient.callTool` and consumed by the signing fetch wrapper\n * attached to the transport. Opaque to the transport helpers — they only\n * use `cacheKey` (to disambiguate connection-cache entries per signing\n * identity), `getCapability` (to read the cached seller advertisement on\n * each outbound request), and `signing` (to produce the signer key or\n * provider).\n */\nexport interface AgentSigningContext {\n /** Signing config copied from AgentConfig.request_signing. */\n signing: AgentRequestSigningConfig;\n /** Provider when `signing.kind === 'provider'`; undefined for inline keys. */\n provider?: SigningProvider;\n /** Snapshot of identity fields read from the provider at build time. */\n identity: AgentSigningIdentitySnapshot;\n /** Suffix to append to transport connection-cache keys so agents with different signing identities don't share a connection. */\n cacheKey: string;\n /** Lazy accessor for the currently cached capability for this agent. */\n getCapability: () => CachedCapability | undefined;\n /** Capability cache backing this context (for external invalidation). */\n cache: CapabilityCache;\n /** Stable cache key used against the capability cache itself. */\n capabilityCacheKey: string;\n /** Trusted SDK/endpoint pin used to select the request-signing wire profile. */\n adcpVersion: string;\n /**\n * Evict this context's capability entry so the next outbound call\n * re-primes `get_adcp_capabilities`. Use after a seller-side rotation\n * signal — or on a 401 / protocol-signature error — without having to\n * rebuild the cache key from the agent's identifying fields.\n */\n invalidate(): void;\n}\n\n/**\n * AsyncLocalStorage carrying the signing context across the transport layer.\n * Top-level protocol entries (`callMCPTool`, `callA2ATool`, etc.) push a\n * context onto this storage for the duration of the call; internal helpers\n * (`withCachedConnection`, `connectMCPWithFallback`, `buildFetchImpl`) read\n * it when building cache keys and signing-fetch wrappers, avoiding the need\n * to thread `signingContext` through every intermediate signature.\n *\n * The top-level entries always call `run()` — including with `undefined` —\n * so a non-signing call cannot inherit a stale context from an enclosing\n * scope.\n */\nexport const signingContextStorage = globalAsyncLocalStorage<AgentSigningContext | undefined>('signingContext');\n\n/**\n * Build an `AgentSigningContext` from an `AgentConfig` when signing is\n * configured. Returns `undefined` when the agent has no `request_signing`\n * block — callers use this to branch into the no-op fast path.\n */\nexport function buildAgentSigningContext(\n agent: AgentConfig,\n options: { cache?: CapabilityCache; adcpVersion?: string } = {}\n): AgentSigningContext | undefined {\n const signing = agent.request_signing;\n if (!signing) return undefined;\n\n const cache = options.cache ?? defaultCapabilityCache;\n const identity = snapshotIdentity(signing);\n const cacheFingerprint = deriveCacheFingerprint(identity);\n const adcpVersion = options.adcpVersion ?? ADCP_VERSION;\n const capabilityCacheKey = buildCapabilityCacheKey(\n agent.agent_uri,\n capabilityPrincipalScope(agent),\n cacheFingerprint,\n adcpVersion\n );\n // Transport-connection cache-key suffix binds to the defensively hashed\n // identity, not just the advertised `kid`. Two tenants that misconfigure\n // the same `kid` string but hold distinct keys must not collide on a\n // shared cached transport — that would sign one tenant's outbound\n // requests with the other tenant's key (same `kid`, different material),\n // an impersonation. The hash includes `algorithm` so an Ed25519/P-256\n // swap on the same `kid+fingerprint` doesn't alias either.\n const cacheKey = `sig=${cacheFingerprint};adcp=${adcpVersion}`;\n const provider = signing.kind === 'provider' ? signing.provider : undefined;\n\n return {\n signing,\n provider,\n identity,\n cacheKey,\n cache,\n capabilityCacheKey,\n adcpVersion,\n getCapability: () => cache.get(capabilityCacheKey),\n invalidate: () => cache.invalidate(capabilityCacheKey),\n };\n}\n\n/**\n * Bind capability advertisements to the effective authenticated/routed\n * principal. Basic and routing credentials live in headers, while OAuth\n * credentials live outside `auth_token`; hashing the complete scope prevents\n * one principal from reusing another principal's signing policy.\n */\nfunction capabilityPrincipalScope(agent: AgentConfig): string | undefined {\n const credentials = agent.oauth_client_credentials;\n const headers = agent.headers\n ? Object.fromEntries(\n Object.entries(agent.headers)\n .map(([name, value]) => [name.toLowerCase(), value] as const)\n .sort(([a], [b]) => a.localeCompare(b))\n )\n : undefined;\n const scope = {\n protocol: agent.protocol,\n authToken: agent.auth_token,\n oauthAccessToken: agent.oauth_tokens?.access_token,\n oauthClientId: agent.oauth_client?.client_id,\n oauthResource: agent.oauth_resource,\n oauthClientCredentials: credentials\n ? {\n tokenEndpoint: credentials.token_endpoint,\n clientId: credentials.client_id,\n scope: credentials.scope,\n resource: credentials.resource,\n audience: credentials.audience,\n }\n : undefined,\n headers,\n };\n return capabilityScopeDisambiguator(JSON.stringify(scope));\n}\n\nfunction capabilityScopeDisambiguator(value: string): string {\n return Buffer.from(hkdfSync('sha256', value, CAPABILITY_SCOPE_SALT, 'adcp-signing-capability-cache', 32)).toString(\n 'hex'\n );\n}\n\n/**\n * Snapshot the signing identity at context-build time. For provider configs,\n * reads `keyid` / `algorithm` / `fingerprint` once and freezes them. For\n * inline configs, derives a fingerprint from the private scalar — same\n * 64-bit cache disambiguator the SDK has always used.\n */\nfunction snapshotIdentity(signing: AgentRequestSigningConfig): AgentSigningIdentitySnapshot {\n if (signing.kind === 'provider') {\n const provider = signing.provider;\n return {\n keyid: provider.keyid,\n algorithm: provider.algorithm,\n ...(provider.adcpUse !== undefined && { adcpUse: provider.adcpUse }),\n fingerprint: provider.fingerprint,\n };\n }\n return {\n keyid: signing.kid,\n algorithm: signing.alg,\n ...(typeof signing.private_key.adcp_use === 'string' && { adcpUse: signing.private_key.adcp_use }),\n fingerprint: inlineFingerprint(signing.kid, signing.private_key.d),\n };\n}\n\n/**\n * Defensively hash the snapshot before composing cache keys. A\n * provider-supplied `fingerprint` is treated as untrusted input — a\n * confused integrator could return a constant, an empty string, or a\n * tenant-controlled value, any of which would re-enable cross-tenant\n * collisions on the same `kid`. Including `algorithm` in the digest\n * prevents an Ed25519/P-256 swap on identical `kid+fingerprint` from\n * aliasing.\n *\n * Truncated to 16 hex chars — a 64-bit collision-resistance budget against\n * random keys is plenty for a cache disambiguator, and we never rely on\n * this value as a security boundary.\n */\nfunction deriveCacheFingerprint(identity: AgentSigningIdentitySnapshot): string {\n return createHash('sha256')\n .update(identity.algorithm)\n .update('\\0')\n .update(identity.keyid)\n .update('\\0')\n .update(identity.adcpUse ?? '')\n .update('\\0')\n .update(identity.fingerprint)\n .digest('hex')\n .slice(0, 16);\n}\n\nfunction inlineFingerprint(kid: string, d: string | undefined): string {\n if (!d) {\n throw new TypeError(\n `AgentRequestSigningConfig (kind: 'inline', kid='${kid}') is missing 'private_key.d' — JWK must include the private scalar.`\n );\n }\n return createHash('sha256').update(kid).update('\\0').update(d).digest('hex').slice(0, 16);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAkD;AAClD,wCAAwC;AAExC,8BAKO;AAGP,qBAA6B;AAE7B,MAAM,4BAAwB,gCAAY,EAAE;AAiErC,MAAM,4BAAwB,2DAAyD,gBAAgB;AAOvG,SAAS,yBACd,OACA,UAA6D,CAAC,GAC7B;AACjC,QAAM,UAAU,MAAM;AACtB,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,WAAW,iBAAiB,OAAO;AACzC,QAAM,mBAA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EAAE;AAAA,IACxG;AAAA,EACF;AACF;AAQA,SAAS,iBAAiB,SAAkE;AAC1F,MAAI,QAAQ,SAAS,YAAY;AAC/B,UAAM,WAAW,QAAQ;AACzB,WAAO;AAAA,MACL,OAAO,SAAS;AAAA,MAChB,WAAW,SAAS;AAAA,MACpB,GAAI,SAAS,YAAY,UAAa,EAAE,SAAS,SAAS,QAAQ;AAAA,MAClE,aAAa,SAAS;AAAA,IACxB;AAAA,EACF;AACA,SAAO;AAAA,IACL,OAAO,QAAQ;AAAA,IACf,WAAW,QAAQ;AAAA,IACnB,GAAI,OAAO,QAAQ,YAAY,aAAa,YAAY,EAAE,SAAS,QAAQ,YAAY,SAAS;AAAA,IAChG,aAAa,kBAAkB,QAAQ,KAAK,QAAQ,YAAY,CAAC;AAAA,EACnE;AACF;AAeA,SAAS,uBAAuB,UAAgD;AAC9E,aAAO,+BAAW,QAAQ,EACvB,OAAO,SAAS,SAAS,EACzB,OAAO,IAAI,EACX,OAAO,SAAS,KAAK,EACrB,OAAO,IAAI,EACX,OAAO,SAAS,WAAW,EAAE,EAC7B,OAAO,IAAI,EACX,OAAO,SAAS,WAAW,EAC3B,OAAO,KAAK,EACZ,MAAM,GAAG,EAAE;AAChB;AAEA,SAAS,kBAAkB,KAAa,GAA+B;AACrE,MAAI,CAAC,GAAG;AACN,UAAM,IAAI;AAAA,MACR,mDAAmD,GAAG;AAAA,IACxD;AAAA,EACF;AACA,aAAO,+BAAW,QAAQ,EAAE,OAAO,GAAG,EAAE,OAAO,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC1F;","names":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { createHash, hkdfSync, randomBytes } from "node:crypto";
|
|
2
2
|
import { globalAsyncLocalStorage } from "../utils/global-async-local-storage.mjs";
|
|
3
3
|
import {
|
|
4
4
|
buildCapabilityCacheKey,
|
|
5
5
|
defaultCapabilityCache
|
|
6
6
|
} from "./capability-cache.mjs";
|
|
7
7
|
import { ADCP_VERSION } from "../version.mjs";
|
|
8
|
+
const CAPABILITY_SCOPE_SALT = randomBytes(32);
|
|
8
9
|
const signingContextStorage = globalAsyncLocalStorage("signingContext");
|
|
9
10
|
function buildAgentSigningContext(agent, options = {}) {
|
|
10
11
|
const signing = agent.request_signing;
|
|
@@ -13,7 +14,12 @@ function buildAgentSigningContext(agent, options = {}) {
|
|
|
13
14
|
const identity = snapshotIdentity(signing);
|
|
14
15
|
const cacheFingerprint = deriveCacheFingerprint(identity);
|
|
15
16
|
const adcpVersion = options.adcpVersion ?? ADCP_VERSION;
|
|
16
|
-
const capabilityCacheKey = buildCapabilityCacheKey(
|
|
17
|
+
const capabilityCacheKey = buildCapabilityCacheKey(
|
|
18
|
+
agent.agent_uri,
|
|
19
|
+
capabilityPrincipalScope(agent),
|
|
20
|
+
cacheFingerprint,
|
|
21
|
+
adcpVersion
|
|
22
|
+
);
|
|
17
23
|
const cacheKey = `sig=${cacheFingerprint};adcp=${adcpVersion}`;
|
|
18
24
|
const provider = signing.kind === "provider" ? signing.provider : void 0;
|
|
19
25
|
return {
|
|
@@ -28,23 +34,52 @@ function buildAgentSigningContext(agent, options = {}) {
|
|
|
28
34
|
invalidate: () => cache.invalidate(capabilityCacheKey)
|
|
29
35
|
};
|
|
30
36
|
}
|
|
37
|
+
function capabilityPrincipalScope(agent) {
|
|
38
|
+
const credentials = agent.oauth_client_credentials;
|
|
39
|
+
const headers = agent.headers ? Object.fromEntries(
|
|
40
|
+
Object.entries(agent.headers).map(([name, value]) => [name.toLowerCase(), value]).sort(([a], [b]) => a.localeCompare(b))
|
|
41
|
+
) : void 0;
|
|
42
|
+
const scope = {
|
|
43
|
+
protocol: agent.protocol,
|
|
44
|
+
authToken: agent.auth_token,
|
|
45
|
+
oauthAccessToken: agent.oauth_tokens?.access_token,
|
|
46
|
+
oauthClientId: agent.oauth_client?.client_id,
|
|
47
|
+
oauthResource: agent.oauth_resource,
|
|
48
|
+
oauthClientCredentials: credentials ? {
|
|
49
|
+
tokenEndpoint: credentials.token_endpoint,
|
|
50
|
+
clientId: credentials.client_id,
|
|
51
|
+
scope: credentials.scope,
|
|
52
|
+
resource: credentials.resource,
|
|
53
|
+
audience: credentials.audience
|
|
54
|
+
} : void 0,
|
|
55
|
+
headers
|
|
56
|
+
};
|
|
57
|
+
return capabilityScopeDisambiguator(JSON.stringify(scope));
|
|
58
|
+
}
|
|
59
|
+
function capabilityScopeDisambiguator(value) {
|
|
60
|
+
return Buffer.from(hkdfSync("sha256", value, CAPABILITY_SCOPE_SALT, "adcp-signing-capability-cache", 32)).toString(
|
|
61
|
+
"hex"
|
|
62
|
+
);
|
|
63
|
+
}
|
|
31
64
|
function snapshotIdentity(signing) {
|
|
32
65
|
if (signing.kind === "provider") {
|
|
33
66
|
const provider = signing.provider;
|
|
34
67
|
return {
|
|
35
68
|
keyid: provider.keyid,
|
|
36
69
|
algorithm: provider.algorithm,
|
|
70
|
+
...provider.adcpUse !== void 0 && { adcpUse: provider.adcpUse },
|
|
37
71
|
fingerprint: provider.fingerprint
|
|
38
72
|
};
|
|
39
73
|
}
|
|
40
74
|
return {
|
|
41
75
|
keyid: signing.kid,
|
|
42
76
|
algorithm: signing.alg,
|
|
77
|
+
...typeof signing.private_key.adcp_use === "string" && { adcpUse: signing.private_key.adcp_use },
|
|
43
78
|
fingerprint: inlineFingerprint(signing.kid, signing.private_key.d)
|
|
44
79
|
};
|
|
45
80
|
}
|
|
46
81
|
function deriveCacheFingerprint(identity) {
|
|
47
|
-
return createHash("sha256").update(identity.algorithm).update("\0").update(identity.keyid).update("\0").update(identity.fingerprint).digest("hex").slice(0, 16);
|
|
82
|
+
return createHash("sha256").update(identity.algorithm).update("\0").update(identity.keyid).update("\0").update(identity.adcpUse ?? "").update("\0").update(identity.fingerprint).digest("hex").slice(0, 16);
|
|
48
83
|
}
|
|
49
84
|
function inlineFingerprint(kid, d) {
|
|
50
85
|
if (!d) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/signing/agent-context.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { globalAsyncLocalStorage } from '../utils/global-async-local-storage';\nimport type { AgentConfig, AgentRequestSigningConfig } from '../types/adcp';\nimport {\n buildCapabilityCacheKey,\n CapabilityCache,\n defaultCapabilityCache,\n type CachedCapability,\n} from './capability-cache';\nimport type { SigningProvider } from './provider';\nimport type { AdcpSignAlg } from './types';\nimport { ADCP_VERSION } from '../version';\n\n/**\n * Snapshot of the signing identity captured at context-build time. The\n * transport layer reads from this snapshot rather than from `provider.*`\n * directly so a provider object whose fields drift between context build\n * and outbound request can't desynchronize the on-wire `keyid` from the\n * cache key the connection was bound to. TypeScript's `readonly` modifier\n * is compile-time only; the snapshot is the runtime defense.\n */\nexport interface AgentSigningIdentitySnapshot {\n keyid: string;\n algorithm: AdcpSignAlg;\n /** Defensively hashed disambiguator — see {@link buildAgentSigningContext}. */\n fingerprint: string;\n}\n\n/**\n * Per-call signing context passed down to the MCP/A2A transport layer. Built\n * at `ProtocolClient.callTool` and consumed by the signing fetch wrapper\n * attached to the transport. Opaque to the transport helpers — they only\n * use `cacheKey` (to disambiguate connection-cache entries per signing\n * identity), `getCapability` (to read the cached seller advertisement on\n * each outbound request), and `signing` (to produce the signer key or\n * provider).\n */\nexport interface AgentSigningContext {\n /** Signing config copied from AgentConfig.request_signing. */\n signing: AgentRequestSigningConfig;\n /** Provider when `signing.kind === 'provider'`; undefined for inline keys. */\n provider?: SigningProvider;\n /** Snapshot of identity fields read from the provider at build time. */\n identity: AgentSigningIdentitySnapshot;\n /** Suffix to append to transport connection-cache keys so agents with different signing identities don't share a connection. */\n cacheKey: string;\n /** Lazy accessor for the currently cached capability for this agent. */\n getCapability: () => CachedCapability | undefined;\n /** Capability cache backing this context (for external invalidation). */\n cache: CapabilityCache;\n /** Stable cache key used against the capability cache itself. */\n capabilityCacheKey: string;\n /** Trusted SDK/endpoint pin used to select the request-signing wire profile. */\n adcpVersion: string;\n /**\n * Evict this context's capability entry so the next outbound call\n * re-primes `get_adcp_capabilities`. Use after a seller-side rotation\n * signal — or on a 401 / protocol-signature error — without having to\n * rebuild the cache key from the agent's identifying fields.\n */\n invalidate(): void;\n}\n\n/**\n * AsyncLocalStorage carrying the signing context across the transport layer.\n * Top-level protocol entries (`callMCPTool`, `callA2ATool`, etc.) push a\n * context onto this storage for the duration of the call; internal helpers\n * (`withCachedConnection`, `connectMCPWithFallback`, `buildFetchImpl`) read\n * it when building cache keys and signing-fetch wrappers, avoiding the need\n * to thread `signingContext` through every intermediate signature.\n *\n * The top-level entries always call `run()` — including with `undefined` —\n * so a non-signing call cannot inherit a stale context from an enclosing\n * scope.\n */\nexport const signingContextStorage = globalAsyncLocalStorage<AgentSigningContext | undefined>('signingContext');\n\n/**\n * Build an `AgentSigningContext` from an `AgentConfig` when signing is\n * configured. Returns `undefined` when the agent has no `request_signing`\n * block — callers use this to branch into the no-op fast path.\n */\nexport function buildAgentSigningContext(\n agent: AgentConfig,\n options: { cache?: CapabilityCache; adcpVersion?: string } = {}\n): AgentSigningContext | undefined {\n const signing = agent.request_signing;\n if (!signing) return undefined;\n\n const cache = options.cache ?? defaultCapabilityCache;\n const identity = snapshotIdentity(signing);\n const cacheFingerprint = deriveCacheFingerprint(identity);\n const adcpVersion = options.adcpVersion ?? ADCP_VERSION;\n const capabilityCacheKey = buildCapabilityCacheKey(agent.agent_uri, agent.auth_token, cacheFingerprint, adcpVersion);\n // Transport-connection cache-key suffix binds to the defensively hashed\n // identity, not just the advertised `kid`. Two tenants that misconfigure\n // the same `kid` string but hold distinct keys must not collide on a\n // shared cached transport — that would sign one tenant's outbound\n // requests with the other tenant's key (same `kid`, different material),\n // an impersonation. The hash includes `algorithm` so an Ed25519/P-256\n // swap on the same `kid+fingerprint` doesn't alias either.\n const cacheKey = `sig=${cacheFingerprint};adcp=${adcpVersion}`;\n const provider = signing.kind === 'provider' ? signing.provider : undefined;\n\n return {\n signing,\n provider,\n identity,\n cacheKey,\n cache,\n capabilityCacheKey,\n adcpVersion,\n getCapability: () => cache.get(capabilityCacheKey),\n invalidate: () => cache.invalidate(capabilityCacheKey),\n };\n}\n\n/**\n * Snapshot the signing identity at context-build time. For provider configs,\n * reads `keyid` / `algorithm` / `fingerprint` once and freezes them. For\n * inline configs, derives a fingerprint from the private scalar — same\n * 64-bit cache disambiguator the SDK has always used.\n */\nfunction snapshotIdentity(signing: AgentRequestSigningConfig): AgentSigningIdentitySnapshot {\n if (signing.kind === 'provider') {\n const provider = signing.provider;\n return {\n keyid: provider.keyid,\n algorithm: provider.algorithm,\n fingerprint: provider.fingerprint,\n };\n }\n return {\n keyid: signing.kid,\n algorithm: signing.alg,\n fingerprint: inlineFingerprint(signing.kid, signing.private_key.d),\n };\n}\n\n/**\n * Defensively hash the snapshot before composing cache keys. A\n * provider-supplied `fingerprint` is treated as untrusted input — a\n * confused integrator could return a constant, an empty string, or a\n * tenant-controlled value, any of which would re-enable cross-tenant\n * collisions on the same `kid`. Including `algorithm` in the digest\n * prevents an Ed25519/P-256 swap on identical `kid+fingerprint` from\n * aliasing.\n *\n * Truncated to 16 hex chars — a 64-bit collision-resistance budget against\n * random keys is plenty for a cache disambiguator, and we never rely on\n * this value as a security boundary.\n */\nfunction deriveCacheFingerprint(identity: AgentSigningIdentitySnapshot): string {\n return createHash('sha256')\n .update(identity.algorithm)\n .update('\\0')\n .update(identity.keyid)\n .update('\\0')\n .update(identity.fingerprint)\n .digest('hex')\n .slice(0, 16);\n}\n\nfunction inlineFingerprint(kid: string, d: string | undefined): string {\n if (!d) {\n throw new TypeError(\n `AgentRequestSigningConfig (kind: 'inline', kid='${kid}') is missing 'private_key.d' — JWK must include the private scalar.`\n );\n }\n return createHash('sha256').update(kid).update('\\0').update(d).digest('hex').slice(0, 16);\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,+BAA+B;AAExC;AAAA,EACE;AAAA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,GAA+B;AACrE,MAAI,CAAC,GAAG;AACN,UAAM,IAAI;AAAA,MACR,mDAAmD,GAAG;AAAA,IACxD;AAAA,EACF;AACA,SAAO,WAAW,QAAQ,EAAE,OAAO,GAAG,EAAE,OAAO,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC1F;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/signing/agent-context.ts"],"sourcesContent":["import { createHash, hkdfSync, randomBytes } from 'node:crypto';\nimport { globalAsyncLocalStorage } from '../utils/global-async-local-storage';\nimport type { AgentConfig, AgentRequestSigningConfig } from '../types/adcp';\nimport {\n buildCapabilityCacheKey,\n CapabilityCache,\n defaultCapabilityCache,\n type CachedCapability,\n} from './capability-cache';\nimport type { SigningProvider } from './provider';\nimport type { AdcpSignAlg } from './types';\nimport { ADCP_VERSION } from '../version';\n\nconst CAPABILITY_SCOPE_SALT = randomBytes(32);\n\n/**\n * Snapshot of the signing identity captured at context-build time. The\n * transport layer reads from this snapshot rather than from `provider.*`\n * directly so a provider object whose fields drift between context build\n * and outbound request can't desynchronize the on-wire `keyid` from the\n * cache key the connection was bound to. TypeScript's `readonly` modifier\n * is compile-time only; the snapshot is the runtime defense.\n */\nexport interface AgentSigningIdentitySnapshot {\n keyid: string;\n algorithm: AdcpSignAlg;\n adcpUse?: string;\n /** Defensively hashed disambiguator — see {@link buildAgentSigningContext}. */\n fingerprint: string;\n}\n\n/**\n * Per-call signing context passed down to the MCP/A2A transport layer. Built\n * at `ProtocolClient.callTool` and consumed by the signing fetch wrapper\n * attached to the transport. Opaque to the transport helpers — they only\n * use `cacheKey` (to disambiguate connection-cache entries per signing\n * identity), `getCapability` (to read the cached seller advertisement on\n * each outbound request), and `signing` (to produce the signer key or\n * provider).\n */\nexport interface AgentSigningContext {\n /** Signing config copied from AgentConfig.request_signing. */\n signing: AgentRequestSigningConfig;\n /** Provider when `signing.kind === 'provider'`; undefined for inline keys. */\n provider?: SigningProvider;\n /** Snapshot of identity fields read from the provider at build time. */\n identity: AgentSigningIdentitySnapshot;\n /** Suffix to append to transport connection-cache keys so agents with different signing identities don't share a connection. */\n cacheKey: string;\n /** Lazy accessor for the currently cached capability for this agent. */\n getCapability: () => CachedCapability | undefined;\n /** Capability cache backing this context (for external invalidation). */\n cache: CapabilityCache;\n /** Stable cache key used against the capability cache itself. */\n capabilityCacheKey: string;\n /** Trusted SDK/endpoint pin used to select the request-signing wire profile. */\n adcpVersion: string;\n /**\n * Evict this context's capability entry so the next outbound call\n * re-primes `get_adcp_capabilities`. Use after a seller-side rotation\n * signal — or on a 401 / protocol-signature error — without having to\n * rebuild the cache key from the agent's identifying fields.\n */\n invalidate(): void;\n}\n\n/**\n * AsyncLocalStorage carrying the signing context across the transport layer.\n * Top-level protocol entries (`callMCPTool`, `callA2ATool`, etc.) push a\n * context onto this storage for the duration of the call; internal helpers\n * (`withCachedConnection`, `connectMCPWithFallback`, `buildFetchImpl`) read\n * it when building cache keys and signing-fetch wrappers, avoiding the need\n * to thread `signingContext` through every intermediate signature.\n *\n * The top-level entries always call `run()` — including with `undefined` —\n * so a non-signing call cannot inherit a stale context from an enclosing\n * scope.\n */\nexport const signingContextStorage = globalAsyncLocalStorage<AgentSigningContext | undefined>('signingContext');\n\n/**\n * Build an `AgentSigningContext` from an `AgentConfig` when signing is\n * configured. Returns `undefined` when the agent has no `request_signing`\n * block — callers use this to branch into the no-op fast path.\n */\nexport function buildAgentSigningContext(\n agent: AgentConfig,\n options: { cache?: CapabilityCache; adcpVersion?: string } = {}\n): AgentSigningContext | undefined {\n const signing = agent.request_signing;\n if (!signing) return undefined;\n\n const cache = options.cache ?? defaultCapabilityCache;\n const identity = snapshotIdentity(signing);\n const cacheFingerprint = deriveCacheFingerprint(identity);\n const adcpVersion = options.adcpVersion ?? ADCP_VERSION;\n const capabilityCacheKey = buildCapabilityCacheKey(\n agent.agent_uri,\n capabilityPrincipalScope(agent),\n cacheFingerprint,\n adcpVersion\n );\n // Transport-connection cache-key suffix binds to the defensively hashed\n // identity, not just the advertised `kid`. Two tenants that misconfigure\n // the same `kid` string but hold distinct keys must not collide on a\n // shared cached transport — that would sign one tenant's outbound\n // requests with the other tenant's key (same `kid`, different material),\n // an impersonation. The hash includes `algorithm` so an Ed25519/P-256\n // swap on the same `kid+fingerprint` doesn't alias either.\n const cacheKey = `sig=${cacheFingerprint};adcp=${adcpVersion}`;\n const provider = signing.kind === 'provider' ? signing.provider : undefined;\n\n return {\n signing,\n provider,\n identity,\n cacheKey,\n cache,\n capabilityCacheKey,\n adcpVersion,\n getCapability: () => cache.get(capabilityCacheKey),\n invalidate: () => cache.invalidate(capabilityCacheKey),\n };\n}\n\n/**\n * Bind capability advertisements to the effective authenticated/routed\n * principal. Basic and routing credentials live in headers, while OAuth\n * credentials live outside `auth_token`; hashing the complete scope prevents\n * one principal from reusing another principal's signing policy.\n */\nfunction capabilityPrincipalScope(agent: AgentConfig): string | undefined {\n const credentials = agent.oauth_client_credentials;\n const headers = agent.headers\n ? Object.fromEntries(\n Object.entries(agent.headers)\n .map(([name, value]) => [name.toLowerCase(), value] as const)\n .sort(([a], [b]) => a.localeCompare(b))\n )\n : undefined;\n const scope = {\n protocol: agent.protocol,\n authToken: agent.auth_token,\n oauthAccessToken: agent.oauth_tokens?.access_token,\n oauthClientId: agent.oauth_client?.client_id,\n oauthResource: agent.oauth_resource,\n oauthClientCredentials: credentials\n ? {\n tokenEndpoint: credentials.token_endpoint,\n clientId: credentials.client_id,\n scope: credentials.scope,\n resource: credentials.resource,\n audience: credentials.audience,\n }\n : undefined,\n headers,\n };\n return capabilityScopeDisambiguator(JSON.stringify(scope));\n}\n\nfunction capabilityScopeDisambiguator(value: string): string {\n return Buffer.from(hkdfSync('sha256', value, CAPABILITY_SCOPE_SALT, 'adcp-signing-capability-cache', 32)).toString(\n 'hex'\n );\n}\n\n/**\n * Snapshot the signing identity at context-build time. For provider configs,\n * reads `keyid` / `algorithm` / `fingerprint` once and freezes them. For\n * inline configs, derives a fingerprint from the private scalar — same\n * 64-bit cache disambiguator the SDK has always used.\n */\nfunction snapshotIdentity(signing: AgentRequestSigningConfig): AgentSigningIdentitySnapshot {\n if (signing.kind === 'provider') {\n const provider = signing.provider;\n return {\n keyid: provider.keyid,\n algorithm: provider.algorithm,\n ...(provider.adcpUse !== undefined && { adcpUse: provider.adcpUse }),\n fingerprint: provider.fingerprint,\n };\n }\n return {\n keyid: signing.kid,\n algorithm: signing.alg,\n ...(typeof signing.private_key.adcp_use === 'string' && { adcpUse: signing.private_key.adcp_use }),\n fingerprint: inlineFingerprint(signing.kid, signing.private_key.d),\n };\n}\n\n/**\n * Defensively hash the snapshot before composing cache keys. A\n * provider-supplied `fingerprint` is treated as untrusted input — a\n * confused integrator could return a constant, an empty string, or a\n * tenant-controlled value, any of which would re-enable cross-tenant\n * collisions on the same `kid`. Including `algorithm` in the digest\n * prevents an Ed25519/P-256 swap on identical `kid+fingerprint` from\n * aliasing.\n *\n * Truncated to 16 hex chars — a 64-bit collision-resistance budget against\n * random keys is plenty for a cache disambiguator, and we never rely on\n * this value as a security boundary.\n */\nfunction deriveCacheFingerprint(identity: AgentSigningIdentitySnapshot): string {\n return createHash('sha256')\n .update(identity.algorithm)\n .update('\\0')\n .update(identity.keyid)\n .update('\\0')\n .update(identity.adcpUse ?? '')\n .update('\\0')\n .update(identity.fingerprint)\n .digest('hex')\n .slice(0, 16);\n}\n\nfunction inlineFingerprint(kid: string, d: string | undefined): string {\n if (!d) {\n throw new TypeError(\n `AgentRequestSigningConfig (kind: 'inline', kid='${kid}') is missing 'private_key.d' — JWK must include the private scalar.`\n );\n }\n return createHash('sha256').update(kid).update('\\0').update(d).digest('hex').slice(0, 16);\n}\n"],"mappings":"AAAA,SAAS,YAAY,UAAU,mBAAmB;AAClD,SAAS,+BAA+B;AAExC;AAAA,EACE;AAAA,EAEA;AAAA,OAEK;AAGP,SAAS,oBAAoB;AAE7B,MAAM,wBAAwB,YAAY,EAAE;AAiErC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|
|
@@ -35,8 +35,7 @@ export declare function extractAdcpOperation(body: unknown): string | undefined;
|
|
|
35
35
|
* `sign_supported: true` (defaults off).
|
|
36
36
|
*
|
|
37
37
|
* Returns false when the capability is unknown (cold cache) except for ops
|
|
38
|
-
* in `always_sign
|
|
39
|
-
* never signed.
|
|
38
|
+
* in `always_sign`.
|
|
40
39
|
*/
|
|
41
40
|
export declare function shouldSignOperation(operation: string | undefined, capability: VerifierCapability | undefined, config: AgentRequestSigningConfig): boolean;
|
|
42
41
|
/**
|
|
@@ -35,8 +35,7 @@ export declare function extractAdcpOperation(body: unknown): string | undefined;
|
|
|
35
35
|
* `sign_supported: true` (defaults off).
|
|
36
36
|
*
|
|
37
37
|
* Returns false when the capability is unknown (cold cache) except for ops
|
|
38
|
-
* in `always_sign
|
|
39
|
-
* never signed.
|
|
38
|
+
* in `always_sign`.
|
|
40
39
|
*/
|
|
41
40
|
export declare function shouldSignOperation(operation: string | undefined, capability: VerifierCapability | undefined, config: AgentRequestSigningConfig): boolean;
|
|
42
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/signing/agent-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,+BAA+B,EAC/B,iCAAiC,EAClC,MAAM,eAAe,CAAC;AAGvB,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AAEpE,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAA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B,GAAG,MAAM,IAAI,+BAA+B,CAElH;AAED,+CAA+C;AAC/C,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,yBAAyB,GAChC,MAAM,IAAI,iCAAiC,CAE7C;AAED,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,yBAAyB,CAAC;IACnC,+EAA+E;IAC/E,aAAa,EAAE,MAAM,gBAAgB,GAAG,SAAS,CAAC;IAClD,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,GAAG,SAAS,CAmCxF;AAgBD,MAAM,WAAW,6BAA6B;IAC5C,iFAAiF;IACjF,OAAO,EAAE,yBAAyB,CAAC;IACnC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;OASG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,GAAG,SAAS,CAUxF"}
|
|
@@ -155,10 +155,12 @@ function buildAgentSigningFetch(options) {
|
|
|
155
155
|
function freezeProviderIdentity(provider) {
|
|
156
156
|
const keyid = provider.keyid;
|
|
157
157
|
const algorithm = provider.algorithm;
|
|
158
|
+
const adcpUse = provider.adcpUse;
|
|
158
159
|
const fingerprint = provider.fingerprint;
|
|
159
160
|
return {
|
|
160
161
|
keyid,
|
|
161
162
|
algorithm,
|
|
163
|
+
adcpUse,
|
|
162
164
|
fingerprint,
|
|
163
165
|
sign: (payload) => provider.sign(payload)
|
|
164
166
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/signing/agent-fetch.ts"],"sourcesContent":["import type {\n AgentRequestSigningConfig,\n AgentRequestSigningConfigInline,\n AgentRequestSigningConfigProvider,\n} from '../types/adcp';\nimport { createSigningFetch, type CoverContentDigestPredicate } from './fetch';\nimport { createSigningFetchAsync } from './fetch-async';\nimport {\n buildCapabilityCacheKey,\n defaultCapabilityCache,\n type CachedCapability,\n type CapabilityCache,\n} from './capability-cache';\nimport type { ContentDigestPolicy, VerifierCapability } from './types';\nimport type { SignerKey } from './signer';\nimport { containsWebhookAuthentication } from './webhook-auth-detection';\nimport { ADCP_VERSION } from '../version';\nimport { requestSigningEncodingForVersion } from './content-digest';\nexport { requestSigningEncodingForVersion } from './content-digest';\n\ntype FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;\nconst MAX_WEBHOOK_AUTH_INSPECTION_BYTES = 1_048_576;\n\n/**\n * Resolve `globalThis.fetch` at the moment of each outbound request — not at\n * module import, and not at factory call. Late resolution lets a polyfill\n * installed after `buildAgentSigningFetch` returns (but before first request)\n * still take effect. The helper throws a clear error on environments lacking\n * global `fetch` instead of binding `undefined` and failing cryptically inside\n * the signing pipeline.\n */\nfunction defaultUpstream(): FetchLike {\n const f = (globalThis as { fetch?: FetchLike }).fetch;\n if (typeof f !== 'function') {\n throw new TypeError(\n 'buildAgentSigningFetch: no upstream fetch provided and globalThis.fetch is unavailable. Pass `upstream: yourFetch` explicitly.'\n );\n }\n return f;\n}\n\nfunction bodyToUtf8(body: unknown): string | undefined {\n if (body === undefined || body === null) return undefined;\n if (typeof body === 'string') return body.length ? body : undefined;\n if (body instanceof Uint8Array) return Buffer.from(body).toString('utf8');\n if (body instanceof ArrayBuffer) return Buffer.from(body).toString('utf8');\n // FormData / Blob / ReadableStream / async iterables fall through. Throw\n // rather than return `undefined` — a silent pass-through would ship the\n // request unsigned with no hint to the caller, defeating the seller's\n // `required_for` contract. Matches the strict posture of `createSigningFetch`\n // which also refuses unsupported body shapes.\n throw new TypeError(\n `buildAgentSigningFetch cannot extract an AdCP operation name from a body of type ${describeBody(body)}. The signer only supports string, Uint8Array, and ArrayBuffer bodies because the signature must cover the exact wire bytes.`\n );\n}\n\nfunction describeBody(body: unknown): string {\n if (body && typeof body === 'object') {\n const ctor = (body as { constructor?: { name?: string } }).constructor?.name;\n if (ctor) return ctor;\n }\n return typeof body;\n}\n\n/**\n * Extract the AdCP operation name from a JSON-RPC request body, if any.\n *\n * - MCP tool calls: `method === \"tools/call\"` → `params.name` is the op name.\n * - A2A `message/send` / `message/stream`: the op name lives on the first\n * data-kind part as `data.skill`.\n * - All other JSON-RPC methods (`initialize`, `tools/list`, notifications)\n * return `undefined` — those are protocol-layer housekeeping, not AdCP\n * operations subject to request-signing policy.\n *\n * Throws if the body is of a shape the signer can't read (Blob, FormData,\n * ReadableStream). The MCP / A2A SDKs both emit JSON strings today; a future\n * SDK version switching to streams would silently break signing otherwise.\n */\nexport function extractAdcpOperation(body: unknown): string | undefined {\n const text = bodyToUtf8(body);\n if (!text) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n return undefined;\n }\n if (!parsed || typeof parsed !== 'object') return undefined;\n const rpc = parsed as { method?: unknown; params?: unknown };\n\n if (rpc.method === 'tools/call') {\n const params = rpc.params as { name?: unknown } | undefined;\n return typeof params?.name === 'string' ? params.name : undefined;\n }\n\n if (rpc.method === 'message/send' || rpc.method === 'message/stream') {\n const params = rpc.params as { message?: { parts?: unknown } } | undefined;\n const parts = params?.message?.parts;\n if (!Array.isArray(parts)) return undefined;\n for (const part of parts) {\n if (part && typeof part === 'object') {\n const p = part as { kind?: unknown; data?: { skill?: unknown } };\n if (p.kind === 'data' && typeof p.data?.skill === 'string') {\n return p.data.skill;\n }\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Detect webhook receiver credentials in the outbound JSON-RPC payload. The\n * verifier rejects unsigned requests carrying these credentials regardless of\n * the seller's operation-level capability advertisement, so the client must\n * sign them even while the capability cache is cold or silent for that op.\n * The scan is bounded; if the body exceeds the inspection budget, sign it.\n */\nfunction carriesWebhookAuthentication(body: unknown): boolean {\n const text = bodyToUtf8(body);\n if (!text) return false;\n if (text.length > MAX_WEBHOOK_AUTH_INSPECTION_BYTES) return true;\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n return false;\n }\n return containsWebhookAuthentication(parsed);\n}\n\n/**\n * Decide whether an outbound AdCP call should be signed given the seller's\n * advertised capability block and the buyer's override list.\n *\n * Precedence matches the AdCP spec (`required_for` > `warn_for` >\n * `supported_for`):\n * 1. `always_sign` on the buyer config — pilot-time override, signs even\n * if the seller hasn't listed the op.\n * 2. Seller `required_for` — seller rejects unsigned requests, MUST sign.\n * 3. Seller `warn_for` — shadow mode. Seller verifies when present and\n * logs failures without rejecting; counterparties SHOULD sign so the\n * seller can surface failure rates before flipping to `required_for`.\n * 4. Seller `supported_for` — sign only if the buyer opted in via\n * `sign_supported: true` (defaults off).\n *\n * Returns false when the capability is unknown (cold cache) except for ops\n * in `always_sign`, so the priming `get_adcp_capabilities` call itself is\n * never signed.\n */\nexport function shouldSignOperation(\n operation: string | undefined,\n capability: VerifierCapability | undefined,\n config: AgentRequestSigningConfig\n): boolean {\n if (!operation) return false;\n if (config.always_sign?.includes(operation)) return true;\n if (!capability?.supported) return false;\n if (capability.required_for?.includes(operation)) return true;\n if (capability.warn_for?.includes(operation)) return true;\n if (config.sign_supported && capability.supported_for?.includes(operation)) return true;\n return false;\n}\n\n/**\n * Resolve the seller's content-digest policy into a concrete per-request\n * coverage decision.\n *\n * - `required` → must cover content-digest.\n * - `forbidden` → must NOT cover content-digest.\n * - `either` / absent → default to covering (body-binding is the safer\n * choice; the seller has explicitly allowed both forms).\n */\nexport function resolveCoverContentDigest(policy: ContentDigestPolicy | undefined): boolean {\n if (policy === 'forbidden') return false;\n return true;\n}\n\n/**\n * Convert an inline `AgentRequestSigningConfig` into the `SignerKey` shape\n * expected by `signRequest` / `createSigningFetch`. Provider-backed configs\n * have no in-process key material — callers must route through\n * `createSigningFetchAsync(upstream, config.provider, ...)` instead.\n */\nexport function toSignerKey(config: AgentRequestSigningConfigInline): SignerKey {\n return {\n keyid: config.kid,\n alg: config.alg,\n privateKey: config.private_key as SignerKey['privateKey'],\n };\n}\n\n/** Narrow predicate for the inline shape (kind absent or `'inline'`). */\nexport function isInlineSigningConfig(config: AgentRequestSigningConfig): config is AgentRequestSigningConfigInline {\n return config.kind !== 'provider';\n}\n\n/** Narrow predicate for the provider shape. */\nexport function isProviderSigningConfig(\n config: AgentRequestSigningConfig\n): config is AgentRequestSigningConfigProvider {\n return config.kind === 'provider';\n}\n\nexport interface BuildAgentSigningFetchOptions {\n /**\n * Upstream fetch to wrap. Defaults to `globalThis.fetch` when omitted —\n * use a Node 18+ / browser / worker global, or pass a polyfill / a\n * decorated fetch (retries, telemetry) to compose.\n */\n upstream?: FetchLike;\n signing: AgentRequestSigningConfig;\n /** Lazy accessor for the current cached capability — re-read on every call. */\n getCapability: () => CachedCapability | undefined;\n /** Trusted SDK/endpoint version pin; never inferred from the request body. */\n adcpVersion?: string;\n}\n\n/**\n * Build a fetch wrapper suitable for injection into MCP/A2A transports. On\n * every outbound request:\n * 1. Sign immediately when the payload carries webhook authentication.\n * 2. Extract the AdCP operation name from the JSON-RPC body (MCP tool-call\n * or A2A message/send). Non-AdCP JSON-RPC methods (e.g., `initialize`)\n * pass through unsigned.\n * 3. Consult the cached seller capability to decide whether to sign.\n * 4. Resolve the seller's content-digest policy into a per-request toggle.\n * 5. Delegate to `createSigningFetch` with the decision baked in.\n */\nexport function buildAgentSigningFetch(options: BuildAgentSigningFetchOptions): FetchLike {\n const { signing, getCapability } = options;\n // Resolve `globalThis.fetch` per-call when no explicit upstream was passed\n // so a polyfill installed between factory creation and first request still\n // takes effect. Eager resolution would freeze whatever was global at\n // factory-call time.\n const explicitUpstream = options.upstream;\n const upstream: FetchLike = explicitUpstream ?? ((input, init) => defaultUpstream()(input, init));\n\n const shouldSign = (_url: string, init: RequestInit | undefined): boolean => {\n if (carriesWebhookAuthentication(init?.body)) return true;\n const operation = extractAdcpOperation(init?.body);\n const entry = getCapability();\n return shouldSignOperation(operation, entry?.requestSigning, signing);\n };\n\n const binaryEncoding = requestSigningEncodingForVersion(options.adcpVersion ?? ADCP_VERSION);\n const coverContentDigest: CoverContentDigestPredicate = (_url, _init) => {\n if (binaryEncoding === 'rfc8941-base64') return true;\n const entry = getCapability();\n return resolveCoverContentDigest(entry?.requestSigning?.covers_content_digest);\n };\n\n if (isProviderSigningConfig(signing)) {\n // Freeze the provider's identity fields at factory time and pass a\n // snapshot view down to the async signer. TypeScript `readonly` on the\n // `SigningProvider` interface is compile-time only — if a downstream\n // adapter mutates `keyid`/`algorithm`/`fingerprint` between context\n // build and outbound request, the wire `keyid` would drift away from\n // the cache key the connection was bound to. The frozen view binds the\n // wire identity to the snapshot already used for cache routing.\n const frozen = freezeProviderIdentity(signing.provider);\n return createSigningFetchAsync(upstream, frozen, { shouldSign, coverContentDigest, binaryEncoding });\n }\n return createSigningFetch(upstream, toSignerKey(signing), { shouldSign, coverContentDigest, binaryEncoding });\n}\n\nfunction freezeProviderIdentity(provider: AgentRequestSigningConfigProvider['provider']) {\n const keyid = provider.keyid;\n const algorithm = provider.algorithm;\n const fingerprint = provider.fingerprint;\n return {\n keyid,\n algorithm,\n fingerprint,\n sign: (payload: Uint8Array) => provider.sign(payload),\n };\n}\n\nexport interface CreateAgentSignedFetchOptions {\n /** This agent's RFC 9421 signing identity (kid, alg, private_key, agent_url). */\n signing: AgentRequestSigningConfig;\n /** Trusted endpoint pin used to select the 3.0/3.1 or 3.2 request profile. */\n adcpVersion?: string;\n /**\n * Target seller's `agent_uri` — the base URL whose `get_adcp_capabilities`\n * response gates whether each operation gets signed. The preset keys a\n * capability-cache entry off this URL so repeat calls reuse the same\n * advertisement.\n *\n * For multi-seller buyers, build one signed fetch per seller (or use\n * {@link buildAgentSigningFetch} directly and supply your own\n * `getCapability` that dispatches on the target URL).\n */\n sellerAgentUri: string;\n /**\n * Optional auth token the seller expects alongside the signing headers.\n * Included in the capability cache key so a token rotation naturally\n * invalidates the cached advertisement.\n */\n sellerAuthToken?: string;\n /**\n * Capability cache. Defaults to the shared {@link defaultCapabilityCache}.\n *\n * **The shared default is load-bearing.** `ProtocolClient` and\n * `buildAgentSigningContext` write the seller's `get_adcp_capabilities`\n * response into `defaultCapabilityCache`; this preset reads from the same\n * instance so a single priming call serves every subsequent signing\n * decision. Passing a fresh `new CapabilityCache()` here without also\n * priming it will silently disable `required_for` enforcement: cold cache\n * → `shouldSignOperation` returns `false` → every required op ships\n * unsigned → seller rejects. The SDK emits no error on this path because\n * \"decided not to sign\" is the spec-correct behavior on a cold cache.\n *\n * Pass an explicit cache only when you've also primed it — call\n * {@link ensureCapabilityLoaded} against your cache instance after\n * construction, or seed it via `cache.set(buildCapabilityCacheKey(uri,\n * token, fingerprint, adcpVersion), entry)` — or when you genuinely want each caller to re-fetch\n * the seller's capability block.\n *\n * Note: the cache stores **public** seller capability advertisements\n * (the contents of `get_adcp_capabilities` responses), not buyer\n * credentials. The shared default is not a multi-tenant security\n * boundary — different sellers, different auth tokens, and different\n * signing keys already get separate entries via\n * {@link buildCapabilityCacheKey}.\n */\n cache?: CapabilityCache;\n /** Upstream fetch. Defaults to `globalThis.fetch`. */\n upstream?: FetchLike;\n}\n\n/**\n * One-call preset for the single-seller case: bundles\n * {@link buildAgentSigningFetch} with a {@link CapabilityCache} lookup keyed\n * by `sellerAgentUri`, so adapter authors don't have to wire the cache and\n * capability accessor themselves.\n *\n * ```ts\n * // fetch.ts\n * import { createAgentSignedFetch } from '@adcp/sdk/signing';\n *\n * export const signedFetch = createAgentSignedFetch({\n * signing: {\n * kid: 'my-agent-2026',\n * alg: 'ed25519',\n * private_key: JSON.parse(process.env.ADCP_PRIV_KEY!),\n * agent_url: 'https://agent.example.com',\n * },\n * sellerAgentUri: 'https://seller.example.com',\n * });\n * ```\n *\n * ```ts\n * // any other module\n * import { signedFetch } from './fetch';\n *\n * await signedFetch('https://seller.example.com/mcp', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify(payload),\n * });\n * ```\n *\n * Signing only happens on operations the seller advertises as\n * `required_for` / `warn_for` (or `supported_for` when the buyer config\n * opts in) — so the `get_adcp_capabilities` priming call itself is always\n * unsigned, as the spec requires.\n *\n * For multi-seller adapters, construct one preset per seller, or use\n * {@link buildAgentSigningFetch} directly with a request-dispatching\n * `getCapability` callback.\n */\nexport function createAgentSignedFetch(options: CreateAgentSignedFetchOptions): FetchLike {\n const cache = options.cache ?? defaultCapabilityCache;\n const adcpVersion = options.adcpVersion ?? ADCP_VERSION;\n const cacheKey = buildCapabilityCacheKey(options.sellerAgentUri, options.sellerAuthToken, undefined, adcpVersion);\n return buildAgentSigningFetch({\n signing: options.signing,\n upstream: options.upstream,\n getCapability: () => cache.get(cacheKey),\n adcpVersion,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAAqE;AACrE,yBAAwC;AACxC,8BAKO;AAGP,oCAA8C;AAC9C,qBAA6B;AAC7B,4BAAiD;AACjD,IAAAA,yBAAiD;AAGjD,MAAM,oCAAoC;AAU1C,SAAS,kBAA6B;AACpC,QAAM,IAAK,WAAqC;AAChD,MAAI,OAAO,MAAM,YAAY;AAC3B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,WAAW,MAAmC;AACrD,MAAI,SAAS,UAAa,SAAS,KAAM,QAAO;AAChD,MAAI,OAAO,SAAS,SAAU,QAAO,KAAK,SAAS,OAAO;AAC1D,MAAI,gBAAgB,WAAY,QAAO,OAAO,KAAK,IAA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O;AAChD,UAAM,QAAQ,cAAc;AAC5B,WAAO,0BAA0B,OAAO,gBAAgB,qBAAqB;AAAA,EAC/E;AAEA,MAAI,wBAAwB,OAAO,GAAG;AAQpC,UAAM,SAAS,uBAAuB,QAAQ,QAAQ;AACtD,eAAO,4CAAwB,UAAU,QAAQ,EAAE,YAAY,oBAAoB,eAAe,CAAC;AAAA,EACrG;AACA,aAAO,iCAAmB,UAAU,YAAY,OAAO,GAAG,EAAE,YAAY,oBAAoB,eAAe,CAAC;AAC9G;AAEA,SAAS,uBAAuB,UAAyD;AACvF,QAAM,QAAQ,SAAS;AACvB,QAAM,YAAY,SAAS;AAC3B,QAAM,cAAc,SAAS;AAC7B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,CAAC,YAAwB,SAAS,KAAK,OAAO;AAAA,EACtD;AACF;AAgGO,SAAS,uBAAuB,SAAmD;AACxF,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,eAAW,iDAAwB,QAAQ,gBAAgB,QAAQ,iBAAiB,QAAW,WAAW;AAChH,SAAO,uBAAuB;AAAA,IAC5B,SAAS,QAAQ;AAAA,IACjB,UAAU,QAAQ;AAAA,IAClB,eAAe,MAAM,MAAM,IAAI,QAAQ;AAAA,IACvC;AAAA,EACF,CAAC;AACH;","names":["import_content_digest"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/signing/agent-fetch.ts"],"sourcesContent":["import type {\n AgentRequestSigningConfig,\n AgentRequestSigningConfigInline,\n AgentRequestSigningConfigProvider,\n} from '../types/adcp';\nimport { createSigningFetch, type CoverContentDigestPredicate } from './fetch';\nimport { createSigningFetchAsync } from './fetch-async';\nimport {\n buildCapabilityCacheKey,\n defaultCapabilityCache,\n type CachedCapability,\n type CapabilityCache,\n} from './capability-cache';\nimport type { ContentDigestPolicy, VerifierCapability } from './types';\nimport type { SignerKey } from './signer';\nimport { containsWebhookAuthentication } from './webhook-auth-detection';\nimport { ADCP_VERSION } from '../version';\nimport { requestSigningEncodingForVersion } from './content-digest';\nexport { requestSigningEncodingForVersion } from './content-digest';\n\ntype FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;\nconst MAX_WEBHOOK_AUTH_INSPECTION_BYTES = 1_048_576;\n\n/**\n * Resolve `globalThis.fetch` at the moment of each outbound request — not at\n * module import, and not at factory call. Late resolution lets a polyfill\n * installed after `buildAgentSigningFetch` returns (but before first request)\n * still take effect. The helper throws a clear error on environments lacking\n * global `fetch` instead of binding `undefined` and failing cryptically inside\n * the signing pipeline.\n */\nfunction defaultUpstream(): FetchLike {\n const f = (globalThis as { fetch?: FetchLike }).fetch;\n if (typeof f !== 'function') {\n throw new TypeError(\n 'buildAgentSigningFetch: no upstream fetch provided and globalThis.fetch is unavailable. Pass `upstream: yourFetch` explicitly.'\n );\n }\n return f;\n}\n\nfunction bodyToUtf8(body: unknown): string | undefined {\n if (body === undefined || body === null) return undefined;\n if (typeof body === 'string') return body.length ? body : undefined;\n if (body instanceof Uint8Array) return Buffer.from(body).toString('utf8');\n if (body instanceof ArrayBuffer) return Buffer.from(body).toString('utf8');\n // FormData / Blob / ReadableStream / async iterables fall through. Throw\n // rather than return `undefined` — a silent pass-through would ship the\n // request unsigned with no hint to the caller, defeating the seller's\n // `required_for` contract. Matches the strict posture of `createSigningFetch`\n // which also refuses unsupported body shapes.\n throw new TypeError(\n `buildAgentSigningFetch cannot extract an AdCP operation name from a body of type ${describeBody(body)}. The signer only supports string, Uint8Array, and ArrayBuffer bodies because the signature must cover the exact wire bytes.`\n );\n}\n\nfunction describeBody(body: unknown): string {\n if (body && typeof body === 'object') {\n const ctor = (body as { constructor?: { name?: string } }).constructor?.name;\n if (ctor) return ctor;\n }\n return typeof body;\n}\n\n/**\n * Extract the AdCP operation name from a JSON-RPC request body, if any.\n *\n * - MCP tool calls: `method === \"tools/call\"` → `params.name` is the op name.\n * - A2A `message/send` / `message/stream`: the op name lives on the first\n * data-kind part as `data.skill`.\n * - All other JSON-RPC methods (`initialize`, `tools/list`, notifications)\n * return `undefined` — those are protocol-layer housekeeping, not AdCP\n * operations subject to request-signing policy.\n *\n * Throws if the body is of a shape the signer can't read (Blob, FormData,\n * ReadableStream). The MCP / A2A SDKs both emit JSON strings today; a future\n * SDK version switching to streams would silently break signing otherwise.\n */\nexport function extractAdcpOperation(body: unknown): string | undefined {\n const text = bodyToUtf8(body);\n if (!text) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n return undefined;\n }\n if (!parsed || typeof parsed !== 'object') return undefined;\n const rpc = parsed as { method?: unknown; params?: unknown };\n\n if (rpc.method === 'tools/call') {\n const params = rpc.params as { name?: unknown } | undefined;\n return typeof params?.name === 'string' ? params.name : undefined;\n }\n\n if (rpc.method === 'message/send' || rpc.method === 'message/stream') {\n const params = rpc.params as { message?: { parts?: unknown } } | undefined;\n const parts = params?.message?.parts;\n if (!Array.isArray(parts)) return undefined;\n for (const part of parts) {\n if (part && typeof part === 'object') {\n const p = part as { kind?: unknown; data?: { skill?: unknown } };\n if (p.kind === 'data' && typeof p.data?.skill === 'string') {\n return p.data.skill;\n }\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Detect webhook receiver credentials in the outbound JSON-RPC payload. The\n * verifier rejects unsigned requests carrying these credentials regardless of\n * the seller's operation-level capability advertisement, so the client must\n * sign them even while the capability cache is cold or silent for that op.\n * The scan is bounded; if the body exceeds the inspection budget, sign it.\n */\nfunction carriesWebhookAuthentication(body: unknown): boolean {\n const text = bodyToUtf8(body);\n if (!text) return false;\n if (text.length > MAX_WEBHOOK_AUTH_INSPECTION_BYTES) return true;\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n return false;\n }\n return containsWebhookAuthentication(parsed);\n}\n\n/**\n * Decide whether an outbound AdCP call should be signed given the seller's\n * advertised capability block and the buyer's override list.\n *\n * Precedence matches the AdCP spec (`required_for` > `warn_for` >\n * `supported_for`):\n * 1. `always_sign` on the buyer config — pilot-time override, signs even\n * if the seller hasn't listed the op.\n * 2. Seller `required_for` — seller rejects unsigned requests, MUST sign.\n * 3. Seller `warn_for` — shadow mode. Seller verifies when present and\n * logs failures without rejecting; counterparties SHOULD sign so the\n * seller can surface failure rates before flipping to `required_for`.\n * 4. Seller `supported_for` — sign only if the buyer opted in via\n * `sign_supported: true` (defaults off).\n *\n * Returns false when the capability is unknown (cold cache) except for ops\n * in `always_sign`.\n */\nexport function shouldSignOperation(\n operation: string | undefined,\n capability: VerifierCapability | undefined,\n config: AgentRequestSigningConfig\n): boolean {\n if (!operation) return false;\n if (config.always_sign?.includes(operation)) return true;\n if (!capability?.supported) return false;\n if (capability.required_for?.includes(operation)) return true;\n if (capability.warn_for?.includes(operation)) return true;\n if (config.sign_supported && capability.supported_for?.includes(operation)) return true;\n return false;\n}\n\n/**\n * Resolve the seller's content-digest policy into a concrete per-request\n * coverage decision.\n *\n * - `required` → must cover content-digest.\n * - `forbidden` → must NOT cover content-digest.\n * - `either` / absent → default to covering (body-binding is the safer\n * choice; the seller has explicitly allowed both forms).\n */\nexport function resolveCoverContentDigest(policy: ContentDigestPolicy | undefined): boolean {\n if (policy === 'forbidden') return false;\n return true;\n}\n\n/**\n * Convert an inline `AgentRequestSigningConfig` into the `SignerKey` shape\n * expected by `signRequest` / `createSigningFetch`. Provider-backed configs\n * have no in-process key material — callers must route through\n * `createSigningFetchAsync(upstream, config.provider, ...)` instead.\n */\nexport function toSignerKey(config: AgentRequestSigningConfigInline): SignerKey {\n return {\n keyid: config.kid,\n alg: config.alg,\n privateKey: config.private_key as SignerKey['privateKey'],\n };\n}\n\n/** Narrow predicate for the inline shape (kind absent or `'inline'`). */\nexport function isInlineSigningConfig(config: AgentRequestSigningConfig): config is AgentRequestSigningConfigInline {\n return config.kind !== 'provider';\n}\n\n/** Narrow predicate for the provider shape. */\nexport function isProviderSigningConfig(\n config: AgentRequestSigningConfig\n): config is AgentRequestSigningConfigProvider {\n return config.kind === 'provider';\n}\n\nexport interface BuildAgentSigningFetchOptions {\n /**\n * Upstream fetch to wrap. Defaults to `globalThis.fetch` when omitted —\n * use a Node 18+ / browser / worker global, or pass a polyfill / a\n * decorated fetch (retries, telemetry) to compose.\n */\n upstream?: FetchLike;\n signing: AgentRequestSigningConfig;\n /** Lazy accessor for the current cached capability — re-read on every call. */\n getCapability: () => CachedCapability | undefined;\n /** Trusted SDK/endpoint version pin; never inferred from the request body. */\n adcpVersion?: string;\n}\n\n/**\n * Build a fetch wrapper suitable for injection into MCP/A2A transports. On\n * every outbound request:\n * 1. Sign immediately when the payload carries webhook authentication.\n * 2. Extract the AdCP operation name from the JSON-RPC body (MCP tool-call\n * or A2A message/send). Non-AdCP JSON-RPC methods (e.g., `initialize`)\n * pass through unsigned.\n * 3. Consult the cached seller capability to decide whether to sign.\n * 4. Resolve the seller's content-digest policy into a per-request toggle.\n * 5. Delegate to `createSigningFetch` with the decision baked in.\n */\nexport function buildAgentSigningFetch(options: BuildAgentSigningFetchOptions): FetchLike {\n const { signing, getCapability } = options;\n // Resolve `globalThis.fetch` per-call when no explicit upstream was passed\n // so a polyfill installed between factory creation and first request still\n // takes effect. Eager resolution would freeze whatever was global at\n // factory-call time.\n const explicitUpstream = options.upstream;\n const upstream: FetchLike = explicitUpstream ?? ((input, init) => defaultUpstream()(input, init));\n\n const shouldSign = (_url: string, init: RequestInit | undefined): boolean => {\n if (carriesWebhookAuthentication(init?.body)) return true;\n const operation = extractAdcpOperation(init?.body);\n const entry = getCapability();\n return shouldSignOperation(operation, entry?.requestSigning, signing);\n };\n\n const binaryEncoding = requestSigningEncodingForVersion(options.adcpVersion ?? ADCP_VERSION);\n const coverContentDigest: CoverContentDigestPredicate = (_url, _init) => {\n if (binaryEncoding === 'rfc8941-base64') return true;\n const entry = getCapability();\n return resolveCoverContentDigest(entry?.requestSigning?.covers_content_digest);\n };\n\n if (isProviderSigningConfig(signing)) {\n // Freeze the provider's identity fields at factory time and pass a\n // snapshot view down to the async signer. TypeScript `readonly` on the\n // `SigningProvider` interface is compile-time only — if a downstream\n // adapter mutates `keyid`/`algorithm`/`fingerprint` between context\n // build and outbound request, the wire `keyid` would drift away from\n // the cache key the connection was bound to. The frozen view binds the\n // wire identity to the snapshot already used for cache routing.\n const frozen = freezeProviderIdentity(signing.provider);\n return createSigningFetchAsync(upstream, frozen, { shouldSign, coverContentDigest, binaryEncoding });\n }\n return createSigningFetch(upstream, toSignerKey(signing), { shouldSign, coverContentDigest, binaryEncoding });\n}\n\nfunction freezeProviderIdentity(provider: AgentRequestSigningConfigProvider['provider']) {\n const keyid = provider.keyid;\n const algorithm = provider.algorithm;\n const adcpUse = provider.adcpUse;\n const fingerprint = provider.fingerprint;\n return {\n keyid,\n algorithm,\n adcpUse,\n fingerprint,\n sign: (payload: Uint8Array) => provider.sign(payload),\n };\n}\n\nexport interface CreateAgentSignedFetchOptions {\n /** This agent's RFC 9421 signing identity (kid, alg, private_key, agent_url). */\n signing: AgentRequestSigningConfig;\n /** Trusted endpoint pin used to select the 3.0/3.1 or 3.2 request profile. */\n adcpVersion?: string;\n /**\n * Target seller's `agent_uri` — the base URL whose `get_adcp_capabilities`\n * response gates whether each operation gets signed. The preset keys a\n * capability-cache entry off this URL so repeat calls reuse the same\n * advertisement.\n *\n * For multi-seller buyers, build one signed fetch per seller (or use\n * {@link buildAgentSigningFetch} directly and supply your own\n * `getCapability` that dispatches on the target URL).\n */\n sellerAgentUri: string;\n /**\n * Optional auth token the seller expects alongside the signing headers.\n * Included in the capability cache key so a token rotation naturally\n * invalidates the cached advertisement.\n */\n sellerAuthToken?: string;\n /**\n * Capability cache. Defaults to the shared {@link defaultCapabilityCache}.\n *\n * **The shared default is load-bearing.** `ProtocolClient` and\n * `buildAgentSigningContext` write the seller's `get_adcp_capabilities`\n * response into `defaultCapabilityCache`; this preset reads from the same\n * instance so a single priming call serves every subsequent signing\n * decision. Passing a fresh `new CapabilityCache()` here without also\n * priming it will silently disable `required_for` enforcement: cold cache\n * → `shouldSignOperation` returns `false` → every required op ships\n * unsigned → seller rejects. The SDK emits no error on this path because\n * \"decided not to sign\" is the spec-correct behavior on a cold cache.\n *\n * Pass an explicit cache only when you've also primed it — call\n * {@link ensureCapabilityLoaded} against your cache instance after\n * construction, or seed it via `cache.set(buildCapabilityCacheKey(uri,\n * token, fingerprint, adcpVersion), entry)` — or when you genuinely want each caller to re-fetch\n * the seller's capability block.\n *\n * Note: the cache stores **public** seller capability advertisements\n * (the contents of `get_adcp_capabilities` responses), not buyer\n * credentials. The shared default is not a multi-tenant security\n * boundary — different sellers, different auth tokens, and different\n * signing keys already get separate entries via\n * {@link buildCapabilityCacheKey}.\n */\n cache?: CapabilityCache;\n /** Upstream fetch. Defaults to `globalThis.fetch`. */\n upstream?: FetchLike;\n}\n\n/**\n * One-call preset for the single-seller case: bundles\n * {@link buildAgentSigningFetch} with a {@link CapabilityCache} lookup keyed\n * by `sellerAgentUri`, so adapter authors don't have to wire the cache and\n * capability accessor themselves.\n *\n * ```ts\n * // fetch.ts\n * import { createAgentSignedFetch } from '@adcp/sdk/signing';\n *\n * export const signedFetch = createAgentSignedFetch({\n * signing: {\n * kid: 'my-agent-2026',\n * alg: 'ed25519',\n * private_key: JSON.parse(process.env.ADCP_PRIV_KEY!),\n * agent_url: 'https://agent.example.com',\n * },\n * sellerAgentUri: 'https://seller.example.com',\n * });\n * ```\n *\n * ```ts\n * // any other module\n * import { signedFetch } from './fetch';\n *\n * await signedFetch('https://seller.example.com/mcp', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify(payload),\n * });\n * ```\n *\n * Signing only happens on operations the seller advertises as\n * `required_for` / `warn_for` (or `supported_for` when the buyer config\n * opts in) — so the `get_adcp_capabilities` priming call itself is always\n * unsigned, as the spec requires.\n *\n * For multi-seller adapters, construct one preset per seller, or use\n * {@link buildAgentSigningFetch} directly with a request-dispatching\n * `getCapability` callback.\n */\nexport function createAgentSignedFetch(options: CreateAgentSignedFetchOptions): FetchLike {\n const cache = options.cache ?? defaultCapabilityCache;\n const adcpVersion = options.adcpVersion ?? ADCP_VERSION;\n const cacheKey = buildCapabilityCacheKey(options.sellerAgentUri, options.sellerAuthToken, undefined, adcpVersion);\n return buildAgentSigningFetch({\n signing: options.signing,\n upstream: options.upstream,\n getCapability: () => cache.get(cacheKey),\n adcpVersion,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAAqE;AACrE,yBAAwC;AACxC,8BAKO;AAGP,oCAA8C;AAC9C,qBAA6B;AAC7B,4BAAiD;AACjD,IAAAA,yBAAiD;AAGjD,MAAM,oCAAoC;AAU1C,SAAS,kBAA6B;AACpC,QAAM,IAAK,WAAqC;AAChD,MAAI,OAAO,MAAM,YAAY;AAC3B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,WAAW,MAAmC;AACrD,MAAI,SAAS,UAAa,SAAS,KAAM,QAAO;AAChD,MAAI,OAAO,SAAS,SAAU,QAAO,KAAK,SAAS,OAAO;AAC1D,MAAI,gBAAgB,WAAY,QAAO,OAAO,KAAK,IAAI,EAAE,SAAS,MAAM;AACxE,MAAI,gBAAgB,YAAa,QAAO,OAAO,KAAK,IAAI,EAAE,SAAS,MAAM;AAMzE,QAAM,IAAI;AAAA,IACR,oFAAoF,aAAa,IAAI,CAAC;AAAA,EACxG;AACF;AAEA,SAAS,aAAa,MAAuB;AAC3C,MAAI,QAAQ,OAAO,SAAS,UAAU;AACpC,UAAM,OAAQ,KAA6C,aAAa;AACxE,QAAI,KAAM,QAAO;AAAA,EACnB;AACA,SAAO,OAAO;AAChB;AAgBO,SAAS,qBAAqB,MAAmC;AACtE,QAAM,OAAO,WAAW,IAAI;AAC5B,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI;AACJ,MAAI;AACF,aAAS,KAAK,M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C7B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,CAAC,YAAwB,SAAS,KAAK,OAAO;AAAA,EACtD;AACF;AAgGO,SAAS,uBAAuB,SAAmD;AACxF,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,eAAW,iDAAwB,QAAQ,gBAAgB,QAAQ,iBAAiB,QAAW,WAAW;AAChH,SAAO,uBAAuB;AAAA,IAC5B,SAAS,QAAQ;AAAA,IACjB,UAAU,QAAQ;AAAA,IAClB,eAAe,MAAM,MAAM,IAAI,QAAQ;AAAA,IACvC;AAAA,EACF,CAAC;AACH;","names":["import_content_digest"]}
|
|
@@ -127,10 +127,12 @@ function buildAgentSigningFetch(options) {
|
|
|
127
127
|
function freezeProviderIdentity(provider) {
|
|
128
128
|
const keyid = provider.keyid;
|
|
129
129
|
const algorithm = provider.algorithm;
|
|
130
|
+
const adcpUse = provider.adcpUse;
|
|
130
131
|
const fingerprint = provider.fingerprint;
|
|
131
132
|
return {
|
|
132
133
|
keyid,
|
|
133
134
|
algorithm,
|
|
135
|
+
adcpUse,
|
|
134
136
|
fingerprint,
|
|
135
137
|
sign: (payload) => provider.sign(payload)
|
|
136
138
|
};
|