x402-express-mantle 1.0.0 → 1.0.3

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 (125) hide show
  1. package/README.md +52 -30
  2. package/lib/cjs/index.d.ts +119 -81
  3. package/lib/cjs/index.js +3 -3
  4. package/lib/esm/index.d.mts +5 -5
  5. package/lib/esm/index.mjs +3 -3
  6. package/package.json +17 -5
  7. package/lib/cjs/client/index.d.ts +0 -243
  8. package/lib/cjs/client/index.js +0 -413
  9. package/lib/cjs/client/index.js.map +0 -1
  10. package/lib/cjs/exact/client/index.d.ts +0 -37
  11. package/lib/cjs/exact/client/index.js +0 -281
  12. package/lib/cjs/exact/client/index.js.map +0 -1
  13. package/lib/cjs/exact/facilitator/index.d.ts +0 -110
  14. package/lib/cjs/exact/facilitator/index.js +0 -714
  15. package/lib/cjs/exact/facilitator/index.js.map +0 -1
  16. package/lib/cjs/exact/server/index.d.ts +0 -87
  17. package/lib/cjs/exact/server/index.js +0 -209
  18. package/lib/cjs/exact/server/index.js.map +0 -1
  19. package/lib/cjs/exact/v1/client/index.d.ts +0 -33
  20. package/lib/cjs/exact/v1/client/index.js +0 -169
  21. package/lib/cjs/exact/v1/client/index.js.map +0 -1
  22. package/lib/cjs/exact/v1/facilitator/index.d.ts +0 -71
  23. package/lib/cjs/exact/v1/facilitator/index.js +0 -384
  24. package/lib/cjs/exact/v1/facilitator/index.js.map +0 -1
  25. package/lib/cjs/facilitator/index.d.ts +0 -192
  26. package/lib/cjs/facilitator/index.js +0 -398
  27. package/lib/cjs/facilitator/index.js.map +0 -1
  28. package/lib/cjs/http/index.d.ts +0 -52
  29. package/lib/cjs/http/index.js +0 -827
  30. package/lib/cjs/http/index.js.map +0 -1
  31. package/lib/cjs/mechanisms-CzuGzYsS.d.ts +0 -270
  32. package/lib/cjs/scheme-MoBRXFM8.d.ts +0 -29
  33. package/lib/cjs/server/index.d.ts +0 -2
  34. package/lib/cjs/server/index.js +0 -1305
  35. package/lib/cjs/server/index.js.map +0 -1
  36. package/lib/cjs/signer-5OVDxViv.d.ts +0 -79
  37. package/lib/cjs/signer-BMkbhFYE.d.ts +0 -123
  38. package/lib/cjs/types/index.d.ts +0 -1
  39. package/lib/cjs/types/index.js +0 -66
  40. package/lib/cjs/types/index.js.map +0 -1
  41. package/lib/cjs/types/v1/index.d.ts +0 -1
  42. package/lib/cjs/types/v1/index.js +0 -19
  43. package/lib/cjs/types/v1/index.js.map +0 -1
  44. package/lib/cjs/utils/index.d.ts +0 -48
  45. package/lib/cjs/utils/index.js +0 -116
  46. package/lib/cjs/utils/index.js.map +0 -1
  47. package/lib/cjs/v1/index.d.ts +0 -12
  48. package/lib/cjs/v1/index.js +0 -180
  49. package/lib/cjs/v1/index.js.map +0 -1
  50. package/lib/cjs/x402HTTPResourceServer-D1YtlH_r.d.ts +0 -719
  51. package/lib/esm/chunk-3CEIVWNN.mjs +0 -339
  52. package/lib/esm/chunk-3CEIVWNN.mjs.map +0 -1
  53. package/lib/esm/chunk-BJTO5JO5.mjs +0 -11
  54. package/lib/esm/chunk-BJTO5JO5.mjs.map +0 -1
  55. package/lib/esm/chunk-EEA7DKZI.mjs +0 -111
  56. package/lib/esm/chunk-EEA7DKZI.mjs.map +0 -1
  57. package/lib/esm/chunk-FOUXRQAV.mjs +0 -88
  58. package/lib/esm/chunk-FOUXRQAV.mjs.map +0 -1
  59. package/lib/esm/chunk-IKSTWKEM.mjs +0 -157
  60. package/lib/esm/chunk-IKSTWKEM.mjs.map +0 -1
  61. package/lib/esm/chunk-JYZWCLMP.mjs +0 -305
  62. package/lib/esm/chunk-JYZWCLMP.mjs.map +0 -1
  63. package/lib/esm/chunk-PNSAJQCF.mjs +0 -108
  64. package/lib/esm/chunk-PNSAJQCF.mjs.map +0 -1
  65. package/lib/esm/chunk-PSA4YVU2.mjs +0 -92
  66. package/lib/esm/chunk-PSA4YVU2.mjs.map +0 -1
  67. package/lib/esm/chunk-QLXM7BIB.mjs +0 -23
  68. package/lib/esm/chunk-QLXM7BIB.mjs.map +0 -1
  69. package/lib/esm/chunk-TDLQZ6MP.mjs +0 -86
  70. package/lib/esm/chunk-TDLQZ6MP.mjs.map +0 -1
  71. package/lib/esm/chunk-VE37GDG2.mjs +0 -7
  72. package/lib/esm/chunk-VE37GDG2.mjs.map +0 -1
  73. package/lib/esm/chunk-WWACQNRQ.mjs +0 -7
  74. package/lib/esm/chunk-WWACQNRQ.mjs.map +0 -1
  75. package/lib/esm/chunk-X4W4S5RB.mjs +0 -39
  76. package/lib/esm/chunk-X4W4S5RB.mjs.map +0 -1
  77. package/lib/esm/chunk-Z4QX3O5V.mjs +0 -748
  78. package/lib/esm/chunk-Z4QX3O5V.mjs.map +0 -1
  79. package/lib/esm/chunk-ZYXTTU74.mjs +0 -88
  80. package/lib/esm/chunk-ZYXTTU74.mjs.map +0 -1
  81. package/lib/esm/client/index.d.mts +0 -243
  82. package/lib/esm/client/index.mjs +0 -260
  83. package/lib/esm/client/index.mjs.map +0 -1
  84. package/lib/esm/exact/client/index.d.mts +0 -37
  85. package/lib/esm/exact/client/index.mjs +0 -36
  86. package/lib/esm/exact/client/index.mjs.map +0 -1
  87. package/lib/esm/exact/facilitator/index.d.mts +0 -110
  88. package/lib/esm/exact/facilitator/index.mjs +0 -350
  89. package/lib/esm/exact/facilitator/index.mjs.map +0 -1
  90. package/lib/esm/exact/server/index.d.mts +0 -87
  91. package/lib/esm/exact/server/index.mjs +0 -129
  92. package/lib/esm/exact/server/index.mjs.map +0 -1
  93. package/lib/esm/exact/v1/client/index.d.mts +0 -33
  94. package/lib/esm/exact/v1/client/index.mjs +0 -8
  95. package/lib/esm/exact/v1/client/index.mjs.map +0 -1
  96. package/lib/esm/exact/v1/facilitator/index.d.mts +0 -71
  97. package/lib/esm/exact/v1/facilitator/index.mjs +0 -8
  98. package/lib/esm/exact/v1/facilitator/index.mjs.map +0 -1
  99. package/lib/esm/facilitator/index.d.mts +0 -192
  100. package/lib/esm/facilitator/index.mjs +0 -373
  101. package/lib/esm/facilitator/index.mjs.map +0 -1
  102. package/lib/esm/http/index.d.mts +0 -52
  103. package/lib/esm/http/index.mjs +0 -29
  104. package/lib/esm/http/index.mjs.map +0 -1
  105. package/lib/esm/mechanisms-CzuGzYsS.d.mts +0 -270
  106. package/lib/esm/scheme-fjF-9LhT.d.mts +0 -29
  107. package/lib/esm/server/index.d.mts +0 -2
  108. package/lib/esm/server/index.mjs +0 -563
  109. package/lib/esm/server/index.mjs.map +0 -1
  110. package/lib/esm/signer-5OVDxViv.d.mts +0 -79
  111. package/lib/esm/signer-BMkbhFYE.d.mts +0 -123
  112. package/lib/esm/types/index.d.mts +0 -1
  113. package/lib/esm/types/index.mjs +0 -10
  114. package/lib/esm/types/index.mjs.map +0 -1
  115. package/lib/esm/types/v1/index.d.mts +0 -1
  116. package/lib/esm/types/v1/index.mjs +0 -1
  117. package/lib/esm/types/v1/index.mjs.map +0 -1
  118. package/lib/esm/utils/index.d.mts +0 -48
  119. package/lib/esm/utils/index.mjs +0 -20
  120. package/lib/esm/utils/index.mjs.map +0 -1
  121. package/lib/esm/v1/index.d.mts +0 -12
  122. package/lib/esm/v1/index.mjs +0 -13
  123. package/lib/esm/v1/index.mjs.map +0 -1
  124. package/lib/esm/x402HTTPResourceServer-BIfIK5HS.d.mts +0 -719
  125. package/src/index.js +0 -4
@@ -1,79 +0,0 @@
1
- /**
2
- * ClientEvmSigner - Used by x402 clients to sign payment authorizations
3
- * This is typically a LocalAccount or wallet that holds private keys
4
- * and can sign EIP-712 typed data for payment authorizations
5
- */
6
- type ClientEvmSigner = {
7
- readonly address: `0x${string}`;
8
- signTypedData(message: {
9
- domain: Record<string, unknown>;
10
- types: Record<string, unknown>;
11
- primaryType: string;
12
- message: Record<string, unknown>;
13
- }): Promise<`0x${string}`>;
14
- };
15
- /**
16
- * FacilitatorEvmSigner - Used by x402 facilitators to verify and settle payments
17
- * This is typically a viem PublicClient + WalletClient combination that can
18
- * read contract state, verify signatures, write transactions, and wait for receipts
19
- *
20
- * Supports multiple addresses for load balancing, key rotation, and high availability
21
- */
22
- type FacilitatorEvmSigner = {
23
- /**
24
- * Get all addresses this facilitator can use for signing
25
- * Enables dynamic address selection for load balancing and key rotation
26
- */
27
- getAddresses(): readonly `0x${string}`[];
28
- readContract(args: {
29
- address: `0x${string}`;
30
- abi: readonly unknown[];
31
- functionName: string;
32
- args?: readonly unknown[];
33
- }): Promise<unknown>;
34
- verifyTypedData(args: {
35
- address: `0x${string}`;
36
- domain: Record<string, unknown>;
37
- types: Record<string, unknown>;
38
- primaryType: string;
39
- message: Record<string, unknown>;
40
- signature: `0x${string}`;
41
- }): Promise<boolean>;
42
- writeContract(args: {
43
- address: `0x${string}`;
44
- abi: readonly unknown[];
45
- functionName: string;
46
- args: readonly unknown[];
47
- }): Promise<`0x${string}`>;
48
- sendTransaction(args: {
49
- to: `0x${string}`;
50
- data: `0x${string}`;
51
- }): Promise<`0x${string}`>;
52
- waitForTransactionReceipt(args: {
53
- hash: `0x${string}`;
54
- }): Promise<{
55
- status: string;
56
- }>;
57
- getCode(args: {
58
- address: `0x${string}`;
59
- }): Promise<`0x${string}` | undefined>;
60
- };
61
- /**
62
- * Converts a signer to a ClientEvmSigner
63
- *
64
- * @param signer - The signer to convert to a ClientEvmSigner
65
- * @returns The converted signer
66
- */
67
- declare function toClientEvmSigner(signer: ClientEvmSigner): ClientEvmSigner;
68
- /**
69
- * Converts a viem client with single address to a FacilitatorEvmSigner
70
- * Wraps the single address in a getAddresses() function for compatibility
71
- *
72
- * @param client - The client to convert (must have 'address' property)
73
- * @returns FacilitatorEvmSigner with getAddresses() support
74
- */
75
- declare function toFacilitatorEvmSigner(client: Omit<FacilitatorEvmSigner, "getAddresses"> & {
76
- address: `0x${string}`;
77
- }): FacilitatorEvmSigner;
78
-
79
- export { type ClientEvmSigner as C, type FacilitatorEvmSigner as F, toFacilitatorEvmSigner as a, toClientEvmSigner as t };
@@ -1,123 +0,0 @@
1
- import { TransactionSigner, MessagePartialSigner, RpcDevnet, SolanaRpcApiDevnet, RpcTestnet, SolanaRpcApiTestnet, RpcMainnet, SolanaRpcApiMainnet, Address } from '@solana/kit';
2
-
3
- /**
4
- * Client-side signer for creating and signing Solana transactions
5
- * This is a wrapper around TransactionSigner from @solana/kit
6
- */
7
- type ClientSvmSigner = TransactionSigner;
8
- /**
9
- * Configuration for client operations
10
- */
11
- type ClientSvmConfig = {
12
- /**
13
- * Optional custom RPC URL for the client to use
14
- */
15
- rpcUrl?: string;
16
- };
17
- /**
18
- * RPC client type from @solana/kit
19
- * Can be devnet, testnet, or mainnet RPC client
20
- */
21
- type FacilitatorRpcClient = RpcDevnet<SolanaRpcApiDevnet> | RpcTestnet<SolanaRpcApiTestnet> | RpcMainnet<SolanaRpcApiMainnet>;
22
- /**
23
- * Minimal facilitator signer interface for SVM operations.
24
- * Supports multiple signers for load balancing and high availability.
25
- * All implementation details (RPC clients, key management, signature handling) are hidden.
26
- */
27
- type FacilitatorSvmSigner = {
28
- /**
29
- * Get all addresses this facilitator can use as fee payers
30
- * Enables dynamic address selection for load balancing and key rotation
31
- *
32
- * @returns Array of addresses available for signing
33
- */
34
- getAddresses(): readonly Address[];
35
- /**
36
- * Sign a partially-signed transaction with the signer matching feePayer
37
- * Transaction is decoded, signed, and re-encoded internally
38
- *
39
- * @param transaction - Base64 encoded partially-signed transaction
40
- * @param feePayer - Fee payer address (determines which signer to use)
41
- * @param network - CAIP-2 network identifier
42
- * @returns Base64 encoded fully-signed transaction
43
- * @throws Error if no signer exists for feePayer or signing fails
44
- */
45
- signTransaction(transaction: string, feePayer: Address, network: string): Promise<string>;
46
- /**
47
- * Simulate a signed transaction to verify it would succeed
48
- * Implementation manages RPC client selection and simulation details
49
- *
50
- * @param transaction - Base64 encoded signed transaction
51
- * @param network - CAIP-2 network identifier
52
- * @throws Error if simulation fails
53
- */
54
- simulateTransaction(transaction: string, network: string): Promise<void>;
55
- /**
56
- * Send a signed transaction to the network
57
- * Implementation manages RPC client selection and sending details
58
- *
59
- * @param transaction - Base64 encoded signed transaction
60
- * @param network - CAIP-2 network identifier
61
- * @returns Transaction signature
62
- * @throws Error if send fails
63
- */
64
- sendTransaction(transaction: string, network: string): Promise<string>;
65
- /**
66
- * Wait for transaction confirmation
67
- * Allows signer to implement custom retry logic, timeouts, and confirmation strategies
68
- *
69
- * @param signature - Transaction signature to confirm
70
- * @param network - CAIP-2 network identifier
71
- * @returns Promise that resolves when transaction is confirmed
72
- * @throws Error if confirmation fails or times out
73
- */
74
- confirmTransaction(signature: string, network: string): Promise<void>;
75
- };
76
- /**
77
- * Convert a signer to ClientSvmSigner (identity function for type safety)
78
- *
79
- * @param signer - The signer to convert
80
- * @returns The signer as ClientSvmSigner
81
- */
82
- declare function toClientSvmSigner(signer: ClientSvmSigner): ClientSvmSigner;
83
- /**
84
- * RPC configuration for the facilitator
85
- * Can be a single RPC (all networks), a network mapping, or config options
86
- */
87
- type FacilitatorRpcConfig = FacilitatorRpcClient | Record<string, FacilitatorRpcClient> | {
88
- defaultRpcUrl?: string;
89
- };
90
- /**
91
- * Create a FacilitatorSvmSigner from a TransactionSigner and optional RPC config
92
- *
93
- * @param signer - The TransactionSigner (e.g., from createKeyPairSignerFromBytes)
94
- * @param rpcConfig - Optional RPC configuration (single RPC, per-network map, or config)
95
- * @returns A complete FacilitatorSvmSigner
96
- *
97
- * @example
98
- * ```ts
99
- * import { createKeyPairSignerFromBytes, createSolanaRpc, devnet } from "@solana/kit";
100
- *
101
- * // Option 1: No RPC - use defaults (SIMPLEST)
102
- * const keypair = await createKeyPairSignerFromBytes(privateKeyBytes);
103
- * const facilitator = toFacilitatorSvmSigner(keypair);
104
- *
105
- * // Option 2: Single RPC for all networks
106
- * const rpc = createSolanaRpc(devnet("https://api.devnet.solana.com"));
107
- * const facilitator = toFacilitatorSvmSigner(keypair, rpc);
108
- *
109
- * // Option 3: Per-network RPC (FLEXIBLE)
110
- * const facilitator = toFacilitatorSvmSigner(keypair, {
111
- * [SOLANA_MAINNET_CAIP2]: myQuickNodeRpc,
112
- * // Devnet/testnet use defaults
113
- * });
114
- *
115
- * // Option 4: Custom default RPC URL
116
- * const facilitator = toFacilitatorSvmSigner(keypair, {
117
- * defaultRpcUrl: "https://my-rpc.com"
118
- * });
119
- * ```
120
- */
121
- declare function toFacilitatorSvmSigner(signer: TransactionSigner & MessagePartialSigner, rpcConfig?: FacilitatorRpcConfig): FacilitatorSvmSigner;
122
-
123
- export { type ClientSvmSigner as C, type FacilitatorSvmSigner as F, type ClientSvmConfig as a, toFacilitatorSvmSigner as b, type FacilitatorRpcClient as c, type FacilitatorRpcConfig as d, toClientSvmSigner as t };
@@ -1 +0,0 @@
1
- export { A as AssetAmount, M as Money, t as MoneyParser, N as Network, P as PaymentPayload, k as PaymentPayloadV1, c as PaymentRequired, j as PaymentRequiredV1, a as PaymentRequirements, i as PaymentRequirementsV1, h as Price, R as ResourceServerExtension, d as SchemeNetworkClient, b as SchemeNetworkFacilitator, f as SchemeNetworkServer, s as SettleError, q as SettleRequest, S as SettleResponse, e as SupportedResponse, r as VerifyError, p as VerifyRequest, V as VerifyResponse } from '../mechanisms-CzuGzYsS.mjs';
@@ -1,10 +0,0 @@
1
- import {
2
- SettleError,
3
- VerifyError
4
- } from "../chunk-X4W4S5RB.mjs";
5
- import "../chunk-BJTO5JO5.mjs";
6
- export {
7
- SettleError,
8
- VerifyError
9
- };
10
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- export { k as PaymentPayloadV1, j as PaymentRequiredV1, i as PaymentRequirementsV1, m as SettleRequestV1, n as SettleResponseV1, o as SupportedResponseV1, l as VerifyRequestV1 } from '../../mechanisms-CzuGzYsS.mjs';
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,48 +0,0 @@
1
- import { N as Network } from '../mechanisms-CzuGzYsS.mjs';
2
-
3
- /**
4
- * Scheme data structure for facilitator storage
5
- */
6
- interface SchemeData<T> {
7
- facilitator: T;
8
- networks: Set<Network>;
9
- pattern: Network;
10
- }
11
- declare const findSchemesByNetwork: <T>(map: Map<string, Map<string, T>>, network: Network) => Map<string, T> | undefined;
12
- declare const findByNetworkAndScheme: <T>(map: Map<string, Map<string, T>>, scheme: string, network: Network) => T | undefined;
13
- /**
14
- * Finds a facilitator by scheme and network using pattern matching.
15
- * Works with new SchemeData storage structure.
16
- *
17
- * @param schemeMap - Map of scheme names to SchemeData
18
- * @param scheme - The scheme to find
19
- * @param network - The network to match against
20
- * @returns The facilitator if found, undefined otherwise
21
- */
22
- declare const findFacilitatorBySchemeAndNetwork: <T>(schemeMap: Map<string, SchemeData<T>>, scheme: string, network: Network) => T | undefined;
23
- declare const Base64EncodedRegex: RegExp;
24
- /**
25
- * Encodes a string to base64 format
26
- *
27
- * @param data - The string to be encoded to base64
28
- * @returns The base64 encoded string
29
- */
30
- declare function safeBase64Encode(data: string): string;
31
- /**
32
- * Decodes a base64 string back to its original format
33
- *
34
- * @param data - The base64 encoded string to be decoded
35
- * @returns The decoded string in UTF-8 format
36
- */
37
- declare function safeBase64Decode(data: string): string;
38
- /**
39
- * Deep equality comparison for payment requirements
40
- * Uses a normalized JSON.stringify for consistent comparison
41
- *
42
- * @param obj1 - First object to compare
43
- * @param obj2 - Second object to compare
44
- * @returns True if objects are deeply equal
45
- */
46
- declare function deepEqual(obj1: unknown, obj2: unknown): boolean;
47
-
48
- export { Base64EncodedRegex, type SchemeData, deepEqual, findByNetworkAndScheme, findFacilitatorBySchemeAndNetwork, findSchemesByNetwork, safeBase64Decode, safeBase64Encode };
@@ -1,20 +0,0 @@
1
- import {
2
- Base64EncodedRegex,
3
- deepEqual,
4
- findByNetworkAndScheme,
5
- findFacilitatorBySchemeAndNetwork,
6
- findSchemesByNetwork,
7
- safeBase64Decode,
8
- safeBase64Encode
9
- } from "../chunk-TDLQZ6MP.mjs";
10
- import "../chunk-BJTO5JO5.mjs";
11
- export {
12
- Base64EncodedRegex,
13
- deepEqual,
14
- findByNetworkAndScheme,
15
- findFacilitatorBySchemeAndNetwork,
16
- findSchemesByNetwork,
17
- safeBase64Decode,
18
- safeBase64Encode
19
- };
20
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,12 +0,0 @@
1
- export { ExactSvmSchemeV1 } from '../exact/v1/client/index.mjs';
2
- import '@x402/core/types';
3
- import '../signer-BMkbhFYE.mjs';
4
- import '@solana/kit';
5
-
6
- /**
7
- * V1 exports for the SVM mechanism
8
- */
9
-
10
- declare const NETWORKS: string[];
11
-
12
- export { NETWORKS };
@@ -1,13 +0,0 @@
1
- import {
2
- NETWORKS
3
- } from "../chunk-WWACQNRQ.mjs";
4
- import {
5
- ExactSvmSchemeV1
6
- } from "../chunk-EEA7DKZI.mjs";
7
- import "../chunk-3CEIVWNN.mjs";
8
- import "../chunk-IKSTWKEM.mjs";
9
- export {
10
- ExactSvmSchemeV1,
11
- NETWORKS
12
- };
13
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}