@x402/extensions 2.6.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.
- package/dist/cjs/index.d.ts +32 -22
- package/dist/cjs/index.js +874 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/offer-receipt/index.d.ts +702 -0
- package/dist/cjs/offer-receipt/index.js +909 -0
- package/dist/cjs/offer-receipt/index.js.map +1 -0
- package/dist/cjs/sign-in-with-x/index.js +1 -2
- package/dist/cjs/sign-in-with-x/index.js.map +1 -1
- package/dist/esm/{chunk-O34SGKEP.mjs → chunk-QVNCC7CH.mjs} +2 -3
- package/dist/esm/chunk-QVNCC7CH.mjs.map +1 -0
- package/dist/esm/chunk-TYR4QHVX.mjs +828 -0
- package/dist/esm/chunk-TYR4QHVX.mjs.map +1 -0
- package/dist/esm/index.d.mts +32 -22
- package/dist/esm/index.mjs +97 -9
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/offer-receipt/index.d.mts +702 -0
- package/dist/esm/offer-receipt/index.mjs +97 -0
- package/dist/esm/offer-receipt/index.mjs.map +1 -0
- package/dist/esm/sign-in-with-x/index.mjs +1 -1
- package/package.json +14 -2
- package/dist/esm/chunk-O34SGKEP.mjs.map +0 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
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 `
|
|
147
|
-
* The
|
|
148
|
-
*
|
|
149
|
-
*
|
|
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
|
-
|
|
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.
|
|
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(
|
|
222
|
+
* createErc20ApprovalGasSponsoringExtension(signer),
|
|
212
223
|
* );
|
|
213
224
|
* ```
|
|
214
225
|
*/
|
|
215
226
|
interface Erc20ApprovalGasSponsoringFacilitatorExtension extends FacilitatorExtension {
|
|
216
227
|
key: "erc20ApprovalGasSponsoring";
|
|
217
|
-
/**
|
|
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
|
-
*
|
|
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, "
|
|
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 -
|
|
229
|
-
*
|
|
230
|
-
* @param
|
|
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:
|
|
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 };
|