@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.
- package/dist/index.cjs +54 -34
- package/dist/index.js +54 -34
- 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.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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.
|
|
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.
|
|
29
|
-
"@x402/evm": "^2.
|
|
30
|
-
"@x402/extensions": "^2.
|
|
31
|
-
"@x402/svm": "2.
|
|
32
|
-
"mppx": "^0.
|
|
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.
|
|
60
|
-
"@x402/evm": "^2.
|
|
61
|
-
"@x402/extensions": "^2.
|
|
62
|
-
"@x402/svm": "2.
|
|
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.
|
|
64
|
+
"mppx": "^0.5.10",
|
|
65
65
|
"next": "^15.0.0",
|
|
66
66
|
"prettier": "^3.8.1",
|
|
67
67
|
"react": "^19.0.0",
|