thirdweb 5.113.0 → 5.114.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.
Files changed (52) hide show
  1. package/dist/cjs/version.js +1 -1
  2. package/dist/cjs/x402/common.js +2 -10
  3. package/dist/cjs/x402/common.js.map +1 -1
  4. package/dist/cjs/x402/facilitator.js +1 -0
  5. package/dist/cjs/x402/facilitator.js.map +1 -1
  6. package/dist/cjs/x402/fetchWithPayment.js +5 -8
  7. package/dist/cjs/x402/fetchWithPayment.js.map +1 -1
  8. package/dist/cjs/x402/schemas.js +4 -1
  9. package/dist/cjs/x402/schemas.js.map +1 -1
  10. package/dist/cjs/x402/settle-payment.js +12 -1
  11. package/dist/cjs/x402/settle-payment.js.map +1 -1
  12. package/dist/cjs/x402/types.js +6 -1
  13. package/dist/cjs/x402/types.js.map +1 -1
  14. package/dist/cjs/x402/verify-payment.js +11 -1
  15. package/dist/cjs/x402/verify-payment.js.map +1 -1
  16. package/dist/esm/version.js +1 -1
  17. package/dist/esm/x402/common.js +2 -10
  18. package/dist/esm/x402/common.js.map +1 -1
  19. package/dist/esm/x402/facilitator.js +1 -0
  20. package/dist/esm/x402/facilitator.js.map +1 -1
  21. package/dist/esm/x402/fetchWithPayment.js +5 -8
  22. package/dist/esm/x402/fetchWithPayment.js.map +1 -1
  23. package/dist/esm/x402/schemas.js +4 -1
  24. package/dist/esm/x402/schemas.js.map +1 -1
  25. package/dist/esm/x402/settle-payment.js +12 -1
  26. package/dist/esm/x402/settle-payment.js.map +1 -1
  27. package/dist/esm/x402/types.js +5 -0
  28. package/dist/esm/x402/types.js.map +1 -1
  29. package/dist/esm/x402/verify-payment.js +11 -1
  30. package/dist/esm/x402/verify-payment.js.map +1 -1
  31. package/dist/scripts/bridge-widget.js +2 -2
  32. package/dist/types/version.d.ts +1 -1
  33. package/dist/types/x402/common.d.ts.map +1 -1
  34. package/dist/types/x402/facilitator.d.ts.map +1 -1
  35. package/dist/types/x402/fetchWithPayment.d.ts.map +1 -1
  36. package/dist/types/x402/schemas.d.ts +15 -15
  37. package/dist/types/x402/schemas.d.ts.map +1 -1
  38. package/dist/types/x402/settle-payment.d.ts +12 -1
  39. package/dist/types/x402/settle-payment.d.ts.map +1 -1
  40. package/dist/types/x402/types.d.ts +13 -1
  41. package/dist/types/x402/types.d.ts.map +1 -1
  42. package/dist/types/x402/verify-payment.d.ts +11 -1
  43. package/dist/types/x402/verify-payment.d.ts.map +1 -1
  44. package/package.json +3 -3
  45. package/src/version.ts +1 -1
  46. package/src/x402/common.ts +2 -20
  47. package/src/x402/facilitator.ts +1 -0
  48. package/src/x402/fetchWithPayment.ts +5 -11
  49. package/src/x402/schemas.ts +4 -1
  50. package/src/x402/settle-payment.ts +12 -1
  51. package/src/x402/types.ts +16 -1
  52. package/src/x402/verify-payment.ts +11 -1
@@ -1,2 +1,2 @@
1
- export declare const version = "5.113.0";
1
+ export declare const version = "5.114.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/x402/common.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM1D,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE5B,MAAM,YAAY,CAAC;AAEpB,KAAK,4BAA4B,GAAG;IAClC,MAAM,EAAE,GAAG,CAAC;IACZ,mBAAmB,EAAE,4BAA4B,EAAE,CAAC;IACpD,2BAA2B,EAAE,4BAA4B,CAAC;IAC1D,cAAc,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,4BAA4B,GAAG,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,EAElC,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,EAC9B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B,CAAC,EAAE,CAC5B,mBAAmB,EAAE,4BAA4B,EAAE,KAChD,4BAA4B,GAAG,SAAS,CAAC;CAC/C,IAEa,OAAO,WAAW,EAAE,OAAO,WAAW,uBA8FrD"}
1
+ {"version":3,"file":"fetchWithPayment.d.ts","sourceRoot":"","sources":["../../../src/x402/fetchWithPayment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAGL,KAAK,4BAA4B,EAElC,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,EAC9B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B,CAAC,EAAE,CAC5B,mBAAmB,EAAE,4BAA4B,EAAE,KAChD,4BAA4B,GAAG,SAAS,CAAC;CAC/C,IAEa,OAAO,WAAW,EAAE,OAAO,WAAW,uBA6FrD"}
@@ -5,7 +5,6 @@ declare const FacilitatorNetworkSchema: z.ZodString;
5
5
  export type FacilitatorNetwork = z.infer<typeof FacilitatorNetworkSchema>;
6
6
  declare const RequestedPaymentPayloadSchema: z.ZodObject<{
7
7
  x402Version: z.ZodEffects<z.ZodNumber, number, number>;
8
- scheme: z.ZodEnum<["exact"]>;
9
8
  payload: z.ZodUnion<[z.ZodObject<{
10
9
  signature: z.ZodString;
11
10
  authorization: z.ZodObject<{
@@ -59,6 +58,7 @@ declare const RequestedPaymentPayloadSchema: z.ZodObject<{
59
58
  }>]>;
60
59
  } & {
61
60
  network: z.ZodString;
61
+ scheme: z.ZodUnion<[z.ZodLiteral<"exact">, z.ZodLiteral<"upto">]>;
62
62
  }, "strip", z.ZodTypeAny, {
63
63
  payload: {
64
64
  signature: string;
@@ -73,7 +73,7 @@ declare const RequestedPaymentPayloadSchema: z.ZodObject<{
73
73
  } | {
74
74
  transaction: string;
75
75
  };
76
- scheme: "exact";
76
+ scheme: "exact" | "upto";
77
77
  network: string;
78
78
  x402Version: number;
79
79
  }, {
@@ -90,7 +90,7 @@ declare const RequestedPaymentPayloadSchema: z.ZodObject<{
90
90
  } | {
91
91
  transaction: string;
92
92
  };
93
- scheme: "exact";
93
+ scheme: "exact" | "upto";
94
94
  network: string;
95
95
  x402Version: number;
96
96
  }>;
@@ -101,7 +101,6 @@ export type UnsignedPaymentPayload = Omit<RequestedPaymentPayload, "payload"> &
101
101
  };
102
102
  };
103
103
  export declare const RequestedPaymentRequirementsSchema: z.ZodObject<{
104
- scheme: z.ZodEnum<["exact"]>;
105
104
  maxAmountRequired: z.ZodEffects<z.ZodString, string, string>;
106
105
  resource: z.ZodString;
107
106
  description: z.ZodString;
@@ -113,9 +112,10 @@ export declare const RequestedPaymentRequirementsSchema: z.ZodObject<{
113
112
  extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
114
113
  } & {
115
114
  network: z.ZodString;
115
+ scheme: z.ZodUnion<[z.ZodLiteral<"exact">, z.ZodLiteral<"upto">]>;
116
116
  }, "strip", z.ZodTypeAny, {
117
117
  description: string;
118
- scheme: "exact";
118
+ scheme: "exact" | "upto";
119
119
  resource: string;
120
120
  mimeType: string;
121
121
  network: string;
@@ -127,7 +127,7 @@ export declare const RequestedPaymentRequirementsSchema: z.ZodObject<{
127
127
  extra?: Record<string, any> | undefined;
128
128
  }, {
129
129
  description: string;
130
- scheme: "exact";
130
+ scheme: "exact" | "upto";
131
131
  resource: string;
132
132
  mimeType: string;
133
133
  network: string;
@@ -154,16 +154,16 @@ declare const FacilitatorSettleResponseSchema: z.ZodObject<{
154
154
  network: string;
155
155
  errorMessage?: string | undefined;
156
156
  fundWalletLink?: string | undefined;
157
- errorReason?: "insufficient_funds" | "invalid_exact_evm_payload_authorization_valid_after" | "invalid_exact_evm_payload_authorization_valid_before" | "invalid_exact_evm_payload_authorization_value" | "invalid_exact_evm_payload_signature" | "invalid_exact_evm_payload_recipient_mismatch" | "invalid_exact_svm_payload_transaction" | "invalid_exact_svm_payload_transaction_amount_mismatch" | "invalid_exact_svm_payload_transaction_create_ata_instruction" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset" | "invalid_exact_svm_payload_transaction_instructions" | "invalid_exact_svm_payload_transaction_instructions_length" | "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high" | "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked" | "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked" | "invalid_exact_svm_payload_transaction_not_a_transfer_instruction" | "invalid_exact_svm_payload_transaction_receiver_ata_not_found" | "invalid_exact_svm_payload_transaction_sender_ata_not_found" | "invalid_exact_svm_payload_transaction_simulation_failed" | "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata" | "invalid_network" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_payment" | "payment_expired" | "unsupported_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "settle_exact_svm_block_height_exceeded" | "settle_exact_svm_transaction_confirmation_timed_out" | "unexpected_settle_error" | "unexpected_verify_error" | undefined;
158
157
  payer?: string | undefined;
158
+ errorReason?: "insufficient_funds" | "invalid_exact_evm_payload_authorization_valid_after" | "invalid_exact_evm_payload_authorization_valid_before" | "invalid_exact_evm_payload_authorization_value" | "invalid_exact_evm_payload_signature" | "invalid_exact_evm_payload_recipient_mismatch" | "invalid_exact_svm_payload_transaction" | "invalid_exact_svm_payload_transaction_amount_mismatch" | "invalid_exact_svm_payload_transaction_create_ata_instruction" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset" | "invalid_exact_svm_payload_transaction_instructions" | "invalid_exact_svm_payload_transaction_instructions_length" | "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high" | "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked" | "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked" | "invalid_exact_svm_payload_transaction_not_a_transfer_instruction" | "invalid_exact_svm_payload_transaction_receiver_ata_not_found" | "invalid_exact_svm_payload_transaction_sender_ata_not_found" | "invalid_exact_svm_payload_transaction_simulation_failed" | "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata" | "invalid_network" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_payment" | "payment_expired" | "unsupported_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "settle_exact_svm_block_height_exceeded" | "settle_exact_svm_transaction_confirmation_timed_out" | "unexpected_settle_error" | "unexpected_verify_error" | undefined;
159
159
  }, {
160
160
  transaction: string;
161
161
  success: boolean;
162
162
  network: string;
163
163
  errorMessage?: string | undefined;
164
164
  fundWalletLink?: string | undefined;
165
- errorReason?: "insufficient_funds" | "invalid_exact_evm_payload_authorization_valid_after" | "invalid_exact_evm_payload_authorization_valid_before" | "invalid_exact_evm_payload_authorization_value" | "invalid_exact_evm_payload_signature" | "invalid_exact_evm_payload_recipient_mismatch" | "invalid_exact_svm_payload_transaction" | "invalid_exact_svm_payload_transaction_amount_mismatch" | "invalid_exact_svm_payload_transaction_create_ata_instruction" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset" | "invalid_exact_svm_payload_transaction_instructions" | "invalid_exact_svm_payload_transaction_instructions_length" | "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high" | "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked" | "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked" | "invalid_exact_svm_payload_transaction_not_a_transfer_instruction" | "invalid_exact_svm_payload_transaction_receiver_ata_not_found" | "invalid_exact_svm_payload_transaction_sender_ata_not_found" | "invalid_exact_svm_payload_transaction_simulation_failed" | "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata" | "invalid_network" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_payment" | "payment_expired" | "unsupported_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "settle_exact_svm_block_height_exceeded" | "settle_exact_svm_transaction_confirmation_timed_out" | "unexpected_settle_error" | "unexpected_verify_error" | undefined;
166
165
  payer?: string | undefined;
166
+ errorReason?: "insufficient_funds" | "invalid_exact_evm_payload_authorization_valid_after" | "invalid_exact_evm_payload_authorization_valid_before" | "invalid_exact_evm_payload_authorization_value" | "invalid_exact_evm_payload_signature" | "invalid_exact_evm_payload_recipient_mismatch" | "invalid_exact_svm_payload_transaction" | "invalid_exact_svm_payload_transaction_amount_mismatch" | "invalid_exact_svm_payload_transaction_create_ata_instruction" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset" | "invalid_exact_svm_payload_transaction_instructions" | "invalid_exact_svm_payload_transaction_instructions_length" | "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high" | "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked" | "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked" | "invalid_exact_svm_payload_transaction_not_a_transfer_instruction" | "invalid_exact_svm_payload_transaction_receiver_ata_not_found" | "invalid_exact_svm_payload_transaction_sender_ata_not_found" | "invalid_exact_svm_payload_transaction_simulation_failed" | "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata" | "invalid_network" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_payment" | "payment_expired" | "unsupported_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "settle_exact_svm_block_height_exceeded" | "settle_exact_svm_transaction_confirmation_timed_out" | "unexpected_settle_error" | "unexpected_verify_error" | undefined;
167
167
  }>;
168
168
  export type FacilitatorSettleResponse = z.infer<typeof FacilitatorSettleResponseSchema>;
169
169
  declare const FacilitatorVerifyResponseSchema: z.ZodObject<{
@@ -177,21 +177,21 @@ declare const FacilitatorVerifyResponseSchema: z.ZodObject<{
177
177
  isValid: boolean;
178
178
  errorMessage?: string | undefined;
179
179
  fundWalletLink?: string | undefined;
180
- payer?: string | undefined;
181
180
  invalidReason?: "insufficient_funds" | "invalid_exact_evm_payload_authorization_valid_after" | "invalid_exact_evm_payload_authorization_valid_before" | "invalid_exact_evm_payload_authorization_value" | "invalid_exact_evm_payload_signature" | "invalid_exact_evm_payload_recipient_mismatch" | "invalid_exact_svm_payload_transaction" | "invalid_exact_svm_payload_transaction_amount_mismatch" | "invalid_exact_svm_payload_transaction_create_ata_instruction" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset" | "invalid_exact_svm_payload_transaction_instructions" | "invalid_exact_svm_payload_transaction_instructions_length" | "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high" | "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked" | "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked" | "invalid_exact_svm_payload_transaction_not_a_transfer_instruction" | "invalid_exact_svm_payload_transaction_receiver_ata_not_found" | "invalid_exact_svm_payload_transaction_sender_ata_not_found" | "invalid_exact_svm_payload_transaction_simulation_failed" | "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata" | "invalid_network" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_payment" | "payment_expired" | "unsupported_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "settle_exact_svm_block_height_exceeded" | "settle_exact_svm_transaction_confirmation_timed_out" | "unexpected_settle_error" | "unexpected_verify_error" | undefined;
181
+ payer?: string | undefined;
182
182
  }, {
183
183
  isValid: boolean;
184
184
  errorMessage?: string | undefined;
185
185
  fundWalletLink?: string | undefined;
186
- payer?: string | undefined;
187
186
  invalidReason?: "insufficient_funds" | "invalid_exact_evm_payload_authorization_valid_after" | "invalid_exact_evm_payload_authorization_valid_before" | "invalid_exact_evm_payload_authorization_value" | "invalid_exact_evm_payload_signature" | "invalid_exact_evm_payload_recipient_mismatch" | "invalid_exact_svm_payload_transaction" | "invalid_exact_svm_payload_transaction_amount_mismatch" | "invalid_exact_svm_payload_transaction_create_ata_instruction" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee" | "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset" | "invalid_exact_svm_payload_transaction_instructions" | "invalid_exact_svm_payload_transaction_instructions_length" | "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction" | "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high" | "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked" | "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked" | "invalid_exact_svm_payload_transaction_not_a_transfer_instruction" | "invalid_exact_svm_payload_transaction_receiver_ata_not_found" | "invalid_exact_svm_payload_transaction_sender_ata_not_found" | "invalid_exact_svm_payload_transaction_simulation_failed" | "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata" | "invalid_network" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_payment" | "payment_expired" | "unsupported_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "settle_exact_svm_block_height_exceeded" | "settle_exact_svm_transaction_confirmation_timed_out" | "unexpected_settle_error" | "unexpected_verify_error" | undefined;
187
+ payer?: string | undefined;
188
188
  }>;
189
189
  export type FacilitatorVerifyResponse = z.infer<typeof FacilitatorVerifyResponseSchema>;
190
190
  export declare const SupportedSignatureTypeSchema: z.ZodEnum<["TransferWithAuthorization", "Permit"]>;
191
191
  declare const FacilitatorSupportedResponseSchema: z.ZodObject<{} & {
192
192
  kinds: z.ZodArray<z.ZodObject<{
193
193
  x402Version: z.ZodLiteral<1>;
194
- scheme: z.ZodLiteral<"exact">;
194
+ scheme: z.ZodUnion<[z.ZodLiteral<"exact">, z.ZodLiteral<"upto">]>;
195
195
  network: z.ZodString;
196
196
  extra: z.ZodOptional<z.ZodObject<{
197
197
  defaultAsset: z.ZodOptional<z.ZodObject<{
@@ -300,7 +300,7 @@ declare const FacilitatorSupportedResponseSchema: z.ZodObject<{} & {
300
300
  }[] | undefined;
301
301
  }>>;
302
302
  }, "strip", z.ZodTypeAny, {
303
- scheme: "exact";
303
+ scheme: "exact" | "upto";
304
304
  network: string;
305
305
  x402Version: 1;
306
306
  extra?: {
@@ -324,7 +324,7 @@ declare const FacilitatorSupportedResponseSchema: z.ZodObject<{} & {
324
324
  }[] | undefined;
325
325
  } | undefined;
326
326
  }, {
327
- scheme: "exact";
327
+ scheme: "exact" | "upto";
328
328
  network: string;
329
329
  x402Version: 1;
330
330
  extra?: {
@@ -350,7 +350,7 @@ declare const FacilitatorSupportedResponseSchema: z.ZodObject<{} & {
350
350
  }>, "many">;
351
351
  }, "strip", z.ZodTypeAny, {
352
352
  kinds: {
353
- scheme: "exact";
353
+ scheme: "exact" | "upto";
354
354
  network: string;
355
355
  x402Version: 1;
356
356
  extra?: {
@@ -376,7 +376,7 @@ declare const FacilitatorSupportedResponseSchema: z.ZodObject<{} & {
376
376
  }[];
377
377
  }, {
378
378
  kinds: {
379
- scheme: "exact";
379
+ scheme: "exact" | "upto";
380
380
  network: string;
381
381
  x402Version: 1;
382
382
  extra?: {
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/x402/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAOrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,QAAA,MAAM,wBAAwB,aAAa,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,QAAA,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEjC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,uBAAuB,EACvB,SAAS,CACV,GAAG;IACF,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,GAAG;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE,CAAC;CACxE,CAAC;AAEF,eAAO,MAAM,kCAAkC;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AkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBqB,CAAC;AAE9D,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,kCAAkC,CAC1C,CAAC;AAMF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAO3E;AAED;;;GAGG;AACH,QAAA,MAAM,kBAAkB,8FA8DrB,CAAC;AAEJ,KAAK,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,CAK3E"}
@@ -43,7 +43,6 @@ import { type SettlePaymentArgs, type SettlePaymentResult } from "./types.js";
43
43
  * routeConfig: {
44
44
  * description: "Access to premium API content",
45
45
  * mimeType: "application/json",
46
- * maxTimeoutSeconds: 300,
47
46
  * },
48
47
  * });
49
48
  *
@@ -60,6 +59,18 @@ import { type SettlePaymentArgs, type SettlePaymentResult } from "./types.js";
60
59
  * }
61
60
  * ```
62
61
  *
62
+ * ### Upto Payment Scheme
63
+ *
64
+ * You can also use the `upto` payment scheme to settle the payment dynamically based on the usage.
65
+ *
66
+ * ```ts
67
+ * const result = await settlePayment({
68
+ * ...paymentArgs,
69
+ * scheme: "upto",
70
+ * price: "$0.10", // max payable amount
71
+ * });
72
+ * ```
73
+ *
63
74
  * ### Express middleware example
64
75
  *
65
76
  * ```ts
@@ -1 +1 @@
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,CA8D9B"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+HG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,mBAAmB,CAAC,CA8D9B"}
@@ -1,5 +1,5 @@
1
1
  import type { Money, PaymentMiddlewareConfig } from "x402/types";
2
- import type z from "zod";
2
+ import z from "zod";
3
3
  import type { Chain } from "../chains/types.js";
4
4
  import type { Prettify } from "../utils/type-utils.js";
5
5
  import type { ThirdwebX402Facilitator, WaitUntil } from "./facilitator.js";
@@ -23,6 +23,8 @@ export type PaymentArgs = {
23
23
  price: Money | ERC20TokenAmount;
24
24
  /** The payment facilitator instance used to verify and settle payments */
25
25
  facilitator: ThirdwebX402Facilitator;
26
+ /** The scheme of the payment, either "exact" or "upto", defaults to "exact" */
27
+ scheme?: PaymentScheme;
26
28
  /** Optional configuration for the payment middleware route */
27
29
  routeConfig?: PaymentMiddlewareConfig;
28
30
  /** Optional recipient address to receive the payment if different from your facilitator address */
@@ -75,12 +77,21 @@ export type SettlePaymentResult = Prettify<{
75
77
  export type VerifyPaymentResult = Prettify<{
76
78
  /** HTTP 200 - Payment was successfully verified */
77
79
  status: 200;
80
+ /** The decoded payment payload */
78
81
  decodedPayment: RequestedPaymentPayload;
82
+ /** The selected payment requirements */
79
83
  selectedPaymentRequirements: RequestedPaymentRequirements;
80
84
  } | PaymentRequiredResult>;
81
85
  export type SupportedSignatureType = z.infer<typeof SupportedSignatureTypeSchema>;
86
+ export declare const PaymentSchemeSchema: z.ZodUnion<[z.ZodLiteral<"exact">, z.ZodLiteral<"upto">]>;
87
+ type PaymentScheme = z.infer<typeof PaymentSchemeSchema>;
88
+ /**
89
+ * The asset, scheme and amount for the payment in base units
90
+ */
82
91
  export type ERC20TokenAmount = {
92
+ /** The amount of the payment in base units */
83
93
  amount: string;
94
+ /** The asset of the payment, decimals and eip712 data are optional and will be inferred from the address if not provided */
84
95
  asset: {
85
96
  address: `0x${string}`;
86
97
  decimals?: number;
@@ -91,4 +102,5 @@ export type ERC20TokenAmount = {
91
102
  };
92
103
  };
93
104
  };
105
+ export {};
94
106
  //# sourceMappingURL=types.d.ts.map
@@ -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,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,WAAW,I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PaymentResult } from "./types.js";
36
36
  * routeConfig: {
37
37
  * description: "Access to premium API content",
38
38
  * mimeType: "application/json",
39
- * maxTimeoutSeconds: 300,
40
39
  * },
41
40
  * };
42
41
  *
@@ -62,6 +61,17 @@ import { type PaymentArgs, type VerifyPaymentResult } from "./types.js";
62
61
  * }
63
62
  * ```
64
63
  *
64
+ * ### Upto Payment Scheme
65
+ *
66
+ * You can also use the `upto` payment scheme to verify a payment where the final price is dynamically calculated based on the usage.
67
+ *
68
+ * ```ts
69
+ * const result = await verifyPayment({
70
+ * ...paymentArgs,
71
+ * scheme: "upto",
72
+ * price: "$0.10", // max payable amount
73
+ * });
74
+ * ```
65
75
  * @public
66
76
  * @beta
67
77
  * @x402
@@ -1 +1 @@
1
- {"version":3,"file":"verify-payment.d.ts","sourceRoot":"","sources":["../../../src/x402/verify-payment.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,mBAAmB,CAAC,CA2D9B"}
1
+ {"version":3,"file":"verify-payment.d.ts","sourceRoot":"","sources":["../../../src/x402/verify-payment.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,mBAAmB,CAAC,CA2D9B"}
package/package.json CHANGED
@@ -39,8 +39,8 @@
39
39
  "viem": "2.39.0",
40
40
  "x402": "0.7.0",
41
41
  "zod": "3.25.75",
42
- "@thirdweb-dev/engine": "3.4.0",
43
- "@thirdweb-dev/insight": "1.1.1"
42
+ "@thirdweb-dev/insight": "1.1.1",
43
+ "@thirdweb-dev/engine": "3.4.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@aws-sdk/client-kms": "3.592.0",
@@ -399,7 +399,7 @@
399
399
  }
400
400
  },
401
401
  "typings": "./dist/types/exports/thirdweb.d.ts",
402
- "version": "5.113.0",
402
+ "version": "5.114.0",
403
403
  "scripts": {
404
404
  "bench": "vitest -c ./test/vitest.config.ts bench",
405
405
  "bench:compare": "bun run ./benchmarks/run.ts",
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.113.0";
1
+ export const version = "5.114.0";
@@ -35,28 +35,10 @@ type GetPaymentRequirementsResult = {
35
35
  export async function decodePaymentRequest(
36
36
  args: PaymentArgs,
37
37
  ): Promise<GetPaymentRequirementsResult | PaymentRequiredResult> {
38
- const {
39
- price,
40
- network,
41
- facilitator,
42
- payTo,
43
- resourceUrl,
44
- routeConfig = {},
45
- method,
46
- paymentData,
47
- extraMetadata,
48
- } = args;
38
+ const { facilitator, routeConfig = {}, paymentData } = args;
49
39
  const { errorMessages } = routeConfig;
50
40
 
51
- const paymentRequirementsResult = await facilitator.accepts({
52
- resourceUrl,
53
- method,
54
- network,
55
- price,
56
- routeConfig,
57
- payTo,
58
- extraMetadata,
59
- });
41
+ const paymentRequirementsResult = await facilitator.accepts(args);
60
42
 
61
43
  // Check for payment header, if none, return the payment requirements
62
44
  if (!paymentData) {
@@ -278,6 +278,7 @@ export function facilitator(
278
278
  method: args.method,
279
279
  network: caip2ChainId,
280
280
  price: args.price,
281
+ scheme: args.scheme,
281
282
  routeConfig: args.routeConfig,
282
283
  serverWalletAddress: facilitator.address,
283
284
  recipientAddress: args.payTo,
@@ -71,9 +71,9 @@ export function wrapFetchWithPayment(
71
71
  accepts: unknown[];
72
72
  error?: string;
73
73
  };
74
- const parsedPaymentRequirements = accepts
75
- .map((x) => RequestedPaymentRequirementsSchema.parse(x))
76
- .filter((x) => x.scheme === "exact"); // TODO (402): accept other schemes
74
+ const parsedPaymentRequirements = accepts.map((x) =>
75
+ RequestedPaymentRequirementsSchema.parse(x),
76
+ );
77
77
 
78
78
  const account = wallet.getAccount();
79
79
  let chain = wallet.getChain();
@@ -88,7 +88,6 @@ export function wrapFetchWithPayment(
88
88
  : defaultPaymentRequirementsSelector(
89
89
  parsedPaymentRequirements,
90
90
  chain.id,
91
- "exact",
92
91
  error,
93
92
  );
94
93
 
@@ -158,7 +157,6 @@ export function wrapFetchWithPayment(
158
157
  function defaultPaymentRequirementsSelector(
159
158
  paymentRequirements: RequestedPaymentRequirements[],
160
159
  chainId: number,
161
- scheme: "exact",
162
160
  error?: string,
163
161
  ) {
164
162
  if (!paymentRequirements.length) {
@@ -168,9 +166,7 @@ function defaultPaymentRequirementsSelector(
168
166
  }
169
167
  // find the payment requirements matching the connected wallet chain
170
168
  const matchingPaymentRequirements = paymentRequirements.find(
171
- (x) =>
172
- extractEvmChainId(networkToCaip2ChainId(x.network)) === chainId &&
173
- x.scheme === scheme,
169
+ (x) => extractEvmChainId(networkToCaip2ChainId(x.network)) === chainId,
174
170
  );
175
171
 
176
172
  if (matchingPaymentRequirements) {
@@ -178,9 +174,7 @@ function defaultPaymentRequirementsSelector(
178
174
  } else {
179
175
  // if no matching payment requirements, use the first payment requirement
180
176
  // and switch the wallet to that chain
181
- const firstPaymentRequirement = paymentRequirements.find(
182
- (x) => x.scheme === scheme,
183
- );
177
+ const firstPaymentRequirement = paymentRequirements[0];
184
178
  return firstPaymentRequirement;
185
179
  }
186
180
  }
@@ -10,6 +10,7 @@ import {
10
10
  } from "x402/types";
11
11
  import { z } from "zod";
12
12
  import type { Chain } from "../chains/types.js";
13
+ import { PaymentSchemeSchema } from "./types.js";
13
14
 
14
15
  const FacilitatorNetworkSchema = z.string();
15
16
 
@@ -17,6 +18,7 @@ export type FacilitatorNetwork = z.infer<typeof FacilitatorNetworkSchema>;
17
18
 
18
19
  const RequestedPaymentPayloadSchema = PaymentPayloadSchema.extend({
19
20
  network: FacilitatorNetworkSchema,
21
+ scheme: PaymentSchemeSchema,
20
22
  });
21
23
 
22
24
  export type RequestedPaymentPayload = z.infer<
@@ -32,6 +34,7 @@ export type UnsignedPaymentPayload = Omit<
32
34
  export const RequestedPaymentRequirementsSchema =
33
35
  PaymentRequirementsSchema.extend({
34
36
  network: FacilitatorNetworkSchema,
37
+ scheme: PaymentSchemeSchema,
35
38
  });
36
39
 
37
40
  export type RequestedPaymentRequirements = z.infer<
@@ -76,7 +79,7 @@ const FacilitatorSupportedResponseSchema =
76
79
  kinds: z.array(
77
80
  z.object({
78
81
  x402Version: z.literal(1),
79
- scheme: z.literal("exact"),
82
+ scheme: PaymentSchemeSchema,
80
83
  network: FacilitatorNetworkSchema,
81
84
  extra: z
82
85
  .object({
@@ -51,7 +51,6 @@ import {
51
51
  * routeConfig: {
52
52
  * description: "Access to premium API content",
53
53
  * mimeType: "application/json",
54
- * maxTimeoutSeconds: 300,
55
54
  * },
56
55
  * });
57
56
  *
@@ -68,6 +67,18 @@ import {
68
67
  * }
69
68
  * ```
70
69
  *
70
+ * ### Upto Payment Scheme
71
+ *
72
+ * You can also use the `upto` payment scheme to settle the payment dynamically based on the usage.
73
+ *
74
+ * ```ts
75
+ * const result = await settlePayment({
76
+ * ...paymentArgs,
77
+ * scheme: "upto",
78
+ * price: "$0.10", // max payable amount
79
+ * });
80
+ * ```
81
+ *
71
82
  * ### Express middleware example
72
83
  *
73
84
  * ```ts
package/src/x402/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Money, PaymentMiddlewareConfig } from "x402/types";
2
- import type z from "zod";
2
+ import z from "zod";
3
3
  import type { Chain } from "../chains/types.js";
4
4
  import type { Prettify } from "../utils/type-utils.js";
5
5
  import type { ThirdwebX402Facilitator, WaitUntil } from "./facilitator.js";
@@ -31,6 +31,8 @@ export type PaymentArgs = {
31
31
  price: Money | ERC20TokenAmount;
32
32
  /** The payment facilitator instance used to verify and settle payments */
33
33
  facilitator: ThirdwebX402Facilitator;
34
+ /** The scheme of the payment, either "exact" or "upto", defaults to "exact" */
35
+ scheme?: PaymentScheme;
34
36
  /** Optional configuration for the payment middleware route */
35
37
  routeConfig?: PaymentMiddlewareConfig;
36
38
  /** Optional recipient address to receive the payment if different from your facilitator address */
@@ -91,7 +93,9 @@ export type VerifyPaymentResult = Prettify<
91
93
  | {
92
94
  /** HTTP 200 - Payment was successfully verified */
93
95
  status: 200;
96
+ /** The decoded payment payload */
94
97
  decodedPayment: RequestedPaymentPayload;
98
+ /** The selected payment requirements */
95
99
  selectedPaymentRequirements: RequestedPaymentRequirements;
96
100
  }
97
101
  | PaymentRequiredResult
@@ -101,8 +105,19 @@ export type SupportedSignatureType = z.infer<
101
105
  typeof SupportedSignatureTypeSchema
102
106
  >;
103
107
 
108
+ export const PaymentSchemeSchema = z.union([
109
+ z.literal("exact"),
110
+ z.literal("upto"),
111
+ ]);
112
+ type PaymentScheme = z.infer<typeof PaymentSchemeSchema>;
113
+
114
+ /**
115
+ * The asset, scheme and amount for the payment in base units
116
+ */
104
117
  export type ERC20TokenAmount = {
118
+ /** The amount of the payment in base units */
105
119
  amount: string;
120
+ /** The asset of the payment, decimals and eip712 data are optional and will be inferred from the address if not provided */
106
121
  asset: {
107
122
  address: `0x${string}`;
108
123
  decimals?: number;
@@ -42,7 +42,6 @@ import {
42
42
  * routeConfig: {
43
43
  * description: "Access to premium API content",
44
44
  * mimeType: "application/json",
45
- * maxTimeoutSeconds: 300,
46
45
  * },
47
46
  * };
48
47
  *
@@ -68,6 +67,17 @@ import {
68
67
  * }
69
68
  * ```
70
69
  *
70
+ * ### Upto Payment Scheme
71
+ *
72
+ * You can also use the `upto` payment scheme to verify a payment where the final price is dynamically calculated based on the usage.
73
+ *
74
+ * ```ts
75
+ * const result = await verifyPayment({
76
+ * ...paymentArgs,
77
+ * scheme: "upto",
78
+ * price: "$0.10", // max payable amount
79
+ * });
80
+ * ```
71
81
  * @public
72
82
  * @beta
73
83
  * @x402