wolverine-ai 5.3.1 → 5.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wolverine-ai",
3
- "version": "5.3.1",
3
+ "version": "5.3.3",
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": {
@@ -99,15 +99,20 @@ async function x402Plugin(fastify, opts) {
99
99
 
100
100
  // Build payment requirements (v1 format matching @coinbase/x402)
101
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
  };
@@ -127,20 +132,21 @@ async function x402Plugin(fastify, opts) {
127
132
  return;
128
133
  }
129
134
 
130
- // Decode payment
135
+ // Decode payment — parse raw payload directly (matching working project pattern)
131
136
  let decodedPayment;
132
137
  try {
133
- const { exact } = await import("x402/schemes");
134
- const libraryDecoded = exact.evm.decodePayment(paymentHeader);
135
-
136
- // Parse raw payload for metadata
137
138
  const raw = JSON.parse(Buffer.from(paymentHeader, "base64").toString("utf-8"));
138
139
 
140
+ // Validate required fields
141
+ if (!raw.payload?.authorization || !raw.payload?.signature) {
142
+ throw new Error("Missing authorization or signature");
143
+ }
144
+
139
145
  decodedPayment = {
140
146
  x402Version: raw.x402Version || 1,
141
147
  scheme: raw.scheme || "exact",
142
148
  network: raw.network || _network,
143
- payload: libraryDecoded.payload,
149
+ payload: raw.payload,
144
150
  };
145
151
  } catch (err) {
146
152
  reply.code(402).send({ error: "Invalid payment format: " + err.message, accepts: [paymentRequirements] });
@@ -180,17 +186,17 @@ async function x402Plugin(fastify, opts) {
180
186
 
181
187
  try {
182
188
  const paymentHeader = request.headers["x-payment"] || request.headers["payment-signature"];
183
- const { exact } = require("x402/schemes");
184
189
  const raw = JSON.parse(Buffer.from(paymentHeader, "base64").toString("utf-8"));
185
- const libraryDecoded = exact.evm.decodePayment(paymentHeader);
186
- const decodedPayment = { x402Version: raw.x402Version || 1, scheme: raw.scheme || "exact", network: raw.network || _network, payload: libraryDecoded.payload };
190
+ const decodedPayment = { x402Version: raw.x402Version || 1, scheme: raw.scheme || "exact", network: raw.network || _network, payload: raw.payload };
187
191
 
188
192
  const userValue = decodedPayment.payload.authorization.value;
189
193
  const { getAddress } = await import("viem");
194
+ const proto = request.headers["x-forwarded-proto"] || "https";
195
+ const host = request.headers["x-forwarded-host"] || request.headers.host || "localhost";
190
196
  const requirements = {
191
197
  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,
198
+ resource: `${proto}://${host}${request.url}`, description: "", mimeType: "application/json",
199
+ payTo: getAddress(_payTo), maxTimeoutSeconds: 60, asset: getAddress(USDC_ADDRESS), extra: USDC_EIP712,
194
200
  };
195
201
 
196
202
  const settleResult = await _facilitatorClient.settle(decodedPayment, requirements);