@agentcash/router 1.1.6 → 1.1.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/dist/index.cjs +16 -7
- package/dist/index.js +16 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1225,7 +1225,8 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
1225
1225
|
price,
|
|
1226
1226
|
accepts
|
|
1227
1227
|
});
|
|
1228
|
-
if (!verify?.valid)
|
|
1228
|
+
if (!verify?.valid)
|
|
1229
|
+
return await build402(request, routeEntry, deps, meta, pluginCtx, body.data);
|
|
1229
1230
|
const { payload: verifyPayload, requirements: verifyRequirements } = verify;
|
|
1230
1231
|
const matchedNetwork = getRequirementNetwork(verifyRequirements, deps.network);
|
|
1231
1232
|
const wallet = normalizeWalletAddress(verify.payer);
|
|
@@ -1317,15 +1318,23 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
1317
1318
|
return fail(500, `MPP payment processing failed: ${message}`, meta, pluginCtx, body.data);
|
|
1318
1319
|
}
|
|
1319
1320
|
if (mppResult.status === 402) {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1321
|
+
let rejectReason = "";
|
|
1322
|
+
try {
|
|
1323
|
+
const problemBody = await mppResult.challenge.clone().text();
|
|
1324
|
+
if (problemBody) {
|
|
1325
|
+
const problem = JSON.parse(problemBody);
|
|
1326
|
+
rejectReason = problem.detail || problem.title || "";
|
|
1327
|
+
}
|
|
1328
|
+
} catch {
|
|
1329
|
+
}
|
|
1330
|
+
const detail = rejectReason || "credential may be invalid, or check TEMPO_RPC_URL configuration";
|
|
1331
|
+
console.warn(`[router] ${routeEntry.key}: MPP credential rejected \u2014 ${detail}`);
|
|
1323
1332
|
firePluginHook(deps.plugin, "onAlert", pluginCtx, {
|
|
1324
1333
|
level: "warn",
|
|
1325
|
-
message:
|
|
1334
|
+
message: `MPP payment rejected: ${detail}`,
|
|
1326
1335
|
route: routeEntry.key
|
|
1327
1336
|
});
|
|
1328
|
-
return await build402(request, routeEntry, deps, meta, pluginCtx);
|
|
1337
|
+
return await build402(request, routeEntry, deps, meta, pluginCtx, body.data);
|
|
1329
1338
|
}
|
|
1330
1339
|
const credential = import_mppx.Credential.fromRequest(request);
|
|
1331
1340
|
const rawSource = credential?.source ?? "";
|
|
@@ -1367,7 +1376,7 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
1367
1376
|
finalize(response, rawResult, meta, pluginCtx, body.data);
|
|
1368
1377
|
return response;
|
|
1369
1378
|
}
|
|
1370
|
-
return await build402(request, routeEntry, deps, meta, pluginCtx);
|
|
1379
|
+
return await build402(request, routeEntry, deps, meta, pluginCtx, body.data);
|
|
1371
1380
|
};
|
|
1372
1381
|
}
|
|
1373
1382
|
async function parseBody(request, routeEntry) {
|
package/dist/index.js
CHANGED
|
@@ -1186,7 +1186,8 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
1186
1186
|
price,
|
|
1187
1187
|
accepts
|
|
1188
1188
|
});
|
|
1189
|
-
if (!verify?.valid)
|
|
1189
|
+
if (!verify?.valid)
|
|
1190
|
+
return await build402(request, routeEntry, deps, meta, pluginCtx, body.data);
|
|
1190
1191
|
const { payload: verifyPayload, requirements: verifyRequirements } = verify;
|
|
1191
1192
|
const matchedNetwork = getRequirementNetwork(verifyRequirements, deps.network);
|
|
1192
1193
|
const wallet = normalizeWalletAddress(verify.payer);
|
|
@@ -1278,15 +1279,23 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
1278
1279
|
return fail(500, `MPP payment processing failed: ${message}`, meta, pluginCtx, body.data);
|
|
1279
1280
|
}
|
|
1280
1281
|
if (mppResult.status === 402) {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1282
|
+
let rejectReason = "";
|
|
1283
|
+
try {
|
|
1284
|
+
const problemBody = await mppResult.challenge.clone().text();
|
|
1285
|
+
if (problemBody) {
|
|
1286
|
+
const problem = JSON.parse(problemBody);
|
|
1287
|
+
rejectReason = problem.detail || problem.title || "";
|
|
1288
|
+
}
|
|
1289
|
+
} catch {
|
|
1290
|
+
}
|
|
1291
|
+
const detail = rejectReason || "credential may be invalid, or check TEMPO_RPC_URL configuration";
|
|
1292
|
+
console.warn(`[router] ${routeEntry.key}: MPP credential rejected \u2014 ${detail}`);
|
|
1284
1293
|
firePluginHook(deps.plugin, "onAlert", pluginCtx, {
|
|
1285
1294
|
level: "warn",
|
|
1286
|
-
message:
|
|
1295
|
+
message: `MPP payment rejected: ${detail}`,
|
|
1287
1296
|
route: routeEntry.key
|
|
1288
1297
|
});
|
|
1289
|
-
return await build402(request, routeEntry, deps, meta, pluginCtx);
|
|
1298
|
+
return await build402(request, routeEntry, deps, meta, pluginCtx, body.data);
|
|
1290
1299
|
}
|
|
1291
1300
|
const credential = Credential.fromRequest(request);
|
|
1292
1301
|
const rawSource = credential?.source ?? "";
|
|
@@ -1328,7 +1337,7 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
1328
1337
|
finalize(response, rawResult, meta, pluginCtx, body.data);
|
|
1329
1338
|
return response;
|
|
1330
1339
|
}
|
|
1331
|
-
return await build402(request, routeEntry, deps, meta, pluginCtx);
|
|
1340
|
+
return await build402(request, routeEntry, deps, meta, pluginCtx, body.data);
|
|
1332
1341
|
};
|
|
1333
1342
|
}
|
|
1334
1343
|
async function parseBody(request, routeEntry) {
|