@agentcash/router 0.6.6 → 0.6.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 +6 -2
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -369,6 +369,7 @@ function resolveMaxPrice(pricing) {
|
|
|
369
369
|
|
|
370
370
|
// src/orchestrate.ts
|
|
371
371
|
var import_mppx = require("mppx");
|
|
372
|
+
var import_viem = require("viem");
|
|
372
373
|
|
|
373
374
|
// src/protocols/x402.ts
|
|
374
375
|
async function buildX402Challenge(server, routeEntry, request, price, payeeAddress, network, extensions) {
|
|
@@ -871,13 +872,16 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
871
872
|
return await build402(request, routeEntry, deps, meta, pluginCtx);
|
|
872
873
|
}
|
|
873
874
|
const credential = import_mppx.Credential.fromRequest(request);
|
|
874
|
-
const
|
|
875
|
+
const rawSource = credential?.source ?? "";
|
|
876
|
+
const didParts = rawSource.split(":");
|
|
877
|
+
const lastPart = didParts[didParts.length - 1];
|
|
878
|
+
const wallet = ((0, import_viem.isAddress)(lastPart) ? (0, import_viem.getAddress)(lastPart) : rawSource).toLowerCase();
|
|
875
879
|
pluginCtx.setVerifiedWallet(wallet);
|
|
876
880
|
firePluginHook(deps.plugin, "onPaymentVerified", pluginCtx, {
|
|
877
881
|
protocol: "mpp",
|
|
878
882
|
payer: wallet,
|
|
879
883
|
amount: price,
|
|
880
|
-
network: "tempo:
|
|
884
|
+
network: "tempo:4217"
|
|
881
885
|
});
|
|
882
886
|
const { response, rawResult } = await invoke(
|
|
883
887
|
request,
|
package/dist/index.js
CHANGED
|
@@ -332,6 +332,7 @@ function resolveMaxPrice(pricing) {
|
|
|
332
332
|
|
|
333
333
|
// src/orchestrate.ts
|
|
334
334
|
import { Credential } from "mppx";
|
|
335
|
+
import { isAddress, getAddress } from "viem";
|
|
335
336
|
|
|
336
337
|
// src/protocols/x402.ts
|
|
337
338
|
async function buildX402Challenge(server, routeEntry, request, price, payeeAddress, network, extensions) {
|
|
@@ -834,13 +835,16 @@ function createRequestHandler(routeEntry, handler, deps) {
|
|
|
834
835
|
return await build402(request, routeEntry, deps, meta, pluginCtx);
|
|
835
836
|
}
|
|
836
837
|
const credential = Credential.fromRequest(request);
|
|
837
|
-
const
|
|
838
|
+
const rawSource = credential?.source ?? "";
|
|
839
|
+
const didParts = rawSource.split(":");
|
|
840
|
+
const lastPart = didParts[didParts.length - 1];
|
|
841
|
+
const wallet = (isAddress(lastPart) ? getAddress(lastPart) : rawSource).toLowerCase();
|
|
838
842
|
pluginCtx.setVerifiedWallet(wallet);
|
|
839
843
|
firePluginHook(deps.plugin, "onPaymentVerified", pluginCtx, {
|
|
840
844
|
protocol: "mpp",
|
|
841
845
|
payer: wallet,
|
|
842
846
|
amount: price,
|
|
843
|
-
network: "tempo:
|
|
847
|
+
network: "tempo:4217"
|
|
844
848
|
});
|
|
845
849
|
const { response, rawResult } = await invoke(
|
|
846
850
|
request,
|