wolverine-ai 5.2.6 → 5.2.7

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/.env.example CHANGED
@@ -16,6 +16,13 @@ WOLVERINE_API_KEY=
16
16
  # Generate: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
17
17
  WOLVERINE_ADMIN_KEY=
18
18
 
19
+ # ── CDP x402 Facilitator (mainnet payments) ──────────────────────
20
+ # Required for x402 USDC payments on Base mainnet.
21
+ # Sign up free at https://cdp.coinbase.com → create project → get keys
22
+ # Without these, x402 only works on testnet (Base Sepolia).
23
+ CDP_API_KEY_ID=
24
+ CDP_API_KEY_SECRET=
25
+
19
26
  # ── Custom Secrets ───────────────────────────────────────────────
20
27
  # Add any secret here — wolverine automatically redacts its value
21
28
  # from all AI calls, logs, brain storage, and dashboard output.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wolverine-ai",
3
- "version": "5.2.6",
3
+ "version": "5.2.7",
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": {
@@ -16,7 +16,7 @@ const USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
16
16
 
17
17
  let _payTo = null;
18
18
  let _network = "eip155:8453";
19
- let _facilitatorUrl = "https://www.x402.org/facilitator";
19
+ let _facilitatorUrl = "https://api.cdp.coinbase.com/platform/v2/x402";
20
20
 
21
21
  async function x402Plugin(fastify, opts) {
22
22
  _network = opts.network || _network;
@@ -42,10 +42,9 @@ async function x402Plugin(fastify, opts) {
42
42
 
43
43
  // Auto-select facilitator based on network
44
44
  if (!opts.facilitator) {
45
- const isTestnet = _network.includes("84532") || _network.includes("11155");
46
- _facilitatorUrl = isTestnet
47
- ? "https://www.x402.org/facilitator"
48
- : "https://www.x402.org/facilitator"; // www. avoids 308 redirect from x402.org
45
+ if (!process.env.CDP_API_KEY_ID) {
46
+ console.log(` ⚠️ x402: CDP_API_KEY_ID not set — facilitator auth may fail`);
47
+ }
49
48
  }
50
49
 
51
50
  if (_payTo) {
@@ -224,9 +223,29 @@ async function _facilitatorCall(endpoint, paymentPayload, paymentRequirements) {
224
223
  const controller = new AbortController();
225
224
  const timeout = setTimeout(() => controller.abort(), 30000);
226
225
 
226
+ // Build headers — add CDP JWT auth if using CDP facilitator
227
+ const headers = { "Content-Type": "application/json" };
228
+ if (url.includes("api.cdp.coinbase.com") && process.env.CDP_API_KEY_ID) {
229
+ try {
230
+ // Use dynamic import for @coinbase/cdp-sdk (ESM-only jose dependency)
231
+ const { generateJwt } = await import("@coinbase/cdp-sdk/auth");
232
+ const parsedUrl = new URL(url);
233
+ const jwt = await generateJwt({
234
+ apiKeyId: process.env.CDP_API_KEY_ID,
235
+ apiKeySecret: process.env.CDP_API_KEY_SECRET,
236
+ requestMethod: "POST",
237
+ requestHost: `https://${parsedUrl.host}`,
238
+ requestPath: parsedUrl.pathname,
239
+ });
240
+ headers["Authorization"] = `Bearer ${jwt}`;
241
+ } catch (authErr) {
242
+ console.log(` ⚠️ x402 CDP auth failed: ${authErr.message}`);
243
+ }
244
+ }
245
+
227
246
  const response = await fetch(url, {
228
247
  method: "POST",
229
- headers: { "Content-Type": "application/json" },
248
+ headers,
230
249
  body,
231
250
  redirect: "follow",
232
251
  signal: controller.signal,