@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
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = "5.18.1";
2
+ var SDK_VERSION = "5.19.0";
3
3
 
4
4
  // src/http.ts
5
5
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -177,7 +177,12 @@ function getCacheKey(request, counterpartyId) {
177
177
  // its start_checkout quote was served the cached quote-leg grant (no
178
178
  // settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
179
179
  request.commercePhase || "",
180
- request.checkoutSessionId || ""
180
+ request.checkoutSessionId || "",
181
+ // 5.19.0: a route_config purpose claim is checked server-side against
182
+ // the stored rule for this method + path, so it changes the verdict.
183
+ request.purposeSource || "",
184
+ request.requestMethod || "",
185
+ request.requestPath || ""
181
186
  ].join("|");
182
187
  }
183
188
  function getCachedResult(request, counterpartyId) {
@@ -354,6 +359,11 @@ async function callVerifyAccessAPI(config, request) {
354
359
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
355
360
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
356
361
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
362
+ if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
363
+ if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
364
+ if (requestData.metadata) body.metadata = requestData.metadata;
365
+ if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
366
+ if (requestData.requestPath) body.requestPath = requestData.requestPath;
357
367
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
358
368
  body.sdkVersion = SDK_VERSION;
359
369
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -543,9 +553,18 @@ async function verify(config, request, options) {
543
553
  if (!apiResponse.access?.allowed) {
544
554
  const aggregatedFailures = apiResponse.access?.failures;
545
555
  const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
556
+ const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
557
+ astraId: apiResponse.agent.astraId,
558
+ name: apiResponse.agent.name,
559
+ trustScore: apiResponse.agent.trustScore,
560
+ trustLevel: getTrustLevel(apiResponse.agent.trustScore),
561
+ blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
562
+ status: apiResponse.agent.agentStatus
563
+ } : void 0;
546
564
  const result2 = {
547
565
  identityVerified: idVerifiedFromBackend,
548
566
  policyAllowed: false,
567
+ ...denyAgent && { agent: denyAgent },
549
568
  // 3.6.0: the server now emits top-level denialReasons on every deny
550
569
  // path — prefer it verbatim; the failure-message reconstruction remains
551
570
  // as the fallback for older backends.
@@ -716,6 +735,7 @@ var SettlementReportError = class extends AstraSyncError {
716
735
  };
717
736
 
718
737
  // src/adapters/sdk.ts
738
+ var warnedPhaselessValue = false;
719
739
  var VerificationGatewayClient = class {
720
740
  constructor(options) {
721
741
  this.config = {
@@ -747,9 +767,16 @@ var VerificationGatewayClient = class {
747
767
  apiKey: options.apiKey,
748
768
  jwt: options.jwt
749
769
  };
770
+ if (options.transactionValue && !options.commercePhase && !warnedPhaselessValue) {
771
+ warnedPhaselessValue = true;
772
+ console.warn(
773
+ "[astrasync] verify() with a transactionValue and no commercePhase is a purchase leg: it records a pending order and redeems a matching owner approval. Use quoteCheckout() for a price / limit check (commercePhase 'quote') and confirmCheckout() for the purchase. The default becomes 'quote' in 6.0."
774
+ );
775
+ }
750
776
  return this.executeWithRetry(
751
777
  () => verify(this.config, {
752
778
  credentials,
779
+ ...options.commercePhase && { commercePhase: options.commercePhase },
753
780
  purpose: options.purpose,
754
781
  action: options.action,
755
782
  resourceType: options.resourceType,
@@ -765,6 +792,43 @@ var VerificationGatewayClient = class {
765
792
  })
766
793
  );
767
794
  }
795
+ /**
796
+ * 5.19.0: the QUOTE leg of a checkout — a price / limit check before the
797
+ * purchase. Sends `commercePhase: 'quote'`: verify-access evaluates the
798
+ * agent's policy at this value and tells you whether a purchase would be
799
+ * granted, held for the owner's approval, or denied, but records no order,
800
+ * moves no money and never redeems an approval. Always reaches the backend
801
+ * (no verdict cache).
802
+ *
803
+ * Quotes count toward limit-probing detection: a run of rising quotes is
804
+ * how an agent (or a merchant) maps a spending limit. Quote what the buyer
805
+ * asked for, not a ladder of values.
806
+ */
807
+ async quoteCheckout(options) {
808
+ const credentials = {
809
+ astraId: options.astraId,
810
+ apiKey: options.apiKey,
811
+ jwt: options.jwt
812
+ };
813
+ return this.executeWithRetry(
814
+ () => verify(
815
+ this.config,
816
+ {
817
+ credentials,
818
+ purpose: options.purpose ?? "shopping",
819
+ action: options.action ?? "shopping.purchase",
820
+ transactionValue: options.transactionValue,
821
+ currency: options.currency,
822
+ commercePhase: "quote",
823
+ ...options.checkoutSessionId && { checkoutSessionId: options.checkoutSessionId },
824
+ ...options.attemptId && { attemptId: options.attemptId },
825
+ counterpartyUrl: options.counterpartyUrl,
826
+ counterpartyType: options.counterpartyType
827
+ },
828
+ { bypassCache: true }
829
+ )
830
+ );
831
+ }
768
832
  /**
769
833
  * 5.4.0 (astra-pay): confirm-leg of a checkout — the ONLY call that may fire
770
834
  * first-party charge-at-redeem (server-side settlement on the owner's saved
@@ -803,6 +867,14 @@ var VerificationGatewayClient = class {
803
867
  * is matched to — and only to — this confirm. A held cart's approval is
804
868
  * bound to its checkout session and exact value; a confirm for any other
805
869
  * cart is held for its own approval.
870
+ *
871
+ * 5.19.0 checkout kits: pass the kit's `agentArtifacts` (the inbound agent
872
+ * request — signed RFC 9421 headers with the public URL and raw-body
873
+ * digest, or `{ unsigned: true }`) and `metadata` (`{ kitSessionId,
874
+ * protocol }`) from the `verifyPurchase` context. The platform attributes
875
+ * the confirm to the agent from the artifacts, and stores the metadata on
876
+ * any approval this confirm creates so the approval event
877
+ * (`handleApprovalEvents`) can find the kit session.
806
878
  */
807
879
  async confirmCheckout(options) {
808
880
  const credentials = {
@@ -825,6 +897,8 @@ var VerificationGatewayClient = class {
825
897
  ...options.checkoutJwt && { checkoutJwt: options.checkoutJwt },
826
898
  ...options.attemptId && { attemptId: options.attemptId },
827
899
  buyerEmail: options.buyerEmail,
900
+ ...options.agentArtifacts && { agentArtifacts: options.agentArtifacts },
901
+ ...options.metadata && { metadata: options.metadata },
828
902
  counterpartyUrl: options.counterpartyUrl,
829
903
  counterpartyType: options.counterpartyType
830
904
  },