@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
@@ -1,3 +1,26 @@
1
+ import { getWebBotAuthLegacyOriginGate } from "../signing/web-bot-auth.mjs";
2
+ import {
3
+ isIdentity33SchemaScope,
4
+ withIdentity33SchemaScope,
5
+ bindIdentity33SchemaScope
6
+ } from "../validation/schema-loader.mjs";
7
+ import { validateAgentOnboarding } from "../identity-3.3/lifecycle.mjs";
8
+ import { isIdentity33UnboundContext } from "../identity-3.3/server.mjs";
9
+ import {
10
+ WEB_BOT_AUTH_DRAFT_REVISION,
11
+ getWebBotAuthAuthorizationFailure,
12
+ webBotAuthToolFailure,
13
+ selectSignatureProfile,
14
+ verifyWebBotAuth,
15
+ isWebBotAuthRevocationChecked,
16
+ webBotAuthUnavailableResponse,
17
+ WebBotAuthUnavailableError,
18
+ deferWebBotAuthPrincipalFailure,
19
+ webBotAuthPrincipalFailureError,
20
+ WebBotAuthError
21
+ } from "../signing/web-bot-auth.mjs";
22
+ import { validateIdentity33Payload } from "../identity-3.3/validation.mjs";
23
+ import { IdentityAuthorizationError, TrustRecordUnavailableError } from "../identity-3.3/trust.mjs";
1
24
  import { z } from "zod";
2
25
  import {
3
26
  COMPATIBLE_ADCP_VERSIONS,
@@ -752,10 +775,12 @@ function restoreSyncAccountEnvelopeErrorIndices(response, acceptedIndices) {
752
775
  syncContentJsonText(restored, restored.structuredContent, mirrorsStructuredContent);
753
776
  return restored;
754
777
  }
755
- function validateFrameworkPayload(toolName, direction, payload, version, proposalCapabilities) {
778
+ function validateFrameworkPayload(toolName, direction, payload, version, proposalCapabilities, identity33 = false) {
756
779
  if (toolName === "sync_reporting_status" && direction === "request") {
757
780
  return validateSyncReportingStatusEnvelope(payload, version);
758
781
  }
782
+ if (identity33 && toolName !== "refine_proposals" && toolName !== "sync_reporting_status")
783
+ return validateIdentity33Payload(toolName, direction, payload, version);
759
784
  if (toolName !== "refine_proposals") {
760
785
  return direction === "request" ? validateRequest(toolName, payload, version) : validateResponse(toolName, payload, version);
761
786
  }
@@ -1491,6 +1516,15 @@ function resolveEffectiveSignedRequestPolicy(signedRequests, capabilityRequestSi
1491
1516
  };
1492
1517
  }
1493
1518
  function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning, adcpVersion) {
1519
+ const legacyOriginGate = signedRequests.assertLegacyOriginAllowed ?? getWebBotAuthLegacyOriginGate(signedRequests.webBotAuth?.resolvePrincipal);
1520
+ if (signedRequests.webBotAuth && !legacyOriginGate)
1521
+ throw new Error(
1522
+ "Web Bot Auth requires an origin-binding migration fence; use createIdentity33PrincipalResolver or supply assertLegacyOriginAllowed"
1523
+ );
1524
+ if (signedRequests.webBotAuth && !signedRequests.webBotAuth.isRevoked && !isWebBotAuthRevocationChecked(signedRequests.webBotAuth.resolvePrincipal))
1525
+ throw new Error(
1526
+ "Web Bot Auth requires origin revocation: use createIdentity33PrincipalResolver({ revocation }) or supply isRevoked"
1527
+ );
1494
1528
  const requiredFor = effectiveRequestSigning.required_for ?? [];
1495
1529
  const verifier = createExpressVerifier({
1496
1530
  capability: {
@@ -1512,6 +1546,66 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
1512
1546
  return async function adcpPreTransport(req, res) {
1513
1547
  const serveContext = getServeRequestContext(req);
1514
1548
  const canonicalPublicUrl = serveContext?.publicUrl ? new URL(serveContext.publicUrl) : void 0;
1549
+ if (selectSignatureProfile({ headers: req.headers }) === "web-bot-auth") {
1550
+ try {
1551
+ if (!signedRequests.webBotAuth || !canonicalPublicUrl) throw new WebBotAuthError(403, "profile_disabled");
1552
+ if (req.method !== "GET" && req.rawBody === void 0) throw new WebBotAuthError(403, "raw_body_missing");
1553
+ const requestTarget = canonicalPublicUrl.origin + (req.url?.startsWith("/") ? req.url : "/" + (req.url ?? ""));
1554
+ const signers = await verifyWebBotAuth(
1555
+ { method: req.method ?? "POST", url: requestTarget, headers: req.headers, body: req.rawBody ?? "" },
1556
+ {
1557
+ // Identity verification needs only key discovery and replay state;
1558
+ // revocation and binding belong to the principal resolver.
1559
+ directory: signedRequests.webBotAuth.directory,
1560
+ replayStore: signedRequests.replayStore,
1561
+ ...signedRequests.webBotAuth.isRevoked && { isRevoked: signedRequests.webBotAuth.isRevoked }
1562
+ }
1563
+ );
1564
+ const operation = resolveRequestOperation({ rawBody: req.rawBody, method: req.method, url: req.url });
1565
+ let principal;
1566
+ let deferredFailure;
1567
+ try {
1568
+ principal = await signedRequests.webBotAuth.resolvePrincipal(signers, operation);
1569
+ } catch (error) {
1570
+ if (error instanceof WebBotAuthError || error instanceof WebBotAuthUnavailableError) throw error;
1571
+ if (typeof operation !== "string") throw webBotAuthPrincipalFailureError(error);
1572
+ const deferred = deferWebBotAuthPrincipalFailure(signers, error);
1573
+ principal = { principal: deferred.principal };
1574
+ deferredFailure = deferred.authorizationFailure;
1575
+ }
1576
+ const signer = signers[signers.length - 1];
1577
+ const failed = signers.find((s) => s.authorizationFailure);
1578
+ const guardedPrincipal = {
1579
+ ...principal,
1580
+ extra: {
1581
+ ...principal.extra,
1582
+ webBotAuthAuthorization: {
1583
+ signer: failed ?? signer,
1584
+ ...(failed?.authorizationFailure ?? deferredFailure) && {
1585
+ authorizationFailure: failed?.authorizationFailure ?? deferredFailure
1586
+ }
1587
+ }
1588
+ }
1589
+ };
1590
+ attachVerifiedSignerAuth(req, guardedPrincipal, {
1591
+ keyid: signer.keyid,
1592
+ agent_url: signer.origin,
1593
+ verified_at: signer.verified_at
1594
+ });
1595
+ return false;
1596
+ } catch (error) {
1597
+ if (error instanceof WebBotAuthUnavailableError) {
1598
+ const outage = webBotAuthUnavailableResponse();
1599
+ res.writeHead(outage.status, { ...outage.headers, "Content-Type": "application/json" });
1600
+ res.end(JSON.stringify(outage.body));
1601
+ return true;
1602
+ }
1603
+ const rejected = error instanceof WebBotAuthError ? error : new WebBotAuthError(403, "identity_rejected");
1604
+ res.writeHead(rejected.status, { ...rejected.headers, "Content-Type": "application/json" });
1605
+ res.end(JSON.stringify(rejected.body));
1606
+ return true;
1607
+ }
1608
+ }
1515
1609
  const reqShim = {
1516
1610
  method: req.method ?? "POST",
1517
1611
  url: req.url ?? "/mcp",
@@ -1555,6 +1649,7 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
1555
1649
  resolve();
1556
1650
  };
1557
1651
  res.once("finish", () => {
1652
+ verifierCompleted = true;
1558
1653
  if (res.writableEnded) handled = true;
1559
1654
  done();
1560
1655
  });
@@ -1562,8 +1657,7 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
1562
1657
  if (!verifierCompleted) handled = true;
1563
1658
  done();
1564
1659
  });
1565
- verifier(reqShim, resShim, (err) => {
1566
- verifierCompleted = true;
1660
+ verifier(reqShim, resShim, async (err) => {
1567
1661
  if (err) {
1568
1662
  const errName = err.name || "Error";
1569
1663
  const errCode = err.code ?? "unknown";
@@ -1578,6 +1672,11 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
1578
1672
  const verifiedSigner = reqShim.verifiedSigner;
1579
1673
  if (!err && verifiedSigner) {
1580
1674
  try {
1675
+ if (legacyOriginGate) {
1676
+ if (!verifiedSigner.agent_url)
1677
+ throw new AuthError("Legacy signer origin is required for migration fencing");
1678
+ await legacyOriginGate(verifiedSigner.agent_url);
1679
+ }
1581
1680
  const principal = principalForVerifiedSigner(verifiedSigner, signedRequests.makePrincipal);
1582
1681
  attachVerifiedSignerAuth(req, principal, verifiedSigner);
1583
1682
  } catch (identityError) {
@@ -1597,6 +1696,7 @@ function buildSignedRequestsPreTransport(signedRequests, effectiveRequestSigning
1597
1696
  handled = true;
1598
1697
  }
1599
1698
  }
1699
+ verifierCompleted = true;
1600
1700
  if (res.writableEnded) handled = true;
1601
1701
  done();
1602
1702
  });
@@ -1929,6 +2029,11 @@ function isAuthDerivedAccountNotFound(err) {
1929
2029
  return err instanceof AdcpError && err.code === "ACCOUNT_NOT_FOUND";
1930
2030
  }
1931
2031
  function createAdcpServer(config) {
2032
+ if (Boolean(config.identity33) !== isIdentity33SchemaScope())
2033
+ return withIdentity33SchemaScope(() => {
2034
+ const instance = createAdcpServer(config);
2035
+ return config.identity33 ? bindIdentity33SchemaScope(instance) : instance;
2036
+ }, Boolean(config.identity33));
1932
2037
  const {
1933
2038
  name,
1934
2039
  version,
@@ -2020,7 +2125,7 @@ function createAdcpServer(config) {
2020
2125
  }
2021
2126
  const credentialPolicyPatterns = credentialPolicy === void 0 || typeof credentialPolicy === "string" ? void 0 : credentialPolicy.patterns;
2022
2127
  const adcpVersion = resolveAdcpVersion(
2023
- configuredAdcpVersion ?? (config.proposalNegotiation ? ADCP_VERSION : void 0)
2128
+ configuredAdcpVersion ?? (config.identity33 ? "3.3" : config.proposalNegotiation ? ADCP_VERSION : void 0)
2024
2129
  );
2025
2130
  const toolVersionRanges = parseToolVersionRanges(config.toolVersions);
2026
2131
  const toolAvailableForRelease = (toolName, release) => toolIsAvailableInRelease(toolVersionRanges, toolName, release);
@@ -2093,6 +2198,23 @@ function createAdcpServer(config) {
2093
2198
  })();
2094
2199
  const protocolTaskRelease = parseAdcpRelease(protocolBundleKey);
2095
2200
  const supportsProtocolTaskTools = protocolTaskRelease !== void 0 && (protocolTaskRelease.major > 3 || protocolTaskRelease.major === 3 && protocolTaskRelease.minor >= 1);
2201
+ const identityOnboarding = capConfig?.account?.agent_onboarding ?? capConfig?.account?.agentOnboarding;
2202
+ if (identityOnboarding) {
2203
+ if (!config.identity33) throw new Error("agent_onboarding requires the identity33 experiment");
2204
+ validateAgentOnboarding(
2205
+ identityOnboarding,
2206
+ { sandbox: capConfig?.account?.sandbox, supported_billing: capConfig?.account?.supportedBilling },
2207
+ capConfig?.overrides?.experimental_features ?? []
2208
+ );
2209
+ }
2210
+ if (signedRequests?.webBotAuth && (!config.identity33 || !(capConfig?.overrides?.request_signing?.profiles ?? capConfig?.request_signing?.profiles)?.includes(
2211
+ "web-bot-auth"
2212
+ )))
2213
+ throw new Error("Web Bot Auth verifier requires identity33 and request_signing.profiles advertisement");
2214
+ if (config.webhooks?.signingProfile === "web-bot-auth")
2215
+ throw new Error("Select Web Bot Auth on each trusted webhook registration, not as a server-wide default");
2216
+ if (config.webhooks?.webBotAuth && !config.identity33)
2217
+ throw new Error("Web Bot Auth webhook signing requires the identity33 experiment");
2096
2218
  const toolsWithErrorArm = getToolsWithErrorArm(adcpVersion);
2097
2219
  const isProduction = process.env.NODE_ENV === "production";
2098
2220
  const requestValidationMode = validationConfig?.requests ?? (isProduction ? "off" : "strict");
@@ -2651,6 +2773,10 @@ function createAdcpServer(config) {
2651
2773
  const hasAccount = "account" in schema.shape;
2652
2774
  const wrap = meta?.wrap ?? ((data, summary) => genericResponse(toolName, data, summary));
2653
2775
  const toolHandler = async (params, extra) => {
2776
+ const authorizationFailure = getWebBotAuthAuthorizationFailure(extra?.authInfo?.extra);
2777
+ if (authorizationFailure) return webBotAuthToolFailure(authorizationFailure, servedAdcpVersion);
2778
+ if (config.identity33 && !isIdentity33SchemaScope())
2779
+ return withIdentity33SchemaScope(() => toolHandler(params, extra));
2654
2780
  const callRequestValidationMode = effectiveRequestValidationMode(extra);
2655
2781
  let notificationFailureRows = /* @__PURE__ */ new Map();
2656
2782
  const releaseSelection = selectServedAdcpRelease(params, capConfig, adcpVersion, defaultAdcpVersion);
@@ -2705,6 +2831,22 @@ function createAdcpServer(config) {
2705
2831
  })
2706
2832
  );
2707
2833
  }
2834
+ for (const field of ["push_notification_config", "reporting_webhook", "artifact_webhook"]) {
2835
+ const registration = params[field];
2836
+ if (!registration || typeof registration !== "object" || Array.isArray(registration)) continue;
2837
+ const selectedProfile = registration.signing_profile;
2838
+ if (selectedProfile === void 0) continue;
2839
+ const offered = capabilitiesData.webhook_signing?.profiles ?? [
2840
+ "adcp/webhook-signing/v1"
2841
+ ];
2842
+ if (typeof selectedProfile !== "string" || !offered.includes(selectedProfile) || selectedProfile === "web-bot-auth" && (!config.identity33 || !isAdcpVersionAtLeast(requestRelease.wireVersion, "3.3")) || selectedProfile === "web-bot-auth" && registration.authentication !== void 0)
2843
+ return finalize(
2844
+ adcpError("INVALID_REQUEST", {
2845
+ message: "Unsupported or ambiguous webhook signing profile",
2846
+ field: `${field}.signing_profile`
2847
+ })
2848
+ );
2849
+ }
2708
2850
  const operationIdError = pushOperationIdError(params, requestRelease);
2709
2851
  if (operationIdError) return finalize(operationIdError);
2710
2852
  if (toolName === "list_account_changes" && Object.hasOwn(params, "cursor") && Object.hasOwn(params, "starting_position")) {
@@ -2884,7 +3026,8 @@ function createAdcpServer(config) {
2884
3026
  "request",
2885
3027
  params,
2886
3028
  requestRelease.validationVersion,
2887
- proposalRefinementCapabilities
3029
+ proposalRefinementCapabilities,
3030
+ !!config.identity33 && isAdcpVersionAtLeast(requestRelease.wireVersion, "3.3")
2888
3031
  );
2889
3032
  if (!outcome.valid) {
2890
3033
  if ("refinementError" in outcome && outcome.refinementError?.code === "UNSUPPORTED_FEATURE") {
@@ -2939,6 +3082,23 @@ function createAdcpServer(config) {
2939
3082
  }
2940
3083
  }
2941
3084
  }
3085
+ if (config.identity33) {
3086
+ try {
3087
+ await config.identity33.authorize(ctx, toolName, params);
3088
+ } catch (error) {
3089
+ if (error instanceof TrustRecordUnavailableError)
3090
+ return finalize(adcpError("SERVICE_UNAVAILABLE", { message: error.message, recovery: "transient" }));
3091
+ if (error instanceof IdentityAuthorizationError)
3092
+ return finalize(
3093
+ adcpError("PERMISSION_DENIED", {
3094
+ message: error.message,
3095
+ ...error.details && { details: { ...error.details } }
3096
+ })
3097
+ );
3098
+ if (error instanceof AdcpError) return finalize(projectThrownAdcpError(error));
3099
+ return finalize(adcpError("PERMISSION_DENIED", { message: "Agent authorization failed" }));
3100
+ }
3101
+ }
2942
3102
  let unresolvedAccountPassThrough = false;
2943
3103
  const suppliedAccountRef = hasAccount && params.account != null && !(strictAccountReferences && toolName === "list_accounts");
2944
3104
  if (suppliedAccountRef && toolName === "list_accounts") {
@@ -3130,7 +3290,7 @@ function createAdcpServer(config) {
3130
3290
  );
3131
3291
  }
3132
3292
  }
3133
- const callerScopedResolver = toolName === "sync_agent_notification_configs" ? config.protocol?.resolveScope : toolName === "get_principal" || toolName === "sync_principal" ? config.protocol?.resolvePrincipalScope : void 0;
3293
+ const callerScopedResolver = config.identity33 && (toolName === "get_principal" || toolName === "sync_principal" && params.dry_run === true) && isIdentity33UnboundContext(ctx) ? void 0 : toolName === "sync_agent_notification_configs" ? config.protocol?.resolveScope : toolName === "get_principal" || toolName === "sync_principal" ? config.protocol?.resolvePrincipalScope : void 0;
3134
3294
  if (callerScopedResolver || toolName === "report_plan_adjustment") {
3135
3295
  if (ctx.authInfo === void 0 && ctx.agent === void 0) {
3136
3296
  return finalize(
@@ -3334,7 +3494,18 @@ function createAdcpServer(config) {
3334
3494
  if (webhookEmitter) {
3335
3495
  const tenantScope = webhookTenantScopeForContext(ctx);
3336
3496
  const scopedEmitter = tenantScope === void 0 ? configuredWebhookEmitter : webhookEmitter.forTenantScope(tenantScope);
3337
- ctx.emitWebhook = scopedEmitter.emit.bind(scopedEmitter);
3497
+ const profileBindings = ["push_notification_config", "reporting_webhook", "artifact_webhook"].flatMap(
3498
+ (field) => {
3499
+ const value = params[field];
3500
+ return value?.url && value.signing_profile ? [{ url: value.url, profile: value.signing_profile }] : [];
3501
+ }
3502
+ );
3503
+ ctx.emitWebhook = (delivery) => scopedEmitter.emit({
3504
+ ...delivery,
3505
+ ...delivery.signingProfile === void 0 && profileBindings.some((binding) => binding.url === delivery.url) && {
3506
+ signingProfile: profileBindings.find((binding) => binding.url === delivery.url).profile
3507
+ }
3508
+ });
3338
3509
  }
3339
3510
  const handlerParams = notificationFailureRows.size === 0 ? params : {
3340
3511
  ...params,
@@ -3812,7 +3983,14 @@ function createAdcpServer(config) {
3812
3983
  }
3813
3984
  if (responseValidationMode !== "off" && !isErrorResponse(formatted)) {
3814
3985
  const payload = formatted.structuredContent;
3815
- const outcome = validateFrameworkPayload(toolName, "response", payload, requestRelease.validationVersion);
3986
+ const outcome = validateFrameworkPayload(
3987
+ toolName,
3988
+ "response",
3989
+ payload,
3990
+ requestRelease.validationVersion,
3991
+ void 0,
3992
+ !!config.identity33 && isAdcpVersionAtLeast(requestRelease.wireVersion, "3.3")
3993
+ );
3816
3994
  if (!outcome.valid) {
3817
3995
  logger.warn(
3818
3996
  `Schema validation warning (response) for ${toolName}: ${formatIssues(outcome.issues, 3, { rootSchemaId: outcome.schemaId })}`,
@@ -4097,6 +4275,8 @@ function createAdcpServer(config) {
4097
4275
  _meta: frameworkToolMeta
4098
4276
  },
4099
4277
  (async (params, extra) => {
4278
+ const identityError = await authorizeAuxiliaryIdentityTool("get_task_status", params, extra);
4279
+ if (identityError) return finalizeProtocolTaskToolResponse("get_task_status", params ?? {}, identityError);
4100
4280
  const credentialError = taskToolCredentialPolicyError("get_task_status", params ?? {}, extra);
4101
4281
  if (credentialError) {
4102
4282
  return finalizeProtocolTaskToolResponse("get_task_status", params ?? {}, credentialError, {
@@ -4183,6 +4363,8 @@ function createAdcpServer(config) {
4183
4363
  _meta: frameworkToolMeta
4184
4364
  },
4185
4365
  (async (params, extra) => {
4366
+ const identityError = await authorizeAuxiliaryIdentityTool("list_tasks", params, extra);
4367
+ if (identityError) return finalizeProtocolTaskToolResponse("list_tasks", params ?? {}, identityError);
4186
4368
  const credentialError = taskToolCredentialPolicyError("list_tasks", params ?? {}, extra);
4187
4369
  if (credentialError) {
4188
4370
  return finalizeProtocolTaskToolResponse("list_tasks", params ?? {}, credentialError, { echoContext: false });
@@ -4299,6 +4481,8 @@ function createAdcpServer(config) {
4299
4481
  );
4300
4482
  };
4301
4483
  const wrappedHandler = (async (...args) => {
4484
+ const identityError = await authorizeAuxiliaryIdentityTool(customName, args[0], args[args.length - 1]);
4485
+ if (identityError) return finalizeCustomResponse(identityError);
4302
4486
  const params = isPlainObject(args[0]) ? args[0] : {};
4303
4487
  const selectedRelease = selectServedAdcpRelease(params, capConfig, adcpVersion, defaultAdcpVersion);
4304
4488
  if (isMcpToolResponse(selectedRelease)) return finalizeCustomResponse(selectedRelease);
@@ -4417,6 +4601,7 @@ function createAdcpServer(config) {
4417
4601
  ...capConfig.account.defaultBilling && { default_billing: capConfig.account.defaultBilling },
4418
4602
  required_for_products: capConfig.account.requiredForProducts ?? false,
4419
4603
  sandbox: capConfig.account.sandbox ?? false,
4604
+ ...identityOnboarding && { agent_onboarding: identityOnboarding },
4420
4605
  ...capConfig.account.changeFeed !== void 0 && { change_feed: capConfig.account.changeFeed }
4421
4606
  };
4422
4607
  }
@@ -4458,7 +4643,15 @@ function createAdcpServer(config) {
4458
4643
  ...capabilitiesData.webhook_signing,
4459
4644
  supported: true,
4460
4645
  profile,
4461
- algorithms: [algorithm],
4646
+ algorithms: [
4647
+ .../* @__PURE__ */ new Set([
4648
+ algorithm,
4649
+ ...webhooks.webBotAuth ? [
4650
+ ("privateKey" in webhooks.webBotAuth.key ? webhooks.webBotAuth.key.privateKey.crv : webhooks.webBotAuth.key.publicKey.crv) === "P-256" ? "ecdsa-p256-sha256" : "ed25519"
4651
+ ] : []
4652
+ ])
4653
+ ],
4654
+ ...webhooks.webBotAuth && { profiles: ["adcp/webhook-signing/v1", "web-bot-auth"] },
4462
4655
  legacy_hmac_fallback: capabilitiesData.webhook_signing?.legacy_hmac_fallback ?? false,
4463
4656
  delivery_retry_horizon_seconds: webhooks.deliveryRetryHorizonSeconds ?? 86400
4464
4657
  };
@@ -4504,6 +4697,36 @@ function createAdcpServer(config) {
4504
4697
  ];
4505
4698
  }
4506
4699
  capabilitiesData.library_version = `@adcp/client@${LIBRARY_VERSION}`;
4700
+ async function authorizeAuxiliaryIdentityTool(toolName, params, extra) {
4701
+ const failure = getWebBotAuthAuthorizationFailure(extra?.authInfo?.extra);
4702
+ if (failure) return webBotAuthToolFailure(failure, servedAdcpVersion);
4703
+ if (!config.identity33) return void 0;
4704
+ try {
4705
+ await config.identity33.authorize(
4706
+ withImmutableServedAdcpVersion(
4707
+ { toolName, stateStore, authInfo: extra?.authInfo, logger },
4708
+ adcpVersion
4709
+ ),
4710
+ toolName,
4711
+ params
4712
+ );
4713
+ } catch (error) {
4714
+ if (error instanceof TrustRecordUnavailableError)
4715
+ return adcpError("SERVICE_UNAVAILABLE", { message: error.message, recovery: "transient" });
4716
+ if (error instanceof IdentityAuthorizationError)
4717
+ return adcpError("PERMISSION_DENIED", {
4718
+ message: error.message,
4719
+ ...error.details && { details: { ...error.details } }
4720
+ });
4721
+ if (error instanceof AdcpError) return projectThrownAdcpError(error);
4722
+ return adcpError("PERMISSION_DENIED", { message: "Agent authorization failed" });
4723
+ }
4724
+ return void 0;
4725
+ }
4726
+ for (const field of ["request_signing", "webhook_signing"]) {
4727
+ const signing = capabilitiesData[field];
4728
+ if (signing?.profiles?.includes("web-bot-auth")) signing.wba_draft_revision = WEB_BOT_AUTH_DRAFT_REVISION;
4729
+ }
4507
4730
  server.registerTool(
4508
4731
  "get_adcp_capabilities",
4509
4732
  {
@@ -4512,6 +4735,10 @@ function createAdcpServer(config) {
4512
4735
  _meta: frameworkToolMeta
4513
4736
  },
4514
4737
  (async (params, extra = {}) => {
4738
+ const authorizationFailure = getWebBotAuthAuthorizationFailure(extra.authInfo?.extra);
4739
+ if (authorizationFailure) return webBotAuthToolFailure(authorizationFailure, servedAdcpVersion);
4740
+ const identityError = await authorizeAuxiliaryIdentityTool("get_adcp_capabilities", params, extra);
4741
+ if (identityError) return identityError;
4515
4742
  const callRequestValidationMode = effectiveRequestValidationMode(extra);
4516
4743
  const requestParams = isPlainObject(params) ? params : {};
4517
4744
  const releaseSelection = selectServedAdcpRelease(requestParams, capConfig, adcpVersion, defaultAdcpVersion);
@@ -4646,7 +4873,12 @@ function createAdcpServer(config) {
4646
4873
  delete validationPayload.media_buy.proposal_refinement;
4647
4874
  delete validationPayload.media_buy.lifecycle_tools;
4648
4875
  }
4649
- const responseOutcome = validateResponse("get_adcp_capabilities", validationPayload, release.validationVersion);
4876
+ const responseOutcome = config.identity33 && isAdcpVersionAtLeast(release.wireVersion, "3.3") ? validateIdentity33Payload(
4877
+ "get_adcp_capabilities",
4878
+ "response",
4879
+ validationPayload,
4880
+ release.validationVersion
4881
+ ) : validateResponse("get_adcp_capabilities", validationPayload, release.validationVersion);
4650
4882
  if (!responseOutcome.valid) {
4651
4883
  logger.warn(
4652
4884
  `Schema validation warning (response) for get_adcp_capabilities: ${formatIssues(responseOutcome.issues, 3, { rootSchemaId: responseOutcome.schemaId })}`,
@@ -4872,6 +5104,30 @@ function createAdcpServer(config) {
4872
5104
  protocols,
4873
5105
  signedRequests: signedRequestsState
4874
5106
  });
5107
+ if (config.identity33) {
5108
+ for (const method of [
5109
+ "initialize",
5110
+ "tools/list",
5111
+ "tools/call",
5112
+ "resources/list",
5113
+ "resources/read",
5114
+ "prompts/list",
5115
+ "prompts/get",
5116
+ "tasks/get",
5117
+ "tasks/list",
5118
+ "tasks/cancel",
5119
+ "tasks/result"
5120
+ ])
5121
+ wrapSdkRequestHandler(
5122
+ server,
5123
+ method,
5124
+ (original, request, extra) => withIdentity33SchemaScope(() => original(request, extra))
5125
+ );
5126
+ }
5127
+ wrapSdkRequestHandler(server, "tools/call", (original, request, extra) => {
5128
+ const failure = getWebBotAuthAuthorizationFailure(extra?.authInfo?.extra);
5129
+ return failure ? webBotAuthToolFailure(failure, servedAdcpVersion) : original(request, extra);
5130
+ });
4875
5131
  return wrapped;
4876
5132
  }
4877
5133
  export {
@@ -340,6 +340,8 @@ export interface ResolveContext {
340
340
  * before the platform method runs; treat fields the buyer sent as
341
341
  * authoritative, but expect framework-injected entities (e.g.
342
342
  * hydrated product / media-buy refs) to be visible here too.
343
+ * Account-sync guard lookups and upsert receive independent input
344
+ * copies so callback normalization cannot rewrite framework checks.
343
345
  * - **Buyer-controlled untrusted data.** Free-text fields (`brief`,
344
346
  * `message`, creative snippets, etc.) are attacker-controlled.
345
347
  * Don't log `ctx.input` wholesale — secret fields like
@@ -374,6 +376,18 @@ export interface AccountToolContext<TCtxMeta = Record<string, unknown>> extends
374
376
  /** Resolved Account from `accounts.resolve()`. Populated by the framework before dispatch. */
375
377
  account: Account<TCtxMeta>;
376
378
  }
379
+ /** Pre-write snapshots aligned with the accepted entries passed to `upsert`. */
380
+ export interface AccountUpsertContext<TCtxMeta = Record<string, unknown>> extends ResolveContext {
381
+ /** Null for an unresolved or ID-keyed entry. Lookup uses `provisioning: false`. */
382
+ readonly existing?: readonly (Account<TCtxMeta> | null)[];
383
+ }
384
+ /** A sync/list contract violation, delivered only to the seller. */
385
+ export interface AccountSyncDiagnostic {
386
+ readonly code: 'ACCOUNT_SYNC_IDEMPOTENCY_VIOLATION' | 'ACCOUNT_SYNC_PAYMENT_TERMS_MISMATCH' | 'ACCOUNT_SYNC_BILLING_MISMATCH' | 'ACCOUNT_SYNC_LOOKUP_UNSUPPORTED' | 'ACCOUNT_BILLING_FIELDS_MISSING';
387
+ readonly toolName: 'sync_accounts' | 'list_accounts';
388
+ /** Original request index for sync; page index for list. */
389
+ readonly index: number;
390
+ }
377
391
  /**
378
392
  * Request context for tools that can omit an `account` field —
379
393
  * `preview_creative`, `list_creative_formats` (optional since rc.7), and
@@ -469,6 +483,15 @@ export declare function normalizeAccountResolution(resolution: AccountResolution
469
483
  */
470
484
  export declare function isAccountResolutionMode(value: unknown): value is AccountResolutionMode;
471
485
  export interface AccountStore<TCtxMeta = Record<string, unknown>> {
486
+ /**
487
+ * Convert sync contract violations to per-row failures. Default: diagnostics only.
488
+ * This is post-write response validation, not a transaction or rollback.
489
+ * For accept-or-reject guarantees, upsert must check these contracts before
490
+ * committing too (createKeyedAccountStore does so for its own backend).
491
+ */
492
+ readonly strictIdempotency?: boolean;
493
+ /** Server-side diagnostics; never includes credentials or account metadata. Async hooks are fire-and-forget, with failures isolated from dispatch. */
494
+ readonly onDiagnostic?: (diagnostic: AccountSyncDiagnostic) => void;
472
495
  /**
473
496
  * How buyers reference accounts on this platform. Three onboarding models,
474
497
  * aligned with the account-reference taxonomy clarified upstream in
@@ -640,7 +663,7 @@ export interface AccountStore<TCtxMeta = Record<string, unknown>> {
640
663
  * verified `agent_url` from `credential.kind === 'http_sig'` when
641
664
  * `agentRegistry` is not configured).
642
665
  */
643
- upsert?(refs: AccountReference[], ctx?: ResolveContext): Promise<SyncAccountsHandlerResult>;
666
+ upsert?(refs: AccountReference[], ctx?: AccountUpsertContext<TCtxMeta>): Promise<SyncAccountsHandlerResult>;
644
667
  /**
645
668
  * sync_governance API surface. Buyers register governance agent endpoints
646
669
  * per-account; the seller persists the binding and consults the agents
@@ -340,6 +340,8 @@ export interface ResolveContext {
340
340
  * before the platform method runs; treat fields the buyer sent as
341
341
  * authoritative, but expect framework-injected entities (e.g.
342
342
  * hydrated product / media-buy refs) to be visible here too.
343
+ * Account-sync guard lookups and upsert receive independent input
344
+ * copies so callback normalization cannot rewrite framework checks.
343
345
  * - **Buyer-controlled untrusted data.** Free-text fields (`brief`,
344
346
  * `message`, creative snippets, etc.) are attacker-controlled.
345
347
  * Don't log `ctx.input` wholesale — secret fields like
@@ -374,6 +376,18 @@ export interface AccountToolContext<TCtxMeta = Record<string, unknown>> extends
374
376
  /** Resolved Account from `accounts.resolve()`. Populated by the framework before dispatch. */
375
377
  account: Account<TCtxMeta>;
376
378
  }
379
+ /** Pre-write snapshots aligned with the accepted entries passed to `upsert`. */
380
+ export interface AccountUpsertContext<TCtxMeta = Record<string, unknown>> extends ResolveContext {
381
+ /** Null for an unresolved or ID-keyed entry. Lookup uses `provisioning: false`. */
382
+ readonly existing?: readonly (Account<TCtxMeta> | null)[];
383
+ }
384
+ /** A sync/list contract violation, delivered only to the seller. */
385
+ export interface AccountSyncDiagnostic {
386
+ readonly code: 'ACCOUNT_SYNC_IDEMPOTENCY_VIOLATION' | 'ACCOUNT_SYNC_PAYMENT_TERMS_MISMATCH' | 'ACCOUNT_SYNC_BILLING_MISMATCH' | 'ACCOUNT_SYNC_LOOKUP_UNSUPPORTED' | 'ACCOUNT_BILLING_FIELDS_MISSING';
387
+ readonly toolName: 'sync_accounts' | 'list_accounts';
388
+ /** Original request index for sync; page index for list. */
389
+ readonly index: number;
390
+ }
377
391
  /**
378
392
  * Request context for tools that can omit an `account` field —
379
393
  * `preview_creative`, `list_creative_formats` (optional since rc.7), and
@@ -469,6 +483,15 @@ export declare function normalizeAccountResolution(resolution: AccountResolution
469
483
  */
470
484
  export declare function isAccountResolutionMode(value: unknown): value is AccountResolutionMode;
471
485
  export interface AccountStore<TCtxMeta = Record<string, unknown>> {
486
+ /**
487
+ * Convert sync contract violations to per-row failures. Default: diagnostics only.
488
+ * This is post-write response validation, not a transaction or rollback.
489
+ * For accept-or-reject guarantees, upsert must check these contracts before
490
+ * committing too (createKeyedAccountStore does so for its own backend).
491
+ */
492
+ readonly strictIdempotency?: boolean;
493
+ /** Server-side diagnostics; never includes credentials or account metadata. Async hooks are fire-and-forget, with failures isolated from dispatch. */
494
+ readonly onDiagnostic?: (diagnostic: AccountSyncDiagnostic) => void;
472
495
  /**
473
496
  * How buyers reference accounts on this platform. Three onboarding models,
474
497
  * aligned with the account-reference taxonomy clarified upstream in
@@ -640,7 +663,7 @@ export interface AccountStore<TCtxMeta = Record<string, unknown>> {
640
663
  * verified `agent_url` from `credential.kind === 'http_sig'` when
641
664
  * `agentRegistry` is not configured).
642
665
  */
643
- upsert?(refs: AccountReference[], ctx?: ResolveContext): Promise<SyncAccountsHandlerResult>;
666
+ upsert?(refs: AccountReference[], ctx?: AccountUpsertContext<TCtxMeta>): Promise<SyncAccountsHandlerResult>;
644
667
  /**
645
668
  * sync_governance API surface. Buyers register governance agent endpoints
646
669
  * per-account; the seller persists the binding and consults the agents
@@ -19,7 +19,7 @@ export type { CursorPage, CursorRequest } from './pagination.mjs';
19
19
  export { publishStatusChange, setStatusChangeBus, getStatusChangeBus, createInMemoryStatusChangeBus, type StatusChange, type StatusChangeBus, type StatusChangeResourceType, type StatusChangeListener, type PublishStatusChangeOpts, } from './status-changes.mjs';
20
20
  export type { DecisioningCapabilities, ComplianceTestingCapabilities, CreativeAgentRef, TargetingCapabilities, TargetingPostalAreaSupport, ReportingCapabilities, } from './capabilities.mjs';
21
21
  export { normalizePostalAreaSupport, normalizeTargetingCapabilities } from './capabilities.mjs';
22
- export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountToolContext, ResolvedAuthInfo, } from './account.mjs';
22
+ export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountUpsertContext, AccountSyncDiagnostic, AccountToolContext, ResolvedAuthInfo, } from './account.mjs';
23
23
  export { AccountNotFoundError, isAccountResolutionMode, normalizeAccountResolution, refAccountId, refHasNaturalKey, } from './account.mjs';
24
24
  export { createTenantStore, narrowAccountRef } from './tenant-store.mjs';
25
25
  export type { TenantStoreConfig } from './tenant-store.mjs';
@@ -19,7 +19,7 @@ export type { CursorPage, CursorRequest } from './pagination';
19
19
  export { publishStatusChange, setStatusChangeBus, getStatusChangeBus, createInMemoryStatusChangeBus, type StatusChange, type StatusChangeBus, type StatusChangeResourceType, type StatusChangeListener, type PublishStatusChangeOpts, } from './status-changes';
20
20
  export type { DecisioningCapabilities, ComplianceTestingCapabilities, CreativeAgentRef, TargetingCapabilities, TargetingPostalAreaSupport, ReportingCapabilities, } from './capabilities';
21
21
  export { normalizePostalAreaSupport, normalizeTargetingCapabilities } from './capabilities';
22
- export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountToolContext, ResolvedAuthInfo, } from './account';
22
+ export type { Account, AccountResolutionMode, CanonicalAccountResolutionMode, AuthPrincipal, AccountStore, AccountFilter, ListAccountsPayload, ListAccountChangesPayload, SyncAccountsPayload, SyncAccountsSuccessPayload, SyncAccountsRow, SyncAccountsResultRow, SyncGovernancePayload, SyncGovernanceSuccessPayload, SyncGovernanceRow, ReportUsagePayload, GetAccountFinancialsPayload, GetAccountFinancialsSuccessPayload, ListAccountsHandlerResult, ListAccountChangesHandlerResult, SyncAccountsHandlerResult, SyncGovernanceHandlerResult, ReportUsageHandlerResult, GetAccountFinancialsHandlerResult, AdcpAccountStatus, ResolveContext, AccountUpsertContext, AccountSyncDiagnostic, AccountToolContext, ResolvedAuthInfo, } from './account';
23
23
  export { AccountNotFoundError, isAccountResolutionMode, normalizeAccountResolution, refAccountId, refHasNaturalKey, } from './account';
24
24
  export { createTenantStore, narrowAccountRef } from './tenant-store';
25
25
  export type { TenantStoreConfig } from './tenant-store';
@@ -1,53 +1,3 @@
1
- /**
2
- * Build an `AdcpServer` from a `DecisioningPlatform` impl.
3
- *
4
- * v6.0 alpha entry point. Translates the per-specialism platform interface
5
- * into the framework's existing handler-style config and delegates to
6
- * `createAdcpServer()`. This means every framework primitive — idempotency,
7
- * RFC 9421 signing, governance, schema validation, state store, MCP/A2A
8
- * wire mapping, sandbox boundary — applies unchanged. The new code is the
9
- * adapter shim, not a forked runtime.
10
- *
11
- * **Adopter shape (unified hybrid):** each HITL-eligible tool is a single
12
- * method. The method returns the wire success arm (sync fast path) OR
13
- * `ctx.handoffToTask(fn)` to promote the call to a background task (HITL
14
- * slow path). Adopters branch per-call; framework detects the `TaskHandoff`
15
- * marker and dispatches accordingly:
16
- *
17
- * - Sync path: framework awaits the return value in foreground; projects
18
- * it to the wire success arm. `throw new AdcpError(...)` projects to
19
- * the wire `adcp_error` envelope.
20
- * - HITL path: framework detects the `TaskHandoff` marker, allocates
21
- * `taskId`, returns the submitted envelope to the buyer immediately,
22
- * then runs the handoff function in background. The function's return
23
- * value becomes the task's terminal `result`; `taskCtx.reject(...)`
24
- * becomes a business `rejected` result, and thrown `AdcpError` becomes
25
- * the terminal `error`.
26
- *
27
- * Generic thrown errors (`Error`, `TypeError`) fall through to the
28
- * framework's `SERVICE_UNAVAILABLE` mapping.
29
- *
30
- * **Wired surface (6.0):** `SalesPlatform` (14 tools — 3 required core +
31
- * 11 optional; unified hybrid on `create_media_buy` / `sync_creatives`),
32
- * `CreativeBuilderPlatform` (build_creative / sync_creatives unified
33
- * hybrid, optional preview_creative sync-only, optional refineCreative),
34
- * `AudiencePlatform.syncAudiences`, `SignalsPlatform` (get_signals /
35
- * activate_signal), `AccountStore` (reportUsage, getAccountFinancials),
36
- * `ContentStandardsPlatform`, `CampaignGovernancePlatform`,
37
- * `TenantRegistry` (multi-tenant health), `createPostgresTaskRegistry`,
38
- * `tasks/get` wire handler, per-server + module-level `publishStatusChange`.
39
- *
40
- * **Still deferred (rc.1+):** MCP Resources subscription projection for
41
- * `publishStatusChange`. The no-account tool surface (`preview_creative`,
42
- * `list_creative_formats`, `provide_performance_feedback`) is now typed
43
- * via `NoAccountCtx<TCtxMeta>` — handlers receive `ctx.account: Account |
44
- * undefined` and must narrow before reading `ctx_metadata`.
45
- *
46
- * Status: Preview / 6.0. Exported from the canonical `@adcp/sdk/server`
47
- * entry point; the decisioning implementation remains preview until GA.
48
- *
49
- * @public
50
- */
51
1
  import type { AdcpServer } from '../../adcp-server.mjs';
52
2
  import { type AdcpServerConfig, type HandlerContext } from '../../create-adcp-server.mjs';
53
3
  import type { DecisioningPlatform, RequiredPlatformsFor, RequiredCapabilitiesFor } from '../platform.mjs';