@wtflabs/x402 0.0.1-beta.0 → 0.0.1-beta.2
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/esm/client/index.d.mts +64 -0
- package/dist/esm/config-CFBSAuxW.d.mts +10 -0
- package/dist/esm/config-Dfuvno71.d.mts +19 -0
- package/dist/esm/facilitator/index.d.mts +42 -0
- package/dist/esm/index.d.mts +16 -0
- package/dist/esm/middleware-BSjsPDKM.d.mts +93 -0
- package/dist/esm/network-FrFmmiyj.d.mts +11 -0
- package/dist/esm/paywall/index.d.mts +30 -0
- package/dist/esm/rpc-DyKXu0SX.d.mts +35 -0
- package/dist/esm/schemes/index.d.mts +533 -0
- package/dist/esm/shared/evm/index.d.mts +71 -0
- package/dist/esm/shared/index.d.mts +182 -0
- package/dist/esm/types/index.d.mts +1515 -0
- package/dist/esm/verify/index.d.mts +7 -0
- package/dist/esm/wallet-BTqCm9Zp.d.mts +27 -0
- package/dist/esm/wallet-KorGgbAj.d.mts +88 -0
- package/dist/esm/wallet-SJKJpUgQ.d.mts +167 -0
- package/dist/esm/x402Specs-CYq5tSY1.d.mts +1745 -0
- package/package.json +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { N as Network } from '../network-FrFmmiyj.mjs';
|
|
2
|
+
import * as _solana_kit from '@solana/kit';
|
|
3
|
+
import { Transaction, KeyPairSigner, RpcDevnet, SolanaRpcApiDevnet, RpcMainnet, SolanaRpcApiMainnet } from '@solana/kit';
|
|
4
|
+
import { Hex, Address } from 'viem';
|
|
5
|
+
import { R as RoutesConfig, a as RoutePattern, P as Price, E as ERC20TokenAmount, S as SPLTokenAmount } from '../middleware-BSjsPDKM.mjs';
|
|
6
|
+
import { P as PaymentRequirements, a as PaymentPayload, E as ExactSvmPayload } from '../x402Specs-CYq5tSY1.mjs';
|
|
7
|
+
import { c as createDevnetRpcClient, a as createMainnetRpcClient, g as getRpcClient, b as getRpcSubscriptions } from '../rpc-DyKXu0SX.mjs';
|
|
8
|
+
import { a as SvmConnectedClient, S as SvmSigner, c as createSignerFromBase58, b as createSvmConnectedClient, i as isSignerWallet } from '../wallet-BTqCm9Zp.mjs';
|
|
9
|
+
import 'zod';
|
|
10
|
+
import '../wallet-SJKJpUgQ.mjs';
|
|
11
|
+
import 'viem/chains';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Converts an object to a JSON-safe format by converting bigint values to strings
|
|
15
|
+
* and recursively processing nested objects and arrays
|
|
16
|
+
*
|
|
17
|
+
* @param data - The object to convert to JSON-safe format
|
|
18
|
+
* @returns A new object with all bigint values converted to strings
|
|
19
|
+
*/
|
|
20
|
+
declare function toJsonSafe<T extends object>(data: T): object;
|
|
21
|
+
|
|
22
|
+
declare const Base64EncodedRegex: RegExp;
|
|
23
|
+
/**
|
|
24
|
+
* Encodes a string to base64 format
|
|
25
|
+
*
|
|
26
|
+
* @param data - The string to be encoded to base64
|
|
27
|
+
* @returns The base64 encoded string
|
|
28
|
+
*/
|
|
29
|
+
declare function safeBase64Encode(data: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Decodes a base64 string back to its original format
|
|
32
|
+
*
|
|
33
|
+
* @param data - The base64 encoded string to be decoded
|
|
34
|
+
* @returns The decoded string in UTF-8 format
|
|
35
|
+
*/
|
|
36
|
+
declare function safeBase64Decode(data: string): string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts a network name to its corresponding chain ID
|
|
40
|
+
*
|
|
41
|
+
* @param network - The network name to convert to a chain ID
|
|
42
|
+
* @returns The chain ID for the specified network
|
|
43
|
+
* @throws Error if the network is not supported
|
|
44
|
+
*/
|
|
45
|
+
declare function getNetworkId(network: Network): number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Computes the route patterns for the given routes config
|
|
49
|
+
*
|
|
50
|
+
* @param routes - The routes config to compute the patterns for
|
|
51
|
+
* @returns The route patterns
|
|
52
|
+
*/
|
|
53
|
+
declare function computeRoutePatterns(routes: RoutesConfig): RoutePattern[];
|
|
54
|
+
/**
|
|
55
|
+
* Finds the matching route pattern for the given path and method
|
|
56
|
+
*
|
|
57
|
+
* @param routePatterns - The route patterns to search through
|
|
58
|
+
* @param path - The path to match against
|
|
59
|
+
* @param method - The HTTP method to match against
|
|
60
|
+
* @returns The matching route pattern or undefined if no match is found
|
|
61
|
+
*/
|
|
62
|
+
declare function findMatchingRoute(routePatterns: RoutePattern[], path: string, method: string): RoutePattern | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the default asset (USDC) for the given network
|
|
65
|
+
*
|
|
66
|
+
* @param network - The network to get the default asset for
|
|
67
|
+
* @returns The default asset
|
|
68
|
+
*/
|
|
69
|
+
declare function getDefaultAsset(network: Network): {
|
|
70
|
+
address: `0x${string}` | _solana_kit.Address;
|
|
71
|
+
decimals: number;
|
|
72
|
+
eip712: {
|
|
73
|
+
name: string;
|
|
74
|
+
version: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Parses the amount from the given price
|
|
79
|
+
*
|
|
80
|
+
* @param price - The price to parse
|
|
81
|
+
* @param network - The network to get the default asset for
|
|
82
|
+
* @returns The parsed amount or an error message
|
|
83
|
+
*/
|
|
84
|
+
declare function processPriceToAtomicAmount(price: Price, network: Network): {
|
|
85
|
+
maxAmountRequired: string;
|
|
86
|
+
asset: ERC20TokenAmount["asset"] | SPLTokenAmount["asset"];
|
|
87
|
+
} | {
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Finds the matching payment requirements for the given payment
|
|
92
|
+
*
|
|
93
|
+
* @param paymentRequirements - The payment requirements to search through
|
|
94
|
+
* @param payment - The payment to match against
|
|
95
|
+
* @returns The matching payment requirements or undefined if no match is found
|
|
96
|
+
*/
|
|
97
|
+
declare function findMatchingPaymentRequirements(paymentRequirements: PaymentRequirements[], payment: PaymentPayload): {
|
|
98
|
+
scheme: "exact";
|
|
99
|
+
description: string;
|
|
100
|
+
asset: string;
|
|
101
|
+
maxAmountRequired: string;
|
|
102
|
+
network: "base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "bsc" | "bsc-testnet" | "solana-devnet" | "solana";
|
|
103
|
+
resource: string;
|
|
104
|
+
mimeType: string;
|
|
105
|
+
payTo: string;
|
|
106
|
+
maxTimeoutSeconds: number;
|
|
107
|
+
outputSchema?: Record<string, any> | undefined;
|
|
108
|
+
paymentType?: "permit" | "eip3009" | "permit2" | undefined;
|
|
109
|
+
extra?: Record<string, any> | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Decodes the X-PAYMENT-RESPONSE header
|
|
113
|
+
*
|
|
114
|
+
* @param header - The X-PAYMENT-RESPONSE header to decode
|
|
115
|
+
* @returns The decoded payment response
|
|
116
|
+
*/
|
|
117
|
+
declare function decodeXPaymentResponse(header: string): {
|
|
118
|
+
success: boolean;
|
|
119
|
+
transaction: Hex;
|
|
120
|
+
network: Network;
|
|
121
|
+
payer: Address;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Given an object with a base64 encoded transaction, decode the
|
|
126
|
+
* base64 encoded transaction into a solana transaction object.
|
|
127
|
+
*
|
|
128
|
+
* @param svmPayload - The SVM payload to decode
|
|
129
|
+
* @returns The decoded transaction
|
|
130
|
+
*/
|
|
131
|
+
declare function decodeTransactionFromPayload(svmPayload: ExactSvmPayload): Transaction;
|
|
132
|
+
/**
|
|
133
|
+
* Extract the token sender (owner of the source token account)
|
|
134
|
+
* from the TransferChecked instruction.
|
|
135
|
+
*
|
|
136
|
+
* @param transaction - The transaction to extract the token payer from
|
|
137
|
+
* @returns The token payer address as a base58 string
|
|
138
|
+
*/
|
|
139
|
+
declare function getTokenPayerFromTransaction(transaction: Transaction): string;
|
|
140
|
+
/**
|
|
141
|
+
* Sign and simulate a transaction.
|
|
142
|
+
*
|
|
143
|
+
* @param signer - The signer that will sign the transaction
|
|
144
|
+
* @param transaction - The transaction to sign and simulate
|
|
145
|
+
* @param rpc - The RPC client to use to simulate the transaction
|
|
146
|
+
* @returns The transaction simulation result
|
|
147
|
+
*/
|
|
148
|
+
declare function signAndSimulateTransaction(signer: KeyPairSigner, transaction: Transaction, rpc: RpcDevnet<SolanaRpcApiDevnet> | RpcMainnet<SolanaRpcApiMainnet>): Promise<Readonly<{
|
|
149
|
+
context: Readonly<{
|
|
150
|
+
slot: _solana_kit.Slot;
|
|
151
|
+
}>;
|
|
152
|
+
value: Readonly<{
|
|
153
|
+
readonly accounts: null;
|
|
154
|
+
}> & Readonly<{
|
|
155
|
+
err: _solana_kit.TransactionError | null;
|
|
156
|
+
logs: string[] | null;
|
|
157
|
+
returnData: Readonly<{
|
|
158
|
+
data: _solana_kit.Base64EncodedDataResponse;
|
|
159
|
+
programId: _solana_kit.Address;
|
|
160
|
+
}> | null;
|
|
161
|
+
unitsConsumed?: bigint;
|
|
162
|
+
}>;
|
|
163
|
+
}>>;
|
|
164
|
+
|
|
165
|
+
declare const index_KeyPairSigner: typeof KeyPairSigner;
|
|
166
|
+
declare const index_SvmConnectedClient: typeof SvmConnectedClient;
|
|
167
|
+
declare const index_SvmSigner: typeof SvmSigner;
|
|
168
|
+
declare const index_createDevnetRpcClient: typeof createDevnetRpcClient;
|
|
169
|
+
declare const index_createMainnetRpcClient: typeof createMainnetRpcClient;
|
|
170
|
+
declare const index_createSignerFromBase58: typeof createSignerFromBase58;
|
|
171
|
+
declare const index_createSvmConnectedClient: typeof createSvmConnectedClient;
|
|
172
|
+
declare const index_decodeTransactionFromPayload: typeof decodeTransactionFromPayload;
|
|
173
|
+
declare const index_getRpcClient: typeof getRpcClient;
|
|
174
|
+
declare const index_getRpcSubscriptions: typeof getRpcSubscriptions;
|
|
175
|
+
declare const index_getTokenPayerFromTransaction: typeof getTokenPayerFromTransaction;
|
|
176
|
+
declare const index_isSignerWallet: typeof isSignerWallet;
|
|
177
|
+
declare const index_signAndSimulateTransaction: typeof signAndSimulateTransaction;
|
|
178
|
+
declare namespace index {
|
|
179
|
+
export { index_KeyPairSigner as KeyPairSigner, index_SvmConnectedClient as SvmConnectedClient, index_SvmSigner as SvmSigner, index_createDevnetRpcClient as createDevnetRpcClient, index_createMainnetRpcClient as createMainnetRpcClient, index_createSignerFromBase58 as createSignerFromBase58, index_createSvmConnectedClient as createSvmConnectedClient, index_decodeTransactionFromPayload as decodeTransactionFromPayload, index_getRpcClient as getRpcClient, index_getRpcSubscriptions as getRpcSubscriptions, index_getTokenPayerFromTransaction as getTokenPayerFromTransaction, index_isSignerWallet as isSignerWallet, index_signAndSimulateTransaction as signAndSimulateTransaction };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export { Base64EncodedRegex, computeRoutePatterns, decodeXPaymentResponse, findMatchingPaymentRequirements, findMatchingRoute, getDefaultAsset, getNetworkId, processPriceToAtomicAmount, safeBase64Decode, safeBase64Encode, index as svm, toJsonSafe };
|