uvd-x402-sdk 2.89.0 → 2.91.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/README.md +32 -0
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/backend/index.d.mts +2 -2
- package/dist/backend/index.d.ts +2 -2
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs.map +1 -1
- package/dist/erc8128/index.js.map +1 -1
- package/dist/erc8128/index.mjs.map +1 -1
- package/dist/{index-13ZUDF7c.d.mts → index-DAC3DRdT.d.mts} +1 -1
- package/dist/{index-B5B9EK3x.d.ts → index-DRSEcZ36.d.ts} +1 -1
- package/dist/{index-CAJg-_cr.d.mts → index-DRk6i654.d.mts} +1 -1
- package/dist/{index-BWN0Haa0.d.mts → index-DbauIMV2.d.mts} +41 -0
- package/dist/{index-BWN0Haa0.d.ts → index-DbauIMV2.d.ts} +41 -0
- package/dist/{index-Cd1Mpznb.d.ts → index-s6ot_Mu-.d.ts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +43 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -3
- package/dist/index.mjs.map +1 -1
- package/dist/providers/algorand/index.d.mts +1 -1
- package/dist/providers/algorand/index.d.ts +1 -1
- package/dist/providers/algorand/index.js.map +1 -1
- package/dist/providers/algorand/index.mjs.map +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/evm/index.js +23 -1
- package/dist/providers/evm/index.js.map +1 -1
- package/dist/providers/evm/index.mjs +23 -1
- package/dist/providers/evm/index.mjs.map +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/near/index.js.map +1 -1
- package/dist/providers/near/index.mjs.map +1 -1
- package/dist/providers/solana/index.d.mts +1 -1
- package/dist/providers/solana/index.d.ts +1 -1
- package/dist/providers/solana/index.js.map +1 -1
- package/dist/providers/solana/index.mjs.map +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/stellar/index.js.map +1 -1
- package/dist/providers/stellar/index.mjs.map +1 -1
- package/dist/providers/sui/index.d.mts +1 -1
- package/dist/providers/sui/index.d.ts +1 -1
- package/dist/providers/sui/index.js.map +1 -1
- package/dist/providers/sui/index.mjs.map +1 -1
- package/dist/providers/xrpl/index.d.mts +1 -1
- package/dist/providers/xrpl/index.d.ts +1 -1
- package/dist/providers/xrpl/index.js.map +1 -1
- package/dist/providers/xrpl/index.mjs.map +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +44 -5
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +44 -5
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/picker/index.d.mts +1 -1
- package/dist/react/picker/index.d.ts +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +29 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +26 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/{validation-B95g0MqC.d.mts → validity-BTMBMmuj.d.mts} +101 -2
- package/dist/{validation-_Tcjm2gu.d.ts → validity-C0z0GqH6.d.ts} +101 -2
- package/package.json +1 -1
- package/src/client/X402Client.ts +32 -2
- package/src/index.ts +5 -0
- package/src/providers/evm/index.ts +4 -2
- package/src/react/index.tsx +8 -3
- package/src/types/index.ts +41 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/validity.ts +135 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as X402ClientConfig, e as PurchasePolicy, P as PaymentInfo, a as PaymentResult, f as X402FetchOptions, d as WalletState, C as ChainConfig, g as X402Event, h as X402EventHandler, N as NetworkType, T as TokenType, i as TokenConfig } from './index-
|
|
1
|
+
import { b as X402ClientConfig, e as PurchasePolicy, P as PaymentInfo, a as PaymentResult, f as X402FetchOptions, d as WalletState, C as ChainConfig, g as X402Event, h as X402EventHandler, N as NetworkType, T as TokenType, i as TokenConfig } from './index-DbauIMV2.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* uvd-x402-sdk - Main Client
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as X402ClientConfig, e as PurchasePolicy, P as PaymentInfo, a as PaymentResult, f as X402FetchOptions, d as WalletState, C as ChainConfig, g as X402Event, h as X402EventHandler, N as NetworkType, T as TokenType, i as TokenConfig } from './index-
|
|
1
|
+
import { b as X402ClientConfig, e as PurchasePolicy, P as PaymentInfo, a as PaymentResult, f as X402FetchOptions, d as WalletState, C as ChainConfig, g as X402Event, h as X402EventHandler, N as NetworkType, T as TokenType, i as TokenConfig } from './index-DbauIMV2.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* uvd-x402-sdk - Main Client
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as SigningWalletAdapter } from './wallet-w7BnImDG.mjs';
|
|
2
|
-
import { X as X402Version, j as X402Header, k as X402PayloadData } from './index-
|
|
2
|
+
import { X as X402Version, j as X402Header, k as X402PayloadData } from './index-DbauIMV2.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* uvd-x402-sdk - Signed lifecycle orders for `release` / `refundInEscrow`.
|
|
@@ -689,6 +689,26 @@ interface PaymentInfo {
|
|
|
689
689
|
* decides, exactly as before.
|
|
690
690
|
*/
|
|
691
691
|
x402Version?: X402Version;
|
|
692
|
+
/**
|
|
693
|
+
* Seconds this EIP-3009 authorization stays settleable
|
|
694
|
+
* (`validBefore = now + validitySeconds`).
|
|
695
|
+
*
|
|
696
|
+
* Set it when the seller settles **async** -- verify, hand over the resource,
|
|
697
|
+
* settle afterwards -- and needs the authorization alive for longer than the
|
|
698
|
+
* default. Left undefined, `X402ClientConfig.validitySeconds` decides, and
|
|
699
|
+
* failing that `DEFAULT_VALIDITY_SECONDS` (300 s, the timeout this SDK's own
|
|
700
|
+
* seller side announces by default). `X402Client.fetch()` fills it from the
|
|
701
|
+
* seller's `maxTimeoutSeconds` when the 402 declares one.
|
|
702
|
+
*
|
|
703
|
+
* Must be a whole number of seconds between 1 and `MAX_VALIDITY_SECONDS`
|
|
704
|
+
* (3600); anything else is refused with `INVALID_CONFIG` before anything is
|
|
705
|
+
* signed. The ceiling is here because this type is shaped like a parsed 402:
|
|
706
|
+
* a caller that hands a seller's response straight to `createPayment` would
|
|
707
|
+
* otherwise let the SELLER decide how long the payer's authorization stays
|
|
708
|
+
* claimable. The facilitator also keeps a 6 s clock-skew grace, so the payer
|
|
709
|
+
* really has `validitySeconds - 6` to sign.
|
|
710
|
+
*/
|
|
711
|
+
validitySeconds?: number;
|
|
692
712
|
}
|
|
693
713
|
/**
|
|
694
714
|
* One payment option read off a resource's `402`, normalised.
|
|
@@ -711,6 +731,15 @@ interface X402PaymentOffer {
|
|
|
711
731
|
decimals: number;
|
|
712
732
|
/** Recipient of the payment. */
|
|
713
733
|
payTo: string;
|
|
734
|
+
/**
|
|
735
|
+
* The seller's `maxTimeoutSeconds`, when its 402 entry declared a finite number.
|
|
736
|
+
*
|
|
737
|
+
* `X402Client.fetch()` signs this window -- clamped to `1..MAX_VALIDITY_SECONDS`
|
|
738
|
+
* -- instead of the client's own, because the seller is the one party that
|
|
739
|
+
* knows how long its settlement takes. Undefined when the entry declared none,
|
|
740
|
+
* or declared something that is not a number.
|
|
741
|
+
*/
|
|
742
|
+
maxTimeoutSeconds?: number;
|
|
714
743
|
/** The accept object verbatim -- echoed back for v2. */
|
|
715
744
|
raw: Record<string, unknown>;
|
|
716
745
|
}
|
|
@@ -1181,6 +1210,18 @@ interface X402ClientConfig {
|
|
|
1181
1210
|
* stays byte-identical to previous versions.
|
|
1182
1211
|
*/
|
|
1183
1212
|
includeTokenMetadata?: boolean;
|
|
1213
|
+
/**
|
|
1214
|
+
* Seconds every EIP-3009 authorization this client signs stays settleable
|
|
1215
|
+
* (`validBefore = now + validitySeconds`).
|
|
1216
|
+
*
|
|
1217
|
+
* The per-payment {@link PaymentInfo.validitySeconds} overrides it; with
|
|
1218
|
+
* neither, `DEFAULT_VALIDITY_SECONDS` (300 s) applies, and `MAX_VALIDITY_SECONDS`
|
|
1219
|
+
* (3600 s) is the ceiling for both. Until 2.91.0 this
|
|
1220
|
+
* was not configurable at all: the window was 300 s on Base and 60 s on every
|
|
1221
|
+
* other EVM network, decided by the payer's SDK, which is exactly the party
|
|
1222
|
+
* that does not know how long the seller's settlement takes.
|
|
1223
|
+
*/
|
|
1224
|
+
validitySeconds?: number;
|
|
1184
1225
|
}
|
|
1185
1226
|
/**
|
|
1186
1227
|
* Default configuration values
|
|
@@ -689,6 +689,26 @@ interface PaymentInfo {
|
|
|
689
689
|
* decides, exactly as before.
|
|
690
690
|
*/
|
|
691
691
|
x402Version?: X402Version;
|
|
692
|
+
/**
|
|
693
|
+
* Seconds this EIP-3009 authorization stays settleable
|
|
694
|
+
* (`validBefore = now + validitySeconds`).
|
|
695
|
+
*
|
|
696
|
+
* Set it when the seller settles **async** -- verify, hand over the resource,
|
|
697
|
+
* settle afterwards -- and needs the authorization alive for longer than the
|
|
698
|
+
* default. Left undefined, `X402ClientConfig.validitySeconds` decides, and
|
|
699
|
+
* failing that `DEFAULT_VALIDITY_SECONDS` (300 s, the timeout this SDK's own
|
|
700
|
+
* seller side announces by default). `X402Client.fetch()` fills it from the
|
|
701
|
+
* seller's `maxTimeoutSeconds` when the 402 declares one.
|
|
702
|
+
*
|
|
703
|
+
* Must be a whole number of seconds between 1 and `MAX_VALIDITY_SECONDS`
|
|
704
|
+
* (3600); anything else is refused with `INVALID_CONFIG` before anything is
|
|
705
|
+
* signed. The ceiling is here because this type is shaped like a parsed 402:
|
|
706
|
+
* a caller that hands a seller's response straight to `createPayment` would
|
|
707
|
+
* otherwise let the SELLER decide how long the payer's authorization stays
|
|
708
|
+
* claimable. The facilitator also keeps a 6 s clock-skew grace, so the payer
|
|
709
|
+
* really has `validitySeconds - 6` to sign.
|
|
710
|
+
*/
|
|
711
|
+
validitySeconds?: number;
|
|
692
712
|
}
|
|
693
713
|
/**
|
|
694
714
|
* One payment option read off a resource's `402`, normalised.
|
|
@@ -711,6 +731,15 @@ interface X402PaymentOffer {
|
|
|
711
731
|
decimals: number;
|
|
712
732
|
/** Recipient of the payment. */
|
|
713
733
|
payTo: string;
|
|
734
|
+
/**
|
|
735
|
+
* The seller's `maxTimeoutSeconds`, when its 402 entry declared a finite number.
|
|
736
|
+
*
|
|
737
|
+
* `X402Client.fetch()` signs this window -- clamped to `1..MAX_VALIDITY_SECONDS`
|
|
738
|
+
* -- instead of the client's own, because the seller is the one party that
|
|
739
|
+
* knows how long its settlement takes. Undefined when the entry declared none,
|
|
740
|
+
* or declared something that is not a number.
|
|
741
|
+
*/
|
|
742
|
+
maxTimeoutSeconds?: number;
|
|
714
743
|
/** The accept object verbatim -- echoed back for v2. */
|
|
715
744
|
raw: Record<string, unknown>;
|
|
716
745
|
}
|
|
@@ -1181,6 +1210,18 @@ interface X402ClientConfig {
|
|
|
1181
1210
|
* stays byte-identical to previous versions.
|
|
1182
1211
|
*/
|
|
1183
1212
|
includeTokenMetadata?: boolean;
|
|
1213
|
+
/**
|
|
1214
|
+
* Seconds every EIP-3009 authorization this client signs stays settleable
|
|
1215
|
+
* (`validBefore = now + validitySeconds`).
|
|
1216
|
+
*
|
|
1217
|
+
* The per-payment {@link PaymentInfo.validitySeconds} overrides it; with
|
|
1218
|
+
* neither, `DEFAULT_VALIDITY_SECONDS` (300 s) applies, and `MAX_VALIDITY_SECONDS`
|
|
1219
|
+
* (3600 s) is the ceiling for both. Until 2.91.0 this
|
|
1220
|
+
* was not configurable at all: the window was 300 s on Base and 60 s on every
|
|
1221
|
+
* other EVM network, decided by the payer's SDK, which is exactly the party
|
|
1222
|
+
* that does not know how long the seller's settlement takes.
|
|
1223
|
+
*/
|
|
1224
|
+
validitySeconds?: number;
|
|
1184
1225
|
}
|
|
1185
1226
|
/**
|
|
1186
1227
|
* Default configuration values
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as SigningWalletAdapter } from './wallet-w7BnImDG.js';
|
|
2
|
-
import { X as X402Version, j as X402Header, k as X402PayloadData } from './index-
|
|
2
|
+
import { X as X402Version, j as X402Header, k as X402PayloadData } from './index-DbauIMV2.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* uvd-x402-sdk - Signed lifecycle orders for `release` / `refundInEscrow`.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { D as DEFAULT_CHAIN, a as DEFAULT_FACILITATOR_URL, S as SUPPORTED_CHAINS, X as X402Client, b as getAlgorandChains, c as getChainById, g as getChainByName, d as getChainsByNetworkType, e as getChainsByToken, f as getEVMChainIds, h as getEnabledChains, i as getExplorerAddressUrl, j as getExplorerTxUrl, k as getNetworkType, l as getSVMChains, m as getSuiChains, n as getSupportedTokens, o as getTokenByAddress, p as getTokenConfig, q as getXRPLChains, r as isAlgorandChain, s as isChainSupported, t as isSVMChain, u as isSuiChain, v as isTokenSupported, w as isXRPLChain } from './index-
|
|
2
|
-
export { A as AdvertisedQuote, r as AlgorandPaymentPayload, s as CAIP2_IDENTIFIERS, t as CAIP2_TO_CHAIN, C as ChainConfig, D as DEFAULT_CONFIG, u as DecideOptions, E as EIP712Domain, v as EIP712Types, w as EVMPaymentPayload, x as EvaluateOptions, M as MultiPaymentConfig, y as NEARPaymentPayload, z as NativeCurrency, c as NetworkBalance, N as NetworkType, O as OFFER_VALIDITY_EXTENSION, q as PaymentHeaders, P as PaymentInfo, B as PaymentPayload, F as PaymentRequest, a as PaymentResult, o as PaymentTokenMetadata, G as PolicyApproval, H as PolicyAsset, I as PolicyDecision, J as PolicyRefusal, K as PolicyRefusalCode, L as PolicyRefusedError, e as PurchasePolicy, Q as QuoteComparison, R as ReadChallenge, S as SolanaPaymentPayload, U as StellarPaymentPayload, V as SuiPaymentPayload, i as TokenConfig, T as TokenType, Y as USDCConfig, W as WalletAdapter, d as WalletState, Z as X402AlgorandPayload, b as X402ClientConfig, _ as X402EVMPayload, $ as X402Error, a0 as X402ErrorCode, g as X402Event, a1 as X402EventData, h as X402EventHandler, f as X402FetchOptions, j as X402Header, p as X402HeaderName, l as X402HeaderV1, n as X402HeaderV2, a2 as X402NEARPayload, k as X402PayloadData, a3 as X402PaymentOffer, m as X402PaymentOption, a4 as X402Scheme, a5 as X402SettlementAccountPayload, a6 as X402SolanaPayload, a7 as X402StellarPayload, a8 as X402SuiPayload, X as X402Version, a9 as X402XRPLPayload, aa as XRPLPaymentPayload, ab as assetKey, ac as canonicalRecipient, ad as decideOnChallenge, ae as noReadableOffer, af as offerAsset, ag as offerValidUntil } from './index-
|
|
3
|
-
export { D as DEFAULT_PAYMENT_HEADER, P as PAYMENT_HEADER_NAMES, b as buildTokenMetadata, c as caip2ToChain,
|
|
1
|
+
export { D as DEFAULT_CHAIN, a as DEFAULT_FACILITATOR_URL, S as SUPPORTED_CHAINS, X as X402Client, b as getAlgorandChains, c as getChainById, g as getChainByName, d as getChainsByNetworkType, e as getChainsByToken, f as getEVMChainIds, h as getEnabledChains, i as getExplorerAddressUrl, j as getExplorerTxUrl, k as getNetworkType, l as getSVMChains, m as getSuiChains, n as getSupportedTokens, o as getTokenByAddress, p as getTokenConfig, q as getXRPLChains, r as isAlgorandChain, s as isChainSupported, t as isSVMChain, u as isSuiChain, v as isTokenSupported, w as isXRPLChain } from './index-DAC3DRdT.mjs';
|
|
2
|
+
export { A as AdvertisedQuote, r as AlgorandPaymentPayload, s as CAIP2_IDENTIFIERS, t as CAIP2_TO_CHAIN, C as ChainConfig, D as DEFAULT_CONFIG, u as DecideOptions, E as EIP712Domain, v as EIP712Types, w as EVMPaymentPayload, x as EvaluateOptions, M as MultiPaymentConfig, y as NEARPaymentPayload, z as NativeCurrency, c as NetworkBalance, N as NetworkType, O as OFFER_VALIDITY_EXTENSION, q as PaymentHeaders, P as PaymentInfo, B as PaymentPayload, F as PaymentRequest, a as PaymentResult, o as PaymentTokenMetadata, G as PolicyApproval, H as PolicyAsset, I as PolicyDecision, J as PolicyRefusal, K as PolicyRefusalCode, L as PolicyRefusedError, e as PurchasePolicy, Q as QuoteComparison, R as ReadChallenge, S as SolanaPaymentPayload, U as StellarPaymentPayload, V as SuiPaymentPayload, i as TokenConfig, T as TokenType, Y as USDCConfig, W as WalletAdapter, d as WalletState, Z as X402AlgorandPayload, b as X402ClientConfig, _ as X402EVMPayload, $ as X402Error, a0 as X402ErrorCode, g as X402Event, a1 as X402EventData, h as X402EventHandler, f as X402FetchOptions, j as X402Header, p as X402HeaderName, l as X402HeaderV1, n as X402HeaderV2, a2 as X402NEARPayload, k as X402PayloadData, a3 as X402PaymentOffer, m as X402PaymentOption, a4 as X402Scheme, a5 as X402SettlementAccountPayload, a6 as X402SolanaPayload, a7 as X402StellarPayload, a8 as X402SuiPayload, X as X402Version, a9 as X402XRPLPayload, aa as XRPLPaymentPayload, ab as assetKey, ac as canonicalRecipient, ad as decideOnChallenge, ae as noReadableOffer, af as offerAsset, ag as offerValidUntil } from './index-DbauIMV2.mjs';
|
|
3
|
+
export { D as DEFAULT_PAYMENT_HEADER, a as DEFAULT_VALIDITY_SECONDS, M as MAX_VALIDITY_SECONDS, P as PAYMENT_HEADER_NAMES, b as buildTokenMetadata, c as caip2ToChain, d as chainToCAIP2, e as clampValiditySeconds, f as convertX402Header, g as createPaymentHeaders, h as createX402Header, i as createX402V1Header, j as createX402V2Header, k as decodeBase64Utf8, l as decodeX402Header, m as detectX402Version, n as encodeBase64Json, o as encodeBase64Utf8, p as encodeX402Header, q as generatePaymentOptions, r as getPaymentHeader, s as isCAIP2Format, t as parseNetworkIdentifier, u as paymentChallengeFrom, v as resolveValiditySeconds, w as validateAmount, x as validateRecipient } from './validity-BTMBMmuj.mjs';
|
|
4
4
|
import { S as SigningWalletAdapter } from './wallet-w7BnImDG.mjs';
|
|
5
5
|
export { a as EIP3009Authorization, E as EIP3009Params } from './wallet-w7BnImDG.mjs';
|
|
6
6
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from './ows-Z9v4GxOZ.mjs';
|
|
7
|
-
export { A as AMBIGUOUS_LEASE_REASONS, B as BuildLifecycleAuthParams, D as DEFAULT_FACILITATOR_RETRIES, a as DEFAULT_RETRY_AFTER_SECONDS, F as FacilitatorClient, b as FacilitatorClientOptions, c as FacilitatorErrorInfo, d as FacilitatorFailureFields, e as FacilitatorFetchOptions, H as HonoMiddlewareOptions, L as LIFECYCLE_ACTIONS, f as LIFECYCLE_DEFAULT_DEADLINE_SECS, g as LIFECYCLE_DOMAIN_NAME, h as LIFECYCLE_DOMAIN_VERSION, i as LIFECYCLE_MAX_DEADLINE_SECS, j as LIFECYCLE_ORDER_TYPES, k as LifecycleAction, l as LifecycleAuth, m as LifecyclePaymentInfo, n as LifecycleSigner, o as LifecycleTypedData, p as LifecycleTypedDataParams, M as MAX_RETRY_AFTER_SECONDS, P as ParsedFacilitatorErrorBody, q as PaymentAcceptance, r as PaymentMiddlewareOptions, s as PaymentPayloadV2, t as PaymentRequirementsV2, R as REPLAYABLE_LEASE_REASONS, u as ResourceInfoV2, S as SETTLEMENT_UNCONFIRMED, v as SettleRequestV2, V as VerifiedPaymentState, w as VerifyRequestV2, W as WRITER_LEASE_REASONS, x as WagmiLifecycleWalletClient, y as WriterLeaseReason, X as X402_CORS_HEADERS, z as X402_HEADER_NAMES, C as buildLifecycleAuth, E as buildLifecycleTypedData, G as buildPaymentRequirements, I as buildSettleRequest, J as buildSettleRequestForVersion, K as buildSettleRequestV2, N as buildVerifyRequest, O as buildVerifyRequestForVersion, Q as buildVerifyRequestV2, T as create402Response, U as createHonoMiddleware, Y as createPaymentMiddleware, Z as extractPaymentFromHeaders, _ as facilitatorFetch, $ as getCorsHeaders, a0 as isAmbiguousLeaseReason, a1 as isReplayableLeaseReason, a2 as isSettlementUnconfirmed, a3 as lifecycleAuthFromSignature, a4 as parseFacilitatorErrorBody, a5 as parseRetryAfterSeconds, a6 as readFacilitatorError, a7 as resolveEnvelopeVersion, a8 as toPaymentRequirementsV2, a9 as toResourceInfoV2, aa as wagmiLifecycleSigner } from './index-
|
|
7
|
+
export { A as AMBIGUOUS_LEASE_REASONS, B as BuildLifecycleAuthParams, D as DEFAULT_FACILITATOR_RETRIES, a as DEFAULT_RETRY_AFTER_SECONDS, F as FacilitatorClient, b as FacilitatorClientOptions, c as FacilitatorErrorInfo, d as FacilitatorFailureFields, e as FacilitatorFetchOptions, H as HonoMiddlewareOptions, L as LIFECYCLE_ACTIONS, f as LIFECYCLE_DEFAULT_DEADLINE_SECS, g as LIFECYCLE_DOMAIN_NAME, h as LIFECYCLE_DOMAIN_VERSION, i as LIFECYCLE_MAX_DEADLINE_SECS, j as LIFECYCLE_ORDER_TYPES, k as LifecycleAction, l as LifecycleAuth, m as LifecyclePaymentInfo, n as LifecycleSigner, o as LifecycleTypedData, p as LifecycleTypedDataParams, M as MAX_RETRY_AFTER_SECONDS, P as ParsedFacilitatorErrorBody, q as PaymentAcceptance, r as PaymentMiddlewareOptions, s as PaymentPayloadV2, t as PaymentRequirementsV2, R as REPLAYABLE_LEASE_REASONS, u as ResourceInfoV2, S as SETTLEMENT_UNCONFIRMED, v as SettleRequestV2, V as VerifiedPaymentState, w as VerifyRequestV2, W as WRITER_LEASE_REASONS, x as WagmiLifecycleWalletClient, y as WriterLeaseReason, X as X402_CORS_HEADERS, z as X402_HEADER_NAMES, C as buildLifecycleAuth, E as buildLifecycleTypedData, G as buildPaymentRequirements, I as buildSettleRequest, J as buildSettleRequestForVersion, K as buildSettleRequestV2, N as buildVerifyRequest, O as buildVerifyRequestForVersion, Q as buildVerifyRequestV2, T as create402Response, U as createHonoMiddleware, Y as createPaymentMiddleware, Z as extractPaymentFromHeaders, _ as facilitatorFetch, $ as getCorsHeaders, a0 as isAmbiguousLeaseReason, a1 as isReplayableLeaseReason, a2 as isSettlementUnconfirmed, a3 as lifecycleAuthFromSignature, a4 as parseFacilitatorErrorBody, a5 as parseRetryAfterSeconds, a6 as readFacilitatorError, a7 as resolveEnvelopeVersion, a8 as toPaymentRequirementsV2, a9 as toResourceInfoV2, aa as wagmiLifecycleSigner } from './index-DRk6i654.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* DX402 `durable-evidence`: recover a paid response after the fact.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { D as DEFAULT_CHAIN, a as DEFAULT_FACILITATOR_URL, S as SUPPORTED_CHAINS, X as X402Client, b as getAlgorandChains, c as getChainById, g as getChainByName, d as getChainsByNetworkType, e as getChainsByToken, f as getEVMChainIds, h as getEnabledChains, i as getExplorerAddressUrl, j as getExplorerTxUrl, k as getNetworkType, l as getSVMChains, m as getSuiChains, n as getSupportedTokens, o as getTokenByAddress, p as getTokenConfig, q as getXRPLChains, r as isAlgorandChain, s as isChainSupported, t as isSVMChain, u as isSuiChain, v as isTokenSupported, w as isXRPLChain } from './index-
|
|
2
|
-
export { A as AdvertisedQuote, r as AlgorandPaymentPayload, s as CAIP2_IDENTIFIERS, t as CAIP2_TO_CHAIN, C as ChainConfig, D as DEFAULT_CONFIG, u as DecideOptions, E as EIP712Domain, v as EIP712Types, w as EVMPaymentPayload, x as EvaluateOptions, M as MultiPaymentConfig, y as NEARPaymentPayload, z as NativeCurrency, c as NetworkBalance, N as NetworkType, O as OFFER_VALIDITY_EXTENSION, q as PaymentHeaders, P as PaymentInfo, B as PaymentPayload, F as PaymentRequest, a as PaymentResult, o as PaymentTokenMetadata, G as PolicyApproval, H as PolicyAsset, I as PolicyDecision, J as PolicyRefusal, K as PolicyRefusalCode, L as PolicyRefusedError, e as PurchasePolicy, Q as QuoteComparison, R as ReadChallenge, S as SolanaPaymentPayload, U as StellarPaymentPayload, V as SuiPaymentPayload, i as TokenConfig, T as TokenType, Y as USDCConfig, W as WalletAdapter, d as WalletState, Z as X402AlgorandPayload, b as X402ClientConfig, _ as X402EVMPayload, $ as X402Error, a0 as X402ErrorCode, g as X402Event, a1 as X402EventData, h as X402EventHandler, f as X402FetchOptions, j as X402Header, p as X402HeaderName, l as X402HeaderV1, n as X402HeaderV2, a2 as X402NEARPayload, k as X402PayloadData, a3 as X402PaymentOffer, m as X402PaymentOption, a4 as X402Scheme, a5 as X402SettlementAccountPayload, a6 as X402SolanaPayload, a7 as X402StellarPayload, a8 as X402SuiPayload, X as X402Version, a9 as X402XRPLPayload, aa as XRPLPaymentPayload, ab as assetKey, ac as canonicalRecipient, ad as decideOnChallenge, ae as noReadableOffer, af as offerAsset, ag as offerValidUntil } from './index-
|
|
3
|
-
export { D as DEFAULT_PAYMENT_HEADER, P as PAYMENT_HEADER_NAMES, b as buildTokenMetadata, c as caip2ToChain,
|
|
1
|
+
export { D as DEFAULT_CHAIN, a as DEFAULT_FACILITATOR_URL, S as SUPPORTED_CHAINS, X as X402Client, b as getAlgorandChains, c as getChainById, g as getChainByName, d as getChainsByNetworkType, e as getChainsByToken, f as getEVMChainIds, h as getEnabledChains, i as getExplorerAddressUrl, j as getExplorerTxUrl, k as getNetworkType, l as getSVMChains, m as getSuiChains, n as getSupportedTokens, o as getTokenByAddress, p as getTokenConfig, q as getXRPLChains, r as isAlgorandChain, s as isChainSupported, t as isSVMChain, u as isSuiChain, v as isTokenSupported, w as isXRPLChain } from './index-DRSEcZ36.js';
|
|
2
|
+
export { A as AdvertisedQuote, r as AlgorandPaymentPayload, s as CAIP2_IDENTIFIERS, t as CAIP2_TO_CHAIN, C as ChainConfig, D as DEFAULT_CONFIG, u as DecideOptions, E as EIP712Domain, v as EIP712Types, w as EVMPaymentPayload, x as EvaluateOptions, M as MultiPaymentConfig, y as NEARPaymentPayload, z as NativeCurrency, c as NetworkBalance, N as NetworkType, O as OFFER_VALIDITY_EXTENSION, q as PaymentHeaders, P as PaymentInfo, B as PaymentPayload, F as PaymentRequest, a as PaymentResult, o as PaymentTokenMetadata, G as PolicyApproval, H as PolicyAsset, I as PolicyDecision, J as PolicyRefusal, K as PolicyRefusalCode, L as PolicyRefusedError, e as PurchasePolicy, Q as QuoteComparison, R as ReadChallenge, S as SolanaPaymentPayload, U as StellarPaymentPayload, V as SuiPaymentPayload, i as TokenConfig, T as TokenType, Y as USDCConfig, W as WalletAdapter, d as WalletState, Z as X402AlgorandPayload, b as X402ClientConfig, _ as X402EVMPayload, $ as X402Error, a0 as X402ErrorCode, g as X402Event, a1 as X402EventData, h as X402EventHandler, f as X402FetchOptions, j as X402Header, p as X402HeaderName, l as X402HeaderV1, n as X402HeaderV2, a2 as X402NEARPayload, k as X402PayloadData, a3 as X402PaymentOffer, m as X402PaymentOption, a4 as X402Scheme, a5 as X402SettlementAccountPayload, a6 as X402SolanaPayload, a7 as X402StellarPayload, a8 as X402SuiPayload, X as X402Version, a9 as X402XRPLPayload, aa as XRPLPaymentPayload, ab as assetKey, ac as canonicalRecipient, ad as decideOnChallenge, ae as noReadableOffer, af as offerAsset, ag as offerValidUntil } from './index-DbauIMV2.js';
|
|
3
|
+
export { D as DEFAULT_PAYMENT_HEADER, a as DEFAULT_VALIDITY_SECONDS, M as MAX_VALIDITY_SECONDS, P as PAYMENT_HEADER_NAMES, b as buildTokenMetadata, c as caip2ToChain, d as chainToCAIP2, e as clampValiditySeconds, f as convertX402Header, g as createPaymentHeaders, h as createX402Header, i as createX402V1Header, j as createX402V2Header, k as decodeBase64Utf8, l as decodeX402Header, m as detectX402Version, n as encodeBase64Json, o as encodeBase64Utf8, p as encodeX402Header, q as generatePaymentOptions, r as getPaymentHeader, s as isCAIP2Format, t as parseNetworkIdentifier, u as paymentChallengeFrom, v as resolveValiditySeconds, w as validateAmount, x as validateRecipient } from './validity-C0z0GqH6.js';
|
|
4
4
|
import { S as SigningWalletAdapter } from './wallet-w7BnImDG.js';
|
|
5
5
|
export { a as EIP3009Authorization, E as EIP3009Params } from './wallet-w7BnImDG.js';
|
|
6
6
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from './ows-C-KmORG9.js';
|
|
7
|
-
export { A as AMBIGUOUS_LEASE_REASONS, B as BuildLifecycleAuthParams, D as DEFAULT_FACILITATOR_RETRIES, a as DEFAULT_RETRY_AFTER_SECONDS, F as FacilitatorClient, b as FacilitatorClientOptions, c as FacilitatorErrorInfo, d as FacilitatorFailureFields, e as FacilitatorFetchOptions, H as HonoMiddlewareOptions, L as LIFECYCLE_ACTIONS, f as LIFECYCLE_DEFAULT_DEADLINE_SECS, g as LIFECYCLE_DOMAIN_NAME, h as LIFECYCLE_DOMAIN_VERSION, i as LIFECYCLE_MAX_DEADLINE_SECS, j as LIFECYCLE_ORDER_TYPES, k as LifecycleAction, l as LifecycleAuth, m as LifecyclePaymentInfo, n as LifecycleSigner, o as LifecycleTypedData, p as LifecycleTypedDataParams, M as MAX_RETRY_AFTER_SECONDS, P as ParsedFacilitatorErrorBody, q as PaymentAcceptance, r as PaymentMiddlewareOptions, s as PaymentPayloadV2, t as PaymentRequirementsV2, R as REPLAYABLE_LEASE_REASONS, u as ResourceInfoV2, S as SETTLEMENT_UNCONFIRMED, v as SettleRequestV2, V as VerifiedPaymentState, w as VerifyRequestV2, W as WRITER_LEASE_REASONS, x as WagmiLifecycleWalletClient, y as WriterLeaseReason, X as X402_CORS_HEADERS, z as X402_HEADER_NAMES, C as buildLifecycleAuth, E as buildLifecycleTypedData, G as buildPaymentRequirements, I as buildSettleRequest, J as buildSettleRequestForVersion, K as buildSettleRequestV2, N as buildVerifyRequest, O as buildVerifyRequestForVersion, Q as buildVerifyRequestV2, T as create402Response, U as createHonoMiddleware, Y as createPaymentMiddleware, Z as extractPaymentFromHeaders, _ as facilitatorFetch, $ as getCorsHeaders, a0 as isAmbiguousLeaseReason, a1 as isReplayableLeaseReason, a2 as isSettlementUnconfirmed, a3 as lifecycleAuthFromSignature, a4 as parseFacilitatorErrorBody, a5 as parseRetryAfterSeconds, a6 as readFacilitatorError, a7 as resolveEnvelopeVersion, a8 as toPaymentRequirementsV2, a9 as toResourceInfoV2, aa as wagmiLifecycleSigner } from './index-
|
|
7
|
+
export { A as AMBIGUOUS_LEASE_REASONS, B as BuildLifecycleAuthParams, D as DEFAULT_FACILITATOR_RETRIES, a as DEFAULT_RETRY_AFTER_SECONDS, F as FacilitatorClient, b as FacilitatorClientOptions, c as FacilitatorErrorInfo, d as FacilitatorFailureFields, e as FacilitatorFetchOptions, H as HonoMiddlewareOptions, L as LIFECYCLE_ACTIONS, f as LIFECYCLE_DEFAULT_DEADLINE_SECS, g as LIFECYCLE_DOMAIN_NAME, h as LIFECYCLE_DOMAIN_VERSION, i as LIFECYCLE_MAX_DEADLINE_SECS, j as LIFECYCLE_ORDER_TYPES, k as LifecycleAction, l as LifecycleAuth, m as LifecyclePaymentInfo, n as LifecycleSigner, o as LifecycleTypedData, p as LifecycleTypedDataParams, M as MAX_RETRY_AFTER_SECONDS, P as ParsedFacilitatorErrorBody, q as PaymentAcceptance, r as PaymentMiddlewareOptions, s as PaymentPayloadV2, t as PaymentRequirementsV2, R as REPLAYABLE_LEASE_REASONS, u as ResourceInfoV2, S as SETTLEMENT_UNCONFIRMED, v as SettleRequestV2, V as VerifiedPaymentState, w as VerifyRequestV2, W as WRITER_LEASE_REASONS, x as WagmiLifecycleWalletClient, y as WriterLeaseReason, X as X402_CORS_HEADERS, z as X402_HEADER_NAMES, C as buildLifecycleAuth, E as buildLifecycleTypedData, G as buildPaymentRequirements, I as buildSettleRequest, J as buildSettleRequestForVersion, K as buildSettleRequestV2, N as buildVerifyRequest, O as buildVerifyRequestForVersion, Q as buildVerifyRequestV2, T as create402Response, U as createHonoMiddleware, Y as createPaymentMiddleware, Z as extractPaymentFromHeaders, _ as facilitatorFetch, $ as getCorsHeaders, a0 as isAmbiguousLeaseReason, a1 as isReplayableLeaseReason, a2 as isSettlementUnconfirmed, a3 as lifecycleAuthFromSignature, a4 as parseFacilitatorErrorBody, a5 as parseRetryAfterSeconds, a6 as readFacilitatorError, a7 as resolveEnvelopeVersion, a8 as toPaymentRequirementsV2, a9 as toResourceInfoV2, aa as wagmiLifecycleSigner } from './index-s6ot_Mu-.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* DX402 `durable-evidence`: recover a paid response after the fact.
|
package/dist/index.js
CHANGED
|
@@ -1623,6 +1623,37 @@ var init_personal_sign = __esm({
|
|
|
1623
1623
|
}
|
|
1624
1624
|
});
|
|
1625
1625
|
|
|
1626
|
+
// src/utils/validity.ts
|
|
1627
|
+
function resolveValiditySeconds(perPayment, clientDefault) {
|
|
1628
|
+
const chosen = perPayment ?? clientDefault ?? exports.DEFAULT_VALIDITY_SECONDS;
|
|
1629
|
+
if (!Number.isInteger(chosen) || chosen <= 0) {
|
|
1630
|
+
throw new exports.X402Error(
|
|
1631
|
+
`validitySeconds must be a positive whole number of seconds, got ${String(chosen)}`,
|
|
1632
|
+
"INVALID_CONFIG",
|
|
1633
|
+
{ validitySeconds: chosen }
|
|
1634
|
+
);
|
|
1635
|
+
}
|
|
1636
|
+
if (chosen > exports.MAX_VALIDITY_SECONDS) {
|
|
1637
|
+
throw new exports.X402Error(
|
|
1638
|
+
`validitySeconds must be at most ${exports.MAX_VALIDITY_SECONDS} seconds, got ${String(chosen)}. A longer window is a standing claim on the payer: it can be settled long after the payer gave the payment up for expired.`,
|
|
1639
|
+
"INVALID_CONFIG",
|
|
1640
|
+
{ validitySeconds: chosen, max: exports.MAX_VALIDITY_SECONDS }
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
return chosen;
|
|
1644
|
+
}
|
|
1645
|
+
function clampValiditySeconds(maxTimeoutSeconds) {
|
|
1646
|
+
return Math.min(exports.MAX_VALIDITY_SECONDS, Math.max(1, Math.floor(maxTimeoutSeconds)));
|
|
1647
|
+
}
|
|
1648
|
+
exports.DEFAULT_VALIDITY_SECONDS = void 0; exports.MAX_VALIDITY_SECONDS = void 0;
|
|
1649
|
+
var init_validity = __esm({
|
|
1650
|
+
"src/utils/validity.ts"() {
|
|
1651
|
+
init_types();
|
|
1652
|
+
exports.DEFAULT_VALIDITY_SECONDS = 300;
|
|
1653
|
+
exports.MAX_VALIDITY_SECONDS = 3600;
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
|
|
1626
1657
|
// src/utils/index.ts
|
|
1627
1658
|
var init_utils = __esm({
|
|
1628
1659
|
"src/utils/index.ts"() {
|
|
@@ -1631,6 +1662,7 @@ var init_utils = __esm({
|
|
|
1631
1662
|
init_base64();
|
|
1632
1663
|
init_validation();
|
|
1633
1664
|
init_personal_sign();
|
|
1665
|
+
init_validity();
|
|
1634
1666
|
}
|
|
1635
1667
|
});
|
|
1636
1668
|
|
|
@@ -2929,6 +2961,7 @@ var X402Client = class _X402Client {
|
|
|
2929
2961
|
*/
|
|
2930
2962
|
purchasePolicy;
|
|
2931
2963
|
constructor(config = {}) {
|
|
2964
|
+
resolveValiditySeconds(void 0, config.validitySeconds);
|
|
2932
2965
|
this.config = {
|
|
2933
2966
|
...exports.DEFAULT_CONFIG,
|
|
2934
2967
|
...config
|
|
@@ -3256,7 +3289,8 @@ var X402Client = class _X402Client {
|
|
|
3256
3289
|
amount: ethers.ethers.formatUnits(chosen.amount, chosen.decimals),
|
|
3257
3290
|
tokenType,
|
|
3258
3291
|
network: chosen.chainName,
|
|
3259
|
-
x402Version: version
|
|
3292
|
+
x402Version: version,
|
|
3293
|
+
validitySeconds: chosen.maxTimeoutSeconds !== void 0 ? clampValiditySeconds(chosen.maxTimeoutSeconds) : void 0
|
|
3260
3294
|
});
|
|
3261
3295
|
const paidHeaders = {
|
|
3262
3296
|
..._X402Client.headersToRecord(options.init?.headers),
|
|
@@ -3330,6 +3364,7 @@ var X402Client = class _X402Client {
|
|
|
3330
3364
|
continue;
|
|
3331
3365
|
}
|
|
3332
3366
|
const chainName = getChainByName(network) ? network : caip2ToChain(network);
|
|
3367
|
+
const declaredTimeout = typeof accept.maxTimeoutSeconds === "number" && Number.isFinite(accept.maxTimeoutSeconds) ? accept.maxTimeoutSeconds : void 0;
|
|
3333
3368
|
offers.push({
|
|
3334
3369
|
network,
|
|
3335
3370
|
chainName,
|
|
@@ -3337,6 +3372,7 @@ var X402Client = class _X402Client {
|
|
|
3337
3372
|
amount: String(amount),
|
|
3338
3373
|
decimals: _X402Client.offerDecimals(chainName, tokenType),
|
|
3339
3374
|
payTo,
|
|
3375
|
+
...declaredTimeout !== void 0 ? { maxTimeoutSeconds: declaredTimeout } : {},
|
|
3340
3376
|
raw: accept
|
|
3341
3377
|
});
|
|
3342
3378
|
}
|
|
@@ -3636,7 +3672,10 @@ var X402Client = class _X402Client {
|
|
|
3636
3672
|
}
|
|
3637
3673
|
const nonce = ethers.ethers.hexlify(nonceBytes);
|
|
3638
3674
|
const validAfter = 0;
|
|
3639
|
-
const validityWindowSeconds =
|
|
3675
|
+
const validityWindowSeconds = resolveValiditySeconds(
|
|
3676
|
+
paymentInfo.validitySeconds,
|
|
3677
|
+
this.config.validitySeconds
|
|
3678
|
+
);
|
|
3640
3679
|
const validBefore = Math.floor(Date.now() / 1e3) + validityWindowSeconds;
|
|
3641
3680
|
const domain = {
|
|
3642
3681
|
name: token.name,
|
|
@@ -6343,6 +6382,7 @@ exports.buildVerifyRequestV2 = buildVerifyRequestV2;
|
|
|
6343
6382
|
exports.caip2ToChain = caip2ToChain;
|
|
6344
6383
|
exports.canonicalRecipient = canonicalRecipient;
|
|
6345
6384
|
exports.chainToCAIP2 = chainToCAIP2;
|
|
6385
|
+
exports.clampValiditySeconds = clampValiditySeconds;
|
|
6346
6386
|
exports.computeEscrowNonce = computeEscrowNonce;
|
|
6347
6387
|
exports.contentHash = contentHash;
|
|
6348
6388
|
exports.convertX402Header = convertX402Header;
|
|
@@ -6422,6 +6462,7 @@ exports.recoverEvidence = recoverEvidence;
|
|
|
6422
6462
|
exports.replaySafeTypedData = replaySafeTypedData;
|
|
6423
6463
|
exports.resolveDelegation = resolveDelegation;
|
|
6424
6464
|
exports.resolveEnvelopeVersion = resolveEnvelopeVersion;
|
|
6465
|
+
exports.resolveValiditySeconds = resolveValiditySeconds;
|
|
6425
6466
|
exports.rpcDelegationResolver = rpcDelegationResolver;
|
|
6426
6467
|
exports.sealEvidence = sealEvidence;
|
|
6427
6468
|
exports.sealEvidenceTo = sealEvidenceTo;
|