@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
@@ -1,4 +1,4 @@
1
- import { T as TokenGuidance, b as CounterpartyType } from '../types-Bd2O3eX1.mjs';
1
+ import { T as TokenGuidance, b as CounterpartyType } from '../types-BCmHFdkJ.mjs';
2
2
  import '../metadata-capture.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { T as TokenGuidance, b as CounterpartyType } from '../types-DMChboN_.js';
1
+ import { T as TokenGuidance, b as CounterpartyType } from '../types-CwY5IY-0.js';
2
2
  import '../metadata-capture.js';
3
3
 
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -653,11 +653,72 @@ interface VerificationResult {
653
653
  * instrument on file (steer the user to add one via onboarding).
654
654
  */
655
655
  settlementOutcome?: SettlementOutcomeInfo;
656
+ /**
657
+ * 5.5.0 (astra-pay): interim merchant self-settlement token. Present ONLY
658
+ * for firstParty merchants opted into settlement_mode='self_settle' on the
659
+ * confirm leg — YOUR server charges with this material on the shared Stripe
660
+ * account and reports the outcome via `client.reportSettlement()`.
661
+ * MERCHANT-ONLY lane: never expose it to the agent plane, never log it,
662
+ * never echo it back over the bridge handoff (the bridge strips it
663
+ * defensively). Charge with idempotency key `voucher:<jti>` and
664
+ * `metadata.jti` — that lets the platform webhook auto-reconcile even if
665
+ * your report never arrives.
666
+ */
667
+ settlementToken?: MerchantSettlementToken;
668
+ /**
669
+ * 5.6.0 (astra-pay): fulfilment contact for first-party confirm legs.
670
+ * The platform always resolves an email for the merchant — the agent's
671
+ * `buyerEmail` when one was supplied, else the buyer's account email
672
+ * (`emailSource` says which). Present on every first-party confirm leg that
673
+ * progressed (settled, pending_merchant, held, requires_action) so it can be
674
+ * stored with a pending order; only FULFIL against it once the order is
675
+ * settled / pending_merchant. MERCHANT-ONLY lane like `settlementToken` —
676
+ * the bridge strips it from the agent plane. An explicit `buyerEmail` on the
677
+ * confirm handoff body wins over `fulfilment.email` (the platform default).
678
+ */
679
+ fulfilment?: FulfilmentInfo;
656
680
  /** Timestamp of verification */
657
681
  verifiedAt: Date;
658
682
  /** TTL for this result (seconds) */
659
683
  cacheTtl?: number;
660
684
  }
685
+ /**
686
+ * 5.5.0 (astra-pay): agent-blind settlement token for self-settling
687
+ * first-party merchants. Self-describing via `type`, so a Stripe Shared
688
+ * Payment Token can replace the raw customer/payment-method pair without a
689
+ * contract change.
690
+ */
691
+ interface MerchantSettlementToken {
692
+ type: 'stripe_delegated_charge';
693
+ stripeCustomerId: string;
694
+ stripePaymentMethodId: string;
695
+ /** Integer minor units — money is never a float on the wire. */
696
+ amountMinor: number;
697
+ /** Upper-case ISO-4217. */
698
+ currency: string;
699
+ /** Verification session id — the report-back key. */
700
+ sessionId: string | null;
701
+ /** The pending kya_shop_order row your report resolves. */
702
+ orderId: string;
703
+ /** Settlement spine: charge with Stripe idempotency key `voucher:<jti>`
704
+ * and set `metadata.jti` on the PaymentIntent. */
705
+ jti: string;
706
+ statementSuffix: string | null;
707
+ /** Advisory charge-by bound (ISO); stuck orders are ops-swept after it. */
708
+ expiresAt: string;
709
+ }
710
+ /**
711
+ * 5.6.0 (astra-pay): fulfilment contact block. `emailSource` is an OPEN union
712
+ * (same rule as settlement statuses): treat unknown sources like
713
+ * 'agent_provided' — the email is still the one to use.
714
+ */
715
+ interface FulfilmentInfo {
716
+ /** Canonicalized (trimmed, lower-cased) receipt/delivery email. */
717
+ email: string;
718
+ /** 'agent_provided' = the agent passed buyerEmail on this confirm;
719
+ * 'account' = platform default — the buyer's account email. */
720
+ emailSource: 'agent_provided' | 'account' | (string & {});
721
+ }
661
722
  /**
662
723
  * 5.3.0 (astra-pay): sanitized outcome of first-party charge-at-redeem
663
724
  * settlement. Carries NO voucher/instrument material — the settlement channel
@@ -668,9 +729,16 @@ interface VerificationResult {
668
729
  * approves, the platform re-drives the confirm with the SAME
669
730
  * checkoutSessionId and that re-drive carries the settling outcome
670
731
  * (one order row per session — the re-drive claims the same row).
732
+ *
733
+ * 5.5.0: OPEN union — the platform may introduce statuses (e.g.
734
+ * `pending_merchant` for self-settling merchants) ahead of your SDK version.
735
+ * Rule: treat any status you don't recognize as PENDING, never as failed.
736
+ * Also 5.5.0: `no_instrument` on a held/approved session is NON-terminal —
737
+ * the human's approval is NOT consumed; a re-drive with the same
738
+ * checkoutSessionId settles once a card is on file.
671
739
  */
672
740
  interface SettlementOutcomeInfo {
673
- status: 'settled' | 'failed' | 'requires_action' | 'no_instrument' | 'requires_approval';
741
+ status: 'settled' | 'failed' | 'requires_action' | 'no_instrument' | 'requires_approval' | 'pending_merchant' | (string & {});
674
742
  /** First-party order id — the buyer sees the purchase in their AstraSync
675
743
  * dashboard orders view (no public receipt page). */
676
744
  orderId?: string;
@@ -760,6 +828,15 @@ interface VerificationRequest {
760
828
  currency: string;
761
829
  };
762
830
  }>;
831
+ /**
832
+ * 5.6.0 (astra-pay): buyer's receipt/delivery email, forwarded on the
833
+ * confirm leg only. TRANSIT-ONLY fulfilment PII — the platform echoes it
834
+ * back (canonicalized) in `VerificationResult.fulfilment` for first-party
835
+ * merchants and never persists it. When omitted, the platform defaults
836
+ * `fulfilment.email` to the buyer's account email, so supplying this is
837
+ * only needed for an alternate contact (gift delivery etc.).
838
+ */
839
+ buyerEmail?: string;
763
840
  /** Whether this is a sub-agent request */
764
841
  isSubAgentRequest?: boolean;
765
842
  /** Parent agent ID for sub-agent requests */
@@ -1685,6 +1762,21 @@ declare class VerificationGatewayClient {
1685
1762
  * settled/failed/requires_action/no_instrument outcome (+ `orderId`), and the
1686
1763
  * identity/policy/`failures` fields for a denial. On any non-`confirm`/first-
1687
1764
  * party path `settlementOutcome` is simply absent — no money moves.
1765
+ *
1766
+ * 5.5.0 self-settling merchants (settlement_mode='self_settle'): the result
1767
+ * carries `.settlementToken` instead of a completed charge. Charge on your
1768
+ * own integration with Stripe idempotency key `voucher:<token.jti>` and
1769
+ * `metadata: { jti: token.jti, sessionId: token.sessionId }`, then call
1770
+ * `reportSettlement()` with the outcome. Treat any `settlementOutcome.status`
1771
+ * you don't recognize (e.g. `pending_merchant`) as PENDING, never failed.
1772
+ *
1773
+ * 5.6.0 fulfilment contact: first-party confirm results carry
1774
+ * `.fulfilment { email, emailSource }` — the buyer's receipt/delivery
1775
+ * email. You always get one: the platform defaults to the buyer's account
1776
+ * email when no `buyerEmail` was passed. Store it with the pending order;
1777
+ * fulfil against it only once the order is settled / pending_merchant. An
1778
+ * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
1779
+ * account default.
1688
1780
  */
1689
1781
  confirmCheckout(options: {
1690
1782
  astraId?: string;
@@ -1696,9 +1788,34 @@ declare class VerificationGatewayClient {
1696
1788
  currency?: string;
1697
1789
  checkoutSessionId?: string;
1698
1790
  checkoutItems?: VerificationRequest['checkoutItems'];
1791
+ /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
1792
+ * the platform default `fulfilment.email` to the buyer's account email. */
1793
+ buyerEmail?: string;
1699
1794
  counterpartyUrl?: string;
1700
1795
  counterpartyType?: string;
1701
1796
  }): Promise<VerificationResult>;
1797
+ /**
1798
+ * 5.5.0 (astra-pay): report a self-settled charge outcome back to the
1799
+ * platform — the other half of the `settlementToken` contract. Call after
1800
+ * your PaymentIntent reaches a terminal state so the buyer's dashboard,
1801
+ * /orders and the agent's poll surface reconcile. Authenticated with this
1802
+ * client's api key (must be the merchant's own). Amounts must match the
1803
+ * order EXACTLY (integer minor units) or the report is rejected whole
1804
+ * (409 amount_mismatch). Replays of the same terminal state are safe.
1805
+ */
1806
+ reportSettlement(options: {
1807
+ sessionId: string;
1808
+ status: 'settled' | 'declined' | 'failed';
1809
+ amountMinor: number;
1810
+ currency: string;
1811
+ /** Stripe PaymentIntent id — REQUIRED when status is 'settled'. */
1812
+ processorRef?: string;
1813
+ failureCode?: string;
1814
+ }): Promise<{
1815
+ orderId: string;
1816
+ status: string;
1817
+ alreadySettled?: boolean;
1818
+ }>;
1702
1819
  /**
1703
1820
  * Quick verification — checks credentials and policy in one call.
1704
1821
  *
@@ -4641,7 +4758,7 @@ declare function detectRuntime(userAgent: string | undefined | null): string | u
4641
4758
  * silently (never throwing), so this is a no-op there — which is correct:
4642
4759
  * in a browser the page's real UA is the honest identity.
4643
4760
  */
4644
- declare const SDK_USER_AGENT = "astrasync-sdk/5.4.1";
4761
+ declare const SDK_USER_AGENT = "astrasync-sdk/5.6.0";
4645
4762
  declare const sdkFetch: typeof fetch;
4646
4763
 
4647
4764
  /**
@@ -4662,6 +4779,6 @@ declare const sdkFetch: typeof fetch;
4662
4779
  * is fine — bumping both in the release-ceremony commit keeps them
4663
4780
  * lockstep.
4664
4781
  */
4665
- declare const SDK_VERSION = "5.4.1";
4782
+ declare const SDK_VERSION = "5.6.0";
4666
4783
 
4667
- export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, type AttemptOutcome, type AttemptReport, AuthenticationError, type BuildGuidanceParams, CAPTURE_SCHEMA_VERSION, type CallerMetadata, ChallengeHandler, type CommerceArtifactsPayload, type CommerceContext, type CommercePipelineInput, type CommerceShieldProps, type ConsiderationItem, type ConsiderationSet, type CounterpartyType, DEFAULT_EDGE_CONFIG, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, MCP_VERIFIED_HOP_HEADER, MCP_VERIFIED_HOP_MAX_AGE_MS, type McpMiddlewareOptions, type ModelConfig, type NextJsMiddlewareOptions, type ObservedMetadata, type PDLSSConfig$1 as PDLSSConfig, type PDLSSDuration, type PDLSSInfo, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, PLATFORM_AGENT_SIGNATURES, type PendingRegistrationResponse, type PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, clearCache, createMcpMiddleware, degradeToObserve, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, verify };
4784
+ export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, type AttemptOutcome, type AttemptReport, AuthenticationError, type BuildGuidanceParams, CAPTURE_SCHEMA_VERSION, type CallerMetadata, ChallengeHandler, type CommerceArtifactsPayload, type CommerceContext, type CommercePipelineInput, type CommerceShieldProps, type ConsiderationItem, type ConsiderationSet, type CounterpartyType, DEFAULT_EDGE_CONFIG, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, MCP_VERIFIED_HOP_HEADER, MCP_VERIFIED_HOP_MAX_AGE_MS, type McpMiddlewareOptions, type MerchantSettlementToken, type ModelConfig, type NextJsMiddlewareOptions, type ObservedMetadata, type PDLSSConfig$1 as PDLSSConfig, type PDLSSDuration, type PDLSSInfo, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, PLATFORM_AGENT_SIGNATURES, type PendingRegistrationResponse, type PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, clearCache, createMcpMiddleware, degradeToObserve, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, verify };
package/dist/index.d.ts CHANGED
@@ -653,11 +653,72 @@ interface VerificationResult {
653
653
  * instrument on file (steer the user to add one via onboarding).
654
654
  */
655
655
  settlementOutcome?: SettlementOutcomeInfo;
656
+ /**
657
+ * 5.5.0 (astra-pay): interim merchant self-settlement token. Present ONLY
658
+ * for firstParty merchants opted into settlement_mode='self_settle' on the
659
+ * confirm leg — YOUR server charges with this material on the shared Stripe
660
+ * account and reports the outcome via `client.reportSettlement()`.
661
+ * MERCHANT-ONLY lane: never expose it to the agent plane, never log it,
662
+ * never echo it back over the bridge handoff (the bridge strips it
663
+ * defensively). Charge with idempotency key `voucher:<jti>` and
664
+ * `metadata.jti` — that lets the platform webhook auto-reconcile even if
665
+ * your report never arrives.
666
+ */
667
+ settlementToken?: MerchantSettlementToken;
668
+ /**
669
+ * 5.6.0 (astra-pay): fulfilment contact for first-party confirm legs.
670
+ * The platform always resolves an email for the merchant — the agent's
671
+ * `buyerEmail` when one was supplied, else the buyer's account email
672
+ * (`emailSource` says which). Present on every first-party confirm leg that
673
+ * progressed (settled, pending_merchant, held, requires_action) so it can be
674
+ * stored with a pending order; only FULFIL against it once the order is
675
+ * settled / pending_merchant. MERCHANT-ONLY lane like `settlementToken` —
676
+ * the bridge strips it from the agent plane. An explicit `buyerEmail` on the
677
+ * confirm handoff body wins over `fulfilment.email` (the platform default).
678
+ */
679
+ fulfilment?: FulfilmentInfo;
656
680
  /** Timestamp of verification */
657
681
  verifiedAt: Date;
658
682
  /** TTL for this result (seconds) */
659
683
  cacheTtl?: number;
660
684
  }
685
+ /**
686
+ * 5.5.0 (astra-pay): agent-blind settlement token for self-settling
687
+ * first-party merchants. Self-describing via `type`, so a Stripe Shared
688
+ * Payment Token can replace the raw customer/payment-method pair without a
689
+ * contract change.
690
+ */
691
+ interface MerchantSettlementToken {
692
+ type: 'stripe_delegated_charge';
693
+ stripeCustomerId: string;
694
+ stripePaymentMethodId: string;
695
+ /** Integer minor units — money is never a float on the wire. */
696
+ amountMinor: number;
697
+ /** Upper-case ISO-4217. */
698
+ currency: string;
699
+ /** Verification session id — the report-back key. */
700
+ sessionId: string | null;
701
+ /** The pending kya_shop_order row your report resolves. */
702
+ orderId: string;
703
+ /** Settlement spine: charge with Stripe idempotency key `voucher:<jti>`
704
+ * and set `metadata.jti` on the PaymentIntent. */
705
+ jti: string;
706
+ statementSuffix: string | null;
707
+ /** Advisory charge-by bound (ISO); stuck orders are ops-swept after it. */
708
+ expiresAt: string;
709
+ }
710
+ /**
711
+ * 5.6.0 (astra-pay): fulfilment contact block. `emailSource` is an OPEN union
712
+ * (same rule as settlement statuses): treat unknown sources like
713
+ * 'agent_provided' — the email is still the one to use.
714
+ */
715
+ interface FulfilmentInfo {
716
+ /** Canonicalized (trimmed, lower-cased) receipt/delivery email. */
717
+ email: string;
718
+ /** 'agent_provided' = the agent passed buyerEmail on this confirm;
719
+ * 'account' = platform default — the buyer's account email. */
720
+ emailSource: 'agent_provided' | 'account' | (string & {});
721
+ }
661
722
  /**
662
723
  * 5.3.0 (astra-pay): sanitized outcome of first-party charge-at-redeem
663
724
  * settlement. Carries NO voucher/instrument material — the settlement channel
@@ -668,9 +729,16 @@ interface VerificationResult {
668
729
  * approves, the platform re-drives the confirm with the SAME
669
730
  * checkoutSessionId and that re-drive carries the settling outcome
670
731
  * (one order row per session — the re-drive claims the same row).
732
+ *
733
+ * 5.5.0: OPEN union — the platform may introduce statuses (e.g.
734
+ * `pending_merchant` for self-settling merchants) ahead of your SDK version.
735
+ * Rule: treat any status you don't recognize as PENDING, never as failed.
736
+ * Also 5.5.0: `no_instrument` on a held/approved session is NON-terminal —
737
+ * the human's approval is NOT consumed; a re-drive with the same
738
+ * checkoutSessionId settles once a card is on file.
671
739
  */
672
740
  interface SettlementOutcomeInfo {
673
- status: 'settled' | 'failed' | 'requires_action' | 'no_instrument' | 'requires_approval';
741
+ status: 'settled' | 'failed' | 'requires_action' | 'no_instrument' | 'requires_approval' | 'pending_merchant' | (string & {});
674
742
  /** First-party order id — the buyer sees the purchase in their AstraSync
675
743
  * dashboard orders view (no public receipt page). */
676
744
  orderId?: string;
@@ -760,6 +828,15 @@ interface VerificationRequest {
760
828
  currency: string;
761
829
  };
762
830
  }>;
831
+ /**
832
+ * 5.6.0 (astra-pay): buyer's receipt/delivery email, forwarded on the
833
+ * confirm leg only. TRANSIT-ONLY fulfilment PII — the platform echoes it
834
+ * back (canonicalized) in `VerificationResult.fulfilment` for first-party
835
+ * merchants and never persists it. When omitted, the platform defaults
836
+ * `fulfilment.email` to the buyer's account email, so supplying this is
837
+ * only needed for an alternate contact (gift delivery etc.).
838
+ */
839
+ buyerEmail?: string;
763
840
  /** Whether this is a sub-agent request */
764
841
  isSubAgentRequest?: boolean;
765
842
  /** Parent agent ID for sub-agent requests */
@@ -1685,6 +1762,21 @@ declare class VerificationGatewayClient {
1685
1762
  * settled/failed/requires_action/no_instrument outcome (+ `orderId`), and the
1686
1763
  * identity/policy/`failures` fields for a denial. On any non-`confirm`/first-
1687
1764
  * party path `settlementOutcome` is simply absent — no money moves.
1765
+ *
1766
+ * 5.5.0 self-settling merchants (settlement_mode='self_settle'): the result
1767
+ * carries `.settlementToken` instead of a completed charge. Charge on your
1768
+ * own integration with Stripe idempotency key `voucher:<token.jti>` and
1769
+ * `metadata: { jti: token.jti, sessionId: token.sessionId }`, then call
1770
+ * `reportSettlement()` with the outcome. Treat any `settlementOutcome.status`
1771
+ * you don't recognize (e.g. `pending_merchant`) as PENDING, never failed.
1772
+ *
1773
+ * 5.6.0 fulfilment contact: first-party confirm results carry
1774
+ * `.fulfilment { email, emailSource }` — the buyer's receipt/delivery
1775
+ * email. You always get one: the platform defaults to the buyer's account
1776
+ * email when no `buyerEmail` was passed. Store it with the pending order;
1777
+ * fulfil against it only once the order is settled / pending_merchant. An
1778
+ * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
1779
+ * account default.
1688
1780
  */
1689
1781
  confirmCheckout(options: {
1690
1782
  astraId?: string;
@@ -1696,9 +1788,34 @@ declare class VerificationGatewayClient {
1696
1788
  currency?: string;
1697
1789
  checkoutSessionId?: string;
1698
1790
  checkoutItems?: VerificationRequest['checkoutItems'];
1791
+ /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
1792
+ * the platform default `fulfilment.email` to the buyer's account email. */
1793
+ buyerEmail?: string;
1699
1794
  counterpartyUrl?: string;
1700
1795
  counterpartyType?: string;
1701
1796
  }): Promise<VerificationResult>;
1797
+ /**
1798
+ * 5.5.0 (astra-pay): report a self-settled charge outcome back to the
1799
+ * platform — the other half of the `settlementToken` contract. Call after
1800
+ * your PaymentIntent reaches a terminal state so the buyer's dashboard,
1801
+ * /orders and the agent's poll surface reconcile. Authenticated with this
1802
+ * client's api key (must be the merchant's own). Amounts must match the
1803
+ * order EXACTLY (integer minor units) or the report is rejected whole
1804
+ * (409 amount_mismatch). Replays of the same terminal state are safe.
1805
+ */
1806
+ reportSettlement(options: {
1807
+ sessionId: string;
1808
+ status: 'settled' | 'declined' | 'failed';
1809
+ amountMinor: number;
1810
+ currency: string;
1811
+ /** Stripe PaymentIntent id — REQUIRED when status is 'settled'. */
1812
+ processorRef?: string;
1813
+ failureCode?: string;
1814
+ }): Promise<{
1815
+ orderId: string;
1816
+ status: string;
1817
+ alreadySettled?: boolean;
1818
+ }>;
1702
1819
  /**
1703
1820
  * Quick verification — checks credentials and policy in one call.
1704
1821
  *
@@ -4641,7 +4758,7 @@ declare function detectRuntime(userAgent: string | undefined | null): string | u
4641
4758
  * silently (never throwing), so this is a no-op there — which is correct:
4642
4759
  * in a browser the page's real UA is the honest identity.
4643
4760
  */
4644
- declare const SDK_USER_AGENT = "astrasync-sdk/5.4.1";
4761
+ declare const SDK_USER_AGENT = "astrasync-sdk/5.6.0";
4645
4762
  declare const sdkFetch: typeof fetch;
4646
4763
 
4647
4764
  /**
@@ -4662,6 +4779,6 @@ declare const sdkFetch: typeof fetch;
4662
4779
  * is fine — bumping both in the release-ceremony commit keeps them
4663
4780
  * lockstep.
4664
4781
  */
4665
- declare const SDK_VERSION = "5.4.1";
4782
+ declare const SDK_VERSION = "5.6.0";
4666
4783
 
4667
- export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, type AttemptOutcome, type AttemptReport, AuthenticationError, type BuildGuidanceParams, CAPTURE_SCHEMA_VERSION, type CallerMetadata, ChallengeHandler, type CommerceArtifactsPayload, type CommerceContext, type CommercePipelineInput, type CommerceShieldProps, type ConsiderationItem, type ConsiderationSet, type CounterpartyType, DEFAULT_EDGE_CONFIG, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, MCP_VERIFIED_HOP_HEADER, MCP_VERIFIED_HOP_MAX_AGE_MS, type McpMiddlewareOptions, type ModelConfig, type NextJsMiddlewareOptions, type ObservedMetadata, type PDLSSConfig$1 as PDLSSConfig, type PDLSSDuration, type PDLSSInfo, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, PLATFORM_AGENT_SIGNATURES, type PendingRegistrationResponse, type PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, clearCache, createMcpMiddleware, degradeToObserve, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, verify };
4784
+ export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, type AttemptOutcome, type AttemptReport, AuthenticationError, type BuildGuidanceParams, CAPTURE_SCHEMA_VERSION, type CallerMetadata, ChallengeHandler, type CommerceArtifactsPayload, type CommerceContext, type CommercePipelineInput, type CommerceShieldProps, type ConsiderationItem, type ConsiderationSet, type CounterpartyType, DEFAULT_EDGE_CONFIG, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, MCP_VERIFIED_HOP_HEADER, MCP_VERIFIED_HOP_MAX_AGE_MS, type McpMiddlewareOptions, type MerchantSettlementToken, type ModelConfig, type NextJsMiddlewareOptions, type ObservedMetadata, type PDLSSConfig$1 as PDLSSConfig, type PDLSSDuration, type PDLSSInfo, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, PLATFORM_AGENT_SIGNATURES, type PendingRegistrationResponse, type PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, clearCache, createMcpMiddleware, degradeToObserve, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, verify };
package/dist/index.js CHANGED
@@ -112,7 +112,7 @@ function getTrustLevel(score) {
112
112
  }
113
113
 
114
114
  // src/version.ts
115
- var SDK_VERSION = "5.4.1";
115
+ var SDK_VERSION = "5.6.0";
116
116
 
117
117
  // src/http.ts
118
118
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -475,6 +475,7 @@ async function callVerifyAccessAPI(config, request) {
475
475
  if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
476
476
  if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
477
477
  if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
478
+ if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
478
479
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
479
480
  if (requestData.attemptId) body.attemptId = requestData.attemptId;
480
481
  if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
@@ -647,7 +648,12 @@ async function verify(config, request, options) {
647
648
  recommendationReasons: apiResponse.recommendationReasons,
648
649
  stepUpApproval: apiResponse.stepUpApproval,
649
650
  settlement: apiResponse.settlement,
650
- settlementOutcome: apiResponse.settlementOutcome
651
+ settlementOutcome: apiResponse.settlementOutcome,
652
+ // 5.5.0 self-settlement: merchant-only material — passes through to the
653
+ // MERCHANT caller only (bridge callers strip it before the agent plane).
654
+ settlementToken: apiResponse.settlementToken,
655
+ // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
656
+ fulfilment: apiResponse.fulfilment
651
657
  };
652
658
  return result2;
653
659
  }
@@ -705,7 +711,10 @@ async function verify(config, request, options) {
705
711
  warningHeader: apiResponse.warningHeader,
706
712
  stepUpApproval: apiResponse.stepUpApproval,
707
713
  settlement: apiResponse.settlement,
708
- settlementOutcome: apiResponse.settlementOutcome
714
+ settlementOutcome: apiResponse.settlementOutcome,
715
+ settlementToken: apiResponse.settlementToken,
716
+ // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
717
+ fulfilment: apiResponse.fulfilment
709
718
  };
710
719
  if (result.recommendation === "deny") {
711
720
  result.policyAllowed = false;
@@ -2737,6 +2746,21 @@ var VerificationGatewayClient = class {
2737
2746
  * settled/failed/requires_action/no_instrument outcome (+ `orderId`), and the
2738
2747
  * identity/policy/`failures` fields for a denial. On any non-`confirm`/first-
2739
2748
  * party path `settlementOutcome` is simply absent — no money moves.
2749
+ *
2750
+ * 5.5.0 self-settling merchants (settlement_mode='self_settle'): the result
2751
+ * carries `.settlementToken` instead of a completed charge. Charge on your
2752
+ * own integration with Stripe idempotency key `voucher:<token.jti>` and
2753
+ * `metadata: { jti: token.jti, sessionId: token.sessionId }`, then call
2754
+ * `reportSettlement()` with the outcome. Treat any `settlementOutcome.status`
2755
+ * you don't recognize (e.g. `pending_merchant`) as PENDING, never failed.
2756
+ *
2757
+ * 5.6.0 fulfilment contact: first-party confirm results carry
2758
+ * `.fulfilment { email, emailSource }` — the buyer's receipt/delivery
2759
+ * email. You always get one: the platform defaults to the buyer's account
2760
+ * email when no `buyerEmail` was passed. Store it with the pending order;
2761
+ * fulfil against it only once the order is settled / pending_merchant. An
2762
+ * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
2763
+ * account default.
2740
2764
  */
2741
2765
  async confirmCheckout(options) {
2742
2766
  const credentials = {
@@ -2756,6 +2780,7 @@ var VerificationGatewayClient = class {
2756
2780
  commercePhase: "confirm",
2757
2781
  checkoutSessionId: options.checkoutSessionId,
2758
2782
  checkoutItems: options.checkoutItems,
2783
+ buyerEmail: options.buyerEmail,
2759
2784
  counterpartyUrl: options.counterpartyUrl,
2760
2785
  counterpartyType: options.counterpartyType
2761
2786
  },
@@ -2766,6 +2791,32 @@ var VerificationGatewayClient = class {
2766
2791
  )
2767
2792
  );
2768
2793
  }
2794
+ /**
2795
+ * 5.5.0 (astra-pay): report a self-settled charge outcome back to the
2796
+ * platform — the other half of the `settlementToken` contract. Call after
2797
+ * your PaymentIntent reaches a terminal state so the buyer's dashboard,
2798
+ * /orders and the agent's poll surface reconcile. Authenticated with this
2799
+ * client's api key (must be the merchant's own). Amounts must match the
2800
+ * order EXACTLY (integer minor units) or the report is rejected whole
2801
+ * (409 amount_mismatch). Replays of the same terminal state are safe.
2802
+ */
2803
+ async reportSettlement(options) {
2804
+ const base = this.config.apiBaseUrl.replace(/\/+$/, "");
2805
+ const res = await sdkFetch(`${base}/merchant/settlements/report`, {
2806
+ method: "POST",
2807
+ headers: {
2808
+ "Content-Type": "application/json",
2809
+ // Same auth pair as every backend call the SDK makes (verify.ts).
2810
+ ...this.config.apiKey ? { Authorization: `Bearer ${this.config.apiKey}`, "X-API-Key": this.config.apiKey } : {}
2811
+ },
2812
+ body: JSON.stringify(options)
2813
+ });
2814
+ const json = await res.json().catch(() => ({}));
2815
+ if (!res.ok || !json.success || !json.data) {
2816
+ throw new Error(`reportSettlement failed (${res.status}): ${json.error ?? "unknown error"}`);
2817
+ }
2818
+ return json.data;
2819
+ }
2769
2820
  /**
2770
2821
  * Quick verification — checks credentials and policy in one call.
2771
2822
  *