@agentcash/router 1.3.0 → 1.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.
Files changed (3) hide show
  1. package/dist/index.cjs +54 -34
  2. package/dist/index.js +54 -34
  3. package/package.json +11 -11
package/dist/index.cjs CHANGED
@@ -258,6 +258,10 @@ async function createX402Server(config) {
258
258
  );
259
259
  if (evmNetworks.length > 0) {
260
260
  registerExactEvmScheme(server, { networks: evmNetworks });
261
+ const { UptoEvmScheme } = await import("@x402/evm/upto/server");
262
+ for (const network of evmNetworks) {
263
+ server.register(network, new UptoEvmScheme());
264
+ }
261
265
  }
262
266
  if (svmNetworks.length > 0) {
263
267
  const { registerExactSvmScheme } = await import("@x402/svm/exact/server");
@@ -287,18 +291,24 @@ function createFacilitatorClients(facilitatorsByNetwork, HTTPFacilitatorClient)
287
291
  const groups = getResolvedX402FacilitatorGroups(facilitatorsByNetwork);
288
292
  return groups.map((group) => {
289
293
  const inner = new HTTPFacilitatorClient(group.config);
290
- const kinds = group.networks.map((network) => ({
291
- x402Version: 2,
292
- scheme: "exact",
293
- network,
294
- ...group.family === "solana" ? {
295
- extra: {
296
- features: {
297
- xSettlementAccountSupported: true
294
+ const kinds = group.networks.flatMap((network) => {
295
+ const exactKind = {
296
+ x402Version: 2,
297
+ scheme: "exact",
298
+ network,
299
+ ...group.family === "solana" ? {
300
+ extra: {
301
+ features: {
302
+ xSettlementAccountSupported: true
303
+ }
298
304
  }
299
- }
300
- } : {}
301
- }));
305
+ } : {}
306
+ };
307
+ if (group.family === "evm") {
308
+ return [exactKind, { x402Version: 2, scheme: "upto", network }];
309
+ }
310
+ return [exactKind];
311
+ });
302
312
  return cachedClient(inner, kinds);
303
313
  });
304
314
  }
@@ -320,30 +330,40 @@ __export(upstash_rest_exports, {
320
330
  function createUpstashRest(url, token) {
321
331
  const base = url.replace(/\/+$/, "");
322
332
  const headers = { Authorization: `Bearer ${token}` };
333
+ async function get(key) {
334
+ const res = await fetch(`${base}/get/${key}`, { headers });
335
+ if (!res.ok) throw new Error(`[upstash-rest] GET ${key}: ${res.status}`);
336
+ const { result } = await res.json();
337
+ return result ?? null;
338
+ }
339
+ async function set(key, value) {
340
+ const res = await fetch(`${base}`, {
341
+ method: "POST",
342
+ headers: { ...headers, "Content-Type": "application/json" },
343
+ body: JSON.stringify(["SET", key, JSON.stringify(value)])
344
+ });
345
+ if (!res.ok) throw new Error(`[upstash-rest] SET ${key}: ${res.status}`);
346
+ return await res.json();
347
+ }
348
+ async function del(key) {
349
+ const res = await fetch(`${base}`, {
350
+ method: "POST",
351
+ headers: { ...headers, "Content-Type": "application/json" },
352
+ body: JSON.stringify(["DEL", key])
353
+ });
354
+ if (!res.ok) throw new Error(`[upstash-rest] DEL ${key}: ${res.status}`);
355
+ return await res.json();
356
+ }
323
357
  return {
324
- async get(key) {
325
- const res = await fetch(`${base}/get/${key}`, { headers });
326
- if (!res.ok) throw new Error(`[upstash-rest] GET ${key}: ${res.status}`);
327
- const { result } = await res.json();
328
- return result ?? null;
329
- },
330
- async set(key, value) {
331
- const res = await fetch(`${base}`, {
332
- method: "POST",
333
- headers: { ...headers, "Content-Type": "application/json" },
334
- body: JSON.stringify(["SET", key, JSON.stringify(value)])
335
- });
336
- if (!res.ok) throw new Error(`[upstash-rest] SET ${key}: ${res.status}`);
337
- return await res.json();
338
- },
339
- async del(key) {
340
- const res = await fetch(`${base}`, {
341
- method: "POST",
342
- headers: { ...headers, "Content-Type": "application/json" },
343
- body: JSON.stringify(["DEL", key])
344
- });
345
- if (!res.ok) throw new Error(`[upstash-rest] DEL ${key}: ${res.status}`);
346
- return await res.json();
358
+ get,
359
+ set,
360
+ del,
361
+ async update(key, fn) {
362
+ const current = await get(key);
363
+ const change = fn(current);
364
+ if (change.op === "set") await set(key, change.value);
365
+ if (change.op === "delete") await del(key);
366
+ return change.result;
347
367
  }
348
368
  };
349
369
  }
package/dist/index.js CHANGED
@@ -236,6 +236,10 @@ async function createX402Server(config) {
236
236
  );
237
237
  if (evmNetworks.length > 0) {
238
238
  registerExactEvmScheme(server, { networks: evmNetworks });
239
+ const { UptoEvmScheme } = await import("@x402/evm/upto/server");
240
+ for (const network of evmNetworks) {
241
+ server.register(network, new UptoEvmScheme());
242
+ }
239
243
  }
240
244
  if (svmNetworks.length > 0) {
241
245
  const { registerExactSvmScheme } = await import("@x402/svm/exact/server");
@@ -265,18 +269,24 @@ function createFacilitatorClients(facilitatorsByNetwork, HTTPFacilitatorClient)
265
269
  const groups = getResolvedX402FacilitatorGroups(facilitatorsByNetwork);
266
270
  return groups.map((group) => {
267
271
  const inner = new HTTPFacilitatorClient(group.config);
268
- const kinds = group.networks.map((network) => ({
269
- x402Version: 2,
270
- scheme: "exact",
271
- network,
272
- ...group.family === "solana" ? {
273
- extra: {
274
- features: {
275
- xSettlementAccountSupported: true
272
+ const kinds = group.networks.flatMap((network) => {
273
+ const exactKind = {
274
+ x402Version: 2,
275
+ scheme: "exact",
276
+ network,
277
+ ...group.family === "solana" ? {
278
+ extra: {
279
+ features: {
280
+ xSettlementAccountSupported: true
281
+ }
276
282
  }
277
- }
278
- } : {}
279
- }));
283
+ } : {}
284
+ };
285
+ if (group.family === "evm") {
286
+ return [exactKind, { x402Version: 2, scheme: "upto", network }];
287
+ }
288
+ return [exactKind];
289
+ });
280
290
  return cachedClient(inner, kinds);
281
291
  });
282
292
  }
@@ -298,30 +308,40 @@ __export(upstash_rest_exports, {
298
308
  function createUpstashRest(url, token) {
299
309
  const base = url.replace(/\/+$/, "");
300
310
  const headers = { Authorization: `Bearer ${token}` };
311
+ async function get(key) {
312
+ const res = await fetch(`${base}/get/${key}`, { headers });
313
+ if (!res.ok) throw new Error(`[upstash-rest] GET ${key}: ${res.status}`);
314
+ const { result } = await res.json();
315
+ return result ?? null;
316
+ }
317
+ async function set(key, value) {
318
+ const res = await fetch(`${base}`, {
319
+ method: "POST",
320
+ headers: { ...headers, "Content-Type": "application/json" },
321
+ body: JSON.stringify(["SET", key, JSON.stringify(value)])
322
+ });
323
+ if (!res.ok) throw new Error(`[upstash-rest] SET ${key}: ${res.status}`);
324
+ return await res.json();
325
+ }
326
+ async function del(key) {
327
+ const res = await fetch(`${base}`, {
328
+ method: "POST",
329
+ headers: { ...headers, "Content-Type": "application/json" },
330
+ body: JSON.stringify(["DEL", key])
331
+ });
332
+ if (!res.ok) throw new Error(`[upstash-rest] DEL ${key}: ${res.status}`);
333
+ return await res.json();
334
+ }
301
335
  return {
302
- async get(key) {
303
- const res = await fetch(`${base}/get/${key}`, { headers });
304
- if (!res.ok) throw new Error(`[upstash-rest] GET ${key}: ${res.status}`);
305
- const { result } = await res.json();
306
- return result ?? null;
307
- },
308
- async set(key, value) {
309
- const res = await fetch(`${base}`, {
310
- method: "POST",
311
- headers: { ...headers, "Content-Type": "application/json" },
312
- body: JSON.stringify(["SET", key, JSON.stringify(value)])
313
- });
314
- if (!res.ok) throw new Error(`[upstash-rest] SET ${key}: ${res.status}`);
315
- return await res.json();
316
- },
317
- async del(key) {
318
- const res = await fetch(`${base}`, {
319
- method: "POST",
320
- headers: { ...headers, "Content-Type": "application/json" },
321
- body: JSON.stringify(["DEL", key])
322
- });
323
- if (!res.ok) throw new Error(`[upstash-rest] DEL ${key}: ${res.status}`);
324
- return await res.json();
336
+ get,
337
+ set,
338
+ del,
339
+ async update(key, fn) {
340
+ const current = await get(key);
341
+ const change = fn(current);
342
+ if (change.op === "set") await set(key, change.value);
343
+ if (change.op === "delete") await del(key);
344
+ return change.result;
325
345
  }
326
346
  };
327
347
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentcash/router",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Unified route builder for Next.js App Router APIs with x402, MPP, SIWX, and API key auth",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,11 +25,11 @@
25
25
  ],
26
26
  "peerDependencies": {
27
27
  "@coinbase/x402": "^2.1.0",
28
- "@x402/core": "^2.3.0",
29
- "@x402/evm": "^2.3.0",
30
- "@x402/extensions": "^2.3.0",
31
- "@x402/svm": "2.3.0",
32
- "mppx": "^0.4.11",
28
+ "@x402/core": "^2.9.0",
29
+ "@x402/evm": "^2.9.0",
30
+ "@x402/extensions": "^2.9.0",
31
+ "@x402/svm": "^2.9.0",
32
+ "mppx": "^0.5.10",
33
33
  "next": ">=15.0.0",
34
34
  "zod": "^4.0.0",
35
35
  "zod-openapi": "^5.0.0"
@@ -56,12 +56,12 @@
56
56
  "@solana/spl-token": "^0.4.14",
57
57
  "@solana/web3.js": "^1.98.4",
58
58
  "@types/node": "^22.0.0",
59
- "@x402/core": "^2.3.0",
60
- "@x402/evm": "^2.3.0",
61
- "@x402/extensions": "^2.3.0",
62
- "@x402/svm": "2.3.0",
59
+ "@x402/core": "^2.9.0",
60
+ "@x402/evm": "^2.9.0",
61
+ "@x402/extensions": "^2.9.0",
62
+ "@x402/svm": "^2.9.0",
63
63
  "eslint": "^10.0.0",
64
- "mppx": "^0.4.11",
64
+ "mppx": "^0.5.10",
65
65
  "next": "^15.0.0",
66
66
  "prettier": "^3.8.1",
67
67
  "react": "^19.0.0",