@atumlabs/payment-gateway-client 1.0.2 → 2.0.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.
package/dist/index.d.ts CHANGED
@@ -102,10 +102,9 @@ type AuthorizationResult = {
102
102
  };
103
103
  /**
104
104
  * Machine-readable error code (present when status is error or timeout).
105
- * The counterparty and webhook codes (COUNTERPARTY_NOT_FOUND, COUNTERPARTY_TIMEOUT,
106
- * WEBHOOK_ERROR, WEBHOOK_CONNECTION_ERROR, INTERNAL_ERROR) mirror the AuthorizationErrorCode
107
- * protobuf enum. GATEWAY_TIMEOUT, PROOF_INVALID, and PROOF_STALE are produced by payment-gw
108
- * itself and have no protobuf equivalent.
105
+ * Counterparty-sourced codes are derived from the error code the
106
+ * Counterparty Gateway publishes. GATEWAY_TIMEOUT, PROOF_INVALID, and
107
+ * PROOF_STALE are payment-gw-specific (no counterparty envelope corresponds).
109
108
  *
110
109
  */
111
110
  error_code?: 'COUNTERPARTY_NOT_FOUND' | 'COUNTERPARTY_TIMEOUT' | 'WEBHOOK_ERROR' | 'WEBHOOK_CONNECTION_ERROR' | 'INTERNAL_ERROR' | 'GATEWAY_TIMEOUT' | 'PROOF_INVALID' | 'PROOF_STALE';
@@ -126,10 +125,9 @@ type AuthorizationResult = {
126
125
  type status = 'authorized' | 'declined' | 'error' | 'timeout';
127
126
  /**
128
127
  * Machine-readable error code (present when status is error or timeout).
129
- * The counterparty and webhook codes (COUNTERPARTY_NOT_FOUND, COUNTERPARTY_TIMEOUT,
130
- * WEBHOOK_ERROR, WEBHOOK_CONNECTION_ERROR, INTERNAL_ERROR) mirror the AuthorizationErrorCode
131
- * protobuf enum. GATEWAY_TIMEOUT, PROOF_INVALID, and PROOF_STALE are produced by payment-gw
132
- * itself and have no protobuf equivalent.
128
+ * Counterparty-sourced codes are derived from the error code the
129
+ * Counterparty Gateway publishes. GATEWAY_TIMEOUT, PROOF_INVALID, and
130
+ * PROOF_STALE are payment-gw-specific (no counterparty envelope corresponds).
133
131
  *
134
132
  */
135
133
  type error_code = 'COUNTERPARTY_NOT_FOUND' | 'COUNTERPARTY_TIMEOUT' | 'WEBHOOK_ERROR' | 'WEBHOOK_CONNECTION_ERROR' | 'INTERNAL_ERROR' | 'GATEWAY_TIMEOUT' | 'PROOF_INVALID' | 'PROOF_STALE';
@@ -498,12 +496,11 @@ type status2 = 'pending' | 'completed' | 'failed' | 'cancelled';
498
496
  */
499
497
  type PaymentError = {
500
498
  /**
501
- * Machine-readable error code in SCREAMING_SNAKE_CASE.
499
+ * Public error category in SCREAMING_SNAKE_CASE.
502
500
  * Common codes:
503
- * - `QUOTE_DEADLINE_EXPIRED`: No settlement quotes received in time
504
- * - `QUOTE_SELECTION_FAILED`: Quotes received but none met requirements
505
- * - `INSUFFICIENT_FUNDS`: Sender wallet has insufficient balance
506
- * - `FULFILLMENT_TIMEOUT`: Settlement agent didn't complete in time
501
+ * - `SETTLEMENT_FAILED`: The settlement could not be completed
502
+ * - `NO_ROUTE_AVAILABLE`: No settlement route was available
503
+ * - `INTERNAL_ERROR`: An unexpected error occurred
507
504
  *
508
505
  */
509
506
  code: string;
@@ -749,7 +746,7 @@ type TimelineError = {
749
746
  };
750
747
  type TimelineStep = {
751
748
  /**
752
- * Name of the step
749
+ * Internal name of the step (matches settlement event type)
753
750
  */
754
751
  name: string;
755
752
  /**
@@ -799,11 +796,30 @@ type TimelineStep = {
799
796
  *
800
797
  */
801
798
  type status4 = 'completed' | 'in_progress' | 'pending' | 'failed' | 'skipped';
799
+ /**
800
+ * Safe, outward-facing error. Derived from an internal error through the shared error catalog. The public code identifies the category and the message is a curated, safe description.
801
+ */
802
802
  type ErrorResponse = {
803
803
  /**
804
- * Error message
804
+ * Public, machine-readable error category in SCREAMING_SNAKE_CASE.
805
+ */
806
+ code: string;
807
+ /**
808
+ * Curated, safe, human-readable message.
809
+ */
810
+ message: string;
811
+ /**
812
+ * Correlation id to quote to support to locate the internal error record.
805
813
  */
806
- error?: string;
814
+ request_id?: string;
815
+ /**
816
+ * Link to the documentation page for this public code.
817
+ */
818
+ docs_url?: string;
819
+ /**
820
+ * Originating service domain.
821
+ */
822
+ domain?: string;
807
823
  };
808
824
  /**
809
825
  * Request body for opening a quote-request batch. Structurally the existing PaymentRequest
@@ -1083,7 +1099,9 @@ type QuoteRequestStatusResponse = {
1083
1099
  /**
1084
1100
  * Derived batch lifecycle, computed at read time (not a stored state machine). Disjoint
1085
1101
  * from the payment-status enum returned by the award and payment-status endpoints.
1086
- * - `collecting` — collection window in progress; `quotes` absent.
1102
+ * - `collecting` — collection window still open; `quotes` lists those collected so far
1103
+ * (a quote is awardable from arrival, by its own `award_deadline`; more may arrive until
1104
+ * `collection_close`).
1087
1105
  * - `ready` — collection complete; none awarded yet; either at least one quote is still
1088
1106
  * within its `award_deadline`, or no settler bid (empty `quotes` array — the successful
1089
1107
  * "no quotes available" result).
@@ -1095,7 +1113,7 @@ type QuoteRequestStatusResponse = {
1095
1113
  */
1096
1114
  status: 'collecting' | 'ready' | 'awarded' | 'expired';
1097
1115
  /**
1098
- * Collected quotes with award linkage. Absent while status is `collecting`.
1116
+ * Collected quotes with award linkage — those collected so far while `collecting`, the full set once the window closes.
1099
1117
  */
1100
1118
  quotes?: Array<AwardedQuote>;
1101
1119
  /**
@@ -1106,7 +1124,9 @@ type QuoteRequestStatusResponse = {
1106
1124
  /**
1107
1125
  * Derived batch lifecycle, computed at read time (not a stored state machine). Disjoint
1108
1126
  * from the payment-status enum returned by the award and payment-status endpoints.
1109
- * - `collecting` — collection window in progress; `quotes` absent.
1127
+ * - `collecting` — collection window still open; `quotes` lists those collected so far
1128
+ * (a quote is awardable from arrival, by its own `award_deadline`; more may arrive until
1129
+ * `collection_close`).
1110
1130
  * - `ready` — collection complete; none awarded yet; either at least one quote is still
1111
1131
  * within its `award_deadline`, or no settler bid (empty `quotes` array — the successful
1112
1132
  * "no quotes available" result).
@@ -1294,10 +1314,26 @@ type $OpenApiTs = {
1294
1314
  * Invalid request
1295
1315
  */
1296
1316
  400: ErrorResponse;
1317
+ /**
1318
+ * Signature or sender authorization could not be verified
1319
+ */
1320
+ 401: ErrorResponse;
1321
+ /**
1322
+ * Payment declined during counterparty authorization
1323
+ */
1324
+ 403: ErrorResponse;
1325
+ /**
1326
+ * Payment request too large to process
1327
+ */
1328
+ 413: ErrorResponse;
1297
1329
  /**
1298
1330
  * Internal server error
1299
1331
  */
1300
1332
  500: ErrorResponse;
1333
+ /**
1334
+ * A dependency is temporarily unavailable
1335
+ */
1336
+ 503: ErrorResponse;
1301
1337
  };
1302
1338
  };
1303
1339
  };
@@ -1397,6 +1433,10 @@ type $OpenApiTs = {
1397
1433
  * Counterparty not found (no registration for the resolved DID)
1398
1434
  */
1399
1435
  404: ErrorResponse;
1436
+ /**
1437
+ * Internal server error
1438
+ */
1439
+ 500: ErrorResponse;
1400
1440
  /**
1401
1441
  * Counterparty webhook error (HTTP error or connection failure)
1402
1442
  */
@@ -1695,6 +1735,25 @@ declare class PaymentGatewayClient$1 {
1695
1735
  constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor$1);
1696
1736
  }
1697
1737
 
1738
+ /**
1739
+ * Chain defaults returned by the payment gateway /defaults endpoint.
1740
+ */
1741
+ interface ChainDefaults {
1742
+ escrowContract: string;
1743
+ quoteSelector: string;
1744
+ fulfillmentVerifierAccount: string;
1745
+ fulfillmentVerifierEndpoint: string;
1746
+ fulfillmentProxy: string;
1747
+ permit2Contract?: string;
1748
+ /**
1749
+ * V3 Solana escrow domain-separation fields, surfaced by payment-gw
1750
+ * `/defaults` for Solana source chains. Used to build the EscrowDomain that the
1751
+ * V3 deposit hash binds to. Absent for EVM/Tron.
1752
+ */
1753
+ svmSignatureClusterId?: string;
1754
+ svmSignatureDomainVersion?: number;
1755
+ }
1756
+
1698
1757
  interface Logger {
1699
1758
  debug(obj: unknown, msg?: string): void;
1700
1759
  info(obj: unknown, msg?: string): void;
@@ -1737,124 +1796,6 @@ interface Meter {
1737
1796
  /** Reads the cluster's on-chain unix timestamp (seconds) from an RPC endpoint. */
1738
1797
  type SolanaClusterUnixTimeReader = (rpcUrl: string, timeoutMs: number) => Promise<bigint>;
1739
1798
 
1740
- /**
1741
- * Chain defaults returned by the payment gateway /defaults endpoint.
1742
- */
1743
- interface ChainDefaults {
1744
- escrowContract: string;
1745
- quoteSelector: string;
1746
- fulfillmentVerifierAccount: string;
1747
- fulfillmentVerifierEndpoint: string;
1748
- fulfillmentProxy: string;
1749
- permit2Contract?: string;
1750
- /**
1751
- * V3 Solana escrow domain-separation fields, surfaced by payment-gw
1752
- * `/defaults` for Solana source chains. Used to build the EscrowDomain that the
1753
- * V3 deposit hash binds to. Absent for EVM/Tron.
1754
- */
1755
- svmSignatureClusterId?: string;
1756
- svmSignatureDomainVersion?: number;
1757
- }
1758
- /**
1759
- * Result of building a sender auth message for a specific chain.
1760
- */
1761
- interface AuthMessageResult {
1762
- messageScheme: SenderAuthMessageScheme;
1763
- messageHash: string;
1764
- messagePrehash: string;
1765
- }
1766
- /**
1767
- * Chain-specific overrides for the request-body contract fields
1768
- * (`quote_selector`, `fulfillment_verifier`). Some chains must rewrite the raw
1769
- * /defaults values before they go on the wire — e.g. Tron normalizes base58
1770
- * (`T…`) addresses to the canonical 20-byte hex the on-chain verifier and the
1771
- * signed permit witness use. A chain that needs no rewrite returns undefined
1772
- * and the caller falls back to the raw defaults. Applied identically on the
1773
- * payment and quote paths, so their contract fields never diverge.
1774
- */
1775
- interface ContractFieldOverrides {
1776
- quote_selector?: string;
1777
- fulfillment_verifier?: {
1778
- account: string;
1779
- endpoint: string;
1780
- };
1781
- }
1782
- /**
1783
- * Chain adapter that handles all chain-specific logic:
1784
- * message building (SDK), key formatting, and signing (CLI).
1785
- */
1786
- interface ChainAdapter {
1787
- /**
1788
- * Turnkey account address format (e.g. `ADDRESS_FORMAT_ETHEREUM`), used to map a
1789
- * wallet account back to this chain's namespace.
1790
- */
1791
- turnkeyAddressFormat: string;
1792
- /**
1793
- * Build the sender_auth message (hash + prehash). May be async: the Solana
1794
- * adapter reads the on-chain cluster clock to ground `issued_at`.
1795
- */
1796
- buildAuthMessage(params: {
1797
- sourceAsset: string;
1798
- depositor: string;
1799
- fulfillmentAmount: string;
1800
- requestId: string;
1801
- sourceDefaults: ChainDefaults;
1802
- deadlineSeconds?: number;
1803
- /** Solana-only: override the RPC used to read the cluster clock for issued_at. */
1804
- solanaRpcUrl?: string;
1805
- /** Solana-only: injectable clock reader, primarily a test seam. */
1806
- solanaClockReader?: SolanaClusterUnixTimeReader;
1807
- /** Solana-only: optional logger; warns if the cluster clock read fails and issued_at falls back to the wall clock. */
1808
- solanaLogger?: Logger;
1809
- }): Promise<AuthMessageResult>;
1810
- /**
1811
- * Resolve chain-specific overrides for the request-body contract fields
1812
- * (`quote_selector`, `fulfillment_verifier`). Both preparePaymentRequest and
1813
- * prepareQuoteRequest resolve these fields through this one method, so the
1814
- * payment and quote paths always carry byte-identical contract fields.
1815
- * Returns undefined when the chain needs no rewrite (EVM); Tron normalizes
1816
- * base58 → canonical hex.
1817
- */
1818
- resolveContractOverrides?(sourceDefaults: ChainDefaults): ContractFieldOverrides | undefined;
1819
- /** Normalize private key format for this chain. */
1820
- formatPrivateKey(key: string): string;
1821
- /**
1822
- * Reject a malformed raw key value-free (throwing `Invalid private key`)
1823
- * before it reaches the chain's signing library. Chains whose key decoding
1824
- * already fails without echoing the key (e.g. Solana's bs58/length checks)
1825
- * omit this; EVM/Tron implement it because `ethers.Wallet` embeds the key
1826
- * value verbatim in its error for malformed input.
1827
- */
1828
- validatePrivateKey?(key: string): void;
1829
- /**
1830
- * Sign a sender-auth signed_messages[i] entry, returning a 0x-prefixed
1831
- * hex signature. The adapter chooses the appropriate signing scheme
1832
- * based on its chain:
1833
- * - EVM: EIP-712 typed-data signing over signedMessage.message_prehash
1834
- * (which is shaped to be a direct ethers.signTypedData arg set).
1835
- * - Tron: TIP-712 typed-data signing (chain-specific quirks).
1836
- * - Solana: ed25519 over a chain-specific canonicalized digest.
1837
- */
1838
- sign(signedMessage: SignedMessage, privateKey: string): Promise<string>;
1839
- /**
1840
- * Derive the base58 public key of the signing key, for chains whose signatures
1841
- * are NOT public-key-recoverable and must therefore ship the signer's pubkey
1842
- * alongside the signature. Solana (Ed25519) implements this; EVM/Tron do not
1843
- * (secp256k1 signatures are recoverable via ecrecover, so the verifier derives
1844
- * the signer from the signature itself). The result is attached to
1845
- * sender_auth.signed_messages[0].payload.delegate_signer so the settler can feed
1846
- * it to the on-chain Ed25519 verify instruction.
1847
- */
1848
- deriveDelegateSigner?(privateKey: string): string;
1849
- /**
1850
- * Assert the private key derives `address`, so a wrong key/sender pair fails
1851
- * fast (mirrors the Turnkey pinnedAddress check) instead of signing as the
1852
- * wrong depositor and only failing downstream. Throws on mismatch. The error
1853
- * names the addresses (public) but never the key.
1854
- */
1855
- verifyAddressMatchesKey?(privateKey: string, address: string): void;
1856
- }
1857
-
1858
1799
  /** Result of signing a sender_auth message. */
1859
1800
  interface SenderSignature {
1860
1801
  /** 0x-prefixed signature hex (65-byte secp256k1 for EVM/Tron, 64-byte ed25519 for Solana). */
@@ -1898,18 +1839,6 @@ type SenderSignerOptions = {
1898
1839
  provider: 'turnkey';
1899
1840
  } & TurnkeyConfig);
1900
1841
 
1901
- /**
1902
- * Private-key sender signer. Delegates to the chain adapter so the local-key
1903
- * signing path is unchanged. The adapter validates the key in the constructor,
1904
- * so a malformed EVM/Tron key can't leak via ethers even on direct construction.
1905
- */
1906
- declare class RawSenderSigner implements SenderSigner {
1907
- private readonly adapter;
1908
- private readonly privateKey;
1909
- constructor(adapter: ChainAdapter, privateKey: string);
1910
- sign(signedMessage: SignedMessage): Promise<SenderSignature>;
1911
- }
1912
-
1913
1842
  /** Typed contract for the lazily-loaded ./turnkey-impl module; also the test's conformance target. */
1914
1843
  interface TurnkeyImplModule {
1915
1844
  turnkeySign: (chainPrefix: string, cfg: {
@@ -1973,9 +1902,9 @@ declare const $AuthorizationResult: {
1973
1902
  };
1974
1903
  readonly error_code: {
1975
1904
  readonly type: "string";
1976
- readonly description: "Machine-readable error code (present when status is error or timeout).\nThe counterparty and webhook codes (COUNTERPARTY_NOT_FOUND, COUNTERPARTY_TIMEOUT,\nWEBHOOK_ERROR, WEBHOOK_CONNECTION_ERROR, INTERNAL_ERROR) mirror the AuthorizationErrorCode\nprotobuf enum. GATEWAY_TIMEOUT, PROOF_INVALID, and PROOF_STALE are produced by payment-gw\nitself and have no protobuf equivalent.\n";
1905
+ readonly description: "Machine-readable error code (present when status is error or timeout).\nCounterparty-sourced codes are derived from the error code the\nCounterparty Gateway publishes. GATEWAY_TIMEOUT, PROOF_INVALID, and\nPROOF_STALE are payment-gw-specific (no counterparty envelope corresponds).\n";
1977
1906
  readonly enum: readonly ["COUNTERPARTY_NOT_FOUND", "COUNTERPARTY_TIMEOUT", "WEBHOOK_ERROR", "WEBHOOK_CONNECTION_ERROR", "INTERNAL_ERROR", "GATEWAY_TIMEOUT", "PROOF_INVALID", "PROOF_STALE"];
1978
- readonly 'x-enum-description': "The counterparty and webhook codes mirror the AuthorizationErrorCode protobuf enum\n(without the AUTHORIZATION_ERROR_CODE_ prefix for readability in HTTP responses).\nGATEWAY_TIMEOUT, PROOF_INVALID, and PROOF_STALE are payment-gw-local codes with no protobuf equivalent.\n";
1907
+ readonly 'x-enum-description': "COUNTERPARTY_NOT_FOUND, COUNTERPARTY_TIMEOUT, WEBHOOK_ERROR,\nWEBHOOK_CONNECTION_ERROR, and INTERNAL_ERROR are derived from the\nerror code the Counterparty Gateway publishes.\nGATEWAY_TIMEOUT is emitted by payment-gw when no authorization\nresponse is received within the system-wide timeout — source unknown\n(counterparty delay, transport failure, or gateway unavailability).\nOriginator should retry; counterparty-side idempotency prevents PSP re-charge\nif the original was already processed.\n\nPROOF_INVALID is emitted when the W3C Data Integrity proof on the\nbeneficiary PSP's AuthorizationResponse fails verification: signature\nrecovery failed, recovered DID does not match the destination DID,\nresponse shape is malformed (missing @context / payment_id /\ncounterparty_did / proof), or the suite type is unsupported. The\nunderlying reason cardinality is collapsed so originators see one\nactionable category.\n\nPROOF_STALE is emitted when proof.created falls outside the\nconfigured freshness window. Originators should retry with a fresh\nrequest — the freshness window closes a replay attack vector where a\ncaptured-but-cryptographically-valid proof could otherwise be replayed\nindefinitely.\n";
1979
1908
  };
1980
1909
  readonly error_message: {
1981
1910
  readonly type: "string";
@@ -2362,8 +2291,8 @@ declare const $PaymentError: {
2362
2291
  readonly properties: {
2363
2292
  readonly code: {
2364
2293
  readonly type: "string";
2365
- readonly description: "Machine-readable error code in SCREAMING_SNAKE_CASE.\nCommon codes:\n- `QUOTE_DEADLINE_EXPIRED`: No settlement quotes received in time\n- `QUOTE_SELECTION_FAILED`: Quotes received but none met requirements\n- `INSUFFICIENT_FUNDS`: Sender wallet has insufficient balance\n- `FULFILLMENT_TIMEOUT`: Settlement agent didn't complete in time\n";
2366
- readonly example: "QUOTE_DEADLINE_EXPIRED";
2294
+ readonly description: "Public error category in SCREAMING_SNAKE_CASE.\nCommon codes:\n- `SETTLEMENT_FAILED`: The settlement could not be completed\n- `NO_ROUTE_AVAILABLE`: No settlement route was available\n- `INTERNAL_ERROR`: An unexpected error occurred\n";
2295
+ readonly example: "SETTLEMENT_FAILED";
2367
2296
  };
2368
2297
  readonly message: {
2369
2298
  readonly type: "string";
@@ -2626,7 +2555,7 @@ declare const $TimelineStep: {
2626
2555
  readonly properties: {
2627
2556
  readonly name: {
2628
2557
  readonly type: "string";
2629
- readonly description: "Name of the step";
2558
+ readonly description: "Internal name of the step (matches settlement event type)";
2630
2559
  readonly example: "BID_AWARDED";
2631
2560
  };
2632
2561
  readonly label: {
@@ -2667,11 +2596,35 @@ declare const $TimelineStep: {
2667
2596
  };
2668
2597
  declare const $ErrorResponse: {
2669
2598
  readonly type: "object";
2599
+ readonly description: "Safe, outward-facing error. Derived from an internal error through the shared error catalog. The public code identifies the category and the message is a curated, safe description.";
2600
+ readonly required: readonly ["code", "message"];
2670
2601
  readonly properties: {
2671
- readonly error: {
2602
+ readonly code: {
2603
+ readonly type: "string";
2604
+ readonly description: "Public, machine-readable error category in SCREAMING_SNAKE_CASE.";
2605
+ readonly pattern: "^[A-Z][A-Z0-9_]*$";
2606
+ readonly example: "INVALID_SOURCE_ASSET";
2607
+ };
2608
+ readonly message: {
2609
+ readonly type: "string";
2610
+ readonly description: "Curated, safe, human-readable message.";
2611
+ readonly maxLength: 500;
2612
+ readonly example: "The source asset identifier is not a valid CAIP-19 asset.";
2613
+ };
2614
+ readonly request_id: {
2615
+ readonly type: "string";
2616
+ readonly description: "Correlation id to quote to support to locate the internal error record.";
2617
+ readonly example: "req_123456789";
2618
+ };
2619
+ readonly docs_url: {
2672
2620
  readonly type: "string";
2673
- readonly description: "Error message";
2674
- readonly example: "Invalid request: missing required field";
2621
+ readonly format: "uri";
2622
+ readonly description: "Link to the documentation page for this public code.";
2623
+ };
2624
+ readonly domain: {
2625
+ readonly type: "string";
2626
+ readonly description: "Originating service domain.";
2627
+ readonly example: "PAYMENT_GATEWAY";
2675
2628
  };
2676
2629
  };
2677
2630
  };
@@ -3014,12 +2967,12 @@ declare const $QuoteRequestStatusResponse: {
3014
2967
  readonly status: {
3015
2968
  readonly type: "string";
3016
2969
  readonly enum: readonly ["collecting", "ready", "awarded", "expired"];
3017
- readonly description: "Derived batch lifecycle, computed at read time (not a stored state machine). Disjoint\nfrom the payment-status enum returned by the award and payment-status endpoints.\n- `collecting` — collection window in progress; `quotes` absent.\n- `ready` — collection complete; none awarded yet; either at least one quote is still\n within its `award_deadline`, or no settler bid (empty `quotes` array — the successful\n \"no quotes available\" result).\n- `awarded` — a quote produced a payment row; no further awards accepted (MVP).\n- `expired` — collection closed, nothing awarded, and every collected quote is now past\n its `award_deadline` (\"quotes lapsed\"). An empty batch is `ready`, not `expired` — the\n two are deliberately distinct (\"no quotes available\" vs \"quotes lapsed\").\n";
2970
+ readonly description: "Derived batch lifecycle, computed at read time (not a stored state machine). Disjoint\nfrom the payment-status enum returned by the award and payment-status endpoints.\n- `collecting` — collection window still open; `quotes` lists those collected so far\n (a quote is awardable from arrival, by its own `award_deadline`; more may arrive until\n `collection_close`).\n- `ready` — collection complete; none awarded yet; either at least one quote is still\n within its `award_deadline`, or no settler bid (empty `quotes` array — the successful\n \"no quotes available\" result).\n- `awarded` — a quote produced a payment row; no further awards accepted (MVP).\n- `expired` — collection closed, nothing awarded, and every collected quote is now past\n its `award_deadline` (\"quotes lapsed\"). An empty batch is `ready`, not `expired` — the\n two are deliberately distinct (\"no quotes available\" vs \"quotes lapsed\").\n";
3018
2971
  readonly example: "awarded";
3019
2972
  };
3020
2973
  readonly quotes: {
3021
2974
  readonly type: "array";
3022
- readonly description: "Collected quotes with award linkage. Absent while status is `collecting`.";
2975
+ readonly description: "Collected quotes with award linkage — those collected so far while `collecting`, the full set once the window closes.";
3023
2976
  readonly items: {
3024
2977
  readonly $ref: "#/components/schemas/AwardedQuote";
3025
2978
  };
@@ -3568,6 +3521,32 @@ declare class PaymentGatewayClient extends PaymentGatewayClient$1 {
3568
3521
  /**
3569
3522
  * Prepares a payment request with defaults, ready for signing.
3570
3523
  *
3524
+ * By default this resolves the corridor addresses from the gateway `/defaults`
3525
+ * endpoint. It reaches the gateway only for what the caller has NOT already
3526
+ * supplied via `resolvedDefaults`: supply `resolvedDefaults.source` to skip the
3527
+ * source-chain fetch and `resolvedDefaults.destination` to skip the destination
3528
+ * fetch. Supplying both builds the request **entirely offline** (no network) —
3529
+ * how a caller that already holds the corridor addresses (e.g. from a signed
3530
+ * challenge) constructs and signs a request without gateway access. Such a
3531
+ * caller typically also injects `now` so the deadlines are deterministic.
3532
+ *
3533
+ * @example Minimal — fetch corridor addresses from the gateway, then sign
3534
+ * ```ts
3535
+ * const client = new PaymentGatewayClient({ BASE: "https://gateway.example.com" });
3536
+ *
3537
+ * const request = await client.preparePaymentRequest({
3538
+ * depositor: "0xPayerAddress",
3539
+ * sourceAsset: "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
3540
+ * destinationAccount: "0xMerchantAddress",
3541
+ * destinationAsset: "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum
3542
+ * fulfillmentAmount: "10000000", // 10 USDC (6 decimals)
3543
+ * });
3544
+ * // max_source_amount, deadlines, request id, and nonce are all defaulted.
3545
+ *
3546
+ * const signer = createSenderSigner("eip155:8453", { provider: "raw", privateKey });
3547
+ * await signPaymentRequest(request, signer); // fills sender_auth, ready to submit
3548
+ * ```
3549
+ *
3571
3550
  * @param params Payment parameters
3572
3551
  * @returns A complete PaymentRequest object without the signature
3573
3552
  */
@@ -3578,17 +3557,54 @@ declare class PaymentGatewayClient extends PaymentGatewayClient$1 {
3578
3557
  destinationAccount: string;
3579
3558
  destinationAsset: string;
3580
3559
  maxSourceAmount?: string;
3581
- requestId?: string;
3582
- requestIdPrefix?: string;
3560
+ /**
3561
+ * REQUIRED idempotency key. It seeds the deterministic deposit nonce, so a retry that
3562
+ * reuses the same `requestId` reproduces the same single-use permit (no double-charge),
3563
+ * and the gateway dedups on it. The caller owns it and must reuse it on retry — there is
3564
+ * no auto-generated fallback (a random one would silently break idempotency).
3565
+ */
3566
+ requestId: string;
3583
3567
  settlerRequirements?: {
3584
3568
  whitelist?: string[];
3585
3569
  blacklist?: string[];
3586
3570
  };
3587
- deadlineSeconds?: number;
3571
+ /** How long the auction stays open (seconds from now). */
3588
3572
  quoteDeadlineSeconds?: number;
3573
+ /** How long settlement may take (seconds from now). */
3589
3574
  fulfillmentDeadlineSeconds?: number;
3575
+ /** EVM/Tron-only: the Permit2 signature's own on-chain expiry (seconds from now). */
3576
+ deadlineSeconds?: number;
3577
+ /** Clock source used to stamp the deadlines. Defaults to `Date.now`; inject for offline/deterministic builds. */
3578
+ now?: () => number;
3579
+ /**
3580
+ * Explicit deposit-nonce override. OMIT this in normal use: the deposit's single-use nonce is
3581
+ * then derived deterministically from `requestId` + depositor, so rebuilding the same payment
3582
+ * reproduces the same nonce. What that guarantees differs by chain:
3583
+ * - EVM/Tron: the Permit2 nonce is a PERMANENT on-chain bitmap, so across any number of
3584
+ * rebuilds only one deposit can EVER settle — retry-safe without a time bound.
3585
+ * - Solana: the escrow replay nonce only protects within a ~128s window — the nonce pins the
3586
+ * replay slot/bucket, but `issued_at` is re-read on each build, so a rebuild in a later
3587
+ * window is not blocked on-chain by the nonce alone. The payment gateway's `request_id`
3588
+ * dedup (and the init-only deposit PDA, which blocks a byte-identical re-POST forever) are
3589
+ * the durable backstop; pin `issued_at` via `solanaClockReader` to keep a rebuild inside
3590
+ * the same window.
3591
+ * Pass a value only to override the derived nonce.
3592
+ */
3593
+ nonce?: bigint | string;
3590
3594
  /** Solana-only: override the RPC used to read the cluster clock for issued_at. */
3591
3595
  solanaRpcUrl?: string;
3596
+ /** Solana-only: injectable clock reader for `issued_at` (offline / test seam). */
3597
+ solanaClockReader?: SolanaClusterUnixTimeReader;
3598
+ /**
3599
+ * Pre-resolved corridor addresses. Omit to fetch them from the gateway
3600
+ * `/defaults`; supply to build offline. Each side is resolved independently —
3601
+ * a field left out is still fetched. The destination contributes only its
3602
+ * `fulfillmentProxy` (its escrow/roles are source-side concepts, unused here).
3603
+ */
3604
+ resolvedDefaults?: {
3605
+ source?: ChainDefaults;
3606
+ destination?: Pick<ChainDefaults, 'fulfillmentProxy'>;
3607
+ };
3592
3608
  }): Promise<PaymentRequest>;
3593
3609
  /**
3594
3610
  * Prepares a quote-request body (`CreateQuoteRequest`), ready to POST to
@@ -3642,4 +3658,4 @@ declare class PaymentGatewayClient extends PaymentGatewayClient$1 {
3642
3658
  }): Promise<CreateQuoteRequest>;
3643
3659
  }
3644
3660
 
3645
- export { $AuthorizationResult, $AwardAccepted, $AwardRequest, $AwardResponse, $AwardedPayment, $AwardedQuote, $BidAward, $CreateQuoteRequest, $DataIntegrityProof, $ErrorResponse, $FulfillmentConfirmation, $GetPaymentStatusResponse, type $OpenApiTs, $OwnedAsset, $PaymentBlockchainContext, $PaymentError, $PaymentRequest, $PaymentResponse, $PaymentSummary, $PaymentTimelineResponse, $PreparePaymentRequest, $PreparePaymentResponse, $Quote, $QuoteRequestAccepted, $QuoteRequestResponse, $QuoteRequestStatusResponse, $ResolvePaymentResponse, $SenderAuth, $SenderAuthMessageScheme, $SignedMessage, $TimelineError, $TimelineStep, $VerifiableCredential, $VerifiableCredentialAuth, ApiError, type ApiRequestOptions, type ApiResult, type AuthorizationResult, AuthorizationsService, type AuthorizePaymentData, type AuthorizePaymentResponse, type AwardAccepted, type AwardQuoteData, type AwardQuoteResponse, type AwardRequest, type AwardResponse, type AwardedPayment, type AwardedQuote, type BidAward, CancelError, CancelablePromise, type CreateQuoteRequest, type CreateQuoteRequestData, type CreateQuoteRequestResponse, DEFAULT_FULFILLMENT_DEADLINE_SECONDS, DEFAULT_PAYMENT_QUOTE_DEADLINE_SECONDS, DEFAULT_QUOTE_DEADLINE_SECONDS, DEPOSIT_MESSAGE_SIZE, type DataIntegrityProof, type ErrorResponse, type FulfillmentConfirmation, type GetPaymentStatusData, type GetPaymentStatusResponse, type GetPaymentStatusResponse2, type GetPaymentTimelineData, type GetPaymentTimelineResponse, type GetQuoteRequestStatusData, type GetQuoteRequestStatusResponse, type HealthCheckResponse, HealthService, Interceptors, MAX_VALID_SLOT, type OnCancel, OpenAPI, type OpenAPIConfig, type OwnedAsset, PAYMENT_REQUEST_VERSION, PERMIT2_CONTRACT_ADDRESS, type PaymentBlockchainContext, type PaymentError, PaymentGatewayClient, type PaymentRequest, type PaymentResponse, type PaymentSummary, type PaymentTimelineResponse, PaymentsService, type PermitWitnessTransferFromParams, type PreparePaymentData, type PreparePaymentRequest, type PreparePaymentResponse, type PreparePaymentResponse2, type Quote, type QuoteRequestAccepted, type QuoteRequestResponse, type QuoteRequestStatusResponse, QuoteRequestsService, REPLAY_HORIZON_SECS, RawSenderSigner, type ResolvePaymentData, type ResolvePaymentResponse, type ResolvePaymentResponse2, type SenderAuth, type SenderAuthMessageScheme, type SenderSignature, type SenderSigner, type SenderSignerOptions, type SignedMessage, type SolanaDepositParams, type SolanaDepositPrehash, type SubmitPaymentData, type SubmitPaymentResponse, TOTAL_BUCKETS, type TimelineError, type TimelineStep, type TurnkeyConfig, TurnkeySenderSigner, type TvmPermitWitnessTransferFromParams, type VerifiableCredential, type VerifiableCredentialAuth, base58ToBytes, base58ToHex, bytesToHex, createPermitWitnessTransferFromPrehash, createSenderSigner, createSolanaDepositPrehash, createTvmPermitWitnessTransferFromPrehash, defaultGateway, type domain, encodeU64LE, type error_code, generateSolanaNonce, generateSolanaPaymentId, hashPermitWitnessTransferFrom, hashRequestId, hashSolanaDeposit, hashTvmPermitWitnessTransferFrom, hexToBytes, maskChainId, normalizeAddress, resolveTurnkeyAddresses, signPaymentRequest, type status, type status2, type status3, type status4, type status5, type status6, type status7, type status8, type status9 };
3661
+ export { $AuthorizationResult, $AwardAccepted, $AwardRequest, $AwardResponse, $AwardedPayment, $AwardedQuote, $BidAward, $CreateQuoteRequest, $DataIntegrityProof, $ErrorResponse, $FulfillmentConfirmation, $GetPaymentStatusResponse, type $OpenApiTs, $OwnedAsset, $PaymentBlockchainContext, $PaymentError, $PaymentRequest, $PaymentResponse, $PaymentSummary, $PaymentTimelineResponse, $PreparePaymentRequest, $PreparePaymentResponse, $Quote, $QuoteRequestAccepted, $QuoteRequestResponse, $QuoteRequestStatusResponse, $ResolvePaymentResponse, $SenderAuth, $SenderAuthMessageScheme, $SignedMessage, $TimelineError, $TimelineStep, $VerifiableCredential, $VerifiableCredentialAuth, ApiError, type ApiRequestOptions, type ApiResult, type AuthorizationResult, AuthorizationsService, type AuthorizePaymentData, type AuthorizePaymentResponse, type AwardAccepted, type AwardQuoteData, type AwardQuoteResponse, type AwardRequest, type AwardResponse, type AwardedPayment, type AwardedQuote, type BidAward, CancelError, CancelablePromise, type ChainDefaults, type CreateQuoteRequest, type CreateQuoteRequestData, type CreateQuoteRequestResponse, DEFAULT_FULFILLMENT_DEADLINE_SECONDS, DEFAULT_PAYMENT_QUOTE_DEADLINE_SECONDS, DEFAULT_QUOTE_DEADLINE_SECONDS, DEPOSIT_MESSAGE_SIZE, type DataIntegrityProof, type ErrorResponse, type FulfillmentConfirmation, type GetPaymentStatusData, type GetPaymentStatusResponse, type GetPaymentStatusResponse2, type GetPaymentTimelineData, type GetPaymentTimelineResponse, type GetQuoteRequestStatusData, type GetQuoteRequestStatusResponse, type HealthCheckResponse, HealthService, Interceptors, MAX_VALID_SLOT, type OnCancel, OpenAPI, type OpenAPIConfig, type OwnedAsset, PAYMENT_REQUEST_VERSION, PERMIT2_CONTRACT_ADDRESS, type PaymentBlockchainContext, type PaymentError, PaymentGatewayClient, type PaymentRequest, type PaymentResponse, type PaymentSummary, type PaymentTimelineResponse, PaymentsService, type PermitWitnessTransferFromParams, type PreparePaymentData, type PreparePaymentRequest, type PreparePaymentResponse, type PreparePaymentResponse2, type Quote, type QuoteRequestAccepted, type QuoteRequestResponse, type QuoteRequestStatusResponse, QuoteRequestsService, REPLAY_HORIZON_SECS, type ResolvePaymentData, type ResolvePaymentResponse, type ResolvePaymentResponse2, type SenderAuth, type SenderAuthMessageScheme, type SenderSignature, type SenderSigner, type SenderSignerOptions, type SignedMessage, type SolanaClusterUnixTimeReader, type SolanaDepositParams, type SolanaDepositPrehash, type SubmitPaymentData, type SubmitPaymentResponse, TOTAL_BUCKETS, type TimelineError, type TimelineStep, type TurnkeyConfig, TurnkeySenderSigner, type TvmPermitWitnessTransferFromParams, type VerifiableCredential, type VerifiableCredentialAuth, base58ToBytes, base58ToHex, bytesToHex, createPermitWitnessTransferFromPrehash, createSenderSigner, createSolanaDepositPrehash, createTvmPermitWitnessTransferFromPrehash, defaultGateway, type domain, encodeU64LE, type error_code, generateSolanaNonce, generateSolanaPaymentId, hashPermitWitnessTransferFrom, hashRequestId, hashSolanaDeposit, hashTvmPermitWitnessTransferFrom, hexToBytes, maskChainId, normalizeAddress, resolveTurnkeyAddresses, signPaymentRequest, type status, type status2, type status3, type status4, type status5, type status6, type status7, type status8, type status9 };