@astrasyncai/verification-gateway 5.13.0 → 5.15.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 (98) hide show
  1. package/README.md +27 -17
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +504 -249
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +504 -249
  7. package/dist/adapters/express.mjs.map +1 -1
  8. package/dist/adapters/mcp.d.mts +1 -1
  9. package/dist/adapters/mcp.d.ts +1 -1
  10. package/dist/adapters/mcp.js +20 -6
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +20 -6
  13. package/dist/adapters/mcp.mjs.map +1 -1
  14. package/dist/adapters/nextjs.d.mts +1 -1
  15. package/dist/adapters/nextjs.d.ts +1 -1
  16. package/dist/adapters/nextjs.js +487 -248
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +487 -248
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +18 -10
  21. package/dist/adapters/sdk.d.ts +18 -10
  22. package/dist/adapters/sdk.js +80 -23
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +80 -23
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.js +1 -1
  27. package/dist/agent/index.js.map +1 -1
  28. package/dist/agent/index.mjs +1 -1
  29. package/dist/agent/index.mjs.map +1 -1
  30. package/dist/bin/astrasync-claude-hook.js +82 -20
  31. package/dist/bin/astrasync-codex-hook.js +82 -20
  32. package/dist/bin/astrasync-guard.js +82 -20
  33. package/dist/bin/astrasync.js +316 -43
  34. package/dist/browser/background.js +77 -15
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +87 -15
  37. package/dist/browser/background.mjs.map +1 -1
  38. package/dist/cli/index.js +1 -1
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/cli/index.mjs +1 -1
  41. package/dist/cli/index.mjs.map +1 -1
  42. package/dist/codex/index.js +82 -20
  43. package/dist/codex/index.js.map +1 -1
  44. package/dist/codex/index.mjs +92 -20
  45. package/dist/codex/index.mjs.map +1 -1
  46. package/dist/cursor/extension.js +82 -20
  47. package/dist/cursor/extension.js.map +1 -1
  48. package/dist/cursor/extension.mjs +92 -20
  49. package/dist/cursor/extension.mjs.map +1 -1
  50. package/dist/edge-config.d.mts +31 -2
  51. package/dist/edge-config.d.ts +31 -2
  52. package/dist/edge-config.js +35 -5
  53. package/dist/edge-config.js.map +1 -1
  54. package/dist/edge-config.mjs +32 -4
  55. package/dist/edge-config.mjs.map +1 -1
  56. package/dist/edge-core/index.d.mts +43 -6
  57. package/dist/edge-core/index.d.ts +43 -6
  58. package/dist/edge-core/index.js +120 -19
  59. package/dist/edge-core/index.js.map +1 -1
  60. package/dist/edge-core/index.mjs +118 -19
  61. package/dist/edge-core/index.mjs.map +1 -1
  62. package/dist/gateway/gateway.js +77 -15
  63. package/dist/gateway/gateway.js.map +1 -1
  64. package/dist/gateway/gateway.mjs +87 -15
  65. package/dist/gateway/gateway.mjs.map +1 -1
  66. package/dist/git-trigger/git-hooks.d.mts +1 -1
  67. package/dist/git-trigger/git-hooks.d.ts +1 -1
  68. package/dist/index.d.mts +1314 -34
  69. package/dist/index.d.ts +1314 -34
  70. package/dist/index.js +5143 -2621
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +5090 -2623
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/registration/index.d.mts +28 -2
  75. package/dist/registration/index.d.ts +28 -2
  76. package/dist/registration/index.js +18 -3
  77. package/dist/registration/index.js.map +1 -1
  78. package/dist/registration/index.mjs +15 -2
  79. package/dist/registration/index.mjs.map +1 -1
  80. package/dist/transport/index.d.mts +7 -5
  81. package/dist/transport/index.d.ts +7 -5
  82. package/dist/transport/index.js +61 -5
  83. package/dist/transport/index.js.map +1 -1
  84. package/dist/transport/index.mjs +67 -11
  85. package/dist/transport/index.mjs.map +1 -1
  86. package/dist/{types-C_b4QTyO.d.ts → types-DtJjlW4O.d.ts} +104 -10
  87. package/dist/{types-BCkwBA84.d.mts → types-Dxf9DBpr.d.mts} +106 -12
  88. package/dist/{types-BCkwBA84.d.ts → types-Dxf9DBpr.d.ts} +106 -12
  89. package/dist/{types-DlshIIR-.d.mts → types-Eg6VoBNH.d.mts} +104 -10
  90. package/dist/ui/index.d.mts +1 -1
  91. package/dist/ui/index.d.ts +1 -1
  92. package/dist/verify.d.mts +1 -1
  93. package/dist/verify.d.ts +1 -1
  94. package/dist/verify.js +20 -6
  95. package/dist/verify.js.map +1 -1
  96. package/dist/verify.mjs +20 -6
  97. package/dist/verify.mjs.map +1 -1
  98. 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-BCkwBA84.mjs';
1
+ import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-Dxf9DBpr.mjs';
2
2
 
3
3
  /**
4
4
  * AstraSync Universal Verification Gateway — Trust Level helpers.
@@ -118,6 +118,8 @@ declare class VerificationGatewayClient {
118
118
  currency?: string;
119
119
  checkoutSessionId?: string;
120
120
  checkoutItems?: VerificationRequest['checkoutItems'];
121
+ /** 5.15.0: your signed checkout (AP2 checkout_jwt) — returns `mandates` at AP2 merchants. */
122
+ checkoutJwt?: string;
121
123
  /** 5.12.0: the `att_…` attempt-chain id from the bridge handoff body. */
122
124
  attemptId?: string;
123
125
  /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
@@ -127,21 +129,27 @@ declare class VerificationGatewayClient {
127
129
  counterpartyType?: string;
128
130
  }): Promise<VerificationResult>;
129
131
  /**
130
- * 5.5.0 (astra-pay): report a self-settled charge outcome back to the
131
- * platform — the other half of the `settlementToken` contract. Call after
132
- * your PaymentIntent reaches a terminal state so the buyer's dashboard,
133
- * /orders and the agent's poll surface reconcile. Authenticated with this
134
- * client's api key (must be the merchant's own). Amounts must match the
135
- * order EXACTLY (integer minor units) or the report is rejected whole
136
- * (409 amount_mismatch). Replays of the same terminal state are safe.
132
+ * Report a settlement outcome back to the platform. 5.14.1: AstraSync never
133
+ * charges — EVERY merchant settles the orders it is handed (card token,
134
+ * stablecoin voucher, or a protocol-native credential) and reports here, so
135
+ * the buyer's dashboard, /orders and the agent's poll surface reconcile.
136
+ * Identify the order by the confirm's `sessionId` or the `orderId` from
137
+ * `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
138
+ * a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
139
+ * match the order EXACTLY (integer minor units) or the report is rejected
140
+ * whole (409 amount_mismatch). Replays of the same terminal state are safe.
137
141
  */
138
142
  reportSettlement(options: {
139
- sessionId: string;
143
+ sessionId?: string;
144
+ orderId?: string;
140
145
  status: 'settled' | 'declined' | 'failed';
141
146
  amountMinor: number;
142
147
  currency: string;
143
- /** Stripe PaymentIntent id — REQUIRED when status is 'settled'. */
148
+ /** Stripe PaymentIntent id (card) — this or `txHash` is required when settled. */
144
149
  processorRef?: string;
150
+ /** Stablecoin transfer transaction hash (0x…, 32 bytes). */
151
+ txHash?: string;
152
+ chainId?: number;
145
153
  failureCode?: string;
146
154
  }): Promise<{
147
155
  orderId: string;
@@ -1,4 +1,4 @@
1
- import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-BCkwBA84.js';
1
+ import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-Dxf9DBpr.js';
2
2
 
3
3
  /**
4
4
  * AstraSync Universal Verification Gateway — Trust Level helpers.
@@ -118,6 +118,8 @@ declare class VerificationGatewayClient {
118
118
  currency?: string;
119
119
  checkoutSessionId?: string;
120
120
  checkoutItems?: VerificationRequest['checkoutItems'];
121
+ /** 5.15.0: your signed checkout (AP2 checkout_jwt) — returns `mandates` at AP2 merchants. */
122
+ checkoutJwt?: string;
121
123
  /** 5.12.0: the `att_…` attempt-chain id from the bridge handoff body. */
122
124
  attemptId?: string;
123
125
  /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
@@ -127,21 +129,27 @@ declare class VerificationGatewayClient {
127
129
  counterpartyType?: string;
128
130
  }): Promise<VerificationResult>;
129
131
  /**
130
- * 5.5.0 (astra-pay): report a self-settled charge outcome back to the
131
- * platform — the other half of the `settlementToken` contract. Call after
132
- * your PaymentIntent reaches a terminal state so the buyer's dashboard,
133
- * /orders and the agent's poll surface reconcile. Authenticated with this
134
- * client's api key (must be the merchant's own). Amounts must match the
135
- * order EXACTLY (integer minor units) or the report is rejected whole
136
- * (409 amount_mismatch). Replays of the same terminal state are safe.
132
+ * Report a settlement outcome back to the platform. 5.14.1: AstraSync never
133
+ * charges — EVERY merchant settles the orders it is handed (card token,
134
+ * stablecoin voucher, or a protocol-native credential) and reports here, so
135
+ * the buyer's dashboard, /orders and the agent's poll surface reconcile.
136
+ * Identify the order by the confirm's `sessionId` or the `orderId` from
137
+ * `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
138
+ * a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
139
+ * match the order EXACTLY (integer minor units) or the report is rejected
140
+ * whole (409 amount_mismatch). Replays of the same terminal state are safe.
137
141
  */
138
142
  reportSettlement(options: {
139
- sessionId: string;
143
+ sessionId?: string;
144
+ orderId?: string;
140
145
  status: 'settled' | 'declined' | 'failed';
141
146
  amountMinor: number;
142
147
  currency: string;
143
- /** Stripe PaymentIntent id — REQUIRED when status is 'settled'. */
148
+ /** Stripe PaymentIntent id (card) — this or `txHash` is required when settled. */
144
149
  processorRef?: string;
150
+ /** Stablecoin transfer transaction hash (0x…, 32 bytes). */
151
+ txHash?: string;
152
+ chainId?: number;
145
153
  failureCode?: string;
146
154
  }): Promise<{
147
155
  orderId: string;
@@ -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.13.0";
31
+ var SDK_VERSION = "5.15.0";
32
32
 
33
33
  // src/http.ts
34
34
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -373,6 +373,7 @@ async function callVerifyAccessAPI(config, request) {
373
373
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
374
374
  if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
375
375
  if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
376
+ if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
376
377
  if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
377
378
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
378
379
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
@@ -523,7 +524,8 @@ async function verify(config, request, options) {
523
524
  "[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access decisions (verified ID + runtime challenge + PDLSS + trust score). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
524
525
  );
525
526
  }
526
- if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
527
+ const uncacheable = Boolean(request.commerceArtifacts);
528
+ if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
527
529
  const cached = getCachedResult(request, mergedConfig.counterpartyId);
528
530
  if (cached) {
529
531
  if (mergedConfig.debug) {
@@ -604,7 +606,10 @@ async function verify(config, request, options) {
604
606
  // MERCHANT caller only (bridge callers strip it before the agent plane).
605
607
  settlementToken: apiResponse.settlementToken,
606
608
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
607
- fulfilment: apiResponse.fulfilment
609
+ fulfilment: apiResponse.fulfilment,
610
+ mandates: apiResponse.mandates,
611
+ kyaToken: apiResponse.kyaToken,
612
+ aep: apiResponse.aep
608
613
  };
609
614
  return result2;
610
615
  }
@@ -614,7 +619,10 @@ async function verify(config, request, options) {
614
619
  trustScore: apiResponse.agent.trustScore,
615
620
  trustLevel: getTrustLevel(apiResponse.agent.trustScore),
616
621
  blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
617
- status: apiResponse.agent.agentStatus
622
+ status: apiResponse.agent.agentStatus,
623
+ ...apiResponse.agent.protocolIdentities && {
624
+ protocolIdentities: apiResponse.agent.protocolIdentities
625
+ }
618
626
  } : void 0;
619
627
  const developer = apiResponse.developer ? {
620
628
  astradId: apiResponse.developer.kyaOwnerId,
@@ -665,7 +673,11 @@ async function verify(config, request, options) {
665
673
  settlementOutcome: apiResponse.settlementOutcome,
666
674
  settlementToken: apiResponse.settlementToken,
667
675
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
668
- fulfilment: apiResponse.fulfilment
676
+ fulfilment: apiResponse.fulfilment,
677
+ // 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
678
+ mandates: apiResponse.mandates,
679
+ kyaToken: apiResponse.kyaToken,
680
+ aep: apiResponse.aep
669
681
  };
670
682
  if (result.recommendation === "deny") {
671
683
  result.policyAllowed = false;
@@ -685,7 +697,9 @@ async function verify(config, request, options) {
685
697
  }
686
698
  const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
687
699
  if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
688
- cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
700
+ if (!uncacheable) {
701
+ cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
702
+ }
689
703
  }
690
704
  return result;
691
705
  }
@@ -705,6 +719,24 @@ async function quickVerify(config, credentials) {
705
719
  };
706
720
  }
707
721
 
722
+ // src/registration/errors.ts
723
+ var AstraSyncError = class extends Error {
724
+ constructor(message, statusCode, code) {
725
+ super(message);
726
+ this.name = "AstraSyncError";
727
+ this.statusCode = statusCode;
728
+ this.code = code;
729
+ }
730
+ };
731
+ var SettlementReportError = class extends AstraSyncError {
732
+ constructor(message, statusCode, code, issues) {
733
+ super(message, statusCode, code);
734
+ this.name = "SettlementReportError";
735
+ this.issues = issues;
736
+ this.retryable = statusCode === 0 || statusCode === 429 || statusCode >= 500;
737
+ }
738
+ };
739
+
708
740
  // src/adapters/sdk.ts
709
741
  var VerificationGatewayClient = class {
710
742
  constructor(options) {
@@ -812,6 +844,7 @@ var VerificationGatewayClient = class {
812
844
  commercePhase: "confirm",
813
845
  checkoutSessionId: options.checkoutSessionId,
814
846
  checkoutItems: options.checkoutItems,
847
+ ...options.checkoutJwt && { checkoutJwt: options.checkoutJwt },
815
848
  ...options.attemptId && { attemptId: options.attemptId },
816
849
  buyerEmail: options.buyerEmail,
817
850
  counterpartyUrl: options.counterpartyUrl,
@@ -825,28 +858,52 @@ var VerificationGatewayClient = class {
825
858
  );
826
859
  }
827
860
  /**
828
- * 5.5.0 (astra-pay): report a self-settled charge outcome back to the
829
- * platform — the other half of the `settlementToken` contract. Call after
830
- * your PaymentIntent reaches a terminal state so the buyer's dashboard,
831
- * /orders and the agent's poll surface reconcile. Authenticated with this
832
- * client's api key (must be the merchant's own). Amounts must match the
833
- * order EXACTLY (integer minor units) or the report is rejected whole
834
- * (409 amount_mismatch). Replays of the same terminal state are safe.
861
+ * Report a settlement outcome back to the platform. 5.14.1: AstraSync never
862
+ * charges — EVERY merchant settles the orders it is handed (card token,
863
+ * stablecoin voucher, or a protocol-native credential) and reports here, so
864
+ * the buyer's dashboard, /orders and the agent's poll surface reconcile.
865
+ * Identify the order by the confirm's `sessionId` or the `orderId` from
866
+ * `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
867
+ * a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
868
+ * match the order EXACTLY (integer minor units) or the report is rejected
869
+ * whole (409 amount_mismatch). Replays of the same terminal state are safe.
835
870
  */
836
871
  async reportSettlement(options) {
872
+ if (!options.sessionId && !options.orderId) {
873
+ throw new SettlementReportError(
874
+ "reportSettlement needs sessionId or orderId",
875
+ 400,
876
+ "VALIDATION"
877
+ );
878
+ }
837
879
  const base = this.config.apiBaseUrl.replace(/\/+$/, "");
838
- const res = await sdkFetch(`${base}/merchant/settlements/report`, {
839
- method: "POST",
840
- headers: {
841
- "Content-Type": "application/json",
842
- // Same auth pair as every backend call the SDK makes (verify.ts).
843
- ...this.config.apiKey ? { Authorization: `Bearer ${this.config.apiKey}`, "X-API-Key": this.config.apiKey } : {}
844
- },
845
- body: JSON.stringify(options)
846
- });
880
+ let res;
881
+ try {
882
+ res = await sdkFetch(`${base}/merchant/settlements/report`, {
883
+ method: "POST",
884
+ headers: {
885
+ "Content-Type": "application/json",
886
+ // Same auth pair as every backend call the SDK makes (verify.ts).
887
+ ...this.config.apiKey ? { Authorization: `Bearer ${this.config.apiKey}`, "X-API-Key": this.config.apiKey } : {}
888
+ },
889
+ body: JSON.stringify(options)
890
+ });
891
+ } catch (err) {
892
+ throw new SettlementReportError(
893
+ `reportSettlement failed: ${err instanceof Error ? err.message : String(err)}`,
894
+ 0,
895
+ "network_error"
896
+ );
897
+ }
847
898
  const json = await res.json().catch(() => ({}));
848
899
  if (!res.ok || !json.success || !json.data) {
849
- throw new Error(`reportSettlement failed (${res.status}): ${json.error ?? "unknown error"}`);
900
+ const code = json.code ?? json.error ?? "unknown_error";
901
+ throw new SettlementReportError(
902
+ `reportSettlement failed (${res.status}): ${code}`,
903
+ res.status,
904
+ code,
905
+ json.issues
906
+ );
850
907
  }
851
908
  return json.data;
852
909
  }