@x402/extensions 2.5.0 → 2.7.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.
@@ -1,3 +1,3 @@
1
- export { B as BAZAAR, a as BazaarClientExtension, b as BodyDiscoveryExtension, c as BodyDiscoveryInfo, D as DeclareBodyDiscoveryExtensionConfig, d as DeclareDiscoveryExtensionConfig, e as DeclareDiscoveryExtensionInput, f as DeclareMcpDiscoveryExtensionConfig, g as DeclareQueryDiscoveryExtensionConfig, h as DiscoveredHTTPResource, i as DiscoveredMCPResource, j as DiscoveredResource, k as DiscoveryExtension, l as DiscoveryInfo, m as DiscoveryResource, n as DiscoveryResourcesResponse, L as ListDiscoveryResourcesParams, M as McpDiscoveryExtension, o as McpDiscoveryInfo, Q as QueryDiscoveryExtension, p as QueryDiscoveryInfo, V as ValidationResult, q as bazaarResourceServerExtension, r as declareDiscoveryExtension, s as extractDiscoveryInfo, t as extractDiscoveryInfoFromExtension, u as extractDiscoveryInfoV1, v as extractResourceMetadataV1, w as isBodyExtensionConfig, x as isDiscoverableV1, y as isMcpExtensionConfig, z as isQueryExtensionConfig, A as validateAndExtract, C as validateDiscoveryExtension, E as withBazaar } from '../index-G8RNfr6X.js';
1
+ export { k as BAZAAR, A as BazaarClientExtension, c as BodyDiscoveryExtension, B as BodyDiscoveryInfo, g as DeclareBodyDiscoveryExtensionConfig, i as DeclareDiscoveryExtensionConfig, j as DeclareDiscoveryExtensionInput, h as DeclareMcpDiscoveryExtensionConfig, f as DeclareQueryDiscoveryExtensionConfig, s as DiscoveredHTTPResource, t as DiscoveredMCPResource, u as DiscoveredResource, e as DiscoveryExtension, D as DiscoveryInfo, C as DiscoveryResource, E as DiscoveryResourcesResponse, L as ListDiscoveryResourcesParams, d as McpDiscoveryExtension, M as McpDiscoveryInfo, a as QueryDiscoveryExtension, Q as QueryDiscoveryInfo, V as ValidationResult, b as bazaarResourceServerExtension, o as declareDiscoveryExtension, p as extractDiscoveryInfo, q as extractDiscoveryInfoFromExtension, w as extractDiscoveryInfoV1, y as extractResourceMetadataV1, n as isBodyExtensionConfig, x as isDiscoverableV1, l as isMcpExtensionConfig, m as isQueryExtensionConfig, r as validateAndExtract, v as validateDiscoveryExtension, z as withBazaar } from '../index-CtOzXcjN.js';
2
2
  import '@x402/core/types';
3
3
  import '@x402/core/http';
@@ -1,5 +1,5 @@
1
1
  import { FacilitatorExtension, ResourceServerExtension, PaymentPayload, PaymentRequirements, PaymentRequirementsV1 } from '@x402/core/types';
2
- import { BodyMethods, QueryParamMethods, HTTPFacilitatorClient } from '@x402/core/http';
2
+ import { QueryParamMethods, BodyMethods, HTTPFacilitatorClient } from '@x402/core/http';
3
3
 
4
4
  /**
5
5
  * Shared type utilities for x402 extensions
@@ -659,4 +659,4 @@ interface BazaarClientExtension {
659
659
  */
660
660
  declare function withBazaar<T extends HTTPFacilitatorClient>(client: T): WithExtensions<T, BazaarClientExtension>;
661
661
 
662
- export { validateAndExtract as A, BAZAAR as B, validateDiscoveryExtension as C, type DeclareBodyDiscoveryExtensionConfig as D, withBazaar as E, type ListDiscoveryResourcesParams as L, type McpDiscoveryExtension as M, type QueryDiscoveryExtension as Q, type ValidationResult as V, type WithExtensions as W, type BazaarClientExtension as a, type BodyDiscoveryExtension as b, type BodyDiscoveryInfo as c, type DeclareDiscoveryExtensionConfig as d, type DeclareDiscoveryExtensionInput as e, type DeclareMcpDiscoveryExtensionConfig as f, type DeclareQueryDiscoveryExtensionConfig as g, type DiscoveredHTTPResource as h, type DiscoveredMCPResource as i, type DiscoveredResource as j, type DiscoveryExtension as k, type DiscoveryInfo as l, type DiscoveryResource as m, type DiscoveryResourcesResponse as n, type McpDiscoveryInfo as o, type QueryDiscoveryInfo as p, bazaarResourceServerExtension as q, declareDiscoveryExtension as r, extractDiscoveryInfo as s, extractDiscoveryInfoFromExtension as t, extractDiscoveryInfoV1 as u, extractResourceMetadataV1 as v, isBodyExtensionConfig as w, isDiscoverableV1 as x, isMcpExtensionConfig as y, isQueryExtensionConfig as z };
662
+ export { type BazaarClientExtension as A, type BodyDiscoveryInfo as B, type DiscoveryResource as C, type DiscoveryInfo as D, type DiscoveryResourcesResponse as E, type ListDiscoveryResourcesParams as L, type McpDiscoveryInfo as M, type QueryDiscoveryInfo as Q, type ValidationResult as V, type WithExtensions as W, type QueryDiscoveryExtension as a, bazaarResourceServerExtension as b, type BodyDiscoveryExtension as c, type McpDiscoveryExtension as d, type DiscoveryExtension as e, type DeclareQueryDiscoveryExtensionConfig as f, type DeclareBodyDiscoveryExtensionConfig as g, type DeclareMcpDiscoveryExtensionConfig as h, type DeclareDiscoveryExtensionConfig as i, type DeclareDiscoveryExtensionInput as j, BAZAAR as k, isMcpExtensionConfig as l, isQueryExtensionConfig as m, isBodyExtensionConfig as n, declareDiscoveryExtension as o, extractDiscoveryInfo as p, extractDiscoveryInfoFromExtension as q, validateAndExtract as r, type DiscoveredHTTPResource as s, type DiscoveredMCPResource as t, type DiscoveredResource as u, validateDiscoveryExtension as v, extractDiscoveryInfoV1 as w, isDiscoverableV1 as x, extractResourceMetadataV1 as y, withBazaar as z };
@@ -1,9 +1,12 @@
1
- export { B as BAZAAR, a as BazaarClientExtension, b as BodyDiscoveryExtension, c as BodyDiscoveryInfo, D as DeclareBodyDiscoveryExtensionConfig, d as DeclareDiscoveryExtensionConfig, e as DeclareDiscoveryExtensionInput, f as DeclareMcpDiscoveryExtensionConfig, g as DeclareQueryDiscoveryExtensionConfig, h as DiscoveredHTTPResource, i as DiscoveredMCPResource, j as DiscoveredResource, k as DiscoveryExtension, l as DiscoveryInfo, m as DiscoveryResource, n as DiscoveryResourcesResponse, L as ListDiscoveryResourcesParams, M as McpDiscoveryExtension, o as McpDiscoveryInfo, Q as QueryDiscoveryExtension, p as QueryDiscoveryInfo, V as ValidationResult, W as WithExtensions, q as bazaarResourceServerExtension, r as declareDiscoveryExtension, s as extractDiscoveryInfo, t as extractDiscoveryInfoFromExtension, u as extractDiscoveryInfoV1, v as extractResourceMetadataV1, w as isBodyExtensionConfig, x as isDiscoverableV1, y as isMcpExtensionConfig, z as isQueryExtensionConfig, A as validateAndExtract, C as validateDiscoveryExtension, E as withBazaar } from './index-G8RNfr6X.js';
1
+ export { k as BAZAAR, A as BazaarClientExtension, c as BodyDiscoveryExtension, B as BodyDiscoveryInfo, g as DeclareBodyDiscoveryExtensionConfig, i as DeclareDiscoveryExtensionConfig, j as DeclareDiscoveryExtensionInput, h as DeclareMcpDiscoveryExtensionConfig, f as DeclareQueryDiscoveryExtensionConfig, s as DiscoveredHTTPResource, t as DiscoveredMCPResource, u as DiscoveredResource, e as DiscoveryExtension, D as DiscoveryInfo, C as DiscoveryResource, E as DiscoveryResourcesResponse, L as ListDiscoveryResourcesParams, d as McpDiscoveryExtension, M as McpDiscoveryInfo, a as QueryDiscoveryExtension, Q as QueryDiscoveryInfo, V as ValidationResult, W as WithExtensions, b as bazaarResourceServerExtension, o as declareDiscoveryExtension, p as extractDiscoveryInfo, q as extractDiscoveryInfoFromExtension, w as extractDiscoveryInfoV1, y as extractResourceMetadataV1, n as isBodyExtensionConfig, x as isDiscoverableV1, l as isMcpExtensionConfig, m as isQueryExtensionConfig, r as validateAndExtract, v as validateDiscoveryExtension, z as withBazaar } from './index-CtOzXcjN.js';
2
2
  export { CompleteSIWxInfo, CreateSIWxHookOptions, DeclareSIWxOptions, EVMMessageVerifier, EVMSigner, InMemorySIWxStorage, SIGN_IN_WITH_X, SIWxExtension, SIWxExtensionInfo, SIWxExtensionSchema, SIWxHookEvent, SIWxPayload, SIWxPayloadSchema, SIWxSigner, SIWxStorage, SIWxValidationOptions, SIWxValidationResult, SIWxVerifyOptions, SIWxVerifyResult, SOLANA_DEVNET, SOLANA_MAINNET, SOLANA_TESTNET, SignatureScheme, SignatureType, SolanaSigner, SupportedChain, buildSIWxSchema, createSIWxClientHook, createSIWxMessage, createSIWxPayload, createSIWxRequestHook, createSIWxSettleHook, declareSIWxExtension, decodeBase58, encodeBase58, encodeSIWxHeader, extractEVMChainId, extractSolanaChainReference, formatSIWEMessage, formatSIWSMessage, getEVMAddress, getSolanaAddress, isEVMSigner, isSolanaSigner, parseSIWxHeader, signEVMMessage, signSolanaMessage, siwxResourceServerExtension, validateSIWxMessage, verifyEVMSignature, verifySIWxSignature, verifySolanaSignature, wrapFetchWithSIWx } from './sign-in-with-x/index.js';
3
+ export { DecodedOffer, EIP712SignedOffer, EIP712SignedReceipt, EIP712Signer, EIP712VerificationResult, JWSSignedOffer, JWSSignedReceipt, JWSSigner, OFFER_RECEIPT, OFFER_TYPES, OfferInput, OfferPayload, OfferReceiptDeclaration, OfferReceiptIssuer, RECEIPT_TYPES, ReceiptInput, ReceiptPayload, SignTypedDataFn, SignatureFormat, SignedOffer, SignedReceipt, Signer, canonicalize, convertNetworkStringToCAIP2, createEIP712OfferReceiptIssuer, createJWS, createJWSOfferReceiptIssuer, createOfferDomain, createOfferEIP712, createOfferJWS, createOfferReceiptExtension, createReceiptDomain, createReceiptEIP712, createReceiptJWS, declareOfferReceiptExtension, decodeSignedOffers, extractChainIdFromCAIP2, extractEIP155ChainId, extractJWSHeader, extractJWSPayload, extractOfferPayload, extractOffersFromPaymentRequired, extractPublicKeyFromKid, extractReceiptFromResponse, extractReceiptPayload, findAcceptsObjectFromSignedOffer, getCanonicalBytes, hashCanonical, hashOfferTypedData, hashReceiptTypedData, isEIP712SignedOffer, isEIP712SignedReceipt, isEIP712Signer, isJWSSignedOffer, isJWSSignedReceipt, isJWSSigner, prepareOfferForEIP712, prepareReceiptForEIP712, signOfferEIP712, signReceiptEIP712, verifyOfferSignatureEIP712, verifyOfferSignatureJWS, verifyReceiptMatchesOffer, verifyReceiptSignatureEIP712, verifyReceiptSignatureJWS } from './offer-receipt/index.js';
3
4
  export { PAYMENT_IDENTIFIER, PAYMENT_ID_MAX_LENGTH, PAYMENT_ID_MIN_LENGTH, PAYMENT_ID_PATTERN, PaymentIdentifierExtension, PaymentIdentifierInfo, PaymentIdentifierSchema, PaymentIdentifierValidationResult, appendPaymentIdentifierToExtensions, declarePaymentIdentifierExtension, extractAndValidatePaymentIdentifier, extractPaymentIdentifier, generatePaymentId, hasPaymentIdentifier, isPaymentIdentifierExtension, isPaymentIdentifierRequired, isValidPaymentId, paymentIdentifierResourceServerExtension, paymentIdentifierSchema, validatePaymentIdentifier, validatePaymentIdentifierRequirement } from './payment-identifier/index.js';
4
5
  import { FacilitatorExtension, PaymentPayload } from '@x402/core/types';
5
6
  import '@x402/core/http';
6
7
  import 'zod';
8
+ import 'jose';
9
+ import 'viem';
7
10
 
8
11
  /**
9
12
  * Type definitions for the EIP-2612 Gas Sponsoring Extension
@@ -140,13 +143,23 @@ declare function validateEip2612GasSponsoringInfo(info: Eip2612GasSponsoringInfo
140
143
  * it atomically before settling the Permit2 payment.
141
144
  */
142
145
 
146
+ /**
147
+ * A single transaction to be executed by the signer.
148
+ * - `0x${string}`: a pre-signed serialized transaction (broadcast as-is via sendRawTransaction)
149
+ * - `{ to, data, gas? }`: an unsigned call intent (signer signs and broadcasts)
150
+ */
151
+ type TransactionRequest = `0x${string}` | {
152
+ to: `0x${string}`;
153
+ data: `0x${string}`;
154
+ gas?: bigint;
155
+ };
143
156
  /**
144
157
  * Signer capability carried by the ERC-20 approval extension when registered in a facilitator.
145
158
  *
146
- * Mirrors FacilitatorEvmSigner (from @x402/evm) plus `sendRawTransaction`.
147
- * The extension signer owns the full approve+settle flow: it broadcasts the
148
- * pre-signed approval transaction AND executes the Permit2 settle call, enabling
149
- * production implementations to bundle both atomically (e.g., Flashbots, multicall).
159
+ * Mirrors FacilitatorEvmSigner (from @x402/evm) plus `sendTransactions`.
160
+ * The signer owns execution of multiple transactions, enabling production implementations
161
+ * to bundle them atomically (e.g., Flashbots, multicall, smart account batching)
162
+ * while simpler implementations can execute them sequentially.
150
163
  *
151
164
  * The method signatures are duplicated here (rather than extending FacilitatorEvmSigner)
152
165
  * to avoid a circular dependency between @x402/extensions and @x402/evm.
@@ -172,6 +185,7 @@ interface Erc20ApprovalGasSponsoringSigner {
172
185
  abi: readonly unknown[];
173
186
  functionName: string;
174
187
  args: readonly unknown[];
188
+ gas?: bigint;
175
189
  }): Promise<`0x${string}`>;
176
190
  sendTransaction(args: {
177
191
  to: `0x${string}`;
@@ -185,9 +199,7 @@ interface Erc20ApprovalGasSponsoringSigner {
185
199
  getCode(args: {
186
200
  address: `0x${string}`;
187
201
  }): Promise<`0x${string}` | undefined>;
188
- sendRawTransaction(args: {
189
- serializedTransaction: `0x${string}`;
190
- }): Promise<`0x${string}`>;
202
+ sendTransactions(transactions: TransactionRequest[]): Promise<`0x${string}`[]>;
191
203
  }
192
204
  /**
193
205
  * Extension identifier for the ERC-20 approval gas sponsoring extension.
@@ -200,41 +212,39 @@ declare const ERC20_APPROVAL_GAS_SPONSORING_VERSION = "1";
200
212
  /**
201
213
  * Extended extension object registered in a facilitator via registerExtension().
202
214
  * Carries the signer that owns the full approve+settle flow for ERC-20 tokens
203
- * that lack EIP-2612. The signer must have all FacilitatorEvmSigner capabilities
204
- * plus `sendRawTransaction` for broadcasting the pre-signed approval tx.
215
+ * that lack EIP-2612.
205
216
  *
206
217
  * @example
207
218
  * ```typescript
208
219
  * import { createErc20ApprovalGasSponsoringExtension } from '@x402/extensions';
209
220
  *
210
221
  * facilitator.registerExtension(
211
- * createErc20ApprovalGasSponsoringExtension(evmSigner, viemClient),
222
+ * createErc20ApprovalGasSponsoringExtension(signer),
212
223
  * );
213
224
  * ```
214
225
  */
215
226
  interface Erc20ApprovalGasSponsoringFacilitatorExtension extends FacilitatorExtension {
216
227
  key: "erc20ApprovalGasSponsoring";
217
- /** Signer with broadcast + settle capability. Optional — settlement fails gracefully if absent. */
228
+ /** Default signer with approve+settle capability. Optional — settlement fails gracefully if absent. */
218
229
  signer?: Erc20ApprovalGasSponsoringSigner;
230
+ /** Network-specific signer resolver. Takes precedence over `signer` when provided. */
231
+ signerForNetwork?: (network: string) => Erc20ApprovalGasSponsoringSigner | undefined;
219
232
  }
220
233
  /**
221
- * Signer input for {@link createErc20ApprovalGasSponsoringExtension}.
234
+ * Base signer shape without `sendTransactions`.
222
235
  * Matches the FacilitatorEvmSigner shape from @x402/evm (duplicated to avoid circular dep).
223
236
  */
224
- type Erc20ApprovalGasSponsoringBaseSigner = Omit<Erc20ApprovalGasSponsoringSigner, "sendRawTransaction">;
237
+ type Erc20ApprovalGasSponsoringBaseSigner = Omit<Erc20ApprovalGasSponsoringSigner, "sendTransactions">;
225
238
  /**
226
239
  * Create an ERC-20 approval gas sponsoring extension ready to register in a facilitator.
227
240
  *
228
- * @param signer - The EVM facilitator signer (e.g. from `toFacilitatorEvmSigner()`)
229
- * @param client - Object providing `sendRawTransaction` (e.g. a viem WalletClient)
230
- * @param client.sendRawTransaction - Broadcasts a signed transaction to the network
241
+ * @param signer - A complete signer with `sendTransactions` already implemented.
242
+ * The signer decides how to execute the transactions (sequentially, batched, or atomically).
243
+ * @param signerForNetwork - Optional network-specific signer resolver. When provided,
244
+ * takes precedence over `signer` and allows different settlement signers per network.
231
245
  * @returns A fully configured extension to pass to `facilitator.registerExtension()`
232
246
  */
233
- declare function createErc20ApprovalGasSponsoringExtension(signer: Erc20ApprovalGasSponsoringBaseSigner, client: {
234
- sendRawTransaction: (args: {
235
- serializedTransaction: `0x${string}`;
236
- }) => Promise<`0x${string}`>;
237
- }): Erc20ApprovalGasSponsoringFacilitatorExtension;
247
+ declare function createErc20ApprovalGasSponsoringExtension(signer: Erc20ApprovalGasSponsoringSigner, signerForNetwork?: (network: string) => Erc20ApprovalGasSponsoringSigner | undefined): Erc20ApprovalGasSponsoringFacilitatorExtension;
238
248
  /**
239
249
  * ERC-20 approval gas sponsoring info populated by the client.
240
250
  *
@@ -357,4 +367,4 @@ declare function extractErc20ApprovalGasSponsoringInfo(paymentPayload: PaymentPa
357
367
  */
358
368
  declare function validateErc20ApprovalGasSponsoringInfo(info: Erc20ApprovalGasSponsoringInfo): boolean;
359
369
 
360
- export { EIP2612_GAS_SPONSORING, ERC20_APPROVAL_GAS_SPONSORING, ERC20_APPROVAL_GAS_SPONSORING_VERSION, type Eip2612GasSponsoringExtension, type Eip2612GasSponsoringInfo, type Eip2612GasSponsoringServerInfo, type Erc20ApprovalGasSponsoringBaseSigner, type Erc20ApprovalGasSponsoringExtension, type Erc20ApprovalGasSponsoringFacilitatorExtension, type Erc20ApprovalGasSponsoringInfo, type Erc20ApprovalGasSponsoringServerInfo, type Erc20ApprovalGasSponsoringSigner, createErc20ApprovalGasSponsoringExtension, declareEip2612GasSponsoringExtension, declareErc20ApprovalGasSponsoringExtension, erc20ApprovalGasSponsoringSchema, extractEip2612GasSponsoringInfo, extractErc20ApprovalGasSponsoringInfo, validateEip2612GasSponsoringInfo, validateErc20ApprovalGasSponsoringInfo };
370
+ export { EIP2612_GAS_SPONSORING, ERC20_APPROVAL_GAS_SPONSORING, ERC20_APPROVAL_GAS_SPONSORING_VERSION, type Eip2612GasSponsoringExtension, type Eip2612GasSponsoringInfo, type Eip2612GasSponsoringServerInfo, type Erc20ApprovalGasSponsoringBaseSigner, type Erc20ApprovalGasSponsoringExtension, type Erc20ApprovalGasSponsoringFacilitatorExtension, type Erc20ApprovalGasSponsoringInfo, type Erc20ApprovalGasSponsoringServerInfo, type Erc20ApprovalGasSponsoringSigner, type TransactionRequest, createErc20ApprovalGasSponsoringExtension, declareEip2612GasSponsoringExtension, declareErc20ApprovalGasSponsoringExtension, erc20ApprovalGasSponsoringSchema, extractEip2612GasSponsoringInfo, extractErc20ApprovalGasSponsoringInfo, validateEip2612GasSponsoringInfo, validateErc20ApprovalGasSponsoringInfo };