@astrasyncai/verification-gateway 5.18.0 → 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 (115) hide show
  1. package/CHANGELOG.md +178 -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 +375 -117
  46. package/dist/bin/astrasync.js +417 -117
  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 +542 -30
  82. package/dist/index.d.ts +542 -30
  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.d.mts +1 -1
  88. package/dist/registration/index.d.ts +1 -1
  89. package/dist/registration/index.js +1 -1
  90. package/dist/registration/index.js.map +1 -1
  91. package/dist/registration/index.mjs +1 -1
  92. package/dist/registration/index.mjs.map +1 -1
  93. package/dist/transport/index.js +3 -2
  94. package/dist/transport/index.js.map +1 -1
  95. package/dist/transport/index.mjs +3 -2
  96. package/dist/transport/index.mjs.map +1 -1
  97. package/dist/{types-3ObBpsnf.d.mts → types-BoGjyon0.d.mts} +81 -2
  98. package/dist/{types-Cns4l8gX.d.mts → types-DqWPkiYl.d.mts} +90 -12
  99. package/dist/{types-Cns4l8gX.d.ts → types-DqWPkiYl.d.ts} +90 -12
  100. package/dist/{types-BoxZEYPS.d.ts → types-eWyZuz-3.d.ts} +81 -2
  101. package/dist/ui/index.d.mts +1 -1
  102. package/dist/ui/index.d.ts +1 -1
  103. package/dist/verify.d.mts +23 -2
  104. package/dist/verify.d.ts +23 -2
  105. package/dist/verify.js +23 -4
  106. package/dist/verify.js.map +1 -1
  107. package/dist/verify.mjs +23 -4
  108. package/dist/verify.mjs.map +1 -1
  109. package/dist/webhooks.d.mts +16 -3
  110. package/dist/webhooks.d.ts +16 -3
  111. package/dist/webhooks.js +24 -13
  112. package/dist/webhooks.js.map +1 -1
  113. package/dist/webhooks.mjs +24 -13
  114. package/dist/webhooks.mjs.map +1 -1
  115. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-Cns4l8gX.mjs';
1
+ import { T as TrustLevel, S as SDKOptions, e as VerificationResult, d as VerificationRequest, A as AgentArtifacts, C as CheckoutMetadata } from '../types-DqWPkiYl.mjs';
2
2
 
3
3
  /**
4
4
  * AstraSync Universal Verification Gateway — Trust Level helpers.
@@ -68,6 +68,37 @@ declare class VerificationGatewayClient {
68
68
  subAgentDepth?: number;
69
69
  counterpartyUrl?: string;
70
70
  counterpartyType?: string;
71
+ /**
72
+ * 5.19.0: `'quote'` marks a price / limit check (peek only: no order, no
73
+ * approval redeemed) — prefer `quoteCheckout()`. Omitted with a
74
+ * `transactionValue`, the call is a PURCHASE leg (see the warning below).
75
+ */
76
+ commercePhase?: 'quote';
77
+ }): Promise<VerificationResult>;
78
+ /**
79
+ * 5.19.0: the QUOTE leg of a checkout — a price / limit check before the
80
+ * purchase. Sends `commercePhase: 'quote'`: verify-access evaluates the
81
+ * agent's policy at this value and tells you whether a purchase would be
82
+ * granted, held for the owner's approval, or denied, but records no order,
83
+ * moves no money and never redeems an approval. Always reaches the backend
84
+ * (no verdict cache).
85
+ *
86
+ * Quotes count toward limit-probing detection: a run of rising quotes is
87
+ * how an agent (or a merchant) maps a spending limit. Quote what the buyer
88
+ * asked for, not a ladder of values.
89
+ */
90
+ quoteCheckout(options: {
91
+ astraId?: string;
92
+ apiKey?: string;
93
+ jwt?: string;
94
+ purpose?: string;
95
+ action?: string;
96
+ transactionValue?: number;
97
+ currency?: string;
98
+ checkoutSessionId?: string;
99
+ attemptId?: string;
100
+ counterpartyUrl?: string;
101
+ counterpartyType?: string;
71
102
  }): Promise<VerificationResult>;
72
103
  /**
73
104
  * 5.4.0 (astra-pay): confirm-leg of a checkout — the ONLY call that may fire
@@ -107,6 +138,14 @@ declare class VerificationGatewayClient {
107
138
  * is matched to — and only to — this confirm. A held cart's approval is
108
139
  * bound to its checkout session and exact value; a confirm for any other
109
140
  * cart is held for its own approval.
141
+ *
142
+ * 5.19.0 checkout kits: pass the kit's `agentArtifacts` (the inbound agent
143
+ * request — signed RFC 9421 headers with the public URL and raw-body
144
+ * digest, or `{ unsigned: true }`) and `metadata` (`{ kitSessionId,
145
+ * protocol }`) from the `verifyPurchase` context. The platform attributes
146
+ * the confirm to the agent from the artifacts, and stores the metadata on
147
+ * any approval this confirm creates so the approval event
148
+ * (`handleApprovalEvents`) can find the kit session.
110
149
  */
111
150
  confirmCheckout(options: {
112
151
  astraId?: string;
@@ -125,6 +164,10 @@ declare class VerificationGatewayClient {
125
164
  /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
126
165
  * the platform default `fulfilment.email` to the buyer's account email. */
127
166
  buyerEmail?: string;
167
+ /** 5.19.0: the inbound agent request behind this confirm (from the kit's verifyPurchase ctx). */
168
+ agentArtifacts?: AgentArtifacts;
169
+ /** 5.19.0: `{ kitSessionId, protocol }` (from the kit's verifyPurchase ctx). */
170
+ metadata?: CheckoutMetadata;
128
171
  counterpartyUrl?: string;
129
172
  counterpartyType?: string;
130
173
  }): Promise<VerificationResult>;
@@ -1,4 +1,4 @@
1
- import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-Cns4l8gX.js';
1
+ import { T as TrustLevel, S as SDKOptions, e as VerificationResult, d as VerificationRequest, A as AgentArtifacts, C as CheckoutMetadata } from '../types-DqWPkiYl.js';
2
2
 
3
3
  /**
4
4
  * AstraSync Universal Verification Gateway — Trust Level helpers.
@@ -68,6 +68,37 @@ declare class VerificationGatewayClient {
68
68
  subAgentDepth?: number;
69
69
  counterpartyUrl?: string;
70
70
  counterpartyType?: string;
71
+ /**
72
+ * 5.19.0: `'quote'` marks a price / limit check (peek only: no order, no
73
+ * approval redeemed) — prefer `quoteCheckout()`. Omitted with a
74
+ * `transactionValue`, the call is a PURCHASE leg (see the warning below).
75
+ */
76
+ commercePhase?: 'quote';
77
+ }): Promise<VerificationResult>;
78
+ /**
79
+ * 5.19.0: the QUOTE leg of a checkout — a price / limit check before the
80
+ * purchase. Sends `commercePhase: 'quote'`: verify-access evaluates the
81
+ * agent's policy at this value and tells you whether a purchase would be
82
+ * granted, held for the owner's approval, or denied, but records no order,
83
+ * moves no money and never redeems an approval. Always reaches the backend
84
+ * (no verdict cache).
85
+ *
86
+ * Quotes count toward limit-probing detection: a run of rising quotes is
87
+ * how an agent (or a merchant) maps a spending limit. Quote what the buyer
88
+ * asked for, not a ladder of values.
89
+ */
90
+ quoteCheckout(options: {
91
+ astraId?: string;
92
+ apiKey?: string;
93
+ jwt?: string;
94
+ purpose?: string;
95
+ action?: string;
96
+ transactionValue?: number;
97
+ currency?: string;
98
+ checkoutSessionId?: string;
99
+ attemptId?: string;
100
+ counterpartyUrl?: string;
101
+ counterpartyType?: string;
71
102
  }): Promise<VerificationResult>;
72
103
  /**
73
104
  * 5.4.0 (astra-pay): confirm-leg of a checkout — the ONLY call that may fire
@@ -107,6 +138,14 @@ declare class VerificationGatewayClient {
107
138
  * is matched to — and only to — this confirm. A held cart's approval is
108
139
  * bound to its checkout session and exact value; a confirm for any other
109
140
  * cart is held for its own approval.
141
+ *
142
+ * 5.19.0 checkout kits: pass the kit's `agentArtifacts` (the inbound agent
143
+ * request — signed RFC 9421 headers with the public URL and raw-body
144
+ * digest, or `{ unsigned: true }`) and `metadata` (`{ kitSessionId,
145
+ * protocol }`) from the `verifyPurchase` context. The platform attributes
146
+ * the confirm to the agent from the artifacts, and stores the metadata on
147
+ * any approval this confirm creates so the approval event
148
+ * (`handleApprovalEvents`) can find the kit session.
110
149
  */
111
150
  confirmCheckout(options: {
112
151
  astraId?: string;
@@ -125,6 +164,10 @@ declare class VerificationGatewayClient {
125
164
  /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
126
165
  * the platform default `fulfilment.email` to the buyer's account email. */
127
166
  buyerEmail?: string;
167
+ /** 5.19.0: the inbound agent request behind this confirm (from the kit's verifyPurchase ctx). */
168
+ agentArtifacts?: AgentArtifacts;
169
+ /** 5.19.0: `{ kitSessionId, protocol }` (from the kit's verifyPurchase ctx). */
170
+ metadata?: CheckoutMetadata;
128
171
  counterpartyUrl?: string;
129
172
  counterpartyType?: string;
130
173
  }): Promise<VerificationResult>;
@@ -28,7 +28,7 @@ __export(sdk_exports, {
28
28
  module.exports = __toCommonJS(sdk_exports);
29
29
 
30
30
  // src/version.ts
31
- var SDK_VERSION = "5.18.0";
31
+ var SDK_VERSION = "5.19.0";
32
32
 
33
33
  // src/http.ts
34
34
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -206,7 +206,12 @@ function getCacheKey(request, counterpartyId) {
206
206
  // its start_checkout quote was served the cached quote-leg grant (no
207
207
  // settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
208
208
  request.commercePhase || "",
209
- request.checkoutSessionId || ""
209
+ request.checkoutSessionId || "",
210
+ // 5.19.0: a route_config purpose claim is checked server-side against
211
+ // the stored rule for this method + path, so it changes the verdict.
212
+ request.purposeSource || "",
213
+ request.requestMethod || "",
214
+ request.requestPath || ""
210
215
  ].join("|");
211
216
  }
212
217
  function getCachedResult(request, counterpartyId) {
@@ -383,6 +388,11 @@ async function callVerifyAccessAPI(config, request) {
383
388
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
384
389
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
385
390
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
391
+ if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
392
+ if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
393
+ if (requestData.metadata) body.metadata = requestData.metadata;
394
+ if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
395
+ if (requestData.requestPath) body.requestPath = requestData.requestPath;
386
396
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
387
397
  body.sdkVersion = SDK_VERSION;
388
398
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -572,9 +582,18 @@ async function verify(config, request, options) {
572
582
  if (!apiResponse.access?.allowed) {
573
583
  const aggregatedFailures = apiResponse.access?.failures;
574
584
  const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
585
+ const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
586
+ astraId: apiResponse.agent.astraId,
587
+ name: apiResponse.agent.name,
588
+ trustScore: apiResponse.agent.trustScore,
589
+ trustLevel: getTrustLevel(apiResponse.agent.trustScore),
590
+ blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
591
+ status: apiResponse.agent.agentStatus
592
+ } : void 0;
575
593
  const result2 = {
576
594
  identityVerified: idVerifiedFromBackend,
577
595
  policyAllowed: false,
596
+ ...denyAgent && { agent: denyAgent },
578
597
  // 3.6.0: the server now emits top-level denialReasons on every deny
579
598
  // path — prefer it verbatim; the failure-message reconstruction remains
580
599
  // as the fallback for older backends.
@@ -745,6 +764,7 @@ var SettlementReportError = class extends AstraSyncError {
745
764
  };
746
765
 
747
766
  // src/adapters/sdk.ts
767
+ var warnedPhaselessValue = false;
748
768
  var VerificationGatewayClient = class {
749
769
  constructor(options) {
750
770
  this.config = {
@@ -776,9 +796,16 @@ var VerificationGatewayClient = class {
776
796
  apiKey: options.apiKey,
777
797
  jwt: options.jwt
778
798
  };
799
+ if (options.transactionValue && !options.commercePhase && !warnedPhaselessValue) {
800
+ warnedPhaselessValue = true;
801
+ console.warn(
802
+ "[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."
803
+ );
804
+ }
779
805
  return this.executeWithRetry(
780
806
  () => verify(this.config, {
781
807
  credentials,
808
+ ...options.commercePhase && { commercePhase: options.commercePhase },
782
809
  purpose: options.purpose,
783
810
  action: options.action,
784
811
  resourceType: options.resourceType,
@@ -794,6 +821,43 @@ var VerificationGatewayClient = class {
794
821
  })
795
822
  );
796
823
  }
824
+ /**
825
+ * 5.19.0: the QUOTE leg of a checkout — a price / limit check before the
826
+ * purchase. Sends `commercePhase: 'quote'`: verify-access evaluates the
827
+ * agent's policy at this value and tells you whether a purchase would be
828
+ * granted, held for the owner's approval, or denied, but records no order,
829
+ * moves no money and never redeems an approval. Always reaches the backend
830
+ * (no verdict cache).
831
+ *
832
+ * Quotes count toward limit-probing detection: a run of rising quotes is
833
+ * how an agent (or a merchant) maps a spending limit. Quote what the buyer
834
+ * asked for, not a ladder of values.
835
+ */
836
+ async quoteCheckout(options) {
837
+ const credentials = {
838
+ astraId: options.astraId,
839
+ apiKey: options.apiKey,
840
+ jwt: options.jwt
841
+ };
842
+ return this.executeWithRetry(
843
+ () => verify(
844
+ this.config,
845
+ {
846
+ credentials,
847
+ purpose: options.purpose ?? "shopping",
848
+ action: options.action ?? "shopping.purchase",
849
+ transactionValue: options.transactionValue,
850
+ currency: options.currency,
851
+ commercePhase: "quote",
852
+ ...options.checkoutSessionId && { checkoutSessionId: options.checkoutSessionId },
853
+ ...options.attemptId && { attemptId: options.attemptId },
854
+ counterpartyUrl: options.counterpartyUrl,
855
+ counterpartyType: options.counterpartyType
856
+ },
857
+ { bypassCache: true }
858
+ )
859
+ );
860
+ }
797
861
  /**
798
862
  * 5.4.0 (astra-pay): confirm-leg of a checkout — the ONLY call that may fire
799
863
  * first-party charge-at-redeem (server-side settlement on the owner's saved
@@ -832,6 +896,14 @@ var VerificationGatewayClient = class {
832
896
  * is matched to — and only to — this confirm. A held cart's approval is
833
897
  * bound to its checkout session and exact value; a confirm for any other
834
898
  * cart is held for its own approval.
899
+ *
900
+ * 5.19.0 checkout kits: pass the kit's `agentArtifacts` (the inbound agent
901
+ * request — signed RFC 9421 headers with the public URL and raw-body
902
+ * digest, or `{ unsigned: true }`) and `metadata` (`{ kitSessionId,
903
+ * protocol }`) from the `verifyPurchase` context. The platform attributes
904
+ * the confirm to the agent from the artifacts, and stores the metadata on
905
+ * any approval this confirm creates so the approval event
906
+ * (`handleApprovalEvents`) can find the kit session.
835
907
  */
836
908
  async confirmCheckout(options) {
837
909
  const credentials = {
@@ -854,6 +926,8 @@ var VerificationGatewayClient = class {
854
926
  ...options.checkoutJwt && { checkoutJwt: options.checkoutJwt },
855
927
  ...options.attemptId && { attemptId: options.attemptId },
856
928
  buyerEmail: options.buyerEmail,
929
+ ...options.agentArtifacts && { agentArtifacts: options.agentArtifacts },
930
+ ...options.metadata && { metadata: options.metadata },
857
931
  counterpartyUrl: options.counterpartyUrl,
858
932
  counterpartyType: options.counterpartyType
859
933
  },