@ghostlytools/cli 1.13.2 → 1.13.4
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 +9 -8
- package/dist/assets/{api-DV52o7A8.js → api-B5qxNMgg.js} +2 -2
- package/dist/assets/{api-O57SNJcb.js → api-iiij_pP5.js} +213 -59
- package/dist/assets/api-iiij_pP5.js.map +1 -0
- package/dist/assets/{apiKit-CPTFJHA7.js → apiKit-BPuHOoXF.js} +17 -3
- package/dist/assets/apiKit-BPuHOoXF.js.map +1 -0
- package/dist/assets/{appFetch-Ca9DNQQ2.js → appFetch-D89FnCxr.js} +2 -2
- package/dist/assets/{appFetch-Ca9DNQQ2.js.map → appFetch-D89FnCxr.js.map} +1 -1
- package/dist/assets/{apps-uZTu5FlR.js → apps-BpZcd86Y.js} +1 -1
- package/dist/assets/{apps-gXpGFPiv.js → apps-D2YGSPJe.js} +45 -19
- package/dist/assets/apps-D2YGSPJe.js.map +1 -0
- package/dist/assets/{backup-CxH3auHB.js → backup-BrMe9VPY.js} +11 -6
- package/dist/assets/backup-BrMe9VPY.js.map +1 -0
- package/dist/assets/{backup-Di2U6QVH.js → backup-COkkM8Yy.js} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-CjjCN3FD.js +5 -0
- package/dist/assets/{bitcoind-BpZn3bRN.js → bitcoind-CK1QEUHn.js} +2 -2
- package/dist/assets/{bitcoind-BpZn3bRN.js.map → bitcoind-CK1QEUHn.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-D6IFIaJi.js +5 -0
- package/dist/assets/{blobFiles-DDs34n0r.js → blobFiles-DA3UEn37.js} +3 -3
- package/dist/assets/{blobFiles-DDs34n0r.js.map → blobFiles-DA3UEn37.js.map} +1 -1
- package/dist/assets/buttons-BWEdoxgK.js +1 -0
- package/dist/assets/{buttons-D4udKEvT.js → buttons-UsDPQJsQ.js} +4 -4
- package/dist/assets/{buttons-D4udKEvT.js.map → buttons-UsDPQJsQ.js.map} +1 -1
- package/dist/assets/{client-DGx7E8b3.js → client-Cj-VLeTs.js} +2 -2
- package/dist/assets/{client-DGx7E8b3.js.map → client-Cj-VLeTs.js.map} +1 -1
- package/dist/assets/{fedimintSdk-D-6H9Pe7.js → fedimintSdk-eLXBrj9i.js} +2 -2
- package/dist/assets/{fedimintSdk-D-6H9Pe7.js.map → fedimintSdk-eLXBrj9i.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-CRQlnJdu.js +5 -0
- package/dist/assets/{fileBytes-CfvUXdSy.js → fileBytes-B2jXQI8e.js} +3 -3
- package/dist/assets/{fileBytes-CfvUXdSy.js.map → fileBytes-B2jXQI8e.js.map} +1 -1
- package/dist/assets/{fileBytes-tj6-VZcB.js → fileBytes-BQrW3m-d.js} +2 -2
- package/dist/assets/{fileBytes-tj6-VZcB.js.map → fileBytes-BQrW3m-d.js.map} +1 -1
- package/dist/assets/{fileBytes-CCKbwqG_.js → fileBytes-CtjxJ6AL.js} +1 -1
- package/dist/assets/{fileBytesIdb-BJirUAjI.js → fileBytesIdb-B7Wjw0S8.js} +3 -3
- package/dist/assets/{fileBytesIdb-BJirUAjI.js.map → fileBytesIdb-B7Wjw0S8.js.map} +1 -1
- package/dist/assets/fileBytesIdb-Fcj2mwj6.js +1 -0
- package/dist/assets/{fileBytesOpfs-DRUYLER4.js → fileBytesOpfs-BW0u-_f_.js} +3 -3
- package/dist/assets/{fileBytesOpfs-DRUYLER4.js.map → fileBytesOpfs-BW0u-_f_.js.map} +1 -1
- package/dist/assets/{fixedHosts-CODN2pTL.js → fixedHosts-CrO01M_y.js} +3 -3
- package/dist/assets/{fixedHosts-CODN2pTL.js.map → fixedHosts-CrO01M_y.js.map} +1 -1
- package/dist/assets/{groupMeta-CeZpqVVC.js → groupMeta-DHJxOu0K.js} +99 -10
- package/dist/assets/groupMeta-DHJxOu0K.js.map +1 -0
- package/dist/assets/{host-CRA7h5A2.js → host-C4J4y-Zq.js} +187 -29
- package/dist/assets/host-C4J4y-Zq.js.map +1 -0
- package/dist/assets/{idb-ewvbqyDI.js → idb-CmIR_bxg.js} +2 -1
- package/dist/assets/idb-CmIR_bxg.js.map +1 -0
- package/dist/assets/{identityProofs-B8zCp5_0.js → identityProofs-C0rIGT6y.js} +20 -3
- package/dist/assets/identityProofs-C0rIGT6y.js.map +1 -0
- package/dist/assets/{irohWeb-mnOi2Jp7.js → irohWeb-BXgunUhu.js} +113 -33
- package/dist/assets/irohWeb-BXgunUhu.js.map +1 -0
- package/dist/assets/{main-Chc871HV.js → main-BLs-zUTt.js} +68 -28
- package/dist/assets/main-BLs-zUTt.js.map +1 -0
- package/dist/assets/{mainline-CDUXtV-I.js → mainline-CYek1H10.js} +2 -2
- package/dist/assets/{mainline-CDUXtV-I.js.map → mainline-CYek1H10.js.map} +1 -1
- package/dist/assets/{networkReason-DYlPZS5M.js → networkReason-C6LYbjF2.js} +2 -2
- package/dist/assets/{networkReason-DYlPZS5M.js.map → networkReason-C6LYbjF2.js.map} +1 -1
- package/dist/assets/{ownDid-BOuSlDv-.js → ownDid-Dg-8e_hs.js} +6 -5
- package/dist/assets/ownDid-Dg-8e_hs.js.map +1 -0
- package/dist/assets/{ownStatus-CLA1VPkL.js → ownStatus-BOx4vLi6.js} +34 -11
- package/dist/assets/ownStatus-BOx4vLi6.js.map +1 -0
- package/dist/assets/{profiles-BH1bH9aE.js → profiles-BA0ePikY.js} +33 -8
- package/dist/assets/profiles-BA0ePikY.js.map +1 -0
- package/dist/assets/{registry-DAq16T-V.js → registry-DuSwXntJ.js} +1 -1
- package/dist/assets/{registry-DP_-RA-v.js → registry-OoIgxDrO.js} +25 -13
- package/dist/assets/registry-OoIgxDrO.js.map +1 -0
- package/dist/assets/{relay-gJTOYQJZ.js → relay-NT5bf1WA.js} +9 -6
- package/dist/assets/relay-NT5bf1WA.js.map +1 -0
- package/dist/assets/{resolve-B1eQ4dVQ.js → resolve-DUmE70Eo.js} +3 -3
- package/dist/assets/{resolve-B1eQ4dVQ.js.map → resolve-DUmE70Eo.js.map} +1 -1
- package/dist/assets/{restoredRows-D_WSHE7H.js → restoredRows-Cgaxx1xW.js} +2 -2
- package/dist/assets/{restoredRows-D_WSHE7H.js.map → restoredRows-Cgaxx1xW.js.map} +1 -1
- package/dist/assets/{server-Bd2ofxc1.js → server-WWlXICVB.js} +555 -110
- package/dist/assets/server-WWlXICVB.js.map +1 -0
- package/dist/assets/{sshForges-As7dbGXM.js → sshForges-Cfu-dSwc.js} +2 -2
- package/dist/assets/{sshForges-As7dbGXM.js.map → sshForges-Cfu-dSwc.js.map} +1 -1
- package/dist/assets/translate-DnuQMfj0.js.map +1 -1
- package/dist/assets/{usdt-DLmtf8F9.js → usdt-BkO4SY07.js} +2 -2
- package/dist/assets/{usdt-DLmtf8F9.js.map → usdt-BkO4SY07.js.map} +1 -1
- package/dist/assets/{waitNotice-BHuMofaH.js → waitNotice-DSECf6II.js} +2 -2
- package/dist/assets/{waitNotice-BHuMofaH.js.map → waitNotice-DSECf6II.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/assets/api-O57SNJcb.js.map +0 -1
- package/dist/assets/apiKit-CPTFJHA7.js.map +0 -1
- package/dist/assets/apps-gXpGFPiv.js.map +0 -1
- package/dist/assets/backup-CxH3auHB.js.map +0 -1
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +0 -5
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +0 -1
- package/dist/assets/bark_ffi_wasm_bg-VNmaJsc9.wasm +0 -0
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +0 -5
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +0 -1
- package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
- package/dist/assets/buttons-YTYEqvGC.js +0 -1
- package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +0 -5
- package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js.map +0 -1
- package/dist/assets/fedimint_client_wasm_bg-DeFtkIv6.wasm +0 -0
- package/dist/assets/fileBytesIdb-B0zzJ6p7.js +0 -1
- package/dist/assets/groupMeta-CeZpqVVC.js.map +0 -1
- package/dist/assets/host-CRA7h5A2.js.map +0 -1
- package/dist/assets/idb-ewvbqyDI.js.map +0 -1
- package/dist/assets/identityProofs-B8zCp5_0.js.map +0 -1
- package/dist/assets/irohWeb-mnOi2Jp7.js.map +0 -1
- package/dist/assets/main-Chc871HV.js.map +0 -1
- package/dist/assets/ownDid-BOuSlDv-.js.map +0 -1
- package/dist/assets/ownStatus-CLA1VPkL.js.map +0 -1
- package/dist/assets/profiles-BH1bH9aE.js.map +0 -1
- package/dist/assets/registry-DP_-RA-v.js.map +0 -1
- package/dist/assets/relay-gJTOYQJZ.js.map +0 -1
- package/dist/assets/server-Bd2ofxc1.js.map +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { $a as readImageMeta, Ai as GhostlyHttpError, An as baseMime, Dn as PLAYABLE_AUDIO, Dt as TYPING_KINDS, Ea as isAppUrl, En as sanitizeMime, Er as checkStatusCard, Fi as LIMITS, Fn as voiceLevel, Mr as MESSAGE_CLOCK_SKEW_MS, Ni as parseLocalTarget, Nn as parseVoiceMeta, O as GROUP_FILE_LIMITS, On as VOICE_LIMITS, Ot as TYPING_REFRESH_MS, Pa as appRef, Pn as voiceDownloadName, Pr as claimedTime, Si as AWAITING_PEER_MS, Tn as sanitizeFileName, Va as isAppRef, br as appCardId, cr as replySnippet, do as ownInviteRefusal, ji as VIEWER_PERMISSIONS_POLICY, jn as downsamplePeaks, jt as sanitizeTypingStatus, kn as VOICE_METER, kr as statusCardBytes, lo as inviteLink, n as groupCallSfu, nn as APP_DATA_MAX_BYTES, vr as STATUS_CARD_LIMITS, wr as cardLine, xr as appCardUrl } from "./groupMeta-
|
|
2
|
-
import { G as removeStored, J as waitingGroupFile, P as paymentNetwork, Pt as decodeCommunityLink, T as replyRef, Y as IDENTITY_DRAFT_TTL_MS, an as withoutAudioMetadata, b as groupOfFile, cn as NO_PICTURE_METADATA, d as groupPayLineId, f as groupPayNoteId, l as normalizeMintUrl, ln as stripPictureMetadata, p as groupPayTwin, sn as withoutVideoMetadata, t as DEFAULT_IROH_RELAYS, u as groupMemberOfLink, un as withoutPictureMetadata, v as groupFileId, vt as iceServerProblem, yt as iceServerSetting, zt as decodeGroupEntryLink } from "./irohWeb-
|
|
3
|
-
import { c as normalizeRelayUrl, l as relayUrlProblem } from "./relay-
|
|
1
|
+
import { $a as readImageMeta, Ai as GhostlyHttpError, An as baseMime, Dn as PLAYABLE_AUDIO, Dt as TYPING_KINDS, Ea as isAppUrl, En as sanitizeMime, Er as checkStatusCard, Fi as LIMITS, Fn as voiceLevel, Mr as MESSAGE_CLOCK_SKEW_MS, Ni as parseLocalTarget, Nn as parseVoiceMeta, O as GROUP_FILE_LIMITS, On as VOICE_LIMITS, Ot as TYPING_REFRESH_MS, Pa as appRef, Pn as voiceDownloadName, Pr as claimedTime, Si as AWAITING_PEER_MS, Tn as sanitizeFileName, Va as isAppRef, br as appCardId, cr as replySnippet, do as ownInviteRefusal, ji as VIEWER_PERMISSIONS_POLICY, jn as downsamplePeaks, jt as sanitizeTypingStatus, kn as VOICE_METER, kr as statusCardBytes, lo as inviteLink, n as groupCallSfu, nn as APP_DATA_MAX_BYTES, vr as STATUS_CARD_LIMITS, wr as cardLine, xr as appCardUrl } from "./groupMeta-DHJxOu0K.js";
|
|
2
|
+
import { G as removeStored, J as waitingGroupFile, P as paymentNetwork, Pt as decodeCommunityLink, T as replyRef, Y as IDENTITY_DRAFT_TTL_MS, an as withoutAudioMetadata, b as groupOfFile, cn as NO_PICTURE_METADATA, d as groupPayLineId, f as groupPayNoteId, l as normalizeMintUrl, ln as stripPictureMetadata, p as groupPayTwin, sn as withoutVideoMetadata, t as DEFAULT_IROH_RELAYS, u as groupMemberOfLink, un as withoutPictureMetadata, v as groupFileId, vt as iceServerProblem, yt as iceServerSetting, zt as decodeGroupEntryLink } from "./irohWeb-BXgunUhu.js";
|
|
3
|
+
import { c as normalizeRelayUrl, l as relayUrlProblem } from "./relay-NT5bf1WA.js";
|
|
4
4
|
import { n as secretWords, r as findSecret, t as guardText } from "./secretGuard-oz_3hBfW.js";
|
|
5
|
-
import { a as PAY_METHODS, d as ENGINE_METHODS, f as ENGINE_PARAMS, g as engineParamsProblem, i as CHAT_METHODS, l as withStoredIds, m as READ_PARAMS, n as statusJson, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus, u as DESTRUCTIVE_CALLS } from "./ownStatus-
|
|
5
|
+
import { a as PAY_METHODS, d as ENGINE_METHODS, f as ENGINE_PARAMS, g as engineParamsProblem, i as CHAT_METHODS, l as withStoredIds, m as READ_PARAMS, n as statusJson, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus, u as DESTRUCTIVE_CALLS } from "./ownStatus-BOx4vLi6.js";
|
|
6
6
|
import { i as localFileError, o as shownValue, r as asCliError, t as CliError } from "./errors-JVJsO8Iu.js";
|
|
7
|
-
import { A as oneOf, B as
|
|
7
|
+
import { A as oneOf, B as state, C as noMessage, D as notInYet, E as node, F as sharedGroupIds, H as transportOffered, I as shownName, L as sinceSeq, M as ownChatOf, N as sentAt, O as notInYetError, P as settingsOf, R as somebodyJoined, S as noFile, U as waitForState, V as str, W as shellWord, _ as keptForJoin, a as contactKeyOf, b as nameKey, c as findChatOrGroup, d as groupById, f as groupCalled, g as inviteTaken, h as groupPrefixed, j as oneShotWaits, k as num, l as findGroup, m as groupOf, n as chatOf, o as dhtOnly, p as groupNameOf, r as chatOrGroup, s as findChat, t as bool, v as list, w as nobodyJoined, y as messageOf } from "./apiKit-BPuHOoXF.js";
|
|
8
8
|
import { l as toBase64Url, s as randomBytes$1 } from "./bytes-C1DNGY18.js";
|
|
9
|
-
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-
|
|
10
|
-
import { p as fileStore } from "./idb-
|
|
9
|
+
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-B2jXQI8e.js";
|
|
10
|
+
import { p as fileStore } from "./idb-CmIR_bxg.js";
|
|
11
11
|
import { t as childEnv } from "./childEnv-C-99hdbL.js";
|
|
12
|
-
import { a as checkTextSize$1, c as goesOn, d as purgeMessage, f as waitForConfirmed, g as waitForRemoval, h as waitForMessage, i as pressable, l as nobodyElseIn, m as waitForGroupFrame, n as buttonsCard, o as ended, p as waitForEdit, s as foldsAnyway, t as BUTTON_METHODS, u as outOf } from "./buttons-
|
|
13
|
-
import { a as checkShownName } from "./profiles-
|
|
12
|
+
import { a as checkTextSize$1, c as goesOn, d as purgeMessage, f as waitForConfirmed, g as waitForRemoval, h as waitForMessage, i as pressable, l as nobodyElseIn, m as waitForGroupFrame, n as buttonsCard, o as ended, p as waitForEdit, s as foldsAnyway, t as BUTTON_METHODS, u as outOf } from "./buttons-UsDPQJsQ.js";
|
|
13
|
+
import { a as checkShownName } from "./profiles-BA0ePikY.js";
|
|
14
14
|
import { o as MAX_AVATAR_LENGTH, s as sanitizeAvatar } from "./linkPreview-5kHmKUTN.js";
|
|
15
|
-
import { m as identityStatement } from "./identityProofs-
|
|
16
|
-
import { a as SignerTimeout, i as parseProofBunker, t as IDENTITY_PROVIDERS } from "./registry-
|
|
17
|
-
import { t as BACKUP_METHODS } from "./backup-
|
|
18
|
-
import { s as isAppFetchUrl } from "./appFetch-
|
|
19
|
-
import { o as checkedBundle } from "./apps-
|
|
15
|
+
import { m as identityStatement } from "./identityProofs-C0rIGT6y.js";
|
|
16
|
+
import { a as SignerTimeout, i as parseProofBunker, t as IDENTITY_PROVIDERS } from "./registry-OoIgxDrO.js";
|
|
17
|
+
import { t as BACKUP_METHODS } from "./backup-BrMe9VPY.js";
|
|
18
|
+
import { s as isAppFetchUrl } from "./appFetch-D89FnCxr.js";
|
|
19
|
+
import { o as checkedBundle } from "./apps-D2YGSPJe.js";
|
|
20
20
|
import { m as parsePaymentAmount } from "./paymentIntent-Cr3uZa_0.js";
|
|
21
|
-
import { a as heldWords, n as dhtOnlyNote, t as chatState } from "./waitNotice-
|
|
21
|
+
import { a as heldWords, n as dhtOnlyNote, t as chatState } from "./waitNotice-DSECf6II.js";
|
|
22
22
|
import { generateMnemonic } from "@scure/bip39";
|
|
23
23
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
24
24
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -937,7 +937,11 @@ async function stageWhileAsked(bytes, id, path, source, gone) {
|
|
|
937
937
|
* the announcement. This device is its first holder and serves the members who ask.
|
|
938
938
|
*/
|
|
939
939
|
async function sendToGroup(ctx, params, group, path, name, picked, gone) {
|
|
940
|
-
if (picked > GROUP_FILE_LIMITS.maxBytes) throw new CliError("refused", `Too large for a group (
|
|
940
|
+
if (picked > GROUP_FILE_LIMITS.maxBytes) throw new CliError("refused", `Too large for a group: ${name} is ${megabytes(picked)}, a group takes up to ${GROUP_FILE_LIMITS.maxBytes / 1048576} MiB (send it in a 1:1 chat)`, {
|
|
941
|
+
reason: "too_large",
|
|
942
|
+
size: picked,
|
|
943
|
+
max: GROUP_FILE_LIMITS.maxBytes
|
|
944
|
+
});
|
|
941
945
|
if (!picked) throw new CliError("refused", "An empty file cannot go to a group");
|
|
942
946
|
const mime = mimeOf(path, str(params, "mime"), params.voice !== void 0);
|
|
943
947
|
const replyTo = str(params, "reply");
|
|
@@ -1015,14 +1019,15 @@ var NAME_BYTES = 255;
|
|
|
1015
1019
|
/**
|
|
1016
1020
|
* `name` as an entry of a folder: an app's name may have 200 characters, which in UTF-8 can be 800 bytes. The end of
|
|
1017
1021
|
* its stem goes until it fits, its extension stays (as `sanitizeFileName` shortens it), so "文…文.txt" is saved as a text.
|
|
1022
|
+
* A `mark` (" (2)") goes between them and is kept too.
|
|
1018
1023
|
*/
|
|
1019
|
-
function fitName(name) {
|
|
1024
|
+
function fitName(name, mark = "") {
|
|
1020
1025
|
const fits = (candidate) => Buffer.byteLength(candidate) <= NAME_BYTES;
|
|
1021
|
-
if (fits(name)) return name;
|
|
1026
|
+
if (!mark && fits(name)) return name;
|
|
1022
1027
|
const extension = /\.[^.\s]{1,15}$/u.exec(name)?.[0] ?? "";
|
|
1023
1028
|
const stem = [...name.slice(0, name.length - extension.length)];
|
|
1024
|
-
while (stem.length && !fits(stem.join("").trimEnd() + extension)) stem.pop();
|
|
1025
|
-
return (stem.join("").trimEnd() || "file") + extension;
|
|
1029
|
+
while (stem.length && !fits(stem.join("").trimEnd() + mark + extension)) stem.pop();
|
|
1030
|
+
return (stem.join("").trimEnd() || "file") + mark + extension;
|
|
1026
1031
|
}
|
|
1027
1032
|
/**
|
|
1028
1033
|
* The name `file save --dir` writes a file under. Its sender chose it, and the folder is one scripts and people run
|
|
@@ -1082,6 +1087,48 @@ var ACTIONS = [
|
|
|
1082
1087
|
"request"
|
|
1083
1088
|
];
|
|
1084
1089
|
/**
|
|
1090
|
+
* Who ended a transfer, and how, from the engine's words for it (core's `chatFiles.ts`): its view says only `failed`,
|
|
1091
|
+
* and a script could not tell "the contact said no" from "I already did it" without reading the English.
|
|
1092
|
+
*/
|
|
1093
|
+
var ENDS = {
|
|
1094
|
+
"You cancelled it": {
|
|
1095
|
+
reason: "cancelled",
|
|
1096
|
+
by: "me"
|
|
1097
|
+
},
|
|
1098
|
+
"You declined it": {
|
|
1099
|
+
reason: "declined",
|
|
1100
|
+
by: "me"
|
|
1101
|
+
},
|
|
1102
|
+
"Cancelled by your contact": {
|
|
1103
|
+
reason: "cancelled",
|
|
1104
|
+
by: "contact"
|
|
1105
|
+
},
|
|
1106
|
+
"Declined by your contact": {
|
|
1107
|
+
reason: "declined",
|
|
1108
|
+
by: "contact"
|
|
1109
|
+
},
|
|
1110
|
+
"Cancelled by the sender": {
|
|
1111
|
+
reason: "cancelled",
|
|
1112
|
+
by: "contact"
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
var endOf = (transfer) => ENDS[transfer.error ?? ""] ?? {
|
|
1116
|
+
reason: "failed",
|
|
1117
|
+
by: null
|
|
1118
|
+
};
|
|
1119
|
+
/**
|
|
1120
|
+
* A transfer that ended, refused with its words and the way out: the sender still has the bytes and sends them again
|
|
1121
|
+
* (`file resend` goes on from what the contact holds, while it may); the receiver asks the contact for them.
|
|
1122
|
+
*/
|
|
1123
|
+
function endedFile(fileId, where, transfer, outgoing) {
|
|
1124
|
+
const way = where && "chat" in where ? outgoing ? transfer.retry ? " (file resend sends it again)" : ` (send it again: ghostly file send ${where.chat} <path>)` : " (ask the contact to send it again)" : "";
|
|
1125
|
+
return new CliError("refused", `It ended: ${transfer.error ?? "failed"}${way}`, {
|
|
1126
|
+
file: fileId,
|
|
1127
|
+
...where,
|
|
1128
|
+
...endOf(transfer)
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1085
1132
|
* `file wait`: until a transfer ends: done answers, failed is an `engine` error with the transfer's words (and whether
|
|
1086
1133
|
* `file resend` can go on). A file whose transfer this run has not seen answers from the file store. `stopping`: the
|
|
1087
1134
|
* daemon's stop ends it as well (`waitForState`), for `file send --wait`, which answers with what it knows then.
|
|
@@ -1112,7 +1159,8 @@ async function waitForFile(ctx, params, stopping) {
|
|
|
1112
1159
|
if (transfer.state === "failed") throw new CliError("engine", transfer.error ?? "The transfer failed", {
|
|
1113
1160
|
file: fileId,
|
|
1114
1161
|
...where,
|
|
1115
|
-
retry: !!transfer.retry
|
|
1162
|
+
retry: !!transfer.retry,
|
|
1163
|
+
...endOf(transfer)
|
|
1116
1164
|
});
|
|
1117
1165
|
if (transfer.state !== "done") throw waitsForYou((stored ?? await fileStore.get(fileId).catch(() => void 0))?.metadata?.name, fileId, where, transfer.size);
|
|
1118
1166
|
return {
|
|
@@ -1122,14 +1170,49 @@ async function waitForFile(ctx, params, stopping) {
|
|
|
1122
1170
|
size: transfer.size
|
|
1123
1171
|
};
|
|
1124
1172
|
}
|
|
1173
|
+
/** At most this many of the files still coming are named in a refusal; the rest are counted. */
|
|
1174
|
+
var HOLDERS_NAMED = 3;
|
|
1175
|
+
/**
|
|
1176
|
+
* The files still coming that hold this device's room, as the engine counts them (`ChatFiles.stillToCome`): received in
|
|
1177
|
+
* a 1:1 chat, taken (not one still asked about), not ended, largest first; each with its name and its chat's. A group's
|
|
1178
|
+
* file is not counted there.
|
|
1179
|
+
*/
|
|
1180
|
+
async function roomHolders(s, except) {
|
|
1181
|
+
const holders = [];
|
|
1182
|
+
for (const [id, view] of Object.entries(s.transfers ?? {})) {
|
|
1183
|
+
if (id === except || view.direction !== "in" || view.state !== "transferring" || view.stage === "asking") continue;
|
|
1184
|
+
const link = s.links.find((l) => id.startsWith(`${l.id}-in-`));
|
|
1185
|
+
const left = Math.max(0, view.size - view.transferred);
|
|
1186
|
+
if (link && left > 0) holders.push({
|
|
1187
|
+
id,
|
|
1188
|
+
linkId: link.id,
|
|
1189
|
+
left
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
holders.sort((a, b) => b.left - a.left || a.id.localeCompare(b.id));
|
|
1193
|
+
return Promise.all(holders.map(async ({ id, linkId, left }) => {
|
|
1194
|
+
const link = s.links.find((l) => l.id === linkId);
|
|
1195
|
+
return {
|
|
1196
|
+
id,
|
|
1197
|
+
left,
|
|
1198
|
+
name: (await fileStore.get(id).catch(() => void 0))?.metadata?.name,
|
|
1199
|
+
chat: link?.label || link?.peerNick || linkId
|
|
1200
|
+
};
|
|
1201
|
+
}));
|
|
1202
|
+
}
|
|
1125
1203
|
/**
|
|
1126
1204
|
* `file accept` of a file that does not fit the room left beside the files still coming (`FileDesk.accept`), in this
|
|
1127
1205
|
* CLI's MB: the engine's line gave the room in binary MB beside a size in decimal ones, and neither the files still
|
|
1128
|
-
* coming that take the rest nor the way out.
|
|
1206
|
+
* coming that take the rest nor the way out. The files still coming are named with their chat and how to cancel each:
|
|
1207
|
+
* "wait for them, or cancel one" said neither which nor where. Only this side reads it; nothing goes to the contact.
|
|
1129
1208
|
*/
|
|
1130
|
-
function noRoomWords(fileId, name, size, room, coming) {
|
|
1131
|
-
const
|
|
1132
|
-
|
|
1209
|
+
function noRoomWords(fileId, name, size, room, coming, holders = []) {
|
|
1210
|
+
const named = holders.slice(0, HOLDERS_NAMED).map((h) => `${h.name ?? "a file"} from ${h.chat} (${megabytes(h.left)} to come: ghostly file cancel ${shellWord(h.id, "<file>")})`);
|
|
1211
|
+
const more = holders.length > HOLDERS_NAMED ? ` and ${holders.length - HOLDERS_NAMED} more` : "";
|
|
1212
|
+
const which = named.length ? `: ${named.join(", ")}${more}` : "";
|
|
1213
|
+
const rest = coming > 0 ? `, and ${megabytes(coming)} of files still coming need it first${which}` : "";
|
|
1214
|
+
const out = coming > 0 && named.length ? "Free some space or cancel one of them" : "Free some space";
|
|
1215
|
+
return `${name ?? "The file"} (${megabytes(size)}) does not fit: ${megabytes(room)} free${rest}. ${out}, then ghostly file accept ${fileId} again (or file decline)`;
|
|
1133
1216
|
}
|
|
1134
1217
|
/** A received file that waits for this person's `file accept` (`file wait`, `file save`): said naming the command. */
|
|
1135
1218
|
function waitsForYou(name, fileId, where, size) {
|
|
@@ -1314,14 +1397,22 @@ var FILE_METHODS = {
|
|
|
1314
1397
|
if (outgoing !== (action === "resend")) throw new CliError("bad_request", outgoing ? "A file sent from here is sent again: file resend" : "A received file is asked for again: file request");
|
|
1315
1398
|
const transfer = state(ctx).transfers[fileId];
|
|
1316
1399
|
if (!transfer || transfer.state === "done") throw new CliError("refused", outgoing ? "Nothing to send again: it arrived whole" : "Nothing to ask for: the file is all here");
|
|
1317
|
-
if (transfer.state === "failed" && (!outgoing || !transfer.retry)) throw
|
|
1400
|
+
if (transfer.state === "failed" && (!outgoing || !transfer.retry)) throw endedFile(fileId, where, transfer, outgoing);
|
|
1318
1401
|
} else {
|
|
1319
1402
|
const outgoing = fileId.startsWith(`${linkId}-out-`);
|
|
1320
1403
|
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");
|
|
1321
1404
|
await refuseAllHere();
|
|
1322
1405
|
const transfer = state(ctx).transfers[fileId] ?? (await fileStore.get(fileId).catch(() => void 0))?.transfer;
|
|
1323
1406
|
if (action === "pause" && transfer?.stage === "verifying") throw new CliError("refused", "Too late to pause: it is being checked");
|
|
1324
|
-
if (transfer?.state === "failed")
|
|
1407
|
+
if (transfer?.state === "failed") {
|
|
1408
|
+
if ((action === "cancel" || action === "decline") && endOf(transfer).by === "me") return {
|
|
1409
|
+
...where,
|
|
1410
|
+
file: fileId,
|
|
1411
|
+
action,
|
|
1412
|
+
transfer: state(ctx).transfers[fileId] ?? transfer
|
|
1413
|
+
};
|
|
1414
|
+
throw endedFile(fileId, where, transfer, outgoing);
|
|
1415
|
+
}
|
|
1325
1416
|
const whole = outgoing && transfer?.state === "transferring" && (transfer.stage === "verifying" || transfer.size > 0 && transfer.transferred >= transfer.size && transfer.stage !== "asking" && transfer.stage !== "queued" && transfer.stage !== "paused");
|
|
1326
1417
|
if (whole && action === "cancel") throw new CliError("refused", "Too late to cancel: it arrived whole, and the contact keeps it");
|
|
1327
1418
|
if (whole && action === "pause") throw new CliError("refused", "Too late to pause: it arrived whole, and the contact keeps it");
|
|
@@ -1337,10 +1428,14 @@ var FILE_METHODS = {
|
|
|
1337
1428
|
});
|
|
1338
1429
|
} catch (error) {
|
|
1339
1430
|
const { room, size, coming } = error ?? {};
|
|
1340
|
-
if (action === "accept" && error instanceof Error && typeof room === "number" && error.message.startsWith("No room on this device"))
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1431
|
+
if (action === "accept" && error instanceof Error && typeof room === "number" && error.message.startsWith("No room on this device")) {
|
|
1432
|
+
const comes = typeof coming === "number" ? coming : 0;
|
|
1433
|
+
const holders = comes > 0 ? await roomHolders(state(ctx), fileId) : [];
|
|
1434
|
+
throw new CliError("refused", noRoomWords(fileId, (await fileStore.get(fileId).catch(() => void 0))?.metadata?.name, typeof size === "number" ? size : view?.size ?? 0, room, comes, holders), {
|
|
1435
|
+
reason: "no_room",
|
|
1436
|
+
room
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1344
1439
|
throw error;
|
|
1345
1440
|
}
|
|
1346
1441
|
return {
|
|
@@ -1369,7 +1464,7 @@ var FILE_METHODS = {
|
|
|
1369
1464
|
if (!stored?.metadata) throw noFile(fileId);
|
|
1370
1465
|
if (stored.leftOut) throw new CliError("not_found", "Not in this backup: the light backup this profile was restored from left the file out");
|
|
1371
1466
|
const transfer = stored.direction === "out" ? void 0 : state(ctx).transfers[fileId] ?? waitingGroupFile(stored) ?? stored.transfer;
|
|
1372
|
-
if (transfer?.state === "failed") throw
|
|
1467
|
+
if (transfer?.state === "failed") throw endedFile(fileId, stored.linkId.startsWith("group:") ? { group: stored.linkId.slice(6) } : { chat: stored.linkId }, transfer, false);
|
|
1373
1468
|
if (transfer?.state === "transferring" && transfer.stage === "asking" && transfer.direction === "in") {
|
|
1374
1469
|
let where;
|
|
1375
1470
|
try {
|
|
@@ -1388,6 +1483,10 @@ var FILE_METHODS = {
|
|
|
1388
1483
|
}
|
|
1389
1484
|
const free = !force && !str(params, "path") && !!stored.metadata.voice;
|
|
1390
1485
|
const ext = extname(named), stem = named.slice(0, named.length - ext.length);
|
|
1486
|
+
const numbered = (n) => {
|
|
1487
|
+
const plain = `${stem} (${n})${ext}`;
|
|
1488
|
+
return Buffer.byteLength(basename(plain)) <= NAME_BYTES ? plain : join(dirname(named), fitName(basename(named), ` (${n})`));
|
|
1489
|
+
};
|
|
1391
1490
|
let next = 2;
|
|
1392
1491
|
const taken = async (target, code) => {
|
|
1393
1492
|
const there = await stat(target).catch(() => void 0);
|
|
@@ -1398,14 +1497,14 @@ var FILE_METHODS = {
|
|
|
1398
1497
|
if (path) return new CliError("confirm", replace);
|
|
1399
1498
|
if (free && next <= 1e3) return new CliError("confirm", replace);
|
|
1400
1499
|
let n = 2;
|
|
1401
|
-
while (n <= 1e3 && await stat(
|
|
1402
|
-
const other =
|
|
1500
|
+
while (n <= 1e3 && await stat(numbered(n)).catch(() => void 0)) n += 1;
|
|
1501
|
+
const other = numbered(n);
|
|
1403
1502
|
return new CliError("confirm", `${replace}, or --path ${shellWord(other, "<the one in details.path>")} (path over the socket) to keep both`, { path: other });
|
|
1404
1503
|
};
|
|
1405
1504
|
let target = named;
|
|
1406
1505
|
for (let refused = await taken(target); refused; refused = await taken(target)) {
|
|
1407
1506
|
if (!free || refused.code !== "confirm" || next > 1e3) throw refused;
|
|
1408
|
-
target =
|
|
1507
|
+
target = numbered(next);
|
|
1409
1508
|
next += 1;
|
|
1410
1509
|
}
|
|
1411
1510
|
const partial = join(dirname(target), `.ghostly-save-${process.pid}-${toBase64Url(randomBytes$1(6))}.partial`);
|
|
@@ -1454,7 +1553,7 @@ var FILE_METHODS = {
|
|
|
1454
1553
|
const code = error.code;
|
|
1455
1554
|
const refused = code === "EEXIST" || code === "EISDIR" || code === "ENOTEMPTY" ? await taken(target, code) : void 0;
|
|
1456
1555
|
if (free && refused?.code === "confirm" && next <= 1e3) {
|
|
1457
|
-
target =
|
|
1556
|
+
target = numbered(next);
|
|
1458
1557
|
next += 1;
|
|
1459
1558
|
continue;
|
|
1460
1559
|
}
|
|
@@ -2368,6 +2467,15 @@ function groupPayTwins(messages, notes, payments, group) {
|
|
|
2368
2467
|
return twins;
|
|
2369
2468
|
}
|
|
2370
2469
|
/**
|
|
2470
|
+
* A link join reads `status: "invited"` though nobody invited it: its `note` says that it knocks at the link and how to
|
|
2471
|
+
* stop it. Nothing for anything else.
|
|
2472
|
+
*/
|
|
2473
|
+
function knockNote(group) {
|
|
2474
|
+
if (group.status || !group.invitation?.viaLink) return void 0;
|
|
2475
|
+
const id = shellWord(group.id, group.id);
|
|
2476
|
+
return { note: group.invitation.unanswered ? `You opened its link and nobody let you in: ghostly group accept ${id} knocks again, ghostly group decline ${id} drops it` : `You opened its link and knock until a member's app lets you in (stage says how far): ghostly group decline ${id} stops it` };
|
|
2477
|
+
}
|
|
2478
|
+
/**
|
|
2371
2479
|
* A group as the CLI prints it. The entry link lets anyone who reads it join, so it is `<hidden>` unless asked for
|
|
2372
2480
|
* (`--show-secret`, or `group link`); null when the group has none.
|
|
2373
2481
|
*/
|
|
@@ -2395,10 +2503,11 @@ function groupJson(group, showSecret = false) {
|
|
|
2395
2503
|
})),
|
|
2396
2504
|
...group.hubs ? { hubs: group.hubs } : {},
|
|
2397
2505
|
invitation: group.invitation ? {
|
|
2398
|
-
chat: group.invitation.linkId,
|
|
2506
|
+
chat: group.invitation.viaLink ? null : group.invitation.linkId,
|
|
2399
2507
|
accepted: group.invitation.accepted,
|
|
2400
2508
|
viaLink: !!group.invitation.viaLink,
|
|
2401
2509
|
stage: group.invitation.stage ?? null,
|
|
2510
|
+
...knockNote(group),
|
|
2402
2511
|
...group.invitation.unanswered ? { unanswered: true } : {},
|
|
2403
2512
|
...group.invitation.takenBack ? { takenBack: true } : {}
|
|
2404
2513
|
} : null,
|
|
@@ -2562,6 +2671,7 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2562
2671
|
},
|
|
2563
2672
|
async "group.hub"(ctx, params) {
|
|
2564
2673
|
const group = joined(ctx, params);
|
|
2674
|
+
if (group.profile === "community") throw new CliError("refused", `${group.name} is a community: it chooses its hubs by itself; group hub is for a private group past 16 members`);
|
|
2565
2675
|
const role = str(params, "role") ?? "auto";
|
|
2566
2676
|
if (![
|
|
2567
2677
|
"pin",
|
|
@@ -2603,6 +2713,7 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2603
2713
|
link: null
|
|
2604
2714
|
};
|
|
2605
2715
|
}
|
|
2716
|
+
if (group.profile === "community" && !group.isAdmin && !group.entryLink && !reset) throw new CliError("refused", "The admin turned the link off: nobody can join with it, and the link shared before will not work again. Only the admin can make a new one.");
|
|
2606
2717
|
const { link } = await node(ctx).enableGroupLink({
|
|
2607
2718
|
groupId: group.id,
|
|
2608
2719
|
...reset ? { reset: true } : {}
|
|
@@ -3138,14 +3249,15 @@ var OPENED_SERVICE_CSP_RELAY_ONLY = "default-src 'self' data: blob: 'unsafe-inli
|
|
|
3138
3249
|
/**
|
|
3139
3250
|
* The contact's headers that are not passed on: each makes the browser send something to a place it names, outside
|
|
3140
3251
|
* `connect-src` (violation and network-error reports, and the endpoints they go to; `Link` preloads, prefetches and
|
|
3141
|
-
* early connections). Only the contact's server is reached.
|
|
3252
|
+
* early connections; `Speculation-Rules` prefetches and prerenders). Only the contact's server is reached.
|
|
3142
3253
|
*/
|
|
3143
3254
|
var OPENED_SERVICE_DROPPED_HEADERS = [
|
|
3144
3255
|
"content-security-policy-report-only",
|
|
3145
3256
|
"reporting-endpoints",
|
|
3146
3257
|
"report-to",
|
|
3147
3258
|
"nel",
|
|
3148
|
-
"link"
|
|
3259
|
+
"link",
|
|
3260
|
+
"speculation-rules"
|
|
3149
3261
|
];
|
|
3150
3262
|
/**
|
|
3151
3263
|
* A contact's headers that would set the page's browser features (camera, microphone, location, a device): the
|
|
@@ -3574,10 +3686,13 @@ function servedApp(apps, ref) {
|
|
|
3574
3686
|
}
|
|
3575
3687
|
/** A link a contact's app reads a card's bundle from. */
|
|
3576
3688
|
var readable = (url) => isAppFetchUrl(url) && appCardUrl(url) !== void 0;
|
|
3577
|
-
/**
|
|
3689
|
+
/**
|
|
3690
|
+
* Whether this engine offers apps/1 now: it read the list when it started, so the first app served waits for a restart,
|
|
3691
|
+
* and so does the end of the offer once the last one is unserved.
|
|
3692
|
+
*/
|
|
3578
3693
|
var offered = (ctx, apps) => ({
|
|
3579
3694
|
offered: ctx.runtime.apps,
|
|
3580
|
-
...apps.length > 0
|
|
3695
|
+
...apps.length > 0 !== ctx.runtime.apps && { restart: true }
|
|
3581
3696
|
});
|
|
3582
3697
|
var APP_SERVE_METHODS = {
|
|
3583
3698
|
async "app.serve"(ctx, params) {
|
|
@@ -4861,6 +4976,8 @@ var NO_ROOM = {
|
|
|
4861
4976
|
var JOIN_STOPS = /* @__PURE__ */ new Set(["replaced", ...Object.keys(NO_ROOM)]);
|
|
4862
4977
|
/** How long a one-shot `group join` waits to be let in: as long as a one-shot `invite join` waits to pair. */
|
|
4863
4978
|
var ONE_SHOT_JOIN_S = 60;
|
|
4979
|
+
/** A replaced link never lets it in: the next step is a new link, not a daemon. */
|
|
4980
|
+
var REPLACED = "This link was replaced or turned off: ask someone in the group for the current link, then ghostly group join <link>";
|
|
4864
4981
|
/**
|
|
4865
4982
|
* A one-shot `group join` waits to be let in, as a one-shot invite join waits to pair: a member's app lets the joiner
|
|
4866
4983
|
* in only while its knocks go on, and they stop when the command leaves. It left at once with `{"group": id}` and exit
|
|
@@ -4907,10 +5024,23 @@ async function letIn(ctx, groupId, link, held) {
|
|
|
4907
5024
|
}
|
|
4908
5025
|
if (ctx.mode !== "one-shot") {
|
|
4909
5026
|
const now = seen(state(ctx));
|
|
5027
|
+
const joined = now?.status === "active", stage = now?.invitation?.stage ?? null;
|
|
5028
|
+
if (joined || !now?.invitation?.viaLink) return {
|
|
5029
|
+
group: groupId,
|
|
5030
|
+
joined,
|
|
5031
|
+
stage
|
|
5032
|
+
};
|
|
5033
|
+
if (stage === "replaced") return {
|
|
5034
|
+
group: groupId,
|
|
5035
|
+
joined,
|
|
5036
|
+
stage,
|
|
5037
|
+
warning: REPLACED
|
|
5038
|
+
};
|
|
4910
5039
|
return {
|
|
4911
5040
|
group: groupId,
|
|
4912
|
-
joined
|
|
4913
|
-
stage
|
|
5041
|
+
joined,
|
|
5042
|
+
stage,
|
|
5043
|
+
warning: `Not in yet: the daemon goes on knocking at the group's link until a member's app lets you in: ghostly group show ${id} follows it, ghostly group decline ${id} stops it`
|
|
4914
5044
|
};
|
|
4915
5045
|
}
|
|
4916
5046
|
const done = (g) => !g || g.status === "active" || JOIN_STOPS.has(g.invitation?.stage ?? "");
|
|
@@ -4931,7 +5061,7 @@ async function letIn(ctx, groupId, link, held) {
|
|
|
4931
5061
|
group: groupId,
|
|
4932
5062
|
joined,
|
|
4933
5063
|
stage,
|
|
4934
|
-
warning:
|
|
5064
|
+
warning: REPLACED
|
|
4935
5065
|
};
|
|
4936
5066
|
const show = `keep it running (ghostly daemon --detach), then ghostly group show ${shellWord(groupId, groupId)}`;
|
|
4937
5067
|
const full = stage === "full" ? group.invitation?.full : void 0;
|
|
@@ -5124,9 +5254,10 @@ var METHODS = {
|
|
|
5124
5254
|
}
|
|
5125
5255
|
patch[key] = servers;
|
|
5126
5256
|
const unused = servers.flatMap((server) => server.urls.split(/[\s,]+/)).filter((url) => /^turns:|\?transport=tcp$/i.test(url));
|
|
5127
|
-
if (unused.length) warning = `The CLI reaches TURN over UDP only: it does not use ${unused.join(", ")} (the apps do). Add a turn: server over UDP for the CLI`;
|
|
5257
|
+
if (unused.length) warning = (warning ? `${warning}. ` : "") + `The CLI reaches TURN over UDP only: it does not use ${unused.join(", ")} (the apps do). Add a turn: server over UDP for the CLI`;
|
|
5128
5258
|
continue;
|
|
5129
5259
|
}
|
|
5260
|
+
if (key === "hyperdhtRelay" && value) warning = (warning ? `${warning}. ` : "") + "This CLI runs HyperDHT itself and does not dial through hyperdhtRelay: it uses it only with Hide my IP from contacts, which comes in a later release. It is kept for the apps this profile moves to";
|
|
5130
5261
|
patch[key] = value;
|
|
5131
5262
|
}
|
|
5132
5263
|
await node(ctx).updateSettings({ settings: patch }).catch((error) => {
|
|
@@ -5675,7 +5806,7 @@ var METHODS = {
|
|
|
5675
5806
|
};
|
|
5676
5807
|
let link;
|
|
5677
5808
|
try {
|
|
5678
|
-
link = notAGroup(ctx, params, () => chatOf(ctx, params), (shown, id) => `ghostly message delete ${groupPrefixed(typed) === null && reachesGroup(typed) ? shown : shellWord(groupPrefixed(typed) === null ? `group:${typed}` : typed, `group:${id}`)} ${ref === "<message>" ? ref : shellWord(ref, "<message>")} --everyone${purge ? " --purge" : ""}`);
|
|
5809
|
+
link = notAGroup(ctx, params, () => chatOf(ctx, params), (shown, id) => `ghostly message delete ${id === void 0 || groupPrefixed(typed) === null && reachesGroup(typed) ? shown : shellWord(groupPrefixed(typed) === null ? `group:${typed}` : typed, `group:${id}`)} ${ref === "<message>" ? ref : shellWord(ref, "<message>")} --everyone${purge ? " --purge" : ""}${byItsId(id)}`);
|
|
5679
5810
|
} catch (error) {
|
|
5680
5811
|
const group = error instanceof CliError ? error.details?.group : void 0;
|
|
5681
5812
|
const theirs = typeof group === "string" && ref !== "<message>" ? await messageOf(ctx, `group:${group}`, ref).catch(() => void 0) : void 0;
|
|
@@ -6036,7 +6167,7 @@ var METHODS = {
|
|
|
6036
6167
|
if (!bool(params, "yes")) throw new CliError("confirm", "Leaving a group deletes its history and files on this device; pass --yes (yes: true over the socket) to go on");
|
|
6037
6168
|
const ref = str(params, "group", true);
|
|
6038
6169
|
const { admin } = await node(ctx).leaveGroup({ groupId: group.id }).catch((error) => {
|
|
6039
|
-
throw leaveRefused(group, ref, error);
|
|
6170
|
+
throw leaveRefused(ctx, group, ref, error);
|
|
6040
6171
|
});
|
|
6041
6172
|
const next = admin ? group.members.find((m) => m.key === admin) : void 0;
|
|
6042
6173
|
return {
|
|
@@ -6050,7 +6181,9 @@ var METHODS = {
|
|
|
6050
6181
|
async "group.forget"(ctx, params) {
|
|
6051
6182
|
const group = groupOf(ctx, params, "chat remove <chat> --yes");
|
|
6052
6183
|
if (!bool(params, "yes")) throw new CliError("confirm", "Forgetting a group deletes its history on this device; pass --yes (yes: true over the socket) to go on");
|
|
6053
|
-
await node(ctx).forgetGroup({ groupId: group.id })
|
|
6184
|
+
await node(ctx).forgetGroup({ groupId: group.id }).catch((error) => {
|
|
6185
|
+
throw nobodyForLeave(ctx, group, str(params, "group", true), error) ?? error;
|
|
6186
|
+
});
|
|
6054
6187
|
return { forgotten: group.id };
|
|
6055
6188
|
},
|
|
6056
6189
|
async "group.accept"(ctx, params) {
|
|
@@ -6268,13 +6401,27 @@ function groupSendRefused(error) {
|
|
|
6268
6401
|
}
|
|
6269
6402
|
/** The engine's admin who may not leave: the app's words say "make someone the admin", which names no command here. */
|
|
6270
6403
|
var ADMIN_ALONE = "You are the admin and nobody else in the group is online to take over. Try again when a member is, or make someone the admin first.";
|
|
6404
|
+
/** A community's leave (or an admin's forget, which leaves first) with no edge to a member to carry it. */
|
|
6405
|
+
var NOBODY_FOR_LEAVE = "Nobody in the group is connected right now to take your leave. Try again in a moment.";
|
|
6406
|
+
/**
|
|
6407
|
+
* A community's leave nobody was connected to take, said with the CLI's next step: "Try again in a moment" never passed
|
|
6408
|
+
* in a one-shot, which has no edge yet when it runs, and every member is refused alike (`group admin` hands nothing on
|
|
6409
|
+
* here). The code stays the engine's. Undefined for other errors.
|
|
6410
|
+
*/
|
|
6411
|
+
function nobodyForLeave(ctx, group, ref, error) {
|
|
6412
|
+
if (!(error instanceof Error) || error.message !== NOBODY_FOR_LEAVE) return void 0;
|
|
6413
|
+
const shown = shellWord(ref, group.id), show = `ghostly group show ${shown} says who is`;
|
|
6414
|
+
return new CliError("engine", ctx.mode === "one-shot" ? `Nobody in ${groupCalled(group)} is connected to take your leave, and a command without a daemon has no connection yet: keep this profile online (ghostly daemon --detach), then ghostly group leave ${shown} --yes once a member is (${show})` : `Nobody in ${groupCalled(group)} is connected to take your leave: try again when a member is online (${show})`);
|
|
6415
|
+
}
|
|
6271
6416
|
/**
|
|
6272
6417
|
* `group leave` the engine refused, said with the CLI's next step: an invitation not joined yet answered "Group not
|
|
6273
|
-
* found" of a group `group show` lists (its way out is `group decline`),
|
|
6274
|
-
* admin", the app's words. The code stays the engine's.
|
|
6418
|
+
* found" of a group `group show` lists (its way out is `group decline`), an admin alone online "make someone the
|
|
6419
|
+
* admin", the app's words, and a community nobody is connected to (`nobodyForLeave`). The code stays the engine's.
|
|
6275
6420
|
*/
|
|
6276
|
-
function leaveRefused(group, ref, error) {
|
|
6421
|
+
function leaveRefused(ctx, group, ref, error) {
|
|
6277
6422
|
if (!(error instanceof Error)) return error;
|
|
6423
|
+
const nobody = nobodyForLeave(ctx, group, ref, error);
|
|
6424
|
+
if (nobody) return nobody;
|
|
6278
6425
|
const shown = shellWord(ref, group.id);
|
|
6279
6426
|
if (error.message === ADMIN_ALONE) return new CliError("engine", `You are the admin and nobody else in ${groupCalled(group)} is online to take over: try again when a member is, or make one the admin first (ghostly group admin ${shown} <member key>)`);
|
|
6280
6427
|
const yet = error.message === "Group not found" ? notInYet(group, ref, true) : void 0;
|
|
@@ -6307,13 +6454,14 @@ function joinRefused(link, error) {
|
|
|
6307
6454
|
* never has the group.
|
|
6308
6455
|
*/
|
|
6309
6456
|
function chatNotGroupLink(ctx, params) {
|
|
6310
|
-
return notAGroup(ctx, params, () => chatOf(ctx, params), (shown) => `it connects through its members' chats, with no transport of its own (ghostly group show ${shown})`);
|
|
6457
|
+
return notAGroup(ctx, params, () => chatOf(ctx, params), (shown, id) => `it connects through its members' chats, with no transport of its own (${id === void 0 ? "ghostly group list" : `ghostly group show ${shown}`})`);
|
|
6311
6458
|
}
|
|
6312
6459
|
/**
|
|
6313
6460
|
* A chat command given a group's id, prefix or name: `not_found` that says it is a group, with `hint`: the group
|
|
6314
6461
|
* command that takes it (`react` on a group, where `group react` is meant), or what to do where none does. `group:<id>`,
|
|
6315
6462
|
* the form `pin` and `saved` take, is that group too (it read "No chat" before). A name no chat and no group has stays
|
|
6316
|
-
* the chat's error.
|
|
6463
|
+
* the chat's error. A name more than one group has says so too, with no `id` for `hint` (`shown` is `<group>`): the
|
|
6464
|
+
* group to name is one of theirs, by its id (`ghostly group list`).
|
|
6317
6465
|
*/
|
|
6318
6466
|
function notAGroup(ctx, params, chat, hint) {
|
|
6319
6467
|
try {
|
|
@@ -6325,16 +6473,19 @@ function notAGroup(ctx, params, chat, hint) {
|
|
|
6325
6473
|
let group;
|
|
6326
6474
|
try {
|
|
6327
6475
|
group = findGroup(state(ctx).groups, named);
|
|
6328
|
-
} catch {
|
|
6476
|
+
} catch (inner) {
|
|
6477
|
+
if (sharedGroupIds(inner)) throw new CliError("not_found", `${JSON.stringify(ref)} names more than one group, not a chat: ${hint("<group>")}`);
|
|
6329
6478
|
throw error;
|
|
6330
6479
|
}
|
|
6331
6480
|
const shown = shellWord(named, group.id);
|
|
6332
6481
|
throw new CliError("not_found", `${JSON.stringify(ref)} is a group, not a chat: ${hint(shown, group.id)}`, { group: group.id });
|
|
6333
6482
|
}
|
|
6334
6483
|
}
|
|
6484
|
+
/** Where a command offered for a name more than one group has (no `id`) finds the id of the one meant. */
|
|
6485
|
+
var byItsId = (id) => id === void 0 ? ", with the id of the group meant (ghostly group list)" : "";
|
|
6335
6486
|
/** The chat a chat command with a group twin names: a group's name says so, with `command`, the twin (see `notAGroup`). */
|
|
6336
6487
|
function chatNotGroup(ctx, params, command, rest = "") {
|
|
6337
|
-
return notAGroup(ctx, params, () => chatOf(ctx, params), (shown) => `ghostly ${command} ${shown}${rest ? ` ${rest}` : ""}`);
|
|
6488
|
+
return notAGroup(ctx, params, () => chatOf(ctx, params), (shown, id) => `ghostly ${command} ${shown}${rest ? ` ${rest}` : ""}${byItsId(id)}`);
|
|
6338
6489
|
}
|
|
6339
6490
|
/**
|
|
6340
6491
|
* An edit the engine refused. A message that is not in the chat or group at all is `not_found` (exit 3), said as every
|
|
@@ -6376,7 +6527,7 @@ function deleteNotMine(ctx, target, ref, theirs, place, purge) {
|
|
|
6376
6527
|
/**
|
|
6377
6528
|
* About the longest ASCII text, and edit, the DHT packet carries once sealed and signed: within the 256 bytes, the
|
|
6378
6529
|
* envelope's authentication (and an edit's element) takes the rest. The edge moves by a byte or two with the chat (the
|
|
6379
|
-
* envelope's sequence, the edit's number), so the words say "about"; `
|
|
6530
|
+
* envelope's sequence, the edit's number), so the words say "about"; `dhtPacketBudget.test.ts` sends both sizes on two
|
|
6380
6531
|
* paired daemons.
|
|
6381
6532
|
*/
|
|
6382
6533
|
var DHT_TEXT_FITS = 248;
|
|
@@ -6445,12 +6596,15 @@ var RESUMING_MS = 3e5;
|
|
|
6445
6596
|
* Why a daemon's `chat connect` timed out, as the chat reads at the end. No attempt of this run ended yet
|
|
6446
6597
|
* (`lastAttempt` null) while the daemon just started, or while the contact reads online: the chat is still coming
|
|
6447
6598
|
* back, nobody failed to answer. It said "the contact did not answer" right after a `daemon restart`, with the
|
|
6448
|
-
* contact online. A one-shot always just started: it keeps the words it had.
|
|
6599
|
+
* contact online. A one-shot always just started: it keeps the words it had. Not resuming once the chat was live in
|
|
6600
|
+
* this run (then held by the contact, say), nor with the contact's record read offline (`peerLastSeenAt` is this
|
|
6601
|
+
* run's): those said "still resuming" for the daemon's first 5 minutes too.
|
|
6449
6602
|
*/
|
|
6450
6603
|
function notLiveYet(ctx, link) {
|
|
6451
6604
|
const now = state(ctx).links.find((l) => l.id === link.id) ?? link;
|
|
6452
6605
|
if (ctx.mode !== "daemon" || now.liveAttempt) return "the contact did not answer";
|
|
6453
|
-
|
|
6606
|
+
const readOffline = !now.peerOnline && now.peerLastSeenAt > 0;
|
|
6607
|
+
if (process.uptime() * 1e3 < RESUMING_MS && !readOffline && !ctx.hub.wasLive(link.id)) return "the chat is still resuming after the daemon's start, and no attempt to reach the contact has ended yet";
|
|
6454
6608
|
return now.peerOnline ? "your contact's app reads online, and no attempt to reach it has ended yet" : "the contact did not answer";
|
|
6455
6609
|
}
|
|
6456
6610
|
/** What happens after a `chat connect` the contact did not answer: the daemon dials again by itself, a one-shot does not. */
|
|
@@ -6612,4 +6766,4 @@ async function callApi(ctx, method, params = {}, call) {
|
|
|
6612
6766
|
}
|
|
6613
6767
|
export { groupJson as _, hideStateSecrets as a, resumeHolds as b, refuseBeforeStart as c, reportAppFrames as d, servedApps as f, chatMessageJson as g, chatJson as h, groupSendRefused as i, settingsInEffect as l, identityProvider as m, SETTABLE as n, mentionsFor as o, nodeLocalFetch as p, callApi as r, redactSettings as s, API_METHODS as t, paymentJson as u, groupMessageJson as v, flushCardUpdates as x, groupPayTwins as y };
|
|
6614
6768
|
|
|
6615
|
-
//# sourceMappingURL=api-
|
|
6769
|
+
//# sourceMappingURL=api-iiij_pP5.js.map
|