@ghostlytools/cli 1.11.4 → 1.12.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 +31 -14
- package/dist/assets/{api-MYc6QNRs.js → api-BwEgbvvK.js} +395 -131
- package/dist/assets/api-BwEgbvvK.js.map +1 -0
- package/dist/assets/{api-BwyFq4lA.js → api-jRUXnBdX.js} +2 -2
- package/dist/assets/{apiKit-CfsNx9ZR.js → apiKit-BlsNk-Cx.js} +48 -11
- package/dist/assets/apiKit-BlsNk-Cx.js.map +1 -0
- package/dist/assets/appFetch-CW9fJPHh.js +602 -0
- package/dist/assets/appFetch-CW9fJPHh.js.map +1 -0
- package/dist/assets/apps-BcG4u6SM.js +1 -0
- package/dist/assets/{apps-h12II1us.js → apps-CL8TXHhu.js} +20 -14
- package/dist/assets/apps-CL8TXHhu.js.map +1 -0
- package/dist/assets/{argon2id-088uQfnH.js → argon2id-B9wFdSj6.js} +2 -3
- package/dist/assets/{argon2id-088uQfnH.js.map → argon2id-B9wFdSj6.js.map} +1 -1
- package/dist/assets/{arkade-Bw_4PZRG.js → arkade-DryM-q5n.js} +6 -7
- package/dist/assets/arkade-DryM-q5n.js.map +1 -0
- package/dist/assets/{backup-Chvy79SN.js → backup-BA41EDvh.js} +110 -26
- package/dist/assets/backup-BA41EDvh.js.map +1 -0
- package/dist/assets/backup-xZfV-ytw.js +1 -0
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +5 -0
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +1 -0
- package/dist/assets/{bark_ffi_wasm_bg-Bxru_BVW.wasm → bark_ffi_wasm_bg-VNmaJsc9.wasm} +0 -0
- package/dist/assets/{bitcoind-CdSmvy2y.js → bitcoind-Dh7n9amb.js} +4 -5
- package/dist/assets/{bitcoind-CdSmvy2y.js.map → bitcoind-Dh7n9amb.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +5 -0
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +1 -0
- package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
- package/dist/assets/{blobFiles-BmsrvZc3.js → blobFiles-DDs34n0r.js} +4 -5
- package/dist/assets/{blobFiles-BmsrvZc3.js.map → blobFiles-DDs34n0r.js.map} +1 -1
- package/dist/assets/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/dist/assets/buttons-CsGdQNnR.js +1 -0
- package/dist/assets/{buttons-BgoExb4E.js → buttons-SH1tNRh7.js} +45 -23
- package/dist/assets/buttons-SH1tNRh7.js.map +1 -0
- package/dist/assets/bytes-C1DNGY18.js +132 -0
- package/dist/assets/bytes-C1DNGY18.js.map +1 -0
- package/dist/assets/{childEnv-K_IzUqQx.js → childEnv-C-99hdbL.js} +2 -3
- package/dist/assets/{childEnv-K_IzUqQx.js.map → childEnv-C-99hdbL.js.map} +1 -1
- package/dist/assets/{client-DY8tZZWi.js → client-DGS-atRu.js} +5 -8
- package/dist/assets/{client-DY8tZZWi.js.map → client-DGS-atRu.js.map} +1 -1
- package/dist/assets/{codec-BnMg-Grj.js → codec-B2rH1mfx.js} +2 -4
- package/dist/assets/{codec-BnMg-Grj.js.map → codec-B2rH1mfx.js.map} +1 -1
- package/dist/assets/domainProofs-BDNP1dIy.js +280 -0
- package/dist/assets/domainProofs-BDNP1dIy.js.map +1 -0
- package/dist/assets/{endpoint-DarqblYE.js → endpoint-Cvu-taMs.js} +462 -424
- package/dist/assets/endpoint-Cvu-taMs.js.map +1 -0
- package/dist/assets/engineErrors--9hfgKlK.js +150 -0
- package/dist/assets/engineErrors--9hfgKlK.js.map +1 -0
- package/dist/assets/{envelope-CdV7vHVZ.js → envelope-Bi2kMqbp.js} +3 -4
- package/dist/assets/{envelope-CdV7vHVZ.js.map → envelope-Bi2kMqbp.js.map} +1 -1
- package/dist/assets/{errors-CAh6GLJZ.js → errors-DDLFO4Gf.js} +5 -4
- package/dist/assets/errors-DDLFO4Gf.js.map +1 -0
- package/dist/assets/{fedimintSdk-CPFfVK-G.js → fedimintSdk-D-6H9Pe7.js} +4 -5
- package/dist/assets/{fedimintSdk-CPFfVK-G.js.map → fedimintSdk-D-6H9Pe7.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +5 -0
- package/dist/assets/{fedimint_client_wasm_bg-BtHHlFpp.js.map → fedimint_client_wasm_bg-Cr5xGD-w.js.map} +1 -1
- package/dist/assets/fileBytes-CCKbwqG_.js +1 -0
- package/dist/assets/{fileBytes-BLPZq9YU.js → fileBytes-CfvUXdSy.js} +5 -7
- package/dist/assets/fileBytes-CfvUXdSy.js.map +1 -0
- package/dist/assets/{fileBytes-B0z9A6Le.js → fileBytes-tj6-VZcB.js} +3 -4
- package/dist/assets/{fileBytes-B0z9A6Le.js.map → fileBytes-tj6-VZcB.js.map} +1 -1
- package/dist/assets/fileBytesIdb-B0zzJ6p7.js +1 -0
- package/dist/assets/{fileBytesIdb-Bmlrl9EO.js → fileBytesIdb-BJirUAjI.js} +4 -5
- package/dist/assets/{fileBytesIdb-Bmlrl9EO.js.map → fileBytesIdb-BJirUAjI.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-DBS0kbPT.js → fileBytesOpfs-DRUYLER4.js} +4 -5
- package/dist/assets/{fileBytesOpfs-DBS0kbPT.js.map → fileBytesOpfs-DRUYLER4.js.map} +1 -1
- package/dist/assets/{fixedHosts-CbgqrIKs.js → fixedHosts-CPSsGOI2.js} +4 -5
- package/dist/assets/{fixedHosts-CbgqrIKs.js.map → fixedHosts-CPSsGOI2.js.map} +1 -1
- package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js → ghostly_iroh_web-DIj5xGmR.js} +2 -3
- package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js.map → ghostly_iroh_web-DIj5xGmR.js.map} +1 -1
- package/dist/assets/{src-DJe-OYxd.js → groupMeta-DxuJzko_.js} +6009 -25536
- package/dist/assets/groupMeta-DxuJzko_.js.map +1 -0
- package/dist/assets/{host-C0NMNQLl.js → host-BxM-HMr0.js} +262 -134
- package/dist/assets/host-BxM-HMr0.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-Dz7pvcBA.js → hyperdhtRelay-DLUiwfnt.js} +36 -9
- package/dist/assets/hyperdhtRelay-DLUiwfnt.js.map +1 -0
- package/dist/assets/hyperdhtRelay-bjNGacf5.js +32 -0
- package/dist/assets/hyperdhtRelay-bjNGacf5.js.map +1 -0
- package/dist/assets/{idb-CEuoNsTv.js → idb-ewvbqyDI.js} +2 -3
- package/dist/assets/{idb-CEuoNsTv.js.map → idb-ewvbqyDI.js.map} +1 -1
- package/dist/assets/identityProofs-Cksc_K7_.js +940 -0
- package/dist/assets/identityProofs-Cksc_K7_.js.map +1 -0
- package/dist/assets/{irohWeb-caAj4Dms.js → irohWeb-CbnGtUo6.js} +3231 -87
- package/dist/assets/irohWeb-CbnGtUo6.js.map +1 -0
- package/dist/assets/joinTrace-CBr1jbch.js +1 -0
- package/dist/assets/{joinTrace-CjRDFy85.js → joinTrace-xKBe73j9.js} +2 -3
- package/dist/assets/{joinTrace-CjRDFy85.js.map → joinTrace-xKBe73j9.js.map} +1 -1
- package/dist/assets/{legacy_ciphers-JJOu0JXL.js → legacy_ciphers-BnYATjxo.js} +2 -3
- package/dist/assets/{legacy_ciphers-JJOu0JXL.js.map → legacy_ciphers-BnYATjxo.js.map} +1 -1
- package/dist/assets/linkPreview-DdMf-YAc.js +252 -0
- package/dist/assets/linkPreview-DdMf-YAc.js.map +1 -0
- package/dist/assets/{main-C6t5zrD5.js → main-CwTaepxR.js} +296 -122
- package/dist/assets/main-CwTaepxR.js.map +1 -0
- package/dist/assets/{mainline-DCuGUSZF.js → mainline-CVrd0C1n.js} +72 -18
- package/dist/assets/mainline-CVrd0C1n.js.map +1 -0
- package/dist/assets/mints-BcBODVVW.js +1 -0
- package/dist/assets/{mints-j5XAOk4f.js → mints-CMDLbMeH.js} +8 -6
- package/dist/assets/mints-CMDLbMeH.js.map +1 -0
- package/dist/assets/{nacl-fast-CDhNCYHs.js → nacl-fast-B1ThWvuM.js} +2 -3
- package/dist/assets/{nacl-fast-CDhNCYHs.js.map → nacl-fast-B1ThWvuM.js.map} +1 -1
- package/dist/assets/{networkReason-BbQW1Xpc.js → networkReason-Be-hMghr.js} +10 -14
- package/dist/assets/{networkReason-BbQW1Xpc.js.map → networkReason-Be-hMghr.js.map} +1 -1
- package/dist/assets/{noble_curves-DDWn5AH0.js → noble_curves-DqpNlhAU.js} +3 -4
- package/dist/assets/{noble_curves-DDWn5AH0.js.map → noble_curves-DqpNlhAU.js.map} +1 -1
- package/dist/assets/{noble_hashes-B7AZyFyS.js → noble_hashes-LFe1N2xt.js} +3 -4
- package/dist/assets/{noble_hashes-B7AZyFyS.js.map → noble_hashes-LFe1N2xt.js.map} +1 -1
- package/dist/assets/{nwc-CSDRMZ0e.js → nwc-DKE2FXr6.js} +5 -6
- package/dist/assets/{nwc-CSDRMZ0e.js.map → nwc-DKE2FXr6.js.map} +1 -1
- package/dist/assets/nwcProvider-pL2XqSbW.js +208 -0
- package/dist/assets/nwcProvider-pL2XqSbW.js.map +1 -0
- package/dist/assets/{openpgp-BBFr-zHQ.js → openpgp-LkR_Zof0.js} +14 -15
- package/dist/assets/{openpgp-BBFr-zHQ.js.map → openpgp-LkR_Zof0.js.map} +1 -1
- package/dist/assets/ownDid-DY3rYqDI.js +862 -0
- package/dist/assets/ownDid-DY3rYqDI.js.map +1 -0
- package/dist/assets/{ownStatus-BoTf5WqQ.js → ownStatus-DtzIllg2.js} +70 -20
- package/dist/assets/ownStatus-DtzIllg2.js.map +1 -0
- package/dist/assets/pairedTransports-BKmvlKz1.js +581 -0
- package/dist/assets/pairedTransports-BKmvlKz1.js.map +1 -0
- package/dist/assets/paymentIntent-DySU3Ajm.js +349 -0
- package/dist/assets/paymentIntent-DySU3Ajm.js.map +1 -0
- package/dist/assets/pkarr-BQo4PcCg.js +367 -0
- package/dist/assets/pkarr-BQo4PcCg.js.map +1 -0
- package/dist/assets/{profiles-DszHjEJi.js → profiles-BOYGlmu2.js} +9 -10
- package/dist/assets/profiles-BOYGlmu2.js.map +1 -0
- package/dist/assets/registry-4W1LGlCF.js +1 -0
- package/dist/assets/{registry-Da-r6eC3.js → registry-Bep4umOM.js} +1296 -80
- package/dist/assets/registry-Bep4umOM.js.map +1 -0
- package/dist/assets/relay-Cjfmdec0.js +2219 -0
- package/dist/assets/relay-Cjfmdec0.js.map +1 -0
- package/dist/assets/resolve-CIc3KZMV.js +970 -0
- package/dist/assets/resolve-CIc3KZMV.js.map +1 -0
- package/dist/assets/{restoredRows-C3LcxmOw.js → restoredRows-D_WSHE7H.js} +3 -4
- package/dist/assets/{restoredRows-C3LcxmOw.js.map → restoredRows-D_WSHE7H.js.map} +1 -1
- package/dist/assets/secretGuard-Bm6nci0I.js +1 -0
- package/dist/assets/{secretGuard-CsVHDdYk.js → secretGuard-BrATm_gl.js} +43 -22
- package/dist/assets/{secretGuard-CsVHDdYk.js.map → secretGuard-BrATm_gl.js.map} +1 -1
- package/dist/assets/{server-C1jZZ61O.js → server-D4gf-LnD.js} +9797 -479
- package/dist/assets/server-D4gf-LnD.js.map +1 -0
- package/dist/assets/{sha512-BYId-G-T.js → sha512-DST9fbWH.js} +2 -3
- package/dist/assets/{sha512-BYId-G-T.js.map → sha512-DST9fbWH.js.map} +1 -1
- package/dist/assets/sshForges-BnvwmNj-.js +539 -0
- package/dist/assets/sshForges-BnvwmNj-.js.map +1 -0
- package/dist/assets/{storage-Bya5b2Xt.js → storage-BpjdxvO2.js} +243 -34
- package/dist/assets/storage-BpjdxvO2.js.map +1 -0
- package/dist/assets/text-li76pThX.js +106 -0
- package/dist/assets/text-li76pThX.js.map +1 -0
- package/dist/assets/{translate-CUuC5szR.js → translate-BcbSWkuq.js} +21 -26
- package/dist/assets/{translate-CUuC5szR.js.map → translate-BcbSWkuq.js.map} +1 -1
- package/dist/assets/{tree-store-N362nuzZ.js → tree-store-CAchkO_l.js} +22 -6
- package/dist/assets/tree-store-CAchkO_l.js.map +1 -0
- package/dist/assets/{types-Clyb52K2.js → types-CdWwgvyt.js} +2 -3
- package/dist/assets/{types-Clyb52K2.js.map → types-CdWwgvyt.js.map} +1 -1
- package/dist/assets/{unbzip2-stream-B1C-JX9L.js → unbzip2-stream-BtkYGpC5.js} +2 -3
- package/dist/assets/{unbzip2-stream-B1C-JX9L.js.map → unbzip2-stream-BtkYGpC5.js.map} +1 -1
- package/dist/assets/{usdt-DI51znt-.js → usdt-CBJ4Q5Ji.js} +7 -7
- package/dist/assets/usdt-CBJ4Q5Ji.js.map +1 -0
- package/dist/assets/{waitNotice-Cn0WJ-He.js → waitNotice-DQvZgz2T.js} +27 -4
- package/dist/assets/waitNotice-DQvZgz2T.js.map +1 -0
- package/dist/assets/{web-DwgdhfcY.js → web-68CYFCl9.js} +314 -91
- package/dist/assets/web-68CYFCl9.js.map +1 -0
- package/dist/ghostly.mjs +3 -5
- package/dist/ghostly.mjs.map +1 -1
- package/npm-shrinkwrap.json +225 -200
- package/package.json +16 -16
- package/dist/assets/api-MYc6QNRs.js.map +0 -1
- package/dist/assets/apiKit-CfsNx9ZR.js.map +0 -1
- package/dist/assets/appFetch-DVYZOZFw.js +0 -194
- package/dist/assets/appFetch-DVYZOZFw.js.map +0 -1
- package/dist/assets/apps-Dbw2Hcko.js +0 -2
- package/dist/assets/apps-h12II1us.js.map +0 -1
- package/dist/assets/arkade-Bw_4PZRG.js.map +0 -1
- package/dist/assets/backup-CdEzTq5C.js +0 -2
- package/dist/assets/backup-Chvy79SN.js.map +0 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js +0 -6
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +0 -1
- package/dist/assets/bitcoindProvider-BvoRh0D5.js +0 -97
- package/dist/assets/bitcoindProvider-BvoRh0D5.js.map +0 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js +0 -6
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +0 -1
- package/dist/assets/bitcoindevkit_bg-CRkZTSbO.wasm +0 -0
- package/dist/assets/buttons-BgoExb4E.js.map +0 -1
- package/dist/assets/buttons-DK2aAGat.js +0 -2
- package/dist/assets/endpoint-DarqblYE.js.map +0 -1
- package/dist/assets/errors-CAh6GLJZ.js.map +0 -1
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js +0 -6
- package/dist/assets/fileBytes-BLPZq9YU.js.map +0 -1
- package/dist/assets/fileBytes-BtIyoDF2.js +0 -2
- package/dist/assets/fileBytesIdb-D8mAK4pF.js +0 -2
- package/dist/assets/host-C0NMNQLl.js.map +0 -1
- package/dist/assets/hyperdhtRelay-1wzya_0L.js +0 -25
- package/dist/assets/hyperdhtRelay-1wzya_0L.js.map +0 -1
- package/dist/assets/hyperdhtRelay-Dz7pvcBA.js.map +0 -1
- package/dist/assets/irohWeb-caAj4Dms.js.map +0 -1
- package/dist/assets/joinTrace-D-fnt2p3.js +0 -2
- package/dist/assets/jsonOut-POtMBS_V.js +0 -16
- package/dist/assets/jsonOut-POtMBS_V.js.map +0 -1
- package/dist/assets/main-C6t5zrD5.js.map +0 -1
- package/dist/assets/mainline-DCuGUSZF.js.map +0 -1
- package/dist/assets/mints-BaOmx517.js +0 -2
- package/dist/assets/mints-j5XAOk4f.js.map +0 -1
- package/dist/assets/nwcProvider-PE0wli8n.js +0 -88
- package/dist/assets/nwcProvider-PE0wli8n.js.map +0 -1
- package/dist/assets/ownDid-C1R5Kd8q.js +0 -282
- package/dist/assets/ownDid-C1R5Kd8q.js.map +0 -1
- package/dist/assets/ownStatus-BoTf5WqQ.js.map +0 -1
- package/dist/assets/profiles-DszHjEJi.js.map +0 -1
- package/dist/assets/registry-Da-r6eC3.js.map +0 -1
- package/dist/assets/registry-zUZBSHYv.js +0 -2
- package/dist/assets/resolve-tUzh4lHh.js +0 -400
- package/dist/assets/resolve-tUzh4lHh.js.map +0 -1
- package/dist/assets/secretGuard-DCb1I0_B.js +0 -2
- package/dist/assets/server-C1jZZ61O.js.map +0 -1
- package/dist/assets/src-DJe-OYxd.js.map +0 -1
- package/dist/assets/sshForges-C9zTO72R.js +0 -261
- package/dist/assets/sshForges-C9zTO72R.js.map +0 -1
- package/dist/assets/storage-Bya5b2Xt.js.map +0 -1
- package/dist/assets/tree-store-N362nuzZ.js.map +0 -1
- package/dist/assets/usdt-DI51znt-.js.map +0 -1
- package/dist/assets/waitNotice-Cn0WJ-He.js.map +0 -1
- package/dist/assets/web-DwgdhfcY.js.map +0 -1
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { s as
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { t as childEnv } from "./childEnv-
|
|
12
|
-
import { t as
|
|
13
|
-
import { a as
|
|
14
|
-
import { a as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
1
|
+
import { Ai as parseLocalTarget, At as sanitizeTypingStatus, Ca as isAppUrl, Cn as sanitizeFileName, D as GROUP_FILE_LIMITS, Di as GhostlyHttpError, Dn as VOICE_METER, Dr as statusCardBytes, Dt as TYPING_REFRESH_MS, En as VOICE_LIMITS, Et as TYPING_KINDS, La as isAppRef, Mi as LIMITS, Mn as voiceDownloadName, Nn as voiceLevel, Oi as VIEWER_PERMISSIONS_POLICY, On as baseMime, Sr as cardLine, Tn as PLAYABLE_AUDIO, Ya as readImageMeta, ao as inviteLink, gr as STATUS_CARD_LIMITS, ja as appRef, jn as parseVoiceMeta, jr as claimedTime, kn as downsamplePeaks, kr as MESSAGE_CLOCK_SKEW_MS, n as groupCallSfu, or as replySnippet, so as ownInviteRefusal, tn as APP_DATA_MAX_BYTES, vr as appCardId, wn as sanitizeMime, wr as checkStatusCard, yi as AWAITING_PEER_MS, yr as appCardUrl } from "./groupMeta-DxuJzko_.js";
|
|
2
|
+
import { B as removeStored, Qt as withoutPictureMetadata, Tt as decodeGroupEntryLink, U as waitingGroupFile, W as IDENTITY_DRAFT_TTL_MS, Xt as NO_PICTURE_METADATA, Yt as withoutVideoMetadata, Zt as stripPictureMetadata, a as groupMemberOfLink, b as replyRef, c as groupPayTwin, ft as iceServerProblem, h as groupOfFile, k as paymentNetwork, o as groupPayLineId, p as groupFileId, pt as iceServerSetting, qt as withoutAudioMetadata, s as groupPayNoteId, t as DEFAULT_IROH_RELAYS } from "./irohWeb-CbnGtUo6.js";
|
|
3
|
+
import { c as normalizeRelayUrl, l as relayUrlProblem } from "./relay-Cjfmdec0.js";
|
|
4
|
+
import { n as secretWords, r as findSecret, t as guardText } from "./secretGuard-BrATm_gl.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-DtzIllg2.js";
|
|
6
|
+
import { i as localFileError, r as asCliError, t as CliError } from "./errors-DDLFO4Gf.js";
|
|
7
|
+
import { A as sentAt, B as shellWord, C as nobodyJoined, D as oneOf, E as num, I as state, L as str, M as shownName, N as sinceSeq, O as oneShotWaits, P as somebodyJoined, R as transportOffered, S as noMessage, T as node, _ as list, a as contactKeyOf, c as findChatOrGroup, d as groupById, f as groupNameOf, g as keptForJoin, h as inviteTaken, j as settingsOf, k as ownChatOf, l as findGroup, m as groupPrefixed, n as chatOf, o as dhtOnly, p as groupOf, r as chatOrGroup, s as findChat, t as bool, v as messageOf, x as noFile, z as waitForState } from "./apiKit-BlsNk-Cx.js";
|
|
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-CfvUXdSy.js";
|
|
10
|
+
import { p as fileStore } from "./idb-ewvbqyDI.js";
|
|
11
|
+
import { t as childEnv } from "./childEnv-C-99hdbL.js";
|
|
12
|
+
import { a as checkTextSize$1, c as nobodyElseIn, d as waitForConfirmed, f as waitForEdit, h as waitForRemoval, i as pressable, l as outOf, m as waitForMessage, n as buttonsCard, o as ended, p as waitForGroupFrame, s as goesOn, t as BUTTON_METHODS, u as purgeMessage } from "./buttons-SH1tNRh7.js";
|
|
13
|
+
import { a as checkShownName } from "./profiles-BOYGlmu2.js";
|
|
14
|
+
import { a as MAX_AVATAR_LENGTH, o as sanitizeAvatar } from "./linkPreview-DdMf-YAc.js";
|
|
15
|
+
import { m as identityStatement } from "./identityProofs-Cksc_K7_.js";
|
|
16
|
+
import { a as SignerTimeout, i as parseProofBunker, t as IDENTITY_PROVIDERS } from "./registry-Bep4umOM.js";
|
|
17
|
+
import { t as BACKUP_METHODS } from "./backup-BA41EDvh.js";
|
|
18
|
+
import { s as isAppFetchUrl } from "./appFetch-CW9fJPHh.js";
|
|
19
|
+
import { o as checkedBundle } from "./apps-CL8TXHhu.js";
|
|
20
|
+
import { m as parsePaymentAmount } from "./paymentIntent-DySU3Ajm.js";
|
|
21
|
+
import { t as chatState } from "./waitNotice-DQvZgz2T.js";
|
|
17
22
|
import { generateMnemonic } from "@scure/bip39";
|
|
18
23
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
19
24
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -24,7 +29,7 @@ import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
|
24
29
|
import { createServer } from "node:http";
|
|
25
30
|
import { Readable } from "node:stream";
|
|
26
31
|
import { pipeline } from "node:stream/promises";
|
|
27
|
-
|
|
32
|
+
// src/typing.ts
|
|
28
33
|
/**
|
|
29
34
|
* `typing --for` and `group typing --for`: a `start` holds 6 s on the other side (WISP 401 § Typing, WISP 902 · Group
|
|
30
35
|
* Mesh § Typing), so the daemon says it again until the time is up, a message goes to that chat or group, or a
|
|
@@ -124,8 +129,7 @@ function endTyping(ctx, target, tell) {
|
|
|
124
129
|
if (tell) sayTyping(ctx, target, false);
|
|
125
130
|
return true;
|
|
126
131
|
}
|
|
127
|
-
|
|
128
|
-
//#region src/voicePeaks.ts
|
|
132
|
+
// src/voicePeaks.ts
|
|
129
133
|
/** Longer than any voice note (15 minutes) with room: a WebM or Ogg past it is not read (their demuxers hold it all). */
|
|
130
134
|
var MAX_BYTES = 268435456;
|
|
131
135
|
/** Read first to tell a file's kind; a WAV's header is looked for in up to `WAV_HEAD_MAX` (as in ffmpeg's output). */
|
|
@@ -244,7 +248,10 @@ function kindOf(head) {
|
|
|
244
248
|
if (ascii(head, 0, 3) === "ID3" || head[0] === 255 && (head[1] & 224) === 224) return "mp3";
|
|
245
249
|
return null;
|
|
246
250
|
}
|
|
247
|
-
/**
|
|
251
|
+
/**
|
|
252
|
+
* Feeds `sink` the sound of a kind this module decodes itself, reading the file only as far as its decoder goes; false
|
|
253
|
+
* for a kind it leaves to ffmpeg, not read past its head.
|
|
254
|
+
*/
|
|
248
255
|
async function streamFile(path, sink) {
|
|
249
256
|
const file = await open(path);
|
|
250
257
|
try {
|
|
@@ -339,7 +346,10 @@ function sampleReader(view, format, bits) {
|
|
|
339
346
|
}
|
|
340
347
|
/** Frames of a channel each pushed at a time: few enough to keep nothing large, many enough for few calls. */
|
|
341
348
|
var PIECE_FRAMES = 4096;
|
|
342
|
-
/**
|
|
349
|
+
/**
|
|
350
|
+
* PCM (8, 16, 24 or 32 bit) or float (32 or 64 bit) WAV, read a piece of frames at a time until the sink wants no
|
|
351
|
+
* more. A data chunk whose size is unknown (a pipe) runs to the end.
|
|
352
|
+
*/
|
|
343
353
|
async function streamWavFile(file, size, sink) {
|
|
344
354
|
let header = null;
|
|
345
355
|
for (let length = HEAD_BYTES; !header; length *= 2) {
|
|
@@ -666,7 +676,9 @@ function streamFfmpeg(path, sink, command = process.env.GHOSTLY_FFMPEG || "ffmpe
|
|
|
666
676
|
});
|
|
667
677
|
child.on("error", (error) => {
|
|
668
678
|
clearTimeout(timer);
|
|
669
|
-
|
|
679
|
+
const setting = process.env.GHOSTLY_FFMPEG;
|
|
680
|
+
const missing = setting && command === setting ? `GHOSTLY_FFMPEG (${setting}) is not there: set it to ffmpeg's path, or unset it to use the one on the PATH` : "no decoder here for this kind of audio (install ffmpeg to read it)";
|
|
681
|
+
reject(new Error(error.code === "ENOENT" ? missing : `ffmpeg: ${error.message}`));
|
|
670
682
|
});
|
|
671
683
|
child.on("close", (code) => {
|
|
672
684
|
clearTimeout(timer);
|
|
@@ -695,8 +707,7 @@ function streamFfmpeg(path, sink, command = process.env.GHOSTLY_FFMPEG || "ffmpe
|
|
|
695
707
|
});
|
|
696
708
|
});
|
|
697
709
|
}
|
|
698
|
-
|
|
699
|
-
//#region src/files.ts
|
|
710
|
+
// src/files.ts
|
|
700
711
|
/**
|
|
701
712
|
* Files and voice notes in a chat (WISP 1100, phase 3), as the app's composer sends them (packages/browser
|
|
702
713
|
* platform/services.ts `sendFile`): the bytes go into the profile's file store first, then the engine offers them.
|
|
@@ -722,12 +733,18 @@ var TYPES = {
|
|
|
722
733
|
".ogg": "audio/ogg",
|
|
723
734
|
".opus": "audio/ogg",
|
|
724
735
|
".wav": "audio/wav",
|
|
736
|
+
".aac": "audio/aac",
|
|
737
|
+
".flac": "audio/flac",
|
|
738
|
+
".oga": "audio/ogg",
|
|
739
|
+
".weba": "audio/webm",
|
|
725
740
|
".webm": "audio/webm",
|
|
726
741
|
".mp4": "video/mp4",
|
|
727
742
|
".mov": "video/quicktime"
|
|
728
743
|
};
|
|
729
|
-
|
|
730
|
-
|
|
744
|
+
/** A voice note in an .mp4 is its sound in an MP4 box, as an .m4a: sent as audio/mp4, not as a video. */
|
|
745
|
+
function mimeOf(path, given, voice = false) {
|
|
746
|
+
const known = TYPES[extname(path).toLowerCase()];
|
|
747
|
+
return sanitizeMime(given ?? (voice && known === "video/mp4" ? "audio/mp4" : known) ?? "application/octet-stream");
|
|
731
748
|
}
|
|
732
749
|
/**
|
|
733
750
|
* The time a saved voice message is named from: its message's in the chat, as the apps' Download names it. The file's
|
|
@@ -839,7 +856,7 @@ async function voiceOf(params, path, mime, size) {
|
|
|
839
856
|
if (params.voice === void 0) return {};
|
|
840
857
|
const name = basename(path);
|
|
841
858
|
if (!size) throw new CliError("bad_request", `${name} is empty: a voice note is audio`);
|
|
842
|
-
if (!PLAYABLE_AUDIO.test(baseMime(mime))) throw new CliError("bad_request", `${name} is ${mime}, not audio (webm, ogg, mp4, mpeg, aac,
|
|
859
|
+
if (!PLAYABLE_AUDIO.test(baseMime(mime))) throw new CliError("bad_request", `${name} is ${mime}, not audio (webm, ogg, opus, mp4, m4a, mpeg, aac, wav or flac)`);
|
|
843
860
|
const given = params.voice === true ? void 0 : num(params, "voice", 0, { min: 1 });
|
|
844
861
|
let duration = given;
|
|
845
862
|
let peaks = list(params, "peaks").map(Number);
|
|
@@ -901,13 +918,28 @@ async function whileUnchanged(path, read) {
|
|
|
901
918
|
}
|
|
902
919
|
}
|
|
903
920
|
/**
|
|
921
|
+
* The file copied into the profile (`stage`) for a send whose client is still there to hear of it (`CallScope.gone`).
|
|
922
|
+
* Ctrl-C on `file send` through a daemon, while a large file was copied in (seconds per GiB), said "stopped before the
|
|
923
|
+
* command answered"; the daemon went on, and the file went to the contact a moment later. Sent again, it went twice.
|
|
924
|
+
* The copy stops at its next step, and what was copied is removed: nothing is in the chat, nothing goes.
|
|
925
|
+
*/
|
|
926
|
+
async function stageWhileAsked(bytes, id, path, source, gone) {
|
|
927
|
+
const stillAsked = () => {
|
|
928
|
+
if (gone?.aborted) throw new CliError("interrupted", "The file was not sent: the command that sent it went away before it was copied in");
|
|
929
|
+
};
|
|
930
|
+
const digest = await whileUnchanged(path, () => bytes.stage(id, source, stillAsked));
|
|
931
|
+
if (gone?.aborted) await bytes.remove(id).catch(() => {});
|
|
932
|
+
stillAsked();
|
|
933
|
+
return digest;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
904
936
|
* 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
|
|
905
937
|
* the announcement. This device is its first holder and serves the members who ask.
|
|
906
938
|
*/
|
|
907
|
-
async function sendToGroup(ctx, params, group, path, name, picked) {
|
|
939
|
+
async function sendToGroup(ctx, params, group, path, name, picked, gone) {
|
|
908
940
|
if (picked > GROUP_FILE_LIMITS.maxBytes) throw new CliError("refused", `Too large for a group (at most ${GROUP_FILE_LIMITS.maxBytes} bytes)`);
|
|
909
941
|
if (!picked) throw new CliError("refused", "An empty file cannot go to a group");
|
|
910
|
-
const mime = mimeOf(path, str(params, "mime"));
|
|
942
|
+
const mime = mimeOf(path, str(params, "mime"), params.voice !== void 0);
|
|
911
943
|
const replyTo = str(params, "reply");
|
|
912
944
|
if (replyTo) {
|
|
913
945
|
if (!await findMessage(ctx, `group:${group.id}`, (m) => m.id === replyTo || replyRef(m) === replyTo)) throw noMessage(replyTo, {
|
|
@@ -932,7 +964,7 @@ async function sendToGroup(ctx, params, group, path, name, picked) {
|
|
|
932
964
|
};
|
|
933
965
|
const timestamp = Date.now();
|
|
934
966
|
const bytes = await fileBytes();
|
|
935
|
-
const digest = await
|
|
967
|
+
const digest = await stageWhileAsked(bytes, fileId, path, source, gone);
|
|
936
968
|
await fileStore.put({
|
|
937
969
|
id: fileId,
|
|
938
970
|
linkId: `group:${group.id}`,
|
|
@@ -1100,7 +1132,7 @@ function waitsForYou(name, fileId, where, size) {
|
|
|
1100
1132
|
});
|
|
1101
1133
|
}
|
|
1102
1134
|
var FILE_METHODS = {
|
|
1103
|
-
async "file.send"(ctx, params) {
|
|
1135
|
+
async "file.send"(ctx, params, call) {
|
|
1104
1136
|
const path = resolve(str(params, "path", true));
|
|
1105
1137
|
const name = sanitizeFileName(str(params, "name") ?? basename(path));
|
|
1106
1138
|
guardText(name, bool(params, "force"), "file's name", "send it");
|
|
@@ -1118,12 +1150,12 @@ var FILE_METHODS = {
|
|
|
1118
1150
|
min: 1,
|
|
1119
1151
|
max: 86400
|
|
1120
1152
|
});
|
|
1121
|
-
if ("group" in target) return sendToGroup(ctx, params, target.group, path, name, info.size);
|
|
1153
|
+
if ("group" in target) return sendToGroup(ctx, params, target.group, path, name, info.size, call?.gone);
|
|
1122
1154
|
const { link } = target;
|
|
1123
1155
|
if (link.profile && link.dataLink === "open" && !link.capabilities?.files) throw new CliError("unavailable", "The contact's app takes no files");
|
|
1124
1156
|
if (link.dataLink === "open" && !link.capabilities?.largeFiles && info.size > LIMITS.maxFileBytes) throw new CliError("refused", `Too large for the contact's app (at most ${LIMITS.maxFileBytes} bytes)`);
|
|
1125
1157
|
if (typeof link.peerFileRoom === "number" && info.size > link.peerFileRoom) throw new CliError("refused", `Not enough space on the contact's device (${link.peerFileRoom} bytes free)`);
|
|
1126
|
-
const mime = mimeOf(path, str(params, "mime"));
|
|
1158
|
+
const mime = mimeOf(path, str(params, "mime"), params.voice !== void 0);
|
|
1127
1159
|
const replyTo = str(params, "reply");
|
|
1128
1160
|
if (replyTo) {
|
|
1129
1161
|
if (!await findMessage(ctx, link.id, (m) => m.id === replyTo || replyRef(m) === replyTo)) throw noMessage(replyTo, {
|
|
@@ -1145,7 +1177,7 @@ var FILE_METHODS = {
|
|
|
1145
1177
|
};
|
|
1146
1178
|
const timestamp = sentAt();
|
|
1147
1179
|
const bytes = await fileBytes();
|
|
1148
|
-
const digest = await
|
|
1180
|
+
const digest = await stageWhileAsked(bytes, file.id, path, source, call?.gone);
|
|
1149
1181
|
await fileStore.put({
|
|
1150
1182
|
id: file.id,
|
|
1151
1183
|
linkId: link.id,
|
|
@@ -1267,6 +1299,7 @@ var FILE_METHODS = {
|
|
|
1267
1299
|
transfer: state(ctx).transfers[fileId] ?? null
|
|
1268
1300
|
};
|
|
1269
1301
|
}
|
|
1302
|
+
if (!state(ctx).transfers[fileId] && !await fileStore.get(fileId).catch(() => void 0)) throw noFile(fileId);
|
|
1270
1303
|
if (action === "resend" || action === "request") {
|
|
1271
1304
|
const outgoing = fileId.startsWith(`${linkId}-out-`);
|
|
1272
1305
|
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");
|
|
@@ -1330,23 +1363,32 @@ var FILE_METHODS = {
|
|
|
1330
1363
|
const named = str(params, "path") ? resolve(str(params, "path", true)) : join(resolve(str(params, "dir") ?? "."), saveName(stored.metadata.voice ? voiceDownloadName(stored.metadata.mime, await voiceTime(ctx, stored)) : stored.metadata.name));
|
|
1331
1364
|
const force = bool(params, "force");
|
|
1332
1365
|
const path = str(params, "path");
|
|
1333
|
-
if (path && (path.endsWith("/") || path.endsWith(sep))
|
|
1366
|
+
if (path && (path.endsWith("/") || path.endsWith(sep))) {
|
|
1367
|
+
const there = await stat(named).catch(() => void 0);
|
|
1368
|
+
if (!there) throw new CliError("not_found", `No such folder: ${named} (make it first, or name a file in a folder that is there)`);
|
|
1369
|
+
if (!there.isDirectory()) throw new CliError("not_found", `${named} is a file, not a folder: name a file in a folder that is there`);
|
|
1370
|
+
}
|
|
1334
1371
|
const free = !force && !str(params, "path") && !!stored.metadata.voice;
|
|
1335
1372
|
const ext = extname(named), stem = named.slice(0, named.length - ext.length);
|
|
1373
|
+
let next = 2;
|
|
1336
1374
|
const taken = async (target, code) => {
|
|
1337
1375
|
const there = await stat(target).catch(() => void 0);
|
|
1338
|
-
if (there?.isDirectory()) return new CliError("
|
|
1376
|
+
if (there?.isDirectory() && free && next <= 1e3) return new CliError("confirm", `${target} is a folder`);
|
|
1377
|
+
if (there?.isDirectory()) return new CliError("bad_request", `${target} is a folder: name a file, or use --dir ${shellWord(target, "<the one in details.dir>")} (dir over the socket)`, { dir: target });
|
|
1339
1378
|
if (!(there && !force || code === "EEXIST")) return;
|
|
1340
1379
|
const replace = `${target} exists: pass --force (force: true over the socket) to replace it`;
|
|
1341
1380
|
if (path) return new CliError("confirm", replace);
|
|
1381
|
+
if (free && next <= 1e3) return new CliError("confirm", replace);
|
|
1342
1382
|
let n = 2;
|
|
1343
1383
|
while (n <= 1e3 && await stat(`${stem} (${n})${ext}`).catch(() => void 0)) n += 1;
|
|
1344
|
-
|
|
1384
|
+
const other = `${stem} (${n})${ext}`;
|
|
1385
|
+
return new CliError("confirm", `${replace}, or --path ${shellWord(other, "<the one in details.path>")} (path over the socket) to keep both`, { path: other });
|
|
1345
1386
|
};
|
|
1346
1387
|
let target = named;
|
|
1347
|
-
for (let
|
|
1348
|
-
if (!free || refused.code !== "confirm" ||
|
|
1349
|
-
target = `${stem} (${
|
|
1388
|
+
for (let refused = await taken(target); refused; refused = await taken(target)) {
|
|
1389
|
+
if (!free || refused.code !== "confirm" || next > 1e3) throw refused;
|
|
1390
|
+
target = `${stem} (${next})${ext}`;
|
|
1391
|
+
next += 1;
|
|
1350
1392
|
}
|
|
1351
1393
|
const partial = join(dirname(target), `.ghostly-save-${process.pid}-${toBase64Url(randomBytes$1(6))}.partial`);
|
|
1352
1394
|
const asked = (error, where) => {
|
|
@@ -1387,14 +1429,15 @@ var FILE_METHODS = {
|
|
|
1387
1429
|
} else throw new CliError("not_found", "The file's bytes are not on this device");
|
|
1388
1430
|
await out.close();
|
|
1389
1431
|
out = null;
|
|
1390
|
-
|
|
1432
|
+
while (!complete) try {
|
|
1391
1433
|
await place(partial, target, force);
|
|
1392
1434
|
complete = true;
|
|
1393
1435
|
} catch (error) {
|
|
1394
1436
|
const code = error.code;
|
|
1395
1437
|
const refused = code === "EEXIST" || code === "EISDIR" || code === "ENOTEMPTY" ? await taken(target, code) : void 0;
|
|
1396
|
-
if (free && refused?.code === "confirm" &&
|
|
1397
|
-
target = `${stem} (${
|
|
1438
|
+
if (free && refused?.code === "confirm" && next <= 1e3) {
|
|
1439
|
+
target = `${stem} (${next})${ext}`;
|
|
1440
|
+
next += 1;
|
|
1398
1441
|
continue;
|
|
1399
1442
|
}
|
|
1400
1443
|
throw refused ?? error;
|
|
@@ -1415,8 +1458,7 @@ var FILE_METHODS = {
|
|
|
1415
1458
|
};
|
|
1416
1459
|
}
|
|
1417
1460
|
};
|
|
1418
|
-
|
|
1419
|
-
//#region src/statusCards.ts
|
|
1461
|
+
// src/statusCards.ts
|
|
1420
1462
|
/** A card's updates go at most this often: the rest merge into the next, so a chatty bot spends few edits. */
|
|
1421
1463
|
var CARD_UPDATE_GAP_MS = 2500;
|
|
1422
1464
|
var paces = /* @__PURE__ */ new WeakMap();
|
|
@@ -1876,8 +1918,7 @@ var STATUS_CARD_METHODS = {
|
|
|
1876
1918
|
/** WISP 405 § Usage: how much of a quota the bot has left, kept as one card per chat; `all` for every 1:1 chat. */
|
|
1877
1919
|
"usage.send": sendUsage
|
|
1878
1920
|
};
|
|
1879
|
-
|
|
1880
|
-
//#region src/holds.ts
|
|
1921
|
+
// src/holds.ts
|
|
1881
1922
|
/**
|
|
1882
1923
|
* `chat disconnect --hold <minutes>`: a chat kept off its direct link for a while. It is the chat's own "DHT only"
|
|
1883
1924
|
* choice (WISP 400: either side choosing it keeps both off the live link, so the contact's app does not redial),
|
|
@@ -2062,8 +2103,7 @@ function resumeHolds(ctx) {
|
|
|
2062
2103
|
if (gone.length) writeHolds(ctx, holds);
|
|
2063
2104
|
for (const [linkId, hold] of Object.entries(holds)) schedule(ctx, linkId, hold.until);
|
|
2064
2105
|
}
|
|
2065
|
-
|
|
2066
|
-
//#region src/views.ts
|
|
2106
|
+
// src/views.ts
|
|
2067
2107
|
/**
|
|
2068
2108
|
* A live session carries the chat now, in this run: its link is open and, on a paired chat, the session authenticated
|
|
2069
2109
|
* on a transport. The engine's own rule for a chat's connection line (`observeTransport`). `textDelivery` alone says
|
|
@@ -2342,11 +2382,14 @@ function groupJson(group, showSecret = false) {
|
|
|
2342
2382
|
}) } : {},
|
|
2343
2383
|
community: group.community ?? null,
|
|
2344
2384
|
picture: !!group.picture,
|
|
2385
|
+
call: group.call ? {
|
|
2386
|
+
sfu: group.call.sfu,
|
|
2387
|
+
e2ee: group.call.e2ee === 1
|
|
2388
|
+
} : null,
|
|
2345
2389
|
pin: pinJson(group.pin)
|
|
2346
2390
|
};
|
|
2347
2391
|
}
|
|
2348
|
-
|
|
2349
|
-
//#region src/groupAdmin.ts
|
|
2392
|
+
// src/groupAdmin.ts
|
|
2350
2393
|
/**
|
|
2351
2394
|
* Group administration and pictures (WISP 1100, phase 3): what the app's group menu and profile screen do. The
|
|
2352
2395
|
* engine enforces who may do what (the admin); these check the arguments and name members.
|
|
@@ -2414,10 +2457,29 @@ async function pictureFrom(path) {
|
|
|
2414
2457
|
return checked;
|
|
2415
2458
|
}
|
|
2416
2459
|
async function picture(params) {
|
|
2460
|
+
if (bool(params, "clear") && str(params, "path") !== void 0) throw new CliError("bad_request", "clear removes the picture: not with path");
|
|
2417
2461
|
if (bool(params, "clear")) return null;
|
|
2418
2462
|
return pictureFrom(str(params, "path", true));
|
|
2419
2463
|
}
|
|
2420
2464
|
/**
|
|
2465
|
+
* The node a group's calls go through (WISP 602): an https origin in its one spelling, refused here before anything is
|
|
2466
|
+
* signed. A URL that names an https origin in another spelling (a path, a trailing `/`, capitals, `:443`) is told that
|
|
2467
|
+
* origin, and an origin past the limit is told the limit: before, both were told of a path, query or `/` it may not have.
|
|
2468
|
+
*/
|
|
2469
|
+
function callNode(raw, ref, groupId) {
|
|
2470
|
+
const sfu = groupCallSfu(raw);
|
|
2471
|
+
if (sfu) return sfu;
|
|
2472
|
+
let origin;
|
|
2473
|
+
try {
|
|
2474
|
+
const url = new URL(raw);
|
|
2475
|
+
if (url.protocol === "https:") origin = url.origin;
|
|
2476
|
+
} catch {}
|
|
2477
|
+
const quoted = JSON.stringify(raw);
|
|
2478
|
+
if (!origin) throw new CliError("bad_request", `${quoted} is not an https origin: a call node is like https://call.example.com`);
|
|
2479
|
+
if (origin.length > 200) throw new CliError("bad_request", `${quoted} is too long: a call node is an https origin of at most 200 characters`);
|
|
2480
|
+
throw new CliError("bad_request", `${quoted} is not in its one spelling (lower case, no default port, path, query or trailing /): ghostly group call ${shellWord(ref, groupId)} --sfu ${origin}`);
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2421
2483
|
* A group this profile administers or is in, not only an invitation: before, the engine answered `group rename`,
|
|
2422
2484
|
* `picture`, `link`, `rotate` and `invite` on an invitation not yet joined with "Group not found" (engine, exit 1),
|
|
2423
2485
|
* while `group show` listed it, and `remove`/`admin` said "No member" of a member list it had not received yet.
|
|
@@ -2425,12 +2487,21 @@ async function picture(params) {
|
|
|
2425
2487
|
function joined(ctx, params, twin) {
|
|
2426
2488
|
const group = groupOf(ctx, params, twin);
|
|
2427
2489
|
if (group.status || !group.invitation) return group;
|
|
2428
|
-
const
|
|
2490
|
+
const shown = shellWord(str(params, "group", true), group.id);
|
|
2429
2491
|
throw new CliError("refused", group.invitation.accepted ? `You are not in ${group.name} yet: you accepted its invitation, and its admin has not let you in` : `You are not in ${group.name} yet: ghostly group accept ${shown} joins it`);
|
|
2430
2492
|
}
|
|
2431
2493
|
/** The member `params.member` names in `group`, this profile's own name said to be it; by its key only for a grant. */
|
|
2432
2494
|
var member = (ctx, group, params, grant = false) => findMember(group, str(params, "member", true), settingsOf(ctx).nick, grant);
|
|
2433
|
-
|
|
2495
|
+
/**
|
|
2496
|
+
* A group's link and the address that opens it in the app, as `invite create` answers `invite` and `link`. Only the
|
|
2497
|
+
* token (`group2/…`) was given: pasted in a chat it is no link anyone can tap, and the app's own Share link is this one.
|
|
2498
|
+
*/
|
|
2499
|
+
var withUrl = (group, link) => ({
|
|
2500
|
+
group,
|
|
2501
|
+
link,
|
|
2502
|
+
...link && { url: `https://app.ghostly.tools/#/join/${link}` }
|
|
2503
|
+
});
|
|
2504
|
+
var view = (ctx, id, params) => groupJson(groupOf(ctx, { group: id }), bool(params, "showSecret"));
|
|
2434
2505
|
var GROUP_ADMIN_METHODS = {
|
|
2435
2506
|
async "group.invite"(ctx, params) {
|
|
2436
2507
|
const group = joined(ctx, params);
|
|
@@ -2448,7 +2519,7 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2448
2519
|
groupId: group.id,
|
|
2449
2520
|
key: removed.key
|
|
2450
2521
|
});
|
|
2451
|
-
const linkOn = !!(
|
|
2522
|
+
const linkOn = !!(groupById(ctx, group.id) ?? group).entryLink;
|
|
2452
2523
|
return {
|
|
2453
2524
|
...view(ctx, group.id, params),
|
|
2454
2525
|
...linkOn && { warning: `${removed.nick ?? "They"} can still join again with the group's link: ghostly group link ${group.id} --reset gives it a new one and keeps them out` }
|
|
@@ -2494,6 +2565,8 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2494
2565
|
},
|
|
2495
2566
|
async "group.link"(ctx, params) {
|
|
2496
2567
|
const group = joined(ctx, params);
|
|
2568
|
+
const out = outOf(group);
|
|
2569
|
+
if (out) throw new CliError("refused", out);
|
|
2497
2570
|
const on = params.on === void 0 || bool(params, "on"), reset = bool(params, "reset");
|
|
2498
2571
|
if (!on && reset) throw new CliError("bad_request", "on: false turns the link off: not with reset");
|
|
2499
2572
|
if (!on) {
|
|
@@ -2507,10 +2580,7 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2507
2580
|
groupId: group.id,
|
|
2508
2581
|
...reset ? { reset: true } : {}
|
|
2509
2582
|
});
|
|
2510
|
-
return
|
|
2511
|
-
group: group.id,
|
|
2512
|
-
link
|
|
2513
|
-
};
|
|
2583
|
+
return withUrl(group.id, link);
|
|
2514
2584
|
},
|
|
2515
2585
|
async "group.picture"(ctx, params) {
|
|
2516
2586
|
const group = joined(ctx, params);
|
|
@@ -2523,14 +2593,35 @@ var GROUP_ADMIN_METHODS = {
|
|
|
2523
2593
|
picture: !bool(params, "clear")
|
|
2524
2594
|
};
|
|
2525
2595
|
},
|
|
2596
|
+
async "group.call"(ctx, params) {
|
|
2597
|
+
const group = joined(ctx, params);
|
|
2598
|
+
if (group.profile !== "community") throw new CliError("refused", `${group.name} is a private group: only a community group has calls through a node`);
|
|
2599
|
+
const out = outOf(group);
|
|
2600
|
+
if (out) throw new CliError("refused", out);
|
|
2601
|
+
if (!group.isAdmin) throw new CliError("refused", `Only the admin of ${group.name} sets its call node`);
|
|
2602
|
+
const ref = str(params, "group", true), raw = str(params, "sfu");
|
|
2603
|
+
const e2ee = params.e2ee === void 0 || params.e2ee === null ? void 0 : bool(params, "e2ee");
|
|
2604
|
+
let sfu;
|
|
2605
|
+
if (bool(params, "clear") && raw !== void 0) throw new CliError("bad_request", "clear removes the call node: not with sfu");
|
|
2606
|
+
if (bool(params, "clear") && e2ee !== void 0) throw new CliError("bad_request", "clear removes the call node: not with e2ee");
|
|
2607
|
+
if (bool(params, "clear")) sfu = null;
|
|
2608
|
+
else if (raw !== void 0 || e2ee === void 0) sfu = callNode(str(params, "sfu", true), ref, group.id);
|
|
2609
|
+
else if (group.call) sfu = group.call.sfu;
|
|
2610
|
+
else throw new CliError("refused", `${group.name} has no call node: ghostly group call ${shellWord(ref, group.id)} --sfu <https origin>${e2ee ? " --e2ee" : ""}`);
|
|
2611
|
+
await node(ctx).setGroupCall({
|
|
2612
|
+
groupId: group.id,
|
|
2613
|
+
sfu,
|
|
2614
|
+
...sfu !== null && e2ee !== void 0 && { e2ee }
|
|
2615
|
+
});
|
|
2616
|
+
return view(ctx, group.id, params);
|
|
2617
|
+
},
|
|
2526
2618
|
async "profile.picture"(ctx, params) {
|
|
2527
2619
|
const avatar = await picture(params);
|
|
2528
2620
|
await node(ctx).updateSettings({ settings: { avatar: avatar ?? "" } });
|
|
2529
2621
|
return { picture: avatar !== null };
|
|
2530
2622
|
}
|
|
2531
2623
|
};
|
|
2532
|
-
|
|
2533
|
-
//#region src/identities.ts
|
|
2624
|
+
// src/identities.ts
|
|
2534
2625
|
/**
|
|
2535
2626
|
* Drafts per daemon: a proof made in two steps needs the same process for both. Kept as long as the engine keeps them,
|
|
2536
2627
|
* and the oldest dropped when a fifth begins as the engine drops it, so what `identity add` promises still completes.
|
|
@@ -2674,9 +2765,11 @@ var IDENTITY_METHODS = {
|
|
|
2674
2765
|
} catch (error) {
|
|
2675
2766
|
throw new CliError("bad_request", `${bunker.name} (${bunker.label}): ${error instanceof Error ? error.message : String(error)}`);
|
|
2676
2767
|
}
|
|
2677
|
-
const
|
|
2768
|
+
const most = signer.maxWaitMs ? Math.floor(signer.maxWaitMs / 1e3) : 3600;
|
|
2769
|
+
if (typeof params.timeout === "number" && params.timeout > most) throw new CliError("bad_request", `timeout must be a number from 5 to ${most}: ${signer.label} waits at most ${most} s for an approval`);
|
|
2770
|
+
const seconds = num(params, "timeout", Math.min(300, most), {
|
|
2678
2771
|
min: 5,
|
|
2679
|
-
max:
|
|
2772
|
+
max: most
|
|
2680
2773
|
});
|
|
2681
2774
|
const signal = AbortSignal.timeout(seconds * 1e3);
|
|
2682
2775
|
return {
|
|
@@ -2684,6 +2777,7 @@ var IDENTITY_METHODS = {
|
|
|
2684
2777
|
proof: proofJson(await signer.run({
|
|
2685
2778
|
values,
|
|
2686
2779
|
signal,
|
|
2780
|
+
waitMs: seconds * 1e3,
|
|
2687
2781
|
onAuthUrl: (url) => {
|
|
2688
2782
|
ctx.hub.emitLive("identity.approval", `identity.approval:${Date.now()}`, {
|
|
2689
2783
|
provider: p.id,
|
|
@@ -2720,7 +2814,7 @@ var IDENTITY_METHODS = {
|
|
|
2720
2814
|
throw error;
|
|
2721
2815
|
}
|
|
2722
2816
|
}).catch((error) => {
|
|
2723
|
-
if (!signal.aborted || error instanceof CliError) throw error;
|
|
2817
|
+
if (!(signal.aborted || error instanceof SignerTimeout) || error instanceof CliError) throw error;
|
|
2724
2818
|
throw new CliError("timeout", `Timed out after ${seconds} s waiting for ${signer.label} to approve the ${p.label} proof: --timeout <seconds> waits longer`);
|
|
2725
2819
|
}))
|
|
2726
2820
|
};
|
|
@@ -2853,8 +2947,7 @@ var IDENTITY_METHODS = {
|
|
|
2853
2947
|
return IDENTITY_METHODS["identity.contact"](ctx, { chat: link.id });
|
|
2854
2948
|
}
|
|
2855
2949
|
};
|
|
2856
|
-
|
|
2857
|
-
//#region src/x401.ts
|
|
2950
|
+
// src/x401.ts
|
|
2858
2951
|
/**
|
|
2859
2952
|
* x401 credentials (WISP 3xx): the holder keys and issued credentials a bot keeps to show a website who stands behind
|
|
2860
2953
|
* it. Here only keeping them: `x401 fetch`, which presents one, comes later. Claim values are printed only with
|
|
@@ -2894,8 +2987,7 @@ var X401_METHODS = {
|
|
|
2894
2987
|
return { removed: id };
|
|
2895
2988
|
}
|
|
2896
2989
|
};
|
|
2897
|
-
|
|
2898
|
-
//#region src/services.ts
|
|
2990
|
+
// src/services.ts
|
|
2899
2991
|
/**
|
|
2900
2992
|
* Shared services (WISP 700/701, WISP 1100 phase 3b): a web app on this machine a contact may open over the chat's live
|
|
2901
2993
|
* link, and a contact's app opened here on a loopback port. As on the Desktop: only loopback is reached, redirects are
|
|
@@ -3019,6 +3111,11 @@ var OPENED_SERVICE_DROPPED_HEADERS = [
|
|
|
3019
3111
|
"nel",
|
|
3020
3112
|
"link"
|
|
3021
3113
|
];
|
|
3114
|
+
/**
|
|
3115
|
+
* A contact's headers that would set the page's browser features (camera, microphone, location, a device): the
|
|
3116
|
+
* viewer's own `VIEWER_PERMISSIONS_POLICY` takes their place, as in the extension's viewer (core `withViewerPolicy`).
|
|
3117
|
+
*/
|
|
3118
|
+
var OPENED_SERVICE_FEATURE_HEADERS = ["permissions-policy", "feature-policy"];
|
|
3022
3119
|
/** The directives of a contact's policy that send reports to a URL it names, dropped from it. */
|
|
3023
3120
|
var OPENED_SERVICE_DROPPED_DIRECTIVES = ["report-uri", "report-to"];
|
|
3024
3121
|
/** A contact's `Content-Security-Policy` value (one policy or several joined by commas) without its report directives. */
|
|
@@ -3118,7 +3215,7 @@ async function proxy(request, response, chunks, send, cookies, policy) {
|
|
|
3118
3215
|
const out = {};
|
|
3119
3216
|
for (const [name, value] of answer.headers) {
|
|
3120
3217
|
const lower = name.toLowerCase();
|
|
3121
|
-
if (lower === "transfer-encoding" || lower === "connection" || OPENED_SERVICE_DROPPED_HEADERS.includes(lower)) continue;
|
|
3218
|
+
if (lower === "transfer-encoding" || lower === "connection" || OPENED_SERVICE_DROPPED_HEADERS.includes(lower) || OPENED_SERVICE_FEATURE_HEADERS.includes(lower)) continue;
|
|
3122
3219
|
if (lower === "set-cookie") {
|
|
3123
3220
|
const cookie = hostOnlyCookie(value);
|
|
3124
3221
|
if (!cookie) continue;
|
|
@@ -3130,6 +3227,7 @@ async function proxy(request, response, chunks, send, cookies, policy) {
|
|
|
3130
3227
|
} else out[lower] = value;
|
|
3131
3228
|
}
|
|
3132
3229
|
out["content-security-policy"] = [...out["content-security-policy"] ?? [], policy];
|
|
3230
|
+
out["permissions-policy"] = VIEWER_PERMISSIONS_POLICY;
|
|
3133
3231
|
response.writeHead(answer.status, out);
|
|
3134
3232
|
await pipeline(Readable.from(answer.body, { objectMode: false }), response);
|
|
3135
3233
|
} catch (error) {
|
|
@@ -3156,6 +3254,18 @@ function serviceOf(ctx, params) {
|
|
|
3156
3254
|
return serviceId;
|
|
3157
3255
|
}
|
|
3158
3256
|
/**
|
|
3257
|
+
* On, unless `off`; or as the answer's own key (`shared`, `enabled`) says, when a socket client sends it back. Before,
|
|
3258
|
+
* only `off` was read, so `{"shared": false}` shared the service with the contact and `{"enabled": false}` turned it on.
|
|
3259
|
+
* Both, saying the opposite, are refused: neither is guessed.
|
|
3260
|
+
*/
|
|
3261
|
+
function onUnlessOff(params, key) {
|
|
3262
|
+
const on = !bool(params, "off");
|
|
3263
|
+
if (params[key] === void 0 || params[key] === null) return on;
|
|
3264
|
+
const said = bool(params, key);
|
|
3265
|
+
if (params.off !== void 0 && params.off !== null && said !== on) throw new CliError("bad_request", `${key}: ${said} and off: ${!on} say the opposite: give one of them`);
|
|
3266
|
+
return said;
|
|
3267
|
+
}
|
|
3268
|
+
/**
|
|
3159
3269
|
* A port the person chose that could not be taken, in words that name it. Before, one in use was Node's EADDRINUSE as
|
|
3160
3270
|
* `engine`, and one not allowed read as a file (`localFileError`): "Not allowed to write or read the path".
|
|
3161
3271
|
*/
|
|
@@ -3220,19 +3330,20 @@ var SERVICE_METHODS = {
|
|
|
3220
3330
|
return { removed: serviceId };
|
|
3221
3331
|
},
|
|
3222
3332
|
async "service.enable"(ctx, params) {
|
|
3333
|
+
const enabled = onUnlessOff(params, "enabled");
|
|
3223
3334
|
const serviceId = serviceOf(ctx, params);
|
|
3224
3335
|
await node(ctx).setServiceEnabled({
|
|
3225
3336
|
serviceId,
|
|
3226
|
-
enabled
|
|
3337
|
+
enabled
|
|
3227
3338
|
});
|
|
3228
3339
|
return {
|
|
3229
3340
|
service: serviceId,
|
|
3230
|
-
enabled
|
|
3341
|
+
enabled
|
|
3231
3342
|
};
|
|
3232
3343
|
},
|
|
3233
3344
|
async "service.share"(ctx, params) {
|
|
3234
3345
|
const link = ownChatOf(ctx, params);
|
|
3235
|
-
const shared =
|
|
3346
|
+
const shared = onUnlessOff(params, "shared");
|
|
3236
3347
|
const serviceId = serviceOf(ctx, params);
|
|
3237
3348
|
await node(ctx).setServiceShared({
|
|
3238
3349
|
serviceId,
|
|
@@ -3326,8 +3437,7 @@ async function closeServicesOf(ctx, peer) {
|
|
|
3326
3437
|
if (entry) await closeOpened(entry);
|
|
3327
3438
|
}));
|
|
3328
3439
|
}
|
|
3329
|
-
|
|
3330
|
-
//#region src/calls/api.ts
|
|
3440
|
+
// src/calls/api.ts
|
|
3331
3441
|
/** Voice calls (WISP 1100 § Calls): the API methods. The audio itself goes over each call's own socket. */
|
|
3332
3442
|
var CALL_METHODS = {
|
|
3333
3443
|
async "call.start"(ctx, params) {
|
|
@@ -3362,8 +3472,7 @@ var CALL_METHODS = {
|
|
|
3362
3472
|
}) };
|
|
3363
3473
|
}
|
|
3364
3474
|
};
|
|
3365
|
-
|
|
3366
|
-
//#region src/appServe.ts
|
|
3475
|
+
// src/appServe.ts
|
|
3367
3476
|
/** The permissions a bot can be granted: `internet` and `files` are a page's, and no page runs here. */
|
|
3368
3477
|
var GRANTABLE = ["chat", "name"];
|
|
3369
3478
|
var servedFile = (dir) => join(dir, "apps.json");
|
|
@@ -3469,6 +3578,7 @@ var APP_SERVE_METHODS = {
|
|
|
3469
3578
|
const app = servedApp(apps, ref);
|
|
3470
3579
|
const next = apps.filter((a) => a !== app);
|
|
3471
3580
|
writeServed(ctx.runtime.paths.dir, next);
|
|
3581
|
+
if (ctx.mode === "daemon") node(ctx).appsCloseOf(app.ref);
|
|
3472
3582
|
return {
|
|
3473
3583
|
unserved: app.ref,
|
|
3474
3584
|
apps: next.length,
|
|
@@ -3476,8 +3586,7 @@ var APP_SERVE_METHODS = {
|
|
|
3476
3586
|
};
|
|
3477
3587
|
}
|
|
3478
3588
|
};
|
|
3479
|
-
|
|
3480
|
-
//#region src/appEvents.ts
|
|
3589
|
+
// src/appEvents.ts
|
|
3481
3590
|
/** Per hub: what the contacts have open now, `<chat> <reference>` to the version they said. */
|
|
3482
3591
|
var peers = /* @__PURE__ */ new WeakMap();
|
|
3483
3592
|
/** The version of a served app the contact has open in a chat on this session, or undefined. */
|
|
@@ -3488,9 +3597,8 @@ function reportAppFrames(hub, node, profileDir) {
|
|
|
3488
3597
|
const open = /* @__PURE__ */ new Map();
|
|
3489
3598
|
peers.set(hub, open);
|
|
3490
3599
|
/**
|
|
3491
|
-
* Per chat: chat app id to reference, of the apps served when they were learned there; the list's stamp then
|
|
3492
|
-
* (undefined when an id could not be derived, so the next open tries again)
|
|
3493
|
-
* last open since.
|
|
3600
|
+
* Per chat: chat app id to reference, of the apps served when they were learned there; and the list's stamp then
|
|
3601
|
+
* (undefined when an id could not be derived, so the next open tries again).
|
|
3494
3602
|
*/
|
|
3495
3603
|
const known = /* @__PURE__ */ new Map();
|
|
3496
3604
|
let count = 0;
|
|
@@ -3507,29 +3615,25 @@ function reportAppFrames(hub, node, profileDir) {
|
|
|
3507
3615
|
}
|
|
3508
3616
|
const learnt = {
|
|
3509
3617
|
ids,
|
|
3510
|
-
stamp
|
|
3511
|
-
versions: /* @__PURE__ */ new Map()
|
|
3618
|
+
stamp
|
|
3512
3619
|
};
|
|
3513
3620
|
known.set(chat, learnt);
|
|
3514
3621
|
return learnt;
|
|
3515
3622
|
};
|
|
3516
3623
|
/**
|
|
3517
|
-
* An open learns the served list again only when it changed since (a stat, no read)
|
|
3518
|
-
*
|
|
3519
|
-
*
|
|
3624
|
+
* An open learns the served list again only when it changed since (a stat, no read): an app served or unserved since
|
|
3625
|
+
* is taken or left from its next open, and a contact repeating opens (up to 50 a second for each of 16 apps), at one
|
|
3626
|
+
* version or alternating two, costs no read of the list nor derivation of ids, which do not depend on the version.
|
|
3520
3627
|
*/
|
|
3521
3628
|
const current = (chat, frame) => {
|
|
3522
3629
|
const learnt = known.get(chat);
|
|
3523
3630
|
if (!learnt) return learn(chat);
|
|
3524
3631
|
if (!("o" in frame) || frame.o !== "open") return learnt;
|
|
3525
|
-
|
|
3526
|
-
return learnt.stamp === void 0 || learnt.stamp !== servedStamp(profileDir) || was !== void 0 && was !== frame.v ? learn(chat) : learnt;
|
|
3632
|
+
return learnt.stamp === void 0 || learnt.stamp !== servedStamp(profileDir) ? learn(chat) : learnt;
|
|
3527
3633
|
};
|
|
3528
3634
|
return hub.onAppFrame((chat, frame) => {
|
|
3529
|
-
const
|
|
3530
|
-
const app = learnt.ids.get(frame.app);
|
|
3635
|
+
const app = current(chat, frame).ids.get(frame.app);
|
|
3531
3636
|
if (!app) return;
|
|
3532
|
-
if ("o" in frame && frame.o === "open") learnt.versions.set(frame.app, frame.v);
|
|
3533
3637
|
const id = `${chat}:${app}:${Date.now()}-${++count}`;
|
|
3534
3638
|
if ("o" in frame) {
|
|
3535
3639
|
if (frame.o === "open") open.set(`${chat} ${app}`, frame.v);
|
|
@@ -3552,8 +3656,7 @@ function reportAppFrames(hub, node, profileDir) {
|
|
|
3552
3656
|
});
|
|
3553
3657
|
});
|
|
3554
3658
|
}
|
|
3555
|
-
|
|
3556
|
-
//#region src/appChat.ts
|
|
3659
|
+
// src/appChat.ts
|
|
3557
3660
|
/** The chat and the served app a command names, on an engine that speaks apps/1. */
|
|
3558
3661
|
function target(ctx, params) {
|
|
3559
3662
|
const app = servedApp(servedApps(ctx.runtime.paths.dir), str(params, "ref", true));
|
|
@@ -3671,8 +3774,7 @@ var NOT_SENT = {
|
|
|
3671
3774
|
message: `More than 48 frames in a second, or the connection is still sending earlier ones: slow down and send it again`
|
|
3672
3775
|
}
|
|
3673
3776
|
};
|
|
3674
|
-
|
|
3675
|
-
//#region src/wallets.ts
|
|
3777
|
+
// src/wallets.ts
|
|
3676
3778
|
/**
|
|
3677
3779
|
* Wallets and payments (WISP 1100, phase 2): the app's wallet deck and a chat's payment sheet, as methods. Test
|
|
3678
3780
|
* networks move nothing real. On Mainnet every spend passes `confirmedReal`, which the engine requires, only when the
|
|
@@ -3722,12 +3824,20 @@ function lightningCard(ctx, params) {
|
|
|
3722
3824
|
if (!netView(state(ctx), n)?.lightnings?.some((c) => c.card === card)) throw new CliError("not_found", `No Lightning card ${JSON.stringify(card)} on ${n} (ghostly wallet list)`);
|
|
3723
3825
|
}
|
|
3724
3826
|
/**
|
|
3827
|
+
* The card a payment, a request or a wallet command names. "" (an unset variable in a script: `--card "$CARD"`) is a
|
|
3828
|
+
* usage error: taken as not given, it moved money through, or removed, the network's default card or the whole wallet.
|
|
3829
|
+
*/
|
|
3830
|
+
function cardParam(params) {
|
|
3831
|
+
if (params.card === "") throw new CliError("usage", "--card needs a Lightning card id (ghostly wallet list)");
|
|
3832
|
+
return str(params, "card");
|
|
3833
|
+
}
|
|
3834
|
+
/**
|
|
3725
3835
|
* The Lightning card `card` names, checked before the engine is asked: given with another type of wallet it is a usage
|
|
3726
3836
|
* error, and one not on the network is not_found. Before, the engine dropped it for every type but Lightning, so a card
|
|
3727
3837
|
* that named nothing removed the whole wallet of that type and the answer echoed the card as removed.
|
|
3728
3838
|
*/
|
|
3729
3839
|
function cardOf(ctx, params, type) {
|
|
3730
|
-
const card =
|
|
3840
|
+
const card = cardParam(params);
|
|
3731
3841
|
if (card === void 0) return void 0;
|
|
3732
3842
|
if (type !== "lightning") throw new CliError("usage", `--card names a Lightning card: not with ${type}`);
|
|
3733
3843
|
lightningCard(ctx, params);
|
|
@@ -3932,7 +4042,7 @@ var engineCode = (error) => error instanceof Error ? error.engineCode : void 0;
|
|
|
3932
4042
|
var NO_MINT = /^(No mint could create an invoice: No mint configured|You have no (Mainnet|Testnet) Cashu wallet: create one in Wallet → New)$/;
|
|
3933
4043
|
function walletRefusal(error) {
|
|
3934
4044
|
if (!(error instanceof Error) || error instanceof CliError) return error;
|
|
3935
|
-
if (error.name === "SwapUnsettledError") return new CliError("unavailable", error.message);
|
|
4045
|
+
if (error.name === "SwapUnsettledError" || error.unsettled === true) return new CliError("unavailable", error.message);
|
|
3936
4046
|
const code = WALLET_REFUSALS.find(([pattern]) => pattern.test(error.message))?.[1];
|
|
3937
4047
|
return code ? new CliError(code, error.message) : error;
|
|
3938
4048
|
}
|
|
@@ -4033,7 +4143,10 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4033
4143
|
await federationsOpen(ctx);
|
|
4034
4144
|
return {
|
|
4035
4145
|
network: n,
|
|
4036
|
-
history: (
|
|
4146
|
+
history: await node(ctx).walletHistory({
|
|
4147
|
+
network: n,
|
|
4148
|
+
limit
|
|
4149
|
+
})
|
|
4037
4150
|
};
|
|
4038
4151
|
},
|
|
4039
4152
|
async "wallet.receive"(ctx, params) {
|
|
@@ -4116,7 +4229,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4116
4229
|
async "pay"(ctx, params) {
|
|
4117
4230
|
const comment = memoOf(params, "pay", "comment");
|
|
4118
4231
|
const text = str(params, "target", true).trim();
|
|
4119
|
-
const card =
|
|
4232
|
+
const card = cardParam(params);
|
|
4120
4233
|
let invoice = text.replace(/^lightning:/i, "");
|
|
4121
4234
|
let n;
|
|
4122
4235
|
let note;
|
|
@@ -4204,6 +4317,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4204
4317
|
*/
|
|
4205
4318
|
async "chat.request"(ctx, params) {
|
|
4206
4319
|
const memo = memoOf(params, "request");
|
|
4320
|
+
const card = cardParam(params);
|
|
4207
4321
|
const link = chatOf(ctx, params);
|
|
4208
4322
|
const method = params.method === void 0 ? void 0 : oneOf(params, "method", PAY_METHODS, "cashu");
|
|
4209
4323
|
const n = network(params);
|
|
@@ -4219,7 +4333,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4219
4333
|
...memo ? { memo } : {},
|
|
4220
4334
|
...method ? { method } : {},
|
|
4221
4335
|
...rail ? { rail } : {},
|
|
4222
|
-
...
|
|
4336
|
+
...card ? { card } : {}
|
|
4223
4337
|
}).catch((error) => {
|
|
4224
4338
|
throw (!method || method === "cashu") && error instanceof Error && NO_MINT.test(error.message) ? noWalletOf(ctx, n, error) : error;
|
|
4225
4339
|
});
|
|
@@ -4239,8 +4353,12 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4239
4353
|
const s = state(ctx);
|
|
4240
4354
|
const link = ownChatOf(ctx, params, s);
|
|
4241
4355
|
const paymentId = str(params, "payment", true);
|
|
4356
|
+
const card = cardParam(params);
|
|
4242
4357
|
const request = s.payments[paymentId];
|
|
4243
|
-
|
|
4358
|
+
const listed = `(ghostly payment list --chat ${link.id})`;
|
|
4359
|
+
if (request?.linkId === link.id && request.kind !== "request") throw new CliError("not_found", `${JSON.stringify(paymentId)} is ${request.direction === "out" ? "a payment you sent" : "a payment you received"}, not a request: chat pay-request pays a request the contact made of you ${listed}`);
|
|
4360
|
+
if (!request || request.linkId !== link.id) throw new CliError("not_found", `No request ${JSON.stringify(paymentId)} in this chat ${listed}`);
|
|
4361
|
+
if (request.direction !== "in") throw new CliError("bad_request", `${JSON.stringify(paymentId)} is your own request: the contact pays it`);
|
|
4244
4362
|
const n = paymentNetwork(request);
|
|
4245
4363
|
if (n === "mainnet" && !bool(params, "confirmReal")) throw new CliError("confirm", "This request is for real money (Mainnet): pass --confirm-real to confirm this payment", { network: n });
|
|
4246
4364
|
const via = params.via === void 0 ? void 0 : oneOf(params, "via", ["lightning"], "lightning");
|
|
@@ -4251,7 +4369,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4251
4369
|
network: n,
|
|
4252
4370
|
...via ? { via } : {},
|
|
4253
4371
|
...params.maxFee !== void 0 ? { maxFee: num(params, "maxFee", 0) } : {},
|
|
4254
|
-
...
|
|
4372
|
+
...card ? { card } : {},
|
|
4255
4373
|
...real(params)
|
|
4256
4374
|
});
|
|
4257
4375
|
return paymentJson(state(ctx).payments[paymentId] ?? request);
|
|
@@ -4268,7 +4386,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4268
4386
|
};
|
|
4269
4387
|
}
|
|
4270
4388
|
const method = oneOf(params, "method", CHAT_METHODS, "cashu");
|
|
4271
|
-
const on = bool(params, "on");
|
|
4389
|
+
const on = params.on === void 0 || bool(params, "on");
|
|
4272
4390
|
const nets = params.networks === void 0 ? void 0 : (() => {
|
|
4273
4391
|
const value = params.networks;
|
|
4274
4392
|
if (!Array.isArray(value) || !value.every((v) => v === "mainnet" || v === "testnet")) throw new CliError("bad_request", "networks must list mainnet and/or testnet");
|
|
@@ -4316,8 +4434,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
4316
4434
|
}).map(([name, method]) => [name, (ctx, params) => method(ctx, params).catch((error) => {
|
|
4317
4435
|
throw walletRefusal(error);
|
|
4318
4436
|
})]));
|
|
4319
|
-
|
|
4320
|
-
//#region src/api.ts
|
|
4437
|
+
// src/api.ts
|
|
4321
4438
|
/**
|
|
4322
4439
|
* A text past what a chat or a group carries (16 KiB of UTF-8, as the engine counts it: trimmed) is refused before the
|
|
4323
4440
|
* engine is asked, with a code that says it never goes as it is, not "unavailable", which reads as "try later".
|
|
@@ -4560,6 +4677,113 @@ function noRemovalOnItsWay(ctx, linkIds, clearing = false) {
|
|
|
4560
4677
|
];
|
|
4561
4678
|
throw new CliError("confirm", `${one ? "A message you deleted for everyone has" : `${n} messages you deleted for everyone have`} not reached the contact yet: ${now} now leaves ${one ? "it" : "them"} on their device. Keep this profile online until the contact is reachable (ghostly daemon --detach) and ${then}, or pass --force (force: true over the socket) to ${go} now`, { messages: pending });
|
|
4562
4679
|
}
|
|
4680
|
+
/**
|
|
4681
|
+
* Stages a one-shot `group join` stops waiting at. The link was replaced: knocking again does not get in. The group
|
|
4682
|
+
* has no room yet (`full`, or `blocked` while it waits for every member's app to take more than eight): the engine
|
|
4683
|
+
* goes on knocking until there is room, which a minute's wait seldom sees, so it says that the knock goes on only
|
|
4684
|
+
* while the profile runs.
|
|
4685
|
+
*/
|
|
4686
|
+
var NO_ROOM = {
|
|
4687
|
+
full: "No room yet: the group is full",
|
|
4688
|
+
blocked: "No room yet: the group waits for every member's app to take more than eight members"
|
|
4689
|
+
};
|
|
4690
|
+
var JOIN_STOPS = /* @__PURE__ */ new Set(["replaced", ...Object.keys(NO_ROOM)]);
|
|
4691
|
+
/** How long a one-shot `group join` waits to be let in: as long as a one-shot `invite join` waits to pair. */
|
|
4692
|
+
var ONE_SHOT_JOIN_S = 60;
|
|
4693
|
+
/**
|
|
4694
|
+
* 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
|
|
4695
|
+
* in only while its knocks go on, and they stop when the command leaves. It left at once with `{"group": id}` and exit
|
|
4696
|
+
* 0, in 0.5 s, the admin online: the group stayed an invitation at "knocking" and nothing said a daemon had to run for
|
|
4697
|
+
* the knock to be answered. The answer says whether it is in and at what stage it waits, and what to do when it is not.
|
|
4698
|
+
* A contact's invitation to the group keeps its place and the link is only kept beside it: nothing knocks, so it
|
|
4699
|
+
* answers at once. Not accepted, only `group accept` moves it; accepted, only its welcome does, over the contact's chat.
|
|
4700
|
+
* In a group under the link's id already (`held`, before the join), the link is only kept beside it unless it is this
|
|
4701
|
+
* profile's own group's (the engine's `joinByLink`): nothing knocks, and it answered `"joined": true` for a link whose
|
|
4702
|
+
* group it never joined, with a second group waiting under the id that only `group show`'s `others` said.
|
|
4703
|
+
* Through a daemon the knock goes on after the answer, so it waits for nothing; it answered `{"group": id}` only, with
|
|
4704
|
+
* neither whether it was in nor a word about a link only kept beside a group held.
|
|
4705
|
+
*/
|
|
4706
|
+
async function letIn(ctx, groupId, link, held) {
|
|
4707
|
+
const seen = (s) => s.groups.find((g) => g.id === groupId);
|
|
4708
|
+
const id = shellWord(groupId, groupId);
|
|
4709
|
+
const invited = seen(state(ctx))?.invitation;
|
|
4710
|
+
if (invited && !invited.viaLink && !invited.takenBack) {
|
|
4711
|
+
const who = invited.contact || "a contact";
|
|
4712
|
+
if (!invited.accepted) return {
|
|
4713
|
+
group: groupId,
|
|
4714
|
+
joined: false,
|
|
4715
|
+
stage: null,
|
|
4716
|
+
warning: `Not in yet: ${who} invited you to this group and the invitation waits for your answer. Accept it: ghostly group accept ${id}`
|
|
4717
|
+
};
|
|
4718
|
+
return {
|
|
4719
|
+
group: groupId,
|
|
4720
|
+
joined: false,
|
|
4721
|
+
stage: null,
|
|
4722
|
+
warning: `Not in yet: you accepted ${who}'s invitation to this group, and its welcome has not arrived; the link was kept beside it, and knocks nowhere. The welcome arrives only while this profile is running: keep it running (ghostly daemon --detach), then ghostly group show ${id}`
|
|
4723
|
+
};
|
|
4724
|
+
}
|
|
4725
|
+
const opened = decodeGroupEntryLink(link);
|
|
4726
|
+
const own = held?.entryLink ? decodeGroupEntryLink(held.entryLink) : null;
|
|
4727
|
+
if (held?.status === "active" && opened && own?.host !== opened.host) {
|
|
4728
|
+
const kept = seen(state(ctx))?.others?.some((o) => "link" in o && decodeGroupEntryLink(o.link)?.host === opened.host);
|
|
4729
|
+
const pick = `keep the one you are in (ghostly engine keepGroup '{"groupId":"${groupId}"}') or take the link's instead, which leaves the one you are in and deletes its history on this device (ghostly engine switchGroup '{"groupId":"${groupId}","to":"<its link, from group show --show-secret>"}' --yes)`;
|
|
4730
|
+
return {
|
|
4731
|
+
group: groupId,
|
|
4732
|
+
joined: false,
|
|
4733
|
+
stage: null,
|
|
4734
|
+
warning: kept ? `Not joined: you are in a group under this link's id already, and only a group's welcome says whose a link is, so the link was kept beside that group and knocks nowhere. ghostly group show ${id} lists it under "others": ${pick}` : `Not joined: you are in a group under this link's id already, and as many other groups as are kept already wait beside it to be picked, so the link was not kept. ghostly group show ${id} lists them under "others": ${pick}, then open the link again`
|
|
4735
|
+
};
|
|
4736
|
+
}
|
|
4737
|
+
if (ctx.mode !== "one-shot") {
|
|
4738
|
+
const now = seen(state(ctx));
|
|
4739
|
+
return {
|
|
4740
|
+
group: groupId,
|
|
4741
|
+
joined: now?.status === "active",
|
|
4742
|
+
stage: now?.invitation?.stage ?? null
|
|
4743
|
+
};
|
|
4744
|
+
}
|
|
4745
|
+
const done = (g) => !g || g.status === "active" || JOIN_STOPS.has(g.invitation?.stage ?? "");
|
|
4746
|
+
const group = await waitForState(ctx, (s) => {
|
|
4747
|
+
const g = seen(s);
|
|
4748
|
+
return done(g) ? { g } : void 0;
|
|
4749
|
+
}, ONE_SHOT_JOIN_S * 1e3, `group ${groupId} to let this profile in`).then(({ g }) => g, (error) => {
|
|
4750
|
+
if (error instanceof CliError && error.code === "timeout") return seen(state(ctx));
|
|
4751
|
+
throw error;
|
|
4752
|
+
});
|
|
4753
|
+
const joined = group?.status === "active", stage = group?.invitation?.stage ?? null;
|
|
4754
|
+
if (joined || !group) return {
|
|
4755
|
+
group: groupId,
|
|
4756
|
+
joined,
|
|
4757
|
+
stage
|
|
4758
|
+
};
|
|
4759
|
+
if (stage === "replaced") return {
|
|
4760
|
+
group: groupId,
|
|
4761
|
+
joined,
|
|
4762
|
+
stage,
|
|
4763
|
+
warning: "This link was replaced or turned off: ask someone in the group for the current link, then ghostly group join <link>"
|
|
4764
|
+
};
|
|
4765
|
+
const show = `keep it running (ghostly daemon --detach), then ghostly group show ${shellWord(groupId, groupId)}`;
|
|
4766
|
+
const full = stage === "full" ? group.invitation?.full : void 0;
|
|
4767
|
+
const noRoom = stage ? NO_ROOM[stage] : void 0;
|
|
4768
|
+
if (noRoom) return {
|
|
4769
|
+
group: groupId,
|
|
4770
|
+
joined,
|
|
4771
|
+
stage,
|
|
4772
|
+
warning: `${noRoom}${full ? ` (${full.n} of ${full.max} members)` : ""}. Your app goes on knocking only while this profile is running, and gets in when there is room: ${show}`
|
|
4773
|
+
};
|
|
4774
|
+
if (stage === "admitted") return {
|
|
4775
|
+
group: groupId,
|
|
4776
|
+
joined,
|
|
4777
|
+
stage,
|
|
4778
|
+
warning: `Not in yet: a member's app let you in, and the group's welcome has not finished arriving. It arrives only while this profile is running: ${show}`
|
|
4779
|
+
};
|
|
4780
|
+
return {
|
|
4781
|
+
group: groupId,
|
|
4782
|
+
joined,
|
|
4783
|
+
stage,
|
|
4784
|
+
warning: `Not in yet: no member's app has let you in. A member's app lets you in only while this profile is running: ${show}`
|
|
4785
|
+
};
|
|
4786
|
+
}
|
|
4563
4787
|
var METHODS = {
|
|
4564
4788
|
...WALLET_METHODS,
|
|
4565
4789
|
...FILE_METHODS,
|
|
@@ -4575,6 +4799,7 @@ var METHODS = {
|
|
|
4575
4799
|
...APP_CHAT_METHODS,
|
|
4576
4800
|
async status(ctx) {
|
|
4577
4801
|
const s = state(ctx);
|
|
4802
|
+
const seen = ctx.mode === "daemon" ? s.transport.discovery : void 0;
|
|
4578
4803
|
return {
|
|
4579
4804
|
version: ctx.version,
|
|
4580
4805
|
profile: ctx.runtime.paths.name,
|
|
@@ -4589,7 +4814,11 @@ var METHODS = {
|
|
|
4589
4814
|
groups: s.groups.length,
|
|
4590
4815
|
discovery: {
|
|
4591
4816
|
protocol: s.transport.protocol,
|
|
4592
|
-
relays: s.transport.relays
|
|
4817
|
+
relays: s.transport.relays,
|
|
4818
|
+
...seen && {
|
|
4819
|
+
health: seen.relays,
|
|
4820
|
+
via: seen.path?.via ?? null
|
|
4821
|
+
}
|
|
4593
4822
|
},
|
|
4594
4823
|
events: { lastSeq: ctx.hub.lastSeq },
|
|
4595
4824
|
...ctx.listen && { listen: true }
|
|
@@ -5109,6 +5338,7 @@ var METHODS = {
|
|
|
5109
5338
|
};
|
|
5110
5339
|
},
|
|
5111
5340
|
async "chat.delete"(ctx, params) {
|
|
5341
|
+
const purge = bool(params, "purge"), purged = purge ? { purged: true } : {};
|
|
5112
5342
|
if (bool(params, "everyone")) {
|
|
5113
5343
|
const target = chatOrGroup(ctx, str(params, "chat", true));
|
|
5114
5344
|
const wait = oneOf(params, "wait", [
|
|
@@ -5136,9 +5366,22 @@ var METHODS = {
|
|
|
5136
5366
|
messageId: message.id
|
|
5137
5367
|
});
|
|
5138
5368
|
if (result.error) throw new CliError(result.refused ? "refused" : "unavailable", result.error);
|
|
5369
|
+
if (purge) await purgeMessage(ctx, message);
|
|
5370
|
+
const goneHere = async (wait, text) => {
|
|
5371
|
+
try {
|
|
5372
|
+
return await wait();
|
|
5373
|
+
} catch (error) {
|
|
5374
|
+
if (!(error instanceof CliError) || error.code !== "timeout") throw error;
|
|
5375
|
+
throw new CliError("timeout", text ?? error.message, {
|
|
5376
|
+
...error.details,
|
|
5377
|
+
deleted: message.id,
|
|
5378
|
+
...purged
|
|
5379
|
+
});
|
|
5380
|
+
}
|
|
5381
|
+
};
|
|
5139
5382
|
if (target.group) {
|
|
5140
5383
|
const e = result.e;
|
|
5141
|
-
const edges = !e ? 0 : wait === "sent" ? await waitForGroupFrame(ctx, target.id, message.id, e, ms) : node(ctx).groupTaken({
|
|
5384
|
+
const edges = !e ? 0 : wait === "sent" ? await goneHere(() => waitForGroupFrame(ctx, target.id, message.id, e, ms), `${ended(ctx, ms)}: the message is gone here and no member's edge took its removal yet (it goes when one opens). Its removal ${goesOn(ctx)}`) : node(ctx).groupTaken({
|
|
5142
5385
|
groupId: target.id,
|
|
5143
5386
|
messageId: message.id,
|
|
5144
5387
|
edit: e
|
|
@@ -5149,10 +5392,11 @@ var METHODS = {
|
|
|
5149
5392
|
deleted: message.id,
|
|
5150
5393
|
everyone: true,
|
|
5151
5394
|
sent: edges > 0,
|
|
5152
|
-
edges
|
|
5395
|
+
edges,
|
|
5396
|
+
...purged
|
|
5153
5397
|
};
|
|
5154
5398
|
}
|
|
5155
|
-
if (wait === "confirmed") await waitForRemoval(ctx, target.linkId, message.id, ms);
|
|
5399
|
+
if (wait === "confirmed") await goneHere(() => waitForRemoval(ctx, target.linkId, message.id, ms));
|
|
5156
5400
|
return {
|
|
5157
5401
|
chat: target.id,
|
|
5158
5402
|
messageId: message.id,
|
|
@@ -5161,13 +5405,30 @@ var METHODS = {
|
|
|
5161
5405
|
confirmed: !node(ctx).removalPending({
|
|
5162
5406
|
linkId: target.linkId,
|
|
5163
5407
|
messageId: message.id
|
|
5164
|
-
})
|
|
5408
|
+
}),
|
|
5409
|
+
...purged
|
|
5165
5410
|
};
|
|
5166
5411
|
}
|
|
5167
|
-
const ref = str(params, "message") ?? "<message>";
|
|
5168
|
-
const
|
|
5412
|
+
const ref = str(params, "message") ?? "<message>", typed = str(params, "chat", true);
|
|
5413
|
+
const reachesGroup = (name) => {
|
|
5414
|
+
try {
|
|
5415
|
+
return "group" in findChatOrGroup(state(ctx).links, state(ctx).groups, name);
|
|
5416
|
+
} catch {
|
|
5417
|
+
return false;
|
|
5418
|
+
}
|
|
5419
|
+
};
|
|
5420
|
+
let link;
|
|
5421
|
+
try {
|
|
5422
|
+
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" : ""}`);
|
|
5423
|
+
} catch (error) {
|
|
5424
|
+
const group = error instanceof CliError ? error.details?.group : void 0;
|
|
5425
|
+
const theirs = typeof group === "string" && ref !== "<message>" ? await messageOf(ctx, `group:${group}`, ref).catch(() => void 0) : void 0;
|
|
5426
|
+
if (theirs && theirs.sender !== "me") throw new CliError("not_found", `${JSON.stringify(typed)} is a group, and ${JSON.stringify(ref)} is another member's message in it: only its author deletes a group's message, for everyone`, { group });
|
|
5427
|
+
throw error;
|
|
5428
|
+
}
|
|
5169
5429
|
const messageId = str(params, "message", true);
|
|
5170
|
-
|
|
5430
|
+
const message = await node(ctx).getMessage(link.id, messageId);
|
|
5431
|
+
if (!message) throw noMessage(messageId, {
|
|
5171
5432
|
group: false,
|
|
5172
5433
|
ref: str(params, "chat", true)
|
|
5173
5434
|
});
|
|
@@ -5175,11 +5436,13 @@ var METHODS = {
|
|
|
5175
5436
|
linkId: link.id,
|
|
5176
5437
|
messageId
|
|
5177
5438
|
});
|
|
5439
|
+
if (purge) await purgeMessage(ctx, message);
|
|
5178
5440
|
return {
|
|
5179
5441
|
chat: link.id,
|
|
5180
5442
|
messageId,
|
|
5181
5443
|
deleted: messageId,
|
|
5182
|
-
everyone
|
|
5444
|
+
everyone,
|
|
5445
|
+
...purged
|
|
5183
5446
|
};
|
|
5184
5447
|
},
|
|
5185
5448
|
/** A chat's or a group's (`group:<id>`, or its name) message, as the app's details show it; a group's said `No chat`. */
|
|
@@ -5304,20 +5567,19 @@ var METHODS = {
|
|
|
5304
5567
|
});
|
|
5305
5568
|
let link = null;
|
|
5306
5569
|
if (profile === "community") ({link} = await node(ctx).enableGroupLink({ groupId }));
|
|
5307
|
-
return
|
|
5308
|
-
group: groupId,
|
|
5309
|
-
link
|
|
5310
|
-
};
|
|
5570
|
+
return withUrl(groupId, link);
|
|
5311
5571
|
},
|
|
5312
5572
|
async "group.join"(ctx, params) {
|
|
5313
5573
|
let groupId;
|
|
5574
|
+
const link = str(params, "link", true);
|
|
5575
|
+
const before = state(ctx).groups;
|
|
5314
5576
|
try {
|
|
5315
|
-
({groupId} = await node(ctx).joinGroupByLink({ link
|
|
5577
|
+
({groupId} = await node(ctx).joinGroupByLink({ link }));
|
|
5316
5578
|
} catch (error) {
|
|
5317
5579
|
if (error instanceof Error && error.message === "This is not a link to a group") throw new CliError("bad_request", error.message);
|
|
5318
5580
|
throw error;
|
|
5319
5581
|
}
|
|
5320
|
-
return
|
|
5582
|
+
return letIn(ctx, groupId, link, before.find((g) => g.id === groupId));
|
|
5321
5583
|
},
|
|
5322
5584
|
async "group.list"(ctx, params) {
|
|
5323
5585
|
const showSecret = bool(params, "showSecret");
|
|
@@ -5494,16 +5756,15 @@ var METHODS = {
|
|
|
5494
5756
|
sayTyping(ctx, target, typing, word);
|
|
5495
5757
|
const until = seconds ? Date.now() + seconds * 1e3 : null;
|
|
5496
5758
|
const kept = seconds ? keepTyping(ctx, target, seconds * 1e3, word) : null;
|
|
5497
|
-
const reached = (
|
|
5498
|
-
if (kept && ctx.mode === "one-shot") await keepOneShot(ctx, target, kept, (s) => reached(s) > 0);
|
|
5499
|
-
const now = state(ctx);
|
|
5759
|
+
const reached = (now) => (now ?? group).members.filter((m) => !m.me && m.online && !m.viaHub).length;
|
|
5760
|
+
if (kept && ctx.mode === "one-shot") await keepOneShot(ctx, target, kept, (s) => reached(s.groups.find((g) => g.id === group.id)) > 0);
|
|
5500
5761
|
return {
|
|
5501
5762
|
group: group.id,
|
|
5502
5763
|
typing,
|
|
5503
5764
|
...typing ? { kind } : {},
|
|
5504
5765
|
...status ? { status } : {},
|
|
5505
|
-
reached: reached(
|
|
5506
|
-
sendTyping:
|
|
5766
|
+
reached: reached(groupById(ctx, group.id)),
|
|
5767
|
+
sendTyping: settingsOf(ctx).sendTyping !== false,
|
|
5507
5768
|
...until ? { until } : {},
|
|
5508
5769
|
...!kept && ctx.mode === "one-shot" && { note: typing ? ONE_SHOT_TYPING : ONE_SHOT_TYPING_STOP }
|
|
5509
5770
|
};
|
|
@@ -5529,6 +5790,7 @@ var METHODS = {
|
|
|
5529
5790
|
},
|
|
5530
5791
|
async "group.accept"(ctx, params) {
|
|
5531
5792
|
const group = groupOf(ctx, params);
|
|
5793
|
+
if (!group.invitation) throw new CliError("refused", `${outOf(group) ?? `You are in ${group.name} already`}: there is no invitation to accept`);
|
|
5532
5794
|
await node(ctx).acceptGroupInvitation({ groupId: group.id });
|
|
5533
5795
|
return { group: group.id };
|
|
5534
5796
|
},
|
|
@@ -5755,8 +6017,8 @@ function notAGroup(ctx, params, chat, hint) {
|
|
|
5755
6017
|
} catch {
|
|
5756
6018
|
throw error;
|
|
5757
6019
|
}
|
|
5758
|
-
const shown =
|
|
5759
|
-
throw new CliError("not_found", `${JSON.stringify(ref)} is a group, not a chat: ${hint(shown)}`, { group: group.id });
|
|
6020
|
+
const shown = shellWord(named, group.id);
|
|
6021
|
+
throw new CliError("not_found", `${JSON.stringify(ref)} is a group, not a chat: ${hint(shown, group.id)}`, { group: group.id });
|
|
5760
6022
|
}
|
|
5761
6023
|
}
|
|
5762
6024
|
/** The chat a chat command with a group twin names: a group's name says so, with `command`, the twin (see `notAGroup`). */
|
|
@@ -5942,14 +6204,16 @@ function quoteChecked(json, message, originals) {
|
|
|
5942
6204
|
};
|
|
5943
6205
|
}
|
|
5944
6206
|
var API_METHODS = Object.keys(METHODS);
|
|
5945
|
-
/**
|
|
5946
|
-
|
|
6207
|
+
/**
|
|
6208
|
+
* Runs one method of the API: one the table lists itself (`constructor`, which every object has, is none). `call`: who
|
|
6209
|
+
* asked, from a daemon's connection (`host.ts`).
|
|
6210
|
+
*/
|
|
6211
|
+
async function callApi(ctx, method, params = {}, call) {
|
|
5947
6212
|
const run = Object.hasOwn(METHODS, method) ? METHODS[method] : void 0;
|
|
5948
6213
|
if (!run) throw new CliError("not_found", `No method ${method}`);
|
|
5949
6214
|
if (params === null || typeof params !== "object" || Array.isArray(params)) throw new CliError("bad_request", "params must be an object");
|
|
5950
|
-
return run(ctx, await withStoredIds(ctx, params));
|
|
6215
|
+
return run(ctx, await withStoredIds(ctx, params), call);
|
|
5951
6216
|
}
|
|
5952
|
-
//#endregion
|
|
5953
6217
|
export { groupPayTwins as _, hideStateSecrets as a, settingsInEffect as c, servedApps as d, nodeLocalFetch as f, groupMessageJson as g, groupJson as h, groupSendRefused as i, paymentJson as l, chatMessageJson as m, SETTABLE as n, mentionsFor as o, chatJson as p, callApi as r, redactSettings as s, API_METHODS as t, reportAppFrames as u, resumeHolds as v, flushCardUpdates as y };
|
|
5954
6218
|
|
|
5955
|
-
//# sourceMappingURL=api-
|
|
6219
|
+
//# sourceMappingURL=api-BwEgbvvK.js.map
|