@bankofai/x402-cli 1.0.0-beta.1 → 1.0.0-beta.3
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/cli.js +18 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -543,6 +543,20 @@ async function responsePayload(response) {
|
|
|
543
543
|
}
|
|
544
544
|
return text;
|
|
545
545
|
}
|
|
546
|
+
async function withSdkStdoutRedirect(enabled, fn) {
|
|
547
|
+
if (!enabled)
|
|
548
|
+
return fn();
|
|
549
|
+
const originalLog = console.log;
|
|
550
|
+
console.log = (...args) => {
|
|
551
|
+
process.stderr.write(`${args.map(arg => typeof arg === "string" ? arg : JSON.stringify(arg, null, 2)).join(" ")}\n`);
|
|
552
|
+
};
|
|
553
|
+
try {
|
|
554
|
+
return await fn();
|
|
555
|
+
}
|
|
556
|
+
finally {
|
|
557
|
+
console.log = originalLog;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
546
560
|
function cacheDir() {
|
|
547
561
|
return path.join(os.homedir(), ".cache", "x402-cli", "catalog");
|
|
548
562
|
}
|
|
@@ -555,7 +569,7 @@ function providerFilename(fqn) {
|
|
|
555
569
|
function defaultCatalogSource() {
|
|
556
570
|
return fs.existsSync(cachedCatalogPath())
|
|
557
571
|
? cachedCatalogPath()
|
|
558
|
-
: "https://x402-
|
|
572
|
+
: "https://tm-x402-catalog.bankofai.io/api/catalog.json";
|
|
559
573
|
}
|
|
560
574
|
function remoteBaseFromCatalogPayload(payload) {
|
|
561
575
|
const base = payload.base_url ?? payload.baseUrl;
|
|
@@ -682,7 +696,7 @@ function submissionCatalog(detail) {
|
|
|
682
696
|
description,
|
|
683
697
|
useCase,
|
|
684
698
|
i18n: detail.i18n ?? { "zh-CN": zhCopy(title, subtitle, description, useCase) },
|
|
685
|
-
logo: detail.logo ?? "https://x402-
|
|
699
|
+
logo: detail.logo ?? "https://tm-x402-catalog.bankofai.io/assets/providers/default.png",
|
|
686
700
|
category: detail.category ?? "other",
|
|
687
701
|
chains: detail.chains ?? [],
|
|
688
702
|
isFirstParty: Boolean(detail.is_first_party ?? detail.isFirstParty),
|
|
@@ -997,13 +1011,13 @@ async function pay(url, options) {
|
|
|
997
1011
|
});
|
|
998
1012
|
return;
|
|
999
1013
|
}
|
|
1000
|
-
const payload = await createPaymentPayload({
|
|
1014
|
+
const payload = await withSdkStdoutRedirect(outputMode(options) === "json", () => createPaymentPayload({
|
|
1001
1015
|
selected,
|
|
1002
1016
|
resource: required.resource?.url ?? url,
|
|
1003
1017
|
extensions: required.extensions,
|
|
1004
1018
|
rpcUrl: opt(options, "rpc-url"),
|
|
1005
1019
|
privateKey: opt(options, "private-key"),
|
|
1006
|
-
});
|
|
1020
|
+
}));
|
|
1007
1021
|
const retryHeaders = new Headers(baseHeaders);
|
|
1008
1022
|
retryHeaders.set(headers.signature, encodeSignature(payload));
|
|
1009
1023
|
const paid = await fetch(url, {
|