mnemospark 1.2.0 → 1.2.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/README.md +25 -1
- package/dist/cli.js +47 -22
- package/dist/cli.js.map +1 -1
- package/dist/index.js +47 -22
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -202,6 +202,10 @@ var PROXY_PORT = (() => {
|
|
|
202
202
|
return DEFAULT_PORT;
|
|
203
203
|
})();
|
|
204
204
|
var MNEMOSPARK_BACKEND_API_BASE_URL = (process.env.MNEMOSPARK_BACKEND_API_BASE_URL ?? "").trim();
|
|
205
|
+
var MNEMOSPARK_PROXY_VERBOSE_404 = (() => {
|
|
206
|
+
const v = process.env.MNEMOSPARK_PROXY_VERBOSE_404?.trim().toLowerCase();
|
|
207
|
+
return v === "1" || v === "true" || v === "yes";
|
|
208
|
+
})();
|
|
205
209
|
|
|
206
210
|
// src/mnemospark-request-sign.ts
|
|
207
211
|
import { getAddress } from "viem";
|
|
@@ -1778,8 +1782,15 @@ async function readProxyJsonBody(req) {
|
|
|
1778
1782
|
}
|
|
1779
1783
|
return JSON.parse(bodyText);
|
|
1780
1784
|
}
|
|
1785
|
+
function createJsonResponseHeaders() {
|
|
1786
|
+
return {
|
|
1787
|
+
"Content-Type": "application/json",
|
|
1788
|
+
"X-Content-Type-Options": "nosniff",
|
|
1789
|
+
"Cache-Control": "no-store"
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1781
1792
|
function sendJson(res, status, body) {
|
|
1782
|
-
res.writeHead(status,
|
|
1793
|
+
res.writeHead(status, createJsonResponseHeaders());
|
|
1783
1794
|
res.end(JSON.stringify(body));
|
|
1784
1795
|
}
|
|
1785
1796
|
function logProxyEvent(level, event, fields = {}) {
|
|
@@ -1839,7 +1850,9 @@ function isAlreadySettledConflict(status, bodyText) {
|
|
|
1839
1850
|
}
|
|
1840
1851
|
function createBackendForwardHeaders(response) {
|
|
1841
1852
|
const responseHeaders = {
|
|
1842
|
-
"Content-Type": response.contentType
|
|
1853
|
+
"Content-Type": response.contentType,
|
|
1854
|
+
"X-Content-Type-Options": "nosniff",
|
|
1855
|
+
"Cache-Control": "no-store"
|
|
1843
1856
|
};
|
|
1844
1857
|
if (response.paymentRequired) {
|
|
1845
1858
|
responseHeaders["PAYMENT-REQUIRED"] = response.paymentRequired;
|
|
@@ -1877,6 +1890,10 @@ function createWalletRequiredBody() {
|
|
|
1877
1890
|
message: "wallet required for storage endpoints"
|
|
1878
1891
|
});
|
|
1879
1892
|
}
|
|
1893
|
+
function sendWalletRequired(res) {
|
|
1894
|
+
res.writeHead(400, createJsonResponseHeaders());
|
|
1895
|
+
res.end(createWalletRequiredBody());
|
|
1896
|
+
}
|
|
1880
1897
|
function getProxyPort() {
|
|
1881
1898
|
return PROXY_PORT;
|
|
1882
1899
|
}
|
|
@@ -1976,6 +1993,18 @@ async function startProxy(options) {
|
|
|
1976
1993
|
}
|
|
1977
1994
|
correlation.wallet_address = requestPayload.wallet_address;
|
|
1978
1995
|
correlation.object_id = requestPayload.object_id;
|
|
1996
|
+
if (requestPayload.wallet_address.toLowerCase() !== proxyWalletAddressLower) {
|
|
1997
|
+
logProxyEvent("warn", "proxy_price_storage_wallet_mismatch", {
|
|
1998
|
+
request_wallet: requestPayload.wallet_address,
|
|
1999
|
+
proxy_wallet: account.address
|
|
2000
|
+
});
|
|
2001
|
+
emitProxyTerminalFromStatus(correlation, 403, { reason: "wallet_mismatch" });
|
|
2002
|
+
sendJson(res, 403, {
|
|
2003
|
+
error: "wallet_proof_invalid",
|
|
2004
|
+
message: "wallet proof invalid"
|
|
2005
|
+
});
|
|
2006
|
+
return;
|
|
2007
|
+
}
|
|
1979
2008
|
emitProxyEvent("storage.call", "start", correlation, { target: "price-storage" });
|
|
1980
2009
|
const walletSignature = await createBackendWalletSignature(
|
|
1981
2010
|
"POST",
|
|
@@ -1984,8 +2013,7 @@ async function startProxy(options) {
|
|
|
1984
2013
|
);
|
|
1985
2014
|
if (!walletSignature) {
|
|
1986
2015
|
logProxyEvent("warn", "proxy_price_storage_wallet_signature_missing");
|
|
1987
|
-
res
|
|
1988
|
-
res.end(createWalletRequiredBody());
|
|
2016
|
+
sendWalletRequired(res);
|
|
1989
2017
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "wallet_signature_missing" });
|
|
1990
2018
|
return;
|
|
1991
2019
|
}
|
|
@@ -2134,8 +2162,7 @@ async function startProxy(options) {
|
|
|
2134
2162
|
);
|
|
2135
2163
|
if (!walletSignature) {
|
|
2136
2164
|
logProxyEvent("warn", "proxy_payment_settle_wallet_signature_missing");
|
|
2137
|
-
res
|
|
2138
|
-
res.end(createWalletRequiredBody());
|
|
2165
|
+
sendWalletRequired(res);
|
|
2139
2166
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "wallet_signature_missing" });
|
|
2140
2167
|
return;
|
|
2141
2168
|
}
|
|
@@ -2243,8 +2270,7 @@ async function startProxy(options) {
|
|
|
2243
2270
|
);
|
|
2244
2271
|
if (!walletSignature) {
|
|
2245
2272
|
logProxyEvent("warn", "proxy_upload_wallet_signature_missing");
|
|
2246
|
-
res
|
|
2247
|
-
res.end(createWalletRequiredBody());
|
|
2273
|
+
sendWalletRequired(res);
|
|
2248
2274
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "wallet_signature_missing" });
|
|
2249
2275
|
return;
|
|
2250
2276
|
}
|
|
@@ -2291,8 +2317,7 @@ async function startProxy(options) {
|
|
|
2291
2317
|
);
|
|
2292
2318
|
if (!settleWalletSignature) {
|
|
2293
2319
|
logProxyEvent("warn", "proxy_upload_settle_signature_missing");
|
|
2294
|
-
res
|
|
2295
|
-
res.end(createWalletRequiredBody());
|
|
2320
|
+
sendWalletRequired(res);
|
|
2296
2321
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "settle_signature_missing" });
|
|
2297
2322
|
return;
|
|
2298
2323
|
}
|
|
@@ -2432,8 +2457,7 @@ async function startProxy(options) {
|
|
|
2432
2457
|
);
|
|
2433
2458
|
if (!walletSignature) {
|
|
2434
2459
|
logProxyEvent("warn", "proxy_upload_confirm_wallet_signature_missing");
|
|
2435
|
-
res
|
|
2436
|
-
res.end(createWalletRequiredBody());
|
|
2460
|
+
sendWalletRequired(res);
|
|
2437
2461
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "wallet_signature_missing" });
|
|
2438
2462
|
return;
|
|
2439
2463
|
}
|
|
@@ -2527,8 +2551,7 @@ async function startProxy(options) {
|
|
|
2527
2551
|
);
|
|
2528
2552
|
if (!walletSignature) {
|
|
2529
2553
|
logProxyEvent("warn", "proxy_ls_wallet_signature_missing");
|
|
2530
|
-
res
|
|
2531
|
-
res.end(createWalletRequiredBody());
|
|
2554
|
+
sendWalletRequired(res);
|
|
2532
2555
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "wallet_signature_missing" });
|
|
2533
2556
|
return;
|
|
2534
2557
|
}
|
|
@@ -2622,8 +2645,7 @@ async function startProxy(options) {
|
|
|
2622
2645
|
);
|
|
2623
2646
|
if (!walletSignature) {
|
|
2624
2647
|
logProxyEvent("warn", "proxy_download_wallet_signature_missing");
|
|
2625
|
-
res
|
|
2626
|
-
res.end(createWalletRequiredBody());
|
|
2648
|
+
sendWalletRequired(res);
|
|
2627
2649
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "wallet_signature_missing" });
|
|
2628
2650
|
return;
|
|
2629
2651
|
}
|
|
@@ -2739,8 +2761,7 @@ async function startProxy(options) {
|
|
|
2739
2761
|
);
|
|
2740
2762
|
if (!walletSignature) {
|
|
2741
2763
|
logProxyEvent("warn", "proxy_delete_wallet_signature_missing");
|
|
2742
|
-
res
|
|
2743
|
-
res.end(createWalletRequiredBody());
|
|
2764
|
+
sendWalletRequired(res);
|
|
2744
2765
|
emitProxyTerminalFromStatus(correlation, 400, { reason: "wallet_signature_missing" });
|
|
2745
2766
|
return;
|
|
2746
2767
|
}
|
|
@@ -2810,10 +2831,14 @@ async function startProxy(options) {
|
|
|
2810
2831
|
sendJson(res, 200, response);
|
|
2811
2832
|
return;
|
|
2812
2833
|
}
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2834
|
+
if (MNEMOSPARK_PROXY_VERBOSE_404) {
|
|
2835
|
+
sendJson(res, 404, {
|
|
2836
|
+
error: "Not found",
|
|
2837
|
+
message: "Supported paths: /health and /mnemospark/* storage endpoints"
|
|
2838
|
+
});
|
|
2839
|
+
} else {
|
|
2840
|
+
sendJson(res, 404, { error: "Not found" });
|
|
2841
|
+
}
|
|
2817
2842
|
});
|
|
2818
2843
|
const tryListen = (attempt) => {
|
|
2819
2844
|
return new Promise((resolveAttempt, rejectAttempt) => {
|