@ghostlytools/cli 1.8.0 → 1.8.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 (78) hide show
  1. package/README.md +4 -4
  2. package/dist/assets/{api-I_KbuXHa.js → api-BpQC8dAw.js} +68 -33
  3. package/dist/assets/api-BpQC8dAw.js.map +1 -0
  4. package/dist/assets/{api-Dj1yn0px.js → api-CttDF-S5.js} +2 -2
  5. package/dist/assets/{apiKit-C-_PWZvy.js → apiKit-CSMeHKgo.js} +2 -2
  6. package/dist/assets/{apiKit-C-_PWZvy.js.map → apiKit-CSMeHKgo.js.map} +1 -1
  7. package/dist/assets/{apps-DKIe8VjF.js → apps-DqTyZ40T.js} +2 -2
  8. package/dist/assets/{apps-DKIe8VjF.js.map → apps-DqTyZ40T.js.map} +1 -1
  9. package/dist/assets/{apps-DbEfL_3b.js → apps-DzFMdVt6.js} +1 -1
  10. package/dist/assets/{arkade-k1bdSm70.js → arkade-Cu3TbPxC.js} +2 -2
  11. package/dist/assets/{arkade-k1bdSm70.js.map → arkade-Cu3TbPxC.js.map} +1 -1
  12. package/dist/assets/{backup-Cdd6-HNu.js → backup-CLZOORFC.js} +1 -1
  13. package/dist/assets/{backup-beKfbfNk.js → backup-CyTZhu28.js} +4 -4
  14. package/dist/assets/{backup-beKfbfNk.js.map → backup-CyTZhu28.js.map} +1 -1
  15. package/dist/assets/{buttons-ClI13rdv.js → buttons-Bd9fR31r.js} +173 -20
  16. package/dist/assets/buttons-Bd9fR31r.js.map +1 -0
  17. package/dist/assets/buttons-c4CJnL6i.js +2 -0
  18. package/dist/assets/{envelope-B88yiCQj.js → envelope-CGfUsR1m.js} +2 -2
  19. package/dist/assets/{envelope-B88yiCQj.js.map → envelope-CGfUsR1m.js.map} +1 -1
  20. package/dist/assets/fixedHosts-BiukTsd9.js +24 -0
  21. package/dist/assets/fixedHosts-BiukTsd9.js.map +1 -0
  22. package/dist/assets/{ghostly_iroh_web-CO0onry8.js → ghostly_iroh_web-BzAXJUYH.js} +10 -10
  23. package/dist/assets/{ghostly_iroh_web-CO0onry8.js.map → ghostly_iroh_web-BzAXJUYH.js.map} +1 -1
  24. package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
  25. package/dist/assets/{groupFiles-DjQc5XXv.js → groupFiles-CeF9nPv9.js} +631 -12
  26. package/dist/assets/groupFiles-CeF9nPv9.js.map +1 -0
  27. package/dist/assets/{host-CNWGB3-j.js → host-CKAehWP6.js} +30 -18
  28. package/dist/assets/host-CKAehWP6.js.map +1 -0
  29. package/dist/assets/hyperdhtRelay-1wzya_0L.js +25 -0
  30. package/dist/assets/hyperdhtRelay-1wzya_0L.js.map +1 -0
  31. package/dist/assets/{hyperdhtRelay-g7eXzf5h.js → hyperdhtRelay-B8Pdykhg.js} +15 -3
  32. package/dist/assets/hyperdhtRelay-B8Pdykhg.js.map +1 -0
  33. package/dist/assets/{irohWeb-Bx8dI4be.js → irohWeb-D6tAPHZa.js} +11 -7
  34. package/dist/assets/{irohWeb-Bx8dI4be.js.map → irohWeb-D6tAPHZa.js.map} +1 -1
  35. package/dist/assets/{main-BRxhBctJ.js → main-BDY-pfpz.js} +17 -17
  36. package/dist/assets/{main-BRxhBctJ.js.map → main-BDY-pfpz.js.map} +1 -1
  37. package/dist/assets/{mainline-CwuS6ngj.js → mainline-3ueXpFQL.js} +2 -2
  38. package/dist/assets/{mainline-CwuS6ngj.js.map → mainline-3ueXpFQL.js.map} +1 -1
  39. package/dist/assets/{networkReason-CIAMieQm.js → networkReason-DhJYOomu.js} +2 -2
  40. package/dist/assets/{networkReason-CIAMieQm.js.map → networkReason-DhJYOomu.js.map} +1 -1
  41. package/dist/assets/{nwc-C9JLJJkL.js → nwc-B1Quqda-.js} +3 -3
  42. package/dist/assets/{nwc-C9JLJJkL.js.map → nwc-B1Quqda-.js.map} +1 -1
  43. package/dist/assets/{nwcProvider-pFMrsUJh.js → nwcProvider-DUB6xO-b.js} +2 -2
  44. package/dist/assets/{nwcProvider-pFMrsUJh.js.map → nwcProvider-DUB6xO-b.js.map} +1 -1
  45. package/dist/assets/ownDid-BfqHJdA6.js +281 -0
  46. package/dist/assets/ownDid-BfqHJdA6.js.map +1 -0
  47. package/dist/assets/{registry-DY2ixQfU.js → registry-CZTmtSws.js} +1 -1
  48. package/dist/assets/{registry-Cks7FA_o.js → registry-DwlTNQjr.js} +5 -246
  49. package/dist/assets/registry-DwlTNQjr.js.map +1 -0
  50. package/dist/assets/{resolve-C4Y2HPqQ.js → resolve-BVwhiYjj.js} +3 -280
  51. package/dist/assets/resolve-BVwhiYjj.js.map +1 -0
  52. package/dist/assets/{server-D9RAmGdm.js → server-Br3XPwFG.js} +365 -107
  53. package/dist/assets/server-Br3XPwFG.js.map +1 -0
  54. package/dist/assets/{src-1RU4TilT.js → src-C4sOH4zH.js} +233 -106
  55. package/dist/assets/src-C4sOH4zH.js.map +1 -0
  56. package/dist/assets/sshForges-CQQomStK.js +253 -0
  57. package/dist/assets/sshForges-CQQomStK.js.map +1 -0
  58. package/dist/assets/{translate-od5GbpvR.js → translate-C2aNyUkR.js} +11 -5
  59. package/dist/assets/translate-C2aNyUkR.js.map +1 -0
  60. package/dist/assets/{usdt-DldXV0MR.js → usdt-CMwatDnQ.js} +3 -3
  61. package/dist/assets/{usdt-DldXV0MR.js.map → usdt-CMwatDnQ.js.map} +1 -1
  62. package/dist/assets/{words-BS2qq_vV.js → words-CqN2KG1r.js} +2 -2
  63. package/dist/assets/{words-BS2qq_vV.js.map → words-CqN2KG1r.js.map} +1 -1
  64. package/dist/ghostly.mjs +1 -1
  65. package/package.json +1 -1
  66. package/dist/assets/api-I_KbuXHa.js.map +0 -1
  67. package/dist/assets/buttons-BO1_7V4L.js +0 -2
  68. package/dist/assets/buttons-ClI13rdv.js.map +0 -1
  69. package/dist/assets/groupFiles-DjQc5XXv.js.map +0 -1
  70. package/dist/assets/host-CNWGB3-j.js.map +0 -1
  71. package/dist/assets/hyperdhtRelay-BT_wRxab.js +0 -21
  72. package/dist/assets/hyperdhtRelay-BT_wRxab.js.map +0 -1
  73. package/dist/assets/hyperdhtRelay-g7eXzf5h.js.map +0 -1
  74. package/dist/assets/registry-Cks7FA_o.js.map +0 -1
  75. package/dist/assets/resolve-C4Y2HPqQ.js.map +0 -1
  76. package/dist/assets/server-D9RAmGdm.js.map +0 -1
  77. package/dist/assets/src-1RU4TilT.js.map +0 -1
  78. package/dist/assets/translate-od5GbpvR.js.map +0 -1
package/README.md CHANGED
@@ -129,7 +129,7 @@ The rows are in alphabetical order of their first command, and every command of
129
129
  | `chat wait <chat> [--until live\|text\|paired] [--timeout s]` | Wait for a chat to go live, carry text, or see its contact. Live means a session that exists now, in this run of the daemon: a chat that was live before a restart counts once its contact answers again |
130
130
  | `daemon [--detach] [--timeout s]`, `daemon status [--timeout s]`, `daemon stop [--timeout s]`, `daemon restart [--timeout s]` | Keep the profile online; `status` names its version and its socket (`socket`, for the [socket API](#the-socket-api)), or says `"starting": true` with the `pid` of a daemon whose socket does not listen yet (`stop` and `restart` wait up to `--timeout` for that socket, then stop it); `restart` stops it and starts this release's code in the background ([After an upgrade](#after-an-upgrade)). Ctrl-C, SIGTERM and the terminal closing (SIGHUP) stop it cleanly. A command that holds the profile for a moment (a bot's `send` while a service manager restarts it) is waited for, up to `--timeout` (60 s): still held then, `busy` with its pid |
131
131
  | `edit <chat> <message> [text… \| --text <text> \| --stdin] [--force] [--wait none\|confirmed] [--timeout s]` | Replace the text of a message you sent (1:1 chats, `group edit` for a group; `<message>` is the `messageId` `send` gave, or its wire id). The contact sees it in place, marked edited; `--wait confirmed` waits for its app to confirm (the default without a daemon). At most 100 edits a message, no time limit; an older contact app gets it once it shows edits |
132
- | `engine <method> [json \| -] [--confirm-real] [--show-secret] [--yes] [--force]`, `engine --list [--verbose]` | Any call of the app's engine; `--verbose` lists what each takes (`{ linkId, label }`, `?` for an optional key). A call given less than it takes is refused as `bad_request`. One that deletes chats or groups (`clearProfileData`, `removeLink`, `leaveGroup`, `forgetGroup`, `deviceRemove`) needs `--yes`; `clearProfileData` answers what it removed and stops a daemon. One that sends a text that looks like a secret (`sendMessage`, `sendGroupMessage`, `editMessage`, `forwardMessages`) needs `--force` |
132
+ | `engine <method> [json \| -] [--confirm-real] [--show-secret] [--yes] [--force]`, `engine --list [--verbose]` | Any call of the app's engine; `--verbose` lists what each takes (`{ linkId, label }`, `?` for an optional key). A call given less than it takes is refused as `bad_request`. One that deletes chats or groups (`clearProfileData`, `removeLink`, `leaveGroup`, `forgetGroup`, `deviceRemove`) needs `--yes`; `clearProfileData` answers what it removed and stops a daemon. `removeLink`, and `setChatTransport` or `setDeliveryMode` to `dht`, are refused (`busy`) while a call is on in the chat, as `chat remove` and `chat transport dht` are. One that sends a text that looks like a secret (`sendMessage`, `sendGroupMessage`, `editMessage`, `forwardMessages`) needs `--force` |
133
133
  | `events [--since seq] [--translate lang]` | What the event journal holds, without following ([Translation](#translation)) |
134
134
  | `file list <chat\|group>`, `file accept\|decline\|pause\|resume\|cancel [<chat>] <file>` | Transfers; a file over 25 MiB waits for `file accept` (files/3), and so does a group's file that did not come by itself (over 8 MiB): its row's `transfer` says `stage: "asking"`, `waitingFor: "me"` (a file sent from here that the contact has not taken yet: `waitingFor: "contact"`). A file's id names its chat or its group, so `<chat>` may be left out |
135
135
  | `file resend [<chat>] <file>`, `file request [<chat>] <file>` | A file that stopped moving: sent again from here, or asked for again from the contact (a group's file: from whoever holds it); either goes on from the bytes the receiver holds (files/3) |
@@ -138,7 +138,7 @@ The rows are in alphabetical order of their first command, and every command of
138
138
  | `file wait [<chat>] <file> [--timeout s]` | Wait until a transfer ends: exit `0` when the file is all here, `1` with the transfer's error when it failed (`details.retry`: `file resend` can go on), `4` on timeout (default 300 s), `5` at once when a received file waits for you to take it (over 25 MiB, or a group's file that did not come by itself): the message names `file accept` |
139
139
  | `forward <chat\|group> <message>… --to <chat\|group>… [--force] [--wait none\|sent] [--timeout s]` | Forward messages to up to 5 chats and groups (`--to` again for each; `group:<id>` names a group when a chat has the same name; an id that starts with a dash is taken as it is, `--to -Ab…` or `--to=-Ab…`). Each is a new message of yours that says it was forwarded (`forwarded`, the hop count) and nothing of who wrote it. Files go from the bytes this profile holds, never fetched again; a group takes texts only. A text that looks like a seed, a key or ecash needs `--force`. Answers `{from, results: [{to, kind, messageIds, error}]}`; any refusal fails the command (exit 1) with the results in `details`. `--wait sent`: each text on its way (a group's taken by an edge), each file's transfer done |
140
140
  | `group create <name> [--mesh]`, `group join [<link> \| -]` | A community (a link anyone can open), or a private mesh. `group join` reads the link from stdin when none is given or `-` (on the command line it shows in `ps` and the shell's history, and the CLI warns). `group join` with the link of a community the profile was removed from asks to be let in again, and keeps its history |
141
- | `group edit <group> <message> [text… \| --text <text> \| --stdin] [--mention <member>]… [--force]` | Replace the text of a message you sent to the group (`<message>` is the `messageId` `group send` gave). Every member sees it in place, marked edited; mentions whose `@name` is still in the text stay, `--mention` adds more. Answers `{group, messageId, edits, sent, edges}`: `edges` and `sent` as for `group send` (`sent: false` while no edge took this edit, also while it waits for the pace); `--wait sent` and `--timeout` as for `group send`. The text the message already has is no edit: `sent: false, unchanged: true`. A private group's members whose edge is down get it when it opens, a community's with the catch-up; a member on an older app keeps the old text |
141
+ | `group edit <group> <message> [text… \| --text <text> \| --stdin] [--mention <member>]… [--force]` | Replace the text of a message you sent to the group (`<message>` is the `messageId` `group send` gave). Every member sees it in place, marked edited; mentions whose `@name` is still in the text stay, `--mention` adds more. Answers `{group, messageId, edits, sent, edges}`: `edges` and `sent` as for `group send` (`sent: false` while no edge took this edit, also while it waits for the pace); `--wait sent` and `--timeout` as for `group send`. The text the message already has is no edit: `sent: false, unchanged: true`. A profile that is not a member any more (removed from the group) gets `refused`, with the reason, as does `message delete <group> <message> --everyone`. A private group's members whose edge is down get it when it opens, a community's with the catch-up; a member on an older app keeps the old text |
142
142
  | `group hub <group> <member> [--pin \| --exclude \| --auto]` | Past 16 members: pin a member as a hub, keep one from being a hub, or leave it to their app (a daemon offers itself) |
143
143
  | `group invite <group> <chat>`, `group remove <group> <member>`, `group admin <group> <member>` | Membership, for the admin (each prints the group; `--show-secret` for its link) |
144
144
  | `group leave <group> --yes`, `group forget <group> --yes`, `group accept\|decline <group>` | Membership. Leaving deletes the group's history and files on this device, so it asks for `--yes` (`confirm`, exit 5, without it), as `group forget` does; forget also deletes a group you were removed from, which keeps its history. An admin's leave hands the role to a member who is online and names them: `{left, admin: {key, name}}` |
@@ -169,7 +169,7 @@ The rows are in alphabetical order of their first command, and every command of
169
169
  | `routine send <chat\|group> --name <name> --schedule "every day 01:00" [--cron "0 1 * * *"] [--state active\|paused] [--next <time>] [--run ok\|failed\|skipped[:summary]] [--link url]… [--id id] [--text <text>] [--json json\|-\|file] [--force]`, `routine update <chat\|group> <routine> [fields…]` | A routine card for something a bot runs on a schedule (WISP 405 · Status Cards): its name, schedule (and cron line, shown only), state, last run and result, next run and up to 10 recent runs. `--run` records a run now as the last one; `--next` takes milliseconds or a date (no zone: local time, a bare `2026-09-30` local midnight; `Z` or `+02:00` as given). Updates merge and are paced as `task update`'s, and wait as `task send` and `task update` do. The app shows it, and runs nothing |
170
170
  | `saved add\|remove <chat\|group> <message>`, `saved list` | Saved messages: mark a message of a chat or a group to find it again, kept for this profile on this device and never sent (the app shows the same list in its Saved view). `saved list` gives them the last saved first, each as it is now (an edit shows its latest text) with its `chat` or `group` and `savedAt`; a deleted message drops out |
171
171
  | `send <chat> [text…] [--reply <message>] [--button id:Label]… [--style id=primary\|neutral\|danger]… [--once] [--id id] [--stdin] [--force] [--wait none\|sent\|delivered] [--timeout s]` | Send text (arguments, or stdin); `--reply` quotes a message of the chat. `--button yes:Yes` (1 to 6; the id ends at the first colon; no two labels alike ignoring case and spaces, and no label that is another button's id, else exit 2) puts buttons under the text, which is the question and what older apps show, so say how to answer in words. `--once`: one answer a person. A question that goes on the DHT floor or into a hold (the contact's app closed) reaches them as text alone; the engine sends its buttons again once the chat is live, as an edit of the buttons alone (no `message.edited` for it). The answer adds `buttons` (the question's id, `ask-…` unless `--id`), `card`, and `pressable`: whether the contact's app shows buttons (null until it says). A press comes back as `button.pressed` ([Events](#events)) |
172
- | `service add <name> <http://127.0.0.1:port>`, `service share <service> <chat> [--off]`, `service list`, `service remove\|enable` | Share a web app on this machine, per contact. `service add` answers the new one as `service` (the id the others take); its old key `serviceId` stays beside it for one release |
172
+ | `service add <name> <http://127.0.0.1:port>`, `service share <service> <chat> [--off]`, `service list`, `service remove\|enable` | Share a web app on this machine, per contact. `service share` names its chat by the chat's id, its contact's key or a label given here, never only by the contact's own name or a prefix of its id. `service add` answers the new one as `service` (the id the others take); its old key `serviceId` stays beside it for one release |
173
173
  | `service peer <chat>`, `service open <chat> <service> [--port p]`, `service close <chat> <service>` | A contact's app on a loopback port here (daemon). `url` is a link for your browser, `http://<random>.localhost:<port>/.ghostly-open/<token>`: it sets the service's cookie and shows the app on a host name of its own; any other host name, or a request without that cookie, gets 404. Chrome, Edge and curl reach `*.localhost` names by themselves; Safari and Node's `fetch` on macOS may not (add the name to `/etc/hosts` for them) |
174
174
  | `settings get [--show-secret]`, `settings set <key> <json>` | Relays, Iroh relays, the HyperDHT relay, ICE servers, `sendTyping` (false: contacts are never told you type), … `<json>` as `-`, or none on a pipe, is read from stdin: a TURN password stays out of `ps` |
175
175
  | `status` | The profile, its chats, whether WebRTC and calls run, the last event seq |
@@ -547,7 +547,7 @@ A profile publishes on Pkarr within seconds of its first run (its `did:dht` reco
547
547
  public relays and the Mainline DHT unless told otherwise. To keep a private network or a test on its own relays from
548
548
  the start, run every command with `GHOSTLY_PKARR_RELAYS=http://…,…` (the Desktop reads the same variable): those are
549
549
  then the only Pkarr relays, the profile's `relays` setting is not used, and the Mainline DHT is left out unless
550
- `GHOSTLY_DHT_BOOTSTRAP` names your own nodes. `GHOSTLY_IROH_RELAYS=https://…,…` (`http://` on loopback) does the same
550
+ `GHOSTLY_DHT_BOOTSTRAP` names your own nodes. `GHOSTLY_IROH_RELAYS=https://…,…` (`http://` on loopback, at most five) does the same
551
551
  for Iroh: those are the only Iroh relays, whatever `irohRelays` says. `status` shows the relays in use (`discovery.relays`); `settings get`
552
552
  still shows the profile's own list, which is used again once the variable is unset. Without the variable,
553
553
  `settings set relays '["http://…"]'` before the first `daemon`, with `GHOSTLY_DHT=0` or `GHOSTLY_DHT_BOOTSTRAP`, does
@@ -1,15 +1,15 @@
1
- import { Au as toBase64Url, Bo as parseLocalTarget, Cu as MAX_AVATAR_LENGTH, Fr as TYPING_KINDS, Gn as GROUP_FILE_LIMITS, Ho as LIMITS, Ir as TYPING_REFRESH_MS, Ka as replySnippet, Ki as identityStatement, Rc as APP_PERMISSIONS, Ro as GhostlyHttpError, Rr as sanitizeTypingStatus, Sl as inviteLink, Uc as isAppUrl, X as groupName, Zc as appRef, ao as cardLine, ba as voiceLevel, cl as readImageMeta, da as sanitizeMime, fa as PLAYABLE_AUDIO, fo as claimedTime, ga as downsamplePeaks, ha as baseMime, ii as APP_DATA_MAX_BYTES, jo as AWAITING_PEER_MS, ku as randomBytes$1, lo as statusCardBytes, ma as VOICE_METER, pa as VOICE_LIMITS, ro as appCardId, so as checkStatusCard, tl as isAppRef, to as STATUS_CARD_LIMITS, ua as sanitizeFileName, va as parseVoiceMeta, wl as ownInviteRefusal, wu as sanitizeAvatar, ya as voiceDownloadName } from "./src-1RU4TilT.js";
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";
2
3
  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-DjQc5XXv.js";
4
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-Cks7FA_o.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-ClI13rdv.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-BS2qq_vV.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";
8
8
  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, 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-C-_PWZvy.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
10
  import { a as checkShownName } from "./profiles-MFtCmJwK.js";
11
- import { t as BACKUP_METHODS } from "./backup-beKfbfNk.js";
12
- import { o as checkedBundle } from "./apps-DKIe8VjF.js";
11
+ import { t as BACKUP_METHODS } from "./backup-CyTZhu28.js";
12
+ import { o as checkedBundle } from "./apps-DqTyZ40T.js";
13
13
  import { generateMnemonic } from "@scure/bip39";
14
14
  import { wordlist } from "@scure/bip39/wordlists/english.js";
15
15
  import { execFile, spawn } from "node:child_process";
@@ -836,12 +836,27 @@ async function voiceOf(params, path, mime, size) {
836
836
  throw new CliError("bad_request", `A voice note's waveform is 1 to ${VOICE_LIMITS.maxBars} peaks from 0 to 255`);
837
837
  }
838
838
  /**
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.
842
+ */
843
+ async function sendable(path, mime, voice) {
844
+ const source = await openAsBlob(path, { type: mime });
845
+ if (voice) return source;
846
+ try {
847
+ return await withoutPictureMetadata(source, mime) ?? source;
848
+ } 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
+ throw error;
851
+ }
852
+ }
853
+ /**
839
854
  * A file announced in a group (WISP 503): its bytes staged under a group file id with their digest, as a chat's are, then
840
855
  * the announcement. This device is its first holder and serves the members who ask.
841
856
  */
842
- async function sendToGroup(ctx, params, group, path, size) {
843
- if (size > GROUP_FILE_LIMITS.maxBytes) throw new CliError("refused", `Too large for a group (at most ${GROUP_FILE_LIMITS.maxBytes} bytes)`);
844
- if (!size) throw new CliError("refused", "An empty file cannot go to a group");
857
+ async function sendToGroup(ctx, params, group, path, picked) {
858
+ if (picked > GROUP_FILE_LIMITS.maxBytes) throw new CliError("refused", `Too large for a group (at most ${GROUP_FILE_LIMITS.maxBytes} bytes)`);
859
+ if (!picked) throw new CliError("refused", "An empty file cannot go to a group");
845
860
  const mime = mimeOf(path, str(params, "mime"));
846
861
  const replyTo = str(params, "reply");
847
862
  if (replyTo) {
@@ -849,8 +864,9 @@ async function sendToGroup(ctx, params, group, path, size) {
849
864
  }
850
865
  const check = await node(ctx).groupFileCheck({ groupId: group.id });
851
866
  if (check.error) throw check.refused ? new CliError("refused", check.error) : groupSendRefused(check.error);
852
- const { voice, warning } = await voiceOf(params, path, mime, size);
853
- const source = await openAsBlob(path, { type: mime });
867
+ const { voice, warning } = await voiceOf(params, path, mime, picked);
868
+ const source = await sendable(path, mime, voice);
869
+ const size = source.size;
854
870
  const image = voice ? void 0 : await readImageMeta(source, mime);
855
871
  const fileId = groupFileId(group.id, "out");
856
872
  const file = {
@@ -1000,13 +1016,13 @@ var FILE_METHODS = {
1000
1016
  if (!await findMessage(ctx, link.id, (m) => m.id === replyTo || replyRef(m) === replyTo)) throw new CliError("not_found", "That message is not in this chat, or cannot be replied to");
1001
1017
  }
1002
1018
  const { voice, warning } = await voiceOf(params, path, mime, info.size);
1003
- const source = await openAsBlob(path, { type: mime });
1019
+ const source = await sendable(path, mime, voice);
1004
1020
  const image = voice ? void 0 : await readImageMeta(source, mime);
1005
1021
  const wireId = toBase64Url(randomBytes$1(12));
1006
1022
  const file = {
1007
1023
  id: `${link.id}-out-${wireId}`,
1008
1024
  name: sanitizeFileName(str(params, "name") ?? basename(path)),
1009
- size: info.size,
1025
+ size: source.size,
1010
1026
  mime,
1011
1027
  ...voice ? { voice } : {},
1012
1028
  ...image ? { image } : {}
@@ -1128,6 +1144,7 @@ var FILE_METHODS = {
1128
1144
  if (outgoing && (action === "accept" || action === "decline")) throw new CliError("bad_request", "A file sent from here is not accepted or declined: file cancel stops it");
1129
1145
  await refuseAllHere();
1130
1146
  const transfer = state(ctx).transfers[fileId] ?? (await fileStore.get(fileId).catch(() => void 0))?.transfer;
1147
+ if (action === "pause" && transfer?.stage === "verifying") throw new CliError("refused", "Too late to pause: it is being checked");
1131
1148
  if (transfer?.state === "failed") throw new CliError("refused", `It ended: ${transfer.error ?? "failed"}${outgoing && transfer.retry ? " (file resend sends it again)" : ""}`);
1132
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");
1133
1150
  }
@@ -2030,28 +2047,31 @@ function groupJson(group, showSecret = false) {
2030
2047
  * engine enforces who may do what (the admin); these check the arguments and name members.
2031
2048
  */
2032
2049
  /**
2033
- * A member by key, unique key prefix or name; never this profile itself. A whole key is that member, whatever another
2034
- * member calls itself; a prefix and a name stand side by side (two members is an error, not a guess).
2050
+ * A member by key, unique key prefix or name; never this profile itself (`myName`: its name, which its own row lacks).
2051
+ * A whole key is that member, whatever another member calls itself; a prefix and a name stand side by side (two
2052
+ * members is an error, not a guess).
2035
2053
  */
2036
- function findMember(group, ref) {
2054
+ function findMember(group, ref, myName) {
2037
2055
  const lower = ref.toLowerCase();
2038
2056
  const others = group.members.filter((m) => !m.me);
2039
2057
  const byKey = others.filter((m) => m.key === ref);
2040
2058
  const matches = byKey.length ? byKey : others.filter((m) => m.key.startsWith(ref) || m.nick?.trim().toLowerCase() === lower);
2041
2059
  if (matches.length === 1) return matches[0];
2042
- throw matches.length ? new CliError("bad_request", `${JSON.stringify(ref)} names more than one member`) : noMember(group, ref);
2060
+ throw matches.length ? new CliError("bad_request", `${JSON.stringify(ref)} names more than one member`) : noMember(group, ref, myName);
2043
2061
  }
2044
2062
  /**
2045
- * A ref no other member answers to. When it is this profile's own key (or a prefix of it), it says so: "No member"
2046
- * read as if this profile were not in the group.
2063
+ * A ref no other member answers to. When it is this profile's own key (or a prefix of it), or its own name, it says
2064
+ * so: "No member" read as if this profile were not in the group.
2047
2065
  */
2048
- function noMember(group, ref) {
2049
- if (group.members.some((m) => m.me && m.key.startsWith(ref))) return new CliError("bad_request", `${JSON.stringify(ref)} is you: name another member of ${group.name}`);
2066
+ function noMember(group, ref, myName) {
2067
+ if (!!myName?.trim() && myName.trim().toLowerCase() === ref.toLowerCase() || group.members.some((m) => m.me && m.key.startsWith(ref))) return new CliError("bad_request", `${JSON.stringify(ref)} is you: name another member of ${group.name}`);
2050
2068
  return new CliError("not_found", `No member ${JSON.stringify(ref)} in ${group.name}`);
2051
2069
  }
2052
2070
  /**
2053
2071
  * A picture as Ghostly sends it: a square JPEG data URL, checked as a contact would check it. The app scales and
2054
2072
  * crops any image to 128×128; here the file must already be a JPEG within the bounds (no image library on Node).
2073
+ * It goes without its metadata (where it was taken, the device, the time), as the app's re-encoded one does; a
2074
+ * picture whose metadata cannot be removed is refused, never sent as it was.
2055
2075
  */
2056
2076
  async function pictureFrom(path) {
2057
2077
  let bytes;
@@ -2060,7 +2080,14 @@ async function pictureFrom(path) {
2060
2080
  } catch (error) {
2061
2081
  throw localFileError(error, path) ?? new CliError("not_found", `No file ${path}`);
2062
2082
  }
2063
- const url = `data:image/jpeg;base64,${bytes.toString("base64")}`;
2083
+ let parts;
2084
+ try {
2085
+ parts = stripPictureMetadata(bytes, "application/octet-stream");
2086
+ } catch (error) {
2087
+ 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);
2088
+ throw error;
2089
+ }
2090
+ const url = `data:image/jpeg;base64,${(parts ? Buffer.concat(parts) : bytes).toString("base64")}`;
2064
2091
  const checked = sanitizeAvatar(url);
2065
2092
  if (!checked) throw new CliError("bad_request", `A picture is a JPEG of at most 512×512 px and about ${Math.floor(MAX_AVATAR_LENGTH * .74 / 1e3)} KB (128×128 is what the app sends): resize it first`);
2066
2093
  return checked;
@@ -2069,6 +2096,8 @@ async function picture(params) {
2069
2096
  if (bool(params, "clear")) return null;
2070
2097
  return pictureFrom(str(params, "path", true));
2071
2098
  }
2099
+ /** The member `params.member` names in `group`, this profile's own name said to be it. */
2100
+ var member = (ctx, group, params) => findMember(group, str(params, "member", true), state(ctx).settings.nick);
2072
2101
  var view = (ctx, id, params) => groupJson(state(ctx).groups.find((g) => g.id === id) ?? groupOf(ctx, { group: id }), bool(params, "showSecret"));
2073
2102
  var GROUP_ADMIN_METHODS = {
2074
2103
  async "group.invite"(ctx, params) {
@@ -2084,7 +2113,7 @@ var GROUP_ADMIN_METHODS = {
2084
2113
  const group = groupOf(ctx, params);
2085
2114
  await node(ctx).removeGroupMember({
2086
2115
  groupId: group.id,
2087
- key: findMember(group, str(params, "member", true)).key
2116
+ key: member(ctx, group, params).key
2088
2117
  });
2089
2118
  return view(ctx, group.id, params);
2090
2119
  },
@@ -2092,7 +2121,7 @@ var GROUP_ADMIN_METHODS = {
2092
2121
  const group = groupOf(ctx, params);
2093
2122
  await node(ctx).makeGroupAdmin({
2094
2123
  groupId: group.id,
2095
- key: findMember(group, str(params, "member", true)).key
2124
+ key: member(ctx, group, params).key
2096
2125
  });
2097
2126
  return view(ctx, group.id, params);
2098
2127
  },
@@ -2106,7 +2135,7 @@ var GROUP_ADMIN_METHODS = {
2106
2135
  ].includes(role)) throw new CliError("bad_request", "role is pin, exclude or auto");
2107
2136
  await node(ctx).setGroupHub({
2108
2137
  groupId: group.id,
2109
- key: findMember(group, str(params, "member", true)).key,
2138
+ key: member(ctx, group, params).key,
2110
2139
  role: role === "auto" ? null : role
2111
2140
  });
2112
2141
  return view(ctx, group.id, params);
@@ -2782,7 +2811,7 @@ var SERVICE_METHODS = {
2782
2811
  };
2783
2812
  },
2784
2813
  async "service.share"(ctx, params) {
2785
- const link = chatOf(ctx, params);
2814
+ const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
2786
2815
  const shared = !bool(params, "off");
2787
2816
  const serviceId = serviceOf(ctx, params);
2788
2817
  await node(ctx).setServiceShared({
@@ -2929,6 +2958,7 @@ var APP_SERVE_METHODS = {
2929
2958
  if (grant.includes("internet")) throw new CliError("refused", "internet cannot be granted here: no app's page runs on the CLI, and a bot reaches the network as its own program");
2930
2959
  const given = str(params, "url");
2931
2960
  if (given !== void 0 && !isAppUrl(given)) throw new CliError("bad_request", "url is where a contact's app reads the bundle: https only, no user or password, jsDelivr only at a full commit");
2961
+ if (given !== void 0 && /[?#]/.test(given)) throw new CliError("bad_request", "url goes to contacts on the app's card: no query or fragment (a private repository's token rides there); publish the app in a public repository");
2932
2962
  const { bundle, url } = await checkedBundle(source);
2933
2963
  const m = bundle.manifest;
2934
2964
  if (!m.permissions.includes("chat")) throw new CliError("refused", `${m.title} does not ask for chat: it talks to no contact, so a bot has nothing to speak for it`);
@@ -2940,7 +2970,7 @@ var APP_SERVE_METHODS = {
2940
2970
  missing
2941
2971
  });
2942
2972
  const ref = appRef(m.publisher, m.name);
2943
- const cardUrl = given ?? url ?? m.sources?.[0];
2973
+ const cardUrl = appCardUrl(given ?? url ?? m.sources?.[0]);
2944
2974
  const app = {
2945
2975
  ref,
2946
2976
  title: m.title,
@@ -3839,7 +3869,8 @@ var inviteShown = /* @__PURE__ */ new WeakMap();
3839
3869
  * Refuses DHT only (a hold, `chat transport dht`) while a call is on in the chat. A call's signals cross the live
3840
3870
  * link: off it, the call talked on over its own connection, and a hang-up from either side never reached the other
3841
3871
  * (that call ended only when its media stalled out, 16 s later). Removing the chat (`chat remove`) is refused the same
3842
- * way: the call talked on in a chat gone from this device, and its hang-up had no chat left to cross.
3872
+ * way: the call talked on in a chat gone from this device, and its hang-up had no chat left to cross. `engine.call`
3873
+ * refuses the raw calls that do the same (`removeLink`, `setChatTransport` / `setDeliveryMode` to `dht`).
3843
3874
  */
3844
3875
  function noCallOn(ctx, linkId, then) {
3845
3876
  const call = ctx.calls.list().find((c) => c.chat === linkId);
@@ -4181,7 +4212,7 @@ var METHODS = {
4181
4212
  ...messageId && { messageId },
4182
4213
  remove
4183
4214
  });
4184
- if (result.error) throw new CliError(result.refused || /Only the admin/.test(result.error) ? "refused" : /not in this chat|Nothing is pinned/.test(result.error) ? "not_found" : "bad_request", result.error);
4215
+ if (result.error) throw new CliError(result.refused || /Only the admin/.test(result.error) ? "refused" : /not in this (?:chat|group)|Nothing is pinned/.test(result.error) ? "not_found" : "bad_request", result.error);
4185
4216
  if (target.group) return {
4186
4217
  group: target.id,
4187
4218
  messageId: remove ? null : messageId,
@@ -4696,6 +4727,10 @@ var METHODS = {
4696
4727
  });
4697
4728
  const problem = engineParamsProblem(method, args);
4698
4729
  if (problem) throw wrong(problem);
4730
+ if (typeof args?.linkId === "string") {
4731
+ if (method === "removeLink") noCallOn(ctx, args.linkId, "remove the chat");
4732
+ else if (method === "setChatTransport" && args.transport === "dht" || method === "setDeliveryMode" && args.mode === "dht") noCallOn(ctx, args.linkId, "put the chat on DHT only");
4733
+ }
4699
4734
  if (args && ENGINE_SENDS.has(method) && !bool(params, "force")) await guardEngineSend(ctx, method, args);
4700
4735
  if (method === "getMessages") return node(ctx).getMessages(str(args ?? {}, "linkId", true));
4701
4736
  if (method === "getState") return state(ctx);
@@ -4792,7 +4827,7 @@ async function react(ctx, linkId, params) {
4792
4827
  messageId,
4793
4828
  emoji: emoji ?? ""
4794
4829
  });
4795
- if (result.error) throw new CliError(result.refused ? "refused" : /not in this chat|No reaction of yours/.test(result.error) ? "not_found" : "bad_request", result.error);
4830
+ if (result.error) throw new CliError(result.refused ? "refused" : /not in this (?:chat|group)|No reaction of yours/.test(result.error) ? "not_found" : "bad_request", result.error);
4796
4831
  return {
4797
4832
  messageId,
4798
4833
  emoji: emoji || null,
@@ -4987,4 +5022,4 @@ async function callApi(ctx, method, params = {}) {
4987
5022
  //#endregion
4988
5023
  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 };
4989
5024
 
4990
- //# sourceMappingURL=api-I_KbuXHa.js.map
5025
+ //# sourceMappingURL=api-BpQC8dAw.js.map