uvd-x402-sdk 2.43.1 → 2.44.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 (40) hide show
  1. package/README.md +31 -0
  2. package/dist/adapters/index.d.mts +1 -1
  3. package/dist/adapters/index.d.ts +1 -1
  4. package/dist/backend/index.d.mts +80 -2
  5. package/dist/backend/index.d.ts +80 -2
  6. package/dist/backend/index.js +18 -0
  7. package/dist/backend/index.js.map +1 -1
  8. package/dist/backend/index.mjs +17 -1
  9. package/dist/backend/index.mjs.map +1 -1
  10. package/dist/{index-Bw4S80Ph.d.mts → index-BidnFGw_.d.mts} +1 -1
  11. package/dist/{index-NDRI_c7e.d.mts → index-DgChnK_c.d.mts} +1 -1
  12. package/dist/{index-NDRI_c7e.d.ts → index-DgChnK_c.d.ts} +1 -1
  13. package/dist/{index-Dgus5K-7.d.ts → index-H64xdjKh.d.ts} +1 -1
  14. package/dist/index.d.mts +3 -3
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +18 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +17 -1
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/providers/algorand/index.d.mts +1 -1
  21. package/dist/providers/algorand/index.d.ts +1 -1
  22. package/dist/providers/evm/index.d.mts +1 -1
  23. package/dist/providers/evm/index.d.ts +1 -1
  24. package/dist/providers/near/index.d.mts +1 -1
  25. package/dist/providers/near/index.d.ts +1 -1
  26. package/dist/providers/solana/index.d.mts +1 -1
  27. package/dist/providers/solana/index.d.ts +1 -1
  28. package/dist/providers/stellar/index.d.mts +1 -1
  29. package/dist/providers/stellar/index.d.ts +1 -1
  30. package/dist/providers/sui/index.d.mts +1 -1
  31. package/dist/providers/sui/index.d.ts +1 -1
  32. package/dist/providers/xrpl/index.d.mts +1 -1
  33. package/dist/providers/xrpl/index.d.ts +1 -1
  34. package/dist/react/index.d.mts +3 -3
  35. package/dist/react/index.d.ts +3 -3
  36. package/dist/utils/index.d.mts +1 -1
  37. package/dist/utils/index.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/src/backend/index.ts +113 -0
  40. package/src/index.ts +7 -0
package/README.md CHANGED
@@ -1067,6 +1067,37 @@ console.log(stats.total, stats.visible, stats.byHealth.alive);
1067
1067
 
1068
1068
  Timestamps (`firstSeen`, `lastSeen`, `lastUpdated`, `health.lastChecked`) are Unix epoch **seconds**. Use `epochToDate()` to get a `Date`.
1069
1069
 
1070
+ ## x402 v2 requests (`buildVerifyRequestV2` / `buildSettleRequestV2`)
1071
+
1072
+ If your 402 advertises CAIP-2 networks (`eip155:8453`), you are speaking v2 and
1073
+ must send the **v2 envelope**. `buildVerifyRequest` emits the v1 one and cannot
1074
+ express v2:
1075
+
1076
+ ```typescript
1077
+ import { buildVerifyRequestV2 } from 'uvd-x402-sdk';
1078
+
1079
+ const body = buildVerifyRequestV2(
1080
+ payment.payload,
1081
+ { url: 'https://api.example.com/thing', description: 'Thing', mimeType: 'application/json' },
1082
+ { scheme: 'exact', network: 'eip155:8453', asset: '0x8335...', amount: '100000',
1083
+ payTo: '0xabc...', maxTimeoutSeconds: 300 }
1084
+ );
1085
+ ```
1086
+
1087
+ | | v1 envelope | v2 envelope |
1088
+ |---|---|---|
1089
+ | top level | `{x402Version, paymentPayload, paymentRequirements}` | `{x402Version, paymentPayload, resource, accepted}` |
1090
+ | network | plain name — `base` | CAIP-2 — `eip155:8453` |
1091
+ | amount field | `maxAmountRequired` | `amount` |
1092
+ | `resource` | URL **string** | **object** `{url, description, mimeType}` |
1093
+
1094
+ > **Do not mix levels.** Each version demands its own network format and its own
1095
+ > envelope. A v2 payload inside a v1 envelope — or a plain network name inside a
1096
+ > v2 request — matches no variant at the facilitator and fails with
1097
+ > `data did not match any variant of untagged enum VerifyRequestEnvelope`, an
1098
+ > error that names no field. If you see it, check the envelope shape first, not
1099
+ > the fields inside it.
1100
+
1070
1101
  ## Live Traffic Stream (`GET /events`)
1071
1102
 
1072
1103
  The facilitator emits one Server-Sent Event per operation it handles, so you can
@@ -1,4 +1,4 @@
1
- import { X as X402Version, b as PaymentResult } from '../index-NDRI_c7e.mjs';
1
+ import { X as X402Version, b as PaymentResult } from '../index-DgChnK_c.mjs';
2
2
  export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-CYIVd4xO.mjs';
3
3
  import '../wallet-0cX9Pw2F.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { X as X402Version, b as PaymentResult } from '../index-NDRI_c7e.js';
1
+ import { X as X402Version, b as PaymentResult } from '../index-DgChnK_c.js';
2
2
  export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-DTDixPzO.js';
3
3
  import '../wallet-0cX9Pw2F.js';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { S as SigningWalletAdapter } from '../wallet-0cX9Pw2F.mjs';
2
- import { e as X402Header, X as X402Version } from '../index-NDRI_c7e.mjs';
2
+ import { e as X402Header, X as X402Version, f as X402PayloadData } from '../index-DgChnK_c.mjs';
3
3
 
4
4
  /**
5
5
  * Payment requirements sent to the facilitator
@@ -212,6 +212,84 @@ declare function buildVerifyRequest(paymentHeader: X402Header, requirements: Pay
212
212
  * @param requirements - Payment requirements
213
213
  * @returns SettleRequest body ready for fetch/axios
214
214
  */
215
+ /**
216
+ * Describes the protected resource, as x402 v2 expects it.
217
+ *
218
+ * Note this is an OBJECT in v2. Sending a bare URL string here is the single
219
+ * most common v2 mistake and it fails as an unhelpful "no variant matched"
220
+ * deserialization error at the facilitator, naming no field.
221
+ */
222
+ interface ResourceInfoV2 {
223
+ url: string;
224
+ description: string;
225
+ mimeType: string;
226
+ }
227
+ /**
228
+ * Payment requirements in x402 v2 form.
229
+ *
230
+ * Differences from v1 that actually bite:
231
+ * - `network` is CAIP-2 (`eip155:8453`), NOT a plain name (`base`). Mixing a v1
232
+ * name into a v2 request fails deserialization, and vice versa.
233
+ * - `maxAmountRequired` is renamed to `amount`.
234
+ * - `resource` / `description` / `mimeType` moved out to {@link ResourceInfoV2}.
235
+ */
236
+ interface PaymentRequirementsV2 {
237
+ scheme: string;
238
+ /** CAIP-2 chain id, e.g. `eip155:8453`. */
239
+ network: string;
240
+ asset: string;
241
+ amount: string;
242
+ payTo: string;
243
+ maxTimeoutSeconds: number;
244
+ extra?: unknown;
245
+ }
246
+ /** The v2 payment payload — note it carries no top-level scheme/network. */
247
+ interface PaymentPayloadV2 {
248
+ x402Version: 2;
249
+ resource: ResourceInfoV2;
250
+ accepted: PaymentRequirementsV2;
251
+ payload: X402PayloadData;
252
+ extensions?: Record<string, unknown>;
253
+ }
254
+ /**
255
+ * Verify request body in x402 v2 form.
256
+ *
257
+ * There is deliberately NO `paymentRequirements` key: that is the v1 envelope.
258
+ * v2 carries `resource` and `accepted` at the top level instead.
259
+ */
260
+ interface VerifyRequestV2 {
261
+ x402Version: 2;
262
+ paymentPayload: PaymentPayloadV2;
263
+ resource: ResourceInfoV2;
264
+ accepted: PaymentRequirementsV2;
265
+ }
266
+ /** Settle request body in x402 v2 form. Same shape as {@link VerifyRequestV2}. */
267
+ type SettleRequestV2 = VerifyRequestV2;
268
+ /**
269
+ * Build a verify request for the facilitator `/verify` endpoint, in **v2** form.
270
+ *
271
+ * Use this whenever your 402 advertises CAIP-2 networks. {@link buildVerifyRequest}
272
+ * emits the v1 envelope `{x402Version, paymentPayload, paymentRequirements}` and
273
+ * cannot express v2 — putting a v2 payload inside it matches no variant at the
274
+ * facilitator and fails with an error that names no field.
275
+ *
276
+ * @example
277
+ * ```ts
278
+ * const body = buildVerifyRequestV2(
279
+ * payment.payload,
280
+ * { url: 'https://api.example.com/thing', description: 'Thing', mimeType: 'application/json' },
281
+ * { scheme: 'exact', network: 'eip155:8453', asset: '0x8335...', amount: '100000',
282
+ * payTo: '0xabc...', maxTimeoutSeconds: 300 }
283
+ * );
284
+ * ```
285
+ */
286
+ declare function buildVerifyRequestV2(payload: X402PayloadData, resource: ResourceInfoV2, accepted: PaymentRequirementsV2): VerifyRequestV2;
287
+ /**
288
+ * Build a settle request for the facilitator `/settle` endpoint, in **v2** form.
289
+ *
290
+ * See {@link buildVerifyRequestV2} — the envelope is identical.
291
+ */
292
+ declare function buildSettleRequestV2(payload: X402PayloadData, resource: ResourceInfoV2, accepted: PaymentRequirementsV2): SettleRequestV2;
215
293
  declare function buildSettleRequest(paymentHeader: X402Header, requirements: PaymentRequirements): SettleRequest;
216
294
  /**
217
295
  * Recommended CORS headers for x402 payment APIs
@@ -2195,4 +2273,4 @@ declare class AdvancedEscrowClient {
2195
2273
  private sendViaAdapter;
2196
2274
  }
2197
2275
 
2198
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
2276
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
@@ -1,5 +1,5 @@
1
1
  import { S as SigningWalletAdapter } from '../wallet-0cX9Pw2F.js';
2
- import { e as X402Header, X as X402Version } from '../index-NDRI_c7e.js';
2
+ import { e as X402Header, X as X402Version, f as X402PayloadData } from '../index-DgChnK_c.js';
3
3
 
4
4
  /**
5
5
  * Payment requirements sent to the facilitator
@@ -212,6 +212,84 @@ declare function buildVerifyRequest(paymentHeader: X402Header, requirements: Pay
212
212
  * @param requirements - Payment requirements
213
213
  * @returns SettleRequest body ready for fetch/axios
214
214
  */
215
+ /**
216
+ * Describes the protected resource, as x402 v2 expects it.
217
+ *
218
+ * Note this is an OBJECT in v2. Sending a bare URL string here is the single
219
+ * most common v2 mistake and it fails as an unhelpful "no variant matched"
220
+ * deserialization error at the facilitator, naming no field.
221
+ */
222
+ interface ResourceInfoV2 {
223
+ url: string;
224
+ description: string;
225
+ mimeType: string;
226
+ }
227
+ /**
228
+ * Payment requirements in x402 v2 form.
229
+ *
230
+ * Differences from v1 that actually bite:
231
+ * - `network` is CAIP-2 (`eip155:8453`), NOT a plain name (`base`). Mixing a v1
232
+ * name into a v2 request fails deserialization, and vice versa.
233
+ * - `maxAmountRequired` is renamed to `amount`.
234
+ * - `resource` / `description` / `mimeType` moved out to {@link ResourceInfoV2}.
235
+ */
236
+ interface PaymentRequirementsV2 {
237
+ scheme: string;
238
+ /** CAIP-2 chain id, e.g. `eip155:8453`. */
239
+ network: string;
240
+ asset: string;
241
+ amount: string;
242
+ payTo: string;
243
+ maxTimeoutSeconds: number;
244
+ extra?: unknown;
245
+ }
246
+ /** The v2 payment payload — note it carries no top-level scheme/network. */
247
+ interface PaymentPayloadV2 {
248
+ x402Version: 2;
249
+ resource: ResourceInfoV2;
250
+ accepted: PaymentRequirementsV2;
251
+ payload: X402PayloadData;
252
+ extensions?: Record<string, unknown>;
253
+ }
254
+ /**
255
+ * Verify request body in x402 v2 form.
256
+ *
257
+ * There is deliberately NO `paymentRequirements` key: that is the v1 envelope.
258
+ * v2 carries `resource` and `accepted` at the top level instead.
259
+ */
260
+ interface VerifyRequestV2 {
261
+ x402Version: 2;
262
+ paymentPayload: PaymentPayloadV2;
263
+ resource: ResourceInfoV2;
264
+ accepted: PaymentRequirementsV2;
265
+ }
266
+ /** Settle request body in x402 v2 form. Same shape as {@link VerifyRequestV2}. */
267
+ type SettleRequestV2 = VerifyRequestV2;
268
+ /**
269
+ * Build a verify request for the facilitator `/verify` endpoint, in **v2** form.
270
+ *
271
+ * Use this whenever your 402 advertises CAIP-2 networks. {@link buildVerifyRequest}
272
+ * emits the v1 envelope `{x402Version, paymentPayload, paymentRequirements}` and
273
+ * cannot express v2 — putting a v2 payload inside it matches no variant at the
274
+ * facilitator and fails with an error that names no field.
275
+ *
276
+ * @example
277
+ * ```ts
278
+ * const body = buildVerifyRequestV2(
279
+ * payment.payload,
280
+ * { url: 'https://api.example.com/thing', description: 'Thing', mimeType: 'application/json' },
281
+ * { scheme: 'exact', network: 'eip155:8453', asset: '0x8335...', amount: '100000',
282
+ * payTo: '0xabc...', maxTimeoutSeconds: 300 }
283
+ * );
284
+ * ```
285
+ */
286
+ declare function buildVerifyRequestV2(payload: X402PayloadData, resource: ResourceInfoV2, accepted: PaymentRequirementsV2): VerifyRequestV2;
287
+ /**
288
+ * Build a settle request for the facilitator `/settle` endpoint, in **v2** form.
289
+ *
290
+ * See {@link buildVerifyRequestV2} — the envelope is identical.
291
+ */
292
+ declare function buildSettleRequestV2(payload: X402PayloadData, resource: ResourceInfoV2, accepted: PaymentRequirementsV2): SettleRequestV2;
215
293
  declare function buildSettleRequest(paymentHeader: X402Header, requirements: PaymentRequirements): SettleRequest;
216
294
  /**
217
295
  * Recommended CORS headers for x402 payment APIs
@@ -2195,4 +2273,4 @@ declare class AdvancedEscrowClient {
2195
2273
  private sendViaAdapter;
2196
2274
  }
2197
2275
 
2198
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
2276
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, parsePaymentHeader };
@@ -1096,6 +1096,22 @@ function buildVerifyRequest(paymentHeader, requirements) {
1096
1096
  paymentRequirements: requirements
1097
1097
  };
1098
1098
  }
1099
+ function buildV2Envelope(payload, resource, accepted) {
1100
+ return {
1101
+ x402Version: 2,
1102
+ // The facilitator reads the payload from here; `resource` and `accepted` are
1103
+ // repeated at the top level because the v2 envelope declares both.
1104
+ paymentPayload: { x402Version: 2, resource, accepted, payload },
1105
+ resource,
1106
+ accepted
1107
+ };
1108
+ }
1109
+ function buildVerifyRequestV2(payload, resource, accepted) {
1110
+ return buildV2Envelope(payload, resource, accepted);
1111
+ }
1112
+ function buildSettleRequestV2(payload, resource, accepted) {
1113
+ return buildV2Envelope(payload, resource, accepted);
1114
+ }
1099
1115
  function buildSettleRequest(paymentHeader, requirements) {
1100
1116
  return {
1101
1117
  x402Version: paymentHeader.x402Version,
@@ -3894,7 +3910,9 @@ exports.ZERO_ADDRESS = ZERO_ADDRESS;
3894
3910
  exports.buildErc8004PaymentRequirements = buildErc8004PaymentRequirements;
3895
3911
  exports.buildPaymentRequirements = buildPaymentRequirements;
3896
3912
  exports.buildSettleRequest = buildSettleRequest;
3913
+ exports.buildSettleRequestV2 = buildSettleRequestV2;
3897
3914
  exports.buildVerifyRequest = buildVerifyRequest;
3915
+ exports.buildVerifyRequestV2 = buildVerifyRequestV2;
3898
3916
  exports.canRefundEscrow = canRefundEscrow;
3899
3917
  exports.canReleaseEscrow = canReleaseEscrow;
3900
3918
  exports.create402Response = create402Response;