thirdweb 5.108.5-nightly-ce9220ea00e5a58bf3f6997733b4b69df981cba8-20250930000345 → 5.108.5
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/exports/x402.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/x402/facilitator.js +18 -2
- package/dist/cjs/x402/facilitator.js.map +1 -1
- package/dist/cjs/x402/settle-payment.js +2 -1
- package/dist/cjs/x402/settle-payment.js.map +1 -1
- package/dist/esm/exports/x402.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/x402/facilitator.js +18 -2
- package/dist/esm/x402/facilitator.js.map +1 -1
- package/dist/esm/x402/settle-payment.js +2 -1
- package/dist/esm/x402/settle-payment.js.map +1 -1
- package/dist/scripts/bridge-widget.js +2 -2
- package/dist/types/exports/x402.d.ts +2 -2
- package/dist/types/exports/x402.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/x402/facilitator.d.ts +18 -2
- package/dist/types/x402/facilitator.d.ts.map +1 -1
- package/dist/types/x402/settle-payment.d.ts +3 -2
- package/dist/types/x402/settle-payment.d.ts.map +1 -1
- package/dist/types/x402/types.d.ts +4 -1
- package/dist/types/x402/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/x402.ts +5 -0
- package/src/version.ts +1 -1
- package/src/x402/facilitator.ts +22 -2
- package/src/x402/settle-payment.ts +4 -2
- package/src/x402/types.ts +5 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { decodePayment, encodePayment } from "../x402/encode.js";
|
|
2
|
-
export { facilitator, type ThirdwebX402Facilitator, type ThirdwebX402FacilitatorConfig, } from "../x402/facilitator.js";
|
|
2
|
+
export { facilitator, type ThirdwebX402Facilitator, type ThirdwebX402FacilitatorConfig, type WaitUntil, } from "../x402/facilitator.js";
|
|
3
3
|
export { wrapFetchWithPayment } from "../x402/fetchWithPayment.js";
|
|
4
4
|
export { settlePayment } from "../x402/settle-payment.js";
|
|
5
|
-
export type { PaymentArgs, SettlePaymentResult, VerifyPaymentResult, } from "../x402/types.js";
|
|
5
|
+
export type { ERC20TokenAmount, PaymentArgs, PaymentRequiredResult, SettlePaymentArgs, SettlePaymentResult, SupportedSignatureType, VerifyPaymentResult, } from "../x402/types.js";
|
|
6
6
|
export { verifyPayment } from "../x402/verify-payment.js";
|
|
7
7
|
//# sourceMappingURL=x402.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x402.d.ts","sourceRoot":"","sources":["../../../src/exports/x402.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,WAAW,EACX,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,
|
|
1
|
+
{"version":3,"file":"x402.d.ts","sourceRoot":"","sources":["../../../src/exports/x402.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,WAAW,EACX,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,SAAS,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.108.5
|
|
1
|
+
export declare const version = "5.108.5";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAY,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { VerifyResponse } from "x402/types";
|
|
2
2
|
import type { ThirdwebClient } from "../client/client.js";
|
|
3
3
|
import type { FacilitatorSettleResponse, FacilitatorSupportedResponse, RequestedPaymentPayload, RequestedPaymentRequirements } from "./schemas.js";
|
|
4
|
+
export type WaitUntil = "simulated" | "submitted" | "confirmed";
|
|
4
5
|
export type ThirdwebX402FacilitatorConfig = {
|
|
5
6
|
client: ThirdwebClient;
|
|
6
7
|
serverWalletAddress: string;
|
|
7
|
-
waitUtil?:
|
|
8
|
+
waitUtil?: WaitUntil;
|
|
8
9
|
vaultAccessToken?: string;
|
|
9
10
|
baseUrl?: string;
|
|
10
11
|
};
|
|
@@ -22,7 +23,7 @@ export type ThirdwebX402Facilitator = {
|
|
|
22
23
|
list: Record<string, string>;
|
|
23
24
|
}>;
|
|
24
25
|
verify: (payload: RequestedPaymentPayload, paymentRequirements: RequestedPaymentRequirements) => Promise<VerifyResponse>;
|
|
25
|
-
settle: (payload: RequestedPaymentPayload, paymentRequirements: RequestedPaymentRequirements) => Promise<FacilitatorSettleResponse>;
|
|
26
|
+
settle: (payload: RequestedPaymentPayload, paymentRequirements: RequestedPaymentRequirements, waitUtil?: WaitUntil) => Promise<FacilitatorSettleResponse>;
|
|
26
27
|
supported: (filters?: {
|
|
27
28
|
chainId: number;
|
|
28
29
|
tokenAddress?: string;
|
|
@@ -63,6 +64,21 @@ export type ThirdwebX402Facilitator = {
|
|
|
63
64
|
* },
|
|
64
65
|
* thirdwebX402Facilitator,
|
|
65
66
|
* );
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* #### Configuration Options
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* const thirdwebX402Facilitator = facilitator({
|
|
73
|
+
* client: client,
|
|
74
|
+
* serverWalletAddress: "0x1234567890123456789012345678901234567890",
|
|
75
|
+
* // Optional: Wait behavior for settlements
|
|
76
|
+
* // - "simulated": Only simulate the transaction (fastest)
|
|
77
|
+
* // - "submitted": Wait until transaction is submitted
|
|
78
|
+
* // - "confirmed": Wait for full on-chain confirmation (slowest, default)
|
|
79
|
+
* waitUntil: "confirmed",
|
|
80
|
+
* });
|
|
81
|
+
|
|
66
82
|
* ```
|
|
67
83
|
*
|
|
68
84
|
* @bridge x402
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facilitator.d.ts","sourceRoot":"","sources":["../../../src/x402/facilitator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,cAAc,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"facilitator.d.ts","sourceRoot":"","sources":["../../../src/x402/facilitator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC7B,MAAM,cAAc,CAAC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WAAW,CACzB,MAAM,EAAE,6BAA6B,GACpC,uBAAuB,CA0JzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type SettlePaymentArgs, type SettlePaymentResult } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Verifies and processes X402 payments for protected resources.
|
|
4
4
|
*
|
|
@@ -89,6 +89,7 @@ import { type PaymentArgs, type SettlePaymentResult } from "./types.js";
|
|
|
89
89
|
* payTo: "0x1234567890123456789012345678901234567890",
|
|
90
90
|
* network: arbitrumSepolia, // or any other chain
|
|
91
91
|
* price: "$0.05",
|
|
92
|
+
* waitUntil: "submitted",
|
|
92
93
|
* facilitator: thirdwebFacilitator,
|
|
93
94
|
* });
|
|
94
95
|
*
|
|
@@ -115,5 +116,5 @@ import { type PaymentArgs, type SettlePaymentResult } from "./types.js";
|
|
|
115
116
|
* @beta
|
|
116
117
|
* @bridge x402
|
|
117
118
|
*/
|
|
118
|
-
export declare function settlePayment(args:
|
|
119
|
+
export declare function settlePayment(args: SettlePaymentArgs): Promise<SettlePaymentResult>;
|
|
119
120
|
//# sourceMappingURL=settle-payment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settle-payment.d.ts","sourceRoot":"","sources":["../../../src/x402/settle-payment.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"settle-payment.d.ts","sourceRoot":"","sources":["../../../src/x402/settle-payment.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoHG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,mBAAmB,CAAC,CA4D9B"}
|
|
@@ -3,7 +3,7 @@ import type z from "zod";
|
|
|
3
3
|
import type { Chain } from "../chains/types.js";
|
|
4
4
|
import type { Address } from "../utils/address.js";
|
|
5
5
|
import type { Prettify } from "../utils/type-utils.js";
|
|
6
|
-
import type { ThirdwebX402Facilitator } from "./facilitator.js";
|
|
6
|
+
import type { ThirdwebX402Facilitator, WaitUntil } from "./facilitator.js";
|
|
7
7
|
import type { FacilitatorNetwork, FacilitatorSettleResponse, FacilitatorSupportedAssetSchema, RequestedPaymentPayload, RequestedPaymentRequirements, SupportedSignatureTypeSchema } from "./schemas.js";
|
|
8
8
|
export declare const x402Version = 1;
|
|
9
9
|
/**
|
|
@@ -29,6 +29,9 @@ export type PaymentArgs = {
|
|
|
29
29
|
/** Optional configuration for the payment middleware route */
|
|
30
30
|
routeConfig?: PaymentMiddlewareConfig;
|
|
31
31
|
};
|
|
32
|
+
export type SettlePaymentArgs = PaymentArgs & {
|
|
33
|
+
waitUntil?: WaitUntil;
|
|
34
|
+
};
|
|
32
35
|
export type PaymentRequiredResult = {
|
|
33
36
|
/** HTTP 402 - Payment Required, verification or processing failed or payment missing */
|
|
34
37
|
status: 402;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/x402/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","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C,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -399,7 +399,7 @@
|
|
|
399
399
|
}
|
|
400
400
|
},
|
|
401
401
|
"typings": "./dist/types/exports/thirdweb.d.ts",
|
|
402
|
-
"version": "5.108.5
|
|
402
|
+
"version": "5.108.5",
|
|
403
403
|
"scripts": {
|
|
404
404
|
"bench": "vitest -c ./test/vitest.config.ts bench",
|
|
405
405
|
"bench:compare": "bun run ./benchmarks/run.ts",
|
package/src/exports/x402.ts
CHANGED
|
@@ -3,12 +3,17 @@ export {
|
|
|
3
3
|
facilitator,
|
|
4
4
|
type ThirdwebX402Facilitator,
|
|
5
5
|
type ThirdwebX402FacilitatorConfig,
|
|
6
|
+
type WaitUntil,
|
|
6
7
|
} from "../x402/facilitator.js";
|
|
7
8
|
export { wrapFetchWithPayment } from "../x402/fetchWithPayment.js";
|
|
8
9
|
export { settlePayment } from "../x402/settle-payment.js";
|
|
9
10
|
export type {
|
|
11
|
+
ERC20TokenAmount,
|
|
10
12
|
PaymentArgs,
|
|
13
|
+
PaymentRequiredResult,
|
|
14
|
+
SettlePaymentArgs,
|
|
11
15
|
SettlePaymentResult,
|
|
16
|
+
SupportedSignatureType,
|
|
12
17
|
VerifyPaymentResult,
|
|
13
18
|
} from "../x402/types.js";
|
|
14
19
|
export { verifyPayment } from "../x402/verify-payment.js";
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "5.108.5
|
|
1
|
+
export const version = "5.108.5";
|
package/src/x402/facilitator.ts
CHANGED
|
@@ -9,10 +9,12 @@ import type {
|
|
|
9
9
|
RequestedPaymentRequirements,
|
|
10
10
|
} from "./schemas.js";
|
|
11
11
|
|
|
12
|
+
export type WaitUntil = "simulated" | "submitted" | "confirmed";
|
|
13
|
+
|
|
12
14
|
export type ThirdwebX402FacilitatorConfig = {
|
|
13
15
|
client: ThirdwebClient;
|
|
14
16
|
serverWalletAddress: string;
|
|
15
|
-
waitUtil?:
|
|
17
|
+
waitUtil?: WaitUntil;
|
|
16
18
|
vaultAccessToken?: string;
|
|
17
19
|
baseUrl?: string;
|
|
18
20
|
};
|
|
@@ -37,6 +39,7 @@ export type ThirdwebX402Facilitator = {
|
|
|
37
39
|
settle: (
|
|
38
40
|
payload: RequestedPaymentPayload,
|
|
39
41
|
paymentRequirements: RequestedPaymentRequirements,
|
|
42
|
+
waitUtil?: WaitUntil,
|
|
40
43
|
) => Promise<FacilitatorSettleResponse>;
|
|
41
44
|
supported: (filters?: {
|
|
42
45
|
chainId: number;
|
|
@@ -81,6 +84,21 @@ const DEFAULT_BASE_URL = "https://api.thirdweb.com/v1/payments/x402";
|
|
|
81
84
|
* },
|
|
82
85
|
* thirdwebX402Facilitator,
|
|
83
86
|
* );
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* #### Configuration Options
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* const thirdwebX402Facilitator = facilitator({
|
|
93
|
+
* client: client,
|
|
94
|
+
* serverWalletAddress: "0x1234567890123456789012345678901234567890",
|
|
95
|
+
* // Optional: Wait behavior for settlements
|
|
96
|
+
* // - "simulated": Only simulate the transaction (fastest)
|
|
97
|
+
* // - "submitted": Wait until transaction is submitted
|
|
98
|
+
* // - "confirmed": Wait for full on-chain confirmation (slowest, default)
|
|
99
|
+
* waitUntil: "confirmed",
|
|
100
|
+
* });
|
|
101
|
+
|
|
84
102
|
* ```
|
|
85
103
|
*
|
|
86
104
|
* @bridge x402
|
|
@@ -167,12 +185,14 @@ export function facilitator(
|
|
|
167
185
|
async settle(
|
|
168
186
|
payload: RequestedPaymentPayload,
|
|
169
187
|
paymentRequirements: RequestedPaymentRequirements,
|
|
188
|
+
waitUtil?: WaitUntil,
|
|
170
189
|
): Promise<FacilitatorSettleResponse> {
|
|
171
190
|
const url = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
172
191
|
|
|
173
192
|
let headers = { "Content-Type": "application/json" };
|
|
174
193
|
const authHeaders = await facilitator.createAuthHeaders();
|
|
175
194
|
headers = { ...headers, ...authHeaders.settle };
|
|
195
|
+
const waitUtilParam = waitUtil || config.waitUtil;
|
|
176
196
|
|
|
177
197
|
const res = await fetch(`${url}/settle`, {
|
|
178
198
|
method: "POST",
|
|
@@ -181,7 +201,7 @@ export function facilitator(
|
|
|
181
201
|
x402Version: payload.x402Version,
|
|
182
202
|
paymentPayload: payload,
|
|
183
203
|
paymentRequirements: paymentRequirements,
|
|
184
|
-
...(
|
|
204
|
+
...(waitUtilParam ? { waitUtil: waitUtilParam } : {}),
|
|
185
205
|
}),
|
|
186
206
|
});
|
|
187
207
|
|
|
@@ -2,7 +2,7 @@ import { stringify } from "../utils/json.js";
|
|
|
2
2
|
import { decodePaymentRequest } from "./common.js";
|
|
3
3
|
import { safeBase64Encode } from "./encode.js";
|
|
4
4
|
import {
|
|
5
|
-
type
|
|
5
|
+
type SettlePaymentArgs,
|
|
6
6
|
type SettlePaymentResult,
|
|
7
7
|
x402Version,
|
|
8
8
|
} from "./types.js";
|
|
@@ -97,6 +97,7 @@ import {
|
|
|
97
97
|
* payTo: "0x1234567890123456789012345678901234567890",
|
|
98
98
|
* network: arbitrumSepolia, // or any other chain
|
|
99
99
|
* price: "$0.05",
|
|
100
|
+
* waitUntil: "submitted",
|
|
100
101
|
* facilitator: thirdwebFacilitator,
|
|
101
102
|
* });
|
|
102
103
|
*
|
|
@@ -124,7 +125,7 @@ import {
|
|
|
124
125
|
* @bridge x402
|
|
125
126
|
*/
|
|
126
127
|
export async function settlePayment(
|
|
127
|
-
args:
|
|
128
|
+
args: SettlePaymentArgs,
|
|
128
129
|
): Promise<SettlePaymentResult> {
|
|
129
130
|
const { routeConfig = {}, facilitator } = args;
|
|
130
131
|
const { errorMessages } = routeConfig;
|
|
@@ -142,6 +143,7 @@ export async function settlePayment(
|
|
|
142
143
|
const settlement = await facilitator.settle(
|
|
143
144
|
decodedPayment,
|
|
144
145
|
selectedPaymentRequirements,
|
|
146
|
+
args.waitUntil,
|
|
145
147
|
);
|
|
146
148
|
|
|
147
149
|
if (settlement.success) {
|
package/src/x402/types.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type z from "zod";
|
|
|
3
3
|
import type { Chain } from "../chains/types.js";
|
|
4
4
|
import type { Address } from "../utils/address.js";
|
|
5
5
|
import type { Prettify } from "../utils/type-utils.js";
|
|
6
|
-
import type { ThirdwebX402Facilitator } from "./facilitator.js";
|
|
6
|
+
import type { ThirdwebX402Facilitator, WaitUntil } from "./facilitator.js";
|
|
7
7
|
import type {
|
|
8
8
|
FacilitatorNetwork,
|
|
9
9
|
FacilitatorSettleResponse,
|
|
@@ -39,6 +39,10 @@ export type PaymentArgs = {
|
|
|
39
39
|
routeConfig?: PaymentMiddlewareConfig;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
export type SettlePaymentArgs = PaymentArgs & {
|
|
43
|
+
waitUntil?: WaitUntil;
|
|
44
|
+
};
|
|
45
|
+
|
|
42
46
|
export type PaymentRequiredResult = {
|
|
43
47
|
/** HTTP 402 - Payment Required, verification or processing failed or payment missing */
|
|
44
48
|
status: 402;
|