uvd-x402-sdk 2.24.2 → 2.26.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.
@@ -266,7 +266,12 @@ declare function getCorsHeaders(origin?: string): Record<string, string>;
266
266
  interface FacilitatorClientOptions {
267
267
  /** Base URL of the facilitator (default: https://facilitator.ultravioletadao.xyz) */
268
268
  baseUrl?: string;
269
- /** Request timeout in milliseconds (default: 30000) */
269
+ /**
270
+ * Request timeout in milliseconds (default: auto per network).
271
+ * When not set, the client uses per-network defaults from ESCROW_TIMEOUT_MS
272
+ * (960s for Ethereum L1, 90s for L2s, 30s for others).
273
+ * Set explicitly to override per-network auto-detection.
274
+ */
270
275
  timeout?: number;
271
276
  }
272
277
  /**
@@ -292,7 +297,12 @@ interface FacilitatorClientOptions {
292
297
  declare class FacilitatorClient {
293
298
  private readonly baseUrl;
294
299
  private readonly timeout;
300
+ private readonly explicitTimeout;
295
301
  constructor(options?: FacilitatorClientOptions);
302
+ /**
303
+ * Get timeout for a specific network, using per-chain defaults when no explicit timeout was set.
304
+ */
305
+ private getTimeout;
296
306
  /**
297
307
  * Verify a payment with the facilitator
298
308
  *
@@ -1560,6 +1570,12 @@ declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
1560
1570
  * As of 2026-02-03, commerce-payments contracts enforce $100 max per deposit.
1561
1571
  */
1562
1572
  declare const DEPOSIT_LIMIT_USDC = "100000000";
1573
+ /**
1574
+ * Default facilitator request timeout per chain in milliseconds.
1575
+ * Ethereum L1 (~12s blocks) needs much longer than L2s (~2s blocks).
1576
+ * Timeout chain: Client > SDK > Facilitator. The facilitator uses 900s for Ethereum L1.
1577
+ */
1578
+ declare const ESCROW_TIMEOUT_MS: Record<number, number>;
1563
1579
  /**
1564
1580
  * USDC EIP-712 domain name per chain.
1565
1581
  * Most chains use "USD Coin", but some (Celo, Monad, HyperEVM) use "USDC".
@@ -1696,13 +1712,19 @@ interface AdvancedEscrowClientOptions {
1696
1712
  * Chain ID (default: 8453 for Base Mainnet).
1697
1713
  * Supported chains: 8453 (Base), 84532 (Base Sepolia), 1 (Ethereum),
1698
1714
  * 11155111 (Ethereum Sepolia), 137 (Polygon), 42161 (Arbitrum),
1699
- * 42220 (Celo), 143 (Monad), 43114 (Avalanche).
1715
+ * 10 (Optimism), 42220 (Celo), 143 (Monad), 43114 (Avalanche).
1700
1716
  */
1701
1717
  chainId?: number;
1702
1718
  /** Contract addresses (auto-resolved from chainId if not provided) */
1703
1719
  contracts?: AdvancedEscrowContracts;
1704
1720
  /** Gas limit for transactions (default: 300000) */
1705
1721
  gasLimit?: number;
1722
+ /**
1723
+ * Request timeout in milliseconds for facilitator HTTP calls (authorize, gasless release/refund).
1724
+ * Default is per-network: 960s for Ethereum L1, 90s for L2s.
1725
+ * Ethereum L1 confirmations can take several minutes under congestion.
1726
+ */
1727
+ timeout?: number;
1706
1728
  }
1707
1729
  /**
1708
1730
  * Minimal PaymentOperator ABI for the 4 on-chain functions.
@@ -1715,7 +1737,7 @@ declare const OPERATOR_ABI: string[];
1715
1737
  *
1716
1738
  * Supported chains: Base (8453), Base Sepolia (84532), Ethereum (1),
1717
1739
  * Ethereum Sepolia (11155111), Polygon (137), Arbitrum (42161),
1718
- * Celo (42220), Monad (143), Avalanche (43114).
1740
+ * Optimism (10), Celo (42220), Monad (143), Avalanche (43114).
1719
1741
  *
1720
1742
  * Contract addresses are auto-resolved from the chain ID.
1721
1743
  * Pass custom contracts to override.
@@ -1752,6 +1774,7 @@ declare class AdvancedEscrowClient {
1752
1774
  private facilitatorUrl;
1753
1775
  private chainId;
1754
1776
  private gasLimit;
1777
+ private readonly timeout;
1755
1778
  private contracts;
1756
1779
  private signer;
1757
1780
  private payerAddress;
@@ -1904,4 +1927,4 @@ declare class AdvancedEscrowClient {
1904
1927
  refundPostEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string, tokenCollector?: string, collectorData?: string): Promise<AdvancedTransactionResult>;
1905
1928
  }
1906
1929
 
1907
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, type MetadataEntryParam, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
1930
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, type MetadataEntryParam, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
@@ -266,7 +266,12 @@ declare function getCorsHeaders(origin?: string): Record<string, string>;
266
266
  interface FacilitatorClientOptions {
267
267
  /** Base URL of the facilitator (default: https://facilitator.ultravioletadao.xyz) */
268
268
  baseUrl?: string;
269
- /** Request timeout in milliseconds (default: 30000) */
269
+ /**
270
+ * Request timeout in milliseconds (default: auto per network).
271
+ * When not set, the client uses per-network defaults from ESCROW_TIMEOUT_MS
272
+ * (960s for Ethereum L1, 90s for L2s, 30s for others).
273
+ * Set explicitly to override per-network auto-detection.
274
+ */
270
275
  timeout?: number;
271
276
  }
272
277
  /**
@@ -292,7 +297,12 @@ interface FacilitatorClientOptions {
292
297
  declare class FacilitatorClient {
293
298
  private readonly baseUrl;
294
299
  private readonly timeout;
300
+ private readonly explicitTimeout;
295
301
  constructor(options?: FacilitatorClientOptions);
302
+ /**
303
+ * Get timeout for a specific network, using per-chain defaults when no explicit timeout was set.
304
+ */
305
+ private getTimeout;
296
306
  /**
297
307
  * Verify a payment with the facilitator
298
308
  *
@@ -1560,6 +1570,12 @@ declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
1560
1570
  * As of 2026-02-03, commerce-payments contracts enforce $100 max per deposit.
1561
1571
  */
1562
1572
  declare const DEPOSIT_LIMIT_USDC = "100000000";
1573
+ /**
1574
+ * Default facilitator request timeout per chain in milliseconds.
1575
+ * Ethereum L1 (~12s blocks) needs much longer than L2s (~2s blocks).
1576
+ * Timeout chain: Client > SDK > Facilitator. The facilitator uses 900s for Ethereum L1.
1577
+ */
1578
+ declare const ESCROW_TIMEOUT_MS: Record<number, number>;
1563
1579
  /**
1564
1580
  * USDC EIP-712 domain name per chain.
1565
1581
  * Most chains use "USD Coin", but some (Celo, Monad, HyperEVM) use "USDC".
@@ -1696,13 +1712,19 @@ interface AdvancedEscrowClientOptions {
1696
1712
  * Chain ID (default: 8453 for Base Mainnet).
1697
1713
  * Supported chains: 8453 (Base), 84532 (Base Sepolia), 1 (Ethereum),
1698
1714
  * 11155111 (Ethereum Sepolia), 137 (Polygon), 42161 (Arbitrum),
1699
- * 42220 (Celo), 143 (Monad), 43114 (Avalanche).
1715
+ * 10 (Optimism), 42220 (Celo), 143 (Monad), 43114 (Avalanche).
1700
1716
  */
1701
1717
  chainId?: number;
1702
1718
  /** Contract addresses (auto-resolved from chainId if not provided) */
1703
1719
  contracts?: AdvancedEscrowContracts;
1704
1720
  /** Gas limit for transactions (default: 300000) */
1705
1721
  gasLimit?: number;
1722
+ /**
1723
+ * Request timeout in milliseconds for facilitator HTTP calls (authorize, gasless release/refund).
1724
+ * Default is per-network: 960s for Ethereum L1, 90s for L2s.
1725
+ * Ethereum L1 confirmations can take several minutes under congestion.
1726
+ */
1727
+ timeout?: number;
1706
1728
  }
1707
1729
  /**
1708
1730
  * Minimal PaymentOperator ABI for the 4 on-chain functions.
@@ -1715,7 +1737,7 @@ declare const OPERATOR_ABI: string[];
1715
1737
  *
1716
1738
  * Supported chains: Base (8453), Base Sepolia (84532), Ethereum (1),
1717
1739
  * Ethereum Sepolia (11155111), Polygon (137), Arbitrum (42161),
1718
- * Celo (42220), Monad (143), Avalanche (43114).
1740
+ * Optimism (10), Celo (42220), Monad (143), Avalanche (43114).
1719
1741
  *
1720
1742
  * Contract addresses are auto-resolved from the chain ID.
1721
1743
  * Pass custom contracts to override.
@@ -1752,6 +1774,7 @@ declare class AdvancedEscrowClient {
1752
1774
  private facilitatorUrl;
1753
1775
  private chainId;
1754
1776
  private gasLimit;
1777
+ private readonly timeout;
1755
1778
  private contracts;
1756
1779
  private signer;
1757
1780
  private payerAddress;
@@ -1904,4 +1927,4 @@ declare class AdvancedEscrowClient {
1904
1927
  refundPostEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string, tokenCollector?: string, collectorData?: string): Promise<AdvancedTransactionResult>;
1905
1928
  }
1906
1929
 
1907
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, type MetadataEntryParam, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
1930
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, type MetadataEntryParam, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
@@ -954,10 +954,26 @@ function getCorsHeaders(origin = "*") {
954
954
  var FacilitatorClient = class {
955
955
  baseUrl;
956
956
  timeout;
957
+ explicitTimeout;
957
958
  constructor(options = {}) {
958
959
  this.baseUrl = options.baseUrl || "https://facilitator.ultravioletadao.xyz";
960
+ this.explicitTimeout = options.timeout !== void 0;
959
961
  this.timeout = options.timeout || 3e4;
960
962
  }
963
+ /**
964
+ * Get timeout for a specific network, using per-chain defaults when no explicit timeout was set.
965
+ */
966
+ getTimeout(network) {
967
+ if (this.explicitTimeout) return this.timeout;
968
+ if (!network) return this.timeout;
969
+ const match = network.match(/^eip155:(\d+)$/);
970
+ if (match) {
971
+ const chainId = parseInt(match[1], 10);
972
+ return ESCROW_TIMEOUT_MS[chainId] || this.timeout;
973
+ }
974
+ if (network === "ethereum" || network === "ethereum-mainnet") return ESCROW_TIMEOUT_MS[1];
975
+ return this.timeout;
976
+ }
961
977
  /**
962
978
  * Verify a payment with the facilitator
963
979
  *
@@ -1006,8 +1022,9 @@ var FacilitatorClient = class {
1006
1022
  */
1007
1023
  async settle(paymentHeader, requirements) {
1008
1024
  const body = buildSettleRequest(paymentHeader, requirements);
1025
+ const settleTimeout = this.getTimeout(requirements.network);
1009
1026
  const controller = new AbortController();
1010
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
1027
+ const timeoutId = setTimeout(() => controller.abort(), settleTimeout);
1011
1028
  try {
1012
1029
  const response = await fetch(`${this.baseUrl}/settle`, {
1013
1030
  method: "POST",
@@ -2474,6 +2491,29 @@ function buildErc8004PaymentRequirements(options) {
2474
2491
  var PAYMENT_INFO_TYPEHASH = "0xae68ac7ce30c86ece8196b61a7c486d8f0061f575037fbd34e7fe4e2820c6591";
2475
2492
  var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
2476
2493
  var DEPOSIT_LIMIT_USDC = "100000000";
2494
+ var ESCROW_TIMEOUT_MS = {
2495
+ 1: 96e4,
2496
+ // Ethereum L1: 960s (facilitator uses 900s TxWatcher)
2497
+ 11155111: 96e4,
2498
+ // Ethereum Sepolia: same as L1
2499
+ 137: 9e4,
2500
+ // Polygon: 90s
2501
+ 8453: 9e4,
2502
+ // Base: 90s
2503
+ 84532: 9e4,
2504
+ // Base Sepolia: 90s
2505
+ 42161: 9e4,
2506
+ // Arbitrum: 90s
2507
+ 10: 9e4,
2508
+ // Optimism: 90s
2509
+ 43114: 9e4,
2510
+ // Avalanche: 90s
2511
+ 42220: 9e4,
2512
+ // Celo: 90s
2513
+ 143: 9e4
2514
+ // Monad: 90s
2515
+ };
2516
+ var DEFAULT_ESCROW_TIMEOUT_MS = 3e4;
2477
2517
  var USDC_DOMAIN_NAME = {
2478
2518
  8453: "USD Coin",
2479
2519
  // Base Mainnet
@@ -2522,13 +2562,13 @@ var ESCROW_CONTRACTS = {
2522
2562
  refundRequest: "0xc1256Bb30bd0cdDa07D8C8Cf67a59105f2EA1b98",
2523
2563
  usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
2524
2564
  },
2525
- // Ethereum Mainnet (chain 1)
2565
+ // Ethereum Mainnet (chain 1) - Updated from Ali's redeploy (commit e6cf29d)
2526
2566
  1: {
2527
- operator: "0xed02d3E5167BCc9582D851885A89b050AB816a56",
2528
- escrow: "0xc1256Bb30bd0cdDa07D8C8Cf67a59105f2EA1b98",
2529
- tokenCollector: "0xE78648e7af7B1BaDE717FF6E410B922F92adE80f",
2530
- protocolFeeConfig: "0xb33D6502EdBbC47201cd1E53C49d703EC0a660b8",
2531
- refundRequest: "0xc9BbA6A2CF9838e7Dd8c19BC8B3BAC620B9D8178",
2567
+ operator: "0x69B67962ffb7c5C7078ff348a87DF604dfA8001b",
2568
+ escrow: "0x9D4146EF898c8E60B3e865AE254ef438E7cEd2A0",
2569
+ tokenCollector: "0x206D4DbB6E7b876e4B5EFAAD2a04e7d7813FB6ba",
2570
+ protocolFeeConfig: "0x5b3e33791C1764cF7e2573Bf8116F1D361FD97Cd",
2571
+ refundRequest: "0xFa8C4Cb156053b867Ae7489220A29b5939E3Df70",
2532
2572
  usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
2533
2573
  },
2534
2574
  // Polygon (chain 137)
@@ -2612,6 +2652,7 @@ var AdvancedEscrowClient = class {
2612
2652
  facilitatorUrl;
2613
2653
  chainId;
2614
2654
  gasLimit;
2655
+ timeout;
2615
2656
  contracts;
2616
2657
  signer;
2617
2658
  // ethers.Signer
@@ -2621,6 +2662,7 @@ var AdvancedEscrowClient = class {
2621
2662
  this.facilitatorUrl = (options.facilitatorUrl || "https://facilitator.ultravioletadao.xyz").replace(/\/$/, "");
2622
2663
  this.chainId = options.chainId || 8453;
2623
2664
  this.gasLimit = options.gasLimit || 3e5;
2665
+ this.timeout = options.timeout || ESCROW_TIMEOUT_MS[this.chainId] || DEFAULT_ESCROW_TIMEOUT_MS;
2624
2666
  if (options.contracts) {
2625
2667
  this.contracts = options.contracts;
2626
2668
  } else {
@@ -2800,21 +2842,44 @@ var AdvancedEscrowClient = class {
2800
2842
  }
2801
2843
  }
2802
2844
  };
2803
- const response = await fetch(`${this.facilitatorUrl}/settle`, {
2804
- method: "POST",
2805
- headers: { "Content-Type": "application/json" },
2806
- body: JSON.stringify(payload)
2807
- });
2808
- const result = await response.json();
2809
- if (result.success) {
2810
- return {
2811
- success: true,
2812
- transactionHash: result.transaction,
2813
- paymentInfo,
2814
- salt: paymentInfo.salt
2815
- };
2845
+ const controller = new AbortController();
2846
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2847
+ try {
2848
+ const response = await fetch(`${this.facilitatorUrl}/settle`, {
2849
+ method: "POST",
2850
+ headers: { "Content-Type": "application/json" },
2851
+ body: JSON.stringify(payload),
2852
+ signal: controller.signal
2853
+ });
2854
+ clearTimeout(timeoutId);
2855
+ const result = await response.json();
2856
+ if (result.success) {
2857
+ return {
2858
+ success: true,
2859
+ transactionHash: result.transaction,
2860
+ paymentInfo,
2861
+ salt: paymentInfo.salt
2862
+ };
2863
+ }
2864
+ return { success: false, error: result.errorReason };
2865
+ } catch (fetchErr) {
2866
+ clearTimeout(timeoutId);
2867
+ if (fetchErr.name === "AbortError") {
2868
+ try {
2869
+ const state = await this.queryEscrowState(paymentInfo);
2870
+ if (state.capturableAmount && BigInt(state.capturableAmount) > 0n) {
2871
+ return {
2872
+ success: true,
2873
+ paymentInfo,
2874
+ salt: paymentInfo.salt
2875
+ };
2876
+ }
2877
+ } catch {
2878
+ }
2879
+ return { success: false, error: `Authorize timed out after ${this.timeout}ms. On-chain state could not confirm escrow lock.` };
2880
+ }
2881
+ throw fetchErr;
2816
2882
  }
2817
- return { success: false, error: result.errorReason };
2818
2883
  } catch (e) {
2819
2884
  return { success: false, error: e.message || String(e) };
2820
2885
  }
@@ -2930,19 +2995,38 @@ var AdvancedEscrowClient = class {
2930
2995
  }
2931
2996
  }
2932
2997
  };
2933
- const response = await fetch(`${this.facilitatorUrl}/settle`, {
2934
- method: "POST",
2935
- headers: { "Content-Type": "application/json" },
2936
- body: JSON.stringify(payload)
2937
- });
2938
- const result = await response.json();
2939
- if (result.success) {
2940
- return {
2941
- success: true,
2942
- transactionHash: result.transaction || result.transactionHash || result.transaction_hash
2943
- };
2998
+ const controller = new AbortController();
2999
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
3000
+ try {
3001
+ const response = await fetch(`${this.facilitatorUrl}/settle`, {
3002
+ method: "POST",
3003
+ headers: { "Content-Type": "application/json" },
3004
+ body: JSON.stringify(payload),
3005
+ signal: controller.signal
3006
+ });
3007
+ clearTimeout(timeoutId);
3008
+ const result = await response.json();
3009
+ if (result.success) {
3010
+ return {
3011
+ success: true,
3012
+ transactionHash: result.transaction || result.transactionHash || result.transaction_hash
3013
+ };
3014
+ }
3015
+ return { success: false, error: result.errorReason || result.error || "Release failed" };
3016
+ } catch (fetchErr) {
3017
+ clearTimeout(timeoutId);
3018
+ if (fetchErr.name === "AbortError") {
3019
+ try {
3020
+ const state = await this.queryEscrowState(paymentInfo);
3021
+ if (state.capturableAmount === "0" && state.hasCollectedPayment) {
3022
+ return { success: true };
3023
+ }
3024
+ } catch {
3025
+ }
3026
+ return { success: false, error: `Gasless release timed out after ${this.timeout}ms. Check escrow state on-chain.` };
3027
+ }
3028
+ throw fetchErr;
2944
3029
  }
2945
- return { success: false, error: result.errorReason || result.error || "Release failed" };
2946
3030
  } catch (e) {
2947
3031
  return { success: false, error: e.message || String(e) };
2948
3032
  }
@@ -3001,19 +3085,38 @@ var AdvancedEscrowClient = class {
3001
3085
  }
3002
3086
  }
3003
3087
  };
3004
- const response = await fetch(`${this.facilitatorUrl}/settle`, {
3005
- method: "POST",
3006
- headers: { "Content-Type": "application/json" },
3007
- body: JSON.stringify(payload)
3008
- });
3009
- const result = await response.json();
3010
- if (result.success) {
3011
- return {
3012
- success: true,
3013
- transactionHash: result.transaction || result.transactionHash || result.transaction_hash
3014
- };
3088
+ const controller = new AbortController();
3089
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
3090
+ try {
3091
+ const response = await fetch(`${this.facilitatorUrl}/settle`, {
3092
+ method: "POST",
3093
+ headers: { "Content-Type": "application/json" },
3094
+ body: JSON.stringify(payload),
3095
+ signal: controller.signal
3096
+ });
3097
+ clearTimeout(timeoutId);
3098
+ const result = await response.json();
3099
+ if (result.success) {
3100
+ return {
3101
+ success: true,
3102
+ transactionHash: result.transaction || result.transactionHash || result.transaction_hash
3103
+ };
3104
+ }
3105
+ return { success: false, error: result.errorReason || result.error || "Refund failed" };
3106
+ } catch (fetchErr) {
3107
+ clearTimeout(timeoutId);
3108
+ if (fetchErr.name === "AbortError") {
3109
+ try {
3110
+ const state = await this.queryEscrowState(paymentInfo);
3111
+ if (state.refundableAmount === "0") {
3112
+ return { success: true };
3113
+ }
3114
+ } catch {
3115
+ }
3116
+ return { success: false, error: `Gasless refund timed out after ${this.timeout}ms. Check escrow state on-chain.` };
3117
+ }
3118
+ throw fetchErr;
3015
3119
  }
3016
- return { success: false, error: result.errorReason || result.error || "Refund failed" };
3017
3120
  } catch (e) {
3018
3121
  return { success: false, error: e.message || String(e) };
3019
3122
  }
@@ -3172,6 +3275,7 @@ exports.DEPOSIT_LIMIT_USDC = DEPOSIT_LIMIT_USDC;
3172
3275
  exports.ERC8004_CONTRACTS = ERC8004_CONTRACTS;
3173
3276
  exports.ERC8004_EXTENSION_ID = ERC8004_EXTENSION_ID;
3174
3277
  exports.ESCROW_CONTRACTS = ESCROW_CONTRACTS;
3278
+ exports.ESCROW_TIMEOUT_MS = ESCROW_TIMEOUT_MS;
3175
3279
  exports.Erc8004Client = Erc8004Client;
3176
3280
  exports.EscrowClient = EscrowClient;
3177
3281
  exports.FacilitatorClient = FacilitatorClient;