mnemospark 1.1.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/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, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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.writeHead(400, { "Content-Type": "application/json" });
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
- sendJson(res, 404, {
2814
- error: "Not found",
2815
- message: "Supported paths: /health and /mnemospark/* storage endpoints"
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) => {
@@ -3014,6 +3039,15 @@ var USER_AGENT = `mnemospark/${VERSION}`;
3014
3039
  import { existsSync, readFileSync } from "fs";
3015
3040
  import { privateKeyToAccount as privateKeyToAccount6 } from "viem/accounts";
3016
3041
 
3042
+ // src/cloud-help-onboarding.ts
3043
+ var CLOUD_ONBOARDING_BLOCK_LINES = [
3044
+ "",
3045
+ "Start here to securely upload a file and we'll guide you along the way. Copy the line below and replace <file|directory> with the file or directory you'd like to save to the cloud and replace <friendly-name> with an easy to remember name.",
3046
+ "",
3047
+ "`/mnemospark cloud backup <file|directory> name:<friendly-name> async:true`",
3048
+ ""
3049
+ ];
3050
+
3017
3051
  // src/cloud-command.ts
3018
3052
  import { spawn } from "child_process";
3019
3053
  import {
@@ -4261,7 +4295,7 @@ function expandTilde(path) {
4261
4295
  }
4262
4296
  var CLOUD_HELP_TEXT = [
4263
4297
  "\u2601\uFE0F **mnemospark - Wallet and go.** \u{1F499}",
4264
- "",
4298
+ ...CLOUD_ONBOARDING_BLOCK_LINES,
4265
4299
  "**Syntax:** use `/mnemospark cloud \u2026`. Prefer `key:value` for arguments; `key=value` and `--key value` are also accepted. Optional verbose markers: `cloud:true`, `price-storage:true`, etc. Aliases: `wallet:` \u2192 wallet-address, `object:` \u2192 object-id, `quote:` \u2192 quote-id, `hash:` \u2192 object-id-hash.",
4266
4300
  "",
4267
4301
  "**Cloud Commands**",
@@ -7359,17 +7393,21 @@ operation-id: ${operationId}`,
7359
7393
  // src/mnemospark-handler.ts
7360
7394
  var MNEMOSPARK_ROOT_HELP_TEXT = [
7361
7395
  "\u2601\uFE0F **mnemospark - Wallet and go.** \u{1F499}",
7396
+ ...CLOUD_ONBOARDING_BLOCK_LINES,
7397
+ "To view the full help menu use these commands:",
7362
7398
  "",
7363
- "**Syntax:** `/mnemospark cloud \u2026` or `/mnemospark wallet \u2026`",
7364
- "Arguments may use `key:value`, `key=value`, or `--key value`. Optional verbose markers: `cloud:true`, `price-storage:true`, etc. (same as bare words).",
7365
- "Aliases include `wallet:` \u2192 wallet-address, `object:` \u2192 object-id, `quote:` \u2192 quote-id (see `/mnemospark cloud help`).",
7366
- "",
7367
- "**Cloud storage** \u2014 full reference:",
7399
+ "**Cloud storage**",
7368
7400
  "\u2022 `/mnemospark cloud help`",
7369
7401
  "",
7370
- "**Wallet** \u2014 status:",
7402
+ "**Wallet status and funding link:**",
7371
7403
  "\u2022 `/mnemospark wallet`",
7372
- "\u2022 `/mnemospark wallet help` \u2014 commands and funding link"
7404
+ "\u2022 `/mnemospark wallet help`",
7405
+ "",
7406
+ "**Let your agent run mnemospark for you:**",
7407
+ "",
7408
+ "mnemospark installs as an OpenClaw extension under `~/.openclaw/extensions/mnemospark/`. Point your agent at the bundled skill:",
7409
+ "",
7410
+ "Install the mnemospark skill available at `~/.openclaw/extensions/mnemospark/skills/mnemospark/SKILL.md`"
7373
7411
  ].join("\n");
7374
7412
  var MNEMOSPARK_WALLET_HELP_TEXT = (address) => [
7375
7413
  "\u2601\uFE0F **mnemospark Wallet**",