@ghostlytools/cli 1.7.4 → 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.
- package/README.md +16 -10
- package/SKILL.md +1 -1
- package/dist/assets/{api-D3i2hwy0.js → api-BpQC8dAw.js} +121 -40
- package/dist/assets/api-BpQC8dAw.js.map +1 -0
- package/dist/assets/{api-Chhvpwok.js → api-CttDF-S5.js} +2 -2
- package/dist/assets/{apiKit-BtsHrnoo.js → apiKit-CSMeHKgo.js} +17 -5
- package/dist/assets/{apiKit-BtsHrnoo.js.map → apiKit-CSMeHKgo.js.map} +1 -1
- package/dist/assets/{apps-BHl97rHs.js → apps-DqTyZ40T.js} +8 -7
- package/dist/assets/apps-DqTyZ40T.js.map +1 -0
- package/dist/assets/{apps-BFJTqvAt.js → apps-DzFMdVt6.js} +1 -1
- package/dist/assets/{arkade-BFE8KkEE.js → arkade-Cu3TbPxC.js} +2 -2
- package/dist/assets/{arkade-BFE8KkEE.js.map → arkade-Cu3TbPxC.js.map} +1 -1
- package/dist/assets/{backup-Bbsr6nDi.js → backup-CLZOORFC.js} +1 -1
- package/dist/assets/{backup-CxACdtQX.js → backup-CyTZhu28.js} +6 -6
- package/dist/assets/{backup-CxACdtQX.js.map → backup-CyTZhu28.js.map} +1 -1
- package/dist/assets/{buttons-CieBtXEO.js → buttons-Bd9fR31r.js} +177 -23
- package/dist/assets/buttons-Bd9fR31r.js.map +1 -0
- package/dist/assets/buttons-c4CJnL6i.js +2 -0
- package/dist/assets/{daemonProof-QmtwDj-N.js → daemonProof-DtrL5lE5.js} +2 -2
- package/dist/assets/{daemonProof-QmtwDj-N.js.map → daemonProof-DtrL5lE5.js.map} +1 -1
- package/dist/assets/{envelope-DYiGwzq_.js → envelope-CGfUsR1m.js} +2 -2
- package/dist/assets/{envelope-DYiGwzq_.js.map → envelope-CGfUsR1m.js.map} +1 -1
- package/dist/assets/{errors-QUGP-jIF.js → errors-R4S2SAEM.js} +7 -2
- package/dist/assets/errors-R4S2SAEM.js.map +1 -0
- package/dist/assets/fixedHosts-BiukTsd9.js +24 -0
- package/dist/assets/fixedHosts-BiukTsd9.js.map +1 -0
- package/dist/assets/{ghostly_iroh_web-CO0onry8.js → ghostly_iroh_web-BzAXJUYH.js} +10 -10
- package/dist/assets/{ghostly_iroh_web-CO0onry8.js.map → ghostly_iroh_web-BzAXJUYH.js.map} +1 -1
- package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
- package/dist/assets/{groupFiles-CBJIEvCE.js → groupFiles-CeF9nPv9.js} +759 -29
- package/dist/assets/groupFiles-CeF9nPv9.js.map +1 -0
- package/dist/assets/{host-Va-r_KJz.js → host-CKAehWP6.js} +65 -29
- package/dist/assets/host-CKAehWP6.js.map +1 -0
- package/dist/assets/hyperdhtRelay-1wzya_0L.js +25 -0
- package/dist/assets/hyperdhtRelay-1wzya_0L.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-B2uK9tJv.js → hyperdhtRelay-B8Pdykhg.js} +15 -3
- package/dist/assets/hyperdhtRelay-B8Pdykhg.js.map +1 -0
- package/dist/assets/{irohWeb-DxeEgQ-W.js → irohWeb-D6tAPHZa.js} +11 -7
- package/dist/assets/{irohWeb-DxeEgQ-W.js.map → irohWeb-D6tAPHZa.js.map} +1 -1
- package/dist/assets/{main-BX4oPWCJ.js → main-BDY-pfpz.js} +121 -37
- package/dist/assets/main-BDY-pfpz.js.map +1 -0
- package/dist/assets/{mainline-IfWQOB-J.js → mainline-3ueXpFQL.js} +2 -2
- package/dist/assets/{mainline-IfWQOB-J.js.map → mainline-3ueXpFQL.js.map} +1 -1
- package/dist/assets/mints-BaOmx517.js +2 -0
- package/dist/assets/{mints-BrlY773j.js → mints-j5XAOk4f.js} +15 -3
- package/dist/assets/mints-j5XAOk4f.js.map +1 -0
- package/dist/assets/{networkReason-N2vAaoth.js → networkReason-DhJYOomu.js} +2 -2
- package/dist/assets/{networkReason-N2vAaoth.js.map → networkReason-DhJYOomu.js.map} +1 -1
- package/dist/assets/{nwc-CzyCtNK2.js → nwc-B1Quqda-.js} +3 -3
- package/dist/assets/{nwc-CzyCtNK2.js.map → nwc-B1Quqda-.js.map} +1 -1
- package/dist/assets/{nwcProvider-DjWmEn3j.js → nwcProvider-DUB6xO-b.js} +2 -2
- package/dist/assets/{nwcProvider-DjWmEn3j.js.map → nwcProvider-DUB6xO-b.js.map} +1 -1
- package/dist/assets/ownDid-BfqHJdA6.js +281 -0
- package/dist/assets/ownDid-BfqHJdA6.js.map +1 -0
- package/dist/assets/{profiles-DcCeOi7J.js → profiles-MFtCmJwK.js} +3 -3
- package/dist/assets/{profiles-DcCeOi7J.js.map → profiles-MFtCmJwK.js.map} +1 -1
- package/dist/assets/{registry-BmS02J5h.js → registry-CZTmtSws.js} +1 -1
- package/dist/assets/{registry-CeW8XEQc.js → registry-DwlTNQjr.js} +5 -246
- package/dist/assets/registry-DwlTNQjr.js.map +1 -0
- package/dist/assets/{resolve-BvHkAhDH.js → resolve-BVwhiYjj.js} +3 -268
- package/dist/assets/resolve-BVwhiYjj.js.map +1 -0
- package/dist/assets/{restoredRows-mTTp3XNs.js → restoredRows-BCRCjhdF.js} +26 -2
- package/dist/assets/{restoredRows-mTTp3XNs.js.map → restoredRows-BCRCjhdF.js.map} +1 -1
- package/dist/assets/{server-BUcJo4vz.js → server-Br3XPwFG.js} +1001 -243
- package/dist/assets/server-Br3XPwFG.js.map +1 -0
- package/dist/assets/{src-BB5-5P3s.js → src-C4sOH4zH.js} +1109 -181
- package/dist/assets/src-C4sOH4zH.js.map +1 -0
- package/dist/assets/sshForges-CQQomStK.js +253 -0
- package/dist/assets/sshForges-CQQomStK.js.map +1 -0
- package/dist/assets/{translate-2WyaRVCr.js → translate-C2aNyUkR.js} +20 -10
- package/dist/assets/translate-C2aNyUkR.js.map +1 -0
- package/dist/assets/{usdt-BLazHiaP.js → usdt-CMwatDnQ.js} +3 -3
- package/dist/assets/{usdt-BLazHiaP.js.map → usdt-CMwatDnQ.js.map} +1 -1
- package/dist/assets/waitNotice-Ck3el3_Z.js +45 -0
- package/dist/assets/waitNotice-Ck3el3_Z.js.map +1 -0
- package/dist/assets/{words-BaumxjXe.js → words-CqN2KG1r.js} +6 -3
- package/dist/assets/words-CqN2KG1r.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/examples/claude-code-agent.sh +1 -1
- package/package.json +1 -1
- package/dist/assets/api-D3i2hwy0.js.map +0 -1
- package/dist/assets/apps-BHl97rHs.js.map +0 -1
- package/dist/assets/buttons-CieBtXEO.js.map +0 -1
- package/dist/assets/buttons-YtAj3R_E.js +0 -2
- package/dist/assets/errors-QUGP-jIF.js.map +0 -1
- package/dist/assets/groupFiles-CBJIEvCE.js.map +0 -1
- package/dist/assets/host-Va-r_KJz.js.map +0 -1
- package/dist/assets/hyperdhtRelay-B2uK9tJv.js.map +0 -1
- package/dist/assets/hyperdhtRelay-BT_wRxab.js +0 -21
- package/dist/assets/hyperdhtRelay-BT_wRxab.js.map +0 -1
- package/dist/assets/main-BX4oPWCJ.js.map +0 -1
- package/dist/assets/mints-BrlY773j.js.map +0 -1
- package/dist/assets/mints-CqTdA4Gk.js +0 -2
- package/dist/assets/registry-CeW8XEQc.js.map +0 -1
- package/dist/assets/resolve-BvHkAhDH.js.map +0 -1
- package/dist/assets/server-BUcJo4vz.js.map +0 -1
- package/dist/assets/src-BB5-5P3s.js.map +0 -1
- package/dist/assets/translate-2WyaRVCr.js.map +0 -1
- package/dist/assets/words-BaumxjXe.js.map +0 -1
package/README.md
CHANGED
|
@@ -92,9 +92,12 @@ waits until the message went out. Bots should run the daemon: a one-shot is offl
|
|
|
92
92
|
|
|
93
93
|
Every command prints one JSON object on stdout. A failure prints `{"error":{"code","message"}}` and exits with:
|
|
94
94
|
`1` failed (the engine or the network refused), `2` usage, `3` not found, `4` timed out, `5` needs a confirmation
|
|
95
|
-
(`--force`, `--yes`, `--confirm-real`)
|
|
95
|
+
(`--force`, `--yes`, `--confirm-real`), `130` stopped with Ctrl-C (`interrupted`: a one-shot closes its profile first,
|
|
96
|
+
and a line on stderr says what became of what it waited on). A daemon that does not answer a read or `daemon status` within 15 seconds, or
|
|
96
97
|
a command that waits (`chat wait`, `file wait`, `--wait`) within its `--timeout` plus 10, is a timeout too (`4`,
|
|
97
|
-
`details.method`); `ghostly daemon restart` is the way out ([docs/CLI.md](../../docs/CLI.md#what-it-does)).
|
|
98
|
+
`details.method`); `ghostly daemon restart` is the way out ([docs/CLI.md](../../docs/CLI.md#what-it-does)). On a
|
|
99
|
+
terminal, a command that waits says on stderr what it waits for once it has waited a second; nothing is said there on
|
|
100
|
+
a pipe. A `<chat>` is
|
|
98
101
|
its id, a unique prefix of it, or its name; a `<group>` too.
|
|
99
102
|
|
|
100
103
|
The rows are in alphabetical order of their first command, and every command of `ghostly help` has one
|
|
@@ -126,16 +129,16 @@ The rows are in alphabetical order of their first command, and every command of
|
|
|
126
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 |
|
|
127
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 |
|
|
128
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 |
|
|
129
|
-
| `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` |
|
|
130
133
|
| `events [--since seq] [--translate lang]` | What the event journal holds, without following ([Translation](#translation)) |
|
|
131
|
-
| `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). A file's id names its chat or its group, so `<chat>` may be left out |
|
|
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 |
|
|
132
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) |
|
|
133
136
|
| `file save [<chat>] <file> [--dir d \| --path p] [--force] [--wait [--timeout s]]` | Write a received file to disk: to `--path`, or into `--dir` under the name its sender gave it, with a `_` first when that name starts with `-`, so no tool run in the folder takes it for an option; a voice message goes in under the name Ghostly makes for it (`Ghostly voice <date time>`), and when that name is taken (two of one second) under a free `… (2)` (the answer's `path` is what was written). Never over a file without `--force`; an unfinished one says how many bytes are here; `--wait` waits for it first |
|
|
134
137
|
| `file send <chat\|group> <path> [--name n] [--mime t] [--voice [ms] [--peaks …]] [--reply <message>]` | A file, or a voice note (its length and waveform measured from the file unless given); `--reply` quotes a message, as `send --reply` does. Answers the message's `messageId` (what `message delete`, `react` and `pin` take) and the file's id. To a group (`group:<id>` when a chat has the same name), up to 100 MiB: every member sees it at once and each member's app fetches it from a member who has it (WISP 503) |
|
|
135
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` |
|
|
136
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 |
|
|
137
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 |
|
|
138
|
-
| `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 |
|
|
139
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) |
|
|
140
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) |
|
|
141
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}}` |
|
|
@@ -166,7 +169,7 @@ The rows are in alphabetical order of their first command, and every command of
|
|
|
166
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 |
|
|
167
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 |
|
|
168
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)) |
|
|
169
|
-
| `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 |
|
|
170
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) |
|
|
171
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` |
|
|
172
175
|
| `status` | The profile, its chats, whether WebRTC and calls run, the last event seq |
|
|
@@ -323,7 +326,8 @@ chat (`chat list`, `chat show`, `chat rename`, …) and `engine getState` print
|
|
|
323
326
|
none: a copy another member handed on without it, completed by the author's, or an edit that names this profile; once), `group.sent`, `group.event`, `file.offered` (a file over 25 MiB waits for `file accept`),
|
|
324
327
|
`file.stage`, `file.done`, `file.failed` (each with `chat`, or `group` for a group's file, `file`, `messageId`), `chat.held` and
|
|
325
328
|
`chat.released` (`chat disconnect --hold`), `identity.received` and `identity.status` (what a contact
|
|
326
|
-
showed, as checked here
|
|
329
|
+
showed, as checked here: `identity` with `status`, and `error`, why it is not verified, or null; each change of
|
|
330
|
+
status is a new `identity.status`, even back to one it had before), `identity.approval` and `identity.progress` (a signer waits on a link or a code), `group.deleted` (`{group, messageId}`: a group's message deleted, not the group), `group.removed`, `payment.created` and
|
|
327
331
|
`payment.updated` (`payment`: id, chat, kind request|payment, direction in|out, amount, memo, state pending|
|
|
328
332
|
settled|failed, network, method), `call.incoming`, `call.outgoing`, `call.connected` and `call.ended` (voice
|
|
329
333
|
calls: see [Calls](#calls)), `app.opened` (`chat`, `app`, `version`), `app.closed` (`chat`, `app`, and `offline`
|
|
@@ -357,8 +361,10 @@ chat (`chat list`, `chat show`, `chat rename`, …) and `engine getState` print
|
|
|
357
361
|
unpinned), `ref` the id both sides know it by, and `by` `peer` or a member key.
|
|
358
362
|
- `--type message.received` keeps one type; `--type message` (or `message.`, `message.*`) a family. A family deeper
|
|
359
363
|
down ends in "." (`group.typing.`): `group.message` is that type alone.
|
|
360
|
-
- `--from <chat|key>` and `--group <group>` (again for more): an allowlist. Only the chats (id,
|
|
361
|
-
contact's `peer` key, which also matches a chat made later) and groups named get through;
|
|
364
|
+
- `--from <chat|key>` and `--group <group>` (again for more): an allowlist. Only the chats (id, a label given here,
|
|
365
|
+
or the contact's `peer` key, which also matches a chat made later) and groups (id, prefix or name) named get through;
|
|
366
|
+
a prefix of a chat's id or the name its contact gave itself is refused (another contact could call itself that:
|
|
367
|
+
name the chat first with `chat rename`); any other chat's or
|
|
362
368
|
group's event stops before `--exec`, `--webhook` and stdout (the message stays in the chat; the cursor moves past
|
|
363
369
|
it). The profile's own events (`daemon.started`, `events.gap`, `identity.approval`) pass. Names become ids once,
|
|
364
370
|
at the start. A flag, not profile state: each listener (each agent) has its own ([docs/CLI.md](../../docs/CLI.md#allowlist)).
|
|
@@ -541,7 +547,7 @@ A profile publishes on Pkarr within seconds of its first run (its `did:dht` reco
|
|
|
541
547
|
public relays and the Mainline DHT unless told otherwise. To keep a private network or a test on its own relays from
|
|
542
548
|
the start, run every command with `GHOSTLY_PKARR_RELAYS=http://…,…` (the Desktop reads the same variable): those are
|
|
543
549
|
then the only Pkarr relays, the profile's `relays` setting is not used, and the Mainline DHT is left out unless
|
|
544
|
-
`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
|
|
545
551
|
for Iroh: those are the only Iroh relays, whatever `irohRelays` says. `status` shows the relays in use (`discovery.relays`); `settings get`
|
|
546
552
|
still shows the profile's own list, which is used again once the variable is unset. Without the variable,
|
|
547
553
|
`settings set relays '["http://…"]'` before the first `daemon`, with `GHOSTLY_DHT=0` or `GHOSTLY_DHT_BOOTSTRAP`, does
|
package/SKILL.md
CHANGED
|
@@ -387,7 +387,7 @@ needs a person who holds the key: leave that to the owner.
|
|
|
387
387
|
## Rules the CLI enforces
|
|
388
388
|
|
|
389
389
|
- Output is JSON. A failure is `{"error":{"code","message"}}` with exit 1 (failed), 2 (usage), 3 (not found),
|
|
390
|
-
4 (timed out)
|
|
390
|
+
4 (timed out), 5 (needs `--force`, `--yes` or `--confirm-real`) or 130 (stopped with Ctrl-C, `interrupted`).
|
|
391
391
|
- `send` (and `ghostly engine sendMessage` and the other sends through `engine`) refuses text that looks like a recovery
|
|
392
392
|
phrase, a private key or a Cashu token unless `--force`.
|
|
393
393
|
- Spending real money (Mainnet) needs `--confirm-real`.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
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 { 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-CBJIEvCE.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-
|
|
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-
|
|
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-
|
|
8
|
-
import { i as localFileError, r as asCliError, t as CliError } from "./errors-
|
|
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-
|
|
10
|
-
import { a as checkShownName } from "./profiles-
|
|
11
|
-
import { t as BACKUP_METHODS } from "./backup-
|
|
12
|
-
import { o as checkedBundle } from "./apps-
|
|
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
|
+
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";
|
|
13
13
|
import { generateMnemonic } from "@scure/bip39";
|
|
14
14
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
15
|
+
import { execFile, spawn } from "node:child_process";
|
|
15
16
|
import { openAsBlob, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
|
-
import { access, constants as constants$1, copyFile, link, open, readFile, rename, rm, stat } from "node:fs/promises";
|
|
17
|
+
import { access, constants as constants$1, copyFile, link, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
17
18
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
18
|
-
import { spawn } from "node:child_process";
|
|
19
19
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
20
20
|
import { createServer } from "node:http";
|
|
21
21
|
import { Readable } from "node:stream";
|
|
@@ -751,6 +751,32 @@ function filesOf(messages, transferOf) {
|
|
|
751
751
|
}
|
|
752
752
|
/** A file's size as a person reads it: "40 MB", "26.2 MB". */
|
|
753
753
|
var megabytes = (size) => `${Math.round(size / 1e5) / 10} MB`;
|
|
754
|
+
/**
|
|
755
|
+
* Where an unfinished transfer stands, in words, for a person reading a timeout: the stage's id ("asking", "waiting")
|
|
756
|
+
* stays in `details.stage` for a bot. A group's file says why it waits (`note`), as the app does.
|
|
757
|
+
*/
|
|
758
|
+
function stageWords(transfer) {
|
|
759
|
+
switch (transfer.stage) {
|
|
760
|
+
case "preparing": return "getting it ready to send";
|
|
761
|
+
case "waiting": return transfer.note ?? "waiting for a connection to the contact";
|
|
762
|
+
case "asking": return transfer.direction === "in" ? "waiting for you to take it (file accept)" : "waiting for the contact to take it";
|
|
763
|
+
case "queued": return "waiting its turn";
|
|
764
|
+
case "paused": return transfer.pausedBy === "peer" ? "paused by the contact" : "paused here (file resume)";
|
|
765
|
+
case "verifying": return "every byte here, checking it";
|
|
766
|
+
default: return String(transfer.stage);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* A transfer that waits for a person's decision (`asking`), with whose: `me` (`file accept` takes it here) or `contact`
|
|
771
|
+
* (theirs). A received file's `transferring` alone read as if it were moving.
|
|
772
|
+
*/
|
|
773
|
+
function withWaitingFor(transfer) {
|
|
774
|
+
if (transfer?.state !== "transferring" || transfer.stage !== "asking") return transfer;
|
|
775
|
+
return {
|
|
776
|
+
...transfer,
|
|
777
|
+
waitingFor: transfer.direction === "in" ? "me" : "contact"
|
|
778
|
+
};
|
|
779
|
+
}
|
|
754
780
|
/** The chat or the group a file command names (`findChatOrGroup`). */
|
|
755
781
|
var chatOrGroupOf = (ctx, params) => findChatOrGroup(state(ctx).links, state(ctx).groups, str(params, "chat", true));
|
|
756
782
|
/**
|
|
@@ -810,12 +836,27 @@ async function voiceOf(params, path, mime, size) {
|
|
|
810
836
|
throw new CliError("bad_request", `A voice note's waveform is 1 to ${VOICE_LIMITS.maxBars} peaks from 0 to 255`);
|
|
811
837
|
}
|
|
812
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
|
+
/**
|
|
813
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
|
|
814
855
|
* the announcement. This device is its first holder and serves the members who ask.
|
|
815
856
|
*/
|
|
816
|
-
async function sendToGroup(ctx, params, group, path,
|
|
817
|
-
if (
|
|
818
|
-
if (!
|
|
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");
|
|
819
860
|
const mime = mimeOf(path, str(params, "mime"));
|
|
820
861
|
const replyTo = str(params, "reply");
|
|
821
862
|
if (replyTo) {
|
|
@@ -823,8 +864,9 @@ async function sendToGroup(ctx, params, group, path, size) {
|
|
|
823
864
|
}
|
|
824
865
|
const check = await node(ctx).groupFileCheck({ groupId: group.id });
|
|
825
866
|
if (check.error) throw check.refused ? new CliError("refused", check.error) : groupSendRefused(check.error);
|
|
826
|
-
const { voice, warning } = await voiceOf(params, path, mime,
|
|
827
|
-
const source = await
|
|
867
|
+
const { voice, warning } = await voiceOf(params, path, mime, picked);
|
|
868
|
+
const source = await sendable(path, mime, voice);
|
|
869
|
+
const size = source.size;
|
|
828
870
|
const image = voice ? void 0 : await readImageMeta(source, mime);
|
|
829
871
|
const fileId = groupFileId(group.id, "out");
|
|
830
872
|
const file = {
|
|
@@ -924,6 +966,24 @@ async function place(partial, target, force) {
|
|
|
924
966
|
await copyFile(partial, target, constants$1.COPYFILE_EXCL);
|
|
925
967
|
}
|
|
926
968
|
}
|
|
969
|
+
/**
|
|
970
|
+
* Marks a saved copy of a contact's file as downloaded, as a browser and Ghostly Desktop (`file_store.rs`
|
|
971
|
+
* `mark_downloaded`) do, so the system checks it when it is opened: Gatekeeper's "downloaded from the internet" on
|
|
972
|
+
* macOS, SmartScreen and Office's Protected View on Windows. Node has no extended attributes, so macOS's own `xattr`
|
|
973
|
+
* writes `com.apple.quarantine`; on Windows it is the file's `Zone.Identifier` stream. Best effort: a file system that
|
|
974
|
+
* cannot hold the mark still gets the file.
|
|
975
|
+
*/
|
|
976
|
+
async function markDownloaded(path) {
|
|
977
|
+
if (process.platform === "darwin") {
|
|
978
|
+
const value = `0081;${Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0")};Ghostly;`;
|
|
979
|
+
await new Promise((done) => execFile("/usr/bin/xattr", [
|
|
980
|
+
"-w",
|
|
981
|
+
"com.apple.quarantine",
|
|
982
|
+
value,
|
|
983
|
+
path
|
|
984
|
+
], { timeout: 1e4 }, () => done()));
|
|
985
|
+
} else if (process.platform === "win32") await writeFile(`${path}:Zone.Identifier`, "[ZoneTransfer]\r\nZoneId=3\r\n").catch(() => {});
|
|
986
|
+
}
|
|
927
987
|
var ACTIONS = [
|
|
928
988
|
"accept",
|
|
929
989
|
"decline",
|
|
@@ -956,13 +1016,13 @@ var FILE_METHODS = {
|
|
|
956
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");
|
|
957
1017
|
}
|
|
958
1018
|
const { voice, warning } = await voiceOf(params, path, mime, info.size);
|
|
959
|
-
const source = await
|
|
1019
|
+
const source = await sendable(path, mime, voice);
|
|
960
1020
|
const image = voice ? void 0 : await readImageMeta(source, mime);
|
|
961
1021
|
const wireId = toBase64Url(randomBytes$1(12));
|
|
962
1022
|
const file = {
|
|
963
1023
|
id: `${link.id}-out-${wireId}`,
|
|
964
1024
|
name: sanitizeFileName(str(params, "name") ?? basename(path)),
|
|
965
|
-
size:
|
|
1025
|
+
size: source.size,
|
|
966
1026
|
mime,
|
|
967
1027
|
...voice ? { voice } : {},
|
|
968
1028
|
...image ? { image } : {}
|
|
@@ -1032,13 +1092,13 @@ var FILE_METHODS = {
|
|
|
1032
1092
|
const kept = await keptOf(`group:${target.group.id}`);
|
|
1033
1093
|
return {
|
|
1034
1094
|
group: target.group.id,
|
|
1035
|
-
files: filesOf(await node(ctx).groupMessages({ groupId: target.group.id }), (id) => views[id] ?? kept.get(id))
|
|
1095
|
+
files: filesOf(await node(ctx).groupMessages({ groupId: target.group.id }), (id) => withWaitingFor(views[id] ?? kept.get(id)))
|
|
1036
1096
|
};
|
|
1037
1097
|
}
|
|
1038
1098
|
const kept = await keptOf(target.link.id);
|
|
1039
1099
|
return {
|
|
1040
1100
|
chat: target.link.id,
|
|
1041
|
-
files: filesOf(await node(ctx).getMessages(target.link.id), (id) => views[id] ?? kept.get(id))
|
|
1101
|
+
files: filesOf(await node(ctx).getMessages(target.link.id), (id) => withWaitingFor(views[id] ?? kept.get(id)))
|
|
1042
1102
|
};
|
|
1043
1103
|
},
|
|
1044
1104
|
/**
|
|
@@ -1084,7 +1144,9 @@ var FILE_METHODS = {
|
|
|
1084
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");
|
|
1085
1145
|
await refuseAllHere();
|
|
1086
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");
|
|
1087
1148
|
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");
|
|
1088
1150
|
}
|
|
1089
1151
|
await node(ctx).fileAction({
|
|
1090
1152
|
linkId,
|
|
@@ -1116,7 +1178,7 @@ var FILE_METHODS = {
|
|
|
1116
1178
|
return now && (now.state === "done" || now.state === "failed" || now.stage === "asking" && now.direction === "in") ? now : void 0;
|
|
1117
1179
|
}, ms, `file ${fileId} to arrive`).catch((error) => {
|
|
1118
1180
|
const now = state(ctx).transfers[fileId];
|
|
1119
|
-
if (error instanceof CliError && error.code === "timeout" && now) throw new CliError("timeout", `${error.message} (${now.transferred} of ${now.size} bytes${now.stage ? `, ${now
|
|
1181
|
+
if (error instanceof CliError && error.code === "timeout" && now) throw new CliError("timeout", `${error.message} (${now.transferred} of ${now.size} bytes${now.stage ? `, ${stageWords(now)}` : ""})`, {
|
|
1120
1182
|
file: fileId,
|
|
1121
1183
|
transferred: now.transferred,
|
|
1122
1184
|
size: now.size,
|
|
@@ -1220,6 +1282,7 @@ var FILE_METHODS = {
|
|
|
1220
1282
|
}
|
|
1221
1283
|
throw refused ?? error;
|
|
1222
1284
|
}
|
|
1285
|
+
if (stored.direction !== "out") await markDownloaded(target);
|
|
1223
1286
|
} finally {
|
|
1224
1287
|
await out?.close();
|
|
1225
1288
|
await rm(partial, { force: true });
|
|
@@ -1984,28 +2047,31 @@ function groupJson(group, showSecret = false) {
|
|
|
1984
2047
|
* engine enforces who may do what (the admin); these check the arguments and name members.
|
|
1985
2048
|
*/
|
|
1986
2049
|
/**
|
|
1987
|
-
* A member by key, unique key prefix or name; never this profile itself
|
|
1988
|
-
* member calls itself; a prefix and a name stand side by side (two
|
|
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).
|
|
1989
2053
|
*/
|
|
1990
|
-
function findMember(group, ref) {
|
|
2054
|
+
function findMember(group, ref, myName) {
|
|
1991
2055
|
const lower = ref.toLowerCase();
|
|
1992
2056
|
const others = group.members.filter((m) => !m.me);
|
|
1993
2057
|
const byKey = others.filter((m) => m.key === ref);
|
|
1994
2058
|
const matches = byKey.length ? byKey : others.filter((m) => m.key.startsWith(ref) || m.nick?.trim().toLowerCase() === lower);
|
|
1995
2059
|
if (matches.length === 1) return matches[0];
|
|
1996
|
-
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);
|
|
1997
2061
|
}
|
|
1998
2062
|
/**
|
|
1999
|
-
* A ref no other member answers to. When it is this profile's own key (or a prefix of it),
|
|
2000
|
-
* 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.
|
|
2001
2065
|
*/
|
|
2002
|
-
function noMember(group, ref) {
|
|
2003
|
-
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}`);
|
|
2004
2068
|
return new CliError("not_found", `No member ${JSON.stringify(ref)} in ${group.name}`);
|
|
2005
2069
|
}
|
|
2006
2070
|
/**
|
|
2007
2071
|
* A picture as Ghostly sends it: a square JPEG data URL, checked as a contact would check it. The app scales and
|
|
2008
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.
|
|
2009
2075
|
*/
|
|
2010
2076
|
async function pictureFrom(path) {
|
|
2011
2077
|
let bytes;
|
|
@@ -2014,7 +2080,14 @@ async function pictureFrom(path) {
|
|
|
2014
2080
|
} catch (error) {
|
|
2015
2081
|
throw localFileError(error, path) ?? new CliError("not_found", `No file ${path}`);
|
|
2016
2082
|
}
|
|
2017
|
-
|
|
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")}`;
|
|
2018
2091
|
const checked = sanitizeAvatar(url);
|
|
2019
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`);
|
|
2020
2093
|
return checked;
|
|
@@ -2023,6 +2096,8 @@ async function picture(params) {
|
|
|
2023
2096
|
if (bool(params, "clear")) return null;
|
|
2024
2097
|
return pictureFrom(str(params, "path", true));
|
|
2025
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);
|
|
2026
2101
|
var view = (ctx, id, params) => groupJson(state(ctx).groups.find((g) => g.id === id) ?? groupOf(ctx, { group: id }), bool(params, "showSecret"));
|
|
2027
2102
|
var GROUP_ADMIN_METHODS = {
|
|
2028
2103
|
async "group.invite"(ctx, params) {
|
|
@@ -2038,7 +2113,7 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2038
2113
|
const group = groupOf(ctx, params);
|
|
2039
2114
|
await node(ctx).removeGroupMember({
|
|
2040
2115
|
groupId: group.id,
|
|
2041
|
-
key:
|
|
2116
|
+
key: member(ctx, group, params).key
|
|
2042
2117
|
});
|
|
2043
2118
|
return view(ctx, group.id, params);
|
|
2044
2119
|
},
|
|
@@ -2046,7 +2121,7 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2046
2121
|
const group = groupOf(ctx, params);
|
|
2047
2122
|
await node(ctx).makeGroupAdmin({
|
|
2048
2123
|
groupId: group.id,
|
|
2049
|
-
key:
|
|
2124
|
+
key: member(ctx, group, params).key
|
|
2050
2125
|
});
|
|
2051
2126
|
return view(ctx, group.id, params);
|
|
2052
2127
|
},
|
|
@@ -2060,7 +2135,7 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2060
2135
|
].includes(role)) throw new CliError("bad_request", "role is pin, exclude or auto");
|
|
2061
2136
|
await node(ctx).setGroupHub({
|
|
2062
2137
|
groupId: group.id,
|
|
2063
|
-
key:
|
|
2138
|
+
key: member(ctx, group, params).key,
|
|
2064
2139
|
role: role === "auto" ? null : role
|
|
2065
2140
|
});
|
|
2066
2141
|
return view(ctx, group.id, params);
|
|
@@ -2736,7 +2811,7 @@ var SERVICE_METHODS = {
|
|
|
2736
2811
|
};
|
|
2737
2812
|
},
|
|
2738
2813
|
async "service.share"(ctx, params) {
|
|
2739
|
-
const link =
|
|
2814
|
+
const link = findOwnNamedChat(state(ctx).links, str(params, "chat", true));
|
|
2740
2815
|
const shared = !bool(params, "off");
|
|
2741
2816
|
const serviceId = serviceOf(ctx, params);
|
|
2742
2817
|
await node(ctx).setServiceShared({
|
|
@@ -2883,6 +2958,7 @@ var APP_SERVE_METHODS = {
|
|
|
2883
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");
|
|
2884
2959
|
const given = str(params, "url");
|
|
2885
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");
|
|
2886
2962
|
const { bundle, url } = await checkedBundle(source);
|
|
2887
2963
|
const m = bundle.manifest;
|
|
2888
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`);
|
|
@@ -2894,7 +2970,7 @@ var APP_SERVE_METHODS = {
|
|
|
2894
2970
|
missing
|
|
2895
2971
|
});
|
|
2896
2972
|
const ref = appRef(m.publisher, m.name);
|
|
2897
|
-
const cardUrl = given ?? url ?? m.sources?.[0];
|
|
2973
|
+
const cardUrl = appCardUrl(given ?? url ?? m.sources?.[0]);
|
|
2898
2974
|
const app = {
|
|
2899
2975
|
ref,
|
|
2900
2976
|
title: m.title,
|
|
@@ -3793,7 +3869,8 @@ var inviteShown = /* @__PURE__ */ new WeakMap();
|
|
|
3793
3869
|
* Refuses DHT only (a hold, `chat transport dht`) while a call is on in the chat. A call's signals cross the live
|
|
3794
3870
|
* link: off it, the call talked on over its own connection, and a hang-up from either side never reached the other
|
|
3795
3871
|
* (that call ended only when its media stalled out, 16 s later). Removing the chat (`chat remove`) is refused the same
|
|
3796
|
-
* 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`).
|
|
3797
3874
|
*/
|
|
3798
3875
|
function noCallOn(ctx, linkId, then) {
|
|
3799
3876
|
const call = ctx.calls.list().find((c) => c.chat === linkId);
|
|
@@ -4135,7 +4212,7 @@ var METHODS = {
|
|
|
4135
4212
|
...messageId && { messageId },
|
|
4136
4213
|
remove
|
|
4137
4214
|
});
|
|
4138
|
-
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);
|
|
4139
4216
|
if (target.group) return {
|
|
4140
4217
|
group: target.id,
|
|
4141
4218
|
messageId: remove ? null : messageId,
|
|
@@ -4650,6 +4727,10 @@ var METHODS = {
|
|
|
4650
4727
|
});
|
|
4651
4728
|
const problem = engineParamsProblem(method, args);
|
|
4652
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
|
+
}
|
|
4653
4734
|
if (args && ENGINE_SENDS.has(method) && !bool(params, "force")) await guardEngineSend(ctx, method, args);
|
|
4654
4735
|
if (method === "getMessages") return node(ctx).getMessages(str(args ?? {}, "linkId", true));
|
|
4655
4736
|
if (method === "getState") return state(ctx);
|
|
@@ -4746,7 +4827,7 @@ async function react(ctx, linkId, params) {
|
|
|
4746
4827
|
messageId,
|
|
4747
4828
|
emoji: emoji ?? ""
|
|
4748
4829
|
});
|
|
4749
|
-
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);
|
|
4750
4831
|
return {
|
|
4751
4832
|
messageId,
|
|
4752
4833
|
emoji: emoji || null,
|
|
@@ -4941,4 +5022,4 @@ async function callApi(ctx, method, params = {}) {
|
|
|
4941
5022
|
//#endregion
|
|
4942
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 };
|
|
4943
5024
|
|
|
4944
|
-
//# sourceMappingURL=api-
|
|
5025
|
+
//# sourceMappingURL=api-BpQC8dAw.js.map
|