wolverine-ai 5.3.0 → 5.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wolverine-ai",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "description": "Self-healing Node.js server framework powered by AI. Catches crashes, diagnoses errors, generates fixes, verifies, and restarts — automatically.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -43,10 +43,10 @@ async function x402Plugin(fastify, opts) {
43
43
  } catch {}
44
44
  }
45
45
 
46
- // Initialize facilitator from @coinbase/x402
46
+ // Initialize facilitator from @coinbase/x402 (ESM packages, need dynamic import)
47
47
  try {
48
- const { facilitator } = require("@coinbase/x402");
49
- const { useFacilitator } = require("x402/verify");
48
+ const { facilitator } = await import("@coinbase/x402");
49
+ const { useFacilitator } = await import("x402/verify");
50
50
  _facilitatorClient = useFacilitator(facilitator);
51
51
  console.log(` 💰 x402: facilitator loaded (@coinbase/x402)`);
52
52
  } catch (err) {
@@ -98,16 +98,21 @@ async function x402Plugin(fastify, opts) {
98
98
  const paymentHeader = request.headers["x-payment"] || request.headers["payment-signature"];
99
99
 
100
100
  // Build payment requirements (v1 format matching @coinbase/x402)
101
- const { getAddress } = require("viem");
101
+ const { getAddress } = await import("viem");
102
+ // Build full resource URL (required by facilitator)
103
+ const proto = request.headers["x-forwarded-proto"] || "https";
104
+ const host = request.headers["x-forwarded-host"] || request.headers.host || "localhost";
105
+ const resourceUrl = `${proto}://${host}${request.url}`;
106
+
102
107
  const paymentRequirements = {
103
108
  scheme: "exact",
104
109
  network: _network,
105
110
  maxAmountRequired: usdcAtomicAmount,
106
- resource: `${request.method} ${request.url}`,
107
- description: routeConfig.description || `Payment for ${request.method} ${request.url}`,
111
+ resource: resourceUrl,
112
+ description: routeConfig.description || `Payment of $${dollarAmount.toFixed(2)} USDC`,
108
113
  mimeType: "application/json",
109
114
  payTo: getAddress(_payTo),
110
- maxTimeoutSeconds: 300,
115
+ maxTimeoutSeconds: 60,
111
116
  asset: getAddress(USDC_ADDRESS),
112
117
  extra: USDC_EIP712,
113
118
  };
@@ -130,7 +135,7 @@ async function x402Plugin(fastify, opts) {
130
135
  // Decode payment
131
136
  let decodedPayment;
132
137
  try {
133
- const { exact } = require("x402/schemes");
138
+ const { exact } = await import("x402/schemes");
134
139
  const libraryDecoded = exact.evm.decodePayment(paymentHeader);
135
140
 
136
141
  // Parse raw payload for metadata
@@ -186,11 +191,13 @@ async function x402Plugin(fastify, opts) {
186
191
  const decodedPayment = { x402Version: raw.x402Version || 1, scheme: raw.scheme || "exact", network: raw.network || _network, payload: libraryDecoded.payload };
187
192
 
188
193
  const userValue = decodedPayment.payload.authorization.value;
189
- const { getAddress } = require("viem");
194
+ const { getAddress } = await import("viem");
195
+ const proto = request.headers["x-forwarded-proto"] || "https";
196
+ const host = request.headers["x-forwarded-host"] || request.headers.host || "localhost";
190
197
  const requirements = {
191
198
  scheme: "exact", network: _network, maxAmountRequired: userValue,
192
- resource: `${request.method} ${request.url}`, description: "", mimeType: "application/json",
193
- payTo: getAddress(_payTo), maxTimeoutSeconds: 300, asset: getAddress(USDC_ADDRESS), extra: USDC_EIP712,
199
+ resource: `${proto}://${host}${request.url}`, description: "", mimeType: "application/json",
200
+ payTo: getAddress(_payTo), maxTimeoutSeconds: 60, asset: getAddress(USDC_ADDRESS), extra: USDC_EIP712,
194
201
  };
195
202
 
196
203
  const settleResult = await _facilitatorClient.settle(decodedPayment, requirements);