@agentcash/router 1.1.8 → 1.1.10
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 +20 -4
- package/dist/index.js +20 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -662,7 +662,14 @@ async function verifyX402Payment(opts) {
|
|
|
662
662
|
if (!matching) {
|
|
663
663
|
return invalidPaymentVerification();
|
|
664
664
|
}
|
|
665
|
-
|
|
665
|
+
let verify;
|
|
666
|
+
try {
|
|
667
|
+
verify = await server.verifyPayment(payload, matching);
|
|
668
|
+
} catch (err) {
|
|
669
|
+
const sc = err.statusCode;
|
|
670
|
+
if (sc && sc >= 400 && sc < 500) return invalidPaymentVerification();
|
|
671
|
+
throw err;
|
|
672
|
+
}
|
|
666
673
|
if (!verify.isValid) return invalidPaymentVerification();
|
|
667
674
|
return {
|
|
668
675
|
valid: true,
|
|
@@ -1482,8 +1489,12 @@ async function build402(request, routeEntry, deps, meta, pluginCtx, bodyData) {
|
|
|
1482
1489
|
try {
|
|
1483
1490
|
const { z } = await import("zod");
|
|
1484
1491
|
const { declareDiscoveryExtension } = await import("@x402/extensions/bazaar");
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1492
|
+
const toJSON = (schema) => z.toJSONSchema(schema, {
|
|
1493
|
+
target: "draft-2020-12",
|
|
1494
|
+
unrepresentable: "any"
|
|
1495
|
+
});
|
|
1496
|
+
const inputSchema = routeEntry.bodySchema ? toJSON(routeEntry.bodySchema) : routeEntry.querySchema ? toJSON(routeEntry.querySchema) : void 0;
|
|
1497
|
+
const outputSchema = routeEntry.outputSchema ? toJSON(routeEntry.outputSchema) : void 0;
|
|
1487
1498
|
if (inputSchema) {
|
|
1488
1499
|
const config = {
|
|
1489
1500
|
bodyType: routeEntry.bodySchema ? "json" : void 0,
|
|
@@ -1492,7 +1503,12 @@ async function build402(request, routeEntry, deps, meta, pluginCtx, bodyData) {
|
|
|
1492
1503
|
if (outputSchema) config.output = { schema: outputSchema, example: {} };
|
|
1493
1504
|
extensions = declareDiscoveryExtension(config);
|
|
1494
1505
|
}
|
|
1495
|
-
} catch {
|
|
1506
|
+
} catch (err) {
|
|
1507
|
+
firePluginHook(deps.plugin, "onAlert", pluginCtx, {
|
|
1508
|
+
level: "warn",
|
|
1509
|
+
message: `Bazaar schema generation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
1510
|
+
route: routeEntry.key
|
|
1511
|
+
});
|
|
1496
1512
|
}
|
|
1497
1513
|
if (routeEntry.siwxEnabled) {
|
|
1498
1514
|
try {
|
package/dist/index.js
CHANGED
|
@@ -623,7 +623,14 @@ async function verifyX402Payment(opts) {
|
|
|
623
623
|
if (!matching) {
|
|
624
624
|
return invalidPaymentVerification();
|
|
625
625
|
}
|
|
626
|
-
|
|
626
|
+
let verify;
|
|
627
|
+
try {
|
|
628
|
+
verify = await server.verifyPayment(payload, matching);
|
|
629
|
+
} catch (err) {
|
|
630
|
+
const sc = err.statusCode;
|
|
631
|
+
if (sc && sc >= 400 && sc < 500) return invalidPaymentVerification();
|
|
632
|
+
throw err;
|
|
633
|
+
}
|
|
627
634
|
if (!verify.isValid) return invalidPaymentVerification();
|
|
628
635
|
return {
|
|
629
636
|
valid: true,
|
|
@@ -1443,8 +1450,12 @@ async function build402(request, routeEntry, deps, meta, pluginCtx, bodyData) {
|
|
|
1443
1450
|
try {
|
|
1444
1451
|
const { z } = await import("zod");
|
|
1445
1452
|
const { declareDiscoveryExtension } = await import("@x402/extensions/bazaar");
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1453
|
+
const toJSON = (schema) => z.toJSONSchema(schema, {
|
|
1454
|
+
target: "draft-2020-12",
|
|
1455
|
+
unrepresentable: "any"
|
|
1456
|
+
});
|
|
1457
|
+
const inputSchema = routeEntry.bodySchema ? toJSON(routeEntry.bodySchema) : routeEntry.querySchema ? toJSON(routeEntry.querySchema) : void 0;
|
|
1458
|
+
const outputSchema = routeEntry.outputSchema ? toJSON(routeEntry.outputSchema) : void 0;
|
|
1448
1459
|
if (inputSchema) {
|
|
1449
1460
|
const config = {
|
|
1450
1461
|
bodyType: routeEntry.bodySchema ? "json" : void 0,
|
|
@@ -1453,7 +1464,12 @@ async function build402(request, routeEntry, deps, meta, pluginCtx, bodyData) {
|
|
|
1453
1464
|
if (outputSchema) config.output = { schema: outputSchema, example: {} };
|
|
1454
1465
|
extensions = declareDiscoveryExtension(config);
|
|
1455
1466
|
}
|
|
1456
|
-
} catch {
|
|
1467
|
+
} catch (err) {
|
|
1468
|
+
firePluginHook(deps.plugin, "onAlert", pluginCtx, {
|
|
1469
|
+
level: "warn",
|
|
1470
|
+
message: `Bazaar schema generation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
1471
|
+
route: routeEntry.key
|
|
1472
|
+
});
|
|
1457
1473
|
}
|
|
1458
1474
|
if (routeEntry.siwxEnabled) {
|
|
1459
1475
|
try {
|