@agentcash/router 0.5.0 → 0.5.1
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 +5 -3
- package/dist/index.js +5 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1301,6 +1301,7 @@ var RouteBuilder = class {
|
|
|
1301
1301
|
// src/discovery/well-known.ts
|
|
1302
1302
|
var import_server3 = require("next/server");
|
|
1303
1303
|
function createWellKnownHandler(registry, baseUrl, pricesKeys, options = {}) {
|
|
1304
|
+
const normalizedBase = baseUrl.replace(/\/+$/, "");
|
|
1304
1305
|
let validated = false;
|
|
1305
1306
|
return async (_request) => {
|
|
1306
1307
|
if (!validated && pricesKeys) {
|
|
@@ -1310,7 +1311,7 @@ function createWellKnownHandler(registry, baseUrl, pricesKeys, options = {}) {
|
|
|
1310
1311
|
const x402Set = /* @__PURE__ */ new Set();
|
|
1311
1312
|
const mppSet = /* @__PURE__ */ new Set();
|
|
1312
1313
|
for (const [key, entry] of registry.entries()) {
|
|
1313
|
-
const url = `${
|
|
1314
|
+
const url = `${normalizedBase}/api/${entry.path ?? key}`;
|
|
1314
1315
|
if (entry.authMode !== "unprotected") x402Set.add(url);
|
|
1315
1316
|
if (entry.protocols.includes("mpp")) mppSet.add(url);
|
|
1316
1317
|
}
|
|
@@ -1350,6 +1351,7 @@ function createWellKnownHandler(registry, baseUrl, pricesKeys, options = {}) {
|
|
|
1350
1351
|
// src/discovery/openapi.ts
|
|
1351
1352
|
var import_server4 = require("next/server");
|
|
1352
1353
|
function createOpenAPIHandler(registry, baseUrl, pricesKeys, options) {
|
|
1354
|
+
const normalizedBase = baseUrl.replace(/\/+$/, "");
|
|
1353
1355
|
let cached = null;
|
|
1354
1356
|
let validated = false;
|
|
1355
1357
|
return async (_request) => {
|
|
@@ -1376,7 +1378,7 @@ function createOpenAPIHandler(registry, baseUrl, pricesKeys, options) {
|
|
|
1376
1378
|
version: options.version,
|
|
1377
1379
|
...options.contact && { contact: options.contact }
|
|
1378
1380
|
},
|
|
1379
|
-
servers: [{ url: options.baseUrl ??
|
|
1381
|
+
servers: [{ url: (options.baseUrl ?? normalizedBase).replace(/\/+$/, "") }],
|
|
1380
1382
|
tags: Array.from(tagSet).sort().map((name) => ({ name })),
|
|
1381
1383
|
paths
|
|
1382
1384
|
});
|
|
@@ -1461,7 +1463,7 @@ function createRouter(config) {
|
|
|
1461
1463
|
}
|
|
1462
1464
|
console.warn(`[router] ${msg}`);
|
|
1463
1465
|
}
|
|
1464
|
-
const resolvedBaseUrl = baseUrl ?? "http://localhost:3000";
|
|
1466
|
+
const resolvedBaseUrl = (baseUrl ?? "http://localhost:3000").replace(/\/+$/, "");
|
|
1465
1467
|
let x402ConfigError;
|
|
1466
1468
|
let mppConfigError;
|
|
1467
1469
|
if ((!config.protocols || config.protocols.includes("x402")) && !config.payeeAddress) {
|
package/dist/index.js
CHANGED
|
@@ -1264,6 +1264,7 @@ var RouteBuilder = class {
|
|
|
1264
1264
|
// src/discovery/well-known.ts
|
|
1265
1265
|
import { NextResponse as NextResponse3 } from "next/server";
|
|
1266
1266
|
function createWellKnownHandler(registry, baseUrl, pricesKeys, options = {}) {
|
|
1267
|
+
const normalizedBase = baseUrl.replace(/\/+$/, "");
|
|
1267
1268
|
let validated = false;
|
|
1268
1269
|
return async (_request) => {
|
|
1269
1270
|
if (!validated && pricesKeys) {
|
|
@@ -1273,7 +1274,7 @@ function createWellKnownHandler(registry, baseUrl, pricesKeys, options = {}) {
|
|
|
1273
1274
|
const x402Set = /* @__PURE__ */ new Set();
|
|
1274
1275
|
const mppSet = /* @__PURE__ */ new Set();
|
|
1275
1276
|
for (const [key, entry] of registry.entries()) {
|
|
1276
|
-
const url = `${
|
|
1277
|
+
const url = `${normalizedBase}/api/${entry.path ?? key}`;
|
|
1277
1278
|
if (entry.authMode !== "unprotected") x402Set.add(url);
|
|
1278
1279
|
if (entry.protocols.includes("mpp")) mppSet.add(url);
|
|
1279
1280
|
}
|
|
@@ -1313,6 +1314,7 @@ function createWellKnownHandler(registry, baseUrl, pricesKeys, options = {}) {
|
|
|
1313
1314
|
// src/discovery/openapi.ts
|
|
1314
1315
|
import { NextResponse as NextResponse4 } from "next/server";
|
|
1315
1316
|
function createOpenAPIHandler(registry, baseUrl, pricesKeys, options) {
|
|
1317
|
+
const normalizedBase = baseUrl.replace(/\/+$/, "");
|
|
1316
1318
|
let cached = null;
|
|
1317
1319
|
let validated = false;
|
|
1318
1320
|
return async (_request) => {
|
|
@@ -1339,7 +1341,7 @@ function createOpenAPIHandler(registry, baseUrl, pricesKeys, options) {
|
|
|
1339
1341
|
version: options.version,
|
|
1340
1342
|
...options.contact && { contact: options.contact }
|
|
1341
1343
|
},
|
|
1342
|
-
servers: [{ url: options.baseUrl ??
|
|
1344
|
+
servers: [{ url: (options.baseUrl ?? normalizedBase).replace(/\/+$/, "") }],
|
|
1343
1345
|
tags: Array.from(tagSet).sort().map((name) => ({ name })),
|
|
1344
1346
|
paths
|
|
1345
1347
|
});
|
|
@@ -1424,7 +1426,7 @@ function createRouter(config) {
|
|
|
1424
1426
|
}
|
|
1425
1427
|
console.warn(`[router] ${msg}`);
|
|
1426
1428
|
}
|
|
1427
|
-
const resolvedBaseUrl = baseUrl ?? "http://localhost:3000";
|
|
1429
|
+
const resolvedBaseUrl = (baseUrl ?? "http://localhost:3000").replace(/\/+$/, "");
|
|
1428
1430
|
let x402ConfigError;
|
|
1429
1431
|
let mppConfigError;
|
|
1430
1432
|
if ((!config.protocols || config.protocols.includes("x402")) && !config.payeeAddress) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentcash/router",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
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": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@x402/core": "^2.3.0",
|
|
29
29
|
"@x402/evm": "^2.3.0",
|
|
30
30
|
"@x402/extensions": "^2.3.0",
|
|
31
|
-
"mppx": "^0.2
|
|
31
|
+
"mppx": "^0.3.2",
|
|
32
32
|
"next": ">=15.0.0",
|
|
33
33
|
"zod": "^4.0.0",
|
|
34
34
|
"zod-openapi": "^5.0.0"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@x402/evm": "^2.3.0",
|
|
49
49
|
"@x402/extensions": "^2.3.0",
|
|
50
50
|
"eslint": "^10.0.0",
|
|
51
|
-
"mppx": "^0.2
|
|
51
|
+
"mppx": "^0.3.2",
|
|
52
52
|
"next": "^15.0.0",
|
|
53
53
|
"prettier": "^3.8.1",
|
|
54
54
|
"react": "^19.0.0",
|