@astrasyncai/verification-gateway 5.4.2 → 5.6.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 (94) hide show
  1. package/README.md +74 -21
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +12 -3
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +12 -3
  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 +12 -3
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +12 -3
  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 +12 -3
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +12 -3
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +41 -1
  21. package/dist/adapters/sdk.d.ts +41 -1
  22. package/dist/adapters/sdk.js +54 -3
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +54 -3
  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 +12 -3
  31. package/dist/bin/astrasync-codex-hook.js +12 -3
  32. package/dist/bin/astrasync-guard.js +12 -3
  33. package/dist/bin/astrasync.js +13 -3
  34. package/dist/browser/background.js +12 -3
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +12 -3
  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 +12 -3
  43. package/dist/codex/index.js.map +1 -1
  44. package/dist/codex/index.mjs +12 -3
  45. package/dist/codex/index.mjs.map +1 -1
  46. package/dist/cursor/extension.js +12 -3
  47. package/dist/cursor/extension.js.map +1 -1
  48. package/dist/cursor/extension.mjs +12 -3
  49. package/dist/cursor/extension.mjs.map +1 -1
  50. package/dist/edge-config.d.mts +1 -1
  51. package/dist/edge-config.d.ts +1 -1
  52. package/dist/edge-config.js +1 -1
  53. package/dist/edge-config.js.map +1 -1
  54. package/dist/edge-config.mjs +1 -1
  55. package/dist/edge-config.mjs.map +1 -1
  56. package/dist/edge-core/index.d.mts +1 -1
  57. package/dist/edge-core/index.d.ts +1 -1
  58. package/dist/edge-core/index.js +12 -3
  59. package/dist/edge-core/index.js.map +1 -1
  60. package/dist/edge-core/index.mjs +12 -3
  61. package/dist/edge-core/index.mjs.map +1 -1
  62. package/dist/gateway/gateway.js +12 -3
  63. package/dist/gateway/gateway.js.map +1 -1
  64. package/dist/gateway/gateway.mjs +12 -3
  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 +121 -4
  69. package/dist/index.d.ts +121 -4
  70. package/dist/index.js +54 -3
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +54 -3
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/registration/index.js +1 -1
  75. package/dist/registration/index.js.map +1 -1
  76. package/dist/registration/index.mjs +1 -1
  77. package/dist/registration/index.mjs.map +1 -1
  78. package/dist/transport/index.js +1 -1
  79. package/dist/transport/index.js.map +1 -1
  80. package/dist/transport/index.mjs +1 -1
  81. package/dist/transport/index.mjs.map +1 -1
  82. package/dist/{types-Bd2O3eX1.d.mts → types-BCmHFdkJ.d.mts} +78 -1
  83. package/dist/{types-BU04qAAR.d.mts → types-BK_pRNSs.d.mts} +78 -1
  84. package/dist/{types-BU04qAAR.d.ts → types-BK_pRNSs.d.ts} +78 -1
  85. package/dist/{types-DMChboN_.d.ts → types-CwY5IY-0.d.ts} +78 -1
  86. package/dist/ui/index.d.mts +1 -1
  87. package/dist/ui/index.d.ts +1 -1
  88. package/dist/verify.d.mts +1 -1
  89. package/dist/verify.d.ts +1 -1
  90. package/dist/verify.js +12 -3
  91. package/dist/verify.js.map +1 -1
  92. package/dist/verify.mjs +12 -3
  93. package/dist/verify.mjs.map +1 -1
  94. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -19,7 +19,7 @@ function getTrustLevel(score) {
19
19
  }
20
20
 
21
21
  // src/version.ts
22
- var SDK_VERSION = "5.4.1";
22
+ var SDK_VERSION = "5.6.0";
23
23
 
24
24
  // src/http.ts
25
25
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -382,6 +382,7 @@ async function callVerifyAccessAPI(config, request) {
382
382
  if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
383
383
  if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
384
384
  if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
385
+ if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
385
386
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
386
387
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
387
388
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
@@ -554,7 +555,12 @@ async function verify(config, request, options) {
554
555
  recommendationReasons: apiResponse.recommendationReasons,
555
556
  stepUpApproval: apiResponse.stepUpApproval,
556
557
  settlement: apiResponse.settlement,
557
- settlementOutcome: apiResponse.settlementOutcome
558
+ settlementOutcome: apiResponse.settlementOutcome,
559
+ // 5.5.0 self-settlement: merchant-only material — passes through to the
560
+ // MERCHANT caller only (bridge callers strip it before the agent plane).
561
+ settlementToken: apiResponse.settlementToken,
562
+ // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
563
+ fulfilment: apiResponse.fulfilment
558
564
  };
559
565
  return result2;
560
566
  }
@@ -612,7 +618,10 @@ async function verify(config, request, options) {
612
618
  warningHeader: apiResponse.warningHeader,
613
619
  stepUpApproval: apiResponse.stepUpApproval,
614
620
  settlement: apiResponse.settlement,
615
- settlementOutcome: apiResponse.settlementOutcome
621
+ settlementOutcome: apiResponse.settlementOutcome,
622
+ settlementToken: apiResponse.settlementToken,
623
+ // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
624
+ fulfilment: apiResponse.fulfilment
616
625
  };
617
626
  if (result.recommendation === "deny") {
618
627
  result.policyAllowed = false;
@@ -2644,6 +2653,21 @@ var VerificationGatewayClient = class {
2644
2653
  * settled/failed/requires_action/no_instrument outcome (+ `orderId`), and the
2645
2654
  * identity/policy/`failures` fields for a denial. On any non-`confirm`/first-
2646
2655
  * party path `settlementOutcome` is simply absent — no money moves.
2656
+ *
2657
+ * 5.5.0 self-settling merchants (settlement_mode='self_settle'): the result
2658
+ * carries `.settlementToken` instead of a completed charge. Charge on your
2659
+ * own integration with Stripe idempotency key `voucher:<token.jti>` and
2660
+ * `metadata: { jti: token.jti, sessionId: token.sessionId }`, then call
2661
+ * `reportSettlement()` with the outcome. Treat any `settlementOutcome.status`
2662
+ * you don't recognize (e.g. `pending_merchant`) as PENDING, never failed.
2663
+ *
2664
+ * 5.6.0 fulfilment contact: first-party confirm results carry
2665
+ * `.fulfilment { email, emailSource }` — the buyer's receipt/delivery
2666
+ * email. You always get one: the platform defaults to the buyer's account
2667
+ * email when no `buyerEmail` was passed. Store it with the pending order;
2668
+ * fulfil against it only once the order is settled / pending_merchant. An
2669
+ * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
2670
+ * account default.
2647
2671
  */
2648
2672
  async confirmCheckout(options) {
2649
2673
  const credentials = {
@@ -2663,6 +2687,7 @@ var VerificationGatewayClient = class {
2663
2687
  commercePhase: "confirm",
2664
2688
  checkoutSessionId: options.checkoutSessionId,
2665
2689
  checkoutItems: options.checkoutItems,
2690
+ buyerEmail: options.buyerEmail,
2666
2691
  counterpartyUrl: options.counterpartyUrl,
2667
2692
  counterpartyType: options.counterpartyType
2668
2693
  },
@@ -2673,6 +2698,32 @@ var VerificationGatewayClient = class {
2673
2698
  )
2674
2699
  );
2675
2700
  }
2701
+ /**
2702
+ * 5.5.0 (astra-pay): report a self-settled charge outcome back to the
2703
+ * platform — the other half of the `settlementToken` contract. Call after
2704
+ * your PaymentIntent reaches a terminal state so the buyer's dashboard,
2705
+ * /orders and the agent's poll surface reconcile. Authenticated with this
2706
+ * client's api key (must be the merchant's own). Amounts must match the
2707
+ * order EXACTLY (integer minor units) or the report is rejected whole
2708
+ * (409 amount_mismatch). Replays of the same terminal state are safe.
2709
+ */
2710
+ async reportSettlement(options) {
2711
+ const base = this.config.apiBaseUrl.replace(/\/+$/, "");
2712
+ const res = await sdkFetch(`${base}/merchant/settlements/report`, {
2713
+ method: "POST",
2714
+ headers: {
2715
+ "Content-Type": "application/json",
2716
+ // Same auth pair as every backend call the SDK makes (verify.ts).
2717
+ ...this.config.apiKey ? { Authorization: `Bearer ${this.config.apiKey}`, "X-API-Key": this.config.apiKey } : {}
2718
+ },
2719
+ body: JSON.stringify(options)
2720
+ });
2721
+ const json = await res.json().catch(() => ({}));
2722
+ if (!res.ok || !json.success || !json.data) {
2723
+ throw new Error(`reportSettlement failed (${res.status}): ${json.error ?? "unknown error"}`);
2724
+ }
2725
+ return json.data;
2726
+ }
2676
2727
  /**
2677
2728
  * Quick verification — checks credentials and policy in one call.
2678
2729
  *