@ghostlytools/cli 1.7.4 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/SKILL.md +1 -1
- package/dist/assets/{api-Chhvpwok.js → api-Dj1yn0px.js} +2 -2
- package/dist/assets/{api-D3i2hwy0.js → api-I_KbuXHa.js} +62 -16
- package/dist/assets/api-I_KbuXHa.js.map +1 -0
- package/dist/assets/{apiKit-BtsHrnoo.js → apiKit-C-_PWZvy.js} +17 -5
- package/dist/assets/{apiKit-BtsHrnoo.js.map → apiKit-C-_PWZvy.js.map} +1 -1
- package/dist/assets/{apps-BHl97rHs.js → apps-DKIe8VjF.js} +8 -7
- package/dist/assets/apps-DKIe8VjF.js.map +1 -0
- package/dist/assets/{apps-BFJTqvAt.js → apps-DbEfL_3b.js} +1 -1
- package/dist/assets/{arkade-BFE8KkEE.js → arkade-k1bdSm70.js} +2 -2
- package/dist/assets/{arkade-BFE8KkEE.js.map → arkade-k1bdSm70.js.map} +1 -1
- package/dist/assets/{backup-Bbsr6nDi.js → backup-Cdd6-HNu.js} +1 -1
- package/dist/assets/{backup-CxACdtQX.js → backup-beKfbfNk.js} +6 -6
- package/dist/assets/{backup-CxACdtQX.js.map → backup-beKfbfNk.js.map} +1 -1
- package/dist/assets/buttons-BO1_7V4L.js +2 -0
- package/dist/assets/{buttons-CieBtXEO.js → buttons-ClI13rdv.js} +7 -6
- package/dist/assets/buttons-ClI13rdv.js.map +1 -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-B88yiCQj.js} +2 -2
- package/dist/assets/{envelope-DYiGwzq_.js.map → envelope-B88yiCQj.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/{groupFiles-CBJIEvCE.js → groupFiles-DjQc5XXv.js} +135 -24
- package/dist/assets/groupFiles-DjQc5XXv.js.map +1 -0
- package/dist/assets/{host-Va-r_KJz.js → host-CNWGB3-j.js} +44 -20
- package/dist/assets/host-CNWGB3-j.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-B2uK9tJv.js → hyperdhtRelay-g7eXzf5h.js} +2 -2
- package/dist/assets/{hyperdhtRelay-B2uK9tJv.js.map → hyperdhtRelay-g7eXzf5h.js.map} +1 -1
- package/dist/assets/{irohWeb-DxeEgQ-W.js → irohWeb-Bx8dI4be.js} +2 -2
- package/dist/assets/{irohWeb-DxeEgQ-W.js.map → irohWeb-Bx8dI4be.js.map} +1 -1
- package/dist/assets/{main-BX4oPWCJ.js → main-BRxhBctJ.js} +121 -37
- package/dist/assets/main-BRxhBctJ.js.map +1 -0
- package/dist/assets/{mainline-IfWQOB-J.js → mainline-CwuS6ngj.js} +2 -2
- package/dist/assets/{mainline-IfWQOB-J.js.map → mainline-CwuS6ngj.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-CIAMieQm.js} +2 -2
- package/dist/assets/{networkReason-N2vAaoth.js.map → networkReason-CIAMieQm.js.map} +1 -1
- package/dist/assets/{nwc-CzyCtNK2.js → nwc-C9JLJJkL.js} +3 -3
- package/dist/assets/{nwc-CzyCtNK2.js.map → nwc-C9JLJJkL.js.map} +1 -1
- package/dist/assets/{nwcProvider-DjWmEn3j.js → nwcProvider-pFMrsUJh.js} +2 -2
- package/dist/assets/{nwcProvider-DjWmEn3j.js.map → nwcProvider-pFMrsUJh.js.map} +1 -1
- 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-CeW8XEQc.js → registry-Cks7FA_o.js} +3 -3
- package/dist/assets/{registry-CeW8XEQc.js.map → registry-Cks7FA_o.js.map} +1 -1
- package/dist/assets/{registry-BmS02J5h.js → registry-DY2ixQfU.js} +1 -1
- package/dist/assets/{resolve-BvHkAhDH.js → resolve-C4Y2HPqQ.js} +15 -3
- package/dist/assets/resolve-C4Y2HPqQ.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-D9RAmGdm.js} +650 -150
- package/dist/assets/server-D9RAmGdm.js.map +1 -0
- package/dist/assets/{src-BB5-5P3s.js → src-1RU4TilT.js} +878 -77
- package/dist/assets/src-1RU4TilT.js.map +1 -0
- package/dist/assets/{translate-2WyaRVCr.js → translate-od5GbpvR.js} +11 -7
- package/dist/assets/translate-od5GbpvR.js.map +1 -0
- package/dist/assets/{usdt-BLazHiaP.js → usdt-DldXV0MR.js} +3 -3
- package/dist/assets/{usdt-BLazHiaP.js.map → usdt-DldXV0MR.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-BS2qq_vV.js} +6 -3
- package/dist/assets/words-BS2qq_vV.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/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/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
|
|
@@ -128,7 +131,7 @@ The rows are in alphabetical order of their first command, and every command of
|
|
|
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
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` |
|
|
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) |
|
|
@@ -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)).
|
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,3 +1,3 @@
|
|
|
1
|
-
import { c as findGroup, o as findChat } from "./apiKit-
|
|
2
|
-
import { a as hideStateSecrets, i as groupSendRefused, n as SETTABLE, o as mentionsFor, r as callApi, s as redactSettings, t as API_METHODS } from "./api-
|
|
1
|
+
import { c as findGroup, o as findChat } from "./apiKit-C-_PWZvy.js";
|
|
2
|
+
import { a as hideStateSecrets, i as groupSendRefused, n as SETTABLE, o as mentionsFor, r as callApi, s as redactSettings, t as API_METHODS } from "./api-I_KbuXHa.js";
|
|
3
3
|
export { API_METHODS, SETTABLE, callApi, findChat, findGroup, groupSendRefused, hideStateSecrets, mentionsFor, redactSettings };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
2
2
|
import { u as fileStore } from "./idb-BkOJES5_.js";
|
|
3
|
-
import {
|
|
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-
|
|
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-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";
|
|
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";
|
|
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";
|
|
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
|
/**
|
|
@@ -924,6 +950,24 @@ async function place(partial, target, force) {
|
|
|
924
950
|
await copyFile(partial, target, constants$1.COPYFILE_EXCL);
|
|
925
951
|
}
|
|
926
952
|
}
|
|
953
|
+
/**
|
|
954
|
+
* Marks a saved copy of a contact's file as downloaded, as a browser and Ghostly Desktop (`file_store.rs`
|
|
955
|
+
* `mark_downloaded`) do, so the system checks it when it is opened: Gatekeeper's "downloaded from the internet" on
|
|
956
|
+
* macOS, SmartScreen and Office's Protected View on Windows. Node has no extended attributes, so macOS's own `xattr`
|
|
957
|
+
* writes `com.apple.quarantine`; on Windows it is the file's `Zone.Identifier` stream. Best effort: a file system that
|
|
958
|
+
* cannot hold the mark still gets the file.
|
|
959
|
+
*/
|
|
960
|
+
async function markDownloaded(path) {
|
|
961
|
+
if (process.platform === "darwin") {
|
|
962
|
+
const value = `0081;${Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0")};Ghostly;`;
|
|
963
|
+
await new Promise((done) => execFile("/usr/bin/xattr", [
|
|
964
|
+
"-w",
|
|
965
|
+
"com.apple.quarantine",
|
|
966
|
+
value,
|
|
967
|
+
path
|
|
968
|
+
], { timeout: 1e4 }, () => done()));
|
|
969
|
+
} else if (process.platform === "win32") await writeFile(`${path}:Zone.Identifier`, "[ZoneTransfer]\r\nZoneId=3\r\n").catch(() => {});
|
|
970
|
+
}
|
|
927
971
|
var ACTIONS = [
|
|
928
972
|
"accept",
|
|
929
973
|
"decline",
|
|
@@ -1032,13 +1076,13 @@ var FILE_METHODS = {
|
|
|
1032
1076
|
const kept = await keptOf(`group:${target.group.id}`);
|
|
1033
1077
|
return {
|
|
1034
1078
|
group: target.group.id,
|
|
1035
|
-
files: filesOf(await node(ctx).groupMessages({ groupId: target.group.id }), (id) => views[id] ?? kept.get(id))
|
|
1079
|
+
files: filesOf(await node(ctx).groupMessages({ groupId: target.group.id }), (id) => withWaitingFor(views[id] ?? kept.get(id)))
|
|
1036
1080
|
};
|
|
1037
1081
|
}
|
|
1038
1082
|
const kept = await keptOf(target.link.id);
|
|
1039
1083
|
return {
|
|
1040
1084
|
chat: target.link.id,
|
|
1041
|
-
files: filesOf(await node(ctx).getMessages(target.link.id), (id) => views[id] ?? kept.get(id))
|
|
1085
|
+
files: filesOf(await node(ctx).getMessages(target.link.id), (id) => withWaitingFor(views[id] ?? kept.get(id)))
|
|
1042
1086
|
};
|
|
1043
1087
|
},
|
|
1044
1088
|
/**
|
|
@@ -1085,6 +1129,7 @@ var FILE_METHODS = {
|
|
|
1085
1129
|
await refuseAllHere();
|
|
1086
1130
|
const transfer = state(ctx).transfers[fileId] ?? (await fileStore.get(fileId).catch(() => void 0))?.transfer;
|
|
1087
1131
|
if (transfer?.state === "failed") throw new CliError("refused", `It ended: ${transfer.error ?? "failed"}${outgoing && transfer.retry ? " (file resend sends it again)" : ""}`);
|
|
1132
|
+
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
1133
|
}
|
|
1089
1134
|
await node(ctx).fileAction({
|
|
1090
1135
|
linkId,
|
|
@@ -1116,7 +1161,7 @@ var FILE_METHODS = {
|
|
|
1116
1161
|
return now && (now.state === "done" || now.state === "failed" || now.stage === "asking" && now.direction === "in") ? now : void 0;
|
|
1117
1162
|
}, ms, `file ${fileId} to arrive`).catch((error) => {
|
|
1118
1163
|
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
|
|
1164
|
+
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
1165
|
file: fileId,
|
|
1121
1166
|
transferred: now.transferred,
|
|
1122
1167
|
size: now.size,
|
|
@@ -1220,6 +1265,7 @@ var FILE_METHODS = {
|
|
|
1220
1265
|
}
|
|
1221
1266
|
throw refused ?? error;
|
|
1222
1267
|
}
|
|
1268
|
+
if (stored.direction !== "out") await markDownloaded(target);
|
|
1223
1269
|
} finally {
|
|
1224
1270
|
await out?.close();
|
|
1225
1271
|
await rm(partial, { force: true });
|
|
@@ -4941,4 +4987,4 @@ async function callApi(ctx, method, params = {}) {
|
|
|
4941
4987
|
//#endregion
|
|
4942
4988
|
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
4989
|
|
|
4944
|
-
//# sourceMappingURL=api-
|
|
4990
|
+
//# sourceMappingURL=api-I_KbuXHa.js.map
|