@adcp/sdk 15.9.1 → 16.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/bin/adcp-identity.js +74 -0
  2. package/bin/adcp.js +2 -0
  3. package/dist/lib/adapters/keyed-account-backend.d.mts +37 -0
  4. package/dist/lib/adapters/keyed-account-backend.d.ts +37 -0
  5. package/dist/lib/adapters/keyed-account-backend.js +121 -0
  6. package/dist/lib/adapters/keyed-account-backend.mjs +94 -0
  7. package/dist/lib/adapters/keyed-account-store.d.mts +28 -0
  8. package/dist/lib/adapters/keyed-account-store.d.ts +28 -0
  9. package/dist/lib/adapters/keyed-account-store.js +227 -0
  10. package/dist/lib/adapters/keyed-account-store.mjs +203 -0
  11. package/dist/lib/core/SingleAgentClient.d.mts +25 -2
  12. package/dist/lib/core/SingleAgentClient.d.ts +25 -2
  13. package/dist/lib/core/SingleAgentClient.js +280 -62
  14. package/dist/lib/core/SingleAgentClient.mjs +282 -57
  15. package/dist/lib/core/TaskExecutor.d.mts +6 -0
  16. package/dist/lib/core/TaskExecutor.d.ts +6 -0
  17. package/dist/lib/core/TaskExecutor.js +66 -5
  18. package/dist/lib/core/TaskExecutor.mjs +71 -5
  19. package/dist/lib/core/postgres-webhook-registration-store.js +32 -5
  20. package/dist/lib/core/postgres-webhook-registration-store.mjs +32 -5
  21. package/dist/lib/core/redis-webhook-registration-store.js +23 -1
  22. package/dist/lib/core/redis-webhook-registration-store.mjs +23 -1
  23. package/dist/lib/core/webhook-registration.d.mts +7 -1
  24. package/dist/lib/core/webhook-registration.d.ts +7 -1
  25. package/dist/lib/core/webhook-registration.js +24 -2
  26. package/dist/lib/core/webhook-registration.mjs +23 -2
  27. package/dist/lib/identity-3.3/generated-compat.d.mts +34 -0
  28. package/dist/lib/identity-3.3/generated-compat.d.ts +34 -0
  29. package/dist/lib/identity-3.3/generated-compat.js +16 -0
  30. package/dist/lib/identity-3.3/generated-compat.mjs +0 -0
  31. package/dist/lib/identity-3.3/index.d.mts +10 -0
  32. package/dist/lib/identity-3.3/index.d.ts +10 -0
  33. package/dist/lib/identity-3.3/index.js +79 -0
  34. package/dist/lib/identity-3.3/index.mjs +50 -0
  35. package/dist/lib/identity-3.3/lifecycle.d.mts +125 -0
  36. package/dist/lib/identity-3.3/lifecycle.d.ts +125 -0
  37. package/dist/lib/identity-3.3/lifecycle.js +294 -0
  38. package/dist/lib/identity-3.3/lifecycle.mjs +272 -0
  39. package/dist/lib/identity-3.3/revocation.d.mts +86 -0
  40. package/dist/lib/identity-3.3/revocation.d.ts +86 -0
  41. package/dist/lib/identity-3.3/revocation.js +308 -0
  42. package/dist/lib/identity-3.3/revocation.mjs +286 -0
  43. package/dist/lib/identity-3.3/schemas.draft.d.mts +2472 -0
  44. package/dist/lib/identity-3.3/schemas.draft.d.ts +2472 -0
  45. package/dist/lib/identity-3.3/schemas.draft.js +1448 -0
  46. package/dist/lib/identity-3.3/schemas.draft.mjs +1428 -0
  47. package/dist/lib/identity-3.3/server.d.mts +46 -0
  48. package/dist/lib/identity-3.3/server.d.ts +46 -0
  49. package/dist/lib/identity-3.3/server.js +279 -0
  50. package/dist/lib/identity-3.3/server.mjs +260 -0
  51. package/dist/lib/identity-3.3/store.d.mts +24 -0
  52. package/dist/lib/identity-3.3/store.d.ts +24 -0
  53. package/dist/lib/identity-3.3/store.js +191 -0
  54. package/dist/lib/identity-3.3/store.mjs +169 -0
  55. package/dist/lib/identity-3.3/trust.d.mts +155 -0
  56. package/dist/lib/identity-3.3/trust.d.ts +155 -0
  57. package/dist/lib/identity-3.3/trust.js +383 -0
  58. package/dist/lib/identity-3.3/trust.mjs +342 -0
  59. package/dist/lib/identity-3.3/types.d.mts +155 -0
  60. package/dist/lib/identity-3.3/types.d.ts +155 -0
  61. package/dist/lib/identity-3.3/types.js +16 -0
  62. package/dist/lib/identity-3.3/types.mjs +0 -0
  63. package/dist/lib/identity-3.3/validation.d.mts +2 -0
  64. package/dist/lib/identity-3.3/validation.d.ts +2 -0
  65. package/dist/lib/identity-3.3/validation.js +125 -0
  66. package/dist/lib/identity-3.3/validation.mjs +91 -0
  67. package/dist/lib/index.d.mts +1 -1
  68. package/dist/lib/index.d.ts +1 -1
  69. package/dist/lib/index.js +2 -0
  70. package/dist/lib/index.mjs +2 -0
  71. package/dist/lib/protocols/index.d.mts +1 -1
  72. package/dist/lib/protocols/index.d.ts +1 -1
  73. package/dist/lib/protocols/index.js +2 -2
  74. package/dist/lib/protocols/index.mjs +2 -2
  75. package/dist/lib/reporting/azure/index.d.mts +5 -0
  76. package/dist/lib/reporting/azure/index.d.ts +5 -0
  77. package/dist/lib/reporting/azure/index.js +26 -7
  78. package/dist/lib/reporting/azure/index.mjs +26 -7
  79. package/dist/lib/reporting/bigquery/index.d.mts +39 -5
  80. package/dist/lib/reporting/bigquery/index.d.ts +39 -5
  81. package/dist/lib/reporting/bigquery/index.js +26 -20
  82. package/dist/lib/reporting/bigquery/index.mjs +26 -20
  83. package/dist/lib/reporting/gcs/adapter.d.mts +8 -1
  84. package/dist/lib/reporting/gcs/adapter.d.ts +8 -1
  85. package/dist/lib/reporting/gcs/errors.d.mts +6 -0
  86. package/dist/lib/reporting/gcs/errors.d.ts +6 -0
  87. package/dist/lib/reporting/gcs/fence.d.mts +5 -0
  88. package/dist/lib/reporting/gcs/fence.d.ts +5 -0
  89. package/dist/lib/reporting/gcs/index.d.mts +9 -0
  90. package/dist/lib/reporting/gcs/index.d.ts +9 -0
  91. package/dist/lib/reporting/gcs/reader.d.mts +27 -3
  92. package/dist/lib/reporting/gcs/reader.d.ts +27 -3
  93. package/dist/lib/reporting/gcs/row-provider.d.mts +7 -0
  94. package/dist/lib/reporting/gcs/row-provider.d.ts +7 -0
  95. package/dist/lib/reporting/gcs/row-provider.js +34 -14
  96. package/dist/lib/reporting/gcs/row-provider.mjs +34 -14
  97. package/dist/lib/reporting/ledger/change-feed.d.mts +22 -1
  98. package/dist/lib/reporting/ledger/change-feed.d.ts +22 -1
  99. package/dist/lib/reporting/ledger/index.d.mts +11 -0
  100. package/dist/lib/reporting/ledger/index.d.ts +11 -0
  101. package/dist/lib/reporting/ledger/managed-postgres.d.mts +8 -0
  102. package/dist/lib/reporting/ledger/managed-postgres.d.ts +8 -0
  103. package/dist/lib/reporting/ledger/managed-router.d.mts +27 -2
  104. package/dist/lib/reporting/ledger/managed-router.d.ts +27 -2
  105. package/dist/lib/reporting/ledger/managed.d.mts +86 -6
  106. package/dist/lib/reporting/ledger/managed.d.ts +86 -6
  107. package/dist/lib/reporting/ledger/notification-activity.d.mts +65 -3
  108. package/dist/lib/reporting/ledger/notification-activity.d.ts +65 -3
  109. package/dist/lib/reporting/ledger/object-writes.d.mts +64 -5
  110. package/dist/lib/reporting/ledger/object-writes.d.ts +64 -5
  111. package/dist/lib/reporting/ledger/postgres.d.mts +43 -9
  112. package/dist/lib/reporting/ledger/postgres.d.ts +43 -9
  113. package/dist/lib/reporting/ledger/postgres.js +43 -27
  114. package/dist/lib/reporting/ledger/postgres.mjs +43 -27
  115. package/dist/lib/reporting/ledger/row-encoding.d.mts +92 -6
  116. package/dist/lib/reporting/ledger/row-encoding.d.ts +92 -6
  117. package/dist/lib/reporting/ledger/row-encoding.js +8 -4
  118. package/dist/lib/reporting/ledger/row-encoding.mjs +6 -3
  119. package/dist/lib/reporting/ledger/row-storage-errors.d.mts +11 -1
  120. package/dist/lib/reporting/ledger/row-storage-errors.d.ts +11 -1
  121. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +19 -1
  122. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +19 -1
  123. package/dist/lib/reporting/ledger/row-storage-migration.js +133 -18
  124. package/dist/lib/reporting/ledger/row-storage-migration.mjs +133 -18
  125. package/dist/lib/reporting/ledger/row-storage-object.d.mts +103 -12
  126. package/dist/lib/reporting/ledger/row-storage-object.d.ts +103 -12
  127. package/dist/lib/reporting/ledger/row-storage-object.js +106 -31
  128. package/dist/lib/reporting/ledger/row-storage-object.mjs +104 -31
  129. package/dist/lib/reporting/ledger/row-storage.d.mts +87 -20
  130. package/dist/lib/reporting/ledger/row-storage.d.ts +87 -20
  131. package/dist/lib/reporting/ledger/row-storage.js +126 -66
  132. package/dist/lib/reporting/ledger/row-storage.mjs +129 -67
  133. package/dist/lib/reporting/ledger/schedule.d.mts +13 -0
  134. package/dist/lib/reporting/ledger/schedule.d.ts +13 -0
  135. package/dist/lib/reporting/ledger/schedule.js +24 -0
  136. package/dist/lib/reporting/ledger/schedule.mjs +23 -0
  137. package/dist/lib/reporting/ledger/types.d.mts +23 -1
  138. package/dist/lib/reporting/ledger/types.d.ts +23 -1
  139. package/dist/lib/reporting/s3/index.d.mts +5 -0
  140. package/dist/lib/reporting/s3/index.d.ts +5 -0
  141. package/dist/lib/reporting/s3/index.js +37 -14
  142. package/dist/lib/reporting/s3/index.mjs +37 -14
  143. package/dist/lib/reporting/service/index.d.mts +10 -0
  144. package/dist/lib/reporting/service/index.d.ts +10 -0
  145. package/dist/lib/reporting/service/maintenance.d.mts +28 -2
  146. package/dist/lib/reporting/service/maintenance.d.ts +28 -2
  147. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  148. package/dist/lib/server/account-sync-contract.d.mts +14 -0
  149. package/dist/lib/server/account-sync-contract.d.ts +14 -0
  150. package/dist/lib/server/account-sync-contract.js +225 -0
  151. package/dist/lib/server/account-sync-contract.mjs +197 -0
  152. package/dist/lib/server/adcp-server.js +5 -0
  153. package/dist/lib/server/adcp-server.mjs +10 -0
  154. package/dist/lib/server/auth-signature.d.mts +15 -0
  155. package/dist/lib/server/auth-signature.d.ts +15 -0
  156. package/dist/lib/server/auth-signature.js +72 -2
  157. package/dist/lib/server/auth-signature.mjs +81 -2
  158. package/dist/lib/server/auth.d.mts +6 -0
  159. package/dist/lib/server/auth.d.ts +6 -0
  160. package/dist/lib/server/auth.js +6 -0
  161. package/dist/lib/server/auth.mjs +6 -0
  162. package/dist/lib/server/create-adcp-server.d.mts +19 -5
  163. package/dist/lib/server/create-adcp-server.d.ts +19 -5
  164. package/dist/lib/server/create-adcp-server.js +259 -19
  165. package/dist/lib/server/create-adcp-server.mjs +266 -10
  166. package/dist/lib/server/decisioning/account.d.mts +24 -1
  167. package/dist/lib/server/decisioning/account.d.ts +24 -1
  168. package/dist/lib/server/decisioning/index.d.mts +1 -1
  169. package/dist/lib/server/decisioning/index.d.ts +1 -1
  170. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +0 -50
  171. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +0 -50
  172. package/dist/lib/server/decisioning/runtime/from-platform.js +61 -11
  173. package/dist/lib/server/decisioning/runtime/from-platform.mjs +65 -12
  174. package/dist/lib/server/index.d.mts +2 -0
  175. package/dist/lib/server/index.d.ts +2 -0
  176. package/dist/lib/server/index.js +12 -0
  177. package/dist/lib/server/index.mjs +12 -0
  178. package/dist/lib/server/notification-subscriptions/runtime.js +9 -1
  179. package/dist/lib/server/notification-subscriptions/runtime.mjs +9 -1
  180. package/dist/lib/server/notification-subscriptions/types.d.mts +5 -0
  181. package/dist/lib/server/notification-subscriptions/types.d.ts +5 -0
  182. package/dist/lib/server/principal/types.d.mts +1 -1
  183. package/dist/lib/server/principal/types.d.ts +1 -1
  184. package/dist/lib/server/serve.js +5 -0
  185. package/dist/lib/server/serve.mjs +5 -0
  186. package/dist/lib/server/webhook-delivery/recovery.d.mts +1 -0
  187. package/dist/lib/server/webhook-delivery/recovery.d.ts +1 -0
  188. package/dist/lib/server/webhook-delivery/recovery.js +4 -0
  189. package/dist/lib/server/webhook-delivery/recovery.mjs +4 -0
  190. package/dist/lib/server/webhook-emitter.d.mts +10 -0
  191. package/dist/lib/server/webhook-emitter.d.ts +10 -0
  192. package/dist/lib/server/webhook-emitter.js +22 -0
  193. package/dist/lib/server/webhook-emitter.mjs +22 -0
  194. package/dist/lib/signing/agent-context.d.mts +0 -5
  195. package/dist/lib/signing/agent-context.d.ts +0 -5
  196. package/dist/lib/signing/agent-context.js +9 -1
  197. package/dist/lib/signing/agent-context.mjs +9 -1
  198. package/dist/lib/signing/agent-fetch.js +27 -2
  199. package/dist/lib/signing/agent-fetch.mjs +32 -2
  200. package/dist/lib/signing/agent-resolver/canonicalize.d.mts +10 -15
  201. package/dist/lib/signing/agent-resolver/canonicalize.d.ts +10 -15
  202. package/dist/lib/signing/agent-resolver/canonicalize.js +17 -5
  203. package/dist/lib/signing/agent-resolver/canonicalize.mjs +16 -5
  204. package/dist/lib/signing/agent-resolver/index.d.mts +1 -0
  205. package/dist/lib/signing/agent-resolver/index.d.ts +1 -0
  206. package/dist/lib/signing/agent-resolver/index.js +5 -0
  207. package/dist/lib/signing/agent-resolver/index.mjs +3 -0
  208. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +3 -2
  209. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +3 -2
  210. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +30 -3
  211. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +30 -3
  212. package/dist/lib/signing/agent-resolver/strict-json.d.mts +2 -2
  213. package/dist/lib/signing/agent-resolver/strict-json.d.ts +2 -2
  214. package/dist/lib/signing/agent-resolver/strict-json.js +5 -3
  215. package/dist/lib/signing/agent-resolver/strict-json.mjs +5 -3
  216. package/dist/lib/signing/brand-jwks.d.mts +2 -2
  217. package/dist/lib/signing/brand-jwks.d.ts +2 -2
  218. package/dist/lib/signing/brand-jwks.js +4 -4
  219. package/dist/lib/signing/brand-jwks.mjs +4 -4
  220. package/dist/lib/signing/client.d.mts +1 -0
  221. package/dist/lib/signing/client.d.ts +1 -0
  222. package/dist/lib/signing/client.js +5 -0
  223. package/dist/lib/signing/client.mjs +3 -0
  224. package/dist/lib/signing/crypto.js +8 -0
  225. package/dist/lib/signing/crypto.mjs +9 -1
  226. package/dist/lib/signing/fetch-async.js +1 -1
  227. package/dist/lib/signing/fetch-async.mjs +1 -1
  228. package/dist/lib/signing/fetch.js +1 -1
  229. package/dist/lib/signing/fetch.mjs +1 -1
  230. package/dist/lib/signing/jwks-https.d.mts +1 -1
  231. package/dist/lib/signing/jwks-https.d.ts +1 -1
  232. package/dist/lib/signing/jwks-https.js +1 -1
  233. package/dist/lib/signing/jwks-https.mjs +1 -1
  234. package/dist/lib/signing/jwks.d.mts +11 -3
  235. package/dist/lib/signing/jwks.d.ts +11 -3
  236. package/dist/lib/signing/jwks.js +1 -1
  237. package/dist/lib/signing/jwks.mjs +1 -1
  238. package/dist/lib/signing/middleware.js +9 -0
  239. package/dist/lib/signing/middleware.mjs +14 -0
  240. package/dist/lib/signing/parser.d.mts +9 -6
  241. package/dist/lib/signing/parser.d.ts +9 -6
  242. package/dist/lib/signing/parser.js +82 -64
  243. package/dist/lib/signing/parser.mjs +83 -65
  244. package/dist/lib/signing/revocation.d.mts +4 -1
  245. package/dist/lib/signing/revocation.d.ts +4 -1
  246. package/dist/lib/signing/revocation.js +36 -3
  247. package/dist/lib/signing/revocation.mjs +34 -2
  248. package/dist/lib/signing/server.d.mts +1 -1
  249. package/dist/lib/signing/server.d.ts +1 -1
  250. package/dist/lib/signing/server.js +4 -0
  251. package/dist/lib/signing/server.mjs +4 -0
  252. package/dist/lib/signing/types.d.mts +3 -0
  253. package/dist/lib/signing/types.d.ts +3 -0
  254. package/dist/lib/signing/verifier.js +1 -1
  255. package/dist/lib/signing/verifier.mjs +1 -1
  256. package/dist/lib/signing/web-bot-auth.d.mts +191 -0
  257. package/dist/lib/signing/web-bot-auth.d.ts +191 -0
  258. package/dist/lib/signing/web-bot-auth.js +837 -0
  259. package/dist/lib/signing/web-bot-auth.mjs +796 -0
  260. package/dist/lib/signing/webhook-verifier.js +1 -1
  261. package/dist/lib/signing/webhook-verifier.mjs +1 -1
  262. package/dist/lib/testing/client.d.mts +1 -4
  263. package/dist/lib/testing/client.d.ts +1 -4
  264. package/dist/lib/testing/client.js +141 -20
  265. package/dist/lib/testing/client.mjs +137 -19
  266. package/dist/lib/testing/compliance/comply.js +29 -10
  267. package/dist/lib/testing/compliance/comply.mjs +37 -11
  268. package/dist/lib/testing/storyboard/account-sync-contract.d.mts +3 -0
  269. package/dist/lib/testing/storyboard/account-sync-contract.d.ts +3 -0
  270. package/dist/lib/testing/storyboard/account-sync-contract.js +79 -0
  271. package/dist/lib/testing/storyboard/account-sync-contract.mjs +55 -0
  272. package/dist/lib/testing/storyboard/default-invariants.js +2 -0
  273. package/dist/lib/testing/storyboard/default-invariants.mjs +2 -0
  274. package/dist/lib/testing/storyboard/runner.js +23 -8
  275. package/dist/lib/testing/storyboard/runner.mjs +24 -8
  276. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  277. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  278. package/dist/lib/types/adcp.d.mts +4 -0
  279. package/dist/lib/types/adcp.d.ts +4 -0
  280. package/dist/lib/types/schemas.generated.d.ts +6 -6
  281. package/dist/lib/utils/capabilities.d.mts +1 -0
  282. package/dist/lib/utils/capabilities.d.ts +1 -0
  283. package/dist/lib/utils/capabilities.js +5 -0
  284. package/dist/lib/utils/capabilities.mjs +5 -0
  285. package/dist/lib/v2/projection/catalog-snapshot.js +3 -1
  286. package/dist/lib/v2/projection/catalog-snapshot.mjs +3 -1
  287. package/dist/lib/v2/projection/creative-delivery.d.mts +34 -10
  288. package/dist/lib/v2/projection/creative-delivery.d.ts +34 -10
  289. package/dist/lib/v2/projection/creative-delivery.js +26 -10
  290. package/dist/lib/v2/projection/creative-delivery.mjs +26 -10
  291. package/dist/lib/v2/projection/index.d.mts +1 -1
  292. package/dist/lib/v2/projection/index.d.ts +1 -1
  293. package/dist/lib/v2/projection/index.js +2 -0
  294. package/dist/lib/v2/projection/index.mjs +2 -0
  295. package/dist/lib/v2/projection/legacy-routes.d.mts +34 -2
  296. package/dist/lib/v2/projection/legacy-routes.d.ts +34 -2
  297. package/dist/lib/v2/projection/legacy-routes.js +35 -2
  298. package/dist/lib/v2/projection/legacy-routes.mjs +32 -2
  299. package/dist/lib/validation/schema-loader.d.mts +2 -0
  300. package/dist/lib/validation/schema-loader.d.ts +2 -0
  301. package/dist/lib/validation/schema-loader.js +43 -4
  302. package/dist/lib/validation/schema-loader.mjs +39 -3
  303. package/dist/lib/version.d.mts +3 -3
  304. package/dist/lib/version.d.ts +3 -3
  305. package/dist/lib/version.js +3 -3
  306. package/dist/lib/version.mjs +3 -3
  307. package/docs/TYPE-SUMMARY.md +2 -2
  308. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +4 -0
  309. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +1 -1
  310. package/docs/guides/REPORTING-LEDGER.md +99 -29
  311. package/docs/guides/REPORTING-OPERATIONS.md +29 -13
  312. package/docs/guides/REPORTING-STABILITY.md +76 -0
  313. package/docs/guides/account-resolution.md +101 -0
  314. package/docs/llms.txt +3 -2
  315. package/docs/migration-12-to-13.md +15 -0
  316. package/docs/migration-14.x-rc-worksheet.md +4 -4
  317. package/docs/migration-agent-identity-3.3.md +494 -0
  318. package/docs/migration-agent-resolution-3.3.md +5 -0
  319. package/docs/migration-reporting-row-storage-alignment.md +137 -0
  320. package/examples/storyboards/account-sync-contract.yaml +57 -0
  321. package/package.json +17 -1
@@ -34,6 +34,8 @@ __export(SingleAgentClient_exports, {
34
34
  createSingleAgentClient: () => createSingleAgentClient
35
35
  });
36
36
  module.exports = __toCommonJS(SingleAgentClient_exports);
37
+ var import_schema_loader = require('../validation/schema-loader.js');
38
+ var import_canonicalize = require('../signing/agent-resolver/canonicalize.js');
37
39
  var import_products = require('../supply-path/products.js');
38
40
  var import_node_crypto = require("node:crypto");
39
41
  var import_adcp = require('../types/adcp.js');
@@ -41,7 +43,7 @@ var import_version = require('../version.js');
41
43
  var import_adcp_version_config = require('../utils/adcp-version-config.js');
42
44
  var import_reporting_version = require('../media-buy/reporting-version.js');
43
45
  var import_version2 = require('../adapters/version/index.js');
44
- var import_schema_loader = require('../validation/schema-loader.js');
46
+ var import_schema_loader2 = require('../validation/schema-loader.js');
45
47
  var import_idempotency = require('../utils/idempotency.js');
46
48
  var import_a2a = require('../protocols/a2a.js');
47
49
  var import_TaskExecutor = require('./TaskExecutor.js');
@@ -88,6 +90,9 @@ var import_augment_response = require('../v2/projection/augment-response.js');
88
90
  var import_legacy_metadata = require('../v2/projection/legacy-metadata.js');
89
91
  var import_types = require('../v2/projection/types.js');
90
92
  var import_jcs = require('../utils/jcs.js');
93
+ function loadWebBotAuth() {
94
+ return require('../signing/web-bot-auth.js');
95
+ }
91
96
  const SKIP_PRODUCT_CACHE = /* @__PURE__ */ Symbol("adcp.skipProductCache");
92
97
  const SKIP_ACCOUNT_REGISTRY_OBSERVATION = /* @__PURE__ */ Symbol("adcp.skipAccountRegistryObservation");
93
98
  function presentedStaticTransportCredential(authToken, headers, authProvider) {
@@ -742,6 +747,11 @@ class SingleAgentClient {
742
747
  constructor(agent, config = {}) {
743
748
  this.agent = agent;
744
749
  this.config = config;
750
+ if (config.experimentalIdentity33 === true !== (0, import_schema_loader.isIdentity33SchemaScope)())
751
+ return (0, import_schema_loader.withIdentity33SchemaScope)(() => {
752
+ const instance = Reflect.construct(SingleAgentClient, [agent, config], new.target);
753
+ return config.experimentalIdentity33 ? (0, import_schema_loader.bindIdentity33SchemaScope)(instance) : instance;
754
+ }, config.experimentalIdentity33 === true);
745
755
  const configuredTransport = config.transport === void 0 ? void 0 : { ...config.transport };
746
756
  const configuredWebhookVerification = config.webhookVerification === void 0 ? void 0 : {
747
757
  ...config.webhookVerification,
@@ -756,7 +766,9 @@ class SingleAgentClient {
756
766
  };
757
767
  config = this.config;
758
768
  (0, import_agent_discovery_cache.validateAgentDiscoveryCacheConfig)(config.discoveryCache);
759
- this.resolvedAdcpVersion = (0, import_adcp_version_config.resolveAdcpVersion)(config.adcpVersion);
769
+ this.resolvedAdcpVersion = (0, import_adcp_version_config.resolveAdcpVersion)(
770
+ config.adcpVersion ?? (config.experimentalIdentity33 ? "3.3" : void 0)
771
+ );
760
772
  this.webhookRegistrationStore = config.webhookRegistrationStore ?? new import_webhook_registration.InMemoryWebhookRegistrationStore();
761
773
  this.webhookReplayStore = config.webhookVerification?.replayStore ?? new import_server.InMemoryReplayStore();
762
774
  this.webhookRevocationStore = config.webhookVerification?.revocationStore ?? new import_server.InMemoryRevocationStore();
@@ -815,6 +827,10 @@ class SingleAgentClient {
815
827
  webhookUrlTemplate: config.webhookUrlTemplate,
816
828
  agentId: agent.id,
817
829
  webhookSecret: config.webhookSecret,
830
+ identity33SchemaExperiment: config.experimentalIdentity33,
831
+ experimentalIdentity33: () => this.config.experimentalIdentity33 === true && this.usesIdentity33Schemas(),
832
+ signedIdentity33Webhooks: () => this.usesSigned33Webhooks(),
833
+ webhookSigningProfile: () => this.selectedWebhookSigningProfile(),
818
834
  onWebhookRegistration: (registration) => this.persistWebhookRegistration(registration),
819
835
  onDurableSettlementRequired: (operationId) => this.markWebhookDurableSettlementRequired(operationId),
820
836
  externalTaskSettlementRetentionMs: registrationTtl * 1e3,
@@ -1050,7 +1066,7 @@ class SingleAgentClient {
1050
1066
  throw new import_errors3.AccountNotProvisionedError(ref, task);
1051
1067
  }
1052
1068
  const caps = await this.getCapabilities(options);
1053
- if (caps._synthetic || ["get_products", "list_products"].includes(task) && caps.account?.requiredForProducts || params.push_notification_config || !(0, import_schema_loader.schemaAllowsTopLevelField)(task, "brand")) {
1069
+ if (caps._synthetic || ["get_products", "list_products"].includes(task) && caps.account?.requiredForProducts || params.push_notification_config || !(0, import_schema_loader2.schemaAllowsTopLevelField)(task, "brand")) {
1054
1070
  throw new import_errors3.AccountNotProvisionedError(ref, task);
1055
1071
  }
1056
1072
  if (!("brand" in ref)) throw new import_errors3.AccountNotProvisionedError(ref, task);
@@ -1070,6 +1086,7 @@ class SingleAgentClient {
1070
1086
  // Cache canonical base URL (from agent card or stripped /mcp)
1071
1087
  cachedCapabilities;
1072
1088
  // Cache detected server capabilities
1089
+ runAgentInfo;
1073
1090
  cachedToolSchemas;
1074
1091
  // inputSchema.properties per tool name
1075
1092
  primedCapabilitiesExpiresAt;
@@ -1126,18 +1143,18 @@ class SingleAgentClient {
1126
1143
  persistedAgentUrl.username = "";
1127
1144
  persistedAgentUrl.password = "";
1128
1145
  persistedAgentUrl.hash = "";
1129
- const delegatedOperatorAuthorization = this.effectiveDelegatedOperatorAuthorization(
1130
- args.delegatedOperatorAuthorization
1131
- );
1146
+ const delegatedOperatorAuthorization = args.deliveryKind ? void 0 : this.effectiveDelegatedOperatorAuthorization(args.delegatedOperatorAuthorization);
1132
1147
  const registration = {
1133
1148
  agentId: args.agent.id,
1134
1149
  agentUrl: persistedAgentUrl.toString(),
1135
1150
  protocol: args.agent.protocol,
1136
1151
  operationId: args.operationId,
1137
1152
  taskType: args.taskType,
1138
- callbackUrl: args.callbackUrl,
1153
+ callbackUrl: args.deliveryKind ? (0, import_server.canonicalTargetUri)(args.callbackUrl, "3.2") : args.callbackUrl,
1139
1154
  method: "POST",
1140
1155
  mode: args.mode,
1156
+ ...args.signingProfile && { signingProfile: args.signingProfile },
1157
+ ...args.deliveryKind && { deliveryKind: args.deliveryKind },
1141
1158
  authorizationContextVersion: 1,
1142
1159
  ...delegatedOperatorAuthorization !== void 0 && { delegatedOperatorAuthorization },
1143
1160
  ...previewMode && { previewMode },
@@ -1146,6 +1163,14 @@ class SingleAgentClient {
1146
1163
  };
1147
1164
  (0, import_webhook_registration.validateWebhookRegistrationAuthorization)(registration);
1148
1165
  try {
1166
+ if (args.deliveryKind) {
1167
+ const previous = await this.webhookRegistrationStore.get(args.agent.id, args.operationId);
1168
+ if (previous && previous.expiresAt > nowMs && (previous.signingProfile ?? "adcp/webhook-signing/v1") !== (registration.signingProfile ?? "adcp/webhook-signing/v1"))
1169
+ throw new import_errors.ConfigurationError(
1170
+ `${args.deliveryKind} callback is already registered with ${previous.signingProfile ?? "adcp/webhook-signing/v1"}. Use a new callback URL or delete its old registration after outstanding deliveries finish.`,
1171
+ `${args.deliveryKind}_webhook.signing_profile`
1172
+ );
1173
+ }
1149
1174
  await this.webhookRegistrationStore.putIfAbsent(registration);
1150
1175
  const persisted = await this.webhookRegistrationStore.get(args.agent.id, args.operationId);
1151
1176
  if (!persisted || !(0, import_webhook_registration.sameWebhookRegistration)(
@@ -1157,6 +1182,8 @@ class SingleAgentClient {
1157
1182
  );
1158
1183
  }
1159
1184
  } catch (cause) {
1185
+ if (args.deliveryKind && cause instanceof import_errors.ConfigurationError && cause.configField === `${args.deliveryKind}_webhook.signing_profile`)
1186
+ throw cause;
1160
1187
  if (args.mode === "rfc9421" || !RECORDLESS_HMAC_READ_ONLY_TASKS.has(args.taskType)) {
1161
1188
  const error = new import_errors.ConfigurationError("Could not persist trusted webhook registration for this operation.");
1162
1189
  Object.defineProperty(error, "cause", { value: cause, configurable: true });
@@ -1318,7 +1345,7 @@ class SingleAgentClient {
1318
1345
  return (0, import_jcs.canonicalize)([this.canonicalAccountScope(account), "package", packageId]);
1319
1346
  }
1320
1347
  sameCanonicalOptionRef(left, right) {
1321
- return left.scope === right.scope && left.format_option_id === right.format_option_id && (left.scope !== "publisher" || right.scope === "publisher" && left.publisher_domain.toLowerCase() === right.publisher_domain.toLowerCase());
1348
+ return (0, import_legacy_routes.sameFormatOptionRef)(left, right);
1322
1349
  }
1323
1350
  rememberCanonicalLegacyRoute(key, route) {
1324
1351
  this.canonicalLegacyRoutes.delete(key);
@@ -1389,20 +1416,7 @@ class SingleAgentClient {
1389
1416
  if (!value || typeof value !== "object" || Array.isArray(value)) continue;
1390
1417
  const product = value;
1391
1418
  if (typeof product.product_id !== "string") continue;
1392
- const refs = [];
1393
- for (const optionValue of Array.isArray(product.format_options) ? product.format_options : []) {
1394
- if (!optionValue || typeof optionValue !== "object" || Array.isArray(optionValue)) continue;
1395
- const option = optionValue;
1396
- if (typeof option.format_option_id !== "string") continue;
1397
- refs.push(
1398
- typeof option.publisher_domain === "string" ? {
1399
- scope: "publisher",
1400
- publisher_domain: option.publisher_domain,
1401
- format_option_id: option.format_option_id
1402
- } : { scope: "product", format_option_id: option.format_option_id }
1403
- );
1404
- }
1405
- declared.set(product.product_id, refs);
1419
+ declared.set(product.product_id, (0, import_legacy_routes.sellerDeclaredFormatOptionRefs)(product));
1406
1420
  }
1407
1421
  return declared;
1408
1422
  }
@@ -1822,9 +1836,10 @@ class SingleAgentClient {
1822
1836
  */
1823
1837
  async ensureEndpointDiscovered(options) {
1824
1838
  (0, import_abort2.throwIfAborted)(options?.signal);
1839
+ if (this.config._reuseConfiguredDiscovery?.()) this.synchronizeCapabilityEvidenceAuthorizationScope();
1825
1840
  const needsDiscovery = this.normalizedAgent._needsDiscovery;
1826
1841
  const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
1827
- const usesScopedFetch = transport?.trustedFetchFn !== void 0;
1842
+ const usesScopedFetch = this.usesScopedDiscoveryTransport(options);
1828
1843
  if (!needsDiscovery) {
1829
1844
  return this.normalizedAgent;
1830
1845
  }
@@ -1930,7 +1945,7 @@ class SingleAgentClient {
1930
1945
  (0, import_abort2.throwIfAborted)(options?.signal);
1931
1946
  const needsCanonicalUrl = this.normalizedAgent._needsCanonicalUrl;
1932
1947
  const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
1933
- const usesScopedFetch = transport?.trustedFetchFn !== void 0;
1948
+ const usesScopedFetch = this.usesScopedDiscoveryTransport(options);
1934
1949
  if (!needsCanonicalUrl) {
1935
1950
  return this.normalizedAgent;
1936
1951
  }
@@ -1949,8 +1964,11 @@ class SingleAgentClient {
1949
1964
  signal: options?.signal
1950
1965
  });
1951
1966
  }
1967
+ const canonicalEpoch = this.discoveryEpochSnapshot(options);
1952
1968
  const canonicalUrl = await this.fetchA2ACanonicalUrl(this.normalizedAgent.agent_uri, options);
1953
- if (!usesScopedFetch) this.canonicalBaseUrl = canonicalUrl;
1969
+ if (!usesScopedFetch && (!canonicalEpoch || this.discoveryEpochIs(canonicalEpoch))) {
1970
+ this.canonicalBaseUrl = canonicalUrl;
1971
+ }
1954
1972
  return {
1955
1973
  ...this.normalizedAgent,
1956
1974
  agent_uri: canonicalUrl
@@ -2075,7 +2093,9 @@ class SingleAgentClient {
2075
2093
  const { connectMCPWithFallback } = await import("../protocols/mcp.js");
2076
2094
  const { probeModernMCPConnection } = await import("../protocols/mcp-modern.js");
2077
2095
  const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
2078
- const usesScopedFetch = transport?.trustedFetchFn !== void 0;
2096
+ const usesScopedFetch = this.usesScopedDiscoveryTransport(options);
2097
+ const endpointEpoch = this.discoveryEpochSnapshot(options);
2098
+ const mayRetain = () => !usesScopedFetch && (!endpointEpoch || this.discoveryEpochIs(endpointEpoch));
2079
2099
  const authToken = this.normalizedAgent.oauth_client_credentials ? this.normalizedAgent.oauth_tokens?.access_token : this.agent.auth_token;
2080
2100
  const agentHeaders = this.agent.headers;
2081
2101
  const authHeaders = (0, import_auth.createMCPRequestHeaders)(agentHeaders, authToken);
@@ -2095,7 +2115,7 @@ class SingleAgentClient {
2095
2115
  allowPrivateIp: transport?.allowPrivateIp
2096
2116
  });
2097
2117
  if (modern.connected) {
2098
- if (!usesScopedFetch) {
2118
+ if (mayRetain()) {
2099
2119
  this.discoveredMcpEra = modern.era;
2100
2120
  this.discoveredMcpEraAt = Date.now();
2101
2121
  }
@@ -2114,7 +2134,7 @@ class SingleAgentClient {
2114
2134
  }
2115
2135
  );
2116
2136
  await client.close();
2117
- if (!usesScopedFetch) {
2137
+ if (mayRetain()) {
2118
2138
  this.discoveredMcpEra = "legacy";
2119
2139
  this.discoveredMcpEraAt = Date.now();
2120
2140
  }
@@ -2291,7 +2311,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2291
2311
  async verifyAndParseWebhook(options) {
2292
2312
  const rawBody = options.rawBody ?? rawBodyFromUnknown(options.body);
2293
2313
  const authHeaders = inspectWebhookAuthenticationHeaders(options.headers, options.signature, options.timestamp);
2294
- const trustedOperationId = options.operationId && options.operationId !== "unknown" ? options.operationId : void 0;
2314
+ let trustedOperationId = options.operationId && options.operationId !== "unknown" ? options.operationId : void 0;
2295
2315
  let registration;
2296
2316
  if (trustedOperationId) {
2297
2317
  let stored;
@@ -2332,6 +2352,24 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2332
2352
  }
2333
2353
  }
2334
2354
  }
2355
+ if (!registration && options.requestUrl && ["media_buy_delivery", "artifact_delivery"].includes(options.taskType ?? "")) {
2356
+ const kind = options.taskType === "artifact_delivery" ? "artifact" : "reporting";
2357
+ const routeId = (0, import_webhook_registration.deliveryWebhookRegistrationId)(kind, options.requestUrl);
2358
+ try {
2359
+ const stored = await this.webhookRegistrationStore.get(this.agent.id, routeId);
2360
+ if (stored) {
2361
+ registration = (0, import_webhook_registration.parseWebhookRegistration)(stored, { agentId: this.agent.id, operationId: routeId });
2362
+ trustedOperationId = routeId;
2363
+ }
2364
+ } catch (cause) {
2365
+ return {
2366
+ ok: false,
2367
+ code: "webhook_registration_store_unavailable",
2368
+ message: "Delivery registration state is unavailable",
2369
+ cause
2370
+ };
2371
+ }
2372
+ }
2335
2373
  if (registration) {
2336
2374
  const nowMs = this.config.webhookVerification?.now ? Math.floor(this.config.webhookVerification.now() * 1e3) : Date.now();
2337
2375
  if (registration.expiresAt <= nowMs) registration = void 0;
@@ -2412,6 +2450,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2412
2450
  }
2413
2451
  }
2414
2452
  if (registration?.mode === "rfc9421") {
2453
+ const { verifyWebBotAuth, selectSignatureProfile, WebBotAuthError, WebBotAuthUnavailableError } = loadWebBotAuth();
2415
2454
  const requestMethod = options.requestMethod;
2416
2455
  const requestUrl = options.requestUrl;
2417
2456
  if (rawBody === void 0 || !options.headers || !trustedOperationId || !requestMethod || !requestUrl) {
@@ -2424,28 +2463,81 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2424
2463
  const normalizedHeaders = normalizeRfc9421WebhookHeaders(options.headers);
2425
2464
  if (!normalizedHeaders.ok) return normalizedHeaders.failure;
2426
2465
  try {
2427
- const delegatedOperatorAuthorization = this.delegatedOperatorAuthorizationForRegistration(registration);
2428
- await (0, import_server.verifyWebhookSignature)(
2429
- {
2430
- method: requestMethod,
2431
- url: requestUrl,
2432
- headers: normalizedHeaders.headers,
2433
- body: rawBody
2434
- },
2435
- {
2436
- jwks: this.webhookJwksFor(registration),
2437
- publisherPins: await this.config.webhookVerification?.publisherPins?.(registration),
2438
- onKeyResolutionError: this.config.webhookVerification?.onKeyResolutionError,
2439
- replayStore: this.webhookReplayStore,
2440
- revocationStore: this.webhookRevocationStore,
2441
- ...this.config.webhookVerification?.now && { now: this.config.webhookVerification.now },
2442
- agentUrlForKeyid: () => registration.agentUrl,
2443
- ...registration.authorizationContextVersion === 1 && {
2444
- replayScopeBinding: `delegated-operator:v1:${crypto.createHash("sha256").update((0, import_webhook_registration.canonicalDelegatedOperatorAuthorization)(delegatedOperatorAuthorization)).digest("base64url")}`
2466
+ const actualProfile = selectSignatureProfile({ headers: normalizedHeaders.headers });
2467
+ if (registration.signingProfile === "web-bot-auth") {
2468
+ if (registration.delegatedOperatorAuthorization || await this.config.webhookVerification?.publisherPins?.(registration))
2469
+ throw new WebBotAuthError(403, "legacy_webhook_authorization_requires_rfc_profile");
2470
+ const config = this.config.webhookVerification?.webBotAuth;
2471
+ if (!config) throw new WebBotAuthError(403, "webhook_profile_not_configured");
2472
+ const signers = await verifyWebBotAuth(
2473
+ {
2474
+ method: requestMethod,
2475
+ url: requestUrl,
2476
+ headers: normalizedHeaders.headers,
2477
+ body: typeof rawBody === "string" ? rawBody : (
2478
+ // ignoreBOM: Content-Digest covers the exact received bytes.
2479
+ new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(rawBody)
2480
+ )
2481
+ },
2482
+ {
2483
+ directory: config.directory,
2484
+ replayStore: this.webhookReplayStore,
2485
+ ...config.isRevoked && !config.revocation && { isRevoked: config.isRevoked },
2486
+ now: this.config.webhookVerification?.now
2445
2487
  }
2446
- }
2447
- );
2488
+ );
2489
+ if (signers.length !== 1 || signers[0].origin !== (0, import_canonicalize.canonicalAgentOrigin)(registration.agentUrl))
2490
+ throw new WebBotAuthError(403, "webhook_signer_mismatch");
2491
+ if (config.revocation) {
2492
+ let status;
2493
+ try {
2494
+ status = await config.revocation.status(signers[0].origin, signers[0].keyid);
2495
+ } catch (error) {
2496
+ throw new WebBotAuthUnavailableError("revocation_persistence_failed", error);
2497
+ }
2498
+ if (status === "revoked") throw new WebBotAuthError(403, "key_revoked");
2499
+ if (status === "unknown") throw new WebBotAuthError(403, "identity_unverified");
2500
+ } else if (!config.isRevoked) throw new WebBotAuthError(403, "webhook_revocation_not_configured");
2501
+ } else {
2502
+ if (actualProfile === "web-bot-auth") throw new WebBotAuthError(403, "webhook_profile_mismatch");
2503
+ const delegatedOperatorAuthorization = this.delegatedOperatorAuthorizationForRegistration(registration);
2504
+ await (0, import_server.verifyWebhookSignature)(
2505
+ {
2506
+ method: requestMethod,
2507
+ url: requestUrl,
2508
+ headers: normalizedHeaders.headers,
2509
+ body: rawBody
2510
+ },
2511
+ {
2512
+ jwks: this.webhookJwksFor(registration),
2513
+ publisherPins: await this.config.webhookVerification?.publisherPins?.(registration),
2514
+ onKeyResolutionError: this.config.webhookVerification?.onKeyResolutionError,
2515
+ replayStore: this.webhookReplayStore,
2516
+ revocationStore: this.webhookRevocationStore,
2517
+ ...this.config.webhookVerification?.now && { now: this.config.webhookVerification.now },
2518
+ agentUrlForKeyid: () => registration.agentUrl,
2519
+ ...registration.authorizationContextVersion === 1 && {
2520
+ replayScopeBinding: `delegated-operator:v1:${crypto.createHash("sha256").update((0, import_webhook_registration.canonicalDelegatedOperatorAuthorization)(delegatedOperatorAuthorization)).digest("base64url")}`
2521
+ }
2522
+ }
2523
+ );
2524
+ }
2448
2525
  } catch (cause) {
2526
+ if (cause instanceof WebBotAuthUnavailableError)
2527
+ return { ok: false, code: "webhook_verification_unavailable", message: cause.message, cause };
2528
+ if (cause instanceof WebBotAuthError)
2529
+ return {
2530
+ ok: false,
2531
+ code: [
2532
+ "directory_unavailable",
2533
+ "directory_fetch_limit",
2534
+ "directory_expired",
2535
+ "identity_unverified",
2536
+ "verification_unavailable"
2537
+ ].includes(cause.reason) ? "webhook_verification_unavailable" : "webhook_signature_invalid",
2538
+ message: cause.message,
2539
+ cause
2540
+ };
2449
2541
  if (cause instanceof import_server.WebhookSignatureError) {
2450
2542
  if (cause.retryable)
2451
2543
  return {
@@ -2525,6 +2617,45 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
2525
2617
  if (!parsedPayload.ok) {
2526
2618
  return parsedPayload;
2527
2619
  }
2620
+ if (registration?.deliveryKind) {
2621
+ const loader = require('../validation/schema-loader.js');
2622
+ const body = parsedPayload.payload;
2623
+ const isReport = registration.deliveryKind === "reporting";
2624
+ const payload = isReport ? body.result : body;
2625
+ const schemaRef = isReport ? "media-buy/media-buy-delivery-webhook-result.json" : "content-standards/artifact-webhook-payload.json";
2626
+ const validator = loader.getSchemaValidatorByRef(schemaRef, this.resolvedAdcpVersion);
2627
+ const envelopeValidator = isReport ? loader.getSchemaValidatorByRef("core/mcp-webhook-payload.json", this.resolvedAdcpVersion) : void 0;
2628
+ if (!validator || !validator(payload) || isReport && (!envelopeValidator || !envelopeValidator(body) || body.task_type !== "media_buy_delivery"))
2629
+ return {
2630
+ ok: false,
2631
+ code: "webhook_envelope_invalid",
2632
+ message: "Authenticated delivery does not match its registered payload kind"
2633
+ };
2634
+ const taskId = isReport && typeof body.task_id === "string" ? body.task_id : typeof body.media_buy_id === "string" ? body.media_buy_id : registration.operationId;
2635
+ const operationId = isReport && typeof body.operation_id === "string" ? body.operation_id : registration.operationId;
2636
+ const status = isReport && (0, import_task_status.isAdcpStatus)(body.status) ? body.status : "completed";
2637
+ return {
2638
+ ok: true,
2639
+ protocol: registration.protocol,
2640
+ envelope: isReport ? body : {
2641
+ ...body,
2642
+ task_type: registration.taskType,
2643
+ operation_id: operationId,
2644
+ task_id: taskId,
2645
+ status,
2646
+ result: payload
2647
+ },
2648
+ result: payload,
2649
+ metadata: {
2650
+ taskId,
2651
+ taskType: registration.taskType,
2652
+ operationId,
2653
+ status,
2654
+ ...typeof body.timestamp === "string" && { timestamp: body.timestamp },
2655
+ ...typeof body.idempotency_key === "string" && { idempotencyKey: body.idempotency_key }
2656
+ }
2657
+ };
2658
+ }
2528
2659
  const topLevelTaskType = isObjectRecord(parsedPayload.payload) && typeof parsedPayload.payload.task_type === "string" ? parsedPayload.payload.task_type : void 0;
2529
2660
  const payloadRecord = isObjectRecord(parsedPayload.payload) ? parsedPayload.payload : void 0;
2530
2661
  const signedRoute = extractSignedWebhookRoute(parsedPayload.payload);
@@ -3286,7 +3417,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
3286
3417
  if (!options?.skipIdempotencyAutoInject && !options?.preserveGovernedPayload && (0, import_idempotency.requestUsesIdempotency)(taskType, normalizedParams) && normalizedParams && typeof normalizedParams === "object" && !normalizedParams.idempotency_key) {
3287
3418
  normalizedParams = { ...normalizedParams, idempotency_key: (0, import_idempotency.generateIdempotencyKey)() };
3288
3419
  }
3289
- if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation && !options?.preserveGovernedPayload && !(0, import_schema_loader.isExternalSchemaRootActive)(this.resolvedAdcpVersion)) {
3420
+ if (!options?.skipIdempotencyAutoInject && !options?.skipAccountValidation && !options?.skipRequestValidation && !options?.preserveGovernedPayload && !(0, import_schema_loader2.isExternalSchemaRootActive)(this.resolvedAdcpVersion)) {
3290
3421
  this.validateRequest(taskType, normalizedParams);
3291
3422
  }
3292
3423
  await this.validateTaskFeatures(taskType, options);
@@ -4379,7 +4510,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4379
4510
  const filtered = {};
4380
4511
  const schemaStripped = [];
4381
4512
  for (const [key, value] of Object.entries(adapted)) {
4382
- if (declaredFields.has(key) || envelopeFields.has(key) || (0, import_schema_loader.schemaAllowsTopLevelField)(taskType, key, this.resolvedAdcpVersion)) {
4513
+ if (declaredFields.has(key) || envelopeFields.has(key) || (0, import_schema_loader2.schemaAllowsTopLevelField)(taskType, key, this.resolvedAdcpVersion)) {
4383
4514
  filtered[key] = value;
4384
4515
  } else {
4385
4516
  schemaStripped.push(key);
@@ -4714,6 +4845,8 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4714
4845
  params.account
4715
4846
  );
4716
4847
  const hasCreativeFormatData = hasMediaBuyCreativeFormatData(params);
4848
+ if (this.config.experimentalIdentity33) await this.getCapabilities(taskOptions);
4849
+ const signed33Webhooks = this.usesSigned33Webhooks();
4717
4850
  if (this.config.webhookUrlTemplate && !options?.disableWebhook) {
4718
4851
  const now = /* @__PURE__ */ new Date();
4719
4852
  const year = now.getUTCFullYear();
@@ -4734,12 +4867,17 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4734
4867
  const consumerAuth = consumerReportingWebhook?.authentication;
4735
4868
  const consumerUrl = consumerReportingWebhook?.url;
4736
4869
  const consumerFrequency = consumerReportingWebhook?.reporting_frequency;
4737
- const defaultAuth = this.config.webhookSecret ? { schemes: ["HMAC-SHA256"], credentials: this.config.webhookSecret } : void 0;
4870
+ const defaultAuth = !signed33Webhooks && this.config.webhookSecret ? { schemes: ["HMAC-SHA256"], credentials: this.config.webhookSecret } : void 0;
4738
4871
  const resolvedAuth = consumerAuth !== void 0 ? consumerAuth : consumerUrl === void 0 ? defaultAuth : void 0;
4739
- if (resolvedAuth === void 0 || resolvedAuth === null) {
4872
+ if (!signed33Webhooks && resolvedAuth === void 0 || resolvedAuth === null) {
4873
+ if (consumerReportingWebhook && consumerUrl !== void 0 && consumerAuth === void 0) {
4874
+ throw new Error(
4875
+ "reporting_webhook requires an `authentication` block without positively negotiated 3.3 signed webhooks: a caller-supplied `reporting_webhook.url` must bring its own `reporting_webhook.authentication` (the client never pairs `webhookSecret` with a caller-controlled URL). Omit `url` to use the client's webhookUrlTemplate callback, or remove `reporting_webhook` if you do not need automated delivery reports."
4876
+ );
4877
+ }
4740
4878
  if (consumerReportingWebhook) {
4741
4879
  throw new Error(
4742
- "reporting_webhook requires an `authentication` block for all of AdCP 3.x, and no credential is available: set `webhookSecret` on the client, or pass `reporting_webhook.authentication` explicitly. Remove `reporting_webhook` from the request if you do not need automated delivery reports \u2014 the media buy itself does not require it."
4880
+ "reporting_webhook requires an `authentication` block without positively negotiated 3.3 signed webhooks, and no credential is available: set `webhookSecret` on the client, or pass `reporting_webhook.authentication` explicitly. Remove `reporting_webhook` from the request if you do not need automated delivery reports \u2014 the media buy itself does not require it."
4743
4881
  );
4744
4882
  }
4745
4883
  warnReportingWebhookNeedsSecret();
@@ -4755,9 +4893,20 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
4755
4893
  ...consumerReportingWebhook,
4756
4894
  url: consumerUrl !== void 0 ? consumerUrl : deliveryWebhookUrl,
4757
4895
  reporting_frequency: consumerFrequency !== void 0 ? consumerFrequency : libraryDefaults.reporting_frequency,
4758
- authentication: resolvedAuth
4896
+ ...resolvedAuth !== void 0 && { authentication: resolvedAuth },
4897
+ ...resolvedAuth === void 0 && this.selectedWebhookSigningProfile() && { signing_profile: this.selectedWebhookSigningProfile() }
4759
4898
  }
4760
4899
  };
4900
+ if (signed33Webhooks && resolvedAuth === void 0 && consumerUrl === void 0) {
4901
+ await this.persistWebhookRegistration({
4902
+ agent: this.normalizedAgent,
4903
+ taskType: "media_buy_delivery",
4904
+ operationId,
4905
+ callbackUrl: deliveryWebhookUrl,
4906
+ mode: "rfc9421",
4907
+ signingProfile: this.selectedWebhookSigningProfile()
4908
+ });
4909
+ }
4761
4910
  }
4762
4911
  }
4763
4912
  }
@@ -5012,7 +5161,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5012
5161
  ...options,
5013
5162
  [CAPABILITY_DISCOVERY_CONTEXT]: discoveryContext
5014
5163
  });
5015
- const usesScopedFetch = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport)?.trustedFetchFn !== void 0;
5164
+ const usesScopedFetch = this.usesScopedDiscoveryTransport(options);
5016
5165
  const toolSchemas = discoveryContext.toolSchemas ?? (usesScopedFetch ? void 0 : this.cachedToolSchemas);
5017
5166
  const wireRelease = this.config.wireAdcpVersion ?? this.resolvedAdcpVersion;
5018
5167
  const declared = (0, import_creative_delivery.resolveCreativeFormatWireMode)(capabilities, wireRelease);
@@ -5046,7 +5195,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5046
5195
  if ((0, import_idempotency.requestUsesIdempotency)(taskType, normalizedParams) && normalizedParams && typeof normalizedParams === "object" && !normalizedParams.idempotency_key) {
5047
5196
  normalizedParams = { ...normalizedParams, idempotency_key: (0, import_idempotency.generateIdempotencyKey)() };
5048
5197
  }
5049
- if (!(0, import_schema_loader.isExternalSchemaRootActive)(this.resolvedAdcpVersion)) {
5198
+ if (!(0, import_schema_loader2.isExternalSchemaRootActive)(this.resolvedAdcpVersion)) {
5050
5199
  this.validateRequest(taskType, normalizedParams);
5051
5200
  }
5052
5201
  }
@@ -5327,15 +5476,23 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
5327
5476
  );
5328
5477
  }
5329
5478
  async getAdcpCapabilitiesWithinDeadline(params, inputHandler, options) {
5479
+ const scopeKey = this.config._reuseConfiguredDiscovery?.() ? this.getCapabilityEvidenceScope().scopeKey : void 0;
5330
5480
  const agent = await this.ensureEndpointDiscovered(options);
5331
5481
  this.executor.validateRequest("get_adcp_capabilities", params);
5332
- return this.executor.executeTask(
5482
+ const result = await this.executor.executeTask(
5333
5483
  agent,
5334
5484
  "get_adcp_capabilities",
5335
5485
  params,
5336
5486
  inputHandler,
5337
5487
  options
5338
5488
  );
5489
+ if (this.config._reuseConfiguredDiscovery?.() && !this.usesScopedDiscoveryTransport(options) && scopeKey === this.getCapabilityEvidenceScope().scopeKey && Object.keys(params).length === 0 && this.runAgentInfo !== void 0 && result.success && result.data && (0, import_capabilities.looksLikeV3Capabilities)(result.data)) {
5490
+ const capabilities = (0, import_capabilities.parseCapabilitiesResponse)(structuredClone(result.data));
5491
+ if (!capabilities._synthetic) {
5492
+ this.cachedCapabilities = (0, import_capabilities.augmentCapabilitiesFromTools)(capabilities, this.runAgentInfo.tools);
5493
+ }
5494
+ }
5495
+ return result;
5339
5496
  }
5340
5497
  // ====== CREATIVE BUILD TASKS ======
5341
5498
  /**
@@ -6433,6 +6590,25 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6433
6590
  * ```
6434
6591
  */
6435
6592
  async getAgentInfo(options) {
6593
+ (0, import_abort2.throwIfAborted)(options?.signal);
6594
+ const reuse = this.config._reuseConfiguredDiscovery?.() && !this.usesScopedDiscoveryTransport(options);
6595
+ if (!reuse) return this.getAgentInfoLive(options);
6596
+ const scopeKey = this.getCapabilityEvidenceScope().scopeKey;
6597
+ if (this.runAgentInfo) return structuredClone(this.runAgentInfo);
6598
+ const info = await this.getAgentInfoLive(options);
6599
+ if (reuse && scopeKey === this.getCapabilityEvidenceScope().scopeKey) {
6600
+ this.runAgentInfo = structuredClone(info);
6601
+ const documents = new Map(
6602
+ this.runAgentInfo.tools.filter((tool) => tool.inputSchema).map((tool) => [tool.name, tool.inputSchema])
6603
+ );
6604
+ this.cachedToolSchemas = new Map(
6605
+ [...documents].map(([name, schema]) => [name, schema.properties ?? {}])
6606
+ );
6607
+ toolInputSchemasByProperties.set(this.cachedToolSchemas, documents);
6608
+ }
6609
+ return info;
6610
+ }
6611
+ async getAgentInfoLive(options) {
6436
6612
  const { withResponseSizeLimit } = await import("../protocols/responseSizeLimit.js");
6437
6613
  (0, import_abort2.throwIfAborted)(options?.signal);
6438
6614
  const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
@@ -6666,7 +6842,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6666
6842
  this.synchronizeCapabilityEvidenceAuthorizationScope();
6667
6843
  const discoveryContext = options?.[CAPABILITY_DISCOVERY_CONTEXT];
6668
6844
  const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
6669
- const usesScopedFetch = transport?.trustedFetchFn !== void 0;
6845
+ const usesScopedFetch = this.usesScopedDiscoveryTransport(options);
6670
6846
  if (this.primedCapabilitiesExpiresAt !== void 0 && this.primedCapabilitiesExpiresAt <= Date.now()) {
6671
6847
  this.cachedCapabilities = void 0;
6672
6848
  this.cachedToolSchemas = void 0;
@@ -6945,10 +7121,25 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6945
7121
  }
6946
7122
  if (current === this.capabilityEvidenceAuthMaterial) return;
6947
7123
  this.capabilityEvidenceAuthMaterial = current;
7124
+ this.discoveryEpoch++;
7125
+ this.runAgentInfo = void 0;
6948
7126
  this.cachedCapabilities = void 0;
6949
7127
  this.cachedToolSchemas = void 0;
6950
7128
  this.primedCapabilitiesExpiresAt = void 0;
6951
7129
  this.capabilityEvidenceScopeKey = (0, import_node_crypto.randomUUID)();
7130
+ if (this.config._reuseConfiguredDiscovery?.()) {
7131
+ this.discoveredEndpoint = void 0;
7132
+ this.discoveredAgent = void 0;
7133
+ this.canonicalBaseUrl = void 0;
7134
+ this.discoveredMcpEra = void 0;
7135
+ }
7136
+ }
7137
+ /** A comply() run owns its configured fetch; per-call transport changes still discover separately. */
7138
+ usesScopedDiscoveryTransport(options) {
7139
+ const transport = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport);
7140
+ if (!this.config._reuseConfiguredDiscovery?.()) return transport?.trustedFetchFn !== void 0;
7141
+ const configured = (0, import_protocols.normalizeTransportOptions)(this.config.transport);
7142
+ return transport?.trustedFetchFn !== configured?.trustedFetchFn || transport?.allowPrivateIp !== configured?.allowPrivateIp || transport?.maxResponseBytes !== configured?.maxResponseBytes || transport?.requestTimeoutMs !== configured?.requestTimeoutMs || transport?.legacyCompat?.enabled !== configured?.legacyCompat?.enabled;
6952
7143
  }
6953
7144
  /**
6954
7145
  * Reuse a fresh capability observation made by the embedding application.
@@ -6971,7 +7162,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
6971
7162
  const hasValidToolSchemas = snapshot?.toolSchemas === void 0 || typeof snapshot.toolSchemas === "object" && snapshot.toolSchemas !== null && Object.values(snapshot.toolSchemas).every(
6972
7163
  (properties) => typeof properties === "object" && properties !== null && !Array.isArray(properties)
6973
7164
  );
6974
- const configuredScopedFetch = (0, import_protocols.normalizeTransportOptions)(this.config.transport)?.trustedFetchFn !== void 0;
7165
+ const configuredScopedFetch = this.usesScopedDiscoveryTransport();
6975
7166
  const hasToolEvidence = snapshot?.toolSchemas !== void 0 || Array.isArray(capabilities?.discoveredTools);
6976
7167
  if (!matchesScope || !isFresh || !hasCapabilities || !hasValidToolSchemas || !hasToolEvidence || configuredScopedFetch) {
6977
7168
  this.cachedCapabilities = void 0;
@@ -7014,11 +7205,13 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
7014
7205
  /** Epoch of this client's evidence for the call's effective shared key; `undefined` without a shared cache. */
7015
7206
  discoveryEpochSnapshot(options) {
7016
7207
  const key = this.sharedDiscoveryKey(options);
7017
- if (!key || !this.config.discoveryCache) return void 0;
7208
+ if (!key || !this.config.discoveryCache) {
7209
+ return this.config._reuseConfiguredDiscovery?.() ? { local: this.discoveryEpoch, shared: 0, key: "" } : void 0;
7210
+ }
7018
7211
  return { local: this.discoveryEpoch, shared: this.sharedInvalidationEpoch(key), key };
7019
7212
  }
7020
7213
  discoveryEpochIs(epoch) {
7021
- return epoch.local === this.discoveryEpoch && epoch.shared === this.sharedInvalidationEpoch(epoch.key);
7214
+ return epoch.local === this.discoveryEpoch && (!epoch.key || epoch.shared === this.sharedInvalidationEpoch(epoch.key));
7022
7215
  }
7023
7216
  /** The latest invalidation that applies to `key`: its own, combined with the cache's floor of forgotten ones. */
7024
7217
  sharedInvalidationRecord(key) {
@@ -7327,6 +7520,8 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
7327
7520
  * seller answers with a version or capability error.
7328
7521
  */
7329
7522
  async invalidateDiscoveryCache(options) {
7523
+ this.runAgentInfo = void 0;
7524
+ if (this.config._reuseConfiguredDiscovery?.()) this.canonicalBaseUrl = void 0;
7330
7525
  this.cachedCapabilities = void 0;
7331
7526
  this.cachedToolSchemas = void 0;
7332
7527
  this.primedCapabilitiesExpiresAt = void 0;
@@ -7874,7 +8069,29 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
7874
8069
  * injected fields before the adapter gets a chance to clean them up, so
7875
8070
  * the two passes have to agree on "extra keys are fine."
7876
8071
  */
8072
+ usesIdentity33Schemas() {
8073
+ return this.config.experimentalIdentity33 === true && this.cachedCapabilities?._synthetic === false && (0, import_adcp_version_config.isAdcpVersionAtLeast)(this.cachedCapabilities.servedVersion, "3.3.0");
8074
+ }
8075
+ usesSigned33Webhooks() {
8076
+ const capabilities = this.cachedCapabilities;
8077
+ return this.config.experimentalIdentity33 === true && capabilities?._synthetic === false && (0, import_adcp_version_config.isAdcpVersionAtLeast)(capabilities.servedVersion, "3.3.0") && capabilities._raw?.webhook_signing?.supported === true;
8078
+ }
8079
+ selectedWebhookSigningProfile() {
8080
+ if (!this.usesSigned33Webhooks()) return void 0;
8081
+ const advertisement = this.cachedCapabilities?._raw?.webhook_signing;
8082
+ const profile = this.config.webhookSigningProfile ?? (advertisement?.profile === "web-bot-auth" || advertisement?.profiles?.length === 1 && advertisement.profiles[0] === "web-bot-auth" ? "web-bot-auth" : "adcp/webhook-signing/v1");
8083
+ if (profile === "web-bot-auth" && !advertisement?.profiles?.includes(profile))
8084
+ throw new import_errors.ConfigurationError(
8085
+ "Seller did not advertise the selected Web Bot Auth webhook profile",
8086
+ "webhookSigningProfile"
8087
+ );
8088
+ return profile;
8089
+ }
7877
8090
  validateRequest(taskType, params) {
8091
+ if (this.config.experimentalIdentity33 && this.usesIdentity33Schemas()) {
8092
+ this.executor.validateRequest(taskType, params);
8093
+ return;
8094
+ }
7878
8095
  const schema = this.getRequestSchema(taskType);
7879
8096
  if (!schema) {
7880
8097
  return;
@@ -7991,6 +8208,7 @@ function normalizeRfc9421WebhookHeaders(headers) {
7991
8208
  const singletonHeaders = /* @__PURE__ */ new Set([
7992
8209
  "signature",
7993
8210
  "signature-input",
8211
+ "signature-agent",
7994
8212
  "content-digest",
7995
8213
  "content-type",
7996
8214
  "x-adcp-signature",