@alleyboss/micropay-solana-x402-paywall 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,47 +13,60 @@ var LocalSvmFacilitator = class {
13
13
  caipFamily = "solana:*";
14
14
  connection;
15
15
  constructor(rpcUrl) {
16
+ console.log("[LocalSvmFacilitator] Initialized with RPC:", rpcUrl);
16
17
  this.connection = new web3_js.Connection(rpcUrl, "confirmed");
17
18
  }
18
19
  /**
19
20
  * Get supported payment kinds
20
21
  * Mocking the response of the /supported endpoint
21
22
  */
22
- async getSupported(extensionKeys = []) {
23
- return {
23
+ // Network Constants - CAIP-2 format for x402 v2
24
+ NETWORKS = {
25
+ DEVNET: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
26
+ MAINNET: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
27
+ };
28
+ // Dummy fee payer address (System Program) - not used in local verification
29
+ // but required by x402 protocol for supported kinds
30
+ DUMMY_FEE_PAYER = "11111111111111111111111111111111";
31
+ /**
32
+ * Get supported payment kinds
33
+ * Returns x402 v2 compatible response with CAIP-2 network identifiers
34
+ */
35
+ async getSupported(_extensionKeys = []) {
36
+ console.log("[LocalSvmFacilitator] getSupported called");
37
+ const supported = {
24
38
  kinds: [
25
39
  {
26
- x402Version: 1,
40
+ x402Version: 2,
27
41
  scheme: "exact",
28
- network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
29
- // Devnet
30
- extra: {}
42
+ network: this.NETWORKS.DEVNET,
43
+ extra: { feePayer: this.DUMMY_FEE_PAYER }
31
44
  },
32
45
  {
33
- x402Version: 1,
46
+ x402Version: 2,
34
47
  scheme: "exact",
35
- network: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
36
- // Mainnet
37
- extra: {}
48
+ network: this.NETWORKS.MAINNET,
49
+ extra: { feePayer: this.DUMMY_FEE_PAYER }
38
50
  }
39
51
  ],
40
52
  extensions: [],
41
53
  signers: {
42
- "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": [],
43
- "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": []
54
+ "solana:*": [this.DUMMY_FEE_PAYER]
44
55
  }
45
56
  };
57
+ console.log("[LocalSvmFacilitator] Returning supported:", JSON.stringify(supported));
58
+ return supported;
46
59
  }
47
60
  /**
48
61
  * Get mechanism-specific extra data
49
62
  */
50
- getExtra(network) {
63
+ getExtra(_network) {
51
64
  return void 0;
52
65
  }
53
66
  /**
54
67
  * Get default signers (not used for local verification usually, but required by interface)
55
68
  */
56
- getSigners(network) {
69
+ getSigners(_network) {
57
70
  return [];
58
71
  }
59
72
  /**
@@ -160,10 +173,11 @@ function createX402Middleware(config) {
160
173
  accepts: {
161
174
  scheme: "exact",
162
175
  payTo: config.walletAddress,
163
- amount: config.price?.toString() || "0",
176
+ price: config.price?.toString() || "0",
164
177
  network: config.network === "mainnet-beta" ? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" : "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
165
178
  }
166
179
  };
180
+ console.log("[createX402Middleware] Final Config:", JSON.stringify(finalConfig));
167
181
  return next.withX402(handler, finalConfig, server$2);
168
182
  };
169
183
  }
@@ -12,47 +12,60 @@ var LocalSvmFacilitator = class {
12
12
  caipFamily = "solana:*";
13
13
  connection;
14
14
  constructor(rpcUrl) {
15
+ console.log("[LocalSvmFacilitator] Initialized with RPC:", rpcUrl);
15
16
  this.connection = new Connection(rpcUrl, "confirmed");
16
17
  }
17
18
  /**
18
19
  * Get supported payment kinds
19
20
  * Mocking the response of the /supported endpoint
20
21
  */
21
- async getSupported(extensionKeys = []) {
22
- return {
22
+ // Network Constants - CAIP-2 format for x402 v2
23
+ NETWORKS = {
24
+ DEVNET: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
25
+ MAINNET: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
26
+ };
27
+ // Dummy fee payer address (System Program) - not used in local verification
28
+ // but required by x402 protocol for supported kinds
29
+ DUMMY_FEE_PAYER = "11111111111111111111111111111111";
30
+ /**
31
+ * Get supported payment kinds
32
+ * Returns x402 v2 compatible response with CAIP-2 network identifiers
33
+ */
34
+ async getSupported(_extensionKeys = []) {
35
+ console.log("[LocalSvmFacilitator] getSupported called");
36
+ const supported = {
23
37
  kinds: [
24
38
  {
25
- x402Version: 1,
39
+ x402Version: 2,
26
40
  scheme: "exact",
27
- network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
28
- // Devnet
29
- extra: {}
41
+ network: this.NETWORKS.DEVNET,
42
+ extra: { feePayer: this.DUMMY_FEE_PAYER }
30
43
  },
31
44
  {
32
- x402Version: 1,
45
+ x402Version: 2,
33
46
  scheme: "exact",
34
- network: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
35
- // Mainnet
36
- extra: {}
47
+ network: this.NETWORKS.MAINNET,
48
+ extra: { feePayer: this.DUMMY_FEE_PAYER }
37
49
  }
38
50
  ],
39
51
  extensions: [],
40
52
  signers: {
41
- "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": [],
42
- "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": []
53
+ "solana:*": [this.DUMMY_FEE_PAYER]
43
54
  }
44
55
  };
56
+ console.log("[LocalSvmFacilitator] Returning supported:", JSON.stringify(supported));
57
+ return supported;
45
58
  }
46
59
  /**
47
60
  * Get mechanism-specific extra data
48
61
  */
49
- getExtra(network) {
62
+ getExtra(_network) {
50
63
  return void 0;
51
64
  }
52
65
  /**
53
66
  * Get default signers (not used for local verification usually, but required by interface)
54
67
  */
55
- getSigners(network) {
68
+ getSigners(_network) {
56
69
  return [];
57
70
  }
58
71
  /**
@@ -159,10 +172,11 @@ function createX402Middleware(config) {
159
172
  accepts: {
160
173
  scheme: "exact",
161
174
  payTo: config.walletAddress,
162
- amount: config.price?.toString() || "0",
175
+ price: config.price?.toString() || "0",
163
176
  network: config.network === "mainnet-beta" ? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" : "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
164
177
  }
165
178
  };
179
+ console.log("[createX402Middleware] Final Config:", JSON.stringify(finalConfig));
166
180
  return withX402$1(handler, finalConfig, server);
167
181
  };
168
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alleyboss/micropay-solana-x402-paywall",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Production-ready Solana micropayments library wrapper for official x402 SDK",
5
5
  "author": "AlleyBoss",
6
6
  "license": "MIT",