@ghostlytools/cli 1.8.1 → 1.10.0

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 (111) hide show
  1. package/README.md +34 -23
  2. package/SKILL.md +9 -4
  3. package/dist/assets/{api-BpQC8dAw.js → api-BF_KwecF.js} +115 -45
  4. package/dist/assets/api-BF_KwecF.js.map +1 -0
  5. package/dist/assets/{api-CttDF-S5.js → api-DdrA86Ur.js} +2 -2
  6. package/dist/assets/{apiKit-CSMeHKgo.js → apiKit-Du1u2l4x.js} +8 -8
  7. package/dist/assets/apiKit-Du1u2l4x.js.map +1 -0
  8. package/dist/assets/{apps-DzFMdVt6.js → apps-Bti9fDoW.js} +1 -1
  9. package/dist/assets/{apps-DqTyZ40T.js → apps-DwPfp54I.js} +5 -3
  10. package/dist/assets/apps-DwPfp54I.js.map +1 -0
  11. package/dist/assets/{arkade-Cu3TbPxC.js → arkade-DOWpA2Kr.js} +2 -2
  12. package/dist/assets/{arkade-Cu3TbPxC.js.map → arkade-DOWpA2Kr.js.map} +1 -1
  13. package/dist/assets/{backup-CLZOORFC.js → backup-CeRckyl2.js} +1 -1
  14. package/dist/assets/{backup-CyTZhu28.js → backup-DZ_Q1eSu.js} +6 -6
  15. package/dist/assets/{backup-CyTZhu28.js.map → backup-DZ_Q1eSu.js.map} +1 -1
  16. package/dist/assets/{blobFiles-DOQDRdDI.js → blobFiles-BnjN_Vrz.js} +3 -3
  17. package/dist/assets/{blobFiles-DOQDRdDI.js.map → blobFiles-BnjN_Vrz.js.map} +1 -1
  18. package/dist/assets/buttons-BxIThdg9.js +332 -0
  19. package/dist/assets/buttons-BxIThdg9.js.map +1 -0
  20. package/dist/assets/buttons-D9QBHS9Y.js +2 -0
  21. package/dist/assets/client-D5E1RQYB.js +473 -0
  22. package/dist/assets/client-D5E1RQYB.js.map +1 -0
  23. package/dist/assets/{endpoint-BdaeBw2L.js → endpoint-DWHkXWVM.js} +101 -16
  24. package/dist/assets/endpoint-DWHkXWVM.js.map +1 -0
  25. package/dist/assets/{envelope-CGfUsR1m.js → envelope-CugS9qwQ.js} +2 -2
  26. package/dist/assets/{envelope-CGfUsR1m.js.map → envelope-CugS9qwQ.js.map} +1 -1
  27. package/dist/assets/{fileBytes-BPDKufla.js → fileBytes-DMzrIdCu.js} +1 -1
  28. package/dist/assets/{fileBytes-DNgrRL0R.js → fileBytes-DjBYYyXT.js} +3 -3
  29. package/dist/assets/{fileBytes-DNgrRL0R.js.map → fileBytes-DjBYYyXT.js.map} +1 -1
  30. package/dist/assets/{fileBytes-Q3ehcEr8.js → fileBytes-Douk1yOp.js} +2 -2
  31. package/dist/assets/{fileBytes-Q3ehcEr8.js.map → fileBytes-Douk1yOp.js.map} +1 -1
  32. package/dist/assets/fileBytesIdb-CD5Uv490.js +2 -0
  33. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js → fileBytesIdb-CkClu9YI.js} +3 -3
  34. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js.map → fileBytesIdb-CkClu9YI.js.map} +1 -1
  35. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js → fileBytesOpfs-WryQuOgK.js} +3 -3
  36. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js.map → fileBytesOpfs-WryQuOgK.js.map} +1 -1
  37. package/dist/assets/{fixedHosts-BiukTsd9.js → fixedHosts-B4E4VrYE.js} +4 -4
  38. package/dist/assets/{fixedHosts-BiukTsd9.js.map → fixedHosts-B4E4VrYE.js.map} +1 -1
  39. package/dist/assets/{groupFiles-CeF9nPv9.js → groupFiles-NonOYBKN.js} +380 -650
  40. package/dist/assets/groupFiles-NonOYBKN.js.map +1 -0
  41. package/dist/assets/{host-CKAehWP6.js → host-DvcVt5YI.js} +144 -33
  42. package/dist/assets/host-DvcVt5YI.js.map +1 -0
  43. package/dist/assets/{hyperdhtRelay-B8Pdykhg.js → hyperdhtRelay-Ce42sR8x.js} +2 -2
  44. package/dist/assets/{hyperdhtRelay-B8Pdykhg.js.map → hyperdhtRelay-Ce42sR8x.js.map} +1 -1
  45. package/dist/assets/{idb-BkOJES5_.js → idb-BHsAqENE.js} +37 -6
  46. package/dist/assets/idb-BHsAqENE.js.map +1 -0
  47. package/dist/assets/{irohWeb-D6tAPHZa.js → irohWeb-C9ChbD-c.js} +71 -4
  48. package/dist/assets/{irohWeb-D6tAPHZa.js.map → irohWeb-C9ChbD-c.js.map} +1 -1
  49. package/dist/assets/{main-BDY-pfpz.js → main-4qE381KM.js} +226 -280
  50. package/dist/assets/main-4qE381KM.js.map +1 -0
  51. package/dist/assets/{mainline-3ueXpFQL.js → mainline-DOwZDHVy.js} +2 -2
  52. package/dist/assets/{mainline-3ueXpFQL.js.map → mainline-DOwZDHVy.js.map} +1 -1
  53. package/dist/assets/{networkReason-DhJYOomu.js → networkReason-MInk1Y63.js} +3 -3
  54. package/dist/assets/{networkReason-DhJYOomu.js.map → networkReason-MInk1Y63.js.map} +1 -1
  55. package/dist/assets/{nwc-B1Quqda-.js → nwc-CHLWFV1R.js} +3 -3
  56. package/dist/assets/{nwc-B1Quqda-.js.map → nwc-CHLWFV1R.js.map} +1 -1
  57. package/dist/assets/{nwcProvider-DUB6xO-b.js → nwcProvider-BlkPOJen.js} +2 -2
  58. package/dist/assets/{nwcProvider-DUB6xO-b.js.map → nwcProvider-BlkPOJen.js.map} +1 -1
  59. package/dist/assets/{ownDid-BfqHJdA6.js → ownDid-yXtY_1B5.js} +3 -3
  60. package/dist/assets/ownDid-yXtY_1B5.js.map +1 -0
  61. package/dist/assets/{profiles-MFtCmJwK.js → profiles-vbXHs0Mq.js} +40 -3
  62. package/dist/assets/profiles-vbXHs0Mq.js.map +1 -0
  63. package/dist/assets/{registry-CZTmtSws.js → registry-BN9r2pR4.js} +1 -1
  64. package/dist/assets/{registry-DwlTNQjr.js → registry-chCD0KWS.js} +5 -5
  65. package/dist/assets/registry-chCD0KWS.js.map +1 -0
  66. package/dist/assets/{resolve-BVwhiYjj.js → resolve-Dtzogt2W.js} +2 -2
  67. package/dist/assets/{resolve-BVwhiYjj.js.map → resolve-Dtzogt2W.js.map} +1 -1
  68. package/dist/assets/{restoredRows-BCRCjhdF.js → restoredRows-CRYwIx3g.js} +2 -2
  69. package/dist/assets/{restoredRows-BCRCjhdF.js.map → restoredRows-CRYwIx3g.js.map} +1 -1
  70. package/dist/assets/secretGuard-CSVNxXVW.js +1081 -0
  71. package/dist/assets/secretGuard-CSVNxXVW.js.map +1 -0
  72. package/dist/assets/secretGuard-Q2BKq0q0.js +2 -0
  73. package/dist/assets/{server-Br3XPwFG.js → server-BZnsm5X5.js} +2510 -569
  74. package/dist/assets/server-BZnsm5X5.js.map +1 -0
  75. package/dist/assets/{src-C4sOH4zH.js → src-DZagapGt.js} +2015 -161
  76. package/dist/assets/src-DZagapGt.js.map +1 -0
  77. package/dist/assets/{sshForges-CQQomStK.js → sshForges-BkTgy5rx.js} +16 -9
  78. package/dist/assets/{sshForges-CQQomStK.js.map → sshForges-BkTgy5rx.js.map} +1 -1
  79. package/dist/assets/{translate-C2aNyUkR.js → translate-B9SMd6uf.js} +15 -8
  80. package/dist/assets/translate-B9SMd6uf.js.map +1 -0
  81. package/dist/assets/{usdt-CMwatDnQ.js → usdt-BU4ezonh.js} +3 -3
  82. package/dist/assets/{usdt-CMwatDnQ.js.map → usdt-BU4ezonh.js.map} +1 -1
  83. package/dist/assets/{waitNotice-Ck3el3_Z.js → waitNotice-B8D8WhbE.js} +2 -2
  84. package/dist/assets/waitNotice-B8D8WhbE.js.map +1 -0
  85. package/dist/assets/{words-CqN2KG1r.js → words-jYy7lTcb.js} +5 -2
  86. package/dist/assets/words-jYy7lTcb.js.map +1 -0
  87. package/dist/ghostly.mjs +1 -1
  88. package/examples/call-echo.mjs +7 -5
  89. package/package.json +1 -1
  90. package/dist/assets/api-BpQC8dAw.js.map +0 -1
  91. package/dist/assets/apiKit-CSMeHKgo.js.map +0 -1
  92. package/dist/assets/apps-DqTyZ40T.js.map +0 -1
  93. package/dist/assets/buttons-Bd9fR31r.js +0 -698
  94. package/dist/assets/buttons-Bd9fR31r.js.map +0 -1
  95. package/dist/assets/buttons-c4CJnL6i.js +0 -2
  96. package/dist/assets/daemonProof-DtrL5lE5.js +0 -236
  97. package/dist/assets/daemonProof-DtrL5lE5.js.map +0 -1
  98. package/dist/assets/endpoint-BdaeBw2L.js.map +0 -1
  99. package/dist/assets/fileBytesIdb-DZcESfTt.js +0 -2
  100. package/dist/assets/groupFiles-CeF9nPv9.js.map +0 -1
  101. package/dist/assets/host-CKAehWP6.js.map +0 -1
  102. package/dist/assets/idb-BkOJES5_.js.map +0 -1
  103. package/dist/assets/main-BDY-pfpz.js.map +0 -1
  104. package/dist/assets/ownDid-BfqHJdA6.js.map +0 -1
  105. package/dist/assets/profiles-MFtCmJwK.js.map +0 -1
  106. package/dist/assets/registry-DwlTNQjr.js.map +0 -1
  107. package/dist/assets/server-Br3XPwFG.js.map +0 -1
  108. package/dist/assets/src-C4sOH4zH.js.map +0 -1
  109. package/dist/assets/translate-C2aNyUkR.js.map +0 -1
  110. package/dist/assets/waitNotice-Ck3el3_Z.js.map +0 -1
  111. package/dist/assets/words-CqN2KG1r.js.map +0 -1
@@ -1,15 +1,16 @@
1
- import { El as ownInviteRefusal, Eu as sanitizeAvatar, Fr as TYPING_KINDS, Gn as GROUP_FILE_LIMITS, Ir as TYPING_REFRESH_MS, Ka as replySnippet, Ki as identityStatement, Mo as AWAITING_PEER_MS, Mu as toBase64Url, Qc as appRef, Rr as sanitizeTypingStatus, Tu as MAX_AVATAR_LENGTH, Uo as LIMITS, Vo as parseLocalTarget, Wc as isAppUrl, X as groupName, ba as voiceLevel, co as checkStatusCard, da as sanitizeMime, fa as PLAYABLE_AUDIO, ga as downsamplePeaks, ha as baseMime, ii as APP_DATA_MAX_BYTES, io as appCardUrl, ju as randomBytes$1, ma as VOICE_METER, nl as isAppRef, oo as cardLine, pa as VOICE_LIMITS, po as claimedTime, ro as appCardId, to as STATUS_CARD_LIMITS, ua as sanitizeFileName, ul as readImageMeta, uo as statusCardBytes, va as parseVoiceMeta, wl as inviteLink, ya as voiceDownloadName, zc as APP_PERMISSIONS, zo as GhostlyHttpError } from "./src-C4sOH4zH.js";
2
- import { O as waitingGroupFile, T as removeStored, X as iceServerProblem, Z as iceServerSetting, ct as NO_PICTURE_METADATA, dt as stripPictureMetadata, ft as withoutPictureMetadata, i as groupOfFile, k as IDENTITY_DRAFT_TTL_MS, l as replyRef, n as groupFileId, v as paymentNetwork } from "./groupFiles-CeF9nPv9.js";
3
- import { u as fileStore } from "./idb-BkOJES5_.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-DwlTNQjr.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-Bd9fR31r.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-CqN2KG1r.js";
1
+ import { $o as LIMITS, Aa as voiceLevel, Ca as VOICE_LIMITS, Cl as readImageMeta, Co as claimedTime, Ea as downsamplePeaks, Gr as TYPING_REFRESH_MS, Gu as toBase64Url, Hn as stripPictureMetadata, Ho as AWAITING_PEER_MS, Ll as inviteLink, Oa as parseVoiceMeta, Rn as withoutVideoMetadata, Ru as MAX_AVATAR_LENGTH, Sa as PLAYABLE_AUDIO, Ta as baseMime, Un as withoutPictureMetadata, Wr as TYPING_KINDS, Wu as randomBytes$1, Yo as GhostlyHttpError, Z as groupName, Zc as APP_PERMISSIONS, Zo as parseLocalTarget, ba as sanitizeFileName, bo as statusCardBytes, do as STATUS_CARD_LIMITS, er as GROUP_FILE_LIMITS, go as cardLine, hl as isAppRef, ka as voiceDownloadName, mo as appCardUrl, nl as isAppUrl, no as replySnippet, pi as APP_DATA_MAX_BYTES, po as appCardId, qr as sanitizeTypingStatus, ta as identityStatement, ul as appRef, vo as checkStatusCard, wa as VOICE_METER, xa as sanitizeMime, zl as ownInviteRefusal, zn as NO_PICTURE_METADATA, zu as sanitizeAvatar } from "./src-DZagapGt.js";
2
+ import { u as fileStore } from "./idb-BHsAqENE.js";
3
+ import { O as waitingGroupFile, T as removeStored, i as groupOfFile, k as IDENTITY_DRAFT_TTL_MS, l as replyRef, n as groupFileId, nt as iceServerSetting, tt as iceServerProblem, v as paymentNetwork } from "./groupFiles-NonOYBKN.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-chCD0KWS.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-CSMeHKgo.js";
10
- import { a as checkShownName } from "./profiles-MFtCmJwK.js";
11
- import { t as BACKUP_METHODS } from "./backup-CyTZhu28.js";
12
- import { o as checkedBundle } from "./apps-DqTyZ40T.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-jYy7lTcb.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-Du1u2l4x.js";
10
+ import { a as checkShownName } from "./profiles-vbXHs0Mq.js";
11
+ 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-BxIThdg9.js";
12
+ import { t as BACKUP_METHODS } from "./backup-DZ_Q1eSu.js";
13
+ import { o as checkedBundle } from "./apps-DwPfp54I.js";
13
14
  import { generateMnemonic } from "@scure/bip39";
14
15
  import { wordlist } from "@scure/bip39/wordlists/english.js";
15
16
  import { execFile, spawn } from "node:child_process";
@@ -836,17 +837,17 @@ async function voiceOf(params, path, mime, size) {
836
837
  throw new CliError("bad_request", `A voice note's waveform is 1 to ${VOICE_LIMITS.maxBars} peaks from 0 to 255`);
837
838
  }
838
839
  /**
839
- * The file at `path` as it is sent, as the apps send it (platform/services.ts `sendable`): a picture without its metadata
840
- * (where it was taken, the device, the time), before its size is read and its digest computed. A picture whose metadata
841
- * cannot be removed is refused, never sent as it was. A voice note goes as it is.
840
+ * The file at `path` as it is sent, as the apps send it (platform/services.ts `sendable`): a picture or an MP4 or
841
+ * QuickTime video without its metadata (where it was taken or recorded, the device, the time), before its size is read
842
+ * and its digest computed. One whose metadata cannot be removed is refused, never sent as it was. A voice note goes as it is.
842
843
  */
843
844
  async function sendable(path, mime, voice) {
844
845
  const source = await openAsBlob(path, { type: mime });
845
846
  if (voice) return source;
846
847
  try {
847
- return await withoutPictureMetadata(source, mime) ?? source;
848
+ return await withoutPictureMetadata(source, mime) ?? await withoutVideoMetadata(source, mime) ?? source;
848
849
  } catch (error) {
849
- if (error instanceof Error && error.message === "This picture cannot be sent: Ghostly could not remove the details saved in it, like where it was taken") throw new CliError("refused", NO_PICTURE_METADATA);
850
+ if (error instanceof Error && (error.message === "This picture cannot be sent: Ghostly could not remove the details saved in it, like where it was taken" || error.message === "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded")) throw new CliError("refused", error.message);
850
851
  throw error;
851
852
  }
852
853
  }
@@ -995,6 +996,7 @@ var ACTIONS = [
995
996
  ];
996
997
  var FILE_METHODS = {
997
998
  async "file.send"(ctx, params) {
999
+ guardText(str(params, "name"), bool(params, "force"), "file's name", "send it");
998
1000
  const target = chatOrGroupOf(ctx, params);
999
1001
  const path = resolve(str(params, "path", true));
1000
1002
  let info;
@@ -1005,6 +1007,11 @@ var FILE_METHODS = {
1005
1007
  }
1006
1008
  if (!info.isFile()) throw new CliError("bad_request", `${path} is not a file`);
1007
1009
  await access(path, constants$1.R_OK);
1010
+ const wait = oneOf(params, "wait", "group" in target ? ["none"] : ["none", "sent"], !("group" in target) && ctx.mode === "one-shot" ? "sent" : "none");
1011
+ const seconds = num(params, "timeout", 300, {
1012
+ min: 1,
1013
+ max: 86400
1014
+ });
1008
1015
  if ("group" in target) return sendToGroup(ctx, params, target.group, path, info.size);
1009
1016
  const { link } = target;
1010
1017
  if (link.profile && link.dataLink === "open" && !link.capabilities?.files) throw new CliError("unavailable", "The contact's app takes no files");
@@ -1064,6 +1071,11 @@ var FILE_METHODS = {
1064
1071
  await removeStored(file.id).catch(() => {});
1065
1072
  throw new CliError("refused", error instanceof Error ? error.message : String(error));
1066
1073
  }
1074
+ if (wait === "sent") await FILE_METHODS["file.wait"](ctx, {
1075
+ chat: link.id,
1076
+ file: file.id,
1077
+ timeout: seconds
1078
+ });
1067
1079
  return {
1068
1080
  chat: link.id,
1069
1081
  messageId: `me_${timestamp}`,
@@ -1146,7 +1158,9 @@ var FILE_METHODS = {
1146
1158
  const transfer = state(ctx).transfers[fileId] ?? (await fileStore.get(fileId).catch(() => void 0))?.transfer;
1147
1159
  if (action === "pause" && transfer?.stage === "verifying") throw new CliError("refused", "Too late to pause: it is being checked");
1148
1160
  if (transfer?.state === "failed") throw new CliError("refused", `It ended: ${transfer.error ?? "failed"}${outgoing && transfer.retry ? " (file resend sends it again)" : ""}`);
1149
- if (outgoing && action === "cancel" && transfer?.state === "transferring" && (transfer.stage === "verifying" || transfer.size > 0 && transfer.transferred >= transfer.size && transfer.stage !== "asking" && transfer.stage !== "queued" && transfer.stage !== "paused")) throw new CliError("refused", "Too late to cancel: it arrived whole, and the contact keeps it");
1161
+ const whole = outgoing && transfer?.state === "transferring" && (transfer.stage === "verifying" || transfer.size > 0 && transfer.transferred >= transfer.size && transfer.stage !== "asking" && transfer.stage !== "queued" && transfer.stage !== "paused");
1162
+ if (whole && action === "cancel") throw new CliError("refused", "Too late to cancel: it arrived whole, and the contact keeps it");
1163
+ if (whole && action === "pause") throw new CliError("refused", "Too late to pause: it arrived whole, and the contact keeps it");
1150
1164
  }
1151
1165
  await node(ctx).fileAction({
1152
1166
  linkId,
@@ -1317,10 +1331,20 @@ function fieldsOf(params) {
1317
1331
  }
1318
1332
  /**
1319
1333
  * An update merged over a card: fields given replace those there, `pr` field by field, and a field given as null goes
1320
- * (`--json '{"step":null}'`). The kind and the id never change.
1334
+ * (`--json '{"step":null}'`). The kind and the id never change. A task says how far it is one way: a percent given
1335
+ * replaces the steps there and steps given the percent, unless the update gives both. Before, `--steps 4/5` over an
1336
+ * earlier `--progress 90` showed "90% · 4 of 5 steps", its bar at 90: a card's own percent wins over its steps.
1321
1337
  */
1322
1338
  function mergeCard(base, patch) {
1323
1339
  const out = { ...base };
1340
+ if (base.kind === "task") {
1341
+ const given = (key) => patch[key] !== void 0 && patch[key] !== null;
1342
+ const steps = given("done") || given("total");
1343
+ if (given("progress") && !steps) {
1344
+ delete out.done;
1345
+ delete out.total;
1346
+ } else if (steps && !given("progress")) delete out.progress;
1347
+ }
1324
1348
  for (const [key, value] of Object.entries(patch)) {
1325
1349
  if (key === "kind" || key === "id") continue;
1326
1350
  if (value === null) {
@@ -1401,7 +1425,7 @@ function guardSecrets(fields, params, verb) {
1401
1425
  if (bool(params, "force")) return;
1402
1426
  const check = (text) => {
1403
1427
  const secret = findSecret(text);
1404
- 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 });
1428
+ 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 });
1405
1429
  };
1406
1430
  for (const text of cardTexts([fields, params.run])) {
1407
1431
  check(text);
@@ -2102,7 +2126,7 @@ var view = (ctx, id, params) => groupJson(state(ctx).groups.find((g) => g.id ===
2102
2126
  var GROUP_ADMIN_METHODS = {
2103
2127
  async "group.invite"(ctx, params) {
2104
2128
  const group = groupOf(ctx, params);
2105
- const link = chatOf(ctx, params);
2129
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
2106
2130
  await node(ctx).inviteToGroup({
2107
2131
  groupId: group.id,
2108
2132
  linkId: link.id
@@ -2144,6 +2168,7 @@ var GROUP_ADMIN_METHODS = {
2144
2168
  const group = groupOf(ctx, params, "chat rename <chat> <name...>");
2145
2169
  const name = groupName(str(params, "name", true));
2146
2170
  if (!name) throw new CliError("bad_request", `A group's name is 1 to 64 characters on one line`);
2171
+ guardText(name, bool(params, "force"), "group's name", "rename it");
2147
2172
  await node(ctx).renameGroup({
2148
2173
  groupId: group.id,
2149
2174
  name
@@ -2423,7 +2448,7 @@ var IDENTITY_METHODS = {
2423
2448
  return { removed: id };
2424
2449
  },
2425
2450
  async "identity.share"(ctx, params) {
2426
- const link = chatOf(ctx, params);
2451
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
2427
2452
  const id = str(params, "id", true);
2428
2453
  if (!state(ctx).identityProofs.some((p) => p.id === id)) throw new CliError("not_found", `No identity proof ${JSON.stringify(id)} (ghostly identity list)`);
2429
2454
  await node(ctx).shareIdentityProof({
@@ -2621,14 +2646,34 @@ function sameSecret(a, b) {
2621
2646
  }
2622
2647
  /**
2623
2648
  * Added to every answer of a contact's app, next to any policy the contact sends (a browser enforces both): its
2624
- * scripts, forms, pictures, frames, fonts, media, styles and workers reach its own origin and public https sites
2625
- * (and inline, data: and blob: content), never plain http. The page is served from `<random>.localhost`, which Chrome
2626
- * counts as this machine, so its own guard for requests to local addresses (Local Network Access) would not ask
2627
- * before the page reached another service on 127.0.0.1 or the local network. Inline scripts and styles stay allowed:
2628
- * this policy bounds where the page reaches, not how the app is written. A top-level navigation is not covered: no
2629
- * browser lets a policy bound it.
2649
+ * requests (fetch, XHR, beacons, WebSockets, EventSource) and forms reach only its own origin, the contact's server;
2650
+ * its scripts, pictures, frames, fonts, media, styles and workers its own origin and https sites (and inline, data:
2651
+ * and blob: content), never plain http. The page is served from `<random>.localhost`, which Chrome counts as this
2652
+ * machine, so its own guard for requests to local addresses (Local Network Access) would not ask before the page
2653
+ * reached another service on 127.0.0.1 or the local network, and a policy cannot tell a public https site from one
2654
+ * here or on the local network with a trusted certificate: requests that can read an answer or post go nowhere else.
2655
+ * Inline scripts and styles stay allowed: this policy bounds where the page reaches, not how the app is written. A
2656
+ * top-level navigation is not covered: no browser lets a policy bound it.
2657
+ */
2658
+ var OPENED_SERVICE_CSP = "default-src 'self' https: data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
2659
+ /**
2660
+ * The contact's headers that are not passed on: each makes the browser send something to a place it names, outside
2661
+ * `connect-src` (violation and network-error reports, and the endpoints they go to; `Link` preloads, prefetches and
2662
+ * early connections). Only the contact's server is reached.
2630
2663
  */
2631
- var OPENED_SERVICE_CSP = "default-src 'self' https: data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https: wss:; form-action 'self' https:";
2664
+ var OPENED_SERVICE_DROPPED_HEADERS = [
2665
+ "content-security-policy-report-only",
2666
+ "reporting-endpoints",
2667
+ "report-to",
2668
+ "nel",
2669
+ "link"
2670
+ ];
2671
+ /** The directives of a contact's policy that send reports to a URL it names, dropped from it. */
2672
+ var OPENED_SERVICE_DROPPED_DIRECTIVES = ["report-uri", "report-to"];
2673
+ /** A contact's `Content-Security-Policy` value (one policy or several joined by commas) without its report directives. */
2674
+ function withoutReports(value) {
2675
+ 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(", ");
2676
+ }
2632
2677
  function plain(response, status, text, headers = {}) {
2633
2678
  response.writeHead(status, {
2634
2679
  "content-type": "text/plain; charset=utf-8",
@@ -2713,14 +2758,16 @@ async function proxy(request, response, chunks, send, cookies) {
2713
2758
  const out = {};
2714
2759
  for (const [name, value] of answer.headers) {
2715
2760
  const lower = name.toLowerCase();
2716
- if (lower === "transfer-encoding" || lower === "connection") continue;
2761
+ if (lower === "transfer-encoding" || lower === "connection" || OPENED_SERVICE_DROPPED_HEADERS.includes(lower)) continue;
2717
2762
  if (lower === "set-cookie") {
2718
2763
  const cookie = hostOnlyCookie(value);
2719
2764
  if (!cookie) continue;
2720
2765
  if (cookies.size < MAX_COOKIE_NAMES) cookies.add(setCookieName(cookie));
2721
2766
  out[lower] = [...out[lower] ?? [], cookie];
2722
- } else if (lower === "content-security-policy") out[lower] = [...out[lower] ?? [], value];
2723
- else out[lower] = value;
2767
+ } else if (lower === "content-security-policy") {
2768
+ const policy = withoutReports(value);
2769
+ if (policy) out[lower] = [...out[lower] ?? [], policy];
2770
+ } else out[lower] = value;
2724
2771
  }
2725
2772
  out["content-security-policy"] = [...out["content-security-policy"] ?? [], OPENED_SERVICE_CSP];
2726
2773
  response.writeHead(answer.status, out);
@@ -3347,7 +3394,7 @@ function memoOf(params, verb, field = "memo") {
3347
3394
  const memo = str(params, field);
3348
3395
  if (memo && !bool(params, "force")) {
3349
3396
  const secret = findSecret(memo);
3350
- 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 });
3397
+ if (secret) throw new CliError("confirm", `The ${field} looks like ${secretWords(secret)}; ${verb} with --force if you mean to`, { kind: secret.kind });
3351
3398
  }
3352
3399
  return memo || void 0;
3353
3400
  }
@@ -3565,11 +3612,15 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3565
3612
  let invoice = text.replace(/^lightning:/i, "");
3566
3613
  let n;
3567
3614
  let note;
3615
+ 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");
3616
+ const chat = params.chat === void 0 ? void 0 : chatOf(ctx, params);
3617
+ if (chat) inviteTaken(chat);
3568
3618
  if (isInvoice(text)) n = network(params);
3569
3619
  else if (isLnurl(text)) {
3570
3620
  n = network(params);
3571
3621
  const amount = num(params, "amount", 0, { min: 1 });
3572
3622
  if (!amount) throw new CliError("bad_request", "amount is required to pay a Lightning address or LNURL");
3623
+ if (n === "mainnet" && !bool(params, "confirmReal")) throw new CliError("confirm", "This pays real money (Mainnet): pass --confirm-real to confirm this payment");
3573
3624
  const view = await node(ctx).lnurlResolve({
3574
3625
  text,
3575
3626
  network: n
@@ -3597,7 +3648,11 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3597
3648
  quote: quote.quote,
3598
3649
  mint: quote.mint,
3599
3650
  ...note ? { note } : {},
3600
- ...real(params)
3651
+ ...real(params),
3652
+ ...chat ? {
3653
+ linkId: chat.id,
3654
+ invoice
3655
+ } : {}
3601
3656
  });
3602
3657
  return {
3603
3658
  network: n,
@@ -3957,6 +4012,7 @@ var METHODS = {
3957
4012
  async "profile.set"(ctx, params) {
3958
4013
  const patch = {};
3959
4014
  if (params.name !== void 0) patch.nick = checkShownName(params.name);
4015
+ guardText(patch.nick, bool(params, "force"), "name", "set it");
3960
4016
  if (params.shareProfile !== void 0) patch.shareProfile = bool(params, "shareProfile");
3961
4017
  await node(ctx).updateSettings({ settings: patch });
3962
4018
  return METHODS["profile.get"](ctx, {});
@@ -3968,6 +4024,7 @@ var METHODS = {
3968
4024
  const patch = {};
3969
4025
  let warning;
3970
4026
  for (const [key, value] of Object.entries(params)) {
4027
+ if (key === "force") continue;
3971
4028
  const kind = Object.hasOwn(SETTABLE, key) ? SETTABLE[key] : void 0;
3972
4029
  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");
3973
4030
  if (!kind) throw new CliError("bad_request", `${key} is not a setting the CLI changes (${Object.keys(SETTABLE).join(", ")})`);
@@ -3976,6 +4033,7 @@ var METHODS = {
3976
4033
  if (kind === "boolean" && typeof value !== "boolean") throw new CliError("bad_request", `${key} must be true or false`);
3977
4034
  if (key === "nick") {
3978
4035
  patch.nick = checkShownName(value, key);
4036
+ guardText(patch.nick, bool(params, "force"), "nick", "set it");
3979
4037
  continue;
3980
4038
  }
3981
4039
  if (kind === "ice") {
@@ -4072,7 +4130,7 @@ var METHODS = {
4072
4130
  checkTextSize(text);
4073
4131
  if (!bool(params, "force")) {
4074
4132
  const secret = findSecret(text);
4075
- 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 });
4133
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; send it with --force if you mean to`, { kind: secret.kind });
4076
4134
  }
4077
4135
  const wait = oneOf(params, "wait", [
4078
4136
  "none",
@@ -4117,7 +4175,7 @@ var METHODS = {
4117
4175
  const text = str(params, "text", true);
4118
4176
  if (!bool(params, "force")) {
4119
4177
  const secret = findSecret(text);
4120
- 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 });
4178
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; edit with --force if you mean to`, { kind: secret.kind });
4121
4179
  }
4122
4180
  const wait = oneOf(params, "wait", ["none", "confirmed"], "none");
4123
4181
  const ms = num(params, "timeout", 30, {
@@ -4235,13 +4293,13 @@ var METHODS = {
4235
4293
  async "saved.remove"(ctx, params) {
4236
4294
  return saveMark(ctx, params, true);
4237
4295
  },
4238
- /** The saved messages, the last saved first, each as it is now and named by its chat or group. */
4296
+ /** The saved messages under `saved`, the last saved first, each as it is now and named by its chat or group. */
4239
4297
  async "saved.list"(ctx) {
4240
4298
  const { links, groups } = state(ctx);
4241
4299
  const saved = await node(ctx).savedMessages();
4242
4300
  const originals = /* @__PURE__ */ new Map();
4243
4301
  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] : [])));
4244
- return saved.map(({ savedAt, message }) => {
4302
+ return { saved: saved.map(({ savedAt, message }) => {
4245
4303
  const checked = (json) => quoteChecked(json, message, originals.get(message.linkId));
4246
4304
  if (!message.linkId.startsWith("group:")) return {
4247
4305
  chat: message.linkId,
@@ -4254,7 +4312,7 @@ var METHODS = {
4254
4312
  savedAt,
4255
4313
  message: checked(groupMessageJson(message, groups.find((g) => g.id === id)))
4256
4314
  };
4257
- });
4315
+ }) };
4258
4316
  },
4259
4317
  /**
4260
4318
  * 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
@@ -4276,7 +4334,7 @@ var METHODS = {
4276
4334
  }
4277
4335
  if (!bool(params, "force")) for (const message of chosen) {
4278
4336
  const secret = message.file ? null : findSecret(message.text);
4279
- 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`, {
4337
+ if (secret) throw new CliError("confirm", `A message looks like ${secretWords(secret)}; forward it with --force if you mean to`, {
4280
4338
  kind: secret.kind,
4281
4339
  messageId: message.id
4282
4340
  });
@@ -4498,6 +4556,7 @@ var METHODS = {
4498
4556
  async "group.create"(ctx, params) {
4499
4557
  const name = groupName(str(params, "name", true));
4500
4558
  if (!name) throw new CliError("bad_request", `A group's name is 1 to 64 characters on one line`);
4559
+ guardText(name, bool(params, "force"), "group's name", "create it");
4501
4560
  const profile = oneOf(params, "profile", ["community", "mesh"], "community");
4502
4561
  const { groupId } = await node(ctx).createGroup({
4503
4562
  name,
@@ -4583,7 +4642,7 @@ var METHODS = {
4583
4642
  const text = str(params, "text", true);
4584
4643
  if (!bool(params, "force")) {
4585
4644
  const secret = findSecret(text);
4586
- 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 });
4645
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; edit with --force if you mean to`, { kind: secret.kind });
4587
4646
  }
4588
4647
  const mentions = mentionsFor(text, list(params, "mentions"), group);
4589
4648
  const wait = oneOf(params, "wait", ["none", "sent"], "none");
@@ -4753,6 +4812,8 @@ var METHODS = {
4753
4812
  * kept): it stops once it has answered, and the next command starts on the emptied profile.
4754
4813
  */
4755
4814
  async function clearProfile(ctx) {
4815
+ const call = ctx.calls.list()[0];
4816
+ if (call) throw new CliError("busy", `A call is on in a chat: hang it up first (ghostly call hangup ${call.chat}), then clear the profile`, { call: call.call });
4756
4817
  const { links, groups } = state(ctx);
4757
4818
  await node(ctx).clearProfileData();
4758
4819
  const cleared = {
@@ -4767,7 +4828,8 @@ async function clearProfile(ctx) {
4767
4828
  };
4768
4829
  }
4769
4830
  /**
4770
- * The engine's calls that send a text this side writes (a message, a file's caption, a payment's memo): `engine.call`
4831
+ * The engine's calls that send a text this side writes (a message, a file's caption, a payment's memo, a name others
4832
+ * read): `engine.call`
4771
4833
  * 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.
4772
4834
  */
4773
4835
  var ENGINE_SENDS = /* @__PURE__ */ new Set([
@@ -4782,15 +4844,23 @@ var ENGINE_SENDS = /* @__PURE__ */ new Set([
4782
4844
  "askToPay",
4783
4845
  "preparePayment",
4784
4846
  "fedimintInvoice",
4785
- "lnurlInvoice"
4847
+ "lnurlInvoice",
4848
+ "createGroup",
4849
+ "renameGroup",
4850
+ "updateSettings",
4851
+ "sendFile"
4786
4852
  ]);
4787
4853
  async function guardEngineSend(ctx, method, args) {
4854
+ const of = (value, key) => value && typeof value === "object" ? value[key] : void 0;
4788
4855
  let texts = [
4789
4856
  args.text,
4790
4857
  args.card,
4791
4858
  args.caption,
4792
4859
  args.memo,
4793
- args.comment
4860
+ args.comment,
4861
+ args.name,
4862
+ of(args.settings, "nick"),
4863
+ of(args.file, "name")
4794
4864
  ];
4795
4865
  if (method === "forwardMessages") {
4796
4866
  const ids = Array.isArray(args.messageIds) ? args.messageIds.filter((id) => typeof id === "string") : [];
@@ -4801,7 +4871,7 @@ async function guardEngineSend(ctx, method, args) {
4801
4871
  })) : [];
4802
4872
  }
4803
4873
  const secret = secretIn(texts);
4804
- 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 });
4874
+ if (secret) throw new CliError("confirm", `The text looks like ${secretWords(secret)}; call ${method} with --force if you mean to`, { kind: secret.kind });
4805
4875
  }
4806
4876
  /**
4807
4877
  * How long `react` and `pin` in a 1:1 chat wait for the contact: a one-shot until it confirmed (as `edit`), since what
@@ -5022,4 +5092,4 @@ async function callApi(ctx, method, params = {}) {
5022
5092
  //#endregion
5023
5093
  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 };
5024
5094
 
5025
- //# sourceMappingURL=api-BpQC8dAw.js.map
5095
+ //# sourceMappingURL=api-BF_KwecF.js.map