@adcp/sdk 16.1.0 → 16.3.0

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 (126) hide show
  1. package/AGENTS.md +2 -0
  2. package/dist/lib/core/AgentClient.js +17 -1
  3. package/dist/lib/core/AgentClient.mjs +17 -1
  4. package/dist/lib/core/SingleAgentClient.js +13 -0
  5. package/dist/lib/core/SingleAgentClient.mjs +13 -0
  6. package/dist/lib/core/TaskExecutor.js +88 -13
  7. package/dist/lib/core/TaskExecutor.mjs +89 -14
  8. package/dist/lib/errors/index.d.mts +34 -0
  9. package/dist/lib/errors/index.d.ts +34 -0
  10. package/dist/lib/errors/index.js +11 -0
  11. package/dist/lib/errors/index.mjs +10 -0
  12. package/dist/lib/governance/authorization.d.mts +66 -0
  13. package/dist/lib/governance/authorization.d.ts +66 -0
  14. package/dist/lib/governance/authorization.js +181 -37
  15. package/dist/lib/governance/authorization.mjs +183 -36
  16. package/dist/lib/governance/index.d.mts +2 -2
  17. package/dist/lib/governance/index.d.ts +2 -2
  18. package/dist/lib/governance/index.js +4 -2
  19. package/dist/lib/governance/index.mjs +3 -1
  20. package/dist/lib/identity-3.3/index.d.mts +1 -0
  21. package/dist/lib/identity-3.3/index.d.ts +1 -0
  22. package/dist/lib/identity-3.3/index.js +3 -1
  23. package/dist/lib/identity-3.3/index.mjs +1 -0
  24. package/dist/lib/identity-3.3/jws-artifacts.d.mts +147 -0
  25. package/dist/lib/identity-3.3/jws-artifacts.d.ts +147 -0
  26. package/dist/lib/identity-3.3/jws-artifacts.js +258 -0
  27. package/dist/lib/identity-3.3/jws-artifacts.mjs +234 -0
  28. package/dist/lib/identity-3.3/revocation.d.mts +7 -0
  29. package/dist/lib/identity-3.3/revocation.d.ts +7 -0
  30. package/dist/lib/identity-3.3/revocation.js +13 -0
  31. package/dist/lib/identity-3.3/revocation.mjs +13 -0
  32. package/dist/lib/index.d.mts +3 -3
  33. package/dist/lib/index.d.ts +3 -3
  34. package/dist/lib/index.js +4 -0
  35. package/dist/lib/index.mjs +4 -0
  36. package/dist/lib/media-buy/compatibility.d.mts +1 -0
  37. package/dist/lib/media-buy/compatibility.d.ts +1 -0
  38. package/dist/lib/media-buy/compatibility.js +33 -10
  39. package/dist/lib/media-buy/compatibility.mjs +32 -14
  40. package/dist/lib/negotiation/buyer.js +11 -5
  41. package/dist/lib/negotiation/buyer.mjs +11 -5
  42. package/dist/lib/negotiation/types.d.mts +4 -2
  43. package/dist/lib/negotiation/types.d.ts +4 -2
  44. package/dist/lib/negotiation/verification.d.mts +15 -6
  45. package/dist/lib/negotiation/verification.d.ts +15 -6
  46. package/dist/lib/negotiation/verification.js +146 -27
  47. package/dist/lib/negotiation/verification.mjs +146 -28
  48. package/dist/lib/negotiation/version.d.mts +6 -0
  49. package/dist/lib/negotiation/version.d.ts +6 -0
  50. package/dist/lib/negotiation/version.js +60 -0
  51. package/dist/lib/negotiation/version.mjs +33 -0
  52. package/dist/lib/registry/types.generated.d.mts +24 -1
  53. package/dist/lib/registry/types.generated.d.ts +24 -1
  54. package/dist/lib/server/create-adcp-server.js +1 -1
  55. package/dist/lib/server/create-adcp-server.mjs +1 -1
  56. package/dist/lib/server/error-arm-tools.d.mts +10 -10
  57. package/dist/lib/server/error-arm-tools.d.ts +10 -10
  58. package/dist/lib/server/error-arm-tools.js +22 -58
  59. package/dist/lib/server/error-arm-tools.mjs +30 -65
  60. package/dist/lib/server/index.d.mts +2 -2
  61. package/dist/lib/server/index.d.ts +2 -2
  62. package/dist/lib/server/index.js +2 -0
  63. package/dist/lib/server/index.mjs +2 -0
  64. package/dist/lib/signing/web-bot-auth.js +5 -0
  65. package/dist/lib/signing/web-bot-auth.mjs +4 -0
  66. package/dist/lib/testing/compliance/comply.js +17 -0
  67. package/dist/lib/testing/compliance/comply.mjs +17 -0
  68. package/dist/lib/testing/index.d.mts +3 -0
  69. package/dist/lib/testing/index.d.ts +3 -0
  70. package/dist/lib/testing/index.js +44 -2
  71. package/dist/lib/testing/index.mjs +42 -0
  72. package/dist/lib/testing/storyboard/collection-selection.d.mts +259 -0
  73. package/dist/lib/testing/storyboard/collection-selection.d.ts +259 -0
  74. package/dist/lib/testing/storyboard/collection-selection.js +384 -0
  75. package/dist/lib/testing/storyboard/collection-selection.mjs +348 -0
  76. package/dist/lib/testing/storyboard/context.js +12 -6
  77. package/dist/lib/testing/storyboard/context.mjs +12 -6
  78. package/dist/lib/testing/storyboard/fixture-resolution.d.mts +39 -1
  79. package/dist/lib/testing/storyboard/fixture-resolution.d.ts +39 -1
  80. package/dist/lib/testing/storyboard/fixture-resolution.js +216 -12
  81. package/dist/lib/testing/storyboard/fixture-resolution.mjs +218 -12
  82. package/dist/lib/testing/storyboard/index.d.mts +9 -2
  83. package/dist/lib/testing/storyboard/index.d.ts +9 -2
  84. package/dist/lib/testing/storyboard/index.js +51 -2
  85. package/dist/lib/testing/storyboard/index.mjs +49 -1
  86. package/dist/lib/testing/storyboard/prepared-fixtures.d.mts +471 -0
  87. package/dist/lib/testing/storyboard/prepared-fixtures.d.ts +471 -0
  88. package/dist/lib/testing/storyboard/prepared-fixtures.js +434 -0
  89. package/dist/lib/testing/storyboard/prepared-fixtures.mjs +389 -0
  90. package/dist/lib/testing/storyboard/protected-context.d.mts +127 -0
  91. package/dist/lib/testing/storyboard/protected-context.d.ts +127 -0
  92. package/dist/lib/testing/storyboard/protected-context.js +301 -0
  93. package/dist/lib/testing/storyboard/protected-context.mjs +267 -0
  94. package/dist/lib/testing/storyboard/rejection-hints.js +13 -4
  95. package/dist/lib/testing/storyboard/rejection-hints.mjs +13 -4
  96. package/dist/lib/testing/storyboard/runner.d.mts +24 -0
  97. package/dist/lib/testing/storyboard/runner.d.ts +24 -0
  98. package/dist/lib/testing/storyboard/runner.js +1061 -105
  99. package/dist/lib/testing/storyboard/runner.mjs +1075 -106
  100. package/dist/lib/testing/storyboard/seeding.d.mts +15 -1
  101. package/dist/lib/testing/storyboard/seeding.d.ts +15 -1
  102. package/dist/lib/testing/storyboard/seeding.js +272 -12
  103. package/dist/lib/testing/storyboard/seeding.mjs +274 -13
  104. package/dist/lib/testing/storyboard/types.d.mts +207 -10
  105. package/dist/lib/testing/storyboard/types.d.ts +207 -10
  106. package/dist/lib/testing/storyboard/types.js +1 -1
  107. package/dist/lib/testing/storyboard/types.mjs +1 -1
  108. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  109. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  110. package/dist/lib/testing/storyboard/validations.js +95 -0
  111. package/dist/lib/testing/storyboard/validations.mjs +95 -0
  112. package/dist/lib/validation/bundled-schema-store.js +5 -0
  113. package/dist/lib/validation/bundled-schema-store.mjs +4 -0
  114. package/dist/lib/validation/schema-loader.js +19 -2
  115. package/dist/lib/validation/schema-loader.mjs +22 -3
  116. package/dist/lib/version.d.mts +3 -3
  117. package/dist/lib/version.d.ts +3 -3
  118. package/dist/lib/version.js +3 -3
  119. package/dist/lib/version.mjs +3 -3
  120. package/docs/TYPE-SUMMARY.md +2 -2
  121. package/docs/guides/COLLECTION-FIXTURE-FOUNDATION.md +850 -0
  122. package/docs/guides/PROPOSAL-TERMS-VERIFICATION.md +66 -0
  123. package/docs/llms.txt +4 -3
  124. package/docs/migration-14.x-rc-worksheet.md +4 -4
  125. package/docs/migration-agent-identity-3.3.md +51 -6
  126. package/package.json +6 -4
@@ -9,11 +9,22 @@ import {
9
9
  canonicalAgentUrl
10
10
  } from "../signing/agent-resolver/select-agent.mjs";
11
11
  import { parseStrictJson } from "../signing/agent-resolver/strict-json.mjs";
12
+ import {
13
+ JwsArtifactError,
14
+ selectJwsArtifactProfile,
15
+ verifyWebBotAuthJwsArtifact
16
+ } from "../identity-3.3/jws-artifacts.mjs";
12
17
  const GOVERNANCE_AUTHORIZATION_CRITICAL_CLAIMS = Object.freeze([
13
18
  "authorized_commitment",
14
19
  "authorized_task",
15
20
  "authorized_payload_hash"
16
21
  ]);
22
+ const GOVERNANCE_JWS_TYP = "adcp-gov+jws";
23
+ const GOVERNANCE_CRIT = {
24
+ authorized_commitment: true,
25
+ authorized_task: true,
26
+ authorized_payload_hash: true
27
+ };
17
28
  class GovernanceReplayStoreAdapter {
18
29
  constructor(replayStore) {
19
30
  this.replayStore = replayStore;
@@ -247,27 +258,19 @@ function targetDeclaresLegacyGovernanceAwareness(capabilities, task) {
247
258
  const mediaBuy = isRecord(root?.media_buy) ? root.media_buy : void 0;
248
259
  return mediaBuy?.governance_aware === true;
249
260
  }
250
- async function verifyGovernanceAuthorization(options) {
261
+ function parseGovernanceJws(token, expectedIssuer) {
251
262
  const reject = (error, message) => ({
252
263
  ok: false,
253
264
  error,
254
265
  message
255
266
  });
256
- if (!options.authenticatedCaller) {
257
- return reject("governance_token_invalid", "Authenticated caller is required");
258
- }
259
- try {
260
- buildGovernanceCommitment(options.actualCommitment.amount, options.actualCommitment.currency);
261
- } catch (error) {
262
- return reject("governance_token_invalid", error.message);
263
- }
264
- if (typeof options.token !== "string" || options.token.length === 0) {
267
+ if (typeof token !== "string" || token.length === 0) {
265
268
  return reject("governance_token_invalid", "governance_context is required");
266
269
  }
267
- if (options.token.length > 4096) {
270
+ if (token.length > 4096) {
268
271
  return reject("governance_token_invalid", "governance_context exceeds the protocol size limit");
269
272
  }
270
- const parts = options.token.split(".");
273
+ const parts = token.split(".");
271
274
  if (parts.length !== 3 || parts.some((part) => !part || !/^[A-Za-z0-9_-]+$/.test(part))) {
272
275
  return reject("governance_token_invalid", "governance_context is not a compact JWS");
273
276
  }
@@ -280,7 +283,7 @@ async function verifyGovernanceAuthorization(options) {
280
283
  if (alg !== "EdDSA" && alg !== "ES256") {
281
284
  return reject("governance_token_invalid", "Unsupported governance JWS algorithm");
282
285
  }
283
- if (protectedHeader.typ !== "adcp-gov+jws") {
286
+ if (protectedHeader.typ !== GOVERNANCE_JWS_TYP) {
284
287
  return reject("governance_token_invalid", "Invalid governance JWS typ");
285
288
  }
286
289
  const critical = protectedHeader.crit;
@@ -308,35 +311,71 @@ async function verifyGovernanceAuthorization(options) {
308
311
  try {
309
312
  if (typeof decodedClaims.iss !== "string") throw new TypeError("Missing issuer");
310
313
  canonicalIssuer = canonicalAgentUrl(decodedClaims.iss);
311
- if (canonicalIssuer !== canonicalAgentUrl(options.expectedIssuer)) throw new TypeError("Issuer mismatch");
314
+ if (canonicalIssuer !== canonicalAgentUrl(expectedIssuer)) throw new TypeError("Issuer mismatch");
312
315
  } catch {
313
316
  return reject("governance_token_invalid", "Governance token issuer mismatch");
314
317
  }
315
- const kid = typeof protectedHeader.kid === "string" ? protectedHeader.kid : "";
316
- if (!kid) return reject("governance_key_unknown", "Governance signing kid is missing");
317
- let jwk;
318
+ return { ok: true, token, protectedHeader, decodedClaims, canonicalIssuer, alg };
319
+ }
320
+ async function verifyGovernanceAuthorization(options) {
321
+ const reject = (error, message) => ({
322
+ ok: false,
323
+ error,
324
+ message
325
+ });
326
+ if (!options.authenticatedCaller) {
327
+ return reject("governance_token_invalid", "Authenticated caller is required");
328
+ }
318
329
  try {
319
- const resolver = options.buyerIdentity ? createGovernanceAgentJwksResolver(canonicalIssuer, options.buyerIdentity) : options.jwks;
320
- if (!resolver) return reject("governance_key_unknown", "No governance key resolver or buyer identity configured");
321
- jwk = await resolver.resolve(kid);
322
- } catch {
323
- return reject("governance_key_unknown", "Governance signing key could not be resolved");
330
+ buildGovernanceCommitment(options.actualCommitment.amount, options.actualCommitment.currency);
331
+ } catch (error) {
332
+ return reject("governance_token_invalid", error.message);
324
333
  }
325
- if (!jwk || jwk.adcp_use !== "governance-signing" || jwk.use !== "sig" || !jwk.key_ops?.includes("verify") || jwk.alg !== void 0 && jwk.alg !== alg) {
326
- return reject("governance_key_unknown", "Governance signing key is unknown or not authorized");
334
+ const parsed = parseGovernanceJws(options.token, options.expectedIssuer);
335
+ if (!parsed.ok) return parsed;
336
+ const { protectedHeader, decodedClaims, canonicalIssuer, alg } = parsed;
337
+ const kid = typeof protectedHeader.kid === "string" ? protectedHeader.kid : "";
338
+ if (!kid) return reject("governance_key_unknown", "Governance signing kid is missing");
339
+ let profile;
340
+ if (options.webBotAuth) {
341
+ try {
342
+ profile = await selectJwsArtifactProfile(options.expectedIssuer, options.webBotAuth.trust);
343
+ } catch {
344
+ return { ...reject("governance_key_unknown", "Governance issuer trust record is unavailable"), retryable: true };
345
+ }
327
346
  }
328
- try {
329
- const key = await importJWK(jwk, alg);
330
- await compactVerify(options.token, key, {
331
- algorithms: [alg],
332
- crit: {
333
- authorized_commitment: true,
334
- authorized_task: true,
335
- authorized_payload_hash: true
347
+ if (profile?.profile === "web-bot-auth") {
348
+ if (options.buyerIdentity) {
349
+ try {
350
+ const record = relyingPartyAgentRecord(options.buyerIdentity.brandJson, options.buyerIdentity.brandDomain);
351
+ selectAgentByUrl(record, canonicalIssuer, { agentType: "governance" });
352
+ } catch {
353
+ return reject("governance_key_unknown", "Governance issuer is not the buyer's governance agent");
336
354
  }
337
- });
338
- } catch {
339
- return reject("governance_token_invalid", "Governance token signature verification failed");
355
+ }
356
+ const failure = await verifyGovernanceJwsOnWebBotAuth(options.token, profile.origin, options.webBotAuth);
357
+ if (failure) return failure;
358
+ } else {
359
+ let jwk;
360
+ try {
361
+ const resolver = options.buyerIdentity ? createGovernanceAgentJwksResolver(canonicalIssuer, options.buyerIdentity) : options.jwks;
362
+ if (!resolver) return reject("governance_key_unknown", "No governance key resolver or buyer identity configured");
363
+ jwk = await resolver.resolve(kid);
364
+ } catch {
365
+ return reject("governance_key_unknown", "Governance signing key could not be resolved");
366
+ }
367
+ if (!jwk || jwk.adcp_use !== "governance-signing" || jwk.use !== "sig" || !jwk.key_ops?.includes("verify") || jwk.alg !== void 0 && jwk.alg !== alg) {
368
+ return reject("governance_key_unknown", "Governance signing key is unknown or not authorized");
369
+ }
370
+ try {
371
+ const key = await importJWK(jwk, alg);
372
+ await compactVerify(options.token, key, {
373
+ algorithms: [alg],
374
+ crit: GOVERNANCE_CRIT
375
+ });
376
+ } catch {
377
+ return reject("governance_token_invalid", "Governance token signature verification failed");
378
+ }
340
379
  }
341
380
  try {
342
381
  if (options.revocationStore && await options.revocationStore.isRevoked(kid)) {
@@ -494,6 +533,113 @@ async function verifyGovernanceAuthorization(options) {
494
533
  payloadHash
495
534
  };
496
535
  }
536
+ function governanceFailureFromJwsArtifact(error) {
537
+ if (!(error instanceof JwsArtifactError))
538
+ return {
539
+ ok: false,
540
+ error: "governance_key_unknown",
541
+ message: "Governance signing key could not be resolved",
542
+ retryable: true
543
+ };
544
+ switch (error.code) {
545
+ case "jws_key_revoked":
546
+ return { ok: false, error: "governance_token_revoked", message: "Governance signing key is revoked" };
547
+ case "jws_revocation_unavailable":
548
+ return {
549
+ ok: false,
550
+ error: "governance_token_revoked",
551
+ message: "Governance revocation status could not be established",
552
+ retryable: true
553
+ };
554
+ case "jws_invalid":
555
+ return {
556
+ ok: false,
557
+ error: "governance_token_invalid",
558
+ message: `Governance token verification failed: ${error.message}`
559
+ };
560
+ case "jws_key_unavailable":
561
+ return {
562
+ ok: false,
563
+ error: "governance_key_unknown",
564
+ message: "Governance signing key could not be resolved",
565
+ retryable: true
566
+ };
567
+ default:
568
+ return { ok: false, error: "governance_key_unknown", message: "Governance signing key could not be resolved" };
569
+ }
570
+ }
571
+ const NO_ORIGIN_REVOCATION = Object.freeze({
572
+ ok: false,
573
+ error: "governance_token_revoked",
574
+ message: "No origin revocation source is configured for the Web Bot Auth path"
575
+ });
576
+ async function verifyGovernanceJwsOnWebBotAuth(token, origin, webBotAuth) {
577
+ if (!webBotAuth.revocation) return { ...NO_ORIGIN_REVOCATION };
578
+ try {
579
+ await verifyWebBotAuthJwsArtifact(token, origin, {
580
+ typ: GOVERNANCE_JWS_TYP,
581
+ directory: webBotAuth.directory,
582
+ revocation: webBotAuth.revocation,
583
+ // A governance context authorizes spend: an origin that serves no list fails closed.
584
+ revocationAbsent: "reject",
585
+ crit: GOVERNANCE_CRIT
586
+ });
587
+ return void 0;
588
+ } catch (error) {
589
+ return governanceFailureFromJwsArtifact(error);
590
+ }
591
+ }
592
+ async function verifyHistoricalGovernanceContext(options) {
593
+ const parsed = parseGovernanceJws(options.token, options.expectedIssuer);
594
+ if (!parsed.ok) return parsed;
595
+ if (parsed.alg !== "EdDSA")
596
+ return {
597
+ ok: false,
598
+ error: "governance_token_invalid",
599
+ message: "A Web Bot Auth governance context uses alg EdDSA"
600
+ };
601
+ if (!options.webBotAuth.revocation) return { ...NO_ORIGIN_REVOCATION };
602
+ let profile;
603
+ try {
604
+ profile = await selectJwsArtifactProfile(options.expectedIssuer, options.webBotAuth.trust);
605
+ } catch {
606
+ return {
607
+ ok: false,
608
+ error: "governance_key_unknown",
609
+ message: "Governance issuer trust record is unavailable",
610
+ retryable: true
611
+ };
612
+ }
613
+ if (profile.profile !== "web-bot-auth")
614
+ return {
615
+ ok: false,
616
+ error: "governance_key_unknown",
617
+ message: "Governance issuer is on the 3.2 profile; its trust record does not list its origin",
618
+ profile: "3.2"
619
+ };
620
+ try {
621
+ const verified = await verifyWebBotAuthJwsArtifact(parsed.token, profile.origin, {
622
+ typ: GOVERNANCE_JWS_TYP,
623
+ directory: options.webBotAuth.directory,
624
+ archive: options.webBotAuth.archive,
625
+ revocation: options.webBotAuth.revocation,
626
+ // No spend rides on an audit: an origin that serves no list has revoked nothing.
627
+ revocationAbsent: "accept",
628
+ revokedKey: "report",
629
+ crit: GOVERNANCE_CRIT
630
+ });
631
+ return {
632
+ ok: true,
633
+ claims: parsed.decodedClaims,
634
+ protectedHeader: parsed.protectedHeader,
635
+ keySource: verified.keySource,
636
+ revocation: verified.revocation,
637
+ ...verified.revocationDetail ? { revocationDetail: verified.revocationDetail } : {}
638
+ };
639
+ } catch (error) {
640
+ return governanceFailureFromJwsArtifact(error);
641
+ }
642
+ }
497
643
  class GovernanceAuthorizationError extends Error {
498
644
  code;
499
645
  constructor(result) {
@@ -549,5 +695,6 @@ export {
549
695
  governanceTaskRequiresProposedCommitment,
550
696
  targetDeclaresGovernanceEnforcement,
551
697
  targetDeclaresLegacyGovernanceAwareness,
552
- verifyGovernanceAuthorization
698
+ verifyGovernanceAuthorization,
699
+ verifyHistoricalGovernanceContext
553
700
  };
@@ -13,8 +13,8 @@
13
13
  * advisory — the authoritative check happens in the governance agent, which
14
14
  * resolves category synonyms and custom policies server-side.
15
15
  */
16
- export { GOVERNANCE_AUTHORIZATION_CRITICAL_CLAIMS, GovernanceAuthorizationError, GovernanceReplayStoreAdapter, InMemoryGovernanceReplayStore, buildGovernanceCommitment, buildGovernanceExecutionCommitment, buildGovernanceExecutionRequest, buildGovernanceIntentRequest, buildGovernanceProposedCommitment, computeGovernedPayloadHash, createGovernanceEnforcementMiddleware, getGovernanceEnforcementTasks, governancePurchaseTypeForTask, governanceTaskRequiresProposedCommitment, targetDeclaresGovernanceEnforcement, targetDeclaresLegacyGovernanceAwareness, verifyGovernanceAuthorization, createGovernanceAgentJwksResolver, } from './authorization.mjs';
17
- export type { BuildGovernanceExecutionRequestInput, BuildGovernanceIntentRequestInput, GovernanceAuthorizationClaims, GovernanceAuthorizationCriticalClaim, GovernanceAuthorizationErrorCode, GovernanceAuthorizationFailure, GovernanceAuthorizationResult, GovernanceAuthorizationSuccess, GovernanceCommitment, GovernanceEnforcementMiddleware, GovernanceEnforcementMiddlewareConfig, GovernanceEnforcementMiddlewareInput, GovernanceEnforcementMode, GovernanceEnforcementTask, GovernanceReplayStore, GovernanceReplayBinding, GovernanceRevocationResolver, GovernanceRevocationStatus, InMemoryGovernanceReplayStoreOptions, VerifyGovernanceAuthorizationOptions, GovernanceBuyerIdentity, } from './authorization.mjs';
16
+ export { GOVERNANCE_AUTHORIZATION_CRITICAL_CLAIMS, GovernanceAuthorizationError, GovernanceReplayStoreAdapter, InMemoryGovernanceReplayStore, buildGovernanceCommitment, buildGovernanceExecutionCommitment, buildGovernanceExecutionRequest, buildGovernanceIntentRequest, buildGovernanceProposedCommitment, computeGovernedPayloadHash, createGovernanceEnforcementMiddleware, getGovernanceEnforcementTasks, governancePurchaseTypeForTask, governanceTaskRequiresProposedCommitment, targetDeclaresGovernanceEnforcement, targetDeclaresLegacyGovernanceAwareness, verifyGovernanceAuthorization, verifyHistoricalGovernanceContext, createGovernanceAgentJwksResolver, } from './authorization.mjs';
17
+ export type { BuildGovernanceExecutionRequestInput, BuildGovernanceIntentRequestInput, GovernanceAuthorizationClaims, GovernanceAuthorizationCriticalClaim, GovernanceAuthorizationErrorCode, GovernanceAuthorizationFailure, GovernanceAuthorizationResult, GovernanceAuthorizationSuccess, GovernanceCommitment, GovernanceEnforcementMiddleware, GovernanceEnforcementMiddlewareConfig, GovernanceEnforcementMiddlewareInput, GovernanceEnforcementMode, GovernanceEnforcementTask, GovernanceReplayStore, GovernanceReplayBinding, GovernanceRevocationResolver, GovernanceRevocationStatus, InMemoryGovernanceReplayStoreOptions, VerifyGovernanceAuthorizationOptions, VerifyHistoricalGovernanceContextOptions, HistoricalGovernanceContextResult, GovernanceBuyerIdentity, } from './authorization.mjs';
18
18
  /**
19
19
  * `policy_categories` values that MUST set `human_review_required: true`
20
20
  * under GDPR Art 22 / EU AI Act Annex III. Matches the schema's `if/then`
@@ -13,8 +13,8 @@
13
13
  * advisory — the authoritative check happens in the governance agent, which
14
14
  * resolves category synonyms and custom policies server-side.
15
15
  */
16
- export { GOVERNANCE_AUTHORIZATION_CRITICAL_CLAIMS, GovernanceAuthorizationError, GovernanceReplayStoreAdapter, InMemoryGovernanceReplayStore, buildGovernanceCommitment, buildGovernanceExecutionCommitment, buildGovernanceExecutionRequest, buildGovernanceIntentRequest, buildGovernanceProposedCommitment, computeGovernedPayloadHash, createGovernanceEnforcementMiddleware, getGovernanceEnforcementTasks, governancePurchaseTypeForTask, governanceTaskRequiresProposedCommitment, targetDeclaresGovernanceEnforcement, targetDeclaresLegacyGovernanceAwareness, verifyGovernanceAuthorization, createGovernanceAgentJwksResolver, } from './authorization';
17
- export type { BuildGovernanceExecutionRequestInput, BuildGovernanceIntentRequestInput, GovernanceAuthorizationClaims, GovernanceAuthorizationCriticalClaim, GovernanceAuthorizationErrorCode, GovernanceAuthorizationFailure, GovernanceAuthorizationResult, GovernanceAuthorizationSuccess, GovernanceCommitment, GovernanceEnforcementMiddleware, GovernanceEnforcementMiddlewareConfig, GovernanceEnforcementMiddlewareInput, GovernanceEnforcementMode, GovernanceEnforcementTask, GovernanceReplayStore, GovernanceReplayBinding, GovernanceRevocationResolver, GovernanceRevocationStatus, InMemoryGovernanceReplayStoreOptions, VerifyGovernanceAuthorizationOptions, GovernanceBuyerIdentity, } from './authorization';
16
+ export { GOVERNANCE_AUTHORIZATION_CRITICAL_CLAIMS, GovernanceAuthorizationError, GovernanceReplayStoreAdapter, InMemoryGovernanceReplayStore, buildGovernanceCommitment, buildGovernanceExecutionCommitment, buildGovernanceExecutionRequest, buildGovernanceIntentRequest, buildGovernanceProposedCommitment, computeGovernedPayloadHash, createGovernanceEnforcementMiddleware, getGovernanceEnforcementTasks, governancePurchaseTypeForTask, governanceTaskRequiresProposedCommitment, targetDeclaresGovernanceEnforcement, targetDeclaresLegacyGovernanceAwareness, verifyGovernanceAuthorization, verifyHistoricalGovernanceContext, createGovernanceAgentJwksResolver, } from './authorization';
17
+ export type { BuildGovernanceExecutionRequestInput, BuildGovernanceIntentRequestInput, GovernanceAuthorizationClaims, GovernanceAuthorizationCriticalClaim, GovernanceAuthorizationErrorCode, GovernanceAuthorizationFailure, GovernanceAuthorizationResult, GovernanceAuthorizationSuccess, GovernanceCommitment, GovernanceEnforcementMiddleware, GovernanceEnforcementMiddlewareConfig, GovernanceEnforcementMiddlewareInput, GovernanceEnforcementMode, GovernanceEnforcementTask, GovernanceReplayStore, GovernanceReplayBinding, GovernanceRevocationResolver, GovernanceRevocationStatus, InMemoryGovernanceReplayStoreOptions, VerifyGovernanceAuthorizationOptions, VerifyHistoricalGovernanceContextOptions, HistoricalGovernanceContextResult, GovernanceBuyerIdentity, } from './authorization';
18
18
  /**
19
19
  * `policy_categories` values that MUST set `human_review_required: true`
20
20
  * under GDPR Art 22 / EU AI Act Annex III. Matches the schema's `if/then`
@@ -40,7 +40,8 @@ __export(governance_exports, {
40
40
  targetDeclaresGovernanceEnforcement: () => import_authorization.targetDeclaresGovernanceEnforcement,
41
41
  targetDeclaresLegacyGovernanceAwareness: () => import_authorization.targetDeclaresLegacyGovernanceAwareness,
42
42
  validateGovernancePlan: () => validateGovernancePlan,
43
- verifyGovernanceAuthorization: () => import_authorization.verifyGovernanceAuthorization
43
+ verifyGovernanceAuthorization: () => import_authorization.verifyGovernanceAuthorization,
44
+ verifyHistoricalGovernanceContext: () => import_authorization.verifyHistoricalGovernanceContext
44
45
  });
45
46
  module.exports = __toCommonJS(governance_exports);
46
47
  var import_authorization = require('./authorization.js');
@@ -165,5 +166,6 @@ function validateGovernancePlan(plan) {
165
166
  targetDeclaresGovernanceEnforcement,
166
167
  targetDeclaresLegacyGovernanceAwareness,
167
168
  validateGovernancePlan,
168
- verifyGovernanceAuthorization
169
+ verifyGovernanceAuthorization,
170
+ verifyHistoricalGovernanceContext
169
171
  });
@@ -16,6 +16,7 @@ import {
16
16
  targetDeclaresGovernanceEnforcement,
17
17
  targetDeclaresLegacyGovernanceAwareness,
18
18
  verifyGovernanceAuthorization,
19
+ verifyHistoricalGovernanceContext,
19
20
  createGovernanceAgentJwksResolver
20
21
  } from "./authorization.mjs";
21
22
  const REGULATED_HUMAN_REVIEW_CATEGORIES = Object.freeze([
@@ -138,5 +139,6 @@ export {
138
139
  targetDeclaresGovernanceEnforcement,
139
140
  targetDeclaresLegacyGovernanceAwareness,
140
141
  validateGovernancePlan,
141
- verifyGovernanceAuthorization
142
+ verifyGovernanceAuthorization,
143
+ verifyHistoricalGovernanceContext
142
144
  };
@@ -2,6 +2,7 @@ export * from './types.mjs';
2
2
  export * from './trust.mjs';
3
3
  export * from './lifecycle.mjs';
4
4
  export * from './revocation.mjs';
5
+ export * from './jws-artifacts.mjs';
5
6
  export { WEB_BOT_AUTH_DRAFT_REVISION, verifyWebBotAuth, signWebBotAuth, createWebBotAuthFetch, createSignedSignatureDirectory, SignatureDirectoryResolver, verifySignatureDirectory, verifyKeyDirectory, selectSignatureProfile, jwkThumbprint, WebBotAuthError, WebBotAuthUnavailableError, } from '../signing/web-bot-auth.mjs';
6
7
  export type { WebBotSigningKey, WebBotSigningOptions, VerifiedWebBotSigner, VerifyWebBotAuthOptions, VerifiedSignatureDirectory, SignatureDirectoryResolverOptions, } from '../signing/web-bot-auth.mjs';
7
8
  export { validateIdentity33Payload } from './validation.mjs';
@@ -2,6 +2,7 @@ export * from './types';
2
2
  export * from './trust';
3
3
  export * from './lifecycle';
4
4
  export * from './revocation';
5
+ export * from './jws-artifacts';
5
6
  export { WEB_BOT_AUTH_DRAFT_REVISION, verifyWebBotAuth, signWebBotAuth, createWebBotAuthFetch, createSignedSignatureDirectory, SignatureDirectoryResolver, verifySignatureDirectory, verifyKeyDirectory, selectSignatureProfile, jwkThumbprint, WebBotAuthError, WebBotAuthUnavailableError, } from '../signing/web-bot-auth';
6
7
  export type { WebBotSigningKey, WebBotSigningOptions, VerifiedWebBotSigner, VerifyWebBotAuthOptions, VerifiedSignatureDirectory, SignatureDirectoryResolverOptions, } from '../signing/web-bot-auth';
7
8
  export { validateIdentity33Payload } from './validation';
@@ -45,6 +45,7 @@ __reExport(identity_3_exports, require('./types.js'), module.exports);
45
45
  __reExport(identity_3_exports, require('./trust.js'), module.exports);
46
46
  __reExport(identity_3_exports, require('./lifecycle.js'), module.exports);
47
47
  __reExport(identity_3_exports, require('./revocation.js'), module.exports);
48
+ __reExport(identity_3_exports, require('./jws-artifacts.js'), module.exports);
48
49
  var import_web_bot_auth = require('../signing/web-bot-auth.js');
49
50
  var import_validation = require('./validation.js');
50
51
  var import_server = require('./server.js');
@@ -75,5 +76,6 @@ var import_webhook_registration = require('../core/webhook-registration.js');
75
76
  ...require('./types.js'),
76
77
  ...require('./trust.js'),
77
78
  ...require('./lifecycle.js'),
78
- ...require('./revocation.js')
79
+ ...require('./revocation.js'),
80
+ ...require('./jws-artifacts.js')
79
81
  });
@@ -2,6 +2,7 @@ export * from "./types.mjs";
2
2
  export * from "./trust.mjs";
3
3
  export * from "./lifecycle.mjs";
4
4
  export * from "./revocation.mjs";
5
+ export * from "./jws-artifacts.mjs";
5
6
  import {
6
7
  WEB_BOT_AUTH_DRAFT_REVISION,
7
8
  verifyWebBotAuth,
@@ -0,0 +1,147 @@
1
+ import { type SsrfFetchOptions } from '../net/index.mjs';
2
+ import type { AdcpJsonWebKey } from '../signing/types.mjs';
3
+ import { type SignatureDirectoryResolver } from '../signing/web-bot-auth.mjs';
4
+ import type { OriginRevocationResolver, OriginRevocationStatus } from './revocation.mjs';
5
+ import type { TrustEvaluator } from './trust.mjs';
6
+ import type { RevocationDetail } from './types.mjs';
7
+ /** Which profile verifies a JWS artifact from origin `O`. */
8
+ export type JwsArtifactProfile = {
9
+ profile: 'web-bot-auth';
10
+ /** `O`, the canonical origin of the signing agent's URL. */
11
+ origin: string;
12
+ /** The registrable domain whose trust record lists `O`. */
13
+ operator: string;
14
+ } | {
15
+ profile: '3.2';
16
+ origin: string;
17
+ /**
18
+ * `no_trust_record`: `O` has no registrable domain (IP literal, public
19
+ * suffix, no PSL match), or its operator has not published a trust
20
+ * record (404/410 with no remembered 200). `unlisted`: the record does
21
+ * not list `O`.
22
+ */
23
+ reason: 'no_trust_record' | 'unlisted';
24
+ };
25
+ export type JwsArtifactErrorCode =
26
+ /** A trust record, key directory or archive could not be read. Retryable. */
27
+ 'jws_key_unavailable'
28
+ /** No key at `O` (directory, or archive for history) carries the `kid`. */
29
+ | 'jws_key_unknown'
30
+ /** Wrong `typ`, `alg` not `EdDSA`, `kid` not the key's thumbprint, or a signature that does not verify. */
31
+ | 'jws_invalid'
32
+ /** `O`'s revocation list revokes the `kid`. */
33
+ | 'jws_key_revoked'
34
+ /** `O`'s revocation status is unknown, or (by default) `O` serves no list. Retryable. */
35
+ | 'jws_revocation_unavailable';
36
+ export declare class JwsArtifactError extends Error {
37
+ readonly code: JwsArtifactErrorCode;
38
+ constructor(code: JwsArtifactErrorCode, message: string, options?: {
39
+ cause?: unknown;
40
+ });
41
+ /** True for outages: retry later, never treat as absence or as a verdict on the artifact. */
42
+ get transient(): boolean;
43
+ }
44
+ /** Components the WBA path reuses. */
45
+ export interface JwsArtifactWebBotAuthOptions {
46
+ /**
47
+ * Derives the trust record from `O` (R3a step 1) to select the profile.
48
+ * Configure durable `authorityHistory` on it for public, multi-replica or
49
+ * serverless verifiers: without it, the rule that a 404/410 after a 200 is an
50
+ * outage (never a return to 3.2) holds only within one process.
51
+ */
52
+ trust: TrustEvaluator;
53
+ /** `O`'s Web Bot Auth key directory. */
54
+ directory: SignatureDirectoryResolver;
55
+ /** `O`'s revocation list (R3). Required: the WBA path never skips revocation. */
56
+ revocation: OriginRevocationResolver;
57
+ }
58
+ /**
59
+ * Select the profile for a JWS artifact whose signing agent URL is
60
+ * `signingAgentUrl` (R4). Throws {@link JwsArtifactError}
61
+ * `jws_key_unavailable` when the trust record cannot be read: a fetch failure
62
+ * is never absence and never selects the 3.2 profile. An unparseable
63
+ * `signingAgentUrl` is a caller error (`TypeError` from canonicalization).
64
+ */
65
+ export declare function selectJwsArtifactProfile(signingAgentUrl: string, trust: TrustEvaluator): Promise<JwsArtifactProfile>;
66
+ export interface VerifyWebBotAuthJwsArtifactOptions {
67
+ /** The protected-header `typ` this surface accepts, e.g. `adcp-gov+jws`. Any other is refused. */
68
+ typ: string;
69
+ directory: SignatureDirectoryResolver;
70
+ /**
71
+ * `O`'s revocation list (R3). Pass `false` only when the caller checks the
72
+ * returned `kid` against `O`'s list itself.
73
+ */
74
+ revocation: OriginRevocationResolver | false;
75
+ /**
76
+ * `O`'s revocation status `absent` (the origin serves no list). `reject`
77
+ * (default) fails closed, as a WBA identity without a list cannot be bound
78
+ * for spend. `accept` treats it as nothing revoked.
79
+ */
80
+ revocationAbsent?: 'reject' | 'accept';
81
+ /**
82
+ * A key `O`'s list revokes. `reject` (default) refuses the artifact, as
83
+ * online verification must (R9: a revoked key is rejected whatever its
84
+ * detail). `report` verifies it and returns the revocation and its detail,
85
+ * for audit of retained artifacts.
86
+ */
87
+ revokedKey?: 'reject' | 'report';
88
+ /**
89
+ * Historical verification: also look the `kid` up in the governance key
90
+ * archive at `O` when the directory does not carry it or cannot be read.
91
+ * Governance contexts only; only governance agents publish an archive.
92
+ */
93
+ archive?: GovernanceKeyArchiveResolver;
94
+ /** Critical header parameters the surface understands (jose `crit`). */
95
+ crit?: Record<string, boolean>;
96
+ }
97
+ export interface VerifiedWebBotAuthJwsArtifact {
98
+ origin: string;
99
+ kid: string;
100
+ key: AdcpJsonWebKey;
101
+ /** Where the key came from: `O`'s key directory, or (history) its archive. */
102
+ keySource: 'directory' | 'archive';
103
+ protectedHeader: Record<string, unknown>;
104
+ payload: Uint8Array;
105
+ /** `O`'s revocation status for `kid`, when a resolver was supplied. Never `unknown`. */
106
+ revocation?: Exclude<OriginRevocationStatus, 'unknown'>;
107
+ /** The most severe revocation detail recorded for `kid` (R9), when it is revoked. */
108
+ revocationDetail?: RevocationDetail;
109
+ }
110
+ /**
111
+ * Verify a compact JWS with a key from `origin`'s WBA key directory (R4):
112
+ * `typ` as the surface requires, `alg` `EdDSA`, `kid` the key's JWK
113
+ * thumbprint, no `use`/`key_ops`/`adcp_use` checks, and revocation from
114
+ * `origin`'s list. Signature and key only: every other check of the surface
115
+ * (claims, audience, freshness, replay) stays with the surface. Throws
116
+ * {@link JwsArtifactError}.
117
+ */
118
+ export declare function verifyWebBotAuthJwsArtifact(token: string, origin: string, options: VerifyWebBotAuthJwsArtifactOptions): Promise<VerifiedWebBotAuthJwsArtifact>;
119
+ export declare const GOVERNANCE_KEY_ARCHIVE_PATH = "/.well-known/jwks-archive.json";
120
+ export interface GovernanceKeyArchiveResolverOptions {
121
+ now?: () => number;
122
+ fetchOptions?: Pick<SsrfFetchOptions, 'lookup' | 'trustedFetchFn'>;
123
+ /** Seconds an archive read stays cached. Default 300. */
124
+ maxAgeSeconds?: number;
125
+ /** Origins cached at once. Default 256. */
126
+ maxOrigins?: number;
127
+ /** Published fixture keys are read only outside production, as for the key directory. */
128
+ allowTestKeys?: boolean;
129
+ }
130
+ /**
131
+ * The governance key archive at an origin (`security.mdx` §Revocation):
132
+ * `{origin}/.well-known/jwks-archive.json`, a JWKS of retired governance keys
133
+ * kept discoverable for audit. On the WBA path only Ed25519 keys whose `kid`
134
+ * (when present) is their JWK thumbprint are read; other keys are ignored. A
135
+ * 404/410 is an origin with no archive. Any other failure is
136
+ * `jws_key_unavailable`, never absence, and is retried after a cooldown.
137
+ */
138
+ export declare class GovernanceKeyArchiveResolver {
139
+ private readonly options;
140
+ private readonly cache;
141
+ private readonly failures;
142
+ private readonly pending;
143
+ private readonly maxOrigins;
144
+ constructor(options?: GovernanceKeyArchiveResolverOptions);
145
+ resolve(origin: string, kid: string): Promise<AdcpJsonWebKey | null>;
146
+ private fetch;
147
+ }