@adcp/sdk 12.0.0 → 12.0.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 (942) hide show
  1. package/dist/lib/adapters/content-standards-adapter.mjs +0 -6
  2. package/dist/lib/adapters/content-standards-adapter.mjs.map +1 -1
  3. package/dist/lib/adapters/derived-account-store.mjs +0 -6
  4. package/dist/lib/adapters/derived-account-store.mjs.map +1 -1
  5. package/dist/lib/adapters/governance-adapter.mjs +0 -6
  6. package/dist/lib/adapters/governance-adapter.mjs.map +1 -1
  7. package/dist/lib/adapters/implicit-account-store.mjs +0 -6
  8. package/dist/lib/adapters/implicit-account-store.mjs.map +1 -1
  9. package/dist/lib/adapters/index.mjs +0 -6
  10. package/dist/lib/adapters/index.mjs.map +1 -1
  11. package/dist/lib/adapters/legacy/v2-5/create_media_buy.mjs +0 -6
  12. package/dist/lib/adapters/legacy/v2-5/create_media_buy.mjs.map +1 -1
  13. package/dist/lib/adapters/legacy/v2-5/get_products.mjs +0 -6
  14. package/dist/lib/adapters/legacy/v2-5/get_products.mjs.map +1 -1
  15. package/dist/lib/adapters/legacy/v2-5/index.mjs +0 -6
  16. package/dist/lib/adapters/legacy/v2-5/index.mjs.map +1 -1
  17. package/dist/lib/adapters/legacy/v2-5/list_creative_formats.mjs +0 -6
  18. package/dist/lib/adapters/legacy/v2-5/list_creative_formats.mjs.map +1 -1
  19. package/dist/lib/adapters/legacy/v2-5/preview_creative.mjs +0 -6
  20. package/dist/lib/adapters/legacy/v2-5/preview_creative.mjs.map +1 -1
  21. package/dist/lib/adapters/legacy/v2-5/sync_creatives.mjs +0 -6
  22. package/dist/lib/adapters/legacy/v2-5/sync_creatives.mjs.map +1 -1
  23. package/dist/lib/adapters/legacy/v2-5/types.mjs +0 -6
  24. package/dist/lib/adapters/legacy/v2-5/update_media_buy.mjs +0 -6
  25. package/dist/lib/adapters/legacy/v2-5/update_media_buy.mjs.map +1 -1
  26. package/dist/lib/adapters/oauth-passthrough-resolver.mjs +0 -6
  27. package/dist/lib/adapters/oauth-passthrough-resolver.mjs.map +1 -1
  28. package/dist/lib/adapters/property-list-adapter.mjs +0 -6
  29. package/dist/lib/adapters/property-list-adapter.mjs.map +1 -1
  30. package/dist/lib/adapters/roster-account-store.mjs +0 -6
  31. package/dist/lib/adapters/roster-account-store.mjs.map +1 -1
  32. package/dist/lib/adapters/si-session-manager.mjs +0 -6
  33. package/dist/lib/adapters/si-session-manager.mjs.map +1 -1
  34. package/dist/lib/adapters/version/3.0/brand-fields.mjs +0 -6
  35. package/dist/lib/adapters/version/3.0/brand-fields.mjs.map +1 -1
  36. package/dist/lib/adapters/version/3.0/get-products.mjs +0 -6
  37. package/dist/lib/adapters/version/3.0/get-products.mjs.map +1 -1
  38. package/dist/lib/adapters/version/3.0/index.mjs +0 -6
  39. package/dist/lib/adapters/version/3.0/index.mjs.map +1 -1
  40. package/dist/lib/adapters/version/3.0/sync-accounts.mjs +0 -6
  41. package/dist/lib/adapters/version/3.0/sync-accounts.mjs.map +1 -1
  42. package/dist/lib/adapters/version/index.mjs +0 -6
  43. package/dist/lib/adapters/version/index.mjs.map +1 -1
  44. package/dist/lib/adapters/version/types.mjs +0 -6
  45. package/dist/lib/advanced.mjs +0 -6
  46. package/dist/lib/advanced.mjs.map +1 -1
  47. package/dist/lib/agents/index.generated.mjs +0 -6
  48. package/dist/lib/agents/index.generated.mjs.map +1 -1
  49. package/dist/lib/auth/index.mjs +0 -6
  50. package/dist/lib/auth/index.mjs.map +1 -1
  51. package/dist/lib/auth/oauth/CLIFlowHandler.mjs +0 -6
  52. package/dist/lib/auth/oauth/CLIFlowHandler.mjs.map +1 -1
  53. package/dist/lib/auth/oauth/ClientCredentialsFlow.mjs +0 -6
  54. package/dist/lib/auth/oauth/ClientCredentialsFlow.mjs.map +1 -1
  55. package/dist/lib/auth/oauth/MCPOAuthProvider.mjs +0 -6
  56. package/dist/lib/auth/oauth/MCPOAuthProvider.mjs.map +1 -1
  57. package/dist/lib/auth/oauth/NonInteractiveFlowHandler.mjs +0 -6
  58. package/dist/lib/auth/oauth/NonInteractiveFlowHandler.mjs.map +1 -1
  59. package/dist/lib/auth/oauth/authorization-required.mjs +0 -6
  60. package/dist/lib/auth/oauth/authorization-required.mjs.map +1 -1
  61. package/dist/lib/auth/oauth/diagnose.mjs +0 -6
  62. package/dist/lib/auth/oauth/diagnose.mjs.map +1 -1
  63. package/dist/lib/auth/oauth/diagnostics.mjs +0 -6
  64. package/dist/lib/auth/oauth/diagnostics.mjs.map +1 -1
  65. package/dist/lib/auth/oauth/discovery.mjs +0 -6
  66. package/dist/lib/auth/oauth/discovery.mjs.map +1 -1
  67. package/dist/lib/auth/oauth/file-storage.mjs +0 -6
  68. package/dist/lib/auth/oauth/file-storage.mjs.map +1 -1
  69. package/dist/lib/auth/oauth/index.mjs +0 -6
  70. package/dist/lib/auth/oauth/index.mjs.map +1 -1
  71. package/dist/lib/auth/oauth/secret-resolver.mjs +0 -6
  72. package/dist/lib/auth/oauth/secret-resolver.mjs.map +1 -1
  73. package/dist/lib/auth/oauth/storage-registry.mjs +0 -6
  74. package/dist/lib/auth/oauth/storage-registry.mjs.map +1 -1
  75. package/dist/lib/auth/oauth/types.mjs +0 -6
  76. package/dist/lib/auth/oauth/types.mjs.map +1 -1
  77. package/dist/lib/auth/oauth/web-flow.mjs +0 -6
  78. package/dist/lib/auth/oauth/web-flow.mjs.map +1 -1
  79. package/dist/lib/brand/index.mjs +0 -6
  80. package/dist/lib/brand/index.mjs.map +1 -1
  81. package/dist/lib/canonical-references/index.mjs +6 -7
  82. package/dist/lib/canonical-references/index.mjs.map +1 -1
  83. package/dist/lib/client/index.mjs +0 -6
  84. package/dist/lib/client/index.mjs.map +1 -1
  85. package/dist/lib/compliance/index.mjs +0 -6
  86. package/dist/lib/compliance/index.mjs.map +1 -1
  87. package/dist/lib/compliance-fixtures/index.mjs +0 -6
  88. package/dist/lib/compliance-fixtures/index.mjs.map +1 -1
  89. package/dist/lib/compliance-fixtures/test-authorization-server.mjs +0 -6
  90. package/dist/lib/compliance-fixtures/test-authorization-server.mjs.map +1 -1
  91. package/dist/lib/conformance/index.mjs +0 -6
  92. package/dist/lib/conformance/index.mjs.map +1 -1
  93. package/dist/lib/conformance/invariants/uniformError.mjs +0 -6
  94. package/dist/lib/conformance/invariants/uniformError.mjs.map +1 -1
  95. package/dist/lib/conformance/invariants/uniformErrorComparator.mjs +0 -6
  96. package/dist/lib/conformance/invariants/uniformErrorComparator.mjs.map +1 -1
  97. package/dist/lib/conformance/oracle.mjs +0 -6
  98. package/dist/lib/conformance/oracle.mjs.map +1 -1
  99. package/dist/lib/conformance/runConformance.mjs +0 -6
  100. package/dist/lib/conformance/runConformance.mjs.map +1 -1
  101. package/dist/lib/conformance/runners.mjs +0 -6
  102. package/dist/lib/conformance/runners.mjs.map +1 -1
  103. package/dist/lib/conformance/schemaArbitrary.mjs +0 -6
  104. package/dist/lib/conformance/schemaArbitrary.mjs.map +1 -1
  105. package/dist/lib/conformance/schemaLoader.mjs +5 -6
  106. package/dist/lib/conformance/schemaLoader.mjs.map +1 -1
  107. package/dist/lib/conformance/seeder.mjs +0 -6
  108. package/dist/lib/conformance/seeder.mjs.map +1 -1
  109. package/dist/lib/conformance/types.mjs +0 -6
  110. package/dist/lib/conformance/types.mjs.map +1 -1
  111. package/dist/lib/conformance/webhook.mjs +0 -6
  112. package/dist/lib/conformance/webhook.mjs.map +1 -1
  113. package/dist/lib/core/ADCPMultiAgentClient.mjs +0 -6
  114. package/dist/lib/core/ADCPMultiAgentClient.mjs.map +1 -1
  115. package/dist/lib/core/AgentClient.mjs +0 -6
  116. package/dist/lib/core/AgentClient.mjs.map +1 -1
  117. package/dist/lib/core/AsyncHandler.mjs +0 -6
  118. package/dist/lib/core/AsyncHandler.mjs.map +1 -1
  119. package/dist/lib/core/ConfigurationManager.mjs +0 -6
  120. package/dist/lib/core/ConfigurationManager.mjs.map +1 -1
  121. package/dist/lib/core/ConversationTypes.mjs +0 -6
  122. package/dist/lib/core/CreativeAgentClient.mjs +0 -6
  123. package/dist/lib/core/CreativeAgentClient.mjs.map +1 -1
  124. package/dist/lib/core/GovernanceMiddleware.mjs +0 -6
  125. package/dist/lib/core/GovernanceMiddleware.mjs.map +1 -1
  126. package/dist/lib/core/GovernanceTypes.mjs +0 -6
  127. package/dist/lib/core/GovernanceTypes.mjs.map +1 -1
  128. package/dist/lib/core/ProtocolResponseParser.mjs +0 -6
  129. package/dist/lib/core/ProtocolResponseParser.mjs.map +1 -1
  130. package/dist/lib/core/ResponseValidator.mjs +0 -6
  131. package/dist/lib/core/ResponseValidator.mjs.map +1 -1
  132. package/dist/lib/core/SingleAgentClient.mjs +0 -6
  133. package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
  134. package/dist/lib/core/TaskEventTypes.mjs +0 -6
  135. package/dist/lib/core/TaskEventTypes.mjs.map +1 -1
  136. package/dist/lib/core/TaskExecutor.mjs +0 -6
  137. package/dist/lib/core/TaskExecutor.mjs.map +1 -1
  138. package/dist/lib/core/match.mjs +0 -6
  139. package/dist/lib/core/match.mjs.map +1 -1
  140. package/dist/lib/core/task-status.mjs +0 -6
  141. package/dist/lib/core/task-status.mjs.map +1 -1
  142. package/dist/lib/core/webhook-url.mjs +0 -6
  143. package/dist/lib/core/webhook-url.mjs.map +1 -1
  144. package/dist/lib/discovery/adagents-redirects.mjs +0 -6
  145. package/dist/lib/discovery/adagents-redirects.mjs.map +1 -1
  146. package/dist/lib/discovery/agent-directory.mjs +0 -6
  147. package/dist/lib/discovery/agent-directory.mjs.map +1 -1
  148. package/dist/lib/discovery/inline-publisher-properties.mjs +0 -6
  149. package/dist/lib/discovery/inline-publisher-properties.mjs.map +1 -1
  150. package/dist/lib/discovery/network-consistency-checker.mjs +0 -6
  151. package/dist/lib/discovery/network-consistency-checker.mjs.map +1 -1
  152. package/dist/lib/discovery/property-crawler.mjs +0 -6
  153. package/dist/lib/discovery/property-crawler.mjs.map +1 -1
  154. package/dist/lib/discovery/property-index.mjs +0 -6
  155. package/dist/lib/discovery/property-index.mjs.map +1 -1
  156. package/dist/lib/discovery/publisher-property-selector.mjs +0 -6
  157. package/dist/lib/discovery/publisher-property-selector.mjs.map +1 -1
  158. package/dist/lib/discovery/resolve-agent-properties.mjs +0 -6
  159. package/dist/lib/discovery/resolve-agent-properties.mjs.map +1 -1
  160. package/dist/lib/discovery/types.mjs +0 -6
  161. package/dist/lib/discovery/validate-adagents.mjs +0 -6
  162. package/dist/lib/discovery/validate-adagents.mjs.map +1 -1
  163. package/dist/lib/enums.mjs +0 -6
  164. package/dist/lib/enums.mjs.map +1 -1
  165. package/dist/lib/errors/index.mjs +0 -6
  166. package/dist/lib/errors/index.mjs.map +1 -1
  167. package/dist/lib/express-mcp/index.mjs +0 -6
  168. package/dist/lib/express-mcp/index.mjs.map +1 -1
  169. package/dist/lib/governance/index.mjs +0 -6
  170. package/dist/lib/governance/index.mjs.map +1 -1
  171. package/dist/lib/handlers/types.mjs +0 -6
  172. package/dist/lib/handlers/types.mjs.map +1 -1
  173. package/dist/lib/index.mjs +0 -6
  174. package/dist/lib/index.mjs.map +1 -1
  175. package/dist/lib/media-buy/available-actions.mjs +0 -6
  176. package/dist/lib/media-buy/available-actions.mjs.map +1 -1
  177. package/dist/lib/media-buy/index.mjs +0 -6
  178. package/dist/lib/media-buy/index.mjs.map +1 -1
  179. package/dist/lib/media-buy/preflight.mjs +0 -6
  180. package/dist/lib/media-buy/preflight.mjs.map +1 -1
  181. package/dist/lib/media-buy/property-policy.mjs +0 -6
  182. package/dist/lib/media-buy/property-policy.mjs.map +1 -1
  183. package/dist/lib/media-buy/types.mjs +0 -6
  184. package/dist/lib/media-buy/types.mjs.map +1 -1
  185. package/dist/lib/media-buy/update-fields.generated.mjs +0 -6
  186. package/dist/lib/media-buy/update-fields.generated.mjs.map +1 -1
  187. package/dist/lib/mock-server/creative-ad-server/seed-data.mjs +0 -6
  188. package/dist/lib/mock-server/creative-ad-server/seed-data.mjs.map +1 -1
  189. package/dist/lib/mock-server/creative-ad-server/server.mjs +0 -6
  190. package/dist/lib/mock-server/creative-ad-server/server.mjs.map +1 -1
  191. package/dist/lib/mock-server/creative-template/seed-data.mjs +0 -6
  192. package/dist/lib/mock-server/creative-template/seed-data.mjs.map +1 -1
  193. package/dist/lib/mock-server/creative-template/server.mjs +0 -6
  194. package/dist/lib/mock-server/creative-template/server.mjs.map +1 -1
  195. package/dist/lib/mock-server/index.mjs +0 -6
  196. package/dist/lib/mock-server/index.mjs.map +1 -1
  197. package/dist/lib/mock-server/sales-guaranteed/recipe.mjs +0 -6
  198. package/dist/lib/mock-server/sales-guaranteed/recipe.mjs.map +1 -1
  199. package/dist/lib/mock-server/sales-guaranteed/seed-data.mjs +0 -6
  200. package/dist/lib/mock-server/sales-guaranteed/seed-data.mjs.map +1 -1
  201. package/dist/lib/mock-server/sales-guaranteed/server.mjs +0 -6
  202. package/dist/lib/mock-server/sales-guaranteed/server.mjs.map +1 -1
  203. package/dist/lib/mock-server/sales-non-guaranteed/recipe.mjs +0 -6
  204. package/dist/lib/mock-server/sales-non-guaranteed/recipe.mjs.map +1 -1
  205. package/dist/lib/mock-server/sales-non-guaranteed/seed-data.mjs +0 -6
  206. package/dist/lib/mock-server/sales-non-guaranteed/seed-data.mjs.map +1 -1
  207. package/dist/lib/mock-server/sales-non-guaranteed/server.mjs +0 -6
  208. package/dist/lib/mock-server/sales-non-guaranteed/server.mjs.map +1 -1
  209. package/dist/lib/mock-server/sales-social/seed-data.mjs +0 -6
  210. package/dist/lib/mock-server/sales-social/seed-data.mjs.map +1 -1
  211. package/dist/lib/mock-server/sales-social/server.mjs +0 -6
  212. package/dist/lib/mock-server/sales-social/server.mjs.map +1 -1
  213. package/dist/lib/mock-server/scenario.mjs +0 -6
  214. package/dist/lib/mock-server/scenario.mjs.map +1 -1
  215. package/dist/lib/mock-server/signal-marketplace/seed-data.mjs +0 -6
  216. package/dist/lib/mock-server/signal-marketplace/seed-data.mjs.map +1 -1
  217. package/dist/lib/mock-server/signal-marketplace/server.mjs +0 -6
  218. package/dist/lib/mock-server/signal-marketplace/server.mjs.map +1 -1
  219. package/dist/lib/mock-server/sponsored-intelligence/seed-data.mjs +0 -6
  220. package/dist/lib/mock-server/sponsored-intelligence/seed-data.mjs.map +1 -1
  221. package/dist/lib/mock-server/sponsored-intelligence/server.mjs +0 -6
  222. package/dist/lib/mock-server/sponsored-intelligence/server.mjs.map +1 -1
  223. package/dist/lib/net/address-guards.mjs +0 -6
  224. package/dist/lib/net/address-guards.mjs.map +1 -1
  225. package/dist/lib/net/index.mjs +0 -6
  226. package/dist/lib/net/index.mjs.map +1 -1
  227. package/dist/lib/net/ssrf-fetch.mjs +0 -6
  228. package/dist/lib/net/ssrf-fetch.mjs.map +1 -1
  229. package/dist/lib/observability/index.mjs +0 -6
  230. package/dist/lib/observability/index.mjs.map +1 -1
  231. package/dist/lib/observability/tracing.mjs +6 -7
  232. package/dist/lib/observability/tracing.mjs.map +1 -1
  233. package/dist/lib/protocols/a2a.mjs +0 -6
  234. package/dist/lib/protocols/a2a.mjs.map +1 -1
  235. package/dist/lib/protocols/abort.mjs +0 -6
  236. package/dist/lib/protocols/abort.mjs.map +1 -1
  237. package/dist/lib/protocols/index.mjs +0 -6
  238. package/dist/lib/protocols/index.mjs.map +1 -1
  239. package/dist/lib/protocols/mcp-modern.mjs +0 -6
  240. package/dist/lib/protocols/mcp-modern.mjs.map +1 -1
  241. package/dist/lib/protocols/mcp-tasks.mjs +0 -6
  242. package/dist/lib/protocols/mcp-tasks.mjs.map +1 -1
  243. package/dist/lib/protocols/mcp.mjs +0 -6
  244. package/dist/lib/protocols/mcp.mjs.map +1 -1
  245. package/dist/lib/protocols/rawResponseCapture.mjs +0 -6
  246. package/dist/lib/protocols/rawResponseCapture.mjs.map +1 -1
  247. package/dist/lib/protocols/responseSizeLimit.mjs +0 -6
  248. package/dist/lib/protocols/responseSizeLimit.mjs.map +1 -1
  249. package/dist/lib/protocols/transportDiagnostics.mjs +0 -6
  250. package/dist/lib/protocols/transportDiagnostics.mjs.map +1 -1
  251. package/dist/lib/registry/cursor-store.mjs +0 -6
  252. package/dist/lib/registry/cursor-store.mjs.map +1 -1
  253. package/dist/lib/registry/feed-stream.mjs +0 -6
  254. package/dist/lib/registry/feed-stream.mjs.map +1 -1
  255. package/dist/lib/registry/index.mjs +0 -6
  256. package/dist/lib/registry/index.mjs.map +1 -1
  257. package/dist/lib/registry/property-registry.mjs +0 -6
  258. package/dist/lib/registry/property-registry.mjs.map +1 -1
  259. package/dist/lib/registry/sync.mjs +0 -6
  260. package/dist/lib/registry/sync.mjs.map +1 -1
  261. package/dist/lib/registry/types.generated.mjs +0 -6
  262. package/dist/lib/registry/types.mjs +0 -6
  263. package/dist/lib/schemas/index.mjs +0 -6
  264. package/dist/lib/schemas/index.mjs.map +1 -1
  265. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  266. package/dist/lib/server/a2a-adapter.mjs +0 -6
  267. package/dist/lib/server/a2a-adapter.mjs.map +1 -1
  268. package/dist/lib/server/account-mode.mjs +0 -6
  269. package/dist/lib/server/account-mode.mjs.map +1 -1
  270. package/dist/lib/server/adcp-server.mjs +0 -6
  271. package/dist/lib/server/adcp-server.mjs.map +1 -1
  272. package/dist/lib/server/auth-introspection.mjs +0 -6
  273. package/dist/lib/server/auth-introspection.mjs.map +1 -1
  274. package/dist/lib/server/auth-signature.mjs +0 -6
  275. package/dist/lib/server/auth-signature.mjs.map +1 -1
  276. package/dist/lib/server/auth.mjs +0 -6
  277. package/dist/lib/server/auth.mjs.map +1 -1
  278. package/dist/lib/server/create-adcp-server.mjs +0 -6
  279. package/dist/lib/server/create-adcp-server.mjs.map +1 -1
  280. package/dist/lib/server/credential-policy.mjs +0 -6
  281. package/dist/lib/server/credential-policy.mjs.map +1 -1
  282. package/dist/lib/server/ctx-metadata/backends/memory.mjs +0 -6
  283. package/dist/lib/server/ctx-metadata/backends/memory.mjs.map +1 -1
  284. package/dist/lib/server/ctx-metadata/backends/pg.mjs +0 -6
  285. package/dist/lib/server/ctx-metadata/backends/pg.mjs.map +1 -1
  286. package/dist/lib/server/ctx-metadata/backends/redis.mjs +0 -6
  287. package/dist/lib/server/ctx-metadata/backends/redis.mjs.map +1 -1
  288. package/dist/lib/server/ctx-metadata/index.mjs +0 -6
  289. package/dist/lib/server/ctx-metadata/index.mjs.map +1 -1
  290. package/dist/lib/server/ctx-metadata/store.mjs +0 -6
  291. package/dist/lib/server/ctx-metadata/store.mjs.map +1 -1
  292. package/dist/lib/server/ctx-metadata/wire-shape.mjs +0 -6
  293. package/dist/lib/server/ctx-metadata/wire-shape.mjs.map +1 -1
  294. package/dist/lib/server/decisioning/account.mjs +0 -6
  295. package/dist/lib/server/decisioning/account.mjs.map +1 -1
  296. package/dist/lib/server/decisioning/admin-router.mjs +0 -6
  297. package/dist/lib/server/decisioning/admin-router.mjs.map +1 -1
  298. package/dist/lib/server/decisioning/assembly-helpers.mjs +0 -6
  299. package/dist/lib/server/decisioning/assembly-helpers.mjs.map +1 -1
  300. package/dist/lib/server/decisioning/async-outcome.mjs +0 -6
  301. package/dist/lib/server/decisioning/async-outcome.mjs.map +1 -1
  302. package/dist/lib/server/decisioning/buyer-agent.mjs +0 -6
  303. package/dist/lib/server/decisioning/buyer-agent.mjs.map +1 -1
  304. package/dist/lib/server/decisioning/capabilities.mjs +0 -6
  305. package/dist/lib/server/decisioning/capabilities.mjs.map +1 -1
  306. package/dist/lib/server/decisioning/compose.mjs +0 -6
  307. package/dist/lib/server/decisioning/compose.mjs.map +1 -1
  308. package/dist/lib/server/decisioning/context.mjs +0 -6
  309. package/dist/lib/server/decisioning/errors-typed.mjs +0 -6
  310. package/dist/lib/server/decisioning/errors-typed.mjs.map +1 -1
  311. package/dist/lib/server/decisioning/helpers.mjs +0 -6
  312. package/dist/lib/server/decisioning/helpers.mjs.map +1 -1
  313. package/dist/lib/server/decisioning/index.mjs +0 -6
  314. package/dist/lib/server/decisioning/index.mjs.map +1 -1
  315. package/dist/lib/server/decisioning/list-helpers.mjs +0 -6
  316. package/dist/lib/server/decisioning/list-helpers.mjs.map +1 -1
  317. package/dist/lib/server/decisioning/manifest-helpers.mjs +0 -6
  318. package/dist/lib/server/decisioning/manifest-helpers.mjs.map +1 -1
  319. package/dist/lib/server/decisioning/pagination.mjs +0 -6
  320. package/dist/lib/server/decisioning/platform-helpers.mjs +0 -6
  321. package/dist/lib/server/decisioning/platform-helpers.mjs.map +1 -1
  322. package/dist/lib/server/decisioning/platform.mjs +0 -6
  323. package/dist/lib/server/decisioning/proposal/dispatch.mjs +0 -6
  324. package/dist/lib/server/decisioning/proposal/dispatch.mjs.map +1 -1
  325. package/dist/lib/server/decisioning/proposal/index.mjs +0 -6
  326. package/dist/lib/server/decisioning/proposal/index.mjs.map +1 -1
  327. package/dist/lib/server/decisioning/proposal/lifecycle.mjs +0 -6
  328. package/dist/lib/server/decisioning/proposal/lifecycle.mjs.map +1 -1
  329. package/dist/lib/server/decisioning/proposal/mock-manager.mjs +0 -6
  330. package/dist/lib/server/decisioning/proposal/mock-manager.mjs.map +1 -1
  331. package/dist/lib/server/decisioning/proposal/store.mjs +0 -6
  332. package/dist/lib/server/decisioning/proposal/store.mjs.map +1 -1
  333. package/dist/lib/server/decisioning/proposal/types.mjs +0 -6
  334. package/dist/lib/server/decisioning/proposal/types.mjs.map +1 -1
  335. package/dist/lib/server/decisioning/resolve-presets.mjs +0 -6
  336. package/dist/lib/server/decisioning/resolve-presets.mjs.map +1 -1
  337. package/dist/lib/server/decisioning/runtime/entity-hydration.generated.mjs +0 -6
  338. package/dist/lib/server/decisioning/runtime/entity-hydration.generated.mjs.map +1 -1
  339. package/dist/lib/server/decisioning/runtime/from-platform.mjs +0 -6
  340. package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
  341. package/dist/lib/server/decisioning/runtime/observed-modes.mjs +0 -6
  342. package/dist/lib/server/decisioning/runtime/observed-modes.mjs.map +1 -1
  343. package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs +0 -6
  344. package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs.map +1 -1
  345. package/dist/lib/server/decisioning/runtime/protocol-for-tool.mjs +0 -6
  346. package/dist/lib/server/decisioning/runtime/protocol-for-tool.mjs.map +1 -1
  347. package/dist/lib/server/decisioning/runtime/task-registry.mjs +0 -6
  348. package/dist/lib/server/decisioning/runtime/task-registry.mjs.map +1 -1
  349. package/dist/lib/server/decisioning/runtime/to-context.mjs +0 -6
  350. package/dist/lib/server/decisioning/runtime/to-context.mjs.map +1 -1
  351. package/dist/lib/server/decisioning/runtime/validate-platform.mjs +0 -6
  352. package/dist/lib/server/decisioning/runtime/validate-platform.mjs.map +1 -1
  353. package/dist/lib/server/decisioning/specialisms/audiences.mjs +0 -6
  354. package/dist/lib/server/decisioning/specialisms/brand-rights.mjs +0 -6
  355. package/dist/lib/server/decisioning/specialisms/campaign-governance.mjs +0 -6
  356. package/dist/lib/server/decisioning/specialisms/content-standards.mjs +0 -6
  357. package/dist/lib/server/decisioning/specialisms/creative-ad-server.mjs +0 -6
  358. package/dist/lib/server/decisioning/specialisms/creative.mjs +0 -6
  359. package/dist/lib/server/decisioning/specialisms/lists.mjs +0 -6
  360. package/dist/lib/server/decisioning/specialisms/sales.mjs +0 -6
  361. package/dist/lib/server/decisioning/specialisms/signals.mjs +0 -6
  362. package/dist/lib/server/decisioning/specialisms/sponsored-intelligence.mjs +0 -6
  363. package/dist/lib/server/decisioning/start-time.mjs +0 -6
  364. package/dist/lib/server/decisioning/start-time.mjs.map +1 -1
  365. package/dist/lib/server/decisioning/status-changes.mjs +0 -6
  366. package/dist/lib/server/decisioning/status-changes.mjs.map +1 -1
  367. package/dist/lib/server/decisioning/status-mappers.mjs +0 -6
  368. package/dist/lib/server/decisioning/status-mappers.mjs.map +1 -1
  369. package/dist/lib/server/decisioning/tenant-registry.mjs +0 -6
  370. package/dist/lib/server/decisioning/tenant-registry.mjs.map +1 -1
  371. package/dist/lib/server/decisioning/tenant-store.mjs +0 -6
  372. package/dist/lib/server/decisioning/tenant-store.mjs.map +1 -1
  373. package/dist/lib/server/decisioning/validate-specialisms.mjs +0 -6
  374. package/dist/lib/server/decisioning/validate-specialisms.mjs.map +1 -1
  375. package/dist/lib/server/dynamic-registry.mjs +0 -6
  376. package/dist/lib/server/dynamic-registry.mjs.map +1 -1
  377. package/dist/lib/server/envelope-allowlist.mjs +0 -6
  378. package/dist/lib/server/envelope-allowlist.mjs.map +1 -1
  379. package/dist/lib/server/error-arm-tools.mjs +5 -6
  380. package/dist/lib/server/error-arm-tools.mjs.map +1 -1
  381. package/dist/lib/server/errors.mjs +0 -6
  382. package/dist/lib/server/errors.mjs.map +1 -1
  383. package/dist/lib/server/example-tld-guard.mjs +0 -6
  384. package/dist/lib/server/example-tld-guard.mjs.map +1 -1
  385. package/dist/lib/server/express-adapter.mjs +0 -6
  386. package/dist/lib/server/express-adapter.mjs.map +1 -1
  387. package/dist/lib/server/governance.mjs +0 -6
  388. package/dist/lib/server/governance.mjs.map +1 -1
  389. package/dist/lib/server/idempotency/backends/lazy.mjs +0 -6
  390. package/dist/lib/server/idempotency/backends/lazy.mjs.map +1 -1
  391. package/dist/lib/server/idempotency/backends/memory.mjs +0 -6
  392. package/dist/lib/server/idempotency/backends/memory.mjs.map +1 -1
  393. package/dist/lib/server/idempotency/backends/pg.mjs +0 -6
  394. package/dist/lib/server/idempotency/backends/pg.mjs.map +1 -1
  395. package/dist/lib/server/idempotency/backends/redis.mjs +0 -6
  396. package/dist/lib/server/idempotency/backends/redis.mjs.map +1 -1
  397. package/dist/lib/server/idempotency/index.mjs +0 -6
  398. package/dist/lib/server/idempotency/index.mjs.map +1 -1
  399. package/dist/lib/server/idempotency/store.mjs +0 -6
  400. package/dist/lib/server/idempotency/store.mjs.map +1 -1
  401. package/dist/lib/server/index.mjs +0 -6
  402. package/dist/lib/server/index.mjs.map +1 -1
  403. package/dist/lib/server/legacy/v5/index.mjs +0 -6
  404. package/dist/lib/server/legacy/v5/index.mjs.map +1 -1
  405. package/dist/lib/server/mcp-modern-server.mjs +0 -6
  406. package/dist/lib/server/mcp-modern-server.mjs.map +1 -1
  407. package/dist/lib/server/media-buy-actions.mjs +0 -6
  408. package/dist/lib/server/media-buy-actions.mjs.map +1 -1
  409. package/dist/lib/server/media-buy-helpers.mjs +0 -6
  410. package/dist/lib/server/media-buy-helpers.mjs.map +1 -1
  411. package/dist/lib/server/media-buy-store.mjs +0 -6
  412. package/dist/lib/server/media-buy-store.mjs.map +1 -1
  413. package/dist/lib/server/normalize-errors.mjs +0 -6
  414. package/dist/lib/server/normalize-errors.mjs.map +1 -1
  415. package/dist/lib/server/operational-platform.mjs +0 -6
  416. package/dist/lib/server/operational-platform.mjs.map +1 -1
  417. package/dist/lib/server/pick-safe-details.mjs +0 -6
  418. package/dist/lib/server/pick-safe-details.mjs.map +1 -1
  419. package/dist/lib/server/pin-and-bind-fetch.mjs +0 -6
  420. package/dist/lib/server/pin-and-bind-fetch.mjs.map +1 -1
  421. package/dist/lib/server/postgres-state-store.mjs +0 -6
  422. package/dist/lib/server/postgres-state-store.mjs.map +1 -1
  423. package/dist/lib/server/postgres-task-store.mjs +0 -6
  424. package/dist/lib/server/postgres-task-store.mjs.map +1 -1
  425. package/dist/lib/server/product-defaults.mjs +0 -6
  426. package/dist/lib/server/product-defaults.mjs.map +1 -1
  427. package/dist/lib/server/redact.mjs +0 -6
  428. package/dist/lib/server/redact.mjs.map +1 -1
  429. package/dist/lib/server/responses.mjs +0 -6
  430. package/dist/lib/server/responses.mjs.map +1 -1
  431. package/dist/lib/server/serve.mjs +0 -6
  432. package/dist/lib/server/serve.mjs.map +1 -1
  433. package/dist/lib/server/socket-mode/conformance-client.mjs +0 -6
  434. package/dist/lib/server/socket-mode/conformance-client.mjs.map +1 -1
  435. package/dist/lib/server/socket-mode/index.mjs +0 -6
  436. package/dist/lib/server/socket-mode/index.mjs.map +1 -1
  437. package/dist/lib/server/socket-mode/ws-transport.mjs +0 -6
  438. package/dist/lib/server/socket-mode/ws-transport.mjs.map +1 -1
  439. package/dist/lib/server/state-machine.mjs +0 -6
  440. package/dist/lib/server/state-machine.mjs.map +1 -1
  441. package/dist/lib/server/state-store.mjs +0 -6
  442. package/dist/lib/server/state-store.mjs.map +1 -1
  443. package/dist/lib/server/structured-serialize.mjs +0 -6
  444. package/dist/lib/server/structured-serialize.mjs.map +1 -1
  445. package/dist/lib/server/targeting-helpers.mjs +0 -6
  446. package/dist/lib/server/targeting-helpers.mjs.map +1 -1
  447. package/dist/lib/server/tasks.mjs +0 -6
  448. package/dist/lib/server/tasks.mjs.map +1 -1
  449. package/dist/lib/server/test-controller-bridge.mjs +0 -6
  450. package/dist/lib/server/test-controller-bridge.mjs.map +1 -1
  451. package/dist/lib/server/test-controller.mjs +0 -6
  452. package/dist/lib/server/test-controller.mjs.map +1 -1
  453. package/dist/lib/server/upstream-helpers.mjs +0 -6
  454. package/dist/lib/server/upstream-helpers.mjs.map +1 -1
  455. package/dist/lib/server/webhook-emitter.mjs +0 -6
  456. package/dist/lib/server/webhook-emitter.mjs.map +1 -1
  457. package/dist/lib/server/wire-safe.mjs +0 -6
  458. package/dist/lib/server/wire-safe.mjs.map +1 -1
  459. package/dist/lib/server/wire-spec-fields.generated.mjs +0 -6
  460. package/dist/lib/server/wire-spec-fields.generated.mjs.map +1 -1
  461. package/dist/lib/server/wrap-envelope.mjs +0 -6
  462. package/dist/lib/server/wrap-envelope.mjs.map +1 -1
  463. package/dist/lib/signing/agent-context.mjs +0 -6
  464. package/dist/lib/signing/agent-context.mjs.map +1 -1
  465. package/dist/lib/signing/agent-fetch.mjs +0 -6
  466. package/dist/lib/signing/agent-fetch.mjs.map +1 -1
  467. package/dist/lib/signing/agent-resolver/canonicalize.mjs +0 -6
  468. package/dist/lib/signing/agent-resolver/canonicalize.mjs.map +1 -1
  469. package/dist/lib/signing/agent-resolver/capabilities-types.mjs +0 -6
  470. package/dist/lib/signing/agent-resolver/capabilities-types.mjs.map +1 -1
  471. package/dist/lib/signing/agent-resolver/consistency.mjs +0 -6
  472. package/dist/lib/signing/agent-resolver/consistency.mjs.map +1 -1
  473. package/dist/lib/signing/agent-resolver/errors.mjs +0 -6
  474. package/dist/lib/signing/agent-resolver/errors.mjs.map +1 -1
  475. package/dist/lib/signing/agent-resolver/etld.mjs +0 -6
  476. package/dist/lib/signing/agent-resolver/etld.mjs.map +1 -1
  477. package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +0 -6
  478. package/dist/lib/signing/agent-resolver/fetch-helpers.mjs.map +1 -1
  479. package/dist/lib/signing/agent-resolver/index.mjs +0 -6
  480. package/dist/lib/signing/agent-resolver/index.mjs.map +1 -1
  481. package/dist/lib/signing/agent-resolver/jwks-set.mjs +0 -6
  482. package/dist/lib/signing/agent-resolver/jwks-set.mjs.map +1 -1
  483. package/dist/lib/signing/agent-resolver/resolve-agent.mjs +0 -6
  484. package/dist/lib/signing/agent-resolver/resolve-agent.mjs.map +1 -1
  485. package/dist/lib/signing/agent-resolver/select-agent.mjs +0 -6
  486. package/dist/lib/signing/agent-resolver/select-agent.mjs.map +1 -1
  487. package/dist/lib/signing/agent-resolver/strict-json.mjs +0 -6
  488. package/dist/lib/signing/agent-resolver/strict-json.mjs.map +1 -1
  489. package/dist/lib/signing/brand-jwks.mjs +0 -6
  490. package/dist/lib/signing/brand-jwks.mjs.map +1 -1
  491. package/dist/lib/signing/canonicalize.mjs +0 -6
  492. package/dist/lib/signing/canonicalize.mjs.map +1 -1
  493. package/dist/lib/signing/capability-cache.mjs +0 -6
  494. package/dist/lib/signing/capability-cache.mjs.map +1 -1
  495. package/dist/lib/signing/capability-priming.mjs +0 -6
  496. package/dist/lib/signing/capability-priming.mjs.map +1 -1
  497. package/dist/lib/signing/client.mjs +0 -6
  498. package/dist/lib/signing/client.mjs.map +1 -1
  499. package/dist/lib/signing/content-digest.mjs +0 -6
  500. package/dist/lib/signing/content-digest.mjs.map +1 -1
  501. package/dist/lib/signing/crypto.mjs +0 -6
  502. package/dist/lib/signing/crypto.mjs.map +1 -1
  503. package/dist/lib/signing/ecdsa-encoding.mjs +0 -6
  504. package/dist/lib/signing/ecdsa-encoding.mjs.map +1 -1
  505. package/dist/lib/signing/errors.mjs +0 -6
  506. package/dist/lib/signing/errors.mjs.map +1 -1
  507. package/dist/lib/signing/fetch-async.mjs +0 -6
  508. package/dist/lib/signing/fetch-async.mjs.map +1 -1
  509. package/dist/lib/signing/fetch.mjs +0 -6
  510. package/dist/lib/signing/fetch.mjs.map +1 -1
  511. package/dist/lib/signing/index.mjs +0 -6
  512. package/dist/lib/signing/index.mjs.map +1 -1
  513. package/dist/lib/signing/jwks-helpers.mjs +0 -6
  514. package/dist/lib/signing/jwks-helpers.mjs.map +1 -1
  515. package/dist/lib/signing/jwks-https.mjs +0 -6
  516. package/dist/lib/signing/jwks-https.mjs.map +1 -1
  517. package/dist/lib/signing/jwks.mjs +0 -6
  518. package/dist/lib/signing/jwks.mjs.map +1 -1
  519. package/dist/lib/signing/middleware.mjs +0 -6
  520. package/dist/lib/signing/middleware.mjs.map +1 -1
  521. package/dist/lib/signing/parser.mjs +0 -6
  522. package/dist/lib/signing/parser.mjs.map +1 -1
  523. package/dist/lib/signing/postgres-replay-store.mjs +0 -6
  524. package/dist/lib/signing/postgres-replay-store.mjs.map +1 -1
  525. package/dist/lib/signing/protocol-response.mjs +0 -6
  526. package/dist/lib/signing/protocol-response.mjs.map +1 -1
  527. package/dist/lib/signing/provider.mjs +0 -6
  528. package/dist/lib/signing/redis-replay-store.mjs +0 -6
  529. package/dist/lib/signing/redis-replay-store.mjs.map +1 -1
  530. package/dist/lib/signing/replay.mjs +0 -6
  531. package/dist/lib/signing/replay.mjs.map +1 -1
  532. package/dist/lib/signing/request-context.mjs +0 -6
  533. package/dist/lib/signing/request-context.mjs.map +1 -1
  534. package/dist/lib/signing/revocation-https.mjs +0 -6
  535. package/dist/lib/signing/revocation-https.mjs.map +1 -1
  536. package/dist/lib/signing/revocation.mjs +0 -6
  537. package/dist/lib/signing/revocation.mjs.map +1 -1
  538. package/dist/lib/signing/server.mjs +0 -6
  539. package/dist/lib/signing/server.mjs.map +1 -1
  540. package/dist/lib/signing/signer-async.mjs +0 -6
  541. package/dist/lib/signing/signer-async.mjs.map +1 -1
  542. package/dist/lib/signing/signer.mjs +0 -6
  543. package/dist/lib/signing/signer.mjs.map +1 -1
  544. package/dist/lib/signing/testing.mjs +0 -6
  545. package/dist/lib/signing/testing.mjs.map +1 -1
  546. package/dist/lib/signing/types.mjs +0 -6
  547. package/dist/lib/signing/types.mjs.map +1 -1
  548. package/dist/lib/signing/verifier.mjs +0 -6
  549. package/dist/lib/signing/verifier.mjs.map +1 -1
  550. package/dist/lib/signing/webhook-auth-detection.mjs +0 -6
  551. package/dist/lib/signing/webhook-auth-detection.mjs.map +1 -1
  552. package/dist/lib/signing/webhook-verifier.mjs +0 -6
  553. package/dist/lib/signing/webhook-verifier.mjs.map +1 -1
  554. package/dist/lib/storage/MemoryStorage.mjs +0 -6
  555. package/dist/lib/storage/MemoryStorage.mjs.map +1 -1
  556. package/dist/lib/storage/interfaces.mjs +0 -6
  557. package/dist/lib/substitution/encoder/SubstitutionEncoder.mjs +0 -6
  558. package/dist/lib/substitution/encoder/SubstitutionEncoder.mjs.map +1 -1
  559. package/dist/lib/substitution/encoder/index.mjs +0 -6
  560. package/dist/lib/substitution/encoder/index.mjs.map +1 -1
  561. package/dist/lib/substitution/index.mjs +0 -6
  562. package/dist/lib/substitution/index.mjs.map +1 -1
  563. package/dist/lib/substitution/observer/SubstitutionObserver.mjs +0 -6
  564. package/dist/lib/substitution/observer/SubstitutionObserver.mjs.map +1 -1
  565. package/dist/lib/substitution/observer/alignment.mjs +0 -6
  566. package/dist/lib/substitution/observer/alignment.mjs.map +1 -1
  567. package/dist/lib/substitution/observer/assertions.mjs +0 -6
  568. package/dist/lib/substitution/observer/assertions.mjs.map +1 -1
  569. package/dist/lib/substitution/observer/html-parser.mjs +0 -6
  570. package/dist/lib/substitution/observer/html-parser.mjs.map +1 -1
  571. package/dist/lib/substitution/observer/index.mjs +0 -6
  572. package/dist/lib/substitution/observer/index.mjs.map +1 -1
  573. package/dist/lib/substitution/observer/ssrf.mjs +0 -6
  574. package/dist/lib/substitution/observer/ssrf.mjs.map +1 -1
  575. package/dist/lib/substitution/rfc3986.mjs +0 -6
  576. package/dist/lib/substitution/rfc3986.mjs.map +1 -1
  577. package/dist/lib/substitution/translate.mjs +0 -6
  578. package/dist/lib/substitution/translate.mjs.map +1 -1
  579. package/dist/lib/substitution/types.mjs +0 -6
  580. package/dist/lib/substitution/vectors.mjs +0 -6
  581. package/dist/lib/substitution/vectors.mjs.map +1 -1
  582. package/dist/lib/testing/agent-tester.mjs +0 -6
  583. package/dist/lib/testing/agent-tester.mjs.map +1 -1
  584. package/dist/lib/testing/client.mjs +0 -6
  585. package/dist/lib/testing/client.mjs.map +1 -1
  586. package/dist/lib/testing/compliance/briefs.mjs +0 -6
  587. package/dist/lib/testing/compliance/briefs.mjs.map +1 -1
  588. package/dist/lib/testing/compliance/comply.mjs +0 -6
  589. package/dist/lib/testing/compliance/comply.mjs.map +1 -1
  590. package/dist/lib/testing/compliance/index.mjs +0 -6
  591. package/dist/lib/testing/compliance/index.mjs.map +1 -1
  592. package/dist/lib/testing/compliance/spec-conformance.mjs +0 -6
  593. package/dist/lib/testing/compliance/spec-conformance.mjs.map +1 -1
  594. package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -6
  595. package/dist/lib/testing/compliance/storyboard-tracks.mjs.map +1 -1
  596. package/dist/lib/testing/compliance/summary.mjs +0 -6
  597. package/dist/lib/testing/compliance/summary.mjs.map +1 -1
  598. package/dist/lib/testing/compliance/types.mjs +0 -6
  599. package/dist/lib/testing/comply-controller.mjs +0 -6
  600. package/dist/lib/testing/comply-controller.mjs.map +1 -1
  601. package/dist/lib/testing/controller-assertions.mjs +0 -6
  602. package/dist/lib/testing/controller-assertions.mjs.map +1 -1
  603. package/dist/lib/testing/formatter.mjs +0 -6
  604. package/dist/lib/testing/formatter.mjs.map +1 -1
  605. package/dist/lib/testing/index.mjs +0 -6
  606. package/dist/lib/testing/index.mjs.map +1 -1
  607. package/dist/lib/testing/local-agent-runner.mjs +0 -6
  608. package/dist/lib/testing/local-agent-runner.mjs.map +1 -1
  609. package/dist/lib/testing/orchestrator.mjs +0 -6
  610. package/dist/lib/testing/orchestrator.mjs.map +1 -1
  611. package/dist/lib/testing/personas/index.mjs +0 -6
  612. package/dist/lib/testing/personas/index.mjs.map +1 -1
  613. package/dist/lib/testing/scenarios/brand-rights.mjs +0 -6
  614. package/dist/lib/testing/scenarios/brand-rights.mjs.map +1 -1
  615. package/dist/lib/testing/scenarios/capabilities.mjs +0 -6
  616. package/dist/lib/testing/scenarios/capabilities.mjs.map +1 -1
  617. package/dist/lib/testing/scenarios/creative.mjs +0 -6
  618. package/dist/lib/testing/scenarios/creative.mjs.map +1 -1
  619. package/dist/lib/testing/scenarios/deterministic.mjs +0 -6
  620. package/dist/lib/testing/scenarios/deterministic.mjs.map +1 -1
  621. package/dist/lib/testing/scenarios/discovery.mjs +0 -6
  622. package/dist/lib/testing/scenarios/discovery.mjs.map +1 -1
  623. package/dist/lib/testing/scenarios/edge-cases.mjs +0 -6
  624. package/dist/lib/testing/scenarios/edge-cases.mjs.map +1 -1
  625. package/dist/lib/testing/scenarios/error-compliance.mjs +0 -6
  626. package/dist/lib/testing/scenarios/error-compliance.mjs.map +1 -1
  627. package/dist/lib/testing/scenarios/governance.mjs +0 -6
  628. package/dist/lib/testing/scenarios/governance.mjs.map +1 -1
  629. package/dist/lib/testing/scenarios/health.mjs +0 -6
  630. package/dist/lib/testing/scenarios/health.mjs.map +1 -1
  631. package/dist/lib/testing/scenarios/index.mjs +0 -6
  632. package/dist/lib/testing/scenarios/index.mjs.map +1 -1
  633. package/dist/lib/testing/scenarios/media-buy.mjs +0 -6
  634. package/dist/lib/testing/scenarios/media-buy.mjs.map +1 -1
  635. package/dist/lib/testing/scenarios/schema-compliance.mjs +0 -6
  636. package/dist/lib/testing/scenarios/schema-compliance.mjs.map +1 -1
  637. package/dist/lib/testing/scenarios/signals.mjs +0 -6
  638. package/dist/lib/testing/scenarios/signals.mjs.map +1 -1
  639. package/dist/lib/testing/scenarios/sponsored-intelligence.mjs +0 -6
  640. package/dist/lib/testing/scenarios/sponsored-intelligence.mjs.map +1 -1
  641. package/dist/lib/testing/scenarios/trusted-match.mjs +0 -6
  642. package/dist/lib/testing/scenarios/trusted-match.mjs.map +1 -1
  643. package/dist/lib/testing/seed-merge.mjs +0 -6
  644. package/dist/lib/testing/seed-merge.mjs.map +1 -1
  645. package/dist/lib/testing/storyboard/agent-routing.mjs +0 -6
  646. package/dist/lib/testing/storyboard/agent-routing.mjs.map +1 -1
  647. package/dist/lib/testing/storyboard/assertions.mjs +0 -6
  648. package/dist/lib/testing/storyboard/assertions.mjs.map +1 -1
  649. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +0 -6
  650. package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs.map +1 -1
  651. package/dist/lib/testing/storyboard/compliance.mjs +5 -6
  652. package/dist/lib/testing/storyboard/compliance.mjs.map +1 -1
  653. package/dist/lib/testing/storyboard/context.mjs +0 -6
  654. package/dist/lib/testing/storyboard/context.mjs.map +1 -1
  655. package/dist/lib/testing/storyboard/default-invariants.mjs +0 -6
  656. package/dist/lib/testing/storyboard/default-invariants.mjs.map +1 -1
  657. package/dist/lib/testing/storyboard/index.mjs +0 -6
  658. package/dist/lib/testing/storyboard/index.mjs.map +1 -1
  659. package/dist/lib/testing/storyboard/junit.mjs +0 -6
  660. package/dist/lib/testing/storyboard/junit.mjs.map +1 -1
  661. package/dist/lib/testing/storyboard/loader.mjs +0 -6
  662. package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
  663. package/dist/lib/testing/storyboard/parallel-dispatch.mjs +0 -6
  664. package/dist/lib/testing/storyboard/parallel-dispatch.mjs.map +1 -1
  665. package/dist/lib/testing/storyboard/path.mjs +0 -6
  666. package/dist/lib/testing/storyboard/path.mjs.map +1 -1
  667. package/dist/lib/testing/storyboard/probes.mjs +0 -6
  668. package/dist/lib/testing/storyboard/probes.mjs.map +1 -1
  669. package/dist/lib/testing/storyboard/rate-limit-trip.mjs +0 -6
  670. package/dist/lib/testing/storyboard/rate-limit-trip.mjs.map +1 -1
  671. package/dist/lib/testing/storyboard/rejection-hints.mjs +0 -6
  672. package/dist/lib/testing/storyboard/rejection-hints.mjs.map +1 -1
  673. package/dist/lib/testing/storyboard/request-builder.mjs +0 -6
  674. package/dist/lib/testing/storyboard/request-builder.mjs.map +1 -1
  675. package/dist/lib/testing/storyboard/request-signing/builder.mjs +0 -6
  676. package/dist/lib/testing/storyboard/request-signing/builder.mjs.map +1 -1
  677. package/dist/lib/testing/storyboard/request-signing/grader.mjs +0 -6
  678. package/dist/lib/testing/storyboard/request-signing/grader.mjs.map +1 -1
  679. package/dist/lib/testing/storyboard/request-signing/index.mjs +0 -6
  680. package/dist/lib/testing/storyboard/request-signing/index.mjs.map +1 -1
  681. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +0 -6
  682. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs.map +1 -1
  683. package/dist/lib/testing/storyboard/request-signing/probe.mjs +0 -6
  684. package/dist/lib/testing/storyboard/request-signing/probe.mjs.map +1 -1
  685. package/dist/lib/testing/storyboard/request-signing/synthesize.mjs +0 -6
  686. package/dist/lib/testing/storyboard/request-signing/synthesize.mjs.map +1 -1
  687. package/dist/lib/testing/storyboard/request-signing/test-kit.mjs +0 -6
  688. package/dist/lib/testing/storyboard/request-signing/test-kit.mjs.map +1 -1
  689. package/dist/lib/testing/storyboard/request-signing/types.mjs +0 -6
  690. package/dist/lib/testing/storyboard/request-signing/types.mjs.map +1 -1
  691. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +0 -6
  692. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs.map +1 -1
  693. package/dist/lib/testing/storyboard/runner.mjs +0 -6
  694. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  695. package/dist/lib/testing/storyboard/sandbox-entities.mjs +0 -6
  696. package/dist/lib/testing/storyboard/sandbox-entities.mjs.map +1 -1
  697. package/dist/lib/testing/storyboard/seeding.mjs +0 -6
  698. package/dist/lib/testing/storyboard/seeding.mjs.map +1 -1
  699. package/dist/lib/testing/storyboard/shape-drift-hints.mjs +0 -6
  700. package/dist/lib/testing/storyboard/shape-drift-hints.mjs.map +1 -1
  701. package/dist/lib/testing/storyboard/signer-grader/grader.mjs +0 -6
  702. package/dist/lib/testing/storyboard/signer-grader/grader.mjs.map +1 -1
  703. package/dist/lib/testing/storyboard/signer-grader/index.mjs +0 -6
  704. package/dist/lib/testing/storyboard/signer-grader/index.mjs.map +1 -1
  705. package/dist/lib/testing/storyboard/signer-grader/types.mjs +0 -6
  706. package/dist/lib/testing/storyboard/strict-validation-hints.mjs +0 -6
  707. package/dist/lib/testing/storyboard/strict-validation-hints.mjs.map +1 -1
  708. package/dist/lib/testing/storyboard/task-map.mjs +0 -6
  709. package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
  710. package/dist/lib/testing/storyboard/test-kit.mjs +0 -6
  711. package/dist/lib/testing/storyboard/test-kit.mjs.map +1 -1
  712. package/dist/lib/testing/storyboard/types.mjs +0 -6
  713. package/dist/lib/testing/storyboard/types.mjs.map +1 -1
  714. package/dist/lib/testing/storyboard/validations.mjs +0 -6
  715. package/dist/lib/testing/storyboard/validations.mjs.map +1 -1
  716. package/dist/lib/testing/storyboard/webhook-assertions.mjs +0 -6
  717. package/dist/lib/testing/storyboard/webhook-assertions.mjs.map +1 -1
  718. package/dist/lib/testing/storyboard/webhook-receiver.mjs +0 -6
  719. package/dist/lib/testing/storyboard/webhook-receiver.mjs.map +1 -1
  720. package/dist/lib/testing/stubs/governance-agent-stub.mjs +0 -6
  721. package/dist/lib/testing/stubs/governance-agent-stub.mjs.map +1 -1
  722. package/dist/lib/testing/stubs/index.mjs +0 -6
  723. package/dist/lib/testing/stubs/index.mjs.map +1 -1
  724. package/dist/lib/testing/test-controller.mjs +0 -6
  725. package/dist/lib/testing/test-controller.mjs.map +1 -1
  726. package/dist/lib/testing/test-helpers.mjs +0 -6
  727. package/dist/lib/testing/test-helpers.mjs.map +1 -1
  728. package/dist/lib/testing/types.mjs +0 -6
  729. package/dist/lib/types/adcp.mjs +0 -6
  730. package/dist/lib/types/adcp.mjs.map +1 -1
  731. package/dist/lib/types/asset-instances.mjs +0 -6
  732. package/dist/lib/types/compat.mjs +0 -6
  733. package/dist/lib/types/compat.mjs.map +1 -1
  734. package/dist/lib/types/core.generated.mjs +0 -6
  735. package/dist/lib/types/enums.generated.mjs +0 -6
  736. package/dist/lib/types/enums.generated.mjs.map +1 -1
  737. package/dist/lib/types/error-codes.mjs +0 -6
  738. package/dist/lib/types/error-codes.mjs.map +1 -1
  739. package/dist/lib/types/error-details.aliases.mjs +0 -6
  740. package/dist/lib/types/error-details.aliases.mjs.map +1 -1
  741. package/dist/lib/types/format-asset-slots.mjs +0 -6
  742. package/dist/lib/types/forward-compat-error-codes.mjs +0 -6
  743. package/dist/lib/types/forward-compat-error-codes.mjs.map +1 -1
  744. package/dist/lib/types/index.mjs +0 -6
  745. package/dist/lib/types/index.mjs.map +1 -1
  746. package/dist/lib/types/inline-enums.aliases.mjs +0 -6
  747. package/dist/lib/types/inline-enums.aliases.mjs.map +1 -1
  748. package/dist/lib/types/inline-enums.generated.mjs +0 -6
  749. package/dist/lib/types/inline-enums.generated.mjs.map +1 -1
  750. package/dist/lib/types/manifest.generated.mjs +0 -6
  751. package/dist/lib/types/manifest.generated.mjs.map +1 -1
  752. package/dist/lib/types/schemas.generated.mjs +0 -6
  753. package/dist/lib/types/schemas.generated.mjs.map +1 -1
  754. package/dist/lib/types/server-payload-aliases.mjs +0 -6
  755. package/dist/lib/types/server-payload.mjs +0 -6
  756. package/dist/lib/types/sync-rows.mjs +0 -6
  757. package/dist/lib/types/tools.generated.mjs +0 -6
  758. package/dist/lib/types/v2-5/index.mjs +0 -6
  759. package/dist/lib/types/v2-5/index.mjs.map +1 -1
  760. package/dist/lib/types/v2-5/tools.generated.mjs +0 -6
  761. package/dist/lib/types/v3-1-beta/index.mjs +0 -6
  762. package/dist/lib/types/v3-1-beta/index.mjs.map +1 -1
  763. package/dist/lib/types/v3-1-beta/tools.generated.mjs +0 -6
  764. package/dist/lib/types/wellknown-schemas.generated.mjs +0 -6
  765. package/dist/lib/types/wellknown-schemas.generated.mjs.map +1 -1
  766. package/dist/lib/upstream-recorder/constants.mjs +0 -6
  767. package/dist/lib/upstream-recorder/constants.mjs.map +1 -1
  768. package/dist/lib/upstream-recorder/index.mjs +0 -6
  769. package/dist/lib/upstream-recorder/index.mjs.map +1 -1
  770. package/dist/lib/upstream-recorder/recorder.mjs +0 -6
  771. package/dist/lib/upstream-recorder/recorder.mjs.map +1 -1
  772. package/dist/lib/upstream-recorder/types.mjs +0 -6
  773. package/dist/lib/upstream-recorder/types.mjs.map +1 -1
  774. package/dist/lib/utils/a2a-artifacts.mjs +0 -6
  775. package/dist/lib/utils/a2a-artifacts.mjs.map +1 -1
  776. package/dist/lib/utils/a2a-discovery.mjs +0 -6
  777. package/dist/lib/utils/a2a-discovery.mjs.map +1 -1
  778. package/dist/lib/utils/activation-key-builders.mjs +0 -6
  779. package/dist/lib/utils/activation-key-builders.mjs.map +1 -1
  780. package/dist/lib/utils/adcp-version-config.mjs +0 -6
  781. package/dist/lib/utils/adcp-version-config.mjs.map +1 -1
  782. package/dist/lib/utils/asset-builders.mjs +0 -6
  783. package/dist/lib/utils/asset-builders.mjs.map +1 -1
  784. package/dist/lib/utils/build-creative-return-builders.mjs +0 -6
  785. package/dist/lib/utils/build-creative-return-builders.mjs.map +1 -1
  786. package/dist/lib/utils/buyer-retry-policy.mjs +0 -6
  787. package/dist/lib/utils/buyer-retry-policy.mjs.map +1 -1
  788. package/dist/lib/utils/capabilities.mjs +0 -6
  789. package/dist/lib/utils/capabilities.mjs.map +1 -1
  790. package/dist/lib/utils/capability-rollups.mjs +0 -6
  791. package/dist/lib/utils/capability-rollups.mjs.map +1 -1
  792. package/dist/lib/utils/creative-adapter.mjs +0 -6
  793. package/dist/lib/utils/creative-adapter.mjs.map +1 -1
  794. package/dist/lib/utils/creative-delivery.mjs +0 -6
  795. package/dist/lib/utils/creative-delivery.mjs.map +1 -1
  796. package/dist/lib/utils/deprecation.mjs +0 -6
  797. package/dist/lib/utils/deprecation.mjs.map +1 -1
  798. package/dist/lib/utils/envelope-status-compat.mjs +0 -6
  799. package/dist/lib/utils/envelope-status-compat.mjs.map +1 -1
  800. package/dist/lib/utils/error-extraction.mjs +0 -6
  801. package/dist/lib/utils/error-extraction.mjs.map +1 -1
  802. package/dist/lib/utils/extract-result.mjs +0 -6
  803. package/dist/lib/utils/extract-result.mjs.map +1 -1
  804. package/dist/lib/utils/format-asset-slot-builders.mjs +0 -6
  805. package/dist/lib/utils/format-asset-slot-builders.mjs.map +1 -1
  806. package/dist/lib/utils/format-assets.mjs +0 -6
  807. package/dist/lib/utils/format-assets.mjs.map +1 -1
  808. package/dist/lib/utils/format-render-builders.mjs +0 -6
  809. package/dist/lib/utils/format-render-builders.mjs.map +1 -1
  810. package/dist/lib/utils/format-renders.mjs +0 -6
  811. package/dist/lib/utils/format-renders.mjs.map +1 -1
  812. package/dist/lib/utils/get-products-cache-scope.mjs +0 -6
  813. package/dist/lib/utils/get-products-cache-scope.mjs.map +1 -1
  814. package/dist/lib/utils/glob.mjs +0 -6
  815. package/dist/lib/utils/glob.mjs.map +1 -1
  816. package/dist/lib/utils/global-async-local-storage.mjs +0 -6
  817. package/dist/lib/utils/global-async-local-storage.mjs.map +1 -1
  818. package/dist/lib/utils/idempotency.mjs +0 -6
  819. package/dist/lib/utils/idempotency.mjs.map +1 -1
  820. package/dist/lib/utils/index.mjs +0 -6
  821. package/dist/lib/utils/index.mjs.map +1 -1
  822. package/dist/lib/utils/jcs.mjs +0 -6
  823. package/dist/lib/utils/jcs.mjs.map +1 -1
  824. package/dist/lib/utils/json-depth.mjs +0 -6
  825. package/dist/lib/utils/json-depth.mjs.map +1 -1
  826. package/dist/lib/utils/logger.mjs +0 -6
  827. package/dist/lib/utils/logger.mjs.map +1 -1
  828. package/dist/lib/utils/media-buy-delivery-notification-builders.mjs +0 -6
  829. package/dist/lib/utils/media-buy-delivery-notification-builders.mjs.map +1 -1
  830. package/dist/lib/utils/media-buy-status.mjs +0 -6
  831. package/dist/lib/utils/media-buy-status.mjs.map +1 -1
  832. package/dist/lib/utils/pagination.mjs +0 -6
  833. package/dist/lib/utils/pagination.mjs.map +1 -1
  834. package/dist/lib/utils/preview-creative-builders.mjs +0 -6
  835. package/dist/lib/utils/preview-creative-builders.mjs.map +1 -1
  836. package/dist/lib/utils/preview-normalizer.mjs +0 -6
  837. package/dist/lib/utils/preview-normalizer.mjs.map +1 -1
  838. package/dist/lib/utils/preview-utils.mjs +0 -6
  839. package/dist/lib/utils/preview-utils.mjs.map +1 -1
  840. package/dist/lib/utils/pricing-adapter.mjs +0 -6
  841. package/dist/lib/utils/pricing-adapter.mjs.map +1 -1
  842. package/dist/lib/utils/probe-policy.mjs +0 -6
  843. package/dist/lib/utils/probe-policy.mjs.map +1 -1
  844. package/dist/lib/utils/protocol-detection.mjs +0 -6
  845. package/dist/lib/utils/protocol-detection.mjs.map +1 -1
  846. package/dist/lib/utils/redact-secrets.mjs +0 -6
  847. package/dist/lib/utils/redact-secrets.mjs.map +1 -1
  848. package/dist/lib/utils/redis-default-prefix-warn.mjs +0 -6
  849. package/dist/lib/utils/redis-default-prefix-warn.mjs.map +1 -1
  850. package/dist/lib/utils/render-builders.mjs +0 -6
  851. package/dist/lib/utils/render-builders.mjs.map +1 -1
  852. package/dist/lib/utils/request-normalizer.mjs +0 -6
  853. package/dist/lib/utils/request-normalizer.mjs.map +1 -1
  854. package/dist/lib/utils/response-schemas.mjs +0 -6
  855. package/dist/lib/utils/response-schemas.mjs.map +1 -1
  856. package/dist/lib/utils/response-unwrapper.mjs +0 -6
  857. package/dist/lib/utils/response-unwrapper.mjs.map +1 -1
  858. package/dist/lib/utils/retry.mjs +0 -6
  859. package/dist/lib/utils/retry.mjs.map +1 -1
  860. package/dist/lib/utils/signal-discovery-helpers.mjs +0 -6
  861. package/dist/lib/utils/signal-discovery-helpers.mjs.map +1 -1
  862. package/dist/lib/utils/signal-id-builders.mjs +0 -6
  863. package/dist/lib/utils/signal-id-builders.mjs.map +1 -1
  864. package/dist/lib/utils/sync-creatives-adapter.mjs +0 -6
  865. package/dist/lib/utils/sync-creatives-adapter.mjs.map +1 -1
  866. package/dist/lib/utils/task-state.mjs +0 -6
  867. package/dist/lib/utils/task-state.mjs.map +1 -1
  868. package/dist/lib/utils/tool-request-schemas.mjs +0 -6
  869. package/dist/lib/utils/tool-request-schemas.mjs.map +1 -1
  870. package/dist/lib/utils/typeGuards.mjs +0 -6
  871. package/dist/lib/utils/typeGuards.mjs.map +1 -1
  872. package/dist/lib/utils/union-errors.mjs +0 -6
  873. package/dist/lib/utils/union-errors.mjs.map +1 -1
  874. package/dist/lib/utils/validate-user-agent.mjs +0 -6
  875. package/dist/lib/utils/validate-user-agent.mjs.map +1 -1
  876. package/dist/lib/v2/format-schema/fetch.mjs +0 -6
  877. package/dist/lib/v2/format-schema/fetch.mjs.map +1 -1
  878. package/dist/lib/v2/format-schema/index.mjs +0 -6
  879. package/dist/lib/v2/format-schema/index.mjs.map +1 -1
  880. package/dist/lib/v2/format-schema/regex-safety.mjs +0 -6
  881. package/dist/lib/v2/format-schema/regex-safety.mjs.map +1 -1
  882. package/dist/lib/v2/format-schema/resolver.mjs +7 -8
  883. package/dist/lib/v2/format-schema/resolver.mjs.map +1 -1
  884. package/dist/lib/v2/format-schema/sandbox-refs.mjs +0 -6
  885. package/dist/lib/v2/format-schema/sandbox-refs.mjs.map +1 -1
  886. package/dist/lib/v2/projection/augment-response.mjs +0 -6
  887. package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
  888. package/dist/lib/v2/projection/builders.mjs +0 -6
  889. package/dist/lib/v2/projection/builders.mjs.map +1 -1
  890. package/dist/lib/v2/projection/cache-versions.mjs +0 -6
  891. package/dist/lib/v2/projection/cache-versions.mjs.map +1 -1
  892. package/dist/lib/v2/projection/canonical-properties.mjs +5 -6
  893. package/dist/lib/v2/projection/canonical-properties.mjs.map +1 -1
  894. package/dist/lib/v2/projection/catalog.mjs +5 -6
  895. package/dist/lib/v2/projection/catalog.mjs.map +1 -1
  896. package/dist/lib/v2/projection/constants.mjs +0 -6
  897. package/dist/lib/v2/projection/constants.mjs.map +1 -1
  898. package/dist/lib/v2/projection/index.mjs +0 -6
  899. package/dist/lib/v2/projection/index.mjs.map +1 -1
  900. package/dist/lib/v2/projection/registry.mjs +5 -6
  901. package/dist/lib/v2/projection/registry.mjs.map +1 -1
  902. package/dist/lib/v2/projection/types.mjs +0 -6
  903. package/dist/lib/v2/projection/v1-to-v2.mjs +0 -6
  904. package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
  905. package/dist/lib/v2/projection/v2-to-v1.mjs +0 -6
  906. package/dist/lib/v2/projection/v2-to-v1.mjs.map +1 -1
  907. package/dist/lib/v2/projection/write-side.mjs +0 -6
  908. package/dist/lib/v2/projection/write-side.mjs.map +1 -1
  909. package/dist/lib/v2/publisher-catalog/formats.mjs +0 -6
  910. package/dist/lib/v2/publisher-catalog/formats.mjs.map +1 -1
  911. package/dist/lib/v2/publisher-catalog/index.mjs +0 -6
  912. package/dist/lib/v2/publisher-catalog/index.mjs.map +1 -1
  913. package/dist/lib/validation/client-hooks.mjs +0 -6
  914. package/dist/lib/validation/client-hooks.mjs.map +1 -1
  915. package/dist/lib/validation/hints.mjs +0 -6
  916. package/dist/lib/validation/hints.mjs.map +1 -1
  917. package/dist/lib/validation/index.mjs +0 -6
  918. package/dist/lib/validation/index.mjs.map +1 -1
  919. package/dist/lib/validation/schema-errors.mjs +0 -6
  920. package/dist/lib/validation/schema-errors.mjs.map +1 -1
  921. package/dist/lib/validation/schema-loader.mjs +5 -6
  922. package/dist/lib/validation/schema-loader.mjs.map +1 -1
  923. package/dist/lib/validation/schema-validator.mjs +0 -6
  924. package/dist/lib/validation/schema-validator.mjs.map +1 -1
  925. package/dist/lib/validation/sync-creatives.mjs +0 -6
  926. package/dist/lib/validation/sync-creatives.mjs.map +1 -1
  927. package/dist/lib/version.d.mts +3 -3
  928. package/dist/lib/version.d.ts +3 -3
  929. package/dist/lib/version.js +3 -3
  930. package/dist/lib/version.js.map +1 -1
  931. package/dist/lib/version.mjs +3 -9
  932. package/dist/lib/version.mjs.map +1 -1
  933. package/dist/lib/webhooks/index.mjs +0 -6
  934. package/dist/lib/webhooks/index.mjs.map +1 -1
  935. package/dist/lib/wholesale-feed-sync/index.mjs +0 -6
  936. package/dist/lib/wholesale-feed-sync/index.mjs.map +1 -1
  937. package/dist/lib/wholesale-feed-sync/sync.mjs +0 -6
  938. package/dist/lib/wholesale-feed-sync/sync.mjs.map +1 -1
  939. package/dist/lib/wholesale-feed-sync/types.mjs +0 -6
  940. package/dist/lib/wholesale-feed-sync/webhook-notification.mjs +0 -6
  941. package/dist/lib/wholesale-feed-sync/webhook-notification.mjs.map +1 -1
  942. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/server/auth-signature.ts"],"sourcesContent":["/**\n * Bridge between {@link verifyRequestSignature} and the {@link Authenticator}\n * surface so RFC 9421 signatures compose with bearer / API-key auth via\n * {@link anyOf}.\n *\n * Use when an agent declares the `signed-requests` specialism AND also\n * accepts bearer-authed callers — the composition signals \"either credential\n * type is sufficient\". Unsigned-but-bearered requests fall through to the\n * next authenticator; signed requests with a valid signature short-circuit\n * the chain and surface a principal derived from the signing key.\n *\n * A request with a present-but-invalid signature throws {@link AuthError}\n * so `serve()` can return a 401 — `anyOf` surfaces that as \"credentials\n * rejected\" rather than falling through.\n *\n * ```ts\n * import {\n * serve,\n * verifyApiKey,\n * anyOf,\n * verifySignatureAsAuthenticator,\n * mcpToolNameResolver,\n * } from '@adcp/sdk/server';\n *\n * serve(createAgent, {\n * authenticate: anyOf(\n * verifyApiKey({ keys: { 'sk_live_abc': { principal: 'acct_42' } } }),\n * verifySignatureAsAuthenticator({\n * jwks, replayStore, revocationStore,\n * capability: { supported: true, required_for: [], covers_content_digest: 'either' },\n * resolveOperation: mcpToolNameResolver,\n * }),\n * ),\n * });\n * ```\n *\n * The returned authenticator is tagged with {@link AUTH_NEEDS_RAW_BODY} so\n * `serve()` buffers `req.rawBody` before authentication runs.\n */\nimport type { IncomingMessage } from 'http';\nimport type { RequestLike } from '../signing/canonicalize';\nimport { RequestSignatureError } from '../signing/errors';\nimport type { JwksResolver } from '../signing/jwks';\nimport { InMemoryReplayStore, type ReplayStore } from '../signing/replay';\nimport { InMemoryRevocationStore, type RevocationStore } from '../signing/revocation';\nimport type { VerifiedSigner, VerifierCapability, VerifyResult } from '../signing/types';\nimport { verifyRequestSignature } from '../signing/verifier';\nimport { markVerifiedHttpSig } from './decisioning/buyer-agent';\nimport {\n AuthError,\n type AuthPrincipal,\n type AuthResult,\n type Authenticator,\n authenticatorNeedsRawBody,\n tagAuthenticatorNeedsRawBody,\n tagAuthenticatorPresenceGated,\n} from './auth';\n\nexport interface VerifySignatureAsAuthenticatorOptions {\n /** Verifier capability block. `required_for` is not enforced here — unsigned\n * requests fall through to the next authenticator — so set it to whatever\n * your `request_signing` capability claim advertises. */\n capability: VerifierCapability;\n /** Resolves verification keys by `keyid`. */\n jwks: JwksResolver;\n /**\n * Stores `(keyid, signature-bytes, expires)` tuples for replay detection.\n * Defaults to a fresh {@link InMemoryReplayStore} — fine for single-process\n * deployments. Wire a shared store (Redis, Postgres, etc.) for multi-replica\n * setups where a signature accepted on one replica must be rejected on the\n * others.\n */\n replayStore?: ReplayStore;\n /**\n * Consulted for revoked `kid` / `jti` before accepting a signature.\n * Defaults to a fresh {@link InMemoryRevocationStore}. Most agents don't\n * revoke at runtime; when you do, swap in a store backed by your secrets\n * manager or admin tooling.\n */\n revocationStore?: RevocationStore;\n /** Override clock for tests. */\n now?: () => number;\n /**\n * Extract the AdCP operation name from the incoming request. Called with\n * the raw `IncomingMessage`; `req.rawBody` has been buffered by `serve()`\n * before this runs. Same semantics as\n * `ExpressMiddlewareOptions.resolveOperation` on {@link createExpressVerifier}.\n *\n * SECURITY: a resolver that always returns `undefined` disables\n * `capability.required_for` enforcement for this authenticator. Since the\n * bypass here is intentional (this adapter is for composition with other\n * authenticators — see the module docstring), the fall-through still\n * happens when the resolver returns `undefined`, so `required_for`\n * enforcement should live in a separate `preTransport`-mounted verifier\n * when composition is active.\n */\n resolveOperation: (req: IncomingMessage & { rawBody?: string }) => string | undefined;\n /**\n * Override how the request's full URL is reconstructed. Use when the\n * server sits behind a TLS-terminating or path-rewriting load balancer\n * and `req.headers.host` / `req.url` don't reflect what the signer signed.\n */\n getUrl?: (req: IncomingMessage & { rawBody?: string }) => string;\n /** Resolve the `agent_url` claim the verifier stamps on verified results. */\n agentUrlForKeyid?: (keyid: string) => string | undefined;\n /**\n * Shape the principal returned on successful signature verification.\n * Defaults to `{ principal: `signing:${keyid}`, claims: { signature: VerifiedSigner } }`.\n */\n makePrincipal?: (signer: VerifiedSigner) => AuthPrincipal;\n}\n\n/**\n * Build an {@link Authenticator} that verifies an RFC 9421 request signature.\n *\n * Behavior matrix:\n * - No `Signature-Input` header → returns `null` (fall through to next authenticator).\n * - Signature present and valid → returns {@link AuthPrincipal}.\n * - Signature present but invalid → throws {@link AuthError} (surfaces as 401).\n *\n * Populates `req.verifiedSigner` on success so downstream handlers see the\n * same side-channel state as the Express-shaped middleware.\n */\nexport function verifySignatureAsAuthenticator(options: VerifySignatureAsAuthenticatorOptions): Authenticator {\n // Instantiate defaults once at wire-up time so every request on this\n // authenticator shares the same replay/revocation state — lazy\n // per-request construction would defeat replay detection entirely.\n const replayStore = options.replayStore ?? new InMemoryReplayStore();\n const revocationStore = options.revocationStore ?? new InMemoryRevocationStore();\n\n const authenticator: Authenticator = async req => {\n if (!hasSignatureHeader(req)) return null;\n\n const body = (req as IncomingMessage & { rawBody?: string }).rawBody ?? '';\n const url = options.getUrl ? options.getUrl(req as IncomingMessage & { rawBody?: string }) : defaultUrl(req);\n const requestLike: RequestLike = {\n method: req.method ?? 'GET',\n url,\n headers: req.headers,\n body,\n };\n\n let result: VerifyResult;\n try {\n result = await verifyRequestSignature(requestLike, {\n capability: options.capability,\n jwks: options.jwks,\n replayStore,\n revocationStore,\n now: options.now,\n operation: options.resolveOperation(req as IncomingMessage & { rawBody?: string }),\n agentUrlForKeyid: options.agentUrlForKeyid,\n });\n } catch (err) {\n if (err instanceof RequestSignatureError) {\n throw new AuthError(`Signature rejected (${err.code}).`, { cause: err });\n }\n throw new AuthError('Signature verification failed.', { cause: err });\n }\n\n if (result.status !== 'verified') {\n // Unreachable: `hasSignatureHeader` already gated entry, so the verifier\n // either throws (missing-pair / invalid / replayed / etc.) or returns\n // `status: 'verified'`. Fail loud if the verifier contract changes —\n // silently returning `null` would fall through to the next authenticator\n // as if no signature were present, breaking the auth invariant.\n throw new AuthError('Signature verification returned unexpected status.', {\n cause: new Error(`verifier returned status=\"${result.status}\"`),\n });\n }\n\n // keyid is buyer-controlled (JWK spec places no charset restriction on\n // `kid`). Bound it to a URL-safe shape — explicitly excluding `:` — before\n // interpolating into the principal string, so downstream tenant-isolation\n // checks that split `signing:<keyid>` on the first `:` can't be confused\n // by a colon embedded in the signer's key id.\n if (!SAFE_KEYID.test(result.keyid)) {\n throw new AuthError('Signature key id contains unsupported characters.', {\n cause: new Error(`keyid=${JSON.stringify(result.keyid)} fails /^[A-Za-z0-9._-]{1,256}$/`),\n });\n }\n\n const signer: VerifiedSigner = {\n keyid: result.keyid,\n verified_at: result.verified_at,\n ...(result.agent_url !== undefined ? { agent_url: result.agent_url } : {}),\n };\n\n // Stamp the kind-discriminated `credential` variant for the framework's\n // dispatcher and `BuyerAgentRegistry` resolution (Phase 1 Stage 3 of\n // #1269). Per adcontextprotocol/adcp#3831, `agent_url` here is the\n // verifier's `agentUrlForKeyid` lookup result — derived from the\n // `agents[]` entry whose `jwks_uri` resolved the keyid.\n //\n // When `agent_url` is unset (verifier wired without a keyid→agent URL\n // resolver), we OMIT the `credential` rather than synthesize an\n // `http_sig` variant that would otherwise carry an empty agent_url —\n // Stage 1's runtime guard rejects malformed http_sig credentials, so\n // emitting one would just trip the guard and confuse the audit trail.\n const credential =\n signer.agent_url !== undefined\n ? markVerifiedHttpSig({\n kind: 'http_sig',\n keyid: signer.keyid,\n agent_url: signer.agent_url,\n verified_at: signer.verified_at,\n })\n : undefined;\n\n const principal = options.makePrincipal\n ? options.makePrincipal(signer)\n : {\n principal: `signing:${signer.keyid}`,\n claims: {\n signature: {\n keyid: signer.keyid,\n verified_at: signer.verified_at,\n ...(signer.agent_url !== undefined ? { agent_url: signer.agent_url } : {}),\n },\n },\n ...(credential !== undefined && { credential }),\n };\n\n // Write the side-channel state only after the principal is fully built so\n // a throw from `makePrincipal` leaves `req.verifiedSigner` unset — the\n // request didn't actually authenticate, downstream handlers must not see\n // a stale \"verified\" marker on a rejected request.\n (req as IncomingMessage & { verifiedSigner?: VerifiedSigner }).verifiedSigner = signer;\n return principal;\n };\n\n return tagAuthenticatorNeedsRawBody(authenticator);\n}\n\n/**\n * Compose a signature authenticator with a fallback under presence-gated\n * semantics: if the incoming request declares a `Signature-Input` header,\n * the signature authenticator is the ONLY path — its result (principal,\n * `null`, or thrown {@link AuthError}) is the final outcome and the fallback\n * never runs. Without `Signature-Input`, the fallback handles the request.\n *\n * This is the correct composition for the `signed-requests` specialism.\n * {@link anyOf}'s either-or contract incorrectly accepts a bearer-authed\n * request whose signature is present-but-invalid — fine for \"either\n * credential is sufficient\" but wrong for spec conformance, where a\n * declared-but-invalid signature MUST be rejected even when a valid bearer\n * accompanies it (revocation, window expiry, malformed covered-components,\n * etc.).\n *\n * ```ts\n * import {\n * serve,\n * anyOf,\n * verifyApiKey,\n * verifySignatureAsAuthenticator,\n * requireSignatureWhenPresent,\n * } from '@adcp/sdk/server';\n *\n * serve(createAgent, {\n * authenticate: requireSignatureWhenPresent(\n * verifySignatureAsAuthenticator({ jwks, replayStore, revocationStore, capability, resolveOperation }),\n * anyOf(verifyApiKey({ keys }), verifyBearer({ jwksUri, issuer, audience })),\n * ),\n * });\n * ```\n *\n * Presence is detected from RFC 9421 signature headers: either\n * `Signature-Input` or the paired `Signature`. A request carrying only one of\n * the two is malformed but still treated as \"signed intent\" — the signature\n * authenticator runs and throws, which is what AdCP's negative conformance\n * vectors expect.\n *\n * Behavior matrix:\n *\n * | RFC 9421 signature header present? | Signature result | Outcome |\n * |------------------------------------|---------------------------|------------------------------|\n * | yes | verified | signature principal |\n * | yes | throws {@link AuthError} | 401 (does NOT fall through) |\n * | yes | returns `null` | 401 via re-thrown `AuthError` (does NOT fall through) |\n * | no | — | fallback runs verbatim |\n *\n * The returned authenticator is tagged with {@link AUTH_NEEDS_RAW_BODY} when\n * either branch needs the raw body, so `serve()` buffers `req.rawBody` ahead\n * of authentication.\n *\n * **Do not nest this helper inside {@link anyOf}.** `anyOf` catches thrown\n * `AuthError`s and tries the next authenticator, which re-introduces the\n * bypass this helper exists to prevent. `anyOf` refuses such composition at\n * wire-up time (throws synchronously) — invert the order instead:\n * `requireSignatureWhenPresent(sig, anyOf(bearer, apiKey))`.\n */\nexport interface RequireSignatureWhenPresentOptions {\n /**\n * Operations that MUST be signed. When the incoming request carries no\n * RFC 9421 signature header AND the fallback authenticator returns\n * `null` (no credentials at all), the gate throws an {@link AuthError}\n * whose `cause` is {@link RequestSignatureError} with\n * `request_signature_required` — `serve()` maps that into a 401 with\n * `WWW-Authenticate: Signature error=\"request_signature_required\"`.\n *\n * \"Fallback bypass\" is deliberately allowed: if the caller presents a\n * valid bearer (or API key) on a `requiredFor` operation, the fallback\n * succeeds and the request is accepted without a signature. This\n * matches the consensus on\n * [adcp#2586](https://github.com/adcontextprotocol/adcp/issues/2586):\n * `required_for` signals \"signatures are the mandatory mechanism for\n * unauthenticated callers\" — not \"signatures are mandatory on top of\n * every other credential.\"\n *\n * When the request IS signed, `required_for` enforcement happens inside\n * the signature verifier itself (via `capability.required_for`), not\n * here — this pre-check is only for the no-signature path.\n */\n requiredFor?: readonly string[];\n /**\n * Extract the AdCP operation name (or any identifier that can be\n * matched against `requiredFor`) from the incoming request.\n *\n * For MCP agents, pass the exported {@link mcpToolNameResolver} — it\n * implements the standard `tools/call` → `params.name` parse. For A2A\n * agents (or other non-JSON-RPC envelopes), supply a bespoke resolver.\n *\n * When `requiredFor` is set but `resolveOperation` is omitted OR\n * returns `undefined`, the pre-check is skipped — better to let the\n * downstream handler produce a precise `INVALID_REQUEST` than to\n * reject every unsigned call as signature-required.\n */\n resolveOperation?: (req: IncomingMessage & { rawBody?: string }) => string | undefined;\n}\n\n/**\n * Compose a signature authenticator with a fallback under presence-gated\n * semantics: if the incoming request declares a `Signature-Input` header,\n * the signature authenticator is the ONLY path — its result (principal,\n * `null`, or thrown {@link AuthError}) is the final outcome and the fallback\n * never runs. Without `Signature-Input`, the fallback handles the request.\n *\n * Pass {@link RequireSignatureWhenPresentOptions.requiredFor} to enforce\n * `required_for` for the no-signature path: when the fallback produces no\n * principal on an operation that MUST be signed, the gate throws an\n * {@link AuthError} whose cause is a {@link RequestSignatureError} with\n * code `request_signature_required` — `serve()` maps that into a 401\n * with the RFC 9421 `WWW-Authenticate: Signature` challenge.\n */\nexport function requireSignatureWhenPresent(\n signatureAuth: Authenticator,\n fallbackAuth: Authenticator,\n options: RequireSignatureWhenPresentOptions = {}\n): Authenticator {\n const requiredFor = new Set(options.requiredFor ?? []);\n const resolveOperation = options.resolveOperation;\n const combined: Authenticator = async req => {\n if (hasSignatureHeader(req)) {\n const result = await signatureAuth(req);\n if (result === null) {\n // A signature was declared but the sig authenticator didn't recognize\n // it. Falling through to the fallback would re-open the bypass the\n // presence gate exists to prevent — fail closed.\n throw new AuthError('Signature declared but not recognized.');\n }\n return result;\n }\n // Catch the fallback's throw so the `requiredFor` pre-check can run\n // regardless of fallback outcome. Without this, a caller presenting\n // a bad bearer on a required-for op triggers `anyOf` to throw an\n // `AuthError` with Bearer semantics, propagating past the pre-check\n // and producing `WWW-Authenticate: Bearer` — the conformance grader\n // reads the wrong error code on the exact vector this helper\n // exists to close.\n let fallbackResult: AuthResult | null = null;\n let fallbackError: unknown;\n let fallbackThrew = false;\n try {\n fallbackResult = await fallbackAuth(req);\n } catch (err) {\n fallbackThrew = true;\n fallbackError = err;\n }\n // Valid fallback principal short-circuits everything: this is the\n // documented \"bearer bypass on required_for\" semantic (per adcp#2586 —\n // a valid credential is sufficient even when signing is required for\n // unauthenticated callers). Return before the pre-check so the\n // control flow below only runs on `fallbackResult === null`.\n if (fallbackResult !== null) return fallbackResult;\n // `requiredFor` pre-check: when the op requires a signature AND no\n // signature was presented AND no valid fallback credential,\n // surface `request_signature_required` regardless of whether the\n // fallback threw (bad bearer) or returned null (no creds).\n if (requiredFor.size > 0 && resolveOperation) {\n const operation = resolveOperation(req as IncomingMessage & { rawBody?: string });\n if (operation && requiredFor.has(operation)) {\n throw new AuthError(`Signature required for ${operation}.`, {\n cause: new RequestSignatureError(\n 'request_signature_required',\n 0,\n `Operation ${operation} requires an RFC 9421 request signature when no other credentials are presented.`\n ),\n });\n }\n }\n // Op not in requiredFor (or no resolver): rethrow the fallback's\n // original error so the 401 carries the fallback's challenge\n // (Bearer for bad-bearer, invalid_token for no-creds).\n if (fallbackThrew) throw fallbackError;\n return null;\n };\n const anyChildNeedsRawBody = authenticatorNeedsRawBody(signatureAuth) || authenticatorNeedsRawBody(fallbackAuth);\n // When `resolveOperation` is wired, it almost always reads\n // `req.rawBody` to parse the JSON-RPC body — the SDK's documented\n // pattern. If no child is tagged (test stubs, agents whose signature\n // path is non-SDK), `serve()` won't buffer the body and\n // `resolveOperation` silently sees `undefined`, bypassing\n // `requiredFor`. Tag the combined authenticator whenever a resolver\n // is present so buffering happens regardless of the child shapes.\n if (anyChildNeedsRawBody || resolveOperation) {\n tagAuthenticatorNeedsRawBody(combined);\n }\n tagAuthenticatorPresenceGated(combined);\n return combined;\n}\n\nexport interface RequireAuthenticatedOrSignedOptions {\n /** RFC 9421 request-signature authenticator. Usually built with {@link verifySignatureAsAuthenticator}. */\n signature: Authenticator;\n /**\n * Credential authenticator that runs when no signature is present.\n * Usually {@link anyOf} of `verifyApiKey` / `verifyBearer` — whatever\n * credential types the agent accepts on unsigned calls.\n */\n fallback: Authenticator;\n /**\n * Operations that MUST be authenticated with a signature when no other\n * credential is presented. See\n * {@link RequireSignatureWhenPresentOptions.requiredFor}.\n *\n * Pass `MUTATING_TASKS` (exported from `@adcp/sdk`) to require\n * signatures on every mutating AdCP operation — matches the common\n * declaration in `capabilities.request_signing.required_for`.\n */\n requiredFor?: readonly string[];\n /** See {@link RequireSignatureWhenPresentOptions.resolveOperation}. */\n resolveOperation?: (req: IncomingMessage & { rawBody?: string }) => string | undefined;\n}\n\n/**\n * Bundled composition of {@link requireSignatureWhenPresent} with an\n * operation resolver — one call produces an authenticator that:\n *\n * 1. Prefers the RFC 9421 signature path when a `Signature-Input`\n * header is present, with no bearer fall-through on invalid\n * signatures (matches the `signed-requests` specialism contract).\n * 2. Accepts bearer / API key when no signature is present, including\n * on `requiredFor` operations — valid credentials bypass the\n * signature requirement.\n * 3. Rejects unsigned calls with no credentials on `requiredFor`\n * operations with a `WWW-Authenticate: Signature` challenge whose\n * error is `request_signature_required`.\n *\n * ```ts\n * import {\n * serve,\n * verifyApiKey,\n * verifyBearer,\n * anyOf,\n * verifySignatureAsAuthenticator,\n * requireAuthenticatedOrSigned,\n * mcpToolNameResolver,\n * MUTATING_TASKS,\n * } from '@adcp/sdk/server';\n *\n * serve(createAgent, {\n * authenticate: requireAuthenticatedOrSigned({\n * signature: verifySignatureAsAuthenticator({\n * jwks, replayStore, revocationStore, capability,\n * resolveOperation: mcpToolNameResolver,\n * }),\n * fallback: anyOf(verifyApiKey({ keys }), verifyBearer({ jwksUri, issuer, audience })),\n * requiredFor: [...MUTATING_TASKS],\n * resolveOperation: mcpToolNameResolver,\n * }),\n * });\n * ```\n */\nexport function requireAuthenticatedOrSigned(options: RequireAuthenticatedOrSignedOptions): Authenticator {\n return requireSignatureWhenPresent(options.signature, options.fallback, {\n requiredFor: options.requiredFor,\n resolveOperation: options.resolveOperation,\n });\n}\n\n/**\n * Default `resolveOperation` for MCP agents. Parses the buffered JSON-RPC\n * body on `req.rawBody` and returns `params.name` when `method === 'tools/call'`.\n * Returns `undefined` for non-`tools/call` methods, a missing body, or\n * malformed JSON — the same \"skip the pre-check and let the handler produce\n * a precise error\" semantics every other `resolveOperation` in the SDK\n * uses.\n *\n * Pass directly as `resolveOperation` on {@link verifySignatureAsAuthenticator},\n * {@link requireSignatureWhenPresent}, {@link requireAuthenticatedOrSigned},\n * or `createExpressVerifier` from `@adcp/sdk/signing`:\n *\n * ```ts\n * serve(createAgent, {\n * authenticate: requireAuthenticatedOrSigned({\n * signature: verifySignatureAsAuthenticator({\n * jwks, replayStore, revocationStore, capability,\n * resolveOperation: mcpToolNameResolver,\n * }),\n * fallback: anyOf(verifyApiKey({ keys }), verifyBearer({ jwksUri, issuer, audience })),\n * requiredFor: [...MUTATING_TASKS],\n * resolveOperation: mcpToolNameResolver,\n * }),\n * });\n * ```\n *\n * A2A agents use a different envelope — write a bespoke resolver there.\n */\nexport function mcpToolNameResolver(req: { rawBody?: string }): string | undefined {\n const raw = req.rawBody;\n if (!raw) return undefined;\n try {\n const body = JSON.parse(raw) as { method?: unknown; params?: unknown };\n if (body?.method !== 'tools/call') return undefined;\n const params = body.params as { name?: unknown } | undefined;\n return typeof params?.name === 'string' ? params.name : undefined;\n } catch {\n return undefined;\n }\n}\n\nconst SAFE_KEYID = /^[A-Za-z0-9._-]{1,256}$/;\n\nfunction hasSignatureHeader(req: IncomingMessage): boolean {\n // RFC 9421 pairs `Signature-Input` with `Signature`. Either is sufficient\n // \"signed intent\" — a request carrying only one is malformed, but routing\n // it to the fallback would mean a half-formed signing attempt (e.g., client\n // bug that dropped the Signature-Input header) silently auths via bearer.\n // Fail closed: send it to the signature authenticator, which will throw.\n return nonEmptyHeader(req.headers['signature-input']) || nonEmptyHeader(req.headers['signature']);\n}\n\nfunction nonEmptyHeader(v: string | string[] | undefined): boolean {\n if (typeof v === 'string') return v.length > 0;\n if (Array.isArray(v)) return v.length > 0;\n return false;\n}\n\nfunction defaultUrl(req: IncomingMessage): string {\n const forwardedProto = firstHeader(req.headers['x-forwarded-proto']);\n const encrypted = (req.socket as { encrypted?: boolean } | undefined)?.encrypted === true;\n const proto = forwardedProto ?? (encrypted ? 'https' : 'http');\n const host = firstHeader(req.headers['host']);\n if (!host) {\n throw new Error(\n 'verifySignatureAsAuthenticator: missing Host header. Pass `getUrl` to reconstruct the canonical URL explicitly.'\n );\n }\n return `${proto}://${host}${req.url ?? '/'}`;\n}\n\nfunction firstHeader(value: string | string[] | undefined): string | undefined {\n if (typeof value === 'string') return value;\n if (Array.isArray(value) && value.length > 0) return value[0];\n return undefined;\n}\n"],"mappings":";;;;;;AAyCA,SAAS,6BAA6B;AAEtC,SAAS,2BAA6C;AACtD,SAAS,+BAAqD;AAE9D,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAmEA,SAAS,+BAA+B,SAA+D;AAI5G,QAAM,cAAc,QAAQ,eAAe,IAAI,oBAAoB;AACnE,QAAM,kBAAkB,QAAQ,mBAAmB,IAAI,wBAAwB;AAE/E,QAAM,gBAA+B,OAAM,QAAO;AAChD,QAAI,CAAC,mBAAmB,GAAG,EAAG,QAAO;AAErC,UAAM,OAAQ,IAA+C,WAAW;AACxE,UAAM,MAAM,QAAQ,SAAS,QAAQ,OAAO,GAA6C,IAAI,WAAW,GAAG;AAC3G,UAAM,cAA2B;AAAA,MAC/B,QAAQ,IAAI,UAAU;AAAA,MACtB;AAAA,MACA,SAAS,IAAI;AAAA,MACb;AAAA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AAO,MAAM,CAAC;AAC5D,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/server/auth-signature.ts"],"sourcesContent":["/**\n * Bridge between {@link verifyRequestSignature} and the {@link Authenticator}\n * surface so RFC 9421 signatures compose with bearer / API-key auth via\n * {@link anyOf}.\n *\n * Use when an agent declares the `signed-requests` specialism AND also\n * accepts bearer-authed callers — the composition signals \"either credential\n * type is sufficient\". Unsigned-but-bearered requests fall through to the\n * next authenticator; signed requests with a valid signature short-circuit\n * the chain and surface a principal derived from the signing key.\n *\n * A request with a present-but-invalid signature throws {@link AuthError}\n * so `serve()` can return a 401 — `anyOf` surfaces that as \"credentials\n * rejected\" rather than falling through.\n *\n * ```ts\n * import {\n * serve,\n * verifyApiKey,\n * anyOf,\n * verifySignatureAsAuthenticator,\n * mcpToolNameResolver,\n * } from '@adcp/sdk/server';\n *\n * serve(createAgent, {\n * authenticate: anyOf(\n * verifyApiKey({ keys: { 'sk_live_abc': { principal: 'acct_42' } } }),\n * verifySignatureAsAuthenticator({\n * jwks, replayStore, revocationStore,\n * capability: { supported: true, required_for: [], covers_content_digest: 'either' },\n * resolveOperation: mcpToolNameResolver,\n * }),\n * ),\n * });\n * ```\n *\n * The returned authenticator is tagged with {@link AUTH_NEEDS_RAW_BODY} so\n * `serve()` buffers `req.rawBody` before authentication runs.\n */\nimport type { IncomingMessage } from 'http';\nimport type { RequestLike } from '../signing/canonicalize';\nimport { RequestSignatureError } from '../signing/errors';\nimport type { JwksResolver } from '../signing/jwks';\nimport { InMemoryReplayStore, type ReplayStore } from '../signing/replay';\nimport { InMemoryRevocationStore, type RevocationStore } from '../signing/revocation';\nimport type { VerifiedSigner, VerifierCapability, VerifyResult } from '../signing/types';\nimport { verifyRequestSignature } from '../signing/verifier';\nimport { markVerifiedHttpSig } from './decisioning/buyer-agent';\nimport {\n AuthError,\n type AuthPrincipal,\n type AuthResult,\n type Authenticator,\n authenticatorNeedsRawBody,\n tagAuthenticatorNeedsRawBody,\n tagAuthenticatorPresenceGated,\n} from './auth';\n\nexport interface VerifySignatureAsAuthenticatorOptions {\n /** Verifier capability block. `required_for` is not enforced here — unsigned\n * requests fall through to the next authenticator — so set it to whatever\n * your `request_signing` capability claim advertises. */\n capability: VerifierCapability;\n /** Resolves verification keys by `keyid`. */\n jwks: JwksResolver;\n /**\n * Stores `(keyid, signature-bytes, expires)` tuples for replay detection.\n * Defaults to a fresh {@link InMemoryReplayStore} — fine for single-process\n * deployments. Wire a shared store (Redis, Postgres, etc.) for multi-replica\n * setups where a signature accepted on one replica must be rejected on the\n * others.\n */\n replayStore?: ReplayStore;\n /**\n * Consulted for revoked `kid` / `jti` before accepting a signature.\n * Defaults to a fresh {@link InMemoryRevocationStore}. Most agents don't\n * revoke at runtime; when you do, swap in a store backed by your secrets\n * manager or admin tooling.\n */\n revocationStore?: RevocationStore;\n /** Override clock for tests. */\n now?: () => number;\n /**\n * Extract the AdCP operation name from the incoming request. Called with\n * the raw `IncomingMessage`; `req.rawBody` has been buffered by `serve()`\n * before this runs. Same semantics as\n * `ExpressMiddlewareOptions.resolveOperation` on {@link createExpressVerifier}.\n *\n * SECURITY: a resolver that always returns `undefined` disables\n * `capability.required_for` enforcement for this authenticator. Since the\n * bypass here is intentional (this adapter is for composition with other\n * authenticators — see the module docstring), the fall-through still\n * happens when the resolver returns `undefined`, so `required_for`\n * enforcement should live in a separate `preTransport`-mounted verifier\n * when composition is active.\n */\n resolveOperation: (req: IncomingMessage & { rawBody?: string }) => string | undefined;\n /**\n * Override how the request's full URL is reconstructed. Use when the\n * server sits behind a TLS-terminating or path-rewriting load balancer\n * and `req.headers.host` / `req.url` don't reflect what the signer signed.\n */\n getUrl?: (req: IncomingMessage & { rawBody?: string }) => string;\n /** Resolve the `agent_url` claim the verifier stamps on verified results. */\n agentUrlForKeyid?: (keyid: string) => string | undefined;\n /**\n * Shape the principal returned on successful signature verification.\n * Defaults to `{ principal: `signing:${keyid}`, claims: { signature: VerifiedSigner } }`.\n */\n makePrincipal?: (signer: VerifiedSigner) => AuthPrincipal;\n}\n\n/**\n * Build an {@link Authenticator} that verifies an RFC 9421 request signature.\n *\n * Behavior matrix:\n * - No `Signature-Input` header → returns `null` (fall through to next authenticator).\n * - Signature present and valid → returns {@link AuthPrincipal}.\n * - Signature present but invalid → throws {@link AuthError} (surfaces as 401).\n *\n * Populates `req.verifiedSigner` on success so downstream handlers see the\n * same side-channel state as the Express-shaped middleware.\n */\nexport function verifySignatureAsAuthenticator(options: VerifySignatureAsAuthenticatorOptions): Authenticator {\n // Instantiate defaults once at wire-up time so every request on this\n // authenticator shares the same replay/revocation state — lazy\n // per-request construction would defeat replay detection entirely.\n const replayStore = options.replayStore ?? new InMemoryReplayStore();\n const revocationStore = options.revocationStore ?? new InMemoryRevocationStore();\n\n const authenticator: Authenticator = async req => {\n if (!hasSignatureHeader(req)) return null;\n\n const body = (req as IncomingMessage & { rawBody?: string }).rawBody ?? '';\n const url = options.getUrl ? options.getUrl(req as IncomingMessage & { rawBody?: string }) : defaultUrl(req);\n const requestLike: RequestLike = {\n method: req.method ?? 'GET',\n url,\n headers: req.headers,\n body,\n };\n\n let result: VerifyResult;\n try {\n result = await verifyRequestSignature(requestLike, {\n capability: options.capability,\n jwks: options.jwks,\n replayStore,\n revocationStore,\n now: options.now,\n operation: options.resolveOperation(req as IncomingMessage & { rawBody?: string }),\n agentUrlForKeyid: options.agentUrlForKeyid,\n });\n } catch (err) {\n if (err instanceof RequestSignatureError) {\n throw new AuthError(`Signature rejected (${err.code}).`, { cause: err });\n }\n throw new AuthError('Signature verification failed.', { cause: err });\n }\n\n if (result.status !== 'verified') {\n // Unreachable: `hasSignatureHeader` already gated entry, so the verifier\n // either throws (missing-pair / invalid / replayed / etc.) or returns\n // `status: 'verified'`. Fail loud if the verifier contract changes —\n // silently returning `null` would fall through to the next authenticator\n // as if no signature were present, breaking the auth invariant.\n throw new AuthError('Signature verification returned unexpected status.', {\n cause: new Error(`verifier returned status=\"${result.status}\"`),\n });\n }\n\n // keyid is buyer-controlled (JWK spec places no charset restriction on\n // `kid`). Bound it to a URL-safe shape — explicitly excluding `:` — before\n // interpolating into the principal string, so downstream tenant-isolation\n // checks that split `signing:<keyid>` on the first `:` can't be confused\n // by a colon embedded in the signer's key id.\n if (!SAFE_KEYID.test(result.keyid)) {\n throw new AuthError('Signature key id contains unsupported characters.', {\n cause: new Error(`keyid=${JSON.stringify(result.keyid)} fails /^[A-Za-z0-9._-]{1,256}$/`),\n });\n }\n\n const signer: VerifiedSigner = {\n keyid: result.keyid,\n verified_at: result.verified_at,\n ...(result.agent_url !== undefined ? { agent_url: result.agent_url } : {}),\n };\n\n // Stamp the kind-discriminated `credential` variant for the framework's\n // dispatcher and `BuyerAgentRegistry` resolution (Phase 1 Stage 3 of\n // #1269). Per adcontextprotocol/adcp#3831, `agent_url` here is the\n // verifier's `agentUrlForKeyid` lookup result — derived from the\n // `agents[]` entry whose `jwks_uri` resolved the keyid.\n //\n // When `agent_url` is unset (verifier wired without a keyid→agent URL\n // resolver), we OMIT the `credential` rather than synthesize an\n // `http_sig` variant that would otherwise carry an empty agent_url —\n // Stage 1's runtime guard rejects malformed http_sig credentials, so\n // emitting one would just trip the guard and confuse the audit trail.\n const credential =\n signer.agent_url !== undefined\n ? markVerifiedHttpSig({\n kind: 'http_sig',\n keyid: signer.keyid,\n agent_url: signer.agent_url,\n verified_at: signer.verified_at,\n })\n : undefined;\n\n const principal = options.makePrincipal\n ? options.makePrincipal(signer)\n : {\n principal: `signing:${signer.keyid}`,\n claims: {\n signature: {\n keyid: signer.keyid,\n verified_at: signer.verified_at,\n ...(signer.agent_url !== undefined ? { agent_url: signer.agent_url } : {}),\n },\n },\n ...(credential !== undefined && { credential }),\n };\n\n // Write the side-channel state only after the principal is fully built so\n // a throw from `makePrincipal` leaves `req.verifiedSigner` unset — the\n // request didn't actually authenticate, downstream handlers must not see\n // a stale \"verified\" marker on a rejected request.\n (req as IncomingMessage & { verifiedSigner?: VerifiedSigner }).verifiedSigner = signer;\n return principal;\n };\n\n return tagAuthenticatorNeedsRawBody(authenticator);\n}\n\n/**\n * Compose a signature authenticator with a fallback under presence-gated\n * semantics: if the incoming request declares a `Signature-Input` header,\n * the signature authenticator is the ONLY path — its result (principal,\n * `null`, or thrown {@link AuthError}) is the final outcome and the fallback\n * never runs. Without `Signature-Input`, the fallback handles the request.\n *\n * This is the correct composition for the `signed-requests` specialism.\n * {@link anyOf}'s either-or contract incorrectly accepts a bearer-authed\n * request whose signature is present-but-invalid — fine for \"either\n * credential is sufficient\" but wrong for spec conformance, where a\n * declared-but-invalid signature MUST be rejected even when a valid bearer\n * accompanies it (revocation, window expiry, malformed covered-components,\n * etc.).\n *\n * ```ts\n * import {\n * serve,\n * anyOf,\n * verifyApiKey,\n * verifySignatureAsAuthenticator,\n * requireSignatureWhenPresent,\n * } from '@adcp/sdk/server';\n *\n * serve(createAgent, {\n * authenticate: requireSignatureWhenPresent(\n * verifySignatureAsAuthenticator({ jwks, replayStore, revocationStore, capability, resolveOperation }),\n * anyOf(verifyApiKey({ keys }), verifyBearer({ jwksUri, issuer, audience })),\n * ),\n * });\n * ```\n *\n * Presence is detected from RFC 9421 signature headers: either\n * `Signature-Input` or the paired `Signature`. A request carrying only one of\n * the two is malformed but still treated as \"signed intent\" — the signature\n * authenticator runs and throws, which is what AdCP's negative conformance\n * vectors expect.\n *\n * Behavior matrix:\n *\n * | RFC 9421 signature header present? | Signature result | Outcome |\n * |------------------------------------|---------------------------|------------------------------|\n * | yes | verified | signature principal |\n * | yes | throws {@link AuthError} | 401 (does NOT fall through) |\n * | yes | returns `null` | 401 via re-thrown `AuthError` (does NOT fall through) |\n * | no | — | fallback runs verbatim |\n *\n * The returned authenticator is tagged with {@link AUTH_NEEDS_RAW_BODY} when\n * either branch needs the raw body, so `serve()` buffers `req.rawBody` ahead\n * of authentication.\n *\n * **Do not nest this helper inside {@link anyOf}.** `anyOf` catches thrown\n * `AuthError`s and tries the next authenticator, which re-introduces the\n * bypass this helper exists to prevent. `anyOf` refuses such composition at\n * wire-up time (throws synchronously) — invert the order instead:\n * `requireSignatureWhenPresent(sig, anyOf(bearer, apiKey))`.\n */\nexport interface RequireSignatureWhenPresentOptions {\n /**\n * Operations that MUST be signed. When the incoming request carries no\n * RFC 9421 signature header AND the fallback authenticator returns\n * `null` (no credentials at all), the gate throws an {@link AuthError}\n * whose `cause` is {@link RequestSignatureError} with\n * `request_signature_required` — `serve()` maps that into a 401 with\n * `WWW-Authenticate: Signature error=\"request_signature_required\"`.\n *\n * \"Fallback bypass\" is deliberately allowed: if the caller presents a\n * valid bearer (or API key) on a `requiredFor` operation, the fallback\n * succeeds and the request is accepted without a signature. This\n * matches the consensus on\n * [adcp#2586](https://github.com/adcontextprotocol/adcp/issues/2586):\n * `required_for` signals \"signatures are the mandatory mechanism for\n * unauthenticated callers\" — not \"signatures are mandatory on top of\n * every other credential.\"\n *\n * When the request IS signed, `required_for` enforcement happens inside\n * the signature verifier itself (via `capability.required_for`), not\n * here — this pre-check is only for the no-signature path.\n */\n requiredFor?: readonly string[];\n /**\n * Extract the AdCP operation name (or any identifier that can be\n * matched against `requiredFor`) from the incoming request.\n *\n * For MCP agents, pass the exported {@link mcpToolNameResolver} — it\n * implements the standard `tools/call` → `params.name` parse. For A2A\n * agents (or other non-JSON-RPC envelopes), supply a bespoke resolver.\n *\n * When `requiredFor` is set but `resolveOperation` is omitted OR\n * returns `undefined`, the pre-check is skipped — better to let the\n * downstream handler produce a precise `INVALID_REQUEST` than to\n * reject every unsigned call as signature-required.\n */\n resolveOperation?: (req: IncomingMessage & { rawBody?: string }) => string | undefined;\n}\n\n/**\n * Compose a signature authenticator with a fallback under presence-gated\n * semantics: if the incoming request declares a `Signature-Input` header,\n * the signature authenticator is the ONLY path — its result (principal,\n * `null`, or thrown {@link AuthError}) is the final outcome and the fallback\n * never runs. Without `Signature-Input`, the fallback handles the request.\n *\n * Pass {@link RequireSignatureWhenPresentOptions.requiredFor} to enforce\n * `required_for` for the no-signature path: when the fallback produces no\n * principal on an operation that MUST be signed, the gate throws an\n * {@link AuthError} whose cause is a {@link RequestSignatureError} with\n * code `request_signature_required` — `serve()` maps that into a 401\n * with the RFC 9421 `WWW-Authenticate: Signature` challenge.\n */\nexport function requireSignatureWhenPresent(\n signatureAuth: Authenticator,\n fallbackAuth: Authenticator,\n options: RequireSignatureWhenPresentOptions = {}\n): Authenticator {\n const requiredFor = new Set(options.requiredFor ?? []);\n const resolveOperation = options.resolveOperation;\n const combined: Authenticator = async req => {\n if (hasSignatureHeader(req)) {\n const result = await signatureAuth(req);\n if (result === null) {\n // A signature was declared but the sig authenticator didn't recognize\n // it. Falling through to the fallback would re-open the bypass the\n // presence gate exists to prevent — fail closed.\n throw new AuthError('Signature declared but not recognized.');\n }\n return result;\n }\n // Catch the fallback's throw so the `requiredFor` pre-check can run\n // regardless of fallback outcome. Without this, a caller presenting\n // a bad bearer on a required-for op triggers `anyOf` to throw an\n // `AuthError` with Bearer semantics, propagating past the pre-check\n // and producing `WWW-Authenticate: Bearer` — the conformance grader\n // reads the wrong error code on the exact vector this helper\n // exists to close.\n let fallbackResult: AuthResult | null = null;\n let fallbackError: unknown;\n let fallbackThrew = false;\n try {\n fallbackResult = await fallbackAuth(req);\n } catch (err) {\n fallbackThrew = true;\n fallbackError = err;\n }\n // Valid fallback principal short-circuits everything: this is the\n // documented \"bearer bypass on required_for\" semantic (per adcp#2586 —\n // a valid credential is sufficient even when signing is required for\n // unauthenticated callers). Return before the pre-check so the\n // control flow below only runs on `fallbackResult === null`.\n if (fallbackResult !== null) return fallbackResult;\n // `requiredFor` pre-check: when the op requires a signature AND no\n // signature was presented AND no valid fallback credential,\n // surface `request_signature_required` regardless of whether the\n // fallback threw (bad bearer) or returned null (no creds).\n if (requiredFor.size > 0 && resolveOperation) {\n const operation = resolveOperation(req as IncomingMessage & { rawBody?: string });\n if (operation && requiredFor.has(operation)) {\n throw new AuthError(`Signature required for ${operation}.`, {\n cause: new RequestSignatureError(\n 'request_signature_required',\n 0,\n `Operation ${operation} requires an RFC 9421 request signature when no other credentials are presented.`\n ),\n });\n }\n }\n // Op not in requiredFor (or no resolver): rethrow the fallback's\n // original error so the 401 carries the fallback's challenge\n // (Bearer for bad-bearer, invalid_token for no-creds).\n if (fallbackThrew) throw fallbackError;\n return null;\n };\n const anyChildNeedsRawBody = authenticatorNeedsRawBody(signatureAuth) || authenticatorNeedsRawBody(fallbackAuth);\n // When `resolveOperation` is wired, it almost always reads\n // `req.rawBody` to parse the JSON-RPC body — the SDK's documented\n // pattern. If no child is tagged (test stubs, agents whose signature\n // path is non-SDK), `serve()` won't buffer the body and\n // `resolveOperation` silently sees `undefined`, bypassing\n // `requiredFor`. Tag the combined authenticator whenever a resolver\n // is present so buffering happens regardless of the child shapes.\n if (anyChildNeedsRawBody || resolveOperation) {\n tagAuthenticatorNeedsRawBody(combined);\n }\n tagAuthenticatorPresenceGated(combined);\n return combined;\n}\n\nexport interface RequireAuthenticatedOrSignedOptions {\n /** RFC 9421 request-signature authenticator. Usually built with {@link verifySignatureAsAuthenticator}. */\n signature: Authenticator;\n /**\n * Credential authenticator that runs when no signature is present.\n * Usually {@link anyOf} of `verifyApiKey` / `verifyBearer` — whatever\n * credential types the agent accepts on unsigned calls.\n */\n fallback: Authenticator;\n /**\n * Operations that MUST be authenticated with a signature when no other\n * credential is presented. See\n * {@link RequireSignatureWhenPresentOptions.requiredFor}.\n *\n * Pass `MUTATING_TASKS` (exported from `@adcp/sdk`) to require\n * signatures on every mutating AdCP operation — matches the common\n * declaration in `capabilities.request_signing.required_for`.\n */\n requiredFor?: readonly string[];\n /** See {@link RequireSignatureWhenPresentOptions.resolveOperation}. */\n resolveOperation?: (req: IncomingMessage & { rawBody?: string }) => string | undefined;\n}\n\n/**\n * Bundled composition of {@link requireSignatureWhenPresent} with an\n * operation resolver — one call produces an authenticator that:\n *\n * 1. Prefers the RFC 9421 signature path when a `Signature-Input`\n * header is present, with no bearer fall-through on invalid\n * signatures (matches the `signed-requests` specialism contract).\n * 2. Accepts bearer / API key when no signature is present, including\n * on `requiredFor` operations — valid credentials bypass the\n * signature requirement.\n * 3. Rejects unsigned calls with no credentials on `requiredFor`\n * operations with a `WWW-Authenticate: Signature` challenge whose\n * error is `request_signature_required`.\n *\n * ```ts\n * import {\n * serve,\n * verifyApiKey,\n * verifyBearer,\n * anyOf,\n * verifySignatureAsAuthenticator,\n * requireAuthenticatedOrSigned,\n * mcpToolNameResolver,\n * MUTATING_TASKS,\n * } from '@adcp/sdk/server';\n *\n * serve(createAgent, {\n * authenticate: requireAuthenticatedOrSigned({\n * signature: verifySignatureAsAuthenticator({\n * jwks, replayStore, revocationStore, capability,\n * resolveOperation: mcpToolNameResolver,\n * }),\n * fallback: anyOf(verifyApiKey({ keys }), verifyBearer({ jwksUri, issuer, audience })),\n * requiredFor: [...MUTATING_TASKS],\n * resolveOperation: mcpToolNameResolver,\n * }),\n * });\n * ```\n */\nexport function requireAuthenticatedOrSigned(options: RequireAuthenticatedOrSignedOptions): Authenticator {\n return requireSignatureWhenPresent(options.signature, options.fallback, {\n requiredFor: options.requiredFor,\n resolveOperation: options.resolveOperation,\n });\n}\n\n/**\n * Default `resolveOperation` for MCP agents. Parses the buffered JSON-RPC\n * body on `req.rawBody` and returns `params.name` when `method === 'tools/call'`.\n * Returns `undefined` for non-`tools/call` methods, a missing body, or\n * malformed JSON — the same \"skip the pre-check and let the handler produce\n * a precise error\" semantics every other `resolveOperation` in the SDK\n * uses.\n *\n * Pass directly as `resolveOperation` on {@link verifySignatureAsAuthenticator},\n * {@link requireSignatureWhenPresent}, {@link requireAuthenticatedOrSigned},\n * or `createExpressVerifier` from `@adcp/sdk/signing`:\n *\n * ```ts\n * serve(createAgent, {\n * authenticate: requireAuthenticatedOrSigned({\n * signature: verifySignatureAsAuthenticator({\n * jwks, replayStore, revocationStore, capability,\n * resolveOperation: mcpToolNameResolver,\n * }),\n * fallback: anyOf(verifyApiKey({ keys }), verifyBearer({ jwksUri, issuer, audience })),\n * requiredFor: [...MUTATING_TASKS],\n * resolveOperation: mcpToolNameResolver,\n * }),\n * });\n * ```\n *\n * A2A agents use a different envelope — write a bespoke resolver there.\n */\nexport function mcpToolNameResolver(req: { rawBody?: string }): string | undefined {\n const raw = req.rawBody;\n if (!raw) return undefined;\n try {\n const body = JSON.parse(raw) as { method?: unknown; params?: unknown };\n if (body?.method !== 'tools/call') return undefined;\n const params = body.params as { name?: unknown } | undefined;\n return typeof params?.name === 'string' ? params.name : undefined;\n } catch {\n return undefined;\n }\n}\n\nconst SAFE_KEYID = /^[A-Za-z0-9._-]{1,256}$/;\n\nfunction hasSignatureHeader(req: IncomingMessage): boolean {\n // RFC 9421 pairs `Signature-Input` with `Signature`. Either is sufficient\n // \"signed intent\" — a request carrying only one is malformed, but routing\n // it to the fallback would mean a half-formed signing attempt (e.g., client\n // bug that dropped the Signature-Input header) silently auths via bearer.\n // Fail closed: send it to the signature authenticator, which will throw.\n return nonEmptyHeader(req.headers['signature-input']) || nonEmptyHeader(req.headers['signature']);\n}\n\nfunction nonEmptyHeader(v: string | string[] | undefined): boolean {\n if (typeof v === 'string') return v.length > 0;\n if (Array.isArray(v)) return v.length > 0;\n return false;\n}\n\nfunction defaultUrl(req: IncomingMessage): string {\n const forwardedProto = firstHeader(req.headers['x-forwarded-proto']);\n const encrypted = (req.socket as { encrypted?: boolean } | undefined)?.encrypted === true;\n const proto = forwardedProto ?? (encrypted ? 'https' : 'http');\n const host = firstHeader(req.headers['host']);\n if (!host) {\n throw new Error(\n 'verifySignatureAsAuthenticator: missing Host header. Pass `getUrl` to reconstruct the canonical URL explicitly.'\n );\n }\n return `${proto}://${host}${req.url ?? '/'}`;\n}\n\nfunction firstHeader(value: string | string[] | undefined): string | undefined {\n if (typeof value === 'string') return value;\n if (Array.isArray(value) && value.length > 0) return value[0];\n return undefined;\n}\n"],"mappings":"AAyCA,SAAS,6BAA6B;AAEtC,SAAS,2BAA6C;AACtD,SAAS,+BAAqD;AAE9D,SAAS,8BAA8B;AACvC,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AS;AACxC,SAAO;AACT;AAEA,SAAS,WAAW,KAA8B;AAChD,QAAM,iBAAiB,YAAY,IAAI,QAAQ,mBAAmB,CAAC;AACnE,QAAM,YAAa,IAAI,QAAgD,cAAc;AACrF,QAAM,QAAQ,mBAAmB,YAAY,UAAU;AACvD,QAAM,OAAO,YAAY,IAAI,QAAQ,MAAM,CAAC;AAC5C,MAAI,CAAC,MAAM;AACT,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,GAAG,KAAK,MAAM,IAAI,GAAG,IAAI,OAAO,GAAG;AAC5C;AAEA,SAAS,YAAY,OAA0D;AAC7E,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,EAAG,QAAO,MAAM,CAAC;AAC5D,SAAO;AACT;","names":[]}
@@ -1,9 +1,3 @@
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 __filename = __adcpFileURLToPath(import.meta.url);
5
- const __dirname = __adcpDirname(__filename);
6
- const require = __adcpCreateRequire(import.meta.url);
7
1
  import { createHash } from "node:crypto";
8
2
  import { createRemoteJWKSet, jwtVerify } from "jose";
9
3
  import { RequestSignatureError } from "../signing/errors.mjs";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/server/auth.ts"],"sourcesContent":["/**\n * Server-side authentication primitives for AdCP MCP agents.\n *\n * Wire one of these into {@link serve} via `ServeOptions.authenticate` to\n * require credentials on every incoming request. The supported mechanisms\n * match the storyboard security baseline:\n *\n * - `verifyApiKey({ verify })` — static or dynamic API-key lookup.\n * - `verifyBearer({ jwksUri, issuer, audience })` — OAuth 2.0 bearer JWT\n * validation against a JWKS endpoint. Use this when your IdP issues\n * signed JWTs (WorkOS, Auth0, Clerk, Okta, etc.).\n * - `anyOf(a, b, ...)` — pass if any sub-authenticator succeeds. The\n * canonical way to accept \"API key OR OAuth\".\n *\n * On failure, the {@link respondUnauthorized} helper produces an RFC 6750\n * compliant 401 (or 403) with a `WWW-Authenticate` header — required for\n * compliance and what the storyboard runner probes for.\n *\n * **Audience binding is not optional.** `verifyBearer` requires an `audience`\n * and rejects tokens whose `aud` claim doesn't match — this is what stops\n * same-tenant tokens from being replayed against any agent that shares the\n * tenant. If you write a CUSTOM `authenticate` callback (instead of using\n * `verifyBearer`), you MUST validate `aud` yourself against your canonical\n * public URL. IdPs that don't include `aud` in user tokens (some WorkOS /\n * Clerk defaults) break the model: either add `aud` at mint time via a\n * custom claim, or pick a different IdP configuration. Signature + expiry\n * + scope alone is not per-resource isolation.\n */\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport { createHash } from 'node:crypto';\nimport { createRemoteJWKSet, jwtVerify, type JWTPayload, type JWTVerifyOptions } from 'jose';\nimport type { RequestSignatureErrorCode } from '../signing/errors';\nimport { RequestSignatureError } from '../signing/errors';\nimport type { AdcpCredential } from './decisioning/buyer-agent';\n\n/**\n * Hash an api-key bearer token into a stable opaque identifier suitable\n * for `credential.key_id`. The raw token MUST NOT appear on the credential\n * — anything reading `credential.key_id` (handlers, `accounts.resolve`,\n * `BuyerAgentRegistry.resolveByCredential`, log lines that flow through\n * `details.reason`) would otherwise leak the secret.\n *\n * SHA-256 truncated to 32 hex chars (128 bits): collision-resistant\n * enough for an opaque correlator, short enough to be readable in logs.\n * Adopters who want full-hash or full-token forms wire their own\n * authenticator and stamp the `credential` directly.\n */\nfunction hashApiKeyToken(token: string): string {\n return createHash('sha256').update(token).digest('hex').slice(0, 32);\n}\n\n/**\n * Default JWT algorithm allowlist. Asymmetric only — HS-family is intentionally\n * excluded to prevent algorithm-confusion attacks where a JWKS public key is\n * used as an HMAC secret. Callers can override via {@link VerifyBearerOptions.jwtOptions}.\n */\nexport const DEFAULT_JWT_ALGORITHMS = Object.freeze([\n 'RS256',\n 'RS384',\n 'RS512',\n 'ES256',\n 'ES384',\n 'PS256',\n 'PS384',\n 'EdDSA',\n]);\n\n/** Default `exp`/`nbf` tolerance to reduce flakes under minor clock drift. */\nexport const DEFAULT_JWT_CLOCK_TOLERANCE_SECONDS = 30;\n\n/**\n * Successful authentication result. Attach whatever claims you want —\n * `principal` is recommended (an opaque identifier for who's calling).\n */\nexport interface AuthPrincipal {\n principal: string;\n /** Raw credential that authenticated the request. Propagated into `req.auth.token` for MCP tool handlers. */\n token?: string;\n scopes?: string[];\n /**\n * Parsed identity claims. Source depends on the authenticator:\n * - {@link verifyBearer} populates the decoded JWT payload (RFC 7519).\n * - {@link verifyIntrospection} populates the RFC 7662 introspection response\n * — same shape for the overlap fields (`iss`, `sub`, `aud`, `exp`, `iat`,\n * `nbf`, `jti`), plus introspection-only fields (`active`, `client_id`,\n * `username`, `scope`, `token_type`) typed as `unknown` via the index\n * signature. Narrow with a type guard before passing to an LLM context —\n * an upstream IdP that controls `sub`, `username`, `client_id`, or\n * `scope` can inject prompt content if those values reach a model\n * unvalidated (adapters often reflect granted scopes into UI / system\n * prompts, so the scope string is a real injection surface).\n */\n claims?: JWTPayload;\n /** Token expiry (seconds since epoch) when known — propagated to MCP `AuthInfo.expiresAt`. */\n expiresAt?: number;\n /**\n * Kind-discriminated credential variant — Phase 1 Stage 3 of #1269.\n *\n * Built-in authenticators stamp this:\n * - {@link verifyApiKey} → `{ kind: 'api_key', key_id }`\n * - {@link verifyBearer} → `{ kind: 'oauth', client_id, scopes, expires_at }`\n * - {@link verifySignatureAsAuthenticator} → `{ kind: 'http_sig', keyid, agent_url, verified_at }`\n *\n * `serve()` propagates this into `req.auth.extra.credential`, where the\n * dispatcher hoists it onto `ctx.authInfo.credential` for adopter\n * `resolveAccount` callbacks AND for the `BuyerAgentRegistry.resolve`\n * call. Adopters with custom `authenticate` functions can populate this\n * directly to opt into the discriminated-credential surface; otherwise\n * `BuyerAgentRegistry` factories return `null` (no credential = no\n * known agent) and the framework's request flow is unchanged.\n *\n * The `http_sig.agent_url` is cryptographically verified (the verifier\n * derives it from the `agents[]` entry whose `jwks_uri` resolved the\n * `keyid` per adcontextprotocol/adcp#3831). Security-relevant decisions\n * MUST read it from this variant, not from any informational field\n * elsewhere on the request.\n */\n credential?: AdcpCredential;\n /**\n * Adopter-provided extension data. Stamp this in your `verifyApiKey.verify`\n * callback (or any custom `authenticate` function) to carry pre-hash data\n * derived from the raw token — prefix patterns, tenant IDs, test-kit flags —\n * that you can't recover from the hashed `key_id` in `credential`.\n *\n * `serve()` propagates this into `req.auth.extra` and from there to\n * `BuyerAgentResolveInput.extra`, where `BuyerAgentRegistry.bearerOnly` and\n * `mixed` factories forward it as the second argument to `resolveByCredential`.\n *\n * Do NOT put raw token values, passwords, or other secrets here. Treat it\n * with the same care as `credential` fields — avoid logging, and never\n * include in thrown `Error` messages (the framework may project\n * `err.message` into `error.details.reason` on the wire).\n *\n * @example\n * ```ts\n * verifyApiKey({\n * verify: token => {\n * if (!DEMO_PATTERN.test(token)) return null;\n * return { principal: `static:demo:${token}`, extra: { demo_token: token } };\n * },\n * })\n * // Then in bearerOnly:\n * BuyerAgentRegistry.bearerOnly({\n * resolveByCredential: (cred, extra) => {\n * const token = extra?.demo_token as string | undefined;\n * return token?.startsWith('demo-billing-passthrough-')\n * ? Promise.resolve(demoAgent)\n * : Promise.resolve(null);\n * },\n * })\n * ```\n */\n extra?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\n/**\n * Outcome of a single authenticator. Return `null` for \"did not match\" so\n * combinators like {@link anyOf} can move on to the next authenticator.\n * Throw for \"definitely unauthorized\" (e.g., a valid JWT that failed\n * audience validation) so callers can distinguish from \"no credentials\".\n */\nexport type AuthResult = AuthPrincipal | null;\n\n/**\n * Authentication middleware applied before the MCP transport handles a request.\n * Receives the raw Node request so it can read the Authorization header or\n * a query parameter, as needed.\n */\nexport type Authenticator = (req: IncomingMessage) => AuthResult | Promise<AuthResult>;\n\n/**\n * Error class signalling \"credentials presented but rejected\". Carries a\n * sanitized public `message` safe to surface to clients and a `cause` with\n * the underlying implementation error for server-side logs. `serve()` uses\n * this to avoid leaking library-internal messages (e.g. expected `aud` values\n * from `jose`) into `WWW-Authenticate` / response bodies.\n */\nexport class AuthError extends Error {\n readonly publicMessage: string;\n constructor(publicMessage: string, options?: { cause?: unknown }) {\n super(publicMessage);\n this.name = 'AuthError';\n this.publicMessage = publicMessage;\n if (options?.cause !== undefined) (this as Error & { cause?: unknown }).cause = options.cause;\n }\n}\n\n/**\n * Marker tag on an {@link Authenticator} that needs `req.rawBody` to be\n * populated before it runs. `serve()` buffers the request body ahead of\n * authentication when any wired authenticator carries this tag — RFC 9421\n * signature verifiers need the raw bytes to recompute `Content-Digest`.\n *\n * Attach via {@link tagAuthenticatorNeedsRawBody}; {@link anyOf} propagates\n * the tag when any wrapped authenticator carries it.\n */\nexport const AUTH_NEEDS_RAW_BODY: unique symbol = Symbol.for('@adcp/client.auth.needsRawBody');\n\n/**\n * Marker tag on an {@link Authenticator} whose contract depends on being the\n * sole path for some class of requests — wrapping it in {@link anyOf} would\n * reintroduce an either-or fall-through that the gate was built to prevent.\n *\n * Currently carried by the authenticator returned from\n * `requireSignatureWhenPresent`, which guarantees \"if `Signature-Input` is\n * present, the signature path is the ONLY outcome.\" Composing it under\n * `anyOf` would let a valid bearer silently accept an invalid signature —\n * the exact bug the helper closes. `anyOf` throws at composition time when\n * any child is tagged.\n */\nexport const AUTH_PRESENCE_GATED: unique symbol = Symbol.for('@adcp/client.auth.presenceGated');\n\n/**\n * Request-scoped context that {@link serve} stamps on the incoming request\n * before the authenticator runs. Authenticator callbacks read this via\n * {@link getServeRequestContext} so they inherit `serve()`'s host\n * resolution (which honors `trustForwardedHost`) instead of re-reading\n * headers that may be attacker-controlled.\n */\nexport const ADCP_SERVE_REQUEST_CONTEXT: unique symbol = Symbol.for('@adcp/client.auth.serveRequestContext');\n\n/**\n * Per-request context exposed to the `verifyBearer` audience callback.\n * Authoritative host + resolved publicUrl come from `serve()` — the\n * callback MUST NOT reach past this object to read `X-Forwarded-Host`\n * itself, or it will diverge from the advertised OAuth `resource` and\n * let a spoofed header flip the audience check.\n */\nexport interface ServeRequestContext {\n /** Canonical host for the request as resolved by `serve()`. Lowercased, port preserved. */\n host: string;\n /** Resolved `publicUrl` for this host (if configured). Undefined in single-host mode with no publicUrl. */\n publicUrl?: string;\n}\n\n/** Read the serve()-populated context off a request. Returns `undefined` when the request didn't come through `serve()`. */\nexport function getServeRequestContext(req: IncomingMessage): ServeRequestContext | undefined {\n return (req as IncomingMessage & { [ADCP_SERVE_REQUEST_CONTEXT]?: ServeRequestContext })[ADCP_SERVE_REQUEST_CONTEXT];\n}\n\ninterface AuthenticatorFlags {\n [AUTH_NEEDS_RAW_BODY]?: boolean;\n [AUTH_PRESENCE_GATED]?: boolean;\n}\n\n/**\n * Mark an authenticator as needing `req.rawBody`. Safe to call more than once.\n */\nexport function tagAuthenticatorNeedsRawBody(auth: Authenticator): Authenticator {\n (auth as unknown as AuthenticatorFlags)[AUTH_NEEDS_RAW_BODY] = true;\n return auth;\n}\n\n/**\n * Check whether an authenticator (possibly composed via {@link anyOf}) requires\n * the raw request body to be buffered before invocation.\n */\nexport function authenticatorNeedsRawBody(auth: Authenticator | undefined): boolean {\n return !!auth && (auth as unknown as AuthenticatorFlags)[AUTH_NEEDS_RAW_BODY] === true;\n}\n\n/**\n * Mark an authenticator as presence-gated. {@link anyOf} refuses to wrap a\n * tagged authenticator — wrapping would defeat the gate.\n */\nexport function tagAuthenticatorPresenceGated(auth: Authenticator): Authenticator {\n (auth as unknown as AuthenticatorFlags)[AUTH_PRESENCE_GATED] = true;\n return auth;\n}\n\n/**\n * Check whether an authenticator is presence-gated (see {@link AUTH_PRESENCE_GATED}).\n */\nexport function isAuthenticatorPresenceGated(auth: Authenticator | undefined): boolean {\n return !!auth && (auth as unknown as AuthenticatorFlags)[AUTH_PRESENCE_GATED] === true;\n}\n\n// ---------------------------------------------------------------------------\n// Token extraction\n// ---------------------------------------------------------------------------\n\n/**\n * Extract a bearer token from the request. Checks the `Authorization` header\n * first (`Bearer <token>`), then the legacy `x-adcp-auth` header our older\n * clients use.\n */\nexport function extractBearerToken(req: IncomingMessage): string | null {\n const auth = req.headers.authorization;\n if (auth && auth.length > 7 && auth.slice(0, 6).toLowerCase() === 'bearer') {\n // Require at least one whitespace byte between scheme and token — avoids\n // backtracking-prone regexes on attacker-controlled header values.\n const sep = auth.charCodeAt(6);\n if (sep === 0x20 || sep === 0x09) {\n const token = auth.slice(7).trim();\n if (token.length > 0) return token;\n }\n }\n const legacy = req.headers['x-adcp-auth'];\n if (typeof legacy === 'string' && legacy.length > 0) return legacy;\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// API-key authenticator\n// ---------------------------------------------------------------------------\n\nexport interface VerifyApiKeyOptions {\n /**\n * Static map of API keys to the principal they represent. Handy for\n * single-tenant agents or local development.\n */\n keys?: Record<string, AuthPrincipal>;\n /**\n * Dynamic verifier for keys that live in a database or secret store.\n * Return `null` for \"not my key\" (falls through to other authenticators),\n * or a principal to accept.\n */\n verify?: (token: string) => Promise<AuthResult> | AuthResult;\n}\n\n/**\n * Build an API-key authenticator. Accepts a static map and/or a dynamic\n * verifier; if both are provided, the static map is checked first.\n *\n * ```ts\n * serve(createAgent, {\n * authenticate: verifyApiKey({\n * keys: { 'sk_live_abc': { principal: 'acct_42' } },\n * verify: async token => db.lookupKey(token),\n * }),\n * });\n * ```\n */\nexport function verifyApiKey(options: VerifyApiKeyOptions): Authenticator {\n if (!options.keys && !options.verify) {\n throw new Error('verifyApiKey: provide at least one of `keys` or `verify`.');\n }\n return async req => {\n const token = extractBearerToken(req);\n if (!token) return null;\n // ALWAYS stamp an api_key credential — adopter-provided credentials\n // on the matched principal are NOT honored here. Allowing an api-key\n // entry to claim `credential: { kind: 'http_sig', ... }` would let\n // an adopter (or attacker who can write the keys map) forge signed-\n // path identity — `signingOnly` and `mixed` registry factories would\n // route the request as if it were verifier-attested. The api-key\n // path has no signature proof, so the credential MUST be `api_key`\n // regardless of what the matched record carries. Same posture for\n // the dynamic `verify` path below.\n //\n // `key_id` is a SHA-256 hash prefix of the raw token, not the token\n // itself — `credential.key_id` flows broadly through `ctx.authInfo`,\n // handlers, and downstream code that may log structured context.\n // Adopters with custom api-key authenticators that need a different\n // `key_id` shape stamp their own credential and skip this path.\n const apiKeyCredential: AdcpCredential = { kind: 'api_key', key_id: hashApiKeyToken(token) };\n if (options.keys && Object.prototype.hasOwnProperty.call(options.keys, token)) {\n const matched = options.keys[token]!;\n return {\n ...matched,\n token,\n credential: apiKeyCredential,\n };\n }\n if (options.verify) {\n const result = await options.verify(token);\n if (!result) return null;\n return {\n ...result,\n token: result.token ?? token,\n credential: apiKeyCredential,\n };\n }\n return null;\n };\n}\n\n// ---------------------------------------------------------------------------\n// Bearer / JWT authenticator\n// ---------------------------------------------------------------------------\n\nexport interface VerifyBearerOptions {\n /** JWKS URI — usually `<issuer>/.well-known/jwks.json`. */\n jwksUri: string;\n /** Expected `iss` claim. */\n issuer: string;\n /**\n * Expected `aud` claim — the canonical URL clients see for this MCP\n * endpoint (e.g., `https://my-agent.example.com/mcp`). MUST match what\n * the token was issued for. If you advertise via\n * {@link ServeOptions.protectedResource}, set this to the same URL.\n *\n * For multi-host deployments pass a function. The two-argument form\n * receives `(req, ctx)` where `ctx.host` and `ctx.publicUrl` come from\n * `serve()`'s host resolution — inheriting the same\n * `trustForwardedHost` policy that governs the advertised PRM. Prefer\n * `(_req, { publicUrl }) => publicUrl!` so the JWT audience check and\n * the RFC 9728 `resource` URL can never diverge; a callback that reads\n * `X-Forwarded-Host` directly is a footgun when `trustForwardedHost`\n * is off.\n *\n * The single-argument form `(req) => string` still works for agents\n * mounting `verifyBearer` outside `serve()` (e.g., under\n * `createExpressAdapter`), but inherits none of `serve()`'s header\n * hardening — you MUST validate audience inputs yourself.\n */\n audience: string | ((req: IncomingMessage) => string) | ((req: IncomingMessage, ctx: ServeRequestContext) => string);\n /** Optional: required scopes (all must be present in the `scope` / `scp` claim). */\n requiredScopes?: string[];\n /**\n * Optional: JWT verification options passthrough. Defaults to the secure\n * asymmetric-only algorithm allowlist and a 30s clock tolerance — override\n * only if you know why. HS256/HS384/HS512 are rejected by default to prevent\n * algorithm-confusion attacks against the JWKS.\n */\n jwtOptions?: Omit<JWTVerifyOptions, 'issuer' | 'audience'>;\n}\n\n/**\n * Build a JWT bearer authenticator that validates tokens against a JWKS.\n *\n * Uses the `jose` library (already in the dependency tree). Audience and\n * issuer are enforced strictly — a token minted for the wrong audience\n * is rejected, which is the bug pattern we've seen in the wild when an\n * agent advertises an incorrect `/.well-known/oauth-protected-resource`\n * `resource` URL.\n *\n * ```ts\n * serve(createAgent, {\n * authenticate: verifyBearer({\n * jwksUri: 'https://auth.example/.well-known/jwks.json',\n * issuer: 'https://auth.example',\n * audience: 'https://my-agent.example.com/mcp',\n * }),\n * });\n * ```\n */\nexport function verifyBearer(options: VerifyBearerOptions): Authenticator {\n const jwks = createRemoteJWKSet(new URL(options.jwksUri));\n const audienceIsFn = typeof options.audience === 'function';\n const baseVerifyOptions: Omit<JWTVerifyOptions, 'audience'> = {\n algorithms: DEFAULT_JWT_ALGORITHMS.slice(),\n clockTolerance: DEFAULT_JWT_CLOCK_TOLERANCE_SECONDS,\n ...options.jwtOptions,\n issuer: options.issuer,\n };\n const staticVerifyOptions: JWTVerifyOptions | undefined = audienceIsFn\n ? undefined\n : { ...baseVerifyOptions, audience: options.audience as string };\n return async req => {\n const token = extractBearerToken(req);\n if (!token) return null;\n let payload: JWTPayload;\n let verifyOptions: JWTVerifyOptions;\n if (audienceIsFn) {\n let audience: string;\n try {\n // Pass the serve()-resolved context as the second argument. The\n // callback can use `ctx.publicUrl` (preferred — it's the same URL\n // the RFC 9728 PRM advertises) or `ctx.host` for its own\n // reconstruction. Falls back to an empty-host ctx when the\n // authenticator is mounted outside `serve()`, so callbacks must\n // still tolerate `host === ''`.\n const ctx: ServeRequestContext = getServeRequestContext(req) ?? { host: '' };\n audience = (options.audience as (r: IncomingMessage, c: ServeRequestContext) => string)(req, ctx);\n } catch (err) {\n // Resolver threw — surface as auth failure rather than 500 so the\n // client sees a clean 401 and the operator sees the cause in the log.\n throw new AuthError('Token validation failed.', { cause: err });\n }\n verifyOptions = { ...baseVerifyOptions, audience };\n } else {\n verifyOptions = staticVerifyOptions as JWTVerifyOptions;\n }\n try {\n ({ payload } = await jwtVerify(token, jwks, verifyOptions));\n } catch (err) {\n // Never surface jose's message to the client — it echoes expected audience,\n // issuer, or token-shape details that probing attackers can use.\n throw new AuthError('Token validation failed.', { cause: err });\n }\n const scopes = extractScopes(payload);\n if (options.requiredScopes?.length) {\n const missing = options.requiredScopes.filter(s => !scopes.includes(s));\n if (missing.length > 0) {\n throw new AuthError('Insufficient scope.', {\n cause: new Error(`Missing required scope(s): ${missing.join(', ')}`),\n });\n }\n }\n // Prefer `payload.client_id` over `payload.sub` per RFC 9068 §2.2:\n // `sub` is the resource-owner subject (often the user); `client_id`\n // is the OAuth client identity (the buyer agent for AdCP traffic).\n // For the client-credentials grant where `sub === client_id` both\n // resolve to the same value; for authorization-code flows where\n // `sub` is a user, falling back to `sub` would mis-route registry\n // lookups keyed by client identity.\n //\n // When neither is a usable string, omit the `credential` entirely\n // — `BuyerAgentRegistry` sees `null` (no credential = no known\n // agent) instead of bucketing every unauthenticated principal into\n // a single `'unknown'` row.\n const clientIdFromPayload =\n typeof payload.client_id === 'string' && payload.client_id.length > 0\n ? payload.client_id\n : typeof payload.sub === 'string' && payload.sub.length > 0\n ? payload.sub\n : undefined;\n const principal: AuthPrincipal = {\n principal: clientIdFromPayload ?? 'unknown',\n token,\n scopes,\n claims: payload,\n ...(clientIdFromPayload !== undefined && {\n credential: {\n kind: 'oauth' as const,\n client_id: clientIdFromPayload,\n scopes,\n ...(typeof payload.exp === 'number' && { expires_at: payload.exp }),\n },\n }),\n };\n if (typeof payload.exp === 'number') principal.expiresAt = payload.exp;\n return principal;\n };\n}\n\n/**\n * Extract scopes from a JWT payload. Handles both RFC 8693 `scope` (string,\n * space-delimited) and RFC 9068 / Azure AD / Okta `scp` (string or string[]).\n */\nfunction extractScopes(payload: JWTPayload): string[] {\n const out: string[] = [];\n if (typeof payload.scope === 'string') {\n out.push(...payload.scope.split(/\\s+/).filter(Boolean));\n } else if (Array.isArray(payload.scope)) {\n out.push(...(payload.scope as unknown[]).filter((s): s is string => typeof s === 'string'));\n }\n const scp = (payload as JWTPayload & { scp?: unknown }).scp;\n if (typeof scp === 'string') {\n out.push(...scp.split(/\\s+/).filter(Boolean));\n } else if (Array.isArray(scp)) {\n out.push(...scp.filter((s): s is string => typeof s === 'string'));\n }\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Combinators\n// ---------------------------------------------------------------------------\n\n/**\n * Pass if any authenticator succeeds. A `null` from one falls through to the\n * next; a thrown error short-circuits to 401 (credentials were presented but\n * rejected — not a \"no credentials\" case). Errors are wrapped in an\n * {@link AuthError} with a generic public message so the client can't tell\n * which mechanism rejected them.\n */\nexport function anyOf(...authenticators: Authenticator[]): Authenticator {\n for (const auth of authenticators) {\n if (isAuthenticatorPresenceGated(auth)) {\n throw new Error(\n 'anyOf: refusing to wrap a presence-gated authenticator. Wrapping would ' +\n 'reintroduce the bearer-bypass bug the gate was built to prevent. ' +\n 'Invert the composition: requireSignatureWhenPresent(sig, anyOf(...others)).'\n );\n }\n }\n const combined: Authenticator = async req => {\n let rejected = false;\n const causes: unknown[] = [];\n for (const auth of authenticators) {\n try {\n const result = await auth(req);\n if (result) return result;\n } catch (err) {\n rejected = true;\n causes.push(err);\n }\n }\n if (rejected) {\n throw new AuthError('Credentials rejected.', { cause: causes });\n }\n return null;\n };\n if (authenticators.some(a => authenticatorNeedsRawBody(a))) {\n tagAuthenticatorNeedsRawBody(combined);\n }\n return combined;\n}\n\n// ---------------------------------------------------------------------------\n// 401 / 403 response helper\n// ---------------------------------------------------------------------------\n\nexport interface RespondUnauthorizedOptions {\n /**\n * Bearer realm value. Defaults to `\"mcp\"` — a stable value that won't reflect\n * an attacker-controlled `Host` header into the challenge.\n */\n realm?: string;\n /** RFC 6750 error code. Defaults to `invalid_token`. */\n error?: 'invalid_request' | 'invalid_token' | 'insufficient_scope';\n /** Human-readable description. */\n errorDescription?: string;\n /**\n * OAuth 2.0 resource URL (RFC 9728). If set, included in the challenge so\n * clients can discover the auth server from the protected-resource metadata.\n */\n resourceMetadata?: string;\n /** Set to 403 instead of 401 for valid-but-unauthorized scenarios. */\n status?: 401 | 403;\n /**\n * RFC 9421 signature error code. When set, the challenge scheme switches\n * from `Bearer` to `Signature` and the body's `error` field carries the\n * signature code verbatim — what the `signed_requests` conformance grader\n * reads from `WWW-Authenticate` to decide pass/fail on negative vectors.\n *\n * Set this whenever the rejection is a signature-layer failure (invalid\n * signature, missing required signature, revoked key, replayed nonce,\n * etc.). `serve()` auto-detects this from an {@link AuthError} whose\n * `cause` is a {@link RequestSignatureError}; callers rarely set it\n * directly.\n */\n signatureError?: RequestSignatureErrorCode;\n}\n\n/**\n * Send an RFC 6750-compliant 401/403 response with the `WWW-Authenticate`\n * header set. Called automatically by {@link serve} when `authenticate`\n * returns `null` or throws.\n *\n * When {@link RespondUnauthorizedOptions.signatureError} is set, the\n * challenge scheme becomes `Signature` (per the `signed-requests`\n * specialism) and the body's `error` field carries the RFC 9421 error\n * code — the `signed_requests` grader reads both from the challenge.\n */\nexport function respondUnauthorized(\n _req: IncomingMessage,\n res: ServerResponse,\n options: RespondUnauthorizedOptions = {}\n): void {\n const realm = options.realm ?? 'mcp';\n const parts = [`realm=\"${escapeQuotes(realm)}\"`];\n const useSignatureChallenge = options.signatureError !== undefined;\n // The `error` codes are typed unions — the type system gives us the\n // only quote-safe guarantee. Route through `escapeQuotes` so a future\n // widening to `string` or a code that happens to include `\"` doesn't\n // inject a new parameter into the challenge header.\n if (useSignatureChallenge) {\n parts.push(`error=\"${escapeQuotes(options.signatureError!)}\"`);\n } else if (options.error) {\n parts.push(`error=\"${escapeQuotes(options.error)}\"`);\n }\n if (options.errorDescription) parts.push(`error_description=\"${escapeQuotes(options.errorDescription)}\"`);\n if (options.resourceMetadata) parts.push(`resource_metadata=\"${escapeQuotes(options.resourceMetadata)}\"`);\n\n const scheme = useSignatureChallenge ? 'Signature' : 'Bearer';\n res.writeHead(options.status ?? 401, {\n 'Content-Type': 'application/json',\n 'WWW-Authenticate': `${scheme} ${parts.join(', ')}`,\n });\n res.end(\n JSON.stringify({\n error: useSignatureChallenge ? options.signatureError : (options.error ?? 'unauthorized'),\n error_description: options.errorDescription ?? 'Authentication required.',\n })\n );\n}\n\n/**\n * Unwrap the first {@link RequestSignatureError} found walking the\n * `cause` chain of an {@link AuthError} (or any error), so callers can\n * switch the `WWW-Authenticate` challenge scheme on signature-layer\n * failures. Returns `null` for non-signature errors.\n */\nexport function signatureErrorCodeFromCause(err: unknown): RequestSignatureErrorCode | null {\n // Track visited refs to break arbitrary cycles (self-reference, N-cycles,\n // or a long non-signature chain that would otherwise exhaust the walker).\n // The visited set is a belt-and-suspenders companion to the hop cap —\n // either one alone is enough for legitimate chains, but cycle resistance\n // is the security-relevant property.\n const visited = new Set<unknown>();\n let current: unknown = err;\n let hops = 0;\n while (current != null && hops < 32 && !visited.has(current)) {\n if (current instanceof RequestSignatureError) return current.code;\n visited.add(current);\n current = (current as { cause?: unknown }).cause;\n hops++;\n }\n return null;\n}\n\nfunction escapeQuotes(s: string): string {\n // Escape backslashes first so later-inserted escapes aren't re-escaped.\n return s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n}\n"],"mappings":";;;;;;AA6BA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB,iBAAyD;AAEtF,SAAS,6BAA6B;AAetC,SAAS,gBAAgB,OAAuB;AAC9C,SAAO,WAAW,QAAQ,EAAE,OAAO,KAAK,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AACrE;AAOO,MAAM,yBAAyB,OAAO,OAAO;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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authentication primitives for AdCP MCP agents.\n *\n * Wire one of these into {@link serve} via `ServeOptions.authenticate` to\n * require credentials on every incoming request. The supported mechanisms\n * match the storyboard security baseline:\n *\n * - `verifyApiKey({ verify })` — static or dynamic API-key lookup.\n * - `verifyBearer({ jwksUri, issuer, audience })` — OAuth 2.0 bearer JWT\n * validation against a JWKS endpoint. Use this when your IdP issues\n * signed JWTs (WorkOS, Auth0, Clerk, Okta, etc.).\n * - `anyOf(a, b, ...)` — pass if any sub-authenticator succeeds. The\n * canonical way to accept \"API key OR OAuth\".\n *\n * On failure, the {@link respondUnauthorized} helper produces an RFC 6750\n * compliant 401 (or 403) with a `WWW-Authenticate` header — required for\n * compliance and what the storyboard runner probes for.\n *\n * **Audience binding is not optional.** `verifyBearer` requires an `audience`\n * and rejects tokens whose `aud` claim doesn't match — this is what stops\n * same-tenant tokens from being replayed against any agent that shares the\n * tenant. If you write a CUSTOM `authenticate` callback (instead of using\n * `verifyBearer`), you MUST validate `aud` yourself against your canonical\n * public URL. IdPs that don't include `aud` in user tokens (some WorkOS /\n * Clerk defaults) break the model: either add `aud` at mint time via a\n * custom claim, or pick a different IdP configuration. Signature + expiry\n * + scope alone is not per-resource isolation.\n */\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport { createHash } from 'node:crypto';\nimport { createRemoteJWKSet, jwtVerify, type JWTPayload, type JWTVerifyOptions } from 'jose';\nimport type { RequestSignatureErrorCode } from '../signing/errors';\nimport { RequestSignatureError } from '../signing/errors';\nimport type { AdcpCredential } from './decisioning/buyer-agent';\n\n/**\n * Hash an api-key bearer token into a stable opaque identifier suitable\n * for `credential.key_id`. The raw token MUST NOT appear on the credential\n * — anything reading `credential.key_id` (handlers, `accounts.resolve`,\n * `BuyerAgentRegistry.resolveByCredential`, log lines that flow through\n * `details.reason`) would otherwise leak the secret.\n *\n * SHA-256 truncated to 32 hex chars (128 bits): collision-resistant\n * enough for an opaque correlator, short enough to be readable in logs.\n * Adopters who want full-hash or full-token forms wire their own\n * authenticator and stamp the `credential` directly.\n */\nfunction hashApiKeyToken(token: string): string {\n return createHash('sha256').update(token).digest('hex').slice(0, 32);\n}\n\n/**\n * Default JWT algorithm allowlist. Asymmetric only — HS-family is intentionally\n * excluded to prevent algorithm-confusion attacks where a JWKS public key is\n * used as an HMAC secret. Callers can override via {@link VerifyBearerOptions.jwtOptions}.\n */\nexport const DEFAULT_JWT_ALGORITHMS = Object.freeze([\n 'RS256',\n 'RS384',\n 'RS512',\n 'ES256',\n 'ES384',\n 'PS256',\n 'PS384',\n 'EdDSA',\n]);\n\n/** Default `exp`/`nbf` tolerance to reduce flakes under minor clock drift. */\nexport const DEFAULT_JWT_CLOCK_TOLERANCE_SECONDS = 30;\n\n/**\n * Successful authentication result. Attach whatever claims you want —\n * `principal` is recommended (an opaque identifier for who's calling).\n */\nexport interface AuthPrincipal {\n principal: string;\n /** Raw credential that authenticated the request. Propagated into `req.auth.token` for MCP tool handlers. */\n token?: string;\n scopes?: string[];\n /**\n * Parsed identity claims. Source depends on the authenticator:\n * - {@link verifyBearer} populates the decoded JWT payload (RFC 7519).\n * - {@link verifyIntrospection} populates the RFC 7662 introspection response\n * — same shape for the overlap fields (`iss`, `sub`, `aud`, `exp`, `iat`,\n * `nbf`, `jti`), plus introspection-only fields (`active`, `client_id`,\n * `username`, `scope`, `token_type`) typed as `unknown` via the index\n * signature. Narrow with a type guard before passing to an LLM context —\n * an upstream IdP that controls `sub`, `username`, `client_id`, or\n * `scope` can inject prompt content if those values reach a model\n * unvalidated (adapters often reflect granted scopes into UI / system\n * prompts, so the scope string is a real injection surface).\n */\n claims?: JWTPayload;\n /** Token expiry (seconds since epoch) when known — propagated to MCP `AuthInfo.expiresAt`. */\n expiresAt?: number;\n /**\n * Kind-discriminated credential variant — Phase 1 Stage 3 of #1269.\n *\n * Built-in authenticators stamp this:\n * - {@link verifyApiKey} → `{ kind: 'api_key', key_id }`\n * - {@link verifyBearer} → `{ kind: 'oauth', client_id, scopes, expires_at }`\n * - {@link verifySignatureAsAuthenticator} → `{ kind: 'http_sig', keyid, agent_url, verified_at }`\n *\n * `serve()` propagates this into `req.auth.extra.credential`, where the\n * dispatcher hoists it onto `ctx.authInfo.credential` for adopter\n * `resolveAccount` callbacks AND for the `BuyerAgentRegistry.resolve`\n * call. Adopters with custom `authenticate` functions can populate this\n * directly to opt into the discriminated-credential surface; otherwise\n * `BuyerAgentRegistry` factories return `null` (no credential = no\n * known agent) and the framework's request flow is unchanged.\n *\n * The `http_sig.agent_url` is cryptographically verified (the verifier\n * derives it from the `agents[]` entry whose `jwks_uri` resolved the\n * `keyid` per adcontextprotocol/adcp#3831). Security-relevant decisions\n * MUST read it from this variant, not from any informational field\n * elsewhere on the request.\n */\n credential?: AdcpCredential;\n /**\n * Adopter-provided extension data. Stamp this in your `verifyApiKey.verify`\n * callback (or any custom `authenticate` function) to carry pre-hash data\n * derived from the raw token — prefix patterns, tenant IDs, test-kit flags —\n * that you can't recover from the hashed `key_id` in `credential`.\n *\n * `serve()` propagates this into `req.auth.extra` and from there to\n * `BuyerAgentResolveInput.extra`, where `BuyerAgentRegistry.bearerOnly` and\n * `mixed` factories forward it as the second argument to `resolveByCredential`.\n *\n * Do NOT put raw token values, passwords, or other secrets here. Treat it\n * with the same care as `credential` fields — avoid logging, and never\n * include in thrown `Error` messages (the framework may project\n * `err.message` into `error.details.reason` on the wire).\n *\n * @example\n * ```ts\n * verifyApiKey({\n * verify: token => {\n * if (!DEMO_PATTERN.test(token)) return null;\n * return { principal: `static:demo:${token}`, extra: { demo_token: token } };\n * },\n * })\n * // Then in bearerOnly:\n * BuyerAgentRegistry.bearerOnly({\n * resolveByCredential: (cred, extra) => {\n * const token = extra?.demo_token as string | undefined;\n * return token?.startsWith('demo-billing-passthrough-')\n * ? Promise.resolve(demoAgent)\n * : Promise.resolve(null);\n * },\n * })\n * ```\n */\n extra?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\n/**\n * Outcome of a single authenticator. Return `null` for \"did not match\" so\n * combinators like {@link anyOf} can move on to the next authenticator.\n * Throw for \"definitely unauthorized\" (e.g., a valid JWT that failed\n * audience validation) so callers can distinguish from \"no credentials\".\n */\nexport type AuthResult = AuthPrincipal | null;\n\n/**\n * Authentication middleware applied before the MCP transport handles a request.\n * Receives the raw Node request so it can read the Authorization header or\n * a query parameter, as needed.\n */\nexport type Authenticator = (req: IncomingMessage) => AuthResult | Promise<AuthResult>;\n\n/**\n * Error class signalling \"credentials presented but rejected\". Carries a\n * sanitized public `message` safe to surface to clients and a `cause` with\n * the underlying implementation error for server-side logs. `serve()` uses\n * this to avoid leaking library-internal messages (e.g. expected `aud` values\n * from `jose`) into `WWW-Authenticate` / response bodies.\n */\nexport class AuthError extends Error {\n readonly publicMessage: string;\n constructor(publicMessage: string, options?: { cause?: unknown }) {\n super(publicMessage);\n this.name = 'AuthError';\n this.publicMessage = publicMessage;\n if (options?.cause !== undefined) (this as Error & { cause?: unknown }).cause = options.cause;\n }\n}\n\n/**\n * Marker tag on an {@link Authenticator} that needs `req.rawBody` to be\n * populated before it runs. `serve()` buffers the request body ahead of\n * authentication when any wired authenticator carries this tag — RFC 9421\n * signature verifiers need the raw bytes to recompute `Content-Digest`.\n *\n * Attach via {@link tagAuthenticatorNeedsRawBody}; {@link anyOf} propagates\n * the tag when any wrapped authenticator carries it.\n */\nexport const AUTH_NEEDS_RAW_BODY: unique symbol = Symbol.for('@adcp/client.auth.needsRawBody');\n\n/**\n * Marker tag on an {@link Authenticator} whose contract depends on being the\n * sole path for some class of requests — wrapping it in {@link anyOf} would\n * reintroduce an either-or fall-through that the gate was built to prevent.\n *\n * Currently carried by the authenticator returned from\n * `requireSignatureWhenPresent`, which guarantees \"if `Signature-Input` is\n * present, the signature path is the ONLY outcome.\" Composing it under\n * `anyOf` would let a valid bearer silently accept an invalid signature —\n * the exact bug the helper closes. `anyOf` throws at composition time when\n * any child is tagged.\n */\nexport const AUTH_PRESENCE_GATED: unique symbol = Symbol.for('@adcp/client.auth.presenceGated');\n\n/**\n * Request-scoped context that {@link serve} stamps on the incoming request\n * before the authenticator runs. Authenticator callbacks read this via\n * {@link getServeRequestContext} so they inherit `serve()`'s host\n * resolution (which honors `trustForwardedHost`) instead of re-reading\n * headers that may be attacker-controlled.\n */\nexport const ADCP_SERVE_REQUEST_CONTEXT: unique symbol = Symbol.for('@adcp/client.auth.serveRequestContext');\n\n/**\n * Per-request context exposed to the `verifyBearer` audience callback.\n * Authoritative host + resolved publicUrl come from `serve()` — the\n * callback MUST NOT reach past this object to read `X-Forwarded-Host`\n * itself, or it will diverge from the advertised OAuth `resource` and\n * let a spoofed header flip the audience check.\n */\nexport interface ServeRequestContext {\n /** Canonical host for the request as resolved by `serve()`. Lowercased, port preserved. */\n host: string;\n /** Resolved `publicUrl` for this host (if configured). Undefined in single-host mode with no publicUrl. */\n publicUrl?: string;\n}\n\n/** Read the serve()-populated context off a request. Returns `undefined` when the request didn't come through `serve()`. */\nexport function getServeRequestContext(req: IncomingMessage): ServeRequestContext | undefined {\n return (req as IncomingMessage & { [ADCP_SERVE_REQUEST_CONTEXT]?: ServeRequestContext })[ADCP_SERVE_REQUEST_CONTEXT];\n}\n\ninterface AuthenticatorFlags {\n [AUTH_NEEDS_RAW_BODY]?: boolean;\n [AUTH_PRESENCE_GATED]?: boolean;\n}\n\n/**\n * Mark an authenticator as needing `req.rawBody`. Safe to call more than once.\n */\nexport function tagAuthenticatorNeedsRawBody(auth: Authenticator): Authenticator {\n (auth as unknown as AuthenticatorFlags)[AUTH_NEEDS_RAW_BODY] = true;\n return auth;\n}\n\n/**\n * Check whether an authenticator (possibly composed via {@link anyOf}) requires\n * the raw request body to be buffered before invocation.\n */\nexport function authenticatorNeedsRawBody(auth: Authenticator | undefined): boolean {\n return !!auth && (auth as unknown as AuthenticatorFlags)[AUTH_NEEDS_RAW_BODY] === true;\n}\n\n/**\n * Mark an authenticator as presence-gated. {@link anyOf} refuses to wrap a\n * tagged authenticator — wrapping would defeat the gate.\n */\nexport function tagAuthenticatorPresenceGated(auth: Authenticator): Authenticator {\n (auth as unknown as AuthenticatorFlags)[AUTH_PRESENCE_GATED] = true;\n return auth;\n}\n\n/**\n * Check whether an authenticator is presence-gated (see {@link AUTH_PRESENCE_GATED}).\n */\nexport function isAuthenticatorPresenceGated(auth: Authenticator | undefined): boolean {\n return !!auth && (auth as unknown as AuthenticatorFlags)[AUTH_PRESENCE_GATED] === true;\n}\n\n// ---------------------------------------------------------------------------\n// Token extraction\n// ---------------------------------------------------------------------------\n\n/**\n * Extract a bearer token from the request. Checks the `Authorization` header\n * first (`Bearer <token>`), then the legacy `x-adcp-auth` header our older\n * clients use.\n */\nexport function extractBearerToken(req: IncomingMessage): string | null {\n const auth = req.headers.authorization;\n if (auth && auth.length > 7 && auth.slice(0, 6).toLowerCase() === 'bearer') {\n // Require at least one whitespace byte between scheme and token — avoids\n // backtracking-prone regexes on attacker-controlled header values.\n const sep = auth.charCodeAt(6);\n if (sep === 0x20 || sep === 0x09) {\n const token = auth.slice(7).trim();\n if (token.length > 0) return token;\n }\n }\n const legacy = req.headers['x-adcp-auth'];\n if (typeof legacy === 'string' && legacy.length > 0) return legacy;\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// API-key authenticator\n// ---------------------------------------------------------------------------\n\nexport interface VerifyApiKeyOptions {\n /**\n * Static map of API keys to the principal they represent. Handy for\n * single-tenant agents or local development.\n */\n keys?: Record<string, AuthPrincipal>;\n /**\n * Dynamic verifier for keys that live in a database or secret store.\n * Return `null` for \"not my key\" (falls through to other authenticators),\n * or a principal to accept.\n */\n verify?: (token: string) => Promise<AuthResult> | AuthResult;\n}\n\n/**\n * Build an API-key authenticator. Accepts a static map and/or a dynamic\n * verifier; if both are provided, the static map is checked first.\n *\n * ```ts\n * serve(createAgent, {\n * authenticate: verifyApiKey({\n * keys: { 'sk_live_abc': { principal: 'acct_42' } },\n * verify: async token => db.lookupKey(token),\n * }),\n * });\n * ```\n */\nexport function verifyApiKey(options: VerifyApiKeyOptions): Authenticator {\n if (!options.keys && !options.verify) {\n throw new Error('verifyApiKey: provide at least one of `keys` or `verify`.');\n }\n return async req => {\n const token = extractBearerToken(req);\n if (!token) return null;\n // ALWAYS stamp an api_key credential — adopter-provided credentials\n // on the matched principal are NOT honored here. Allowing an api-key\n // entry to claim `credential: { kind: 'http_sig', ... }` would let\n // an adopter (or attacker who can write the keys map) forge signed-\n // path identity — `signingOnly` and `mixed` registry factories would\n // route the request as if it were verifier-attested. The api-key\n // path has no signature proof, so the credential MUST be `api_key`\n // regardless of what the matched record carries. Same posture for\n // the dynamic `verify` path below.\n //\n // `key_id` is a SHA-256 hash prefix of the raw token, not the token\n // itself — `credential.key_id` flows broadly through `ctx.authInfo`,\n // handlers, and downstream code that may log structured context.\n // Adopters with custom api-key authenticators that need a different\n // `key_id` shape stamp their own credential and skip this path.\n const apiKeyCredential: AdcpCredential = { kind: 'api_key', key_id: hashApiKeyToken(token) };\n if (options.keys && Object.prototype.hasOwnProperty.call(options.keys, token)) {\n const matched = options.keys[token]!;\n return {\n ...matched,\n token,\n credential: apiKeyCredential,\n };\n }\n if (options.verify) {\n const result = await options.verify(token);\n if (!result) return null;\n return {\n ...result,\n token: result.token ?? token,\n credential: apiKeyCredential,\n };\n }\n return null;\n };\n}\n\n// ---------------------------------------------------------------------------\n// Bearer / JWT authenticator\n// ---------------------------------------------------------------------------\n\nexport interface VerifyBearerOptions {\n /** JWKS URI — usually `<issuer>/.well-known/jwks.json`. */\n jwksUri: string;\n /** Expected `iss` claim. */\n issuer: string;\n /**\n * Expected `aud` claim — the canonical URL clients see for this MCP\n * endpoint (e.g., `https://my-agent.example.com/mcp`). MUST match what\n * the token was issued for. If you advertise via\n * {@link ServeOptions.protectedResource}, set this to the same URL.\n *\n * For multi-host deployments pass a function. The two-argument form\n * receives `(req, ctx)` where `ctx.host` and `ctx.publicUrl` come from\n * `serve()`'s host resolution — inheriting the same\n * `trustForwardedHost` policy that governs the advertised PRM. Prefer\n * `(_req, { publicUrl }) => publicUrl!` so the JWT audience check and\n * the RFC 9728 `resource` URL can never diverge; a callback that reads\n * `X-Forwarded-Host` directly is a footgun when `trustForwardedHost`\n * is off.\n *\n * The single-argument form `(req) => string` still works for agents\n * mounting `verifyBearer` outside `serve()` (e.g., under\n * `createExpressAdapter`), but inherits none of `serve()`'s header\n * hardening — you MUST validate audience inputs yourself.\n */\n audience: string | ((req: IncomingMessage) => string) | ((req: IncomingMessage, ctx: ServeRequestContext) => string);\n /** Optional: required scopes (all must be present in the `scope` / `scp` claim). */\n requiredScopes?: string[];\n /**\n * Optional: JWT verification options passthrough. Defaults to the secure\n * asymmetric-only algorithm allowlist and a 30s clock tolerance — override\n * only if you know why. HS256/HS384/HS512 are rejected by default to prevent\n * algorithm-confusion attacks against the JWKS.\n */\n jwtOptions?: Omit<JWTVerifyOptions, 'issuer' | 'audience'>;\n}\n\n/**\n * Build a JWT bearer authenticator that validates tokens against a JWKS.\n *\n * Uses the `jose` library (already in the dependency tree). Audience and\n * issuer are enforced strictly — a token minted for the wrong audience\n * is rejected, which is the bug pattern we've seen in the wild when an\n * agent advertises an incorrect `/.well-known/oauth-protected-resource`\n * `resource` URL.\n *\n * ```ts\n * serve(createAgent, {\n * authenticate: verifyBearer({\n * jwksUri: 'https://auth.example/.well-known/jwks.json',\n * issuer: 'https://auth.example',\n * audience: 'https://my-agent.example.com/mcp',\n * }),\n * });\n * ```\n */\nexport function verifyBearer(options: VerifyBearerOptions): Authenticator {\n const jwks = createRemoteJWKSet(new URL(options.jwksUri));\n const audienceIsFn = typeof options.audience === 'function';\n const baseVerifyOptions: Omit<JWTVerifyOptions, 'audience'> = {\n algorithms: DEFAULT_JWT_ALGORITHMS.slice(),\n clockTolerance: DEFAULT_JWT_CLOCK_TOLERANCE_SECONDS,\n ...options.jwtOptions,\n issuer: options.issuer,\n };\n const staticVerifyOptions: JWTVerifyOptions | undefined = audienceIsFn\n ? undefined\n : { ...baseVerifyOptions, audience: options.audience as string };\n return async req => {\n const token = extractBearerToken(req);\n if (!token) return null;\n let payload: JWTPayload;\n let verifyOptions: JWTVerifyOptions;\n if (audienceIsFn) {\n let audience: string;\n try {\n // Pass the serve()-resolved context as the second argument. The\n // callback can use `ctx.publicUrl` (preferred — it's the same URL\n // the RFC 9728 PRM advertises) or `ctx.host` for its own\n // reconstruction. Falls back to an empty-host ctx when the\n // authenticator is mounted outside `serve()`, so callbacks must\n // still tolerate `host === ''`.\n const ctx: ServeRequestContext = getServeRequestContext(req) ?? { host: '' };\n audience = (options.audience as (r: IncomingMessage, c: ServeRequestContext) => string)(req, ctx);\n } catch (err) {\n // Resolver threw — surface as auth failure rather than 500 so the\n // client sees a clean 401 and the operator sees the cause in the log.\n throw new AuthError('Token validation failed.', { cause: err });\n }\n verifyOptions = { ...baseVerifyOptions, audience };\n } else {\n verifyOptions = staticVerifyOptions as JWTVerifyOptions;\n }\n try {\n ({ payload } = await jwtVerify(token, jwks, verifyOptions));\n } catch (err) {\n // Never surface jose's message to the client — it echoes expected audience,\n // issuer, or token-shape details that probing attackers can use.\n throw new AuthError('Token validation failed.', { cause: err });\n }\n const scopes = extractScopes(payload);\n if (options.requiredScopes?.length) {\n const missing = options.requiredScopes.filter(s => !scopes.includes(s));\n if (missing.length > 0) {\n throw new AuthError('Insufficient scope.', {\n cause: new Error(`Missing required scope(s): ${missing.join(', ')}`),\n });\n }\n }\n // Prefer `payload.client_id` over `payload.sub` per RFC 9068 §2.2:\n // `sub` is the resource-owner subject (often the user); `client_id`\n // is the OAuth client identity (the buyer agent for AdCP traffic).\n // For the client-credentials grant where `sub === client_id` both\n // resolve to the same value; for authorization-code flows where\n // `sub` is a user, falling back to `sub` would mis-route registry\n // lookups keyed by client identity.\n //\n // When neither is a usable string, omit the `credential` entirely\n // — `BuyerAgentRegistry` sees `null` (no credential = no known\n // agent) instead of bucketing every unauthenticated principal into\n // a single `'unknown'` row.\n const clientIdFromPayload =\n typeof payload.client_id === 'string' && payload.client_id.length > 0\n ? payload.client_id\n : typeof payload.sub === 'string' && payload.sub.length > 0\n ? payload.sub\n : undefined;\n const principal: AuthPrincipal = {\n principal: clientIdFromPayload ?? 'unknown',\n token,\n scopes,\n claims: payload,\n ...(clientIdFromPayload !== undefined && {\n credential: {\n kind: 'oauth' as const,\n client_id: clientIdFromPayload,\n scopes,\n ...(typeof payload.exp === 'number' && { expires_at: payload.exp }),\n },\n }),\n };\n if (typeof payload.exp === 'number') principal.expiresAt = payload.exp;\n return principal;\n };\n}\n\n/**\n * Extract scopes from a JWT payload. Handles both RFC 8693 `scope` (string,\n * space-delimited) and RFC 9068 / Azure AD / Okta `scp` (string or string[]).\n */\nfunction extractScopes(payload: JWTPayload): string[] {\n const out: string[] = [];\n if (typeof payload.scope === 'string') {\n out.push(...payload.scope.split(/\\s+/).filter(Boolean));\n } else if (Array.isArray(payload.scope)) {\n out.push(...(payload.scope as unknown[]).filter((s): s is string => typeof s === 'string'));\n }\n const scp = (payload as JWTPayload & { scp?: unknown }).scp;\n if (typeof scp === 'string') {\n out.push(...scp.split(/\\s+/).filter(Boolean));\n } else if (Array.isArray(scp)) {\n out.push(...scp.filter((s): s is string => typeof s === 'string'));\n }\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Combinators\n// ---------------------------------------------------------------------------\n\n/**\n * Pass if any authenticator succeeds. A `null` from one falls through to the\n * next; a thrown error short-circuits to 401 (credentials were presented but\n * rejected — not a \"no credentials\" case). Errors are wrapped in an\n * {@link AuthError} with a generic public message so the client can't tell\n * which mechanism rejected them.\n */\nexport function anyOf(...authenticators: Authenticator[]): Authenticator {\n for (const auth of authenticators) {\n if (isAuthenticatorPresenceGated(auth)) {\n throw new Error(\n 'anyOf: refusing to wrap a presence-gated authenticator. Wrapping would ' +\n 'reintroduce the bearer-bypass bug the gate was built to prevent. ' +\n 'Invert the composition: requireSignatureWhenPresent(sig, anyOf(...others)).'\n );\n }\n }\n const combined: Authenticator = async req => {\n let rejected = false;\n const causes: unknown[] = [];\n for (const auth of authenticators) {\n try {\n const result = await auth(req);\n if (result) return result;\n } catch (err) {\n rejected = true;\n causes.push(err);\n }\n }\n if (rejected) {\n throw new AuthError('Credentials rejected.', { cause: causes });\n }\n return null;\n };\n if (authenticators.some(a => authenticatorNeedsRawBody(a))) {\n tagAuthenticatorNeedsRawBody(combined);\n }\n return combined;\n}\n\n// ---------------------------------------------------------------------------\n// 401 / 403 response helper\n// ---------------------------------------------------------------------------\n\nexport interface RespondUnauthorizedOptions {\n /**\n * Bearer realm value. Defaults to `\"mcp\"` — a stable value that won't reflect\n * an attacker-controlled `Host` header into the challenge.\n */\n realm?: string;\n /** RFC 6750 error code. Defaults to `invalid_token`. */\n error?: 'invalid_request' | 'invalid_token' | 'insufficient_scope';\n /** Human-readable description. */\n errorDescription?: string;\n /**\n * OAuth 2.0 resource URL (RFC 9728). If set, included in the challenge so\n * clients can discover the auth server from the protected-resource metadata.\n */\n resourceMetadata?: string;\n /** Set to 403 instead of 401 for valid-but-unauthorized scenarios. */\n status?: 401 | 403;\n /**\n * RFC 9421 signature error code. When set, the challenge scheme switches\n * from `Bearer` to `Signature` and the body's `error` field carries the\n * signature code verbatim — what the `signed_requests` conformance grader\n * reads from `WWW-Authenticate` to decide pass/fail on negative vectors.\n *\n * Set this whenever the rejection is a signature-layer failure (invalid\n * signature, missing required signature, revoked key, replayed nonce,\n * etc.). `serve()` auto-detects this from an {@link AuthError} whose\n * `cause` is a {@link RequestSignatureError}; callers rarely set it\n * directly.\n */\n signatureError?: RequestSignatureErrorCode;\n}\n\n/**\n * Send an RFC 6750-compliant 401/403 response with the `WWW-Authenticate`\n * header set. Called automatically by {@link serve} when `authenticate`\n * returns `null` or throws.\n *\n * When {@link RespondUnauthorizedOptions.signatureError} is set, the\n * challenge scheme becomes `Signature` (per the `signed-requests`\n * specialism) and the body's `error` field carries the RFC 9421 error\n * code — the `signed_requests` grader reads both from the challenge.\n */\nexport function respondUnauthorized(\n _req: IncomingMessage,\n res: ServerResponse,\n options: RespondUnauthorizedOptions = {}\n): void {\n const realm = options.realm ?? 'mcp';\n const parts = [`realm=\"${escapeQuotes(realm)}\"`];\n const useSignatureChallenge = options.signatureError !== undefined;\n // The `error` codes are typed unions — the type system gives us the\n // only quote-safe guarantee. Route through `escapeQuotes` so a future\n // widening to `string` or a code that happens to include `\"` doesn't\n // inject a new parameter into the challenge header.\n if (useSignatureChallenge) {\n parts.push(`error=\"${escapeQuotes(options.signatureError!)}\"`);\n } else if (options.error) {\n parts.push(`error=\"${escapeQuotes(options.error)}\"`);\n }\n if (options.errorDescription) parts.push(`error_description=\"${escapeQuotes(options.errorDescription)}\"`);\n if (options.resourceMetadata) parts.push(`resource_metadata=\"${escapeQuotes(options.resourceMetadata)}\"`);\n\n const scheme = useSignatureChallenge ? 'Signature' : 'Bearer';\n res.writeHead(options.status ?? 401, {\n 'Content-Type': 'application/json',\n 'WWW-Authenticate': `${scheme} ${parts.join(', ')}`,\n });\n res.end(\n JSON.stringify({\n error: useSignatureChallenge ? options.signatureError : (options.error ?? 'unauthorized'),\n error_description: options.errorDescription ?? 'Authentication required.',\n })\n );\n}\n\n/**\n * Unwrap the first {@link RequestSignatureError} found walking the\n * `cause` chain of an {@link AuthError} (or any error), so callers can\n * switch the `WWW-Authenticate` challenge scheme on signature-layer\n * failures. Returns `null` for non-signature errors.\n */\nexport function signatureErrorCodeFromCause(err: unknown): RequestSignatureErrorCode | null {\n // Track visited refs to break arbitrary cycles (self-reference, N-cycles,\n // or a long non-signature chain that would otherwise exhaust the walker).\n // The visited set is a belt-and-suspenders companion to the hop cap —\n // either one alone is enough for legitimate chains, but cycle resistance\n // is the security-relevant property.\n const visited = new Set<unknown>();\n let current: unknown = err;\n let hops = 0;\n while (current != null && hops < 32 && !visited.has(current)) {\n if (current instanceof RequestSignatureError) return current.code;\n visited.add(current);\n current = (current as { cause?: unknown }).cause;\n hops++;\n }\n return null;\n}\n\nfunction escapeQuotes(s: string): string {\n // Escape backslashes first so later-inserted escapes aren't re-escaped.\n return s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\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QAAQ,IAAI,OAAO,GAAG;AAC5D,QAAI,mBAAmB,sBAAuB,QAAO,QAAQ;AAC7D,YAAQ,IAAI,OAAO;AACnB,cAAW,QAAgC;AAC3C;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,aAAa,GAAmB;AAEvC,SAAO,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK;AACrD;","names":[]}
@@ -1,9 +1,3 @@
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 __filename = __adcpFileURLToPath(import.meta.url);
5
- const __dirname = __adcpDirname(__filename);
6
- const require = __adcpCreateRequire(import.meta.url);
7
1
  import { z } from "zod";
8
2
  import { parseAdcpMajorVersion, toReleasePrecisionVersion } from "../version.mjs";
9
3
  import { resolveAdcpVersion } from "../utils/adcp-version-config.mjs";