@adcp/sdk 15.9.0 → 16.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) 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 +16 -2
  12. package/dist/lib/core/SingleAgentClient.d.ts +16 -2
  13. package/dist/lib/core/SingleAgentClient.js +259 -62
  14. package/dist/lib/core/SingleAgentClient.mjs +261 -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/index.d.mts +10 -0
  28. package/dist/lib/identity-3.3/index.d.ts +10 -0
  29. package/dist/lib/identity-3.3/index.js +75 -0
  30. package/dist/lib/identity-3.3/index.mjs +46 -0
  31. package/dist/lib/identity-3.3/lifecycle.d.mts +113 -0
  32. package/dist/lib/identity-3.3/lifecycle.d.ts +113 -0
  33. package/dist/lib/identity-3.3/lifecycle.js +267 -0
  34. package/dist/lib/identity-3.3/lifecycle.mjs +240 -0
  35. package/dist/lib/identity-3.3/revocation.d.mts +50 -0
  36. package/dist/lib/identity-3.3/revocation.d.ts +50 -0
  37. package/dist/lib/identity-3.3/revocation.js +238 -0
  38. package/dist/lib/identity-3.3/revocation.mjs +216 -0
  39. package/dist/lib/identity-3.3/schemas.draft.d.mts +2472 -0
  40. package/dist/lib/identity-3.3/schemas.draft.d.ts +2472 -0
  41. package/dist/lib/identity-3.3/schemas.draft.js +1448 -0
  42. package/dist/lib/identity-3.3/schemas.draft.mjs +1428 -0
  43. package/dist/lib/identity-3.3/server.d.mts +34 -0
  44. package/dist/lib/identity-3.3/server.d.ts +34 -0
  45. package/dist/lib/identity-3.3/server.js +219 -0
  46. package/dist/lib/identity-3.3/server.mjs +194 -0
  47. package/dist/lib/identity-3.3/store.d.mts +24 -0
  48. package/dist/lib/identity-3.3/store.d.ts +24 -0
  49. package/dist/lib/identity-3.3/store.js +191 -0
  50. package/dist/lib/identity-3.3/store.mjs +169 -0
  51. package/dist/lib/identity-3.3/trust.d.mts +94 -0
  52. package/dist/lib/identity-3.3/trust.d.ts +94 -0
  53. package/dist/lib/identity-3.3/trust.js +278 -0
  54. package/dist/lib/identity-3.3/trust.mjs +239 -0
  55. package/dist/lib/identity-3.3/types.d.mts +127 -0
  56. package/dist/lib/identity-3.3/types.d.ts +127 -0
  57. package/dist/lib/identity-3.3/types.js +16 -0
  58. package/dist/lib/identity-3.3/types.mjs +0 -0
  59. package/dist/lib/identity-3.3/validation.d.mts +2 -0
  60. package/dist/lib/identity-3.3/validation.d.ts +2 -0
  61. package/dist/lib/identity-3.3/validation.js +125 -0
  62. package/dist/lib/identity-3.3/validation.mjs +91 -0
  63. package/dist/lib/index.d.mts +1 -1
  64. package/dist/lib/index.d.ts +1 -1
  65. package/dist/lib/reporting/azure/index.d.mts +5 -0
  66. package/dist/lib/reporting/azure/index.d.ts +5 -0
  67. package/dist/lib/reporting/azure/index.js +26 -7
  68. package/dist/lib/reporting/azure/index.mjs +26 -7
  69. package/dist/lib/reporting/bigquery/index.d.mts +80 -25
  70. package/dist/lib/reporting/bigquery/index.d.ts +80 -25
  71. package/dist/lib/reporting/bigquery/index.js +184 -81
  72. package/dist/lib/reporting/bigquery/index.mjs +182 -80
  73. package/dist/lib/reporting/gcs/adapter.d.mts +8 -1
  74. package/dist/lib/reporting/gcs/adapter.d.ts +8 -1
  75. package/dist/lib/reporting/gcs/errors.d.mts +6 -0
  76. package/dist/lib/reporting/gcs/errors.d.ts +6 -0
  77. package/dist/lib/reporting/gcs/fence.d.mts +5 -0
  78. package/dist/lib/reporting/gcs/fence.d.ts +5 -0
  79. package/dist/lib/reporting/gcs/index.d.mts +9 -0
  80. package/dist/lib/reporting/gcs/index.d.ts +9 -0
  81. package/dist/lib/reporting/gcs/reader.d.mts +27 -3
  82. package/dist/lib/reporting/gcs/reader.d.ts +27 -3
  83. package/dist/lib/reporting/gcs/row-provider.d.mts +7 -0
  84. package/dist/lib/reporting/gcs/row-provider.d.ts +7 -0
  85. package/dist/lib/reporting/gcs/row-provider.js +34 -14
  86. package/dist/lib/reporting/gcs/row-provider.mjs +34 -14
  87. package/dist/lib/reporting/ledger/change-feed.d.mts +22 -1
  88. package/dist/lib/reporting/ledger/change-feed.d.ts +22 -1
  89. package/dist/lib/reporting/ledger/index.d.mts +11 -0
  90. package/dist/lib/reporting/ledger/index.d.ts +11 -0
  91. package/dist/lib/reporting/ledger/managed-postgres.d.mts +8 -0
  92. package/dist/lib/reporting/ledger/managed-postgres.d.ts +8 -0
  93. package/dist/lib/reporting/ledger/managed-router.d.mts +27 -2
  94. package/dist/lib/reporting/ledger/managed-router.d.ts +27 -2
  95. package/dist/lib/reporting/ledger/managed.d.mts +86 -6
  96. package/dist/lib/reporting/ledger/managed.d.ts +86 -6
  97. package/dist/lib/reporting/ledger/notification-activity.d.mts +65 -3
  98. package/dist/lib/reporting/ledger/notification-activity.d.ts +65 -3
  99. package/dist/lib/reporting/ledger/object-writes.d.mts +64 -5
  100. package/dist/lib/reporting/ledger/object-writes.d.ts +64 -5
  101. package/dist/lib/reporting/ledger/postgres.d.mts +43 -9
  102. package/dist/lib/reporting/ledger/postgres.d.ts +43 -9
  103. package/dist/lib/reporting/ledger/postgres.js +43 -27
  104. package/dist/lib/reporting/ledger/postgres.mjs +43 -27
  105. package/dist/lib/reporting/ledger/row-encoding.d.mts +92 -6
  106. package/dist/lib/reporting/ledger/row-encoding.d.ts +92 -6
  107. package/dist/lib/reporting/ledger/row-encoding.js +8 -4
  108. package/dist/lib/reporting/ledger/row-encoding.mjs +6 -3
  109. package/dist/lib/reporting/ledger/row-storage-errors.d.mts +11 -1
  110. package/dist/lib/reporting/ledger/row-storage-errors.d.ts +11 -1
  111. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +19 -1
  112. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +19 -1
  113. package/dist/lib/reporting/ledger/row-storage-migration.js +133 -18
  114. package/dist/lib/reporting/ledger/row-storage-migration.mjs +133 -18
  115. package/dist/lib/reporting/ledger/row-storage-object.d.mts +103 -12
  116. package/dist/lib/reporting/ledger/row-storage-object.d.ts +103 -12
  117. package/dist/lib/reporting/ledger/row-storage-object.js +106 -31
  118. package/dist/lib/reporting/ledger/row-storage-object.mjs +104 -31
  119. package/dist/lib/reporting/ledger/row-storage.d.mts +87 -20
  120. package/dist/lib/reporting/ledger/row-storage.d.ts +87 -20
  121. package/dist/lib/reporting/ledger/row-storage.js +126 -66
  122. package/dist/lib/reporting/ledger/row-storage.mjs +129 -67
  123. package/dist/lib/reporting/ledger/schedule.d.mts +13 -0
  124. package/dist/lib/reporting/ledger/schedule.d.ts +13 -0
  125. package/dist/lib/reporting/ledger/schedule.js +24 -0
  126. package/dist/lib/reporting/ledger/schedule.mjs +23 -0
  127. package/dist/lib/reporting/ledger/types.d.mts +23 -1
  128. package/dist/lib/reporting/ledger/types.d.ts +23 -1
  129. package/dist/lib/reporting/s3/index.d.mts +5 -0
  130. package/dist/lib/reporting/s3/index.d.ts +5 -0
  131. package/dist/lib/reporting/s3/index.js +37 -14
  132. package/dist/lib/reporting/s3/index.mjs +37 -14
  133. package/dist/lib/reporting/service/index.d.mts +10 -0
  134. package/dist/lib/reporting/service/index.d.ts +10 -0
  135. package/dist/lib/reporting/service/maintenance.d.mts +28 -2
  136. package/dist/lib/reporting/service/maintenance.d.ts +28 -2
  137. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  138. package/dist/lib/server/account-sync-contract.d.mts +14 -0
  139. package/dist/lib/server/account-sync-contract.d.ts +14 -0
  140. package/dist/lib/server/account-sync-contract.js +225 -0
  141. package/dist/lib/server/account-sync-contract.mjs +197 -0
  142. package/dist/lib/server/adcp-server.js +5 -0
  143. package/dist/lib/server/adcp-server.mjs +10 -0
  144. package/dist/lib/server/auth-signature.d.mts +10 -0
  145. package/dist/lib/server/auth-signature.d.ts +10 -0
  146. package/dist/lib/server/auth-signature.js +61 -2
  147. package/dist/lib/server/auth-signature.mjs +65 -2
  148. package/dist/lib/server/auth.d.mts +6 -0
  149. package/dist/lib/server/auth.d.ts +6 -0
  150. package/dist/lib/server/auth.js +6 -0
  151. package/dist/lib/server/auth.mjs +6 -0
  152. package/dist/lib/server/create-adcp-server.d.mts +19 -5
  153. package/dist/lib/server/create-adcp-server.d.ts +19 -5
  154. package/dist/lib/server/create-adcp-server.js +238 -19
  155. package/dist/lib/server/create-adcp-server.mjs +240 -10
  156. package/dist/lib/server/decisioning/account.d.mts +24 -1
  157. package/dist/lib/server/decisioning/account.d.ts +24 -1
  158. package/dist/lib/server/decisioning/index.d.mts +1 -1
  159. package/dist/lib/server/decisioning/index.d.ts +1 -1
  160. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +0 -50
  161. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +0 -50
  162. package/dist/lib/server/decisioning/runtime/from-platform.js +61 -11
  163. package/dist/lib/server/decisioning/runtime/from-platform.mjs +65 -12
  164. package/dist/lib/server/index.d.mts +2 -0
  165. package/dist/lib/server/index.d.ts +2 -0
  166. package/dist/lib/server/index.js +12 -0
  167. package/dist/lib/server/index.mjs +12 -0
  168. package/dist/lib/server/notification-subscriptions/runtime.js +9 -1
  169. package/dist/lib/server/notification-subscriptions/runtime.mjs +9 -1
  170. package/dist/lib/server/notification-subscriptions/types.d.mts +5 -0
  171. package/dist/lib/server/notification-subscriptions/types.d.ts +5 -0
  172. package/dist/lib/server/principal/types.d.mts +1 -1
  173. package/dist/lib/server/principal/types.d.ts +1 -1
  174. package/dist/lib/server/serve.js +5 -0
  175. package/dist/lib/server/serve.mjs +5 -0
  176. package/dist/lib/server/webhook-delivery/recovery.d.mts +1 -0
  177. package/dist/lib/server/webhook-delivery/recovery.d.ts +1 -0
  178. package/dist/lib/server/webhook-delivery/recovery.js +4 -0
  179. package/dist/lib/server/webhook-delivery/recovery.mjs +4 -0
  180. package/dist/lib/server/webhook-emitter.d.mts +10 -0
  181. package/dist/lib/server/webhook-emitter.d.ts +10 -0
  182. package/dist/lib/server/webhook-emitter.js +22 -0
  183. package/dist/lib/server/webhook-emitter.mjs +22 -0
  184. package/dist/lib/signing/agent-context.d.mts +0 -5
  185. package/dist/lib/signing/agent-context.d.ts +0 -5
  186. package/dist/lib/signing/agent-context.js +9 -1
  187. package/dist/lib/signing/agent-context.mjs +9 -1
  188. package/dist/lib/signing/agent-fetch.js +27 -2
  189. package/dist/lib/signing/agent-fetch.mjs +32 -2
  190. package/dist/lib/signing/agent-resolver/canonicalize.d.mts +10 -15
  191. package/dist/lib/signing/agent-resolver/canonicalize.d.ts +10 -15
  192. package/dist/lib/signing/agent-resolver/canonicalize.js +17 -5
  193. package/dist/lib/signing/agent-resolver/canonicalize.mjs +16 -5
  194. package/dist/lib/signing/agent-resolver/index.d.mts +1 -0
  195. package/dist/lib/signing/agent-resolver/index.d.ts +1 -0
  196. package/dist/lib/signing/agent-resolver/index.js +5 -0
  197. package/dist/lib/signing/agent-resolver/index.mjs +3 -0
  198. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +3 -2
  199. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +3 -2
  200. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +30 -3
  201. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +30 -3
  202. package/dist/lib/signing/agent-resolver/strict-json.d.mts +2 -2
  203. package/dist/lib/signing/agent-resolver/strict-json.d.ts +2 -2
  204. package/dist/lib/signing/agent-resolver/strict-json.js +5 -3
  205. package/dist/lib/signing/agent-resolver/strict-json.mjs +5 -3
  206. package/dist/lib/signing/brand-jwks.d.mts +2 -2
  207. package/dist/lib/signing/brand-jwks.d.ts +2 -2
  208. package/dist/lib/signing/brand-jwks.js +4 -4
  209. package/dist/lib/signing/brand-jwks.mjs +4 -4
  210. package/dist/lib/signing/client.d.mts +1 -0
  211. package/dist/lib/signing/client.d.ts +1 -0
  212. package/dist/lib/signing/client.js +5 -0
  213. package/dist/lib/signing/client.mjs +3 -0
  214. package/dist/lib/signing/jwks-https.d.mts +1 -1
  215. package/dist/lib/signing/jwks-https.d.ts +1 -1
  216. package/dist/lib/signing/jwks-https.js +1 -1
  217. package/dist/lib/signing/jwks-https.mjs +1 -1
  218. package/dist/lib/signing/jwks.d.mts +11 -3
  219. package/dist/lib/signing/jwks.d.ts +11 -3
  220. package/dist/lib/signing/jwks.js +1 -1
  221. package/dist/lib/signing/jwks.mjs +1 -1
  222. package/dist/lib/signing/parser.d.mts +1 -1
  223. package/dist/lib/signing/parser.d.ts +1 -1
  224. package/dist/lib/signing/parser.js +5 -3
  225. package/dist/lib/signing/parser.mjs +6 -4
  226. package/dist/lib/signing/revocation.d.mts +4 -1
  227. package/dist/lib/signing/revocation.d.ts +4 -1
  228. package/dist/lib/signing/revocation.js +33 -3
  229. package/dist/lib/signing/revocation.mjs +31 -2
  230. package/dist/lib/signing/server.d.mts +1 -1
  231. package/dist/lib/signing/server.d.ts +1 -1
  232. package/dist/lib/signing/server.js +4 -0
  233. package/dist/lib/signing/server.mjs +4 -0
  234. package/dist/lib/signing/types.d.mts +3 -0
  235. package/dist/lib/signing/types.d.ts +3 -0
  236. package/dist/lib/signing/web-bot-auth.d.mts +117 -0
  237. package/dist/lib/signing/web-bot-auth.d.ts +117 -0
  238. package/dist/lib/signing/web-bot-auth.js +660 -0
  239. package/dist/lib/signing/web-bot-auth.mjs +624 -0
  240. package/dist/lib/testing/client.d.mts +1 -4
  241. package/dist/lib/testing/client.d.ts +1 -4
  242. package/dist/lib/testing/client.js +141 -20
  243. package/dist/lib/testing/client.mjs +137 -19
  244. package/dist/lib/testing/compliance/comply.js +29 -10
  245. package/dist/lib/testing/compliance/comply.mjs +37 -11
  246. package/dist/lib/testing/storyboard/account-sync-contract.d.mts +3 -0
  247. package/dist/lib/testing/storyboard/account-sync-contract.d.ts +3 -0
  248. package/dist/lib/testing/storyboard/account-sync-contract.js +79 -0
  249. package/dist/lib/testing/storyboard/account-sync-contract.mjs +55 -0
  250. package/dist/lib/testing/storyboard/default-invariants.js +2 -0
  251. package/dist/lib/testing/storyboard/default-invariants.mjs +2 -0
  252. package/dist/lib/testing/storyboard/runner.js +23 -8
  253. package/dist/lib/testing/storyboard/runner.mjs +24 -8
  254. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  255. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  256. package/dist/lib/types/adcp.d.mts +4 -0
  257. package/dist/lib/types/adcp.d.ts +4 -0
  258. package/dist/lib/types/schemas.generated.d.ts +6 -6
  259. package/dist/lib/utils/capabilities.d.mts +1 -0
  260. package/dist/lib/utils/capabilities.d.ts +1 -0
  261. package/dist/lib/utils/capabilities.js +5 -0
  262. package/dist/lib/utils/capabilities.mjs +5 -0
  263. package/dist/lib/v2/projection/creative-delivery.d.mts +3 -1
  264. package/dist/lib/v2/projection/creative-delivery.d.ts +3 -1
  265. package/dist/lib/v2/projection/creative-delivery.js +26 -10
  266. package/dist/lib/v2/projection/creative-delivery.mjs +26 -10
  267. package/dist/lib/v2/projection/index.d.mts +1 -1
  268. package/dist/lib/v2/projection/index.d.ts +1 -1
  269. package/dist/lib/v2/projection/legacy-routes.d.mts +24 -2
  270. package/dist/lib/v2/projection/legacy-routes.d.ts +24 -2
  271. package/dist/lib/v2/projection/legacy-routes.js +28 -2
  272. package/dist/lib/v2/projection/legacy-routes.mjs +26 -2
  273. package/dist/lib/validation/schema-loader.d.mts +2 -0
  274. package/dist/lib/validation/schema-loader.d.ts +2 -0
  275. package/dist/lib/validation/schema-loader.js +43 -4
  276. package/dist/lib/validation/schema-loader.mjs +39 -3
  277. package/dist/lib/version.d.mts +3 -3
  278. package/dist/lib/version.d.ts +3 -3
  279. package/dist/lib/version.js +3 -3
  280. package/dist/lib/version.mjs +3 -3
  281. package/docs/TYPE-SUMMARY.md +2 -2
  282. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +4 -0
  283. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +1 -1
  284. package/docs/guides/REPORTING-LEDGER.md +132 -46
  285. package/docs/guides/REPORTING-OPERATIONS.md +25 -4
  286. package/docs/guides/REPORTING-STABILITY.md +76 -0
  287. package/docs/guides/account-resolution.md +101 -0
  288. package/docs/llms.txt +3 -2
  289. package/docs/migration-12-to-13.md +7 -0
  290. package/docs/migration-14.x-rc-worksheet.md +4 -4
  291. package/docs/migration-agent-identity-3.3.md +355 -0
  292. package/docs/migration-agent-resolution-3.3.md +5 -0
  293. package/docs/migration-reporting-row-storage-alignment.md +137 -0
  294. package/examples/storyboards/account-sync-contract.yaml +57 -0
  295. package/package.json +15 -1
@@ -112,12 +112,37 @@ function buildAgentSigningFetch(options) {
112
112
  const explicitUpstream = options.upstream;
113
113
  const upstream = explicitUpstream ?? ((input, init) => defaultUpstream()(input, init));
114
114
  const shouldSign = (_url, init) => {
115
- if (carriesWebhookAuthentication(init?.body)) return true;
115
+ if (carriesWebhookAuthentication(init?.body)) {
116
+ if (signing.profile === "web-bot-auth" && !getCapability()?.requestSigning?.profiles?.includes("web-bot-auth"))
117
+ throw new TypeError("Seller did not advertise the Web Bot Auth request signing profile");
118
+ return true;
119
+ }
116
120
  const operation = extractAdcpOperation(init?.body);
117
121
  const entry = getCapability();
118
- return shouldSignOperation(operation, entry?.requestSigning, signing);
122
+ const sign = signing.profile === "web-bot-auth" && !!operation && entry?.requestSigning?.profiles?.includes("web-bot-auth") ? true : shouldSignOperation(operation, entry?.requestSigning, signing);
123
+ if (sign && signing.profile === "web-bot-auth" && !entry?.requestSigning?.profiles?.includes("web-bot-auth"))
124
+ throw new TypeError("Seller did not advertise the Web Bot Auth request signing profile");
125
+ return sign;
119
126
  };
120
127
  const binaryEncoding = (0, import_content_digest.requestSigningEncodingForVersion)(options.adcpVersion ?? import_version.ADCP_VERSION);
128
+ if (signing.profile === "web-bot-auth") {
129
+ const { createWebBotAuthFetch, jwkThumbprint } = require('./web-bot-auth.js');
130
+ if (isProviderSigningConfig(signing)) {
131
+ if (!signing.public_key) throw new TypeError("Web Bot Auth providers require public_key");
132
+ return createWebBotAuthFetch(
133
+ upstream,
134
+ { provider: freezeProviderIdentity(signing.provider), publicKey: signing.public_key },
135
+ { origin: signing.agent_url, shouldSign }
136
+ );
137
+ }
138
+ if (jwkThumbprint(signing.private_key) !== signing.kid)
139
+ throw new TypeError("Web Bot Auth kid must be the public JWK thumbprint");
140
+ return createWebBotAuthFetch(
141
+ upstream,
142
+ { privateKey: signing.private_key },
143
+ { origin: signing.agent_url, shouldSign }
144
+ );
145
+ }
121
146
  const coverContentDigest = (_url, _init) => {
122
147
  if (binaryEncoding === "rfc8941-base64") return true;
123
148
  const entry = getCapability();
@@ -1,3 +1,8 @@
1
+ import { fileURLToPath as __adcpFileURLToPath } from "node:url";
2
+ import { dirname as __adcpDirname } from "node:path";
3
+ import { createRequire as __adcpCreateRequire } from "node:module";
4
+ const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
5
+ const require2 = __adcpCreateRequire(import.meta.url);
1
6
  import { createSigningFetch } from "./fetch.mjs";
2
7
  import { createSigningFetchAsync } from "./fetch-async.mjs";
3
8
  import {
@@ -84,12 +89,37 @@ function buildAgentSigningFetch(options) {
84
89
  const explicitUpstream = options.upstream;
85
90
  const upstream = explicitUpstream ?? ((input, init) => defaultUpstream()(input, init));
86
91
  const shouldSign = (_url, init) => {
87
- if (carriesWebhookAuthentication(init?.body)) return true;
92
+ if (carriesWebhookAuthentication(init?.body)) {
93
+ if (signing.profile === "web-bot-auth" && !getCapability()?.requestSigning?.profiles?.includes("web-bot-auth"))
94
+ throw new TypeError("Seller did not advertise the Web Bot Auth request signing profile");
95
+ return true;
96
+ }
88
97
  const operation = extractAdcpOperation(init?.body);
89
98
  const entry = getCapability();
90
- return shouldSignOperation(operation, entry?.requestSigning, signing);
99
+ const sign = signing.profile === "web-bot-auth" && !!operation && entry?.requestSigning?.profiles?.includes("web-bot-auth") ? true : shouldSignOperation(operation, entry?.requestSigning, signing);
100
+ if (sign && signing.profile === "web-bot-auth" && !entry?.requestSigning?.profiles?.includes("web-bot-auth"))
101
+ throw new TypeError("Seller did not advertise the Web Bot Auth request signing profile");
102
+ return sign;
91
103
  };
92
104
  const binaryEncoding = requestSigningEncodingForVersion(options.adcpVersion ?? ADCP_VERSION);
105
+ if (signing.profile === "web-bot-auth") {
106
+ const { createWebBotAuthFetch, jwkThumbprint } = require2("./web-bot-auth");
107
+ if (isProviderSigningConfig(signing)) {
108
+ if (!signing.public_key) throw new TypeError("Web Bot Auth providers require public_key");
109
+ return createWebBotAuthFetch(
110
+ upstream,
111
+ { provider: freezeProviderIdentity(signing.provider), publicKey: signing.public_key },
112
+ { origin: signing.agent_url, shouldSign }
113
+ );
114
+ }
115
+ if (jwkThumbprint(signing.private_key) !== signing.kid)
116
+ throw new TypeError("Web Bot Auth kid must be the public JWK thumbprint");
117
+ return createWebBotAuthFetch(
118
+ upstream,
119
+ { privateKey: signing.private_key },
120
+ { origin: signing.agent_url, shouldSign }
121
+ );
122
+ }
93
123
  const coverContentDigest = (_url, _init) => {
94
124
  if (binaryEncoding === "rfc8941-base64") return true;
95
125
  const entry = getCapability();
@@ -1,17 +1,3 @@
1
- /**
2
- * Origin canonicalization for the brand_json_url verifier algorithm.
3
- * `security.mdx` §"Quickstart: implement a `brand_json_url`-based verifier"
4
- * step 3 mandates: ASCII-lowercase the host, then convert to IDNA-2008
5
- * A-label (Punycode) form before byte-equality. A non-canonical comparison
6
- * (raw `Example.COM` vs `example.com`, or U-label vs A-label) silently
7
- * rejects legitimate traffic.
8
- *
9
- * Node's WHATWG URL parser already performs IDNA-2008 A-label conversion
10
- * and ASCII-lowercases the host on construction (`new URL('https://Bücher.example/').hostname`
11
- * returns `xn--bcher-kva.example`). We delegate to it rather than vendoring
12
- * an IDNA implementation — the rule is "use the platform's IDNA-2008", not
13
- * "ship our own".
14
- */
15
1
  export declare class CanonicalizeError extends Error {
16
2
  readonly meta: {
17
3
  input: string;
@@ -29,13 +15,22 @@ export declare function canonicalizeHost(host: string): string;
29
15
  * Canonicalize the origin component (scheme + host) of a URL or origin string.
30
16
  * Accepts either a full URL (`https://Example.COM/path`) or a bare origin
31
17
  * (`https://Example.COM`). Output is `https://example.com` form — scheme +
32
- * canonical host, no port when default, no path/query.
18
+ * canonical host, no port when default, no path/query. Authority validation
19
+ * follows the shared URL canonicalization steps 1–4, including removal of
20
+ * one DNS root-label dot and rejection of malformed authorities.
33
21
  *
34
22
  * Used for the step-7 `identity.key_origins` consistency check: the verifier
35
23
  * compares the canonicalized host of the resolved `jwks_uri` against the
36
24
  * canonicalized host of the declared `key_origins.{purpose}` value.
37
25
  */
38
26
  export declare function canonicalizeOrigin(originOrUrl: string): string;
27
+ /**
28
+ * Canonical agent origin, without path, query, fragment, or userinfo.
29
+ * Normalizes producer inputs, including IDN U-labels. Wire comparers must
30
+ * separately reject unnormalized non-ASCII hostnames, as canonicalAgentUrl
31
+ * does. Normalizing a locator does not establish signer identity or authority.
32
+ */
33
+ export declare const canonicalAgentOrigin: typeof canonicalizeOrigin;
39
34
  /**
40
35
  * Compare two origins (scheme + host + port) for byte-equality after
41
36
  * canonicalization. Wrong scheme, wrong port, or wrong host all return false.
@@ -1,17 +1,3 @@
1
- /**
2
- * Origin canonicalization for the brand_json_url verifier algorithm.
3
- * `security.mdx` §"Quickstart: implement a `brand_json_url`-based verifier"
4
- * step 3 mandates: ASCII-lowercase the host, then convert to IDNA-2008
5
- * A-label (Punycode) form before byte-equality. A non-canonical comparison
6
- * (raw `Example.COM` vs `example.com`, or U-label vs A-label) silently
7
- * rejects legitimate traffic.
8
- *
9
- * Node's WHATWG URL parser already performs IDNA-2008 A-label conversion
10
- * and ASCII-lowercases the host on construction (`new URL('https://Bücher.example/').hostname`
11
- * returns `xn--bcher-kva.example`). We delegate to it rather than vendoring
12
- * an IDNA implementation — the rule is "use the platform's IDNA-2008", not
13
- * "ship our own".
14
- */
15
1
  export declare class CanonicalizeError extends Error {
16
2
  readonly meta: {
17
3
  input: string;
@@ -29,13 +15,22 @@ export declare function canonicalizeHost(host: string): string;
29
15
  * Canonicalize the origin component (scheme + host) of a URL or origin string.
30
16
  * Accepts either a full URL (`https://Example.COM/path`) or a bare origin
31
17
  * (`https://Example.COM`). Output is `https://example.com` form — scheme +
32
- * canonical host, no port when default, no path/query.
18
+ * canonical host, no port when default, no path/query. Authority validation
19
+ * follows the shared URL canonicalization steps 1–4, including removal of
20
+ * one DNS root-label dot and rejection of malformed authorities.
33
21
  *
34
22
  * Used for the step-7 `identity.key_origins` consistency check: the verifier
35
23
  * compares the canonicalized host of the resolved `jwks_uri` against the
36
24
  * canonicalized host of the declared `key_origins.{purpose}` value.
37
25
  */
38
26
  export declare function canonicalizeOrigin(originOrUrl: string): string;
27
+ /**
28
+ * Canonical agent origin, without path, query, fragment, or userinfo.
29
+ * Normalizes producer inputs, including IDN U-labels. Wire comparers must
30
+ * separately reject unnormalized non-ASCII hostnames, as canonicalAgentUrl
31
+ * does. Normalizing a locator does not establish signer identity or authority.
32
+ */
33
+ export declare const canonicalAgentOrigin: typeof canonicalizeOrigin;
39
34
  /**
40
35
  * Compare two origins (scheme + host + port) for byte-equality after
41
36
  * canonicalization. Wrong scheme, wrong port, or wrong host all return false.
@@ -19,11 +19,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var canonicalize_exports = {};
20
20
  __export(canonicalize_exports, {
21
21
  CanonicalizeError: () => CanonicalizeError,
22
+ canonicalAgentOrigin: () => canonicalAgentOrigin,
22
23
  canonicalizeHost: () => canonicalizeHost,
23
24
  canonicalizeOrigin: () => canonicalizeOrigin,
24
25
  originsEqual: () => originsEqual
25
26
  });
26
27
  module.exports = __toCommonJS(canonicalize_exports);
28
+ var import_canonicalize = require('../canonicalize.js');
27
29
  class CanonicalizeError extends Error {
28
30
  constructor(message, meta) {
29
31
  super(message);
@@ -44,21 +46,30 @@ function canonicalizeHost(host) {
44
46
  }
45
47
  }
46
48
  function canonicalizeOrigin(originOrUrl) {
49
+ const errorMeta = { input: "[redacted]" };
47
50
  if (typeof originOrUrl !== "string" || originOrUrl.length === 0) {
48
- throw new CanonicalizeError("Empty origin", { input: originOrUrl });
51
+ throw new CanonicalizeError("Empty origin", errorMeta);
52
+ }
53
+ const authority = /^[a-z][a-z0-9+.\-]*:\/\/([^/?#]*)/i.exec(originOrUrl)?.[1];
54
+ if (!authority || /[\u0000-\u0020\u007f\\]/.test(authority)) {
55
+ throw new CanonicalizeError("Malformed origin authority", errorMeta);
49
56
  }
50
57
  let parsed;
51
58
  try {
52
59
  parsed = new URL(originOrUrl);
53
60
  } catch {
54
- throw new CanonicalizeError(`Invalid origin: ${originOrUrl}`, { input: originOrUrl });
61
+ throw new CanonicalizeError("Invalid origin", errorMeta);
55
62
  }
56
63
  if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
57
- throw new CanonicalizeError(`Unsupported scheme: ${parsed.protocol}`, { input: originOrUrl });
64
+ throw new CanonicalizeError("Unsupported origin scheme", errorMeta);
65
+ }
66
+ try {
67
+ return `${parsed.protocol}//${(0, import_canonicalize.canonicalAuthority)(originOrUrl, "3.2")}`;
68
+ } catch {
69
+ throw new CanonicalizeError("Invalid origin authority", errorMeta);
58
70
  }
59
- const port = parsed.port ? `:${parsed.port}` : "";
60
- return `${parsed.protocol}//${parsed.hostname}${port}`;
61
71
  }
72
+ const canonicalAgentOrigin = canonicalizeOrigin;
62
73
  function originsEqual(a, b) {
63
74
  try {
64
75
  return canonicalizeOrigin(a) === canonicalizeOrigin(b);
@@ -69,6 +80,7 @@ function originsEqual(a, b) {
69
80
  // Annotate the CommonJS export names for ESM import in node:
70
81
  0 && (module.exports = {
71
82
  CanonicalizeError,
83
+ canonicalAgentOrigin,
72
84
  canonicalizeHost,
73
85
  canonicalizeOrigin,
74
86
  originsEqual
@@ -1,3 +1,4 @@
1
+ import { canonicalAuthority } from "../canonicalize.mjs";
1
2
  class CanonicalizeError extends Error {
2
3
  constructor(message, meta) {
3
4
  super(message);
@@ -18,21 +19,30 @@ function canonicalizeHost(host) {
18
19
  }
19
20
  }
20
21
  function canonicalizeOrigin(originOrUrl) {
22
+ const errorMeta = { input: "[redacted]" };
21
23
  if (typeof originOrUrl !== "string" || originOrUrl.length === 0) {
22
- throw new CanonicalizeError("Empty origin", { input: originOrUrl });
24
+ throw new CanonicalizeError("Empty origin", errorMeta);
25
+ }
26
+ const authority = /^[a-z][a-z0-9+.\-]*:\/\/([^/?#]*)/i.exec(originOrUrl)?.[1];
27
+ if (!authority || /[\u0000-\u0020\u007f\\]/.test(authority)) {
28
+ throw new CanonicalizeError("Malformed origin authority", errorMeta);
23
29
  }
24
30
  let parsed;
25
31
  try {
26
32
  parsed = new URL(originOrUrl);
27
33
  } catch {
28
- throw new CanonicalizeError(`Invalid origin: ${originOrUrl}`, { input: originOrUrl });
34
+ throw new CanonicalizeError("Invalid origin", errorMeta);
29
35
  }
30
36
  if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
31
- throw new CanonicalizeError(`Unsupported scheme: ${parsed.protocol}`, { input: originOrUrl });
37
+ throw new CanonicalizeError("Unsupported origin scheme", errorMeta);
38
+ }
39
+ try {
40
+ return `${parsed.protocol}//${canonicalAuthority(originOrUrl, "3.2")}`;
41
+ } catch {
42
+ throw new CanonicalizeError("Invalid origin authority", errorMeta);
32
43
  }
33
- const port = parsed.port ? `:${parsed.port}` : "";
34
- return `${parsed.protocol}//${parsed.hostname}${port}`;
35
44
  }
45
+ const canonicalAgentOrigin = canonicalizeOrigin;
36
46
  function originsEqual(a, b) {
37
47
  try {
38
48
  return canonicalizeOrigin(a) === canonicalizeOrigin(b);
@@ -42,6 +52,7 @@ function originsEqual(a, b) {
42
52
  }
43
53
  export {
44
54
  CanonicalizeError,
55
+ canonicalAgentOrigin,
45
56
  canonicalizeHost,
46
57
  canonicalizeOrigin,
47
58
  originsEqual
@@ -17,6 +17,7 @@
17
17
  */
18
18
  export { resolveAgent } from './resolve-agent.mjs';
19
19
  export { ResolvedAgentJwksResolver } from './resolved-agent-jwks.mjs';
20
+ export { canonicalAgentOrigin, CanonicalizeError } from './canonicalize.mjs';
20
21
  export type { AgentResolution, AgentProtocol, AuthorizedOperatorScope, DelegatedOperatorAuthorizationContext, FetchCapabilitiesFn, ResolveAgentOptions, TraceStep, } from './resolve-agent.mjs';
21
22
  export type { ResolvedAgentJwksResolverOptions } from './resolved-agent-jwks.mjs';
22
23
  export { getAgentJwks, createAgentJwksSet } from './jwks-set.mjs';
@@ -17,6 +17,7 @@
17
17
  */
18
18
  export { resolveAgent } from './resolve-agent';
19
19
  export { ResolvedAgentJwksResolver } from './resolved-agent-jwks';
20
+ export { canonicalAgentOrigin, CanonicalizeError } from './canonicalize';
20
21
  export type { AgentResolution, AgentProtocol, AuthorizedOperatorScope, DelegatedOperatorAuthorizationContext, FetchCapabilitiesFn, ResolveAgentOptions, TraceStep, } from './resolve-agent';
21
22
  export type { ResolvedAgentJwksResolverOptions } from './resolved-agent-jwks';
22
23
  export { getAgentJwks, createAgentJwksSet } from './jwks-set';
@@ -20,8 +20,10 @@ var agent_resolver_exports = {};
20
20
  __export(agent_resolver_exports, {
21
21
  ATTACKER_INFLUENCED: () => import_errors.ATTACKER_INFLUENCED,
22
22
  AgentResolverError: () => import_errors.AgentResolverError,
23
+ CanonicalizeError: () => import_canonicalize.CanonicalizeError,
23
24
  ResolvedAgentJwksResolver: () => import_resolved_agent_jwks.ResolvedAgentJwksResolver,
24
25
  attackerInfluencedFields: () => import_errors.attackerInfluencedFields,
26
+ canonicalAgentOrigin: () => import_canonicalize.canonicalAgentOrigin,
25
27
  createAgentJwksSet: () => import_jwks_set.createAgentJwksSet,
26
28
  getAgentJwks: () => import_jwks_set.getAgentJwks,
27
29
  readBrandJsonUrl: () => import_capabilities_types.readBrandJsonUrl,
@@ -31,6 +33,7 @@ __export(agent_resolver_exports, {
31
33
  module.exports = __toCommonJS(agent_resolver_exports);
32
34
  var import_resolve_agent = require('./resolve-agent.js');
33
35
  var import_resolved_agent_jwks = require('./resolved-agent-jwks.js');
36
+ var import_canonicalize = require('./canonicalize.js');
34
37
  var import_jwks_set = require('./jwks-set.js');
35
38
  var import_errors = require('./errors.js');
36
39
  var import_capabilities_types = require('./capabilities-types.js');
@@ -38,8 +41,10 @@ var import_capabilities_types = require('./capabilities-types.js');
38
41
  0 && (module.exports = {
39
42
  ATTACKER_INFLUENCED,
40
43
  AgentResolverError,
44
+ CanonicalizeError,
41
45
  ResolvedAgentJwksResolver,
42
46
  attackerInfluencedFields,
47
+ canonicalAgentOrigin,
43
48
  createAgentJwksSet,
44
49
  getAgentJwks,
45
50
  readBrandJsonUrl,
@@ -1,5 +1,6 @@
1
1
  import { resolveAgent } from "./resolve-agent.mjs";
2
2
  import { ResolvedAgentJwksResolver } from "./resolved-agent-jwks.mjs";
3
+ import { canonicalAgentOrigin, CanonicalizeError } from "./canonicalize.mjs";
3
4
  import { getAgentJwks, createAgentJwksSet } from "./jwks-set.mjs";
4
5
  import {
5
6
  AgentResolverError,
@@ -10,8 +11,10 @@ import { readBrandJsonUrl, readIdentityPosture } from "./capabilities-types.mjs"
10
11
  export {
11
12
  ATTACKER_INFLUENCED,
12
13
  AgentResolverError,
14
+ CanonicalizeError,
13
15
  ResolvedAgentJwksResolver,
14
16
  attackerInfluencedFields,
17
+ canonicalAgentOrigin,
15
18
  createAgentJwksSet,
16
19
  getAgentJwks,
17
20
  readBrandJsonUrl,
@@ -19,6 +19,7 @@ export declare class ResolvedAgentJwksResolver implements JwksResolver {
19
19
  private readonly unknownKidCooldownSeconds;
20
20
  private readonly resolveAgentFn;
21
21
  private canonicalAgentUrl?;
22
+ private configuredOrigin?;
22
23
  private legacyWebhookFallback?;
23
24
  private operatorRecord?;
24
25
  get resolvedAgentUrl(): string | undefined;
@@ -29,8 +30,8 @@ export declare class ResolvedAgentJwksResolver implements JwksResolver {
29
30
  private lastDiscoveryAttemptAt;
30
31
  private inFlight?;
31
32
  constructor(agentUrl: string, protocol: AgentProtocol, options?: ResolvedAgentJwksResolverOptions);
32
- resolve(keyid: string): Promise<AdcpJsonWebKey | null>;
33
- resolveWithMetadata(keyid: string): Promise<JwksResolution>;
33
+ resolve(keyid: string, signerOrigin?: string): Promise<AdcpJsonWebKey | null>;
34
+ resolveWithMetadata(keyid: string, signerOrigin?: string): Promise<JwksResolution>;
34
35
  forceRefresh(): Promise<void>;
35
36
  private resolution;
36
37
  private refresh;
@@ -19,6 +19,7 @@ export declare class ResolvedAgentJwksResolver implements JwksResolver {
19
19
  private readonly unknownKidCooldownSeconds;
20
20
  private readonly resolveAgentFn;
21
21
  private canonicalAgentUrl?;
22
+ private configuredOrigin?;
22
23
  private legacyWebhookFallback?;
23
24
  private operatorRecord?;
24
25
  get resolvedAgentUrl(): string | undefined;
@@ -29,8 +30,8 @@ export declare class ResolvedAgentJwksResolver implements JwksResolver {
29
30
  private lastDiscoveryAttemptAt;
30
31
  private inFlight?;
31
32
  constructor(agentUrl: string, protocol: AgentProtocol, options?: ResolvedAgentJwksResolverOptions);
32
- resolve(keyid: string): Promise<AdcpJsonWebKey | null>;
33
- resolveWithMetadata(keyid: string): Promise<JwksResolution>;
33
+ resolve(keyid: string, signerOrigin?: string): Promise<AdcpJsonWebKey | null>;
34
+ resolveWithMetadata(keyid: string, signerOrigin?: string): Promise<JwksResolution>;
34
35
  forceRefresh(): Promise<void>;
35
36
  private resolution;
36
37
  private refresh;
@@ -22,6 +22,8 @@ __export(resolved_agent_jwks_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(resolved_agent_jwks_exports);
24
24
  var import_errors = require('./errors.js');
25
+ var import_canonicalize = require('./canonicalize.js');
26
+ var import_select_agent = require('./select-agent.js');
25
27
  var import_resolve_agent = require('./resolve-agent.js');
26
28
  class ResolvedAgentJwksResolver {
27
29
  constructor(agentUrl, protocol, options = {}) {
@@ -47,6 +49,7 @@ class ResolvedAgentJwksResolver {
47
49
  unknownKidCooldownSeconds;
48
50
  resolveAgentFn;
49
51
  canonicalAgentUrl;
52
+ configuredOrigin;
50
53
  legacyWebhookFallback;
51
54
  operatorRecord;
52
55
  get resolvedAgentUrl() {
@@ -58,10 +61,34 @@ class ResolvedAgentJwksResolver {
58
61
  lastUnknownKidRefresh = Number.NEGATIVE_INFINITY;
59
62
  lastDiscoveryAttemptAt = Number.NEGATIVE_INFINITY;
60
63
  inFlight;
61
- async resolve(keyid) {
62
- return (await this.resolveWithMetadata(keyid)).jwk;
64
+ async resolve(keyid, signerOrigin) {
65
+ return (await this.resolveWithMetadata(keyid, signerOrigin)).jwk;
63
66
  }
64
- async resolveWithMetadata(keyid) {
67
+ async resolveWithMetadata(keyid, signerOrigin) {
68
+ if (signerOrigin !== void 0) {
69
+ try {
70
+ this.configuredOrigin ??= (0, import_canonicalize.canonicalAgentOrigin)(this.agentUrl);
71
+ } catch {
72
+ throw new import_errors.AgentResolverError("request_signature_key_unknown", "Configured agent origin is malformed.");
73
+ }
74
+ let requestedOrigin;
75
+ try {
76
+ requestedOrigin = (0, import_canonicalize.canonicalAgentOrigin)(signerOrigin);
77
+ const authority = signerOrigin.slice(signerOrigin.indexOf("://") + 3).split(/[/?#]/, 1)[0];
78
+ if (authority.slice(authority.lastIndexOf("@") + 1).includes("%")) {
79
+ throw new TypeError("Signer origin host must use its ASCII spelling.");
80
+ }
81
+ (0, import_select_agent.canonicalAgentUrl)(signerOrigin);
82
+ } catch {
83
+ throw new import_errors.AgentResolverError("request_signature_key_unknown", "Signer origin is malformed.");
84
+ }
85
+ if (requestedOrigin !== this.configuredOrigin) {
86
+ throw new import_errors.AgentResolverError(
87
+ "request_signature_key_unknown",
88
+ "Signer origin does not match the configured agent origin."
89
+ );
90
+ }
91
+ }
65
92
  const now = this.now();
66
93
  let refreshed = false;
67
94
  if (now >= this.expiresAt) {
@@ -1,4 +1,6 @@
1
1
  import { AgentResolverError } from "./errors.mjs";
2
+ import { canonicalAgentOrigin } from "./canonicalize.mjs";
3
+ import { canonicalAgentUrl } from "./select-agent.mjs";
2
4
  import { resolveAgent } from "./resolve-agent.mjs";
3
5
  class ResolvedAgentJwksResolver {
4
6
  constructor(agentUrl, protocol, options = {}) {
@@ -24,6 +26,7 @@ class ResolvedAgentJwksResolver {
24
26
  unknownKidCooldownSeconds;
25
27
  resolveAgentFn;
26
28
  canonicalAgentUrl;
29
+ configuredOrigin;
27
30
  legacyWebhookFallback;
28
31
  operatorRecord;
29
32
  get resolvedAgentUrl() {
@@ -35,10 +38,34 @@ class ResolvedAgentJwksResolver {
35
38
  lastUnknownKidRefresh = Number.NEGATIVE_INFINITY;
36
39
  lastDiscoveryAttemptAt = Number.NEGATIVE_INFINITY;
37
40
  inFlight;
38
- async resolve(keyid) {
39
- return (await this.resolveWithMetadata(keyid)).jwk;
41
+ async resolve(keyid, signerOrigin) {
42
+ return (await this.resolveWithMetadata(keyid, signerOrigin)).jwk;
40
43
  }
41
- async resolveWithMetadata(keyid) {
44
+ async resolveWithMetadata(keyid, signerOrigin) {
45
+ if (signerOrigin !== void 0) {
46
+ try {
47
+ this.configuredOrigin ??= canonicalAgentOrigin(this.agentUrl);
48
+ } catch {
49
+ throw new AgentResolverError("request_signature_key_unknown", "Configured agent origin is malformed.");
50
+ }
51
+ let requestedOrigin;
52
+ try {
53
+ requestedOrigin = canonicalAgentOrigin(signerOrigin);
54
+ const authority = signerOrigin.slice(signerOrigin.indexOf("://") + 3).split(/[/?#]/, 1)[0];
55
+ if (authority.slice(authority.lastIndexOf("@") + 1).includes("%")) {
56
+ throw new TypeError("Signer origin host must use its ASCII spelling.");
57
+ }
58
+ canonicalAgentUrl(signerOrigin);
59
+ } catch {
60
+ throw new AgentResolverError("request_signature_key_unknown", "Signer origin is malformed.");
61
+ }
62
+ if (requestedOrigin !== this.configuredOrigin) {
63
+ throw new AgentResolverError(
64
+ "request_signature_key_unknown",
65
+ "Signer origin does not match the configured agent origin."
66
+ );
67
+ }
68
+ }
42
69
  const now = this.now();
43
70
  let refreshed = false;
44
71
  if (now >= this.expiresAt) {
@@ -40,7 +40,7 @@ export declare class StrictJsonError extends Error {
40
40
  * 256 KiB brand.json budget — both are linear, the constant factor is small,
41
41
  * and we never trust the tokenizer to produce the value (it's only a guard).
42
42
  */
43
- export declare function parseStrictJson(text: string): unknown;
43
+ export declare function parseStrictJson(text: string, maxDepth?: number): unknown;
44
44
  /**
45
45
  * Walk the source character-by-character and reject when any object scope
46
46
  * declares the same key twice. Comments are not legal JSON, so a `//` or
@@ -51,4 +51,4 @@ export declare function parseStrictJson(text: string): unknown;
51
51
  * - whether the next quoted-string at object scope is the key half of
52
52
  * a key-value pair.
53
53
  */
54
- export declare function rejectDuplicateJsonKeys(text: string): void;
54
+ export declare function rejectDuplicateJsonKeys(text: string, maxDepth?: number): void;
@@ -40,7 +40,7 @@ export declare class StrictJsonError extends Error {
40
40
  * 256 KiB brand.json budget — both are linear, the constant factor is small,
41
41
  * and we never trust the tokenizer to produce the value (it's only a guard).
42
42
  */
43
- export declare function parseStrictJson(text: string): unknown;
43
+ export declare function parseStrictJson(text: string, maxDepth?: number): unknown;
44
44
  /**
45
45
  * Walk the source character-by-character and reject when any object scope
46
46
  * declares the same key twice. Comments are not legal JSON, so a `//` or
@@ -51,4 +51,4 @@ export declare function parseStrictJson(text: string): unknown;
51
51
  * - whether the next quoted-string at object scope is the key half of
52
52
  * a key-value pair.
53
53
  */
54
- export declare function rejectDuplicateJsonKeys(text: string): void;
54
+ export declare function rejectDuplicateJsonKeys(text: string, maxDepth?: number): void;
@@ -44,8 +44,8 @@ class StrictJsonError extends Error {
44
44
  this.detail = detail;
45
45
  }
46
46
  }
47
- function parseStrictJson(text) {
48
- rejectDuplicateJsonKeys(text);
47
+ function parseStrictJson(text, maxDepth = Number.POSITIVE_INFINITY) {
48
+ rejectDuplicateJsonKeys(text, maxDepth);
49
49
  try {
50
50
  return import_secure_json_parse.default.parse(text, null, { protoAction: "error", constructorAction: "error" });
51
51
  } catch (err) {
@@ -56,7 +56,7 @@ function parseStrictJson(text) {
56
56
  throw new StrictJsonError("invalid_json", message);
57
57
  }
58
58
  }
59
- function rejectDuplicateJsonKeys(text) {
59
+ function rejectDuplicateJsonKeys(text, maxDepth = Number.POSITIVE_INFINITY) {
60
60
  const stack = [];
61
61
  let expectingKey = false;
62
62
  let i = 0;
@@ -68,6 +68,7 @@ function rejectDuplicateJsonKeys(text) {
68
68
  continue;
69
69
  }
70
70
  if (ch === "{") {
71
+ if (stack.length >= maxDepth) throw new StrictJsonError("invalid_json", "JSON nesting exceeds limit");
71
72
  stack.push({ kind: "object", keys: /* @__PURE__ */ new Set() });
72
73
  expectingKey = true;
73
74
  i++;
@@ -80,6 +81,7 @@ function rejectDuplicateJsonKeys(text) {
80
81
  continue;
81
82
  }
82
83
  if (ch === "[") {
84
+ if (stack.length >= maxDepth) throw new StrictJsonError("invalid_json", "JSON nesting exceeds limit");
83
85
  stack.push({ kind: "array" });
84
86
  expectingKey = false;
85
87
  i++;
@@ -9,8 +9,8 @@ class StrictJsonError extends Error {
9
9
  this.detail = detail;
10
10
  }
11
11
  }
12
- function parseStrictJson(text) {
13
- rejectDuplicateJsonKeys(text);
12
+ function parseStrictJson(text, maxDepth = Number.POSITIVE_INFINITY) {
13
+ rejectDuplicateJsonKeys(text, maxDepth);
14
14
  try {
15
15
  return sjp.parse(text, null, { protoAction: "error", constructorAction: "error" });
16
16
  } catch (err) {
@@ -21,7 +21,7 @@ function parseStrictJson(text) {
21
21
  throw new StrictJsonError("invalid_json", message);
22
22
  }
23
23
  }
24
- function rejectDuplicateJsonKeys(text) {
24
+ function rejectDuplicateJsonKeys(text, maxDepth = Number.POSITIVE_INFINITY) {
25
25
  const stack = [];
26
26
  let expectingKey = false;
27
27
  let i = 0;
@@ -33,6 +33,7 @@ function rejectDuplicateJsonKeys(text) {
33
33
  continue;
34
34
  }
35
35
  if (ch === "{") {
36
+ if (stack.length >= maxDepth) throw new StrictJsonError("invalid_json", "JSON nesting exceeds limit");
36
37
  stack.push({ kind: "object", keys: /* @__PURE__ */ new Set() });
37
38
  expectingKey = true;
38
39
  i++;
@@ -45,6 +46,7 @@ function rejectDuplicateJsonKeys(text) {
45
46
  continue;
46
47
  }
47
48
  if (ch === "[") {
49
+ if (stack.length >= maxDepth) throw new StrictJsonError("invalid_json", "JSON nesting exceeds limit");
48
50
  stack.push({ kind: "array" });
49
51
  expectingKey = false;
50
52
  i++;
@@ -84,8 +84,8 @@ export declare class BrandJsonJwksResolver implements JwksResolver {
84
84
  constructor(brandJsonUrl: string, options: BrandJsonJwksResolverOptions);
85
85
  private createResolver;
86
86
  private confirmedResolver;
87
- resolve(keyid: string): Promise<AdcpJsonWebKey | null>;
88
- resolveWithMetadata(keyid: string): Promise<JwksResolution>;
87
+ resolve(keyid: string, signerOrigin?: string): Promise<AdcpJsonWebKey | null>;
88
+ resolveWithMetadata(keyid: string, signerOrigin?: string): Promise<JwksResolution>;
89
89
  get agentUrl(): string | undefined;
90
90
  forceRefresh(): Promise<void>;
91
91
  }
@@ -84,8 +84,8 @@ export declare class BrandJsonJwksResolver implements JwksResolver {
84
84
  constructor(brandJsonUrl: string, options: BrandJsonJwksResolverOptions);
85
85
  private createResolver;
86
86
  private confirmedResolver;
87
- resolve(keyid: string): Promise<AdcpJsonWebKey | null>;
88
- resolveWithMetadata(keyid: string): Promise<JwksResolution>;
87
+ resolve(keyid: string, signerOrigin?: string): Promise<AdcpJsonWebKey | null>;
88
+ resolveWithMetadata(keyid: string, signerOrigin?: string): Promise<JwksResolution>;
89
89
  get agentUrl(): string | undefined;
90
90
  forceRefresh(): Promise<void>;
91
91
  }
@@ -113,11 +113,11 @@ class BrandJsonJwksResolver {
113
113
  });
114
114
  return this.onboarding;
115
115
  }
116
- async resolve(keyid) {
117
- return (await this.confirmedResolver()).resolve(keyid);
116
+ async resolve(keyid, signerOrigin) {
117
+ return (await this.confirmedResolver()).resolve(keyid, signerOrigin);
118
118
  }
119
- async resolveWithMetadata(keyid) {
120
- return (await this.confirmedResolver()).resolveWithMetadata(keyid);
119
+ async resolveWithMetadata(keyid, signerOrigin) {
120
+ return (await this.confirmedResolver()).resolveWithMetadata(keyid, signerOrigin);
121
121
  }
122
122
  get agentUrl() {
123
123
  return this.resolver?.resolvedAgentUrl;