@astrasyncai/verification-gateway 5.18.1 → 5.19.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 (113) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/README.md +168 -4
  3. package/dist/adapters/express.d.mts +9 -1
  4. package/dist/adapters/express.d.ts +9 -1
  5. package/dist/adapters/express.js +96 -37
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +96 -37
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/http-pdlss.d.mts +7 -1
  10. package/dist/adapters/http-pdlss.d.ts +7 -1
  11. package/dist/adapters/http-pdlss.js +18 -2
  12. package/dist/adapters/http-pdlss.js.map +1 -1
  13. package/dist/adapters/http-pdlss.mjs +16 -1
  14. package/dist/adapters/http-pdlss.mjs.map +1 -1
  15. package/dist/adapters/kit-express.d.mts +93 -1
  16. package/dist/adapters/kit-express.d.ts +93 -1
  17. package/dist/adapters/kit-express.js +181 -2
  18. package/dist/adapters/kit-express.js.map +1 -1
  19. package/dist/adapters/kit-express.mjs +180 -2
  20. package/dist/adapters/kit-express.mjs.map +1 -1
  21. package/dist/adapters/mcp.d.mts +80 -9
  22. package/dist/adapters/mcp.d.ts +80 -9
  23. package/dist/adapters/mcp.js +153 -5
  24. package/dist/adapters/mcp.js.map +1 -1
  25. package/dist/adapters/mcp.mjs +151 -5
  26. package/dist/adapters/mcp.mjs.map +1 -1
  27. package/dist/adapters/nextjs.d.mts +1 -1
  28. package/dist/adapters/nextjs.d.ts +1 -1
  29. package/dist/adapters/nextjs.js +41 -4
  30. package/dist/adapters/nextjs.js.map +1 -1
  31. package/dist/adapters/nextjs.mjs +41 -4
  32. package/dist/adapters/nextjs.mjs.map +1 -1
  33. package/dist/adapters/sdk.d.mts +44 -1
  34. package/dist/adapters/sdk.d.ts +44 -1
  35. package/dist/adapters/sdk.js +76 -2
  36. package/dist/adapters/sdk.js.map +1 -1
  37. package/dist/adapters/sdk.mjs +76 -2
  38. package/dist/adapters/sdk.mjs.map +1 -1
  39. package/dist/agent/index.js +1 -1
  40. package/dist/agent/index.js.map +1 -1
  41. package/dist/agent/index.mjs +1 -1
  42. package/dist/agent/index.mjs.map +1 -1
  43. package/dist/bin/astrasync-claude-hook.js +46 -6
  44. package/dist/bin/astrasync-codex-hook.js +46 -6
  45. package/dist/bin/astrasync-guard.js +46 -6
  46. package/dist/bin/astrasync.js +77 -5
  47. package/dist/browser/background.js +46 -6
  48. package/dist/browser/background.js.map +1 -1
  49. package/dist/browser/background.mjs +46 -6
  50. package/dist/browser/background.mjs.map +1 -1
  51. package/dist/cli/index.js +1 -1
  52. package/dist/cli/index.js.map +1 -1
  53. package/dist/cli/index.mjs +1 -1
  54. package/dist/cli/index.mjs.map +1 -1
  55. package/dist/codex/index.js +46 -6
  56. package/dist/codex/index.js.map +1 -1
  57. package/dist/codex/index.mjs +46 -6
  58. package/dist/codex/index.mjs.map +1 -1
  59. package/dist/cursor/extension.js +46 -6
  60. package/dist/cursor/extension.js.map +1 -1
  61. package/dist/cursor/extension.mjs +46 -6
  62. package/dist/cursor/extension.mjs.map +1 -1
  63. package/dist/edge-config.d.mts +1 -1
  64. package/dist/edge-config.d.ts +1 -1
  65. package/dist/edge-config.js +1 -1
  66. package/dist/edge-config.js.map +1 -1
  67. package/dist/edge-config.mjs +1 -1
  68. package/dist/edge-config.mjs.map +1 -1
  69. package/dist/edge-core/index.d.mts +1 -1
  70. package/dist/edge-core/index.d.ts +1 -1
  71. package/dist/edge-core/index.js +21 -2
  72. package/dist/edge-core/index.js.map +1 -1
  73. package/dist/edge-core/index.mjs +21 -2
  74. package/dist/edge-core/index.mjs.map +1 -1
  75. package/dist/gateway/gateway.js +46 -6
  76. package/dist/gateway/gateway.js.map +1 -1
  77. package/dist/gateway/gateway.mjs +46 -6
  78. package/dist/gateway/gateway.mjs.map +1 -1
  79. package/dist/git-trigger/git-hooks.d.mts +1 -1
  80. package/dist/git-trigger/git-hooks.d.ts +1 -1
  81. package/dist/index.d.mts +541 -29
  82. package/dist/index.d.ts +541 -29
  83. package/dist/index.js +1171 -183
  84. package/dist/index.js.map +1 -1
  85. package/dist/index.mjs +1157 -173
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/registration/index.js +1 -1
  88. package/dist/registration/index.js.map +1 -1
  89. package/dist/registration/index.mjs +1 -1
  90. package/dist/registration/index.mjs.map +1 -1
  91. package/dist/transport/index.js +3 -2
  92. package/dist/transport/index.js.map +1 -1
  93. package/dist/transport/index.mjs +3 -2
  94. package/dist/transport/index.mjs.map +1 -1
  95. package/dist/{types-3ObBpsnf.d.mts → types-BoGjyon0.d.mts} +81 -2
  96. package/dist/{types-Cns4l8gX.d.mts → types-DqWPkiYl.d.mts} +90 -12
  97. package/dist/{types-Cns4l8gX.d.ts → types-DqWPkiYl.d.ts} +90 -12
  98. package/dist/{types-BoxZEYPS.d.ts → types-eWyZuz-3.d.ts} +81 -2
  99. package/dist/ui/index.d.mts +1 -1
  100. package/dist/ui/index.d.ts +1 -1
  101. package/dist/verify.d.mts +23 -2
  102. package/dist/verify.d.ts +23 -2
  103. package/dist/verify.js +23 -4
  104. package/dist/verify.js.map +1 -1
  105. package/dist/verify.mjs +23 -4
  106. package/dist/verify.mjs.map +1 -1
  107. package/dist/webhooks.d.mts +16 -3
  108. package/dist/webhooks.d.ts +16 -3
  109. package/dist/webhooks.js +24 -13
  110. package/dist/webhooks.js.map +1 -1
  111. package/dist/webhooks.mjs +24 -13
  112. package/dist/webhooks.mjs.map +1 -1
  113. package/package.json +1 -1
@@ -3752,7 +3752,7 @@ function getTrustLevel(score) {
3752
3752
  }
3753
3753
 
3754
3754
  // src/version.ts
3755
- var SDK_VERSION = "5.18.1";
3755
+ var SDK_VERSION = "5.19.0";
3756
3756
 
3757
3757
  // src/http.ts
3758
3758
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -3907,7 +3907,12 @@ function getCacheKey(request, counterpartyId) {
3907
3907
  // its start_checkout quote was served the cached quote-leg grant (no
3908
3908
  // settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
3909
3909
  request.commercePhase || "",
3910
- request.checkoutSessionId || ""
3910
+ request.checkoutSessionId || "",
3911
+ // 5.19.0: a route_config purpose claim is checked server-side against
3912
+ // the stored rule for this method + path, so it changes the verdict.
3913
+ request.purposeSource || "",
3914
+ request.requestMethod || "",
3915
+ request.requestPath || ""
3911
3916
  ].join("|");
3912
3917
  }
3913
3918
  function getCachedResult(request, counterpartyId) {
@@ -4081,6 +4086,11 @@ async function callVerifyAccessAPI(config, request) {
4081
4086
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
4082
4087
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4083
4088
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
4089
+ if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
4090
+ if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
4091
+ if (requestData.metadata) body.metadata = requestData.metadata;
4092
+ if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
4093
+ if (requestData.requestPath) body.requestPath = requestData.requestPath;
4084
4094
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4085
4095
  body.sdkVersion = SDK_VERSION;
4086
4096
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -4270,9 +4280,18 @@ async function verify(config, request, options) {
4270
4280
  if (!apiResponse.access?.allowed) {
4271
4281
  const aggregatedFailures = apiResponse.access?.failures;
4272
4282
  const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
4283
+ const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
4284
+ astraId: apiResponse.agent.astraId,
4285
+ name: apiResponse.agent.name,
4286
+ trustScore: apiResponse.agent.trustScore,
4287
+ trustLevel: getTrustLevel(apiResponse.agent.trustScore),
4288
+ blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
4289
+ status: apiResponse.agent.agentStatus
4290
+ } : void 0;
4273
4291
  const result2 = {
4274
4292
  identityVerified: idVerifiedFromBackend,
4275
4293
  policyAllowed: false,
4294
+ ...denyAgent && { agent: denyAgent },
4276
4295
  // 3.6.0: the server now emits top-level denialReasons on every deny
4277
4296
  // path — prefer it verbatim; the failure-message reconstruction remains
4278
4297
  // as the fallback for older backends.
@@ -4418,6 +4437,9 @@ var MAX_TOTAL_BYTES = 16 * 1024;
4418
4437
  // src/adapters/commerce-detect.ts
4419
4438
  var MAX_BODY_BYTES = 64 * 1024;
4420
4439
 
4440
+ // src/adapters/routes-cache.ts
4441
+ var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
4442
+
4421
4443
  // src/edge-config.ts
4422
4444
  var DEFAULT_EDGE_CONFIG = Object.freeze({
4423
4445
  version: 1,
@@ -4659,9 +4681,6 @@ var BeaconBuffer = class {
4659
4681
  };
4660
4682
  var beaconBuffer = new BeaconBuffer();
4661
4683
 
4662
- // src/adapters/express.ts
4663
- var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
4664
-
4665
4684
  // src/adapters/nextjs.ts
4666
4685
  var DEFAULT_ROUTES_REFRESH_MS2 = 5 * 60 * 1e3;
4667
4686
 
@@ -4747,6 +4766,25 @@ var import_jose2 = require("jose");
4747
4766
  // src/idempotency/index.ts
4748
4767
  var DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1e3;
4749
4768
 
4769
+ // src/ucp/approval-events.ts
4770
+ var MemorySeenEvents = class {
4771
+ constructor(max = 1e4) {
4772
+ this.max = max;
4773
+ this.ids = /* @__PURE__ */ new Set();
4774
+ }
4775
+ async has(eventId) {
4776
+ return this.ids.has(eventId);
4777
+ }
4778
+ async add(eventId) {
4779
+ if (this.ids.size >= this.max) {
4780
+ const first = this.ids.values().next().value;
4781
+ if (first !== void 0) this.ids.delete(first);
4782
+ }
4783
+ this.ids.add(eventId);
4784
+ }
4785
+ };
4786
+ var defaultSeen = new MemorySeenEvents();
4787
+
4750
4788
  // src/payments/kyapay.ts
4751
4789
  var import_jose4 = require("jose");
4752
4790
 
@@ -4786,7 +4824,9 @@ function toDecision(result) {
4786
4824
  if (result.identityVerified && result.policyAllowed) {
4787
4825
  return {
4788
4826
  recommendation: "ALLOW",
4789
- reason: result.agent?.trustScore ? `Verified (trust score ${result.agent.trustScore})` : "Verified",
4827
+ // 5.19.0: the score is on `trustScore` for the merchant; `reason` is
4828
+ // text a merchant may relay to the agent, so it never embeds the number.
4829
+ reason: "Verified",
4790
4830
  trustScore: result.agent?.trustScore,
4791
4831
  sessionId: "sessionId" in result ? result.sessionId : void 0
4792
4832
  };
@@ -3751,7 +3751,7 @@ function getTrustLevel(score) {
3751
3751
  }
3752
3752
 
3753
3753
  // src/version.ts
3754
- var SDK_VERSION = "5.18.1";
3754
+ var SDK_VERSION = "5.19.0";
3755
3755
 
3756
3756
  // src/http.ts
3757
3757
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -3906,7 +3906,12 @@ function getCacheKey(request, counterpartyId) {
3906
3906
  // its start_checkout quote was served the cached quote-leg grant (no
3907
3907
  // settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
3908
3908
  request.commercePhase || "",
3909
- request.checkoutSessionId || ""
3909
+ request.checkoutSessionId || "",
3910
+ // 5.19.0: a route_config purpose claim is checked server-side against
3911
+ // the stored rule for this method + path, so it changes the verdict.
3912
+ request.purposeSource || "",
3913
+ request.requestMethod || "",
3914
+ request.requestPath || ""
3910
3915
  ].join("|");
3911
3916
  }
3912
3917
  function getCachedResult(request, counterpartyId) {
@@ -4080,6 +4085,11 @@ async function callVerifyAccessAPI(config, request) {
4080
4085
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
4081
4086
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4082
4087
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
4088
+ if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
4089
+ if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
4090
+ if (requestData.metadata) body.metadata = requestData.metadata;
4091
+ if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
4092
+ if (requestData.requestPath) body.requestPath = requestData.requestPath;
4083
4093
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4084
4094
  body.sdkVersion = SDK_VERSION;
4085
4095
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -4269,9 +4279,18 @@ async function verify(config, request, options) {
4269
4279
  if (!apiResponse.access?.allowed) {
4270
4280
  const aggregatedFailures = apiResponse.access?.failures;
4271
4281
  const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
4282
+ const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
4283
+ astraId: apiResponse.agent.astraId,
4284
+ name: apiResponse.agent.name,
4285
+ trustScore: apiResponse.agent.trustScore,
4286
+ trustLevel: getTrustLevel(apiResponse.agent.trustScore),
4287
+ blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
4288
+ status: apiResponse.agent.agentStatus
4289
+ } : void 0;
4272
4290
  const result2 = {
4273
4291
  identityVerified: idVerifiedFromBackend,
4274
4292
  policyAllowed: false,
4293
+ ...denyAgent && { agent: denyAgent },
4275
4294
  // 3.6.0: the server now emits top-level denialReasons on every deny
4276
4295
  // path — prefer it verbatim; the failure-message reconstruction remains
4277
4296
  // as the fallback for older backends.
@@ -4417,6 +4436,9 @@ var MAX_TOTAL_BYTES = 16 * 1024;
4417
4436
  // src/adapters/commerce-detect.ts
4418
4437
  var MAX_BODY_BYTES = 64 * 1024;
4419
4438
 
4439
+ // src/adapters/routes-cache.ts
4440
+ var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
4441
+
4420
4442
  // src/edge-config.ts
4421
4443
  var DEFAULT_EDGE_CONFIG = Object.freeze({
4422
4444
  version: 1,
@@ -4658,9 +4680,6 @@ var BeaconBuffer = class {
4658
4680
  };
4659
4681
  var beaconBuffer = new BeaconBuffer();
4660
4682
 
4661
- // src/adapters/express.ts
4662
- var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
4663
-
4664
4683
  // src/adapters/nextjs.ts
4665
4684
  var DEFAULT_ROUTES_REFRESH_MS2 = 5 * 60 * 1e3;
4666
4685
 
@@ -4746,6 +4765,25 @@ var import_jose2 = require("jose");
4746
4765
  // src/idempotency/index.ts
4747
4766
  var DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1e3;
4748
4767
 
4768
+ // src/ucp/approval-events.ts
4769
+ var MemorySeenEvents = class {
4770
+ constructor(max = 1e4) {
4771
+ this.max = max;
4772
+ this.ids = /* @__PURE__ */ new Set();
4773
+ }
4774
+ async has(eventId) {
4775
+ return this.ids.has(eventId);
4776
+ }
4777
+ async add(eventId) {
4778
+ if (this.ids.size >= this.max) {
4779
+ const first = this.ids.values().next().value;
4780
+ if (first !== void 0) this.ids.delete(first);
4781
+ }
4782
+ this.ids.add(eventId);
4783
+ }
4784
+ };
4785
+ var defaultSeen = new MemorySeenEvents();
4786
+
4749
4787
  // src/payments/kyapay.ts
4750
4788
  var import_jose4 = require("jose");
4751
4789
 
@@ -4785,7 +4823,9 @@ function toDecision(result) {
4785
4823
  if (result.identityVerified && result.policyAllowed) {
4786
4824
  return {
4787
4825
  recommendation: "ALLOW",
4788
- reason: result.agent?.trustScore ? `Verified (trust score ${result.agent.trustScore})` : "Verified",
4826
+ // 5.19.0: the score is on `trustScore` for the merchant; `reason` is
4827
+ // text a merchant may relay to the agent, so it never embeds the number.
4828
+ reason: "Verified",
4789
4829
  trustScore: result.agent?.trustScore,
4790
4830
  sessionId: "sessionId" in result ? result.sessionId : void 0
4791
4831
  };
@@ -3713,7 +3713,7 @@ Policy saved to ${outputPath}`);
3713
3713
  };
3714
3714
 
3715
3715
  // src/version.ts
3716
- var SDK_VERSION = "5.18.1";
3716
+ var SDK_VERSION = "5.19.0";
3717
3717
 
3718
3718
  // src/http.ts
3719
3719
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4772,7 +4772,12 @@ function getCacheKey(request2, counterpartyId) {
4772
4772
  // its start_checkout quote was served the cached quote-leg grant (no
4773
4773
  // settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
4774
4774
  request2.commercePhase || "",
4775
- request2.checkoutSessionId || ""
4775
+ request2.checkoutSessionId || "",
4776
+ // 5.19.0: a route_config purpose claim is checked server-side against
4777
+ // the stored rule for this method + path, so it changes the verdict.
4778
+ request2.purposeSource || "",
4779
+ request2.requestMethod || "",
4780
+ request2.requestPath || ""
4776
4781
  ].join("|");
4777
4782
  }
4778
4783
  function getCachedResult(request2, counterpartyId) {
@@ -4946,6 +4951,11 @@ async function callVerifyAccessAPI(config, request2) {
4946
4951
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
4947
4952
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4948
4953
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
4954
+ if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
4955
+ if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
4956
+ if (requestData.metadata) body.metadata = requestData.metadata;
4957
+ if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
4958
+ if (requestData.requestPath) body.requestPath = requestData.requestPath;
4949
4959
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4950
4960
  body.sdkVersion = SDK_VERSION;
4951
4961
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -5135,9 +5145,18 @@ async function verify(config, request2, options) {
5135
5145
  if (!apiResponse.access?.allowed) {
5136
5146
  const aggregatedFailures = apiResponse.access?.failures;
5137
5147
  const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
5148
+ const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
5149
+ astraId: apiResponse.agent.astraId,
5150
+ name: apiResponse.agent.name,
5151
+ trustScore: apiResponse.agent.trustScore,
5152
+ trustLevel: getTrustLevel(apiResponse.agent.trustScore),
5153
+ blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
5154
+ status: apiResponse.agent.agentStatus
5155
+ } : void 0;
5138
5156
  const result2 = {
5139
5157
  identityVerified: idVerifiedFromBackend,
5140
5158
  policyAllowed: false,
5159
+ ...denyAgent && { agent: denyAgent },
5141
5160
  // 3.6.0: the server now emits top-level denialReasons on every deny
5142
5161
  // path — prefer it verbatim; the failure-message reconstruction remains
5143
5162
  // as the fallback for older backends.
@@ -5283,6 +5302,9 @@ var MAX_TOTAL_BYTES = 16 * 1024;
5283
5302
  // src/adapters/commerce-detect.ts
5284
5303
  var MAX_BODY_BYTES = 64 * 1024;
5285
5304
 
5305
+ // src/adapters/routes-cache.ts
5306
+ var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
5307
+
5286
5308
  // src/edge-config.ts
5287
5309
  var DEFAULT_EDGE_CONFIG = Object.freeze({
5288
5310
  version: 1,
@@ -5524,9 +5546,6 @@ var BeaconBuffer = class {
5524
5546
  };
5525
5547
  var beaconBuffer = new BeaconBuffer();
5526
5548
 
5527
- // src/adapters/express.ts
5528
- var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
5529
-
5530
5549
  // src/adapters/nextjs.ts
5531
5550
  var DEFAULT_ROUTES_REFRESH_MS2 = 5 * 60 * 1e3;
5532
5551
 
@@ -5612,6 +5631,25 @@ var import_jose2 = require("jose");
5612
5631
  // src/idempotency/index.ts
5613
5632
  var DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1e3;
5614
5633
 
5634
+ // src/ucp/approval-events.ts
5635
+ var MemorySeenEvents = class {
5636
+ constructor(max = 1e4) {
5637
+ this.max = max;
5638
+ this.ids = /* @__PURE__ */ new Set();
5639
+ }
5640
+ async has(eventId) {
5641
+ return this.ids.has(eventId);
5642
+ }
5643
+ async add(eventId) {
5644
+ if (this.ids.size >= this.max) {
5645
+ const first = this.ids.values().next().value;
5646
+ if (first !== void 0) this.ids.delete(first);
5647
+ }
5648
+ this.ids.add(eventId);
5649
+ }
5650
+ };
5651
+ var defaultSeen = new MemorySeenEvents();
5652
+
5615
5653
  // src/payments/kyapay.ts
5616
5654
  var import_jose4 = require("jose");
5617
5655
 
@@ -5651,7 +5689,9 @@ function toDecision(result) {
5651
5689
  if (result.identityVerified && result.policyAllowed) {
5652
5690
  return {
5653
5691
  recommendation: "ALLOW",
5654
- reason: result.agent?.trustScore ? `Verified (trust score ${result.agent.trustScore})` : "Verified",
5692
+ // 5.19.0: the score is on `trustScore` for the merchant; `reason` is
5693
+ // text a merchant may relay to the agent, so it never embeds the number.
5694
+ reason: "Verified",
5655
5695
  trustScore: result.agent?.trustScore,
5656
5696
  sessionId: "sessionId" in result ? result.sessionId : void 0
5657
5697
  };
@@ -36,7 +36,7 @@ var SDK_VERSION;
36
36
  var init_version = __esm({
37
37
  "src/version.ts"() {
38
38
  "use strict";
39
- SDK_VERSION = "5.18.1";
39
+ SDK_VERSION = "5.19.0";
40
40
  }
41
41
  });
42
42
 
@@ -5186,7 +5186,12 @@ function getCacheKey(request2, counterpartyId) {
5186
5186
  // its start_checkout quote was served the cached quote-leg grant (no
5187
5187
  // settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
5188
5188
  request2.commercePhase || "",
5189
- request2.checkoutSessionId || ""
5189
+ request2.checkoutSessionId || "",
5190
+ // 5.19.0: a route_config purpose claim is checked server-side against
5191
+ // the stored rule for this method + path, so it changes the verdict.
5192
+ request2.purposeSource || "",
5193
+ request2.requestMethod || "",
5194
+ request2.requestPath || ""
5190
5195
  ].join("|");
5191
5196
  }
5192
5197
  function getCachedResult(request2, counterpartyId) {
@@ -5358,6 +5363,11 @@ async function callVerifyAccessAPI(config, request2) {
5358
5363
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
5359
5364
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
5360
5365
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
5366
+ if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
5367
+ if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
5368
+ if (requestData.metadata) body.metadata = requestData.metadata;
5369
+ if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
5370
+ if (requestData.requestPath) body.requestPath = requestData.requestPath;
5361
5371
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
5362
5372
  body.sdkVersion = SDK_VERSION;
5363
5373
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -5547,9 +5557,18 @@ async function verify(config, request2, options) {
5547
5557
  if (!apiResponse.access?.allowed) {
5548
5558
  const aggregatedFailures = apiResponse.access?.failures;
5549
5559
  const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
5560
+ const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
5561
+ astraId: apiResponse.agent.astraId,
5562
+ name: apiResponse.agent.name,
5563
+ trustScore: apiResponse.agent.trustScore,
5564
+ trustLevel: getTrustLevel(apiResponse.agent.trustScore),
5565
+ blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
5566
+ status: apiResponse.agent.agentStatus
5567
+ } : void 0;
5550
5568
  const result2 = {
5551
5569
  identityVerified: idVerifiedFromBackend,
5552
5570
  policyAllowed: false,
5571
+ ...denyAgent && { agent: denyAgent },
5553
5572
  // 3.6.0: the server now emits top-level denialReasons on every deny
5554
5573
  // path — prefer it verbatim; the failure-message reconstruction remains
5555
5574
  // as the fallback for older backends.
@@ -5772,6 +5791,16 @@ var init_commerce_detect = __esm({
5772
5791
  }
5773
5792
  });
5774
5793
 
5794
+ // src/adapters/routes-cache.ts
5795
+ var DEFAULT_ROUTES_REFRESH_MS;
5796
+ var init_routes_cache = __esm({
5797
+ "src/adapters/routes-cache.ts"() {
5798
+ "use strict";
5799
+ init_verify();
5800
+ DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
5801
+ }
5802
+ });
5803
+
5775
5804
  // src/transport/http.ts
5776
5805
  var init_http2 = __esm({
5777
5806
  "src/transport/http.ts"() {
@@ -6101,7 +6130,6 @@ var init_anonymous_beacon = __esm({
6101
6130
  });
6102
6131
 
6103
6132
  // src/adapters/express.ts
6104
- var DEFAULT_ROUTES_REFRESH_MS;
6105
6133
  var init_express = __esm({
6106
6134
  "src/adapters/express.ts"() {
6107
6135
  "use strict";
@@ -6109,6 +6137,7 @@ var init_express = __esm({
6109
6137
  init_types2();
6110
6138
  init_stepup_poll();
6111
6139
  init_verify();
6140
+ init_routes_cache();
6112
6141
  init_http2();
6113
6142
  init_verified_hop();
6114
6143
  init_http_pdlss();
@@ -6119,7 +6148,6 @@ var init_express = __esm({
6119
6148
  init_anonymous_beacon();
6120
6149
  init_failure_posture();
6121
6150
  init_route_pattern();
6122
- DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
6123
6151
  }
6124
6152
  });
6125
6153
 
@@ -6460,6 +6488,7 @@ var init_mcp2 = __esm({
6460
6488
  init_approval_gate();
6461
6489
  init_stepup_poll();
6462
6490
  init_well_known();
6491
+ init_routes_cache();
6463
6492
  init_failure_posture();
6464
6493
  init_mcp_server();
6465
6494
  }
@@ -6648,6 +6677,7 @@ var init_report_amount = __esm({
6648
6677
  var init_kit_shared = __esm({
6649
6678
  "src/ucp/kit-shared.ts"() {
6650
6679
  "use strict";
6680
+ init_sign();
6651
6681
  }
6652
6682
  });
6653
6683
 
@@ -6667,6 +6697,41 @@ var init_checkout_kit = __esm({
6667
6697
  init_signatures();
6668
6698
  init_report_amount();
6669
6699
  init_kit_shared();
6700
+ init_errors();
6701
+ init_stepup_poll();
6702
+ }
6703
+ });
6704
+
6705
+ // src/webhooks.ts
6706
+ var init_webhooks = __esm({
6707
+ "src/webhooks.ts"() {
6708
+ "use strict";
6709
+ }
6710
+ });
6711
+
6712
+ // src/ucp/approval-events.ts
6713
+ var MemorySeenEvents, defaultSeen;
6714
+ var init_approval_events = __esm({
6715
+ "src/ucp/approval-events.ts"() {
6716
+ "use strict";
6717
+ init_webhooks();
6718
+ MemorySeenEvents = class {
6719
+ constructor(max = 1e4) {
6720
+ this.max = max;
6721
+ this.ids = /* @__PURE__ */ new Set();
6722
+ }
6723
+ async has(eventId) {
6724
+ return this.ids.has(eventId);
6725
+ }
6726
+ async add(eventId) {
6727
+ if (this.ids.size >= this.max) {
6728
+ const first = this.ids.values().next().value;
6729
+ if (first !== void 0) this.ids.delete(first);
6730
+ }
6731
+ this.ids.add(eventId);
6732
+ }
6733
+ };
6734
+ defaultSeen = new MemorySeenEvents();
6670
6735
  }
6671
6736
  });
6672
6737
 
@@ -6681,6 +6746,7 @@ var init_ucp2 = __esm({
6681
6746
  init_signatures();
6682
6747
  init_checkout_kit();
6683
6748
  init_jcs();
6749
+ init_approval_events();
6684
6750
  }
6685
6751
  });
6686
6752
 
@@ -6742,6 +6808,8 @@ var init_checkout_kit2 = __esm({
6742
6808
  init_idempotency();
6743
6809
  init_report_amount();
6744
6810
  init_kit_shared();
6811
+ init_errors();
6812
+ init_stepup_poll();
6745
6813
  }
6746
6814
  });
6747
6815
 
@@ -6750,6 +6818,7 @@ var init_acp2 = __esm({
6750
6818
  "src/acp/index.ts"() {
6751
6819
  "use strict";
6752
6820
  init_checkout_kit2();
6821
+ init_approval_events();
6753
6822
  }
6754
6823
  });
6755
6824
 
@@ -6758,6 +6827,7 @@ var init_kit_express = __esm({
6758
6827
  "src/adapters/kit-express.ts"() {
6759
6828
  "use strict";
6760
6829
  init_kit_shared();
6830
+ init_approval_events();
6761
6831
  }
6762
6832
  });
6763
6833
 
@@ -6846,7 +6916,9 @@ function toDecision(result) {
6846
6916
  if (result.identityVerified && result.policyAllowed) {
6847
6917
  return {
6848
6918
  recommendation: "ALLOW",
6849
- reason: result.agent?.trustScore ? `Verified (trust score ${result.agent.trustScore})` : "Verified",
6919
+ // 5.19.0: the score is on `trustScore` for the merchant; `reason` is
6920
+ // text a merchant may relay to the agent, so it never embeds the number.
6921
+ reason: "Verified",
6850
6922
  trustScore: result.agent?.trustScore,
6851
6923
  sessionId: "sessionId" in result ? result.sessionId : void 0
6852
6924
  };
@@ -3988,7 +3988,7 @@ function getTrustLevel(score) {
3988
3988
  }
3989
3989
 
3990
3990
  // src/version.ts
3991
- var SDK_VERSION = "5.18.1";
3991
+ var SDK_VERSION = "5.19.0";
3992
3992
 
3993
3993
  // src/http.ts
3994
3994
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4143,7 +4143,12 @@ function getCacheKey(request, counterpartyId) {
4143
4143
  // its start_checkout quote was served the cached quote-leg grant (no
4144
4144
  // settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
4145
4145
  request.commercePhase || "",
4146
- request.checkoutSessionId || ""
4146
+ request.checkoutSessionId || "",
4147
+ // 5.19.0: a route_config purpose claim is checked server-side against
4148
+ // the stored rule for this method + path, so it changes the verdict.
4149
+ request.purposeSource || "",
4150
+ request.requestMethod || "",
4151
+ request.requestPath || ""
4147
4152
  ].join("|");
4148
4153
  }
4149
4154
  function getCachedResult(request, counterpartyId) {
@@ -4317,6 +4322,11 @@ async function callVerifyAccessAPI(config, request) {
4317
4322
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
4318
4323
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4319
4324
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
4325
+ if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
4326
+ if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
4327
+ if (requestData.metadata) body.metadata = requestData.metadata;
4328
+ if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
4329
+ if (requestData.requestPath) body.requestPath = requestData.requestPath;
4320
4330
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4321
4331
  body.sdkVersion = SDK_VERSION;
4322
4332
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -4506,9 +4516,18 @@ async function verify(config, request, options) {
4506
4516
  if (!apiResponse.access?.allowed) {
4507
4517
  const aggregatedFailures = apiResponse.access?.failures;
4508
4518
  const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
4519
+ const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
4520
+ astraId: apiResponse.agent.astraId,
4521
+ name: apiResponse.agent.name,
4522
+ trustScore: apiResponse.agent.trustScore,
4523
+ trustLevel: getTrustLevel(apiResponse.agent.trustScore),
4524
+ blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
4525
+ status: apiResponse.agent.agentStatus
4526
+ } : void 0;
4509
4527
  const result2 = {
4510
4528
  identityVerified: idVerifiedFromBackend,
4511
4529
  policyAllowed: false,
4530
+ ...denyAgent && { agent: denyAgent },
4512
4531
  // 3.6.0: the server now emits top-level denialReasons on every deny
4513
4532
  // path — prefer it verbatim; the failure-message reconstruction remains
4514
4533
  // as the fallback for older backends.
@@ -4654,6 +4673,9 @@ var MAX_TOTAL_BYTES = 16 * 1024;
4654
4673
  // src/adapters/commerce-detect.ts
4655
4674
  var MAX_BODY_BYTES = 64 * 1024;
4656
4675
 
4676
+ // src/adapters/routes-cache.ts
4677
+ var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
4678
+
4657
4679
  // src/edge-config.ts
4658
4680
  var DEFAULT_EDGE_CONFIG = Object.freeze({
4659
4681
  version: 1,
@@ -4895,9 +4917,6 @@ var BeaconBuffer = class {
4895
4917
  };
4896
4918
  var beaconBuffer = new BeaconBuffer();
4897
4919
 
4898
- // src/adapters/express.ts
4899
- var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
4900
-
4901
4920
  // src/adapters/nextjs.ts
4902
4921
  var DEFAULT_ROUTES_REFRESH_MS2 = 5 * 60 * 1e3;
4903
4922
 
@@ -4983,6 +5002,25 @@ var import_jose2 = require("jose");
4983
5002
  // src/idempotency/index.ts
4984
5003
  var DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1e3;
4985
5004
 
5005
+ // src/ucp/approval-events.ts
5006
+ var MemorySeenEvents = class {
5007
+ constructor(max = 1e4) {
5008
+ this.max = max;
5009
+ this.ids = /* @__PURE__ */ new Set();
5010
+ }
5011
+ async has(eventId) {
5012
+ return this.ids.has(eventId);
5013
+ }
5014
+ async add(eventId) {
5015
+ if (this.ids.size >= this.max) {
5016
+ const first = this.ids.values().next().value;
5017
+ if (first !== void 0) this.ids.delete(first);
5018
+ }
5019
+ this.ids.add(eventId);
5020
+ }
5021
+ };
5022
+ var defaultSeen = new MemorySeenEvents();
5023
+
4986
5024
  // src/payments/kyapay.ts
4987
5025
  var import_jose4 = require("jose");
4988
5026
 
@@ -5022,7 +5060,9 @@ function toDecision(result) {
5022
5060
  if (result.identityVerified && result.policyAllowed) {
5023
5061
  return {
5024
5062
  recommendation: "ALLOW",
5025
- reason: result.agent?.trustScore ? `Verified (trust score ${result.agent.trustScore})` : "Verified",
5063
+ // 5.19.0: the score is on `trustScore` for the merchant; `reason` is
5064
+ // text a merchant may relay to the agent, so it never embeds the number.
5065
+ reason: "Verified",
5026
5066
  trustScore: result.agent?.trustScore,
5027
5067
  sessionId: "sessionId" in result ? result.sessionId : void 0
5028
5068
  };