@ghostlytools/cli 1.9.0 → 1.10.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.
Files changed (118) hide show
  1. package/README.md +35 -27
  2. package/SKILL.md +7 -3
  3. package/dist/assets/api-BOWLZYXM.js +3 -0
  4. package/dist/assets/{api-DFCgr6RH.js → api-Bi6hCcwG.js} +100 -47
  5. package/dist/assets/api-Bi6hCcwG.js.map +1 -0
  6. package/dist/assets/{apiKit-CCavJJcl.js → apiKit-DzXHZojD.js} +26 -9
  7. package/dist/assets/apiKit-DzXHZojD.js.map +1 -0
  8. package/dist/assets/{apps-B7o2BPj6.js → apps-0Ks6KjqS.js} +1 -1
  9. package/dist/assets/{apps-DmxEG147.js → apps-DIQbzG08.js} +33 -10
  10. package/dist/assets/apps-DIQbzG08.js.map +1 -0
  11. package/dist/assets/{arkade-DtYR9H0c.js → arkade-zozCldAE.js} +2 -2
  12. package/dist/assets/{arkade-DtYR9H0c.js.map → arkade-zozCldAE.js.map} +1 -1
  13. package/dist/assets/{backup-YIB2XIES.js → backup-BL49Kt-T.js} +7 -6
  14. package/dist/assets/{backup-YIB2XIES.js.map → backup-BL49Kt-T.js.map} +1 -1
  15. package/dist/assets/{backup-BserdrNk.js → backup-BvIFcZM7.js} +1 -1
  16. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  17. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  18. package/dist/assets/{blobFiles-DOQDRdDI.js → blobFiles-BnjN_Vrz.js} +3 -3
  19. package/dist/assets/{blobFiles-DOQDRdDI.js.map → blobFiles-BnjN_Vrz.js.map} +1 -1
  20. package/dist/assets/buttons-CAW5v5EE.js +332 -0
  21. package/dist/assets/buttons-CAW5v5EE.js.map +1 -0
  22. package/dist/assets/buttons-oJI5mHSL.js +2 -0
  23. package/dist/assets/childEnv-BVOQK9EA.js +21 -0
  24. package/dist/assets/childEnv-BVOQK9EA.js.map +1 -0
  25. package/dist/assets/client-CyApKBEw.js +473 -0
  26. package/dist/assets/client-CyApKBEw.js.map +1 -0
  27. package/dist/assets/codec-DqFxxB_q.js +13 -0
  28. package/dist/assets/codec-DqFxxB_q.js.map +1 -0
  29. package/dist/assets/{endpoint-BdaeBw2L.js → endpoint-DWHkXWVM.js} +101 -16
  30. package/dist/assets/endpoint-DWHkXWVM.js.map +1 -0
  31. package/dist/assets/{envelope-Dt75vrmY.js → envelope-CMUgz31I.js} +3 -12
  32. package/dist/assets/envelope-CMUgz31I.js.map +1 -0
  33. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
  34. package/dist/assets/{fileBytes-BPDKufla.js → fileBytes-DMzrIdCu.js} +1 -1
  35. package/dist/assets/{fileBytes-DNgrRL0R.js → fileBytes-DjBYYyXT.js} +3 -3
  36. package/dist/assets/{fileBytes-DNgrRL0R.js.map → fileBytes-DjBYYyXT.js.map} +1 -1
  37. package/dist/assets/{fileBytes-Q3ehcEr8.js → fileBytes-Douk1yOp.js} +2 -2
  38. package/dist/assets/{fileBytes-Q3ehcEr8.js.map → fileBytes-Douk1yOp.js.map} +1 -1
  39. package/dist/assets/fileBytesIdb-CD5Uv490.js +2 -0
  40. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js → fileBytesIdb-CkClu9YI.js} +3 -3
  41. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js.map → fileBytesIdb-CkClu9YI.js.map} +1 -1
  42. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js → fileBytesOpfs-WryQuOgK.js} +3 -3
  43. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js.map → fileBytesOpfs-WryQuOgK.js.map} +1 -1
  44. package/dist/assets/{fixedHosts-B598JzbC.js → fixedHosts-C2hdCfzK.js} +4 -4
  45. package/dist/assets/{fixedHosts-B598JzbC.js.map → fixedHosts-C2hdCfzK.js.map} +1 -1
  46. package/dist/assets/{groupFiles-FXel6zIc.js → groupFiles-BAQIt_bJ.js} +404 -161
  47. package/dist/assets/groupFiles-BAQIt_bJ.js.map +1 -0
  48. package/dist/assets/{host-DIBeK_c_.js → host-CaRlDMTd.js} +206 -49
  49. package/dist/assets/host-CaRlDMTd.js.map +1 -0
  50. package/dist/assets/{hyperdhtRelay-D185dETu.js → hyperdhtRelay-BxADl3SG.js} +2 -2
  51. package/dist/assets/{hyperdhtRelay-D185dETu.js.map → hyperdhtRelay-BxADl3SG.js.map} +1 -1
  52. package/dist/assets/{idb-BkOJES5_.js → idb-BHsAqENE.js} +37 -6
  53. package/dist/assets/idb-BHsAqENE.js.map +1 -0
  54. package/dist/assets/{irohWeb-BSv_BWyG.js → irohWeb-D2sh6EWp.js} +65 -7
  55. package/dist/assets/irohWeb-D2sh6EWp.js.map +1 -0
  56. package/dist/assets/{main-BbhfMTt8.js → main-Bc4Ow56Z.js} +221 -287
  57. package/dist/assets/main-Bc4Ow56Z.js.map +1 -0
  58. package/dist/assets/{mainline-9Vc3c3SA.js → mainline-DWh4Ccri.js} +2 -2
  59. package/dist/assets/{mainline-9Vc3c3SA.js.map → mainline-DWh4Ccri.js.map} +1 -1
  60. package/dist/assets/networkReason-DT_D_Wpc.js +474 -0
  61. package/dist/assets/networkReason-DT_D_Wpc.js.map +1 -0
  62. package/dist/assets/{nwc-QX3Yt1Sb.js → nwc-DoSEhUKb.js} +3 -3
  63. package/dist/assets/{nwc-QX3Yt1Sb.js.map → nwc-DoSEhUKb.js.map} +1 -1
  64. package/dist/assets/{nwcProvider-CzX3xH47.js → nwcProvider-CGWqUjpB.js} +2 -2
  65. package/dist/assets/{nwcProvider-CzX3xH47.js.map → nwcProvider-CGWqUjpB.js.map} +1 -1
  66. package/dist/assets/{ownDid-D8z5gwGI.js → ownDid-CbGjRLBn.js} +3 -3
  67. package/dist/assets/ownDid-CbGjRLBn.js.map +1 -0
  68. package/dist/assets/{profiles-MFtCmJwK.js → profiles-DgIfvBeN.js} +47 -4
  69. package/dist/assets/profiles-DgIfvBeN.js.map +1 -0
  70. package/dist/assets/{registry-B2Dtnibo.js → registry-BSyxGjN6.js} +11 -9
  71. package/dist/assets/registry-BSyxGjN6.js.map +1 -0
  72. package/dist/assets/{registry-PTtBMaYZ.js → registry-C5cn80Rw.js} +1 -1
  73. package/dist/assets/{resolve-ZxVzwFNA.js → resolve-D-9YRFhl.js} +2 -2
  74. package/dist/assets/{resolve-ZxVzwFNA.js.map → resolve-D-9YRFhl.js.map} +1 -1
  75. package/dist/assets/{restoredRows-BCRCjhdF.js → restoredRows-CRYwIx3g.js} +2 -2
  76. package/dist/assets/{restoredRows-BCRCjhdF.js.map → restoredRows-CRYwIx3g.js.map} +1 -1
  77. package/dist/assets/{buttons-CuRfKnPI.js → secretGuard-CSVNxXVW.js} +80 -330
  78. package/dist/assets/secretGuard-CSVNxXVW.js.map +1 -0
  79. package/dist/assets/secretGuard-Q2BKq0q0.js +2 -0
  80. package/dist/assets/{server-Dw1o8z1o.js → server-BufntkX8.js} +1734 -369
  81. package/dist/assets/server-BufntkX8.js.map +1 -0
  82. package/dist/assets/{src-BD8RBVEp.js → src-CCt5s4DK.js} +3073 -1890
  83. package/dist/assets/src-CCt5s4DK.js.map +1 -0
  84. package/dist/assets/{sshForges-DWrESWkK.js → sshForges-D8CPaIbR.js} +16 -9
  85. package/dist/assets/{sshForges-DWrESWkK.js.map → sshForges-D8CPaIbR.js.map} +1 -1
  86. package/dist/assets/{translate-D1uP0q32.js → translate-Cb-6hMhD.js} +17 -12
  87. package/dist/assets/translate-Cb-6hMhD.js.map +1 -0
  88. package/dist/assets/{usdt-DhVN8geQ.js → usdt-ds461mzA.js} +3 -3
  89. package/dist/assets/{usdt-DhVN8geQ.js.map → usdt-ds461mzA.js.map} +1 -1
  90. package/dist/assets/{words-DdXPkB3n.js → words-B1ylON2h.js} +4 -2
  91. package/dist/assets/words-B1ylON2h.js.map +1 -0
  92. package/dist/ghostly.mjs +1 -1
  93. package/package.json +1 -1
  94. package/dist/assets/api-DFCgr6RH.js.map +0 -1
  95. package/dist/assets/api-raWw9j_m.js +0 -3
  96. package/dist/assets/apiKit-CCavJJcl.js.map +0 -1
  97. package/dist/assets/apps-DmxEG147.js.map +0 -1
  98. package/dist/assets/buttons-CuRfKnPI.js.map +0 -1
  99. package/dist/assets/buttons-De3LPdSG.js +0 -2
  100. package/dist/assets/daemonProof-DtrL5lE5.js +0 -236
  101. package/dist/assets/daemonProof-DtrL5lE5.js.map +0 -1
  102. package/dist/assets/endpoint-BdaeBw2L.js.map +0 -1
  103. package/dist/assets/envelope-Dt75vrmY.js.map +0 -1
  104. package/dist/assets/fileBytesIdb-DZcESfTt.js +0 -2
  105. package/dist/assets/groupFiles-FXel6zIc.js.map +0 -1
  106. package/dist/assets/host-DIBeK_c_.js.map +0 -1
  107. package/dist/assets/idb-BkOJES5_.js.map +0 -1
  108. package/dist/assets/irohWeb-BSv_BWyG.js.map +0 -1
  109. package/dist/assets/main-BbhfMTt8.js.map +0 -1
  110. package/dist/assets/networkReason-BncJ9KSM.js +0 -154
  111. package/dist/assets/networkReason-BncJ9KSM.js.map +0 -1
  112. package/dist/assets/ownDid-D8z5gwGI.js.map +0 -1
  113. package/dist/assets/profiles-MFtCmJwK.js.map +0 -1
  114. package/dist/assets/registry-B2Dtnibo.js.map +0 -1
  115. package/dist/assets/server-Dw1o8z1o.js.map +0 -1
  116. package/dist/assets/src-BD8RBVEp.js.map +0 -1
  117. package/dist/assets/translate-D1uP0q32.js.map +0 -1
  118. package/dist/assets/words-DdXPkB3n.js.map +0 -1
@@ -1,15 +1,17 @@
1
- import { $a as replySnippet, $i as identityStatement, Al as inviteLink, Bn as stripPictureMetadata, Ca as downsamplePeaks, Da as voiceLevel, Ea as voiceDownloadName, Gr as sanitizeTypingStatus, Hr as TYPING_KINDS, In as withoutVideoMetadata, Jo as parseLocalTarget, Kc as APP_PERMISSIONS, Ko as GhostlyHttpError, Ln as NO_PICTURE_METADATA, Lu as randomBytes$1, Ml as ownInviteRefusal, Mu as sanitizeAvatar, Qn as GROUP_FILE_LIMITS, Ru as toBase64Url, Sa as baseMime, Ta as parseVoiceMeta, Ur as TYPING_REFRESH_MS, Vn as withoutPictureMetadata, X as groupName, Xo as LIMITS, Zc as isAppUrl, _a as sanitizeFileName, _o as statusCardBytes, al as appRef, ba as VOICE_LIMITS, bo as claimedTime, co as STATUS_CARD_LIMITS, di as APP_DATA_MAX_BYTES, do as appCardUrl, gl as readImageMeta, ho as checkStatusCard, ju as MAX_AVATAR_LENGTH, ll as isAppRef, po as cardLine, uo as appCardId, va as sanitizeMime, xa as VOICE_METER, ya as PLAYABLE_AUDIO, zo as AWAITING_PEER_MS } from "./src-BD8RBVEp.js";
2
- import { u as fileStore } from "./idb-BkOJES5_.js";
3
- import { O as waitingGroupFile, T as removeStored, X as iceServerProblem, Z as iceServerSetting, i as groupOfFile, k as IDENTITY_DRAFT_TTL_MS, l as replyRef, n as groupFileId, v as paymentNetwork } from "./groupFiles-FXel6zIc.js";
4
- import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-DNgrRL0R.js";
5
- import { t as IDENTITY_PROVIDERS } from "./registry-B2Dtnibo.js";
6
- import { a as waitForConfirmed, c as waitForMessage, i as pressable, l as waitForRemoval, n as buttonsCard, o as waitForEdit, s as waitForGroupFrame, t as BUTTON_METHODS, u as findSecret } from "./buttons-CuRfKnPI.js";
7
- import { a as WALLET_TYPES, c as DESTRUCTIVE_CALLS, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, m as engineParamsProblem, n as CHAT_METHODS, r as PAY_METHODS, s as withStoredIds, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-DdXPkB3n.js";
1
+ import { $o as parseLocalTarget, Aa as voiceDownloadName, Ca as PLAYABLE_AUDIO, Da as downsamplePeaks, Dl as readImageMeta, Ea as baseMime, Gr as TYPING_REFRESH_MS, Hn as stripPictureMetadata, Hu as MAX_AVATAR_LENGTH, Ju as randomBytes$1, Ni as identityStatement, Rn as withoutVideoMetadata, Sa as sanitizeMime, Ta as VOICE_METER, Ul as ownInviteRefusal, Un as withoutPictureMetadata, Uo as AWAITING_PEER_MS, Uu as sanitizeAvatar, Vl as inviteLink, Wr as TYPING_KINDS, Yu as toBase64Url, Z as groupName, Zo as GhostlyHttpError, _o as cardLine, er as GROUP_FILE_LIMITS, fo as STATUS_CARD_LIMITS, ho as appCardUrl, ja as voiceLevel, ka as parseVoiceMeta, ml as appRef, mo as appCardId, ol as isAppUrl, pi as APP_DATA_MAX_BYTES, qr as sanitizeTypingStatus, ro as replySnippet, tl as APP_PERMISSIONS, ts as LIMITS, wa as VOICE_LIMITS, wo as claimedTime, xa as sanitizeFileName, xo as statusCardBytes, yl as isAppRef, yo as checkStatusCard, zn as NO_PICTURE_METADATA } from "./src-CCt5s4DK.js";
2
+ import { u as fileStore } from "./idb-BHsAqENE.js";
3
+ import { J as iceServerProblem, O as waitingGroupFile, T as removeStored, Y as iceServerSetting, i as groupOfFile, k as IDENTITY_DRAFT_TTL_MS, l as replyRef, n as groupFileId, v as paymentNetwork } from "./groupFiles-BAQIt_bJ.js";
4
+ import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-DjBYYyXT.js";
5
+ import { t as IDENTITY_PROVIDERS } from "./registry-BSyxGjN6.js";
6
+ import { n as secretWords, r as findSecret, t as guardText } from "./secretGuard-CSVNxXVW.js";
8
7
  import { i as localFileError, r as asCliError, t as CliError } from "./errors-R4S2SAEM.js";
9
- import { S as waitForState, _ as oneOf, a as dhtOnly, b as str, c as findGroup, d as inviteTaken, f as list, g as num, h as node, i as chatOrGroup, l as findOwnNamedChat, n as bool, o as findChat, p as messageOf, r as chatOf, s as findChatOrGroup, u as groupOf, v as sentAt, x as transportOffered, y as state } from "./apiKit-CCavJJcl.js";
10
- import { a as checkShownName } from "./profiles-MFtCmJwK.js";
11
- import { t as BACKUP_METHODS } from "./backup-YIB2XIES.js";
12
- import { o as checkedBundle } from "./apps-DmxEG147.js";
8
+ import { a as WALLET_TYPES, c as DESTRUCTIVE_CALLS, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, m as engineParamsProblem, n as CHAT_METHODS, r as PAY_METHODS, s as withStoredIds, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-B1ylON2h.js";
9
+ import { C as waitForState, S as transportOffered, _ as oneOf, a as dhtOnly, b as state, c as findGroup, d as inviteTaken, f as list, g as num, h as node, i as chatOrGroup, l as findOwnNamedChat, n as bool, o as findChat, p as messageOf, r as chatOf, s as findChatOrGroup, u as groupOf, v as sentAt, x as str } from "./apiKit-DzXHZojD.js";
10
+ import { t as childEnv } from "./childEnv-BVOQK9EA.js";
11
+ import { a as checkShownName } from "./profiles-DgIfvBeN.js";
12
+ import { a as waitForConfirmed, c as waitForMessage, i as pressable, l as waitForRemoval, n as buttonsCard, o as waitForEdit, s as waitForGroupFrame, t as BUTTON_METHODS } from "./buttons-CAW5v5EE.js";
13
+ import { t as BACKUP_METHODS } from "./backup-BL49Kt-T.js";
14
+ import { o as checkedBundle } from "./apps-DIQbzG08.js";
13
15
  import { generateMnemonic } from "@scure/bip39";
14
16
  import { wordlist } from "@scure/bip39/wordlists/english.js";
15
17
  import { execFile, spawn } from "node:child_process";
@@ -598,11 +600,14 @@ function streamFfmpeg(path, sink, command = process.env.GHOSTLY_FFMPEG || "ffmpe
598
600
  "-c:a",
599
601
  "pcm_f32le",
600
602
  "-"
601
- ], { stdio: [
602
- "ignore",
603
- "pipe",
604
- "pipe"
605
- ] });
603
+ ], {
604
+ stdio: [
605
+ "ignore",
606
+ "pipe",
607
+ "pipe"
608
+ ],
609
+ env: childEnv()
610
+ });
606
611
  let errors = "", pending = Buffer.alloc(0), header = null, done = false, failed = null;
607
612
  let read, left = Infinity, timedOut = false;
608
613
  const timer = setTimeout(() => {
@@ -981,7 +986,10 @@ async function markDownloaded(path) {
981
986
  "com.apple.quarantine",
982
987
  value,
983
988
  path
984
- ], { timeout: 1e4 }, () => done()));
989
+ ], {
990
+ timeout: 1e4,
991
+ env: childEnv()
992
+ }, () => done()));
985
993
  } else if (process.platform === "win32") await writeFile(`${path}:Zone.Identifier`, "[ZoneTransfer]\r\nZoneId=3\r\n").catch(() => {});
986
994
  }
987
995
  var ACTIONS = [
@@ -995,6 +1003,7 @@ var ACTIONS = [
995
1003
  ];
996
1004
  var FILE_METHODS = {
997
1005
  async "file.send"(ctx, params) {
1006
+ guardText(str(params, "name"), bool(params, "force"), "file's name", "send it");
998
1007
  const target = chatOrGroupOf(ctx, params);
999
1008
  const path = resolve(str(params, "path", true));
1000
1009
  let info;
@@ -1423,7 +1432,7 @@ function guardSecrets(fields, params, verb) {
1423
1432
  if (bool(params, "force")) return;
1424
1433
  const check = (text) => {
1425
1434
  const secret = findSecret(text);
1426
- if (secret) throw new CliError("confirm", `The card's text looks like ${secret.kind === "cashu" ? "a Cashu token (money anyone who reads it can take)" : "a secret (a seed or a private key)"}; ${verb} it with --force if you mean to`, { kind: secret.kind });
1435
+ if (secret) throw new CliError("confirm", `The card's text looks like ${secretWords(secret)}; ${verb} it with --force if you mean to`, { kind: secret.kind });
1427
1436
  };
1428
1437
  for (const text of cardTexts([fields, params.run])) {
1429
1438
  check(text);
@@ -2124,7 +2133,7 @@ var view = (ctx, id, params) => groupJson(state(ctx).groups.find((g) => g.id ===
2124
2133
  var GROUP_ADMIN_METHODS = {
2125
2134
  async "group.invite"(ctx, params) {
2126
2135
  const group = groupOf(ctx, params);
2127
- const link = chatOf(ctx, params);
2136
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
2128
2137
  await node(ctx).inviteToGroup({
2129
2138
  groupId: group.id,
2130
2139
  linkId: link.id
@@ -2166,6 +2175,7 @@ var GROUP_ADMIN_METHODS = {
2166
2175
  const group = groupOf(ctx, params, "chat rename <chat> <name...>");
2167
2176
  const name = groupName(str(params, "name", true));
2168
2177
  if (!name) throw new CliError("bad_request", `A group's name is 1 to 64 characters on one line`);
2178
+ guardText(name, bool(params, "force"), "group's name", "rename it");
2169
2179
  await node(ctx).renameGroup({
2170
2180
  groupId: group.id,
2171
2181
  name
@@ -2445,7 +2455,7 @@ var IDENTITY_METHODS = {
2445
2455
  return { removed: id };
2446
2456
  },
2447
2457
  async "identity.share"(ctx, params) {
2448
- const link = chatOf(ctx, params);
2458
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
2449
2459
  const id = str(params, "id", true);
2450
2460
  if (!state(ctx).identityProofs.some((p) => p.id === id)) throw new CliError("not_found", `No identity proof ${JSON.stringify(id)} (ghostly identity list)`);
2451
2461
  await node(ctx).shareIdentityProof({
@@ -2458,7 +2468,7 @@ var IDENTITY_METHODS = {
2458
2468
  };
2459
2469
  },
2460
2470
  async "identity.withdraw"(ctx, params) {
2461
- const link = chatOf(ctx, params);
2471
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
2462
2472
  const id = str(params, "id", true);
2463
2473
  if (!link.identities?.shared.some((s) => s.id === id)) throw new CliError("not_found", `No identity proof ${JSON.stringify(id)} shared in this chat (ghostly identity contact ${link.id})`);
2464
2474
  await node(ctx).withdrawIdentityProof({
@@ -2643,14 +2653,34 @@ function sameSecret(a, b) {
2643
2653
  }
2644
2654
  /**
2645
2655
  * Added to every answer of a contact's app, next to any policy the contact sends (a browser enforces both): its
2646
- * scripts, forms, pictures, frames, fonts, media, styles and workers reach its own origin and public https sites
2647
- * (and inline, data: and blob: content), never plain http. The page is served from `<random>.localhost`, which Chrome
2648
- * counts as this machine, so its own guard for requests to local addresses (Local Network Access) would not ask
2649
- * before the page reached another service on 127.0.0.1 or the local network. Inline scripts and styles stay allowed:
2650
- * this policy bounds where the page reaches, not how the app is written. A top-level navigation is not covered: no
2651
- * browser lets a policy bound it.
2656
+ * requests (fetch, XHR, beacons, WebSockets, EventSource) and forms reach only its own origin, the contact's server;
2657
+ * its scripts, pictures, frames, fonts, media, styles and workers its own origin and https sites (and inline, data:
2658
+ * and blob: content), never plain http. The page is served from `<random>.localhost`, which Chrome counts as this
2659
+ * machine, so its own guard for requests to local addresses (Local Network Access) would not ask before the page
2660
+ * reached another service on 127.0.0.1 or the local network, and a policy cannot tell a public https site from one
2661
+ * here or on the local network with a trusted certificate: requests that can read an answer or post go nowhere else.
2662
+ * Inline scripts and styles stay allowed: this policy bounds where the page reaches, not how the app is written. A
2663
+ * top-level navigation is not covered: no browser lets a policy bound it.
2652
2664
  */
2653
- var OPENED_SERVICE_CSP = "default-src 'self' https: data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https: wss:; form-action 'self' https:";
2665
+ var OPENED_SERVICE_CSP = "default-src 'self' https: data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
2666
+ /**
2667
+ * The contact's headers that are not passed on: each makes the browser send something to a place it names, outside
2668
+ * `connect-src` (violation and network-error reports, and the endpoints they go to; `Link` preloads, prefetches and
2669
+ * early connections). Only the contact's server is reached.
2670
+ */
2671
+ var OPENED_SERVICE_DROPPED_HEADERS = [
2672
+ "content-security-policy-report-only",
2673
+ "reporting-endpoints",
2674
+ "report-to",
2675
+ "nel",
2676
+ "link"
2677
+ ];
2678
+ /** The directives of a contact's policy that send reports to a URL it names, dropped from it. */
2679
+ var OPENED_SERVICE_DROPPED_DIRECTIVES = ["report-uri", "report-to"];
2680
+ /** A contact's `Content-Security-Policy` value (one policy or several joined by commas) without its report directives. */
2681
+ function withoutReports(value) {
2682
+ return value.split(",").map((policy) => policy.split(";").filter((directive) => !OPENED_SERVICE_DROPPED_DIRECTIVES.includes(directive.trim().split(/\s+/)[0].toLowerCase())).join(";").trim()).filter((policy) => policy.replaceAll(";", "").trim()).join(", ");
2683
+ }
2654
2684
  function plain(response, status, text, headers = {}) {
2655
2685
  response.writeHead(status, {
2656
2686
  "content-type": "text/plain; charset=utf-8",
@@ -2735,14 +2765,16 @@ async function proxy(request, response, chunks, send, cookies) {
2735
2765
  const out = {};
2736
2766
  for (const [name, value] of answer.headers) {
2737
2767
  const lower = name.toLowerCase();
2738
- if (lower === "transfer-encoding" || lower === "connection") continue;
2768
+ if (lower === "transfer-encoding" || lower === "connection" || OPENED_SERVICE_DROPPED_HEADERS.includes(lower)) continue;
2739
2769
  if (lower === "set-cookie") {
2740
2770
  const cookie = hostOnlyCookie(value);
2741
2771
  if (!cookie) continue;
2742
2772
  if (cookies.size < MAX_COOKIE_NAMES) cookies.add(setCookieName(cookie));
2743
2773
  out[lower] = [...out[lower] ?? [], cookie];
2744
- } else if (lower === "content-security-policy") out[lower] = [...out[lower] ?? [], value];
2745
- else out[lower] = value;
2774
+ } else if (lower === "content-security-policy") {
2775
+ const policy = withoutReports(value);
2776
+ if (policy) out[lower] = [...out[lower] ?? [], policy];
2777
+ } else out[lower] = value;
2746
2778
  }
2747
2779
  out["content-security-policy"] = [...out["content-security-policy"] ?? [], OPENED_SERVICE_CSP];
2748
2780
  response.writeHead(answer.status, out);
@@ -3369,7 +3401,7 @@ function memoOf(params, verb, field = "memo") {
3369
3401
  const memo = str(params, field);
3370
3402
  if (memo && !bool(params, "force")) {
3371
3403
  const secret = findSecret(memo);
3372
- if (secret) throw new CliError("confirm", `The ${field} looks like ${secret.kind === "cashu" ? "a Cashu token (money anyone who reads it can take)" : "a secret (a seed or a private key)"}; ${verb} with --force if you mean to`, { kind: secret.kind });
3404
+ if (secret) throw new CliError("confirm", `The ${field} looks like ${secretWords(secret)}; ${verb} with --force if you mean to`, { kind: secret.kind });
3373
3405
  }
3374
3406
  return memo || void 0;
3375
3407
  }
@@ -3587,11 +3619,15 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3587
3619
  let invoice = text.replace(/^lightning:/i, "");
3588
3620
  let n;
3589
3621
  let note;
3622
+ if (params.chat !== void 0 && !isInvoice(text)) throw new CliError("usage", "--chat names the chat an invoice came from: an address's or LNURL's invoice is its server's");
3623
+ const chat = params.chat === void 0 ? void 0 : findOwnNamedChat(state(ctx).links, str(params, "chat", true));
3624
+ if (chat) inviteTaken(chat);
3590
3625
  if (isInvoice(text)) n = network(params);
3591
3626
  else if (isLnurl(text)) {
3592
3627
  n = network(params);
3593
3628
  const amount = num(params, "amount", 0, { min: 1 });
3594
3629
  if (!amount) throw new CliError("bad_request", "amount is required to pay a Lightning address or LNURL");
3630
+ if (n === "mainnet" && !bool(params, "confirmReal")) throw new CliError("confirm", "This pays real money (Mainnet): pass --confirm-real to confirm this payment");
3595
3631
  const view = await node(ctx).lnurlResolve({
3596
3632
  text,
3597
3633
  network: n
@@ -3619,7 +3655,11 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3619
3655
  quote: quote.quote,
3620
3656
  mint: quote.mint,
3621
3657
  ...note ? { note } : {},
3622
- ...real(params)
3658
+ ...real(params),
3659
+ ...chat ? {
3660
+ linkId: chat.id,
3661
+ invoice
3662
+ } : {}
3623
3663
  });
3624
3664
  return {
3625
3665
  network: n,
@@ -3632,7 +3672,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3632
3672
  /** Ecash to a contact in a chat (the payment sheet's Pay). */
3633
3673
  async "chat.pay"(ctx, params) {
3634
3674
  const memo = memoOf(params, "pay");
3635
- const link = chatOf(ctx, params);
3675
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
3636
3676
  inviteTaken(link);
3637
3677
  const amount = num(params, "amount", 0, { min: 1 });
3638
3678
  if (!amount) throw new CliError("bad_request", "amount is required");
@@ -3683,7 +3723,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3683
3723
  },
3684
3724
  /** Pays a request the contact made in a chat. */
3685
3725
  async "chat.payRequest"(ctx, params) {
3686
- const link = chatOf(ctx, params);
3726
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
3687
3727
  const paymentId = str(params, "payment", true);
3688
3728
  const request = state(ctx).payments[paymentId];
3689
3729
  if (!request || request.linkId !== link.id || request.kind !== "request") throw new CliError("not_found", `No request ${paymentId} in this chat`);
@@ -3979,6 +4019,7 @@ var METHODS = {
3979
4019
  async "profile.set"(ctx, params) {
3980
4020
  const patch = {};
3981
4021
  if (params.name !== void 0) patch.nick = checkShownName(params.name);
4022
+ guardText(patch.nick, bool(params, "force"), "name", "set it");
3982
4023
  if (params.shareProfile !== void 0) patch.shareProfile = bool(params, "shareProfile");
3983
4024
  await node(ctx).updateSettings({ settings: patch });
3984
4025
  return METHODS["profile.get"](ctx, {});
@@ -3990,6 +4031,7 @@ var METHODS = {
3990
4031
  const patch = {};
3991
4032
  let warning;
3992
4033
  for (const [key, value] of Object.entries(params)) {
4034
+ if (key === "force") continue;
3993
4035
  const kind = Object.hasOwn(SETTABLE, key) ? SETTABLE[key] : void 0;
3994
4036
  if (key === "readRelays") throw new CliError("bad_request", "readRelays is not a setting the CLI follows: it reads the Pkarr relays first, so a contact on the web app (relays only) is found, and the Mainline DHT when every relay fails");
3995
4037
  if (!kind) throw new CliError("bad_request", `${key} is not a setting the CLI changes (${Object.keys(SETTABLE).join(", ")})`);
@@ -3998,6 +4040,7 @@ var METHODS = {
3998
4040
  if (kind === "boolean" && typeof value !== "boolean") throw new CliError("bad_request", `${key} must be true or false`);
3999
4041
  if (key === "nick") {
4000
4042
  patch.nick = checkShownName(value, key);
4043
+ guardText(patch.nick, bool(params, "force"), "nick", "set it");
4001
4044
  continue;
4002
4045
  }
4003
4046
  if (kind === "ice") {
@@ -4094,7 +4137,7 @@ var METHODS = {
4094
4137
  checkTextSize(text);
4095
4138
  if (!bool(params, "force")) {
4096
4139
  const secret = findSecret(text);
4097
- if (secret) throw new CliError("confirm", `The text looks like ${secret.kind === "cashu" ? "a Cashu token (money anyone who reads it can take)" : "a secret (a seed or a private key)"}; send it with --force if you mean to`, { kind: secret.kind });
4140
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; send it with --force if you mean to`, { kind: secret.kind });
4098
4141
  }
4099
4142
  const wait = oneOf(params, "wait", [
4100
4143
  "none",
@@ -4139,7 +4182,7 @@ var METHODS = {
4139
4182
  const text = str(params, "text", true);
4140
4183
  if (!bool(params, "force")) {
4141
4184
  const secret = findSecret(text);
4142
- if (secret) throw new CliError("confirm", `The text looks like ${secret.kind === "cashu" ? "a Cashu token (money anyone who reads it can take)" : "a secret (a seed or a private key)"}; edit with --force if you mean to`, { kind: secret.kind });
4185
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; edit with --force if you mean to`, { kind: secret.kind });
4143
4186
  }
4144
4187
  const wait = oneOf(params, "wait", ["none", "confirmed"], "none");
4145
4188
  const ms = num(params, "timeout", 30, {
@@ -4257,13 +4300,13 @@ var METHODS = {
4257
4300
  async "saved.remove"(ctx, params) {
4258
4301
  return saveMark(ctx, params, true);
4259
4302
  },
4260
- /** The saved messages, the last saved first, each as it is now and named by its chat or group. */
4303
+ /** The saved messages under `saved`, the last saved first, each as it is now and named by its chat or group. */
4261
4304
  async "saved.list"(ctx) {
4262
4305
  const { links, groups } = state(ctx);
4263
4306
  const saved = await node(ctx).savedMessages();
4264
4307
  const originals = /* @__PURE__ */ new Map();
4265
4308
  for (const linkId of new Set(saved.map((s) => s.message.linkId))) originals.set(linkId, await originalsNow(ctx, linkId, saved.flatMap((s) => s.message.linkId === linkId ? [s.message] : [])));
4266
- return saved.map(({ savedAt, message }) => {
4309
+ return { saved: saved.map(({ savedAt, message }) => {
4267
4310
  const checked = (json) => quoteChecked(json, message, originals.get(message.linkId));
4268
4311
  if (!message.linkId.startsWith("group:")) return {
4269
4312
  chat: message.linkId,
@@ -4276,7 +4319,7 @@ var METHODS = {
4276
4319
  savedAt,
4277
4320
  message: checked(groupMessageJson(message, groups.find((g) => g.id === id)))
4278
4321
  };
4279
- });
4322
+ }) };
4280
4323
  },
4281
4324
  /**
4282
4325
  * WISP 400 § Forwards: messages of a chat or a group sent on to up to 5 chats and groups, each as a new message of mine
@@ -4298,7 +4341,7 @@ var METHODS = {
4298
4341
  }
4299
4342
  if (!bool(params, "force")) for (const message of chosen) {
4300
4343
  const secret = message.file ? null : findSecret(message.text);
4301
- if (secret) throw new CliError("confirm", `A message looks like ${secret.kind === "cashu" ? "a Cashu token (money anyone who reads it can take)" : "a secret (a seed or a private key)"}; forward it with --force if you mean to`, {
4344
+ if (secret) throw new CliError("confirm", `A message looks like ${secretWords(secret)}; forward it with --force if you mean to`, {
4302
4345
  kind: secret.kind,
4303
4346
  messageId: message.id
4304
4347
  });
@@ -4520,6 +4563,7 @@ var METHODS = {
4520
4563
  async "group.create"(ctx, params) {
4521
4564
  const name = groupName(str(params, "name", true));
4522
4565
  if (!name) throw new CliError("bad_request", `A group's name is 1 to 64 characters on one line`);
4566
+ guardText(name, bool(params, "force"), "group's name", "create it");
4523
4567
  const profile = oneOf(params, "profile", ["community", "mesh"], "community");
4524
4568
  const { groupId } = await node(ctx).createGroup({
4525
4569
  name,
@@ -4605,7 +4649,7 @@ var METHODS = {
4605
4649
  const text = str(params, "text", true);
4606
4650
  if (!bool(params, "force")) {
4607
4651
  const secret = findSecret(text);
4608
- if (secret) throw new CliError("confirm", `The text looks like ${secret.kind === "cashu" ? "a Cashu token (money anyone who reads it can take)" : "a secret (a seed or a private key)"}; edit with --force if you mean to`, { kind: secret.kind });
4652
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; edit with --force if you mean to`, { kind: secret.kind });
4609
4653
  }
4610
4654
  const mentions = mentionsFor(text, list(params, "mentions"), group);
4611
4655
  const wait = oneOf(params, "wait", ["none", "sent"], "none");
@@ -4791,7 +4835,8 @@ async function clearProfile(ctx) {
4791
4835
  };
4792
4836
  }
4793
4837
  /**
4794
- * The engine's calls that send a text this side writes (a message, a file's caption, a payment's memo): `engine.call`
4838
+ * The engine's calls that send a text this side writes (a message, a file's caption, a payment's memo, a name others
4839
+ * read): `engine.call`
4795
4840
  * runs the secret guard of `send`, `edit` and `forward` on them too (docs/CLI.md § Safety), so a raw call is no way around it. `force: true` (`--force`) sends it.
4796
4841
  */
4797
4842
  var ENGINE_SENDS = /* @__PURE__ */ new Set([
@@ -4806,15 +4851,23 @@ var ENGINE_SENDS = /* @__PURE__ */ new Set([
4806
4851
  "askToPay",
4807
4852
  "preparePayment",
4808
4853
  "fedimintInvoice",
4809
- "lnurlInvoice"
4854
+ "lnurlInvoice",
4855
+ "createGroup",
4856
+ "renameGroup",
4857
+ "updateSettings",
4858
+ "sendFile"
4810
4859
  ]);
4811
4860
  async function guardEngineSend(ctx, method, args) {
4861
+ const of = (value, key) => value && typeof value === "object" ? value[key] : void 0;
4812
4862
  let texts = [
4813
4863
  args.text,
4814
4864
  args.card,
4815
4865
  args.caption,
4816
4866
  args.memo,
4817
- args.comment
4867
+ args.comment,
4868
+ args.name,
4869
+ of(args.settings, "nick"),
4870
+ of(args.file, "name")
4818
4871
  ];
4819
4872
  if (method === "forwardMessages") {
4820
4873
  const ids = Array.isArray(args.messageIds) ? args.messageIds.filter((id) => typeof id === "string") : [];
@@ -4825,7 +4878,7 @@ async function guardEngineSend(ctx, method, args) {
4825
4878
  })) : [];
4826
4879
  }
4827
4880
  const secret = secretIn(texts);
4828
- if (secret) throw new CliError("confirm", `The text looks like ${secret.kind === "cashu" ? "a Cashu token (money anyone who reads it can take)" : "a secret (a seed or a private key)"}; call ${method} with --force if you mean to`, { kind: secret.kind });
4881
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; call ${method} with --force if you mean to`, { kind: secret.kind });
4829
4882
  }
4830
4883
  /**
4831
4884
  * How long `react` and `pin` in a 1:1 chat wait for the contact: a one-shot until it confirmed (as `edit`), since what
@@ -5046,4 +5099,4 @@ async function callApi(ctx, method, params = {}) {
5046
5099
  //#endregion
5047
5100
  export { flushCardUpdates as _, hideStateSecrets as a, paymentJson as c, nodeLocalFetch as d, chatJson as f, resumeHolds as g, groupMessageJson as h, groupSendRefused as i, reportAppFrames as l, groupJson as m, SETTABLE as n, mentionsFor as o, chatMessageJson as p, callApi as r, redactSettings as s, API_METHODS as t, servedApps as u };
5048
5101
 
5049
- //# sourceMappingURL=api-DFCgr6RH.js.map
5102
+ //# sourceMappingURL=api-Bi6hCcwG.js.map