@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,22 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { r as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { p as fileStore } from "./idb-ewvbqyDI.js";
|
|
2
|
+
import { _ as groupPayTwins, d as servedApps, f as nodeLocalFetch, g as groupMessageJson, h as groupJson, l as paymentJson, m as chatMessageJson, p as chatJson, r as callApi, u as reportAppFrames, v as resumeHolds, y as flushCardUpdates } from "./api-BwEgbvvK.js";
|
|
3
|
+
import { N as sinceSeq, s as findChat, u as findOwnNamedChat } from "./apiKit-BlsNk-Cx.js";
|
|
4
|
+
import { r as asCliError, t as CliError } from "./errors-DDLFO4Gf.js";
|
|
5
|
+
import { C as ownFolder, D as runtimePath, E as privateFolder, n as RESTORED_MARK, r as acquireLock, w as ownProfile, x as startingPath } from "./profiles-BOYGlmu2.js";
|
|
6
|
+
import { _ as frameBytes, b as monotonic, d as proof, f as removeDaemonSecret, g as bytesToMs, h as PlaybackQueue, l as greeting, m as DEFAULT_RATE, u as newDaemonSecret, v as frameSamples, y as isCallRate } from "./client-DGS-atRu.js";
|
|
7
|
+
import { Bi as buildSdpFromSignal, Gi as parseCallSignal, Hi as callSignalHeardAt, Ii as CALL_SIGNAL_MAX_AGE_MS, Ki as signalHasVideo, Ri as RTC_CONFIG, Vi as callRtcConfig, Wi as extractParamsFromSdp, Zt as checkPushEndpoint, bi as DAEMON_WATCH_PEER_IDLE_MS, gn as ACTIVE_DHT_POLL_MS, xt as STATUS_IDLE_AFTER_MS, zi as answersOffer } from "./groupMeta-DxuJzko_.js";
|
|
8
|
+
import { d as parsePayLink, r as irohRelayProblem } from "./irohWeb-CbnGtUo6.js";
|
|
9
|
+
import { i as fromBase64Url } from "./bytes-C1DNGY18.js";
|
|
10
|
+
import { u as setLinkTraceSink } from "./relay-Cjfmdec0.js";
|
|
11
|
+
import { b as setPublicKeyFastPath } from "./pkarr-BQo4PcCg.js";
|
|
12
|
+
import { p as nativePublicKey } from "./apps-CL8TXHhu.js";
|
|
13
|
+
import { n as fedimintSdkOn } from "./fedimintSdk-D-6H9Pe7.js";
|
|
14
|
+
import { s as isPublicAddress } from "./domainProofs-BDNP1dIy.js";
|
|
11
15
|
import { createRequire } from "node:module";
|
|
12
16
|
import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, fsync, fsyncSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, truncateSync, writeFileSync, writeSync } from "node:fs";
|
|
13
17
|
import { open, readFile } from "node:fs/promises";
|
|
14
|
-
import { dirname, join } from "node:path";
|
|
18
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
15
19
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
16
20
|
import { networkInterfaces } from "node:os";
|
|
17
21
|
import { Readable } from "node:stream";
|
|
18
|
-
import { createServer, isIP } from "node:net";
|
|
22
|
+
import { connect, createServer, isIP } from "node:net";
|
|
19
23
|
import { createInterface } from "node:readline";
|
|
24
|
+
import { createSocket } from "node:dgram";
|
|
20
25
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
21
26
|
import { Worker } from "node:worker_threads";
|
|
22
27
|
import { request } from "node:https";
|
|
@@ -24,7 +29,7 @@ import { lookup } from "node:dns";
|
|
|
24
29
|
import { WebSocket } from "ws";
|
|
25
30
|
import { DefaultSerializer, deserialize, serialize } from "node:v8";
|
|
26
31
|
import { IDBFactory, IDBKeyRange as IDBKeyRange$1, IDBTransaction } from "fake-indexeddb";
|
|
27
|
-
|
|
32
|
+
// src/announce.ts
|
|
28
33
|
/**
|
|
29
34
|
* What the app's chat screen does by itself, done here for a profile no screen shows (apps/ui/src/hooks/useChat.ts): the side
|
|
30
35
|
* that joined says "👋 <name> joined" once the chat first goes live, and the side that invited answers once. Contacts
|
|
@@ -50,33 +55,89 @@ function announceJoins(hub, node) {
|
|
|
50
55
|
else if (event.type === "chat.joined") say(chat);
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
//#region src/calls/audioSocket.ts
|
|
58
|
+
// src/calls/audioSocket.ts
|
|
55
59
|
/**
|
|
56
60
|
* A call's audio socket (WISP 1100 § Calls): `<profile>/calls/<call>.sock`, 0600, in a folder only the owner may
|
|
57
61
|
* open. When that path is too long for a Unix socket: `ghostly-calls-<hash of the profile>/<call>.sock` in the user's
|
|
58
62
|
* runtime folder (`runtimePath`), a folder of the owner's, 0700, checked as such before use. A named pipe on Windows.
|
|
63
|
+
* With a shared folder (`callSocketDir`): `<that folder>/<call>.sock`.
|
|
59
64
|
*/
|
|
60
|
-
function audioSocketPath(profileDir, callId) {
|
|
65
|
+
function audioSocketPath(profileDir, callId, sharedDir) {
|
|
66
|
+
if (sharedDir && process.platform !== "win32") return join(sharedDir, `${callId}.sock`);
|
|
61
67
|
const inside = join(profileDir, "calls", `${callId}.sock`);
|
|
62
68
|
if (process.platform === "win32") return `\\\\.\\pipe\\ghostly-call-${createHash("sha256").update(inside).digest("hex").slice(0, 24)}`;
|
|
63
69
|
if (Buffer.byteLength(inside) <= 100) return inside;
|
|
64
70
|
return runtimePath("ghostly-calls", profileDir, `${callId}.sock`);
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
73
|
+
* GHOSTLY_CALL_SOCKET_DIR: a folder the machine made for its daemon's call sockets, shared with the group of another
|
|
74
|
+
* user that runs the program on the audio (a Ghostly OS node's assistant). Unset: the profile's own folder. Refused
|
|
75
|
+
* (`usage`) when it is not an absolute path, is too long for a socket's, or on Windows, whose calls are named pipes.
|
|
76
|
+
*/
|
|
77
|
+
function callSocketDir(value = process.env.GHOSTLY_CALL_SOCKET_DIR) {
|
|
78
|
+
if (value === void 0) return void 0;
|
|
79
|
+
if (process.platform === "win32") throw new CliError("usage", "GHOSTLY_CALL_SOCKET_DIR is for Linux and macOS: on Windows a call's audio is a named pipe");
|
|
80
|
+
if (!value.trim() || !isAbsolute(value)) throw new CliError("usage", "GHOSTLY_CALL_SOCKET_DIR takes an absolute path: the folder for the calls' audio sockets");
|
|
81
|
+
const dir = resolve(value);
|
|
82
|
+
if (Buffer.byteLength(join(dir, `${"0".repeat(12)}.sock`)) > 100) throw new CliError("usage", `GHOSTLY_CALL_SOCKET_DIR is too long for a socket's path (${dir}): choose a folder of at most 82 bytes`);
|
|
83
|
+
return dir;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The shared folder (`callSocketDir`), checked before a socket goes in it: the machine made it, so it is not made here.
|
|
87
|
+
* Refused when it is missing, a link, someone else's, or when anyone else may write it (and so replace a socket) or
|
|
88
|
+
* anyone outside its group may enter it: 0750, its group the other user's (setgid, so the sockets take that group).
|
|
89
|
+
* Refused too on Linux when its group is not this user's own and it is not setgid: a socket there takes this user's
|
|
90
|
+
* group, not the folder's, and the other user's program could never open one.
|
|
91
|
+
*/
|
|
92
|
+
function sharedFolder(path) {
|
|
93
|
+
const what = "calls will not put their audio there";
|
|
94
|
+
let info;
|
|
95
|
+
try {
|
|
96
|
+
info = lstatSync(path);
|
|
97
|
+
} catch {
|
|
98
|
+
throw new CliError("refused", `${path} (GHOSTLY_CALL_SOCKET_DIR) is not there: ${what}. Make it a folder of this user's, 0750 with the group that reads the audio (chmod 2750)`);
|
|
99
|
+
}
|
|
100
|
+
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid()) throw new CliError("refused", `${path} (GHOSTLY_CALL_SOCKET_DIR) is not a folder of this user's: ${what}`);
|
|
101
|
+
if ((info.mode & 23) !== 0) throw new CliError("refused", `${path} (GHOSTLY_CALL_SOCKET_DIR) may be written by others or entered by anyone outside its group: ${what}. Run \`chmod 2750 ${path}\`, then try again`);
|
|
102
|
+
if (process.platform === "linux" && process.getegid && info.gid !== process.getegid() && (info.mode & 1024) === 0) throw new CliError("refused", `${path} (GHOSTLY_CALL_SOCKET_DIR) is not setgid: a call's socket there would take this user's group, not the folder's, and its group could not open it. Run \`chmod 2750 ${path}\`, then try again`);
|
|
103
|
+
}
|
|
104
|
+
/** A call's socket's name: its call id, 12 hex digits. */
|
|
105
|
+
var CALL_SOCKET = /^[0-9a-f]{12}\.sock$/;
|
|
106
|
+
/**
|
|
67
107
|
* Removes the call sockets a daemon that died during a call left in this profile's folder (`audioSocketPath`; call
|
|
68
|
-
* ids are 12 hex digits): no call outlives its daemon. A folder that is a link or someone
|
|
108
|
+
* ids are 12 hex digits), or in the shared folder: no call outlives its daemon. A folder that is a link or someone
|
|
109
|
+
* else's is left alone, and so is anything else in it: the shared folder is the machine's, not Ghostly's alone. There a
|
|
110
|
+
* socket goes only once nobody answers on it (`removeIfDead`): two profiles' daemons may share the folder, and the
|
|
111
|
+
* other one's call is live.
|
|
69
112
|
*/
|
|
70
|
-
function clearAudioSockets(profileDir) {
|
|
113
|
+
function clearAudioSockets(profileDir, sharedDir) {
|
|
71
114
|
if (process.platform === "win32") return;
|
|
72
|
-
const folder = dirname(audioSocketPath(profileDir, "0".repeat(12)));
|
|
115
|
+
const folder = dirname(audioSocketPath(profileDir, "0".repeat(12), sharedDir));
|
|
73
116
|
try {
|
|
74
117
|
const info = lstatSync(folder);
|
|
75
118
|
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid()) return;
|
|
76
|
-
for (const entry of readdirSync(folder, { withFileTypes: true }))
|
|
119
|
+
for (const entry of readdirSync(folder, { withFileTypes: true })) {
|
|
120
|
+
if (!CALL_SOCKET.test(entry.name) || entry.isDirectory()) continue;
|
|
121
|
+
if (sharedDir && entry.isSocket()) removeIfDead(join(folder, entry.name));
|
|
122
|
+
else rmSync(join(folder, entry.name), { force: true });
|
|
123
|
+
}
|
|
77
124
|
} catch {}
|
|
78
125
|
}
|
|
79
126
|
/**
|
|
127
|
+
* Removes a shared folder's call socket once a connection to it is refused: its daemon is gone. A live one is another
|
|
128
|
+
* daemon's call, and the connection (which sends no token) replaces nobody there and is closed at once.
|
|
129
|
+
*/
|
|
130
|
+
function removeIfDead(path) {
|
|
131
|
+
const probe = connect(path);
|
|
132
|
+
probe.once("connect", () => probe.destroy());
|
|
133
|
+
probe.once("error", (error) => {
|
|
134
|
+
if (error.code !== "ECONNREFUSED") return;
|
|
135
|
+
try {
|
|
136
|
+
rmSync(path, { force: true });
|
|
137
|
+
} catch {}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
80
141
|
* The socket's handlers for a call's queue: what the program writes is queued, and a program that takes the socket
|
|
81
142
|
* (the first, or one that replaces the last) starts on a queue of its own (`PlaybackQueue.newWriter`): the last
|
|
82
143
|
* one's leftover, half a sample included, would otherwise shift all of its audio by a byte.
|
|
@@ -101,6 +162,7 @@ function feedQueue(queue) {
|
|
|
101
162
|
* of the machine may open and read), a connection is nobody's until it has: it hears nothing and replaces nobody, it is
|
|
102
163
|
* closed when what it sent is not the token, and when `proveMs` pass without it. On an owner-only Unix socket the token
|
|
103
164
|
* is optional: a connection is the program at once, and a token line it sends first is kept out of the call's audio.
|
|
165
|
+
* `shared`: the socket is in the shared folder (`sharedFolder`), 0660 for its group, and the token is required.
|
|
104
166
|
*/
|
|
105
167
|
var AudioSocket = class AudioSocket {
|
|
106
168
|
path;
|
|
@@ -123,8 +185,10 @@ var AudioSocket = class AudioSocket {
|
|
|
123
185
|
this.proveMs = proveMs;
|
|
124
186
|
}
|
|
125
187
|
static async open(path, rate, handlers, options = {}) {
|
|
188
|
+
const shared = !!options.shared && process.platform !== "win32";
|
|
126
189
|
if (process.platform !== "win32") {
|
|
127
|
-
|
|
190
|
+
if (shared) sharedFolder(dirname(path));
|
|
191
|
+
else privateFolder(join(path, ".."), "calls will not put their audio there");
|
|
128
192
|
if (existsSync(path)) rmSync(path, { force: true });
|
|
129
193
|
}
|
|
130
194
|
let self = null;
|
|
@@ -136,8 +200,8 @@ var AudioSocket = class AudioSocket {
|
|
|
136
200
|
resolve();
|
|
137
201
|
});
|
|
138
202
|
});
|
|
139
|
-
if (process.platform !== "win32") chmodSync(path, 384);
|
|
140
|
-
self = new AudioSocket(path, server, rate, options.requireToken ?? process.platform === "win32", options.proveMs ?? 5e3);
|
|
203
|
+
if (process.platform !== "win32") chmodSync(path, shared ? 432 : 384);
|
|
204
|
+
self = new AudioSocket(path, server, rate, options.requireToken ?? (shared || process.platform === "win32"), options.proveMs ?? 5e3);
|
|
141
205
|
return self;
|
|
142
206
|
}
|
|
143
207
|
get connected() {
|
|
@@ -333,8 +397,7 @@ var ReorderBuffer = class {
|
|
|
333
397
|
}
|
|
334
398
|
}
|
|
335
399
|
};
|
|
336
|
-
|
|
337
|
-
//#region src/calls/audio.ts
|
|
400
|
+
// src/calls/audio.ts
|
|
338
401
|
/** The longest stall of the sender whose frames are still sent after it (see `catchUp`). */
|
|
339
402
|
var MAX_CATCH_UP_MS = 1e3;
|
|
340
403
|
/**
|
|
@@ -580,8 +643,7 @@ var CallAudio = class {
|
|
|
580
643
|
this.owed -= this.queue.skip(Math.min(this.owed, this.queue.queuedMs - this.kept));
|
|
581
644
|
}
|
|
582
645
|
};
|
|
583
|
-
|
|
584
|
-
//#region src/envSwitch.ts
|
|
646
|
+
// src/envSwitch.ts
|
|
585
647
|
var OFF = /^(0|false|off|no)$/i;
|
|
586
648
|
var ON = /^(1|true|on|yes)$/i;
|
|
587
649
|
/**
|
|
@@ -598,8 +660,7 @@ function envSwitch(name, fallback, env = process.env) {
|
|
|
598
660
|
if (ON.test(value.trim())) return true;
|
|
599
661
|
throw new CliError("usage", `${name} takes 0 or 1 (or false/true, off/on, no/yes), not ${JSON.stringify(value)}`);
|
|
600
662
|
}
|
|
601
|
-
|
|
602
|
-
//#region src/runtime/rtcThreads.ts
|
|
663
|
+
// src/runtime/rtcThreads.ts
|
|
603
664
|
/**
|
|
604
665
|
* How long no WebRTC connection is open before libdatachannel's threads are let go. For tests,
|
|
605
666
|
* `GHOSTLY_TEST_RTC_IDLE_MS=<ms>` sets it.
|
|
@@ -649,8 +710,7 @@ var rtcThreads = new RtcThreads(async () => {
|
|
|
649
710
|
const ndc = await import("node-datachannel");
|
|
650
711
|
if (rtcThreads.idle) (ndc.cleanup ?? ndc.default.cleanup)();
|
|
651
712
|
});
|
|
652
|
-
|
|
653
|
-
//#region src/calls/media.ts
|
|
713
|
+
// src/calls/media.ts
|
|
654
714
|
var loading = null;
|
|
655
715
|
var OPUS_APPLICATION_VOIP = 2048;
|
|
656
716
|
var OPUS_SET_BITRATE = 4002;
|
|
@@ -717,6 +777,8 @@ function loadCallStack() {
|
|
|
717
777
|
} catch (error) {
|
|
718
778
|
return error.message;
|
|
719
779
|
}
|
|
780
|
+
const bind = process.env.GHOSTLY_CALL_BIND;
|
|
781
|
+
if (bind && !isIP(bind)) return isIP(bind.trim().replace(/^\[(.*)\]$/, "$1")) ? "Calls are off on this headless Ghostly: GHOSTLY_CALL_BIND takes an IP address of this machine without brackets or spaces, such as 127.0.0.1 or ::1" : "Calls are off on this headless Ghostly: GHOSTLY_CALL_BIND takes an IP address of this machine, such as 127.0.0.1, not a name";
|
|
720
782
|
try {
|
|
721
783
|
const ndc = await import("node-datachannel");
|
|
722
784
|
const lib = ndc.PeerConnection ? ndc : ndc.default;
|
|
@@ -780,6 +842,29 @@ var SETTLE_MS = 150;
|
|
|
780
842
|
* `OFFER_HOST_GATHER_MS`).
|
|
781
843
|
*/
|
|
782
844
|
var HOST_GATHER_MS = 2e3;
|
|
845
|
+
/** Not echoed: the address may be one of this network's. */
|
|
846
|
+
var CALL_BIND_GONE = "Calls can't start: GHOSTLY_CALL_BIND is not an address of this machine now (a typo, or a network that changed). Set it to one of this machine's addresses, such as 127.0.0.1, or unset it, then restart the daemon";
|
|
847
|
+
/**
|
|
848
|
+
* Whether a socket can be bound on `address` now. On an address that is not this machine's (a typo, a network that
|
|
849
|
+
* changed since the daemon started), libdatachannel gathers no candidate and throws from an offer's description where
|
|
850
|
+
* node-datachannel catches nothing: the whole daemon aborted, every chat with it.
|
|
851
|
+
*/
|
|
852
|
+
async function bindable(address) {
|
|
853
|
+
const socket = createSocket(isIP(address) === 6 ? "udp6" : "udp4");
|
|
854
|
+
try {
|
|
855
|
+
await new Promise((bound, failed) => {
|
|
856
|
+
socket.once("error", failed);
|
|
857
|
+
socket.bind(0, address, () => bound());
|
|
858
|
+
});
|
|
859
|
+
return true;
|
|
860
|
+
} catch {
|
|
861
|
+
return false;
|
|
862
|
+
} finally {
|
|
863
|
+
try {
|
|
864
|
+
socket.close();
|
|
865
|
+
} catch {}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
783
868
|
/**
|
|
784
869
|
* A connection and its description, with its candidates. An early answer's (`held`) takes the contact's offer
|
|
785
870
|
* without its candidates: with none, this side sends the contact no check, so nothing connects, and no audio is sent
|
|
@@ -788,6 +873,7 @@ var HOST_GATHER_MS = 2e3;
|
|
|
788
873
|
async function openConnection(stack, options, offer, held = false) {
|
|
789
874
|
const { ndc } = stack;
|
|
790
875
|
const bind = process.env.GHOSTLY_CALL_BIND;
|
|
876
|
+
if (bind && !await bindable(bind)) throw new CliError("unavailable", CALL_BIND_GONE);
|
|
791
877
|
const iceServers = callIceServers(options.iceServers);
|
|
792
878
|
const pc = new ndc.PeerConnection("ghostly-call", {
|
|
793
879
|
iceServers,
|
|
@@ -1079,8 +1165,7 @@ function gathering(pc, { turn = false } = {}) {
|
|
|
1079
1165
|
});
|
|
1080
1166
|
});
|
|
1081
1167
|
}
|
|
1082
|
-
|
|
1083
|
-
//#region src/calls/manager.ts
|
|
1168
|
+
// src/calls/manager.ts
|
|
1084
1169
|
/** An outgoing call rings this long, then ends as `unanswered`. */
|
|
1085
1170
|
var RING_MS = 6e4;
|
|
1086
1171
|
/** An answered or accepted call has this long to connect its media, then ends as `failed`. */
|
|
@@ -1124,7 +1209,8 @@ var CallManager = class {
|
|
|
1124
1209
|
this.host = host;
|
|
1125
1210
|
this.configPath = join(host.profileDir, "calls.json");
|
|
1126
1211
|
this.auto = readAuto(this.configPath);
|
|
1127
|
-
if (host.answers !== false)
|
|
1212
|
+
if (host.answers !== false && host.socketDir) sharedFolder(host.socketDir);
|
|
1213
|
+
if (host.answers !== false) clearAudioSockets(host.profileDir, host.socketDir);
|
|
1128
1214
|
}
|
|
1129
1215
|
get now() {
|
|
1130
1216
|
return (this.host.now ?? Date.now)();
|
|
@@ -1308,7 +1394,7 @@ var CallManager = class {
|
|
|
1308
1394
|
*/
|
|
1309
1395
|
prepare(call) {
|
|
1310
1396
|
if (this.host.answers === false || call.ended || call.state !== "ringing") return;
|
|
1311
|
-
const settings = this.host.engine.
|
|
1397
|
+
const settings = this.host.engine.getSettings();
|
|
1312
1398
|
const iceServers = settings?.iceServers ?? [];
|
|
1313
1399
|
if (settings?.relayOnly === true || callUsesTurn(callIceServers(iceServers))) return;
|
|
1314
1400
|
this.stopEarly(call);
|
|
@@ -1554,7 +1640,7 @@ var CallManager = class {
|
|
|
1554
1640
|
*/
|
|
1555
1641
|
async attach(call, create) {
|
|
1556
1642
|
const queue = call.queue = new PlaybackQueue(call.rate);
|
|
1557
|
-
const socket = await AudioSocket.open(audioSocketPath(this.host.profileDir, call.id), call.rate, feedQueue(queue));
|
|
1643
|
+
const socket = await AudioSocket.open(audioSocketPath(this.host.profileDir, call.id, this.host.socketDir), call.rate, feedQueue(queue), { shared: !!this.host.socketDir });
|
|
1558
1644
|
if (call.ended) {
|
|
1559
1645
|
await socket.close();
|
|
1560
1646
|
return;
|
|
@@ -1576,7 +1662,7 @@ var CallManager = class {
|
|
|
1576
1662
|
rate: call.rate,
|
|
1577
1663
|
queue: call.queue ?? void 0,
|
|
1578
1664
|
log: (line) => process.stderr.write(`ghostly: call ${call.id}: ${line}\n`),
|
|
1579
|
-
iceServers: this.host.engine.
|
|
1665
|
+
iceServers: this.host.engine.getSettings()?.iceServers ?? [],
|
|
1580
1666
|
onFrame: (frame) => call.socket?.write(frame),
|
|
1581
1667
|
onState: (state) => {
|
|
1582
1668
|
if (call.ended || attempt !== call.attempt) return;
|
|
@@ -1809,7 +1895,7 @@ var CallManager = class {
|
|
|
1809
1895
|
if (ref) {
|
|
1810
1896
|
const byId = this.calls.get(ref);
|
|
1811
1897
|
if (byId) return byId;
|
|
1812
|
-
const call = this.byChat(this.
|
|
1898
|
+
const call = this.byChat(this.chatOf(ref).id);
|
|
1813
1899
|
if (!call) throw new CliError("not_found", `No call in chat ${ref}`);
|
|
1814
1900
|
return call;
|
|
1815
1901
|
}
|
|
@@ -1820,16 +1906,22 @@ var CallManager = class {
|
|
|
1820
1906
|
throw new CliError("bad_request", "More than one call is on: name one (its id or its chat)", { calls: picked.map((c) => c.id) });
|
|
1821
1907
|
}
|
|
1822
1908
|
link(chat) {
|
|
1823
|
-
return this.host.engine.
|
|
1909
|
+
return this.host.engine.chatView(chat);
|
|
1824
1910
|
}
|
|
1825
|
-
/**
|
|
1826
|
-
|
|
1911
|
+
/**
|
|
1912
|
+
* A chat by id, contact key, prefix or name (the API's rules, `findChat`); a group's says it is one. By its id (as
|
|
1913
|
+
* events name it, and a call's own chat), only that chat's view is built: a call placed and hung up built every chat's
|
|
1914
|
+
* five times, one rung and answered six, ~0.2 s of the daemon's thread at 2,000 chats.
|
|
1915
|
+
*/
|
|
1916
|
+
chatOf(ref) {
|
|
1917
|
+
const byId = this.link(ref);
|
|
1918
|
+
if (byId) return byId;
|
|
1827
1919
|
const { links, groups } = this.host.engine.getState();
|
|
1828
|
-
return findChat(links, ref, groups)
|
|
1920
|
+
return findChat(links, ref, groups);
|
|
1829
1921
|
}
|
|
1830
1922
|
/** The chat, if a call can go in it now; else why not (the engine's reason). */
|
|
1831
1923
|
callable(ref) {
|
|
1832
|
-
const link = this.
|
|
1924
|
+
const link = this.chatOf(ref);
|
|
1833
1925
|
if (this.host.answers === false) throw new CliError("unavailable", CALLS_NEED_DAEMON);
|
|
1834
1926
|
if (!link.profile) throw new CliError("unavailable", "Calls are in chats made since 0.4 (the chat session): this is a compatibility chat");
|
|
1835
1927
|
if (link.callsUnavailable === CALLS_NEED_LIVE) {
|
|
@@ -1837,7 +1929,7 @@ var CallManager = class {
|
|
|
1837
1929
|
throw new CliError("unavailable", `${CALLS_NEED_LIVE}, and your contact's app is not connected now: ghostly chat wait ${shown} --until live waits for it, then call again`, { chat: link.id });
|
|
1838
1930
|
}
|
|
1839
1931
|
if (link.callsUnavailable) throw new CliError("unavailable", link.callsUnavailable);
|
|
1840
|
-
if (this.host.engine.
|
|
1932
|
+
if (this.host.engine.getSettings()?.relayOnly === true) throw new CliError("unavailable", CALLS_OFF_RELAY_ONLY);
|
|
1841
1933
|
return link;
|
|
1842
1934
|
}
|
|
1843
1935
|
autoFor(chat) {
|
|
@@ -1881,8 +1973,7 @@ function readAuto(path) {
|
|
|
1881
1973
|
return off;
|
|
1882
1974
|
}
|
|
1883
1975
|
}
|
|
1884
|
-
|
|
1885
|
-
//#region src/daemonPresence.ts
|
|
1976
|
+
// src/daemonPresence.ts
|
|
1886
1977
|
/** How often a daemon that shares its presence says `active` again: well within the engine's 10 minutes to `idle`. */
|
|
1887
1978
|
var PRESENCE_EVERY_MS = STATUS_IDLE_AFTER_MS / 2;
|
|
1888
1979
|
/**
|
|
@@ -2593,7 +2684,9 @@ var EventHub = class {
|
|
|
2593
2684
|
stateChanged(state) {
|
|
2594
2685
|
const quiet = !this.stateKnown;
|
|
2595
2686
|
const links = new Map(state.links.map((link) => [link.id, link]));
|
|
2687
|
+
const last = new Map(this.state?.links.map((link) => [link.id, link]));
|
|
2596
2688
|
for (const [id, link] of links) {
|
|
2689
|
+
if (last.get(id) === link && this.chats.has(id)) continue;
|
|
2597
2690
|
const shape = chatShape(link), before = this.chats.get(id);
|
|
2598
2691
|
this.chats.set(id, shape);
|
|
2599
2692
|
if (quiet) continue;
|
|
@@ -2697,7 +2790,8 @@ var EventHub = class {
|
|
|
2697
2790
|
this.forget(removedGroups, (event) => groupsGone.has(event.group) && event.type !== "group.removed");
|
|
2698
2791
|
let edgeGroups;
|
|
2699
2792
|
const groupOf = (linkId) => (edgeGroups ??= new Map(state.groups.flatMap((g) => g.members.flatMap((m) => m.edge ? [[m.edge.linkId, g.id]] : [])))).get(linkId) ?? parsePayLink(linkId)?.groupId;
|
|
2700
|
-
|
|
2793
|
+
const payments = state.payments === this.state?.payments ? {} : state.payments ?? {};
|
|
2794
|
+
for (const [id, payment] of Object.entries(payments)) {
|
|
2701
2795
|
const shape = `${payment.state}|${payment.error ?? ""}|${payment.closed ? 1 : 0}`, before = this.payments.get(id);
|
|
2702
2796
|
this.payments.set(id, shape);
|
|
2703
2797
|
if (quiet || before === shape) continue;
|
|
@@ -2715,22 +2809,25 @@ var EventHub = class {
|
|
|
2715
2809
|
payment: json
|
|
2716
2810
|
});
|
|
2717
2811
|
}
|
|
2718
|
-
for (const link of state.links)
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
identity: {
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2812
|
+
for (const link of state.links) {
|
|
2813
|
+
if (last.get(link.id) === link) continue;
|
|
2814
|
+
for (const identity of link.identities?.received ?? []) {
|
|
2815
|
+
const key = `${link.id}:${identity.id}`, shape = identity.status, before = this.received.get(key);
|
|
2816
|
+
this.received.set(key, shape);
|
|
2817
|
+
if (quiet || before === shape) continue;
|
|
2818
|
+
const id = before === void 0 ? `identity.received:${key}:${shape}` : `identity.status:${key}:${shape}:${this.now()}:${this.seq + 1}`;
|
|
2819
|
+
this.emit(before === void 0 ? "identity.received" : "identity.status", id, {
|
|
2820
|
+
chat: link.id,
|
|
2821
|
+
identity: {
|
|
2822
|
+
id: identity.id,
|
|
2823
|
+
provider: identity.provider,
|
|
2824
|
+
subject: identity.subject,
|
|
2825
|
+
status: identity.status,
|
|
2826
|
+
verified: identity.verified,
|
|
2827
|
+
error: identity.error ?? null
|
|
2828
|
+
}
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2734
2831
|
}
|
|
2735
2832
|
for (const [id, transfer] of Object.entries(state.transfers ?? {})) this.transferChanged(id, transfer, state, quiet);
|
|
2736
2833
|
this.state = state;
|
|
@@ -3532,8 +3629,7 @@ function journalWindow(path, lineAt = 0) {
|
|
|
3532
3629
|
closeSync(fd);
|
|
3533
3630
|
}
|
|
3534
3631
|
}
|
|
3535
|
-
|
|
3536
|
-
//#region src/groupAuto.ts
|
|
3632
|
+
// src/groupAuto.ts
|
|
3537
3633
|
var FILE = "groups.json";
|
|
3538
3634
|
var GroupAutoJoin = class {
|
|
3539
3635
|
host;
|
|
@@ -3671,8 +3767,7 @@ function readGrants(path) {
|
|
|
3671
3767
|
return [];
|
|
3672
3768
|
}
|
|
3673
3769
|
}
|
|
3674
|
-
|
|
3675
|
-
//#region src/joinLog.ts
|
|
3770
|
+
// src/joinLog.ts
|
|
3676
3771
|
/**
|
|
3677
3772
|
* A join through a group's link, as a daemon says it in its log (stderr): the steps of the knock and of the entry
|
|
3678
3773
|
* session, one short line each, from the engine's join trace (packages/browser/src/engine/joinTrace.ts). Without them a
|
|
@@ -3713,8 +3808,7 @@ function joinLogLine(traced) {
|
|
|
3713
3808
|
const at = typeof step.t === "number" ? ` at ${new Date(step.t).toISOString()}` : "";
|
|
3714
3809
|
return `ghostly: group ${step.g}: ${SAID[step.step]}${role ? ` (${role === "host" ? "letting in" : "joining"})` : ""}${at}`;
|
|
3715
3810
|
}
|
|
3716
|
-
|
|
3717
|
-
//#region src/runtime/fedimint.ts
|
|
3811
|
+
// src/runtime/fedimint.ts
|
|
3718
3812
|
/**
|
|
3719
3813
|
* The Fedimint client on Node (WISP 1100 § Wallet SDKs on Node): the app's own SDK and WebAssembly, each database in
|
|
3720
3814
|
* a `worker_threads` worker (fedimintWorker.mjs) and a file of the profile's `fedimint/` folder, where the browser has
|
|
@@ -3822,8 +3916,7 @@ function nodeFedimintSdk(dir) {
|
|
|
3822
3916
|
throw error;
|
|
3823
3917
|
});
|
|
3824
3918
|
}
|
|
3825
|
-
|
|
3826
|
-
//#region src/runtime/fileFetch.ts
|
|
3919
|
+
// src/runtime/fileFetch.ts
|
|
3827
3920
|
/**
|
|
3828
3921
|
* `fetch` for `file:` URLs, which Node's does not do. The wallet SDKs' WebAssembly (Bark, BDK, Breez, Iroh) is loaded
|
|
3829
3922
|
* the way a page loads it, `fetch(new URL("…wasm", import.meta.url))`; on Node that URL is a file beside the bundle.
|
|
@@ -3843,8 +3936,7 @@ function installFileFetch() {
|
|
|
3843
3936
|
};
|
|
3844
3937
|
globalThis.fetch = patched;
|
|
3845
3938
|
}
|
|
3846
|
-
|
|
3847
|
-
//#region src/runtime/pushSend.ts
|
|
3939
|
+
// src/runtime/pushSend.ts
|
|
3848
3940
|
/** An address as bytes (4 or 16), or null when it is not one. */
|
|
3849
3941
|
function addressBytes(address) {
|
|
3850
3942
|
const family = isIP(address);
|
|
@@ -3918,8 +4010,7 @@ async function nodePushSend(push, lookup = publicOnlyLookup) {
|
|
|
3918
4010
|
req.end(push.body);
|
|
3919
4011
|
});
|
|
3920
4012
|
}
|
|
3921
|
-
|
|
3922
|
-
//#region src/runtime/holdFetch.ts
|
|
4013
|
+
// src/runtime/holdFetch.ts
|
|
3923
4014
|
/**
|
|
3924
4015
|
* How the CLI reads a held item or manifest (WISP 404): a GET to the address the contact chose, only
|
|
3925
4016
|
* at a name whose every address is public, checked when the connection is made (so a name that changes its answer
|
|
@@ -3946,8 +4037,59 @@ function nodeHoldFetch(lookup = publicOnlyLookup) {
|
|
|
3946
4037
|
req.end();
|
|
3947
4038
|
});
|
|
3948
4039
|
}
|
|
3949
|
-
|
|
3950
|
-
|
|
4040
|
+
// src/runtime/publicFetch.ts
|
|
4041
|
+
var MAX_REDIRECTS = 5;
|
|
4042
|
+
/**
|
|
4043
|
+
* How the CLI reads an identity's proof and public data (WISP 300, PUBLIC-PROFILES.md) at the address a contact named:
|
|
4044
|
+
* HTTPS GET only at a public address, or at a name whose every address is public, checked when the connection is made
|
|
4045
|
+
* (so a name that changes its answer after the engine's own check is refused too). No proxy. A redirect is refused
|
|
4046
|
+
* unless asked for, and each hop is checked the same way. The engine bounds the size and time (`boundedIdentityFetch`).
|
|
4047
|
+
*/
|
|
4048
|
+
function nodePublicFetch(lookup = publicOnlyLookup) {
|
|
4049
|
+
const get = (url, headers, signal) => new Promise((resolve, reject) => {
|
|
4050
|
+
if (url.protocol !== "https:") return reject(/* @__PURE__ */ new TypeError("Only HTTPS is read"));
|
|
4051
|
+
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
4052
|
+
if (isIP(host) && !isPublicIp(host)) return reject(/* @__PURE__ */ new TypeError(`${host} is not a public address`));
|
|
4053
|
+
const req = request(url, {
|
|
4054
|
+
method: "GET",
|
|
4055
|
+
headers: Object.fromEntries(headers),
|
|
4056
|
+
lookup,
|
|
4057
|
+
agent: false,
|
|
4058
|
+
signal
|
|
4059
|
+
}, (res) => {
|
|
4060
|
+
const out = new Headers();
|
|
4061
|
+
for (const [name, value] of Object.entries(res.headers)) if (typeof value === "string") out.set(name, value);
|
|
4062
|
+
const status = res.statusCode ?? 0;
|
|
4063
|
+
resolve(new Response(status === 204 || status === 304 ? null : Readable.toWeb(res), {
|
|
4064
|
+
status,
|
|
4065
|
+
headers: out
|
|
4066
|
+
}));
|
|
4067
|
+
});
|
|
4068
|
+
req.on("error", reject);
|
|
4069
|
+
req.end();
|
|
4070
|
+
});
|
|
4071
|
+
return async (input, init) => {
|
|
4072
|
+
let url = new URL(typeof input === "string" ? input : input instanceof URL ? input.href : input.url);
|
|
4073
|
+
if ((init?.method ?? "GET").toUpperCase() !== "GET") throw new TypeError("Only GET is sent");
|
|
4074
|
+
const headers = new Headers(init?.headers);
|
|
4075
|
+
const signal = init?.signal ?? void 0;
|
|
4076
|
+
for (let hops = 0;; hops++) {
|
|
4077
|
+
const response = await get(url, headers, signal);
|
|
4078
|
+
const location = response.headers.get("location");
|
|
4079
|
+
if (response.status < 300 || response.status > 399 || !location || init?.redirect === "manual") {
|
|
4080
|
+
if (hops) Object.defineProperties(response, {
|
|
4081
|
+
url: { value: url.href },
|
|
4082
|
+
redirected: { value: true }
|
|
4083
|
+
});
|
|
4084
|
+
return response;
|
|
4085
|
+
}
|
|
4086
|
+
await response.body?.cancel();
|
|
4087
|
+
if (init?.redirect !== "follow" || hops >= MAX_REDIRECTS) throw new TypeError("Redirect refused");
|
|
4088
|
+
url = new URL(location, url);
|
|
4089
|
+
}
|
|
4090
|
+
};
|
|
4091
|
+
}
|
|
4092
|
+
// src/runtime/irohRelay.ts
|
|
3951
4093
|
/**
|
|
3952
4094
|
* Whether the CLI's Iroh may dial a contact through the relay its descriptor names (irohWeb.ts `publicRelay`): at a
|
|
3953
4095
|
* public address, or at a name whose every address is public now, as a held item's is (`publicOnlyLookup`). Asked again
|
|
@@ -4001,8 +4143,7 @@ function relaySockets(scope) {
|
|
|
4001
4143
|
} });
|
|
4002
4144
|
return names;
|
|
4003
4145
|
}
|
|
4004
|
-
|
|
4005
|
-
//#region src/runtime/rows.ts
|
|
4146
|
+
// src/runtime/rows.ts
|
|
4006
4147
|
/** The warning `node:sqlite` gives as it loads (experimental on Node 22 and 23): said once for every command, it is noise. */
|
|
4007
4148
|
var SQLITE_WARNING = /^SQLite is an experimental feature/;
|
|
4008
4149
|
var loaded;
|
|
@@ -4065,8 +4206,7 @@ function rowRecords(rows) {
|
|
|
4065
4206
|
return record;
|
|
4066
4207
|
} };
|
|
4067
4208
|
}
|
|
4068
|
-
|
|
4069
|
-
//#region src/runtime/keyBytes.ts
|
|
4209
|
+
// src/runtime/keyBytes.ts
|
|
4070
4210
|
/**
|
|
4071
4211
|
* An IndexedDB key as bytes whose order is the keys' own (W3C IndexedDB § Compare two keys: a number before a date
|
|
4072
4212
|
* before a string before binary before an array; strings by UTF-16 code unit; arrays item by item, the shorter
|
|
@@ -4135,8 +4275,7 @@ function number(value, out) {
|
|
|
4135
4275
|
out.push(negative ? ~byte & 255 : at === 0 ? byte ^ 128 : byte);
|
|
4136
4276
|
}
|
|
4137
4277
|
}
|
|
4138
|
-
|
|
4139
|
-
//#region src/runtime/sqlTree.ts
|
|
4278
|
+
// src/runtime/sqlTree.ts
|
|
4140
4279
|
var buffer = (bytes) => Buffer.from(bytes, "latin1");
|
|
4141
4280
|
/**
|
|
4142
4281
|
* Values just read from rows.db, which nothing else holds: fake-indexeddb copies each value it hands out, and for these
|
|
@@ -4247,6 +4386,15 @@ var TreeFile = class {
|
|
|
4247
4386
|
closeSync(fd);
|
|
4248
4387
|
}
|
|
4249
4388
|
}
|
|
4389
|
+
/**
|
|
4390
|
+
* rows.db written again whole (VACUUM), with nothing but its rows: `secure_delete` zeroes the cell a delete frees, not
|
|
4391
|
+
* the copies a page's rebalancing left in its unused space, where a text gone from every row was still found after a
|
|
4392
|
+
* few thousand writes. A second or two for a profile of 100,000 messages, the thread held: only when asked
|
|
4393
|
+
* (`message delete --purge`).
|
|
4394
|
+
*/
|
|
4395
|
+
scrub() {
|
|
4396
|
+
this.db.exec("VACUUM");
|
|
4397
|
+
}
|
|
4250
4398
|
/** Trees whose store or index is gone from the schema (deleted, a database removed) go, with their entries. */
|
|
4251
4399
|
sweep(keep) {
|
|
4252
4400
|
const ids = this.db.prepare("SELECT id FROM trees").all().map((row) => Number(row.id)).filter((id) => !keep.has(id));
|
|
@@ -4578,7 +4726,8 @@ var SqlTree = class SqlTree {
|
|
|
4578
4726
|
/**
|
|
4579
4727
|
* rows.db, owner-only (SQLite makes its WAL files with the database's mode), in WAL with NORMAL: the journal makes a
|
|
4580
4728
|
* transaction durable, and `sync` runs before a snapshot takes the journal's place. With `secure_delete` SQLite zeroes
|
|
4581
|
-
* what a delete frees: a message or chat deleted is not left readable in the file's free pages after the fold
|
|
4729
|
+
* what a delete frees: a message or chat deleted is not left readable in the file's free pages after the fold (but for
|
|
4730
|
+
* a copy a page's rebalancing left behind, now and then: `TreeFile.scrub`).
|
|
4582
4731
|
*/
|
|
4583
4732
|
function openTreeFile(sqlite, path, constraintError) {
|
|
4584
4733
|
closeSync(openSync(path, "a", 384));
|
|
@@ -4622,8 +4771,7 @@ function holdsBlob(value, depth = 0) {
|
|
|
4622
4771
|
for (const item of Object.values(value)) if (holdsBlob(item, depth + 1)) return true;
|
|
4623
4772
|
return false;
|
|
4624
4773
|
}
|
|
4625
|
-
|
|
4626
|
-
//#region src/runtime/storage.ts
|
|
4774
|
+
// src/runtime/storage.ts
|
|
4627
4775
|
var SNAPSHOT = "snapshot.bin";
|
|
4628
4776
|
var JOURNAL = "journal.bin";
|
|
4629
4777
|
var ROWS = "rows.db";
|
|
@@ -4897,9 +5045,7 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
4897
5045
|
pending.delete(this._rollbackLog);
|
|
4898
5046
|
trees?.abort(this._rollbackLog);
|
|
4899
5047
|
}
|
|
4900
|
-
|
|
4901
|
-
if ((event.type === "complete" || event.type === "abort") && this._state === "finished") dropEnded(this.db._rawDatabase, this);
|
|
4902
|
-
return dispatched;
|
|
5048
|
+
return dispatch.call(this, event);
|
|
4903
5049
|
};
|
|
4904
5050
|
const deleteDatabase = factory.deleteDatabase.bind(factory);
|
|
4905
5051
|
factory.deleteDatabase = (name) => {
|
|
@@ -5046,7 +5192,7 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5046
5192
|
* `sync`: "now", synced before this returns; "shared", synced by the caller through `shareSync`; "lazy", a relaxed
|
|
5047
5193
|
* transaction's entry. A sync blocks the whole process for milliseconds, and what such a transaction wrote can be
|
|
5048
5194
|
* made again (the event set's note of a message it already reported): written, it outlives the process; a power cut
|
|
5049
|
-
* may take its last second.
|
|
5195
|
+
* may take its last second. Its sync, a second later, runs off the thread as a shared one does.
|
|
5050
5196
|
*/
|
|
5051
5197
|
function writeEntry(entry, sync = "now") {
|
|
5052
5198
|
const lazy = sync === "lazy";
|
|
@@ -5072,11 +5218,8 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5072
5218
|
throw error;
|
|
5073
5219
|
}
|
|
5074
5220
|
if (lazy) relaxed ??= setTimeout(() => {
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
} catch (error) {
|
|
5078
|
-
failed(error);
|
|
5079
|
-
}
|
|
5221
|
+
relaxed = null;
|
|
5222
|
+
shareSync(() => {});
|
|
5080
5223
|
}, RELAXED_SYNC_MS).unref();
|
|
5081
5224
|
holdsRatchet ||= entry.includes(RATCHET);
|
|
5082
5225
|
if (statSync(journalPath).size > COMPACT_BYTES || ratchetDue() || deleteDue()) enqueue(writeSnapshot);
|
|
@@ -5126,11 +5269,11 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5126
5269
|
async function synced() {
|
|
5127
5270
|
while (syncing) await syncing;
|
|
5128
5271
|
}
|
|
5129
|
-
async function writeSnapshot() {
|
|
5272
|
+
async function writeSnapshot(scrub = false) {
|
|
5130
5273
|
const dirty = schemaDirty;
|
|
5131
5274
|
schemaDirty = false;
|
|
5132
5275
|
try {
|
|
5133
|
-
await snapshotToDisk();
|
|
5276
|
+
await snapshotToDisk(scrub);
|
|
5134
5277
|
} catch (error) {
|
|
5135
5278
|
schemaDirty ||= dirty;
|
|
5136
5279
|
throw error;
|
|
@@ -5269,12 +5412,13 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5269
5412
|
reader?.db.close();
|
|
5270
5413
|
}
|
|
5271
5414
|
}
|
|
5272
|
-
async function snapshotToDisk() {
|
|
5415
|
+
async function snapshotToDisk(scrub = false) {
|
|
5273
5416
|
await synced();
|
|
5274
5417
|
const name = randomBytes(8).toString("hex");
|
|
5275
5418
|
const snapshot = await capture(name);
|
|
5276
5419
|
if (trees) {
|
|
5277
5420
|
trees.apply(seq);
|
|
5421
|
+
if (scrub) trees.scrub();
|
|
5278
5422
|
trees.sync();
|
|
5279
5423
|
}
|
|
5280
5424
|
const temporary = snapshotPath + ".tmp";
|
|
@@ -5345,10 +5489,10 @@ async function openPersistentIndexedDb(dir, options = {}) {
|
|
|
5345
5489
|
factory,
|
|
5346
5490
|
recovered: !replayed.closed,
|
|
5347
5491
|
flush: () => queue,
|
|
5348
|
-
async compact() {
|
|
5492
|
+
async compact(options) {
|
|
5349
5493
|
await settled();
|
|
5350
5494
|
let thrown = null;
|
|
5351
|
-
await enqueue(() => writeSnapshot().catch((error) => {
|
|
5495
|
+
await enqueue(() => writeSnapshot(options?.scrub).catch((error) => {
|
|
5352
5496
|
thrown = { error };
|
|
5353
5497
|
throw error;
|
|
5354
5498
|
}));
|
|
@@ -5629,24 +5773,6 @@ function readWithoutCopy(classes) {
|
|
|
5629
5773
|
return values;
|
|
5630
5774
|
};
|
|
5631
5775
|
}
|
|
5632
|
-
/** Transactions whose last event is out, by database, and dropped from its list at the next turn: all at once. */
|
|
5633
|
-
var ended = /* @__PURE__ */ new WeakMap();
|
|
5634
|
-
/** A finished transaction's place in its database's list, given back: one walk of the list for all that ended in a turn. */
|
|
5635
|
-
function dropEnded(db, transaction) {
|
|
5636
|
-
let gone = ended.get(db);
|
|
5637
|
-
if (gone) {
|
|
5638
|
-
gone.add(transaction);
|
|
5639
|
-
return;
|
|
5640
|
-
}
|
|
5641
|
-
ended.set(db, gone = /* @__PURE__ */ new Set([transaction]));
|
|
5642
|
-
setImmediate(() => {
|
|
5643
|
-
ended.delete(db);
|
|
5644
|
-
const list = db.transactions;
|
|
5645
|
-
let kept = 0;
|
|
5646
|
-
for (const held of list) if (!gone.has(held)) list[kept++] = held;
|
|
5647
|
-
list.length = kept;
|
|
5648
|
-
});
|
|
5649
|
-
}
|
|
5650
5776
|
/** The classes whose scheduler starts every transaction it can in one pass: shared by every store opened. */
|
|
5651
5777
|
var onePass = /* @__PURE__ */ new WeakSet();
|
|
5652
5778
|
/**
|
|
@@ -6183,8 +6309,7 @@ function safe(read) {
|
|
|
6183
6309
|
return "";
|
|
6184
6310
|
}
|
|
6185
6311
|
}
|
|
6186
|
-
|
|
6187
|
-
//#region src/runtime/engine.ts
|
|
6312
|
+
// src/runtime/engine.ts
|
|
6188
6313
|
setPublicKeyFastPath(nativePublicKey);
|
|
6189
6314
|
/**
|
|
6190
6315
|
* The HyperDHT network: `GHOSTLY_HYPERDHT_BOOTSTRAP` ("host:port,…") replaces the public bootstrap nodes, as it does
|
|
@@ -6407,7 +6532,7 @@ async function startRuntime(paths, options = {}) {
|
|
|
6407
6532
|
const dht = mainlineNetwork();
|
|
6408
6533
|
const trace = process.env.GHOSTLY_LINK_TRACE;
|
|
6409
6534
|
if (trace) setLinkTraceSink((line) => appendFileSync(trace, line + "\n", { mode: 384 }));
|
|
6410
|
-
if (trace || options.logJoins) (await import("./joinTrace-
|
|
6535
|
+
if (trace || options.logJoins) (await import("./joinTrace-CBr1jbch.js")).setJoinTraceSink((line) => {
|
|
6411
6536
|
if (trace) appendFileSync(trace, line + "\n", { mode: 384 });
|
|
6412
6537
|
const said = options.logJoins ? joinLogLine(line) : null;
|
|
6413
6538
|
if (said) process.stderr.write(said + "\n");
|
|
@@ -6417,7 +6542,7 @@ async function startRuntime(paths, options = {}) {
|
|
|
6417
6542
|
const restored = join(paths.dir, RESTORED_MARK);
|
|
6418
6543
|
if (existsSync(restored)) {
|
|
6419
6544
|
try {
|
|
6420
|
-
const rows = await import("./restoredRows-
|
|
6545
|
+
const rows = await import("./restoredRows-D_WSHE7H.js");
|
|
6421
6546
|
await rows.markRestoredWallet();
|
|
6422
6547
|
await rows.markLeftOutFiles(leftOutIn(restored));
|
|
6423
6548
|
await rows.forgetRatchets();
|
|
@@ -6433,15 +6558,15 @@ async function startRuntime(paths, options = {}) {
|
|
|
6433
6558
|
const callsUnavailable = typeof stack === "string" ? stack : null;
|
|
6434
6559
|
installFileFetch();
|
|
6435
6560
|
const testMints = process.env.GHOSTLY_TEST_MINTS;
|
|
6436
|
-
if (testMints) (await import("./mints-
|
|
6561
|
+
if (testMints) (await import("./mints-BcBODVVW.js")).declareTestMints(testMints.split(","));
|
|
6437
6562
|
await installEventSource();
|
|
6438
6563
|
await preloadWalletModules();
|
|
6439
|
-
(await import("./ghostly_iroh_web-
|
|
6440
|
-
const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-
|
|
6564
|
+
(await import("./ghostly_iroh_web-DIj5xGmR.js")).initSync({ module: irohWasmBytes() });
|
|
6565
|
+
const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-CCKbwqG_.js"), import("./fileBytes-tj6-VZcB.js")]);
|
|
6441
6566
|
registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
|
|
6442
|
-
if (await (await import("./blobFiles-
|
|
6443
|
-
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-
|
|
6444
|
-
const mainline = dht.off ? null : new (await (import("./mainline-
|
|
6567
|
+
if (await (await import("./blobFiles-DDs34n0r.js")).moveBlobFiles()) await store.compact();
|
|
6568
|
+
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-D4gf-LnD.js"), import("./endpoint-Cvu-taMs.js")]);
|
|
6569
|
+
const mainline = dht.off ? null : new (await (import("./mainline-CVrd0C1n.js"))).Mainline({
|
|
6445
6570
|
bootstrap: dht.bootstrap,
|
|
6446
6571
|
host: dht.host
|
|
6447
6572
|
});
|
|
@@ -6449,7 +6574,7 @@ async function startRuntime(paths, options = {}) {
|
|
|
6449
6574
|
...pinned ? { relays: pinned } : {},
|
|
6450
6575
|
...relayBudgetForTests()
|
|
6451
6576
|
};
|
|
6452
|
-
const transport = mainline || pinned ? new (await (import("./mainline-
|
|
6577
|
+
const transport = mainline || pinned ? new (await (import("./mainline-CVrd0C1n.js"))).RelaysAndDht(mainline, relayOptions, !!pinned) : null;
|
|
6453
6578
|
const apps = servedApps(paths.dir).length > 0;
|
|
6454
6579
|
const server = new EngineServer({
|
|
6455
6580
|
...transport ? { transport } : {},
|
|
@@ -6468,6 +6593,7 @@ async function startRuntime(paths, options = {}) {
|
|
|
6468
6593
|
localFetch: nodeLocalFetch,
|
|
6469
6594
|
pushSend: (request) => nodePushSend(request),
|
|
6470
6595
|
holdFetch: nodeHoldFetch(),
|
|
6596
|
+
identityFetch: nodePublicFetch(),
|
|
6471
6597
|
webrtcIgnoresRelayOnly: true,
|
|
6472
6598
|
callsSupport: callsUnavailable === null,
|
|
6473
6599
|
...callsUnavailable ? { callsUnavailable } : {},
|
|
@@ -6505,8 +6631,7 @@ async function startRuntime(paths, options = {}) {
|
|
|
6505
6631
|
})()
|
|
6506
6632
|
};
|
|
6507
6633
|
}
|
|
6508
|
-
|
|
6509
|
-
//#region src/host.ts
|
|
6634
|
+
// src/host.ts
|
|
6510
6635
|
/**
|
|
6511
6636
|
* The most a connection may leave unread (answers and events the daemon wrote that its client has not taken): past
|
|
6512
6637
|
* it, the connection ends. A `listen` stopped with Ctrl+Z, or a client that stops reading, kept every later event in
|
|
@@ -6527,6 +6652,7 @@ var BASELINE_NEWEST = 100;
|
|
|
6527
6652
|
*/
|
|
6528
6653
|
async function openHost(paths, mode, version, options = {}) {
|
|
6529
6654
|
ownProfile(paths.dir);
|
|
6655
|
+
const socketDir = mode === "daemon" ? callSocketDir() : void 0;
|
|
6530
6656
|
const locked = acquireLock(paths);
|
|
6531
6657
|
const unmark = mode === "daemon" ? markStarting(paths) : () => {};
|
|
6532
6658
|
const release = () => {
|
|
@@ -6609,6 +6735,7 @@ async function openHost(paths, mode, version, options = {}) {
|
|
|
6609
6735
|
engine: node,
|
|
6610
6736
|
emit: (type, id, fields) => hub.emit(type, id, fields),
|
|
6611
6737
|
profileDir: paths.dir,
|
|
6738
|
+
socketDir,
|
|
6612
6739
|
answers: mode === "daemon"
|
|
6613
6740
|
});
|
|
6614
6741
|
const manager = calls;
|
|
@@ -6781,6 +6908,8 @@ function connection(ctx, socket, secret, answering) {
|
|
|
6781
6908
|
const unsubscribe = () => {
|
|
6782
6909
|
for (const off of unsubscribes.splice(0)) off();
|
|
6783
6910
|
};
|
|
6911
|
+
const gone = new AbortController();
|
|
6912
|
+
socket.on("close", () => gone.abort());
|
|
6784
6913
|
const write = (value, replayed = false) => {
|
|
6785
6914
|
if (socket.destroyed || socket.writableEnded) return;
|
|
6786
6915
|
if (!replayed && socket.writableLength > limit) {
|
|
@@ -6892,7 +7021,7 @@ function connection(ctx, socket, secret, answering) {
|
|
|
6892
7021
|
for (const event of queued) if (event.seq > last) write({ event });
|
|
6893
7022
|
return;
|
|
6894
7023
|
}
|
|
6895
|
-
const answered = callApi(ctx, request.method, request.params ?? {}).then((result) => write({
|
|
7024
|
+
const answered = callApi(ctx, request.method, request.params ?? {}, { gone: gone.signal }).then((result) => write({
|
|
6896
7025
|
id,
|
|
6897
7026
|
result: result ?? null
|
|
6898
7027
|
}), (error) => write({
|
|
@@ -6903,7 +7032,6 @@ function connection(ctx, socket, secret, answering) {
|
|
|
6903
7032
|
answered.then(() => answering.delete(answered));
|
|
6904
7033
|
});
|
|
6905
7034
|
}
|
|
6906
|
-
//#endregion
|
|
6907
7035
|
export { BASELINE_NEWEST, MAX_UNREAD, STOP_ANSWERS_MS, keepServing, openHost, serve };
|
|
6908
7036
|
|
|
6909
|
-
//# sourceMappingURL=host-
|
|
7037
|
+
//# sourceMappingURL=host-BxM-HMr0.js.map
|