@ghostlytools/cli 1.11.4 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/README.md +28 -11
  2. package/dist/assets/{api-MYc6QNRs.js → api-DLzCtePC.js} +363 -125
  3. package/dist/assets/api-DLzCtePC.js.map +1 -0
  4. package/dist/assets/{api-BwyFq4lA.js → api-DYMKyb1k.js} +2 -2
  5. package/dist/assets/{apiKit-CfsNx9ZR.js → apiKit-CVaEzKWQ.js} +48 -11
  6. package/dist/assets/apiKit-CVaEzKWQ.js.map +1 -0
  7. package/dist/assets/appFetch-D56GsYuq.js +602 -0
  8. package/dist/assets/appFetch-D56GsYuq.js.map +1 -0
  9. package/dist/assets/apps-BPFW19Wc.js +1 -0
  10. package/dist/assets/{apps-h12II1us.js → apps-XnZ8VEuj.js} +20 -14
  11. package/dist/assets/apps-XnZ8VEuj.js.map +1 -0
  12. package/dist/assets/{argon2id-088uQfnH.js → argon2id-B9wFdSj6.js} +2 -3
  13. package/dist/assets/{argon2id-088uQfnH.js.map → argon2id-B9wFdSj6.js.map} +1 -1
  14. package/dist/assets/{arkade-Bw_4PZRG.js → arkade-DryM-q5n.js} +6 -7
  15. package/dist/assets/arkade-DryM-q5n.js.map +1 -0
  16. package/dist/assets/backup-COX6j1_W.js +1 -0
  17. package/dist/assets/{backup-Chvy79SN.js → backup-DpyvT9Z6.js} +66 -21
  18. package/dist/assets/backup-DpyvT9Z6.js.map +1 -0
  19. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +5 -0
  20. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +1 -0
  21. package/dist/assets/{bark_ffi_wasm_bg-Bxru_BVW.wasm → bark_ffi_wasm_bg-VNmaJsc9.wasm} +0 -0
  22. package/dist/assets/{bitcoind-CdSmvy2y.js → bitcoind-DTsrd7TF.js} +4 -5
  23. package/dist/assets/{bitcoind-CdSmvy2y.js.map → bitcoind-DTsrd7TF.js.map} +1 -1
  24. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +5 -0
  25. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +1 -0
  26. package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
  27. package/dist/assets/{blobFiles-BmsrvZc3.js → blobFiles-DDs34n0r.js} +4 -5
  28. package/dist/assets/{blobFiles-BmsrvZc3.js.map → blobFiles-DDs34n0r.js.map} +1 -1
  29. package/dist/assets/breez_sdk_spark_wasm_bg.wasm +0 -0
  30. package/dist/assets/buttons-Bq7pTXqF.js +1 -0
  31. package/dist/assets/{buttons-BgoExb4E.js → buttons-BvWqHJeh.js} +45 -23
  32. package/dist/assets/buttons-BvWqHJeh.js.map +1 -0
  33. package/dist/assets/bytes-C1DNGY18.js +132 -0
  34. package/dist/assets/bytes-C1DNGY18.js.map +1 -0
  35. package/dist/assets/{childEnv-K_IzUqQx.js → childEnv-C-99hdbL.js} +2 -3
  36. package/dist/assets/{childEnv-K_IzUqQx.js.map → childEnv-C-99hdbL.js.map} +1 -1
  37. package/dist/assets/{client-DY8tZZWi.js → client-kGZ3ZdUW.js} +5 -8
  38. package/dist/assets/{client-DY8tZZWi.js.map → client-kGZ3ZdUW.js.map} +1 -1
  39. package/dist/assets/{codec-BnMg-Grj.js → codec-B2rH1mfx.js} +2 -4
  40. package/dist/assets/{codec-BnMg-Grj.js.map → codec-B2rH1mfx.js.map} +1 -1
  41. package/dist/assets/domainProofs-BDNP1dIy.js +280 -0
  42. package/dist/assets/domainProofs-BDNP1dIy.js.map +1 -0
  43. package/dist/assets/{endpoint-DarqblYE.js → endpoint-B0vE5ojY.js} +421 -420
  44. package/dist/assets/endpoint-B0vE5ojY.js.map +1 -0
  45. package/dist/assets/engineErrors--9hfgKlK.js +150 -0
  46. package/dist/assets/engineErrors--9hfgKlK.js.map +1 -0
  47. package/dist/assets/{envelope-CdV7vHVZ.js → envelope-Bi2kMqbp.js} +3 -4
  48. package/dist/assets/{envelope-CdV7vHVZ.js.map → envelope-Bi2kMqbp.js.map} +1 -1
  49. package/dist/assets/{errors-CAh6GLJZ.js → errors-DDLFO4Gf.js} +5 -4
  50. package/dist/assets/errors-DDLFO4Gf.js.map +1 -0
  51. package/dist/assets/{fedimintSdk-CPFfVK-G.js → fedimintSdk-D-6H9Pe7.js} +4 -5
  52. package/dist/assets/{fedimintSdk-CPFfVK-G.js.map → fedimintSdk-D-6H9Pe7.js.map} +1 -1
  53. package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +5 -0
  54. package/dist/assets/{fedimint_client_wasm_bg-BtHHlFpp.js.map → fedimint_client_wasm_bg-Cr5xGD-w.js.map} +1 -1
  55. package/dist/assets/fileBytes-CCKbwqG_.js +1 -0
  56. package/dist/assets/{fileBytes-BLPZq9YU.js → fileBytes-CfvUXdSy.js} +5 -7
  57. package/dist/assets/fileBytes-CfvUXdSy.js.map +1 -0
  58. package/dist/assets/{fileBytes-B0z9A6Le.js → fileBytes-tj6-VZcB.js} +3 -4
  59. package/dist/assets/{fileBytes-B0z9A6Le.js.map → fileBytes-tj6-VZcB.js.map} +1 -1
  60. package/dist/assets/fileBytesIdb-B0zzJ6p7.js +1 -0
  61. package/dist/assets/{fileBytesIdb-Bmlrl9EO.js → fileBytesIdb-BJirUAjI.js} +4 -5
  62. package/dist/assets/{fileBytesIdb-Bmlrl9EO.js.map → fileBytesIdb-BJirUAjI.js.map} +1 -1
  63. package/dist/assets/{fileBytesOpfs-DBS0kbPT.js → fileBytesOpfs-DRUYLER4.js} +4 -5
  64. package/dist/assets/{fileBytesOpfs-DBS0kbPT.js.map → fileBytesOpfs-DRUYLER4.js.map} +1 -1
  65. package/dist/assets/{fixedHosts-CbgqrIKs.js → fixedHosts-CPSsGOI2.js} +4 -5
  66. package/dist/assets/{fixedHosts-CbgqrIKs.js.map → fixedHosts-CPSsGOI2.js.map} +1 -1
  67. package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js → ghostly_iroh_web-DIj5xGmR.js} +2 -3
  68. package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js.map → ghostly_iroh_web-DIj5xGmR.js.map} +1 -1
  69. package/dist/assets/{src-DJe-OYxd.js → groupMeta-DTQAJG50.js} +4693 -24241
  70. package/dist/assets/groupMeta-DTQAJG50.js.map +1 -0
  71. package/dist/assets/{host-C0NMNQLl.js → host-z0FAHP9Z.js} +209 -134
  72. package/dist/assets/host-z0FAHP9Z.js.map +1 -0
  73. package/dist/assets/{hyperdhtRelay-Dz7pvcBA.js → hyperdhtRelay-CvsAfQRQ.js} +5 -6
  74. package/dist/assets/hyperdhtRelay-CvsAfQRQ.js.map +1 -0
  75. package/dist/assets/hyperdhtRelay-bjNGacf5.js +32 -0
  76. package/dist/assets/hyperdhtRelay-bjNGacf5.js.map +1 -0
  77. package/dist/assets/{idb-CEuoNsTv.js → idb-ewvbqyDI.js} +2 -3
  78. package/dist/assets/{idb-CEuoNsTv.js.map → idb-ewvbqyDI.js.map} +1 -1
  79. package/dist/assets/identityProofs-Cksc_K7_.js +940 -0
  80. package/dist/assets/identityProofs-Cksc_K7_.js.map +1 -0
  81. package/dist/assets/{irohWeb-caAj4Dms.js → irohWeb-CLBx5MIv.js} +3061 -86
  82. package/dist/assets/irohWeb-CLBx5MIv.js.map +1 -0
  83. package/dist/assets/joinTrace-CBr1jbch.js +1 -0
  84. package/dist/assets/{joinTrace-CjRDFy85.js → joinTrace-xKBe73j9.js} +2 -3
  85. package/dist/assets/{joinTrace-CjRDFy85.js.map → joinTrace-xKBe73j9.js.map} +1 -1
  86. package/dist/assets/{legacy_ciphers-JJOu0JXL.js → legacy_ciphers-BnYATjxo.js} +2 -3
  87. package/dist/assets/{legacy_ciphers-JJOu0JXL.js.map → legacy_ciphers-BnYATjxo.js.map} +1 -1
  88. package/dist/assets/linkPreview-DdMf-YAc.js +252 -0
  89. package/dist/assets/linkPreview-DdMf-YAc.js.map +1 -0
  90. package/dist/assets/{main-C6t5zrD5.js → main-CVqkvuIo.js} +268 -111
  91. package/dist/assets/main-CVqkvuIo.js.map +1 -0
  92. package/dist/assets/{mainline-DCuGUSZF.js → mainline-CVrd0C1n.js} +72 -18
  93. package/dist/assets/mainline-CVrd0C1n.js.map +1 -0
  94. package/dist/assets/mints-BcBODVVW.js +1 -0
  95. package/dist/assets/{mints-j5XAOk4f.js → mints-CMDLbMeH.js} +8 -6
  96. package/dist/assets/mints-CMDLbMeH.js.map +1 -0
  97. package/dist/assets/{nacl-fast-CDhNCYHs.js → nacl-fast-B1ThWvuM.js} +2 -3
  98. package/dist/assets/{nacl-fast-CDhNCYHs.js.map → nacl-fast-B1ThWvuM.js.map} +1 -1
  99. package/dist/assets/{networkReason-BbQW1Xpc.js → networkReason-Be-hMghr.js} +10 -14
  100. package/dist/assets/{networkReason-BbQW1Xpc.js.map → networkReason-Be-hMghr.js.map} +1 -1
  101. package/dist/assets/{noble_curves-DDWn5AH0.js → noble_curves-DqpNlhAU.js} +3 -4
  102. package/dist/assets/{noble_curves-DDWn5AH0.js.map → noble_curves-DqpNlhAU.js.map} +1 -1
  103. package/dist/assets/{noble_hashes-B7AZyFyS.js → noble_hashes-LFe1N2xt.js} +3 -4
  104. package/dist/assets/{noble_hashes-B7AZyFyS.js.map → noble_hashes-LFe1N2xt.js.map} +1 -1
  105. package/dist/assets/{nwc-CSDRMZ0e.js → nwc-DKE2FXr6.js} +5 -6
  106. package/dist/assets/{nwc-CSDRMZ0e.js.map → nwc-DKE2FXr6.js.map} +1 -1
  107. package/dist/assets/nwcProvider-pL2XqSbW.js +208 -0
  108. package/dist/assets/nwcProvider-pL2XqSbW.js.map +1 -0
  109. package/dist/assets/{openpgp-BBFr-zHQ.js → openpgp-LkR_Zof0.js} +14 -15
  110. package/dist/assets/{openpgp-BBFr-zHQ.js.map → openpgp-LkR_Zof0.js.map} +1 -1
  111. package/dist/assets/ownDid-DY3rYqDI.js +862 -0
  112. package/dist/assets/ownDid-DY3rYqDI.js.map +1 -0
  113. package/dist/assets/{ownStatus-BoTf5WqQ.js → ownStatus-DMEhrpkd.js} +69 -20
  114. package/dist/assets/ownStatus-DMEhrpkd.js.map +1 -0
  115. package/dist/assets/pairedTransports-BKmvlKz1.js +581 -0
  116. package/dist/assets/pairedTransports-BKmvlKz1.js.map +1 -0
  117. package/dist/assets/paymentIntent-DySU3Ajm.js +349 -0
  118. package/dist/assets/paymentIntent-DySU3Ajm.js.map +1 -0
  119. package/dist/assets/pkarr-BQo4PcCg.js +367 -0
  120. package/dist/assets/pkarr-BQo4PcCg.js.map +1 -0
  121. package/dist/assets/{profiles-DszHjEJi.js → profiles-BFSGqDFC.js} +9 -10
  122. package/dist/assets/profiles-BFSGqDFC.js.map +1 -0
  123. package/dist/assets/registry-B15Yg_1C.js +1 -0
  124. package/dist/assets/{registry-Da-r6eC3.js → registry-rXgaZeNn.js} +1261 -53
  125. package/dist/assets/registry-rXgaZeNn.js.map +1 -0
  126. package/dist/assets/relay-Cjfmdec0.js +2219 -0
  127. package/dist/assets/relay-Cjfmdec0.js.map +1 -0
  128. package/dist/assets/resolve-CIc3KZMV.js +970 -0
  129. package/dist/assets/resolve-CIc3KZMV.js.map +1 -0
  130. package/dist/assets/{restoredRows-C3LcxmOw.js → restoredRows-D_WSHE7H.js} +3 -4
  131. package/dist/assets/{restoredRows-C3LcxmOw.js.map → restoredRows-D_WSHE7H.js.map} +1 -1
  132. package/dist/assets/{secretGuard-CsVHDdYk.js → secretGuard-B4-LlMjv.js} +11 -14
  133. package/dist/assets/{secretGuard-CsVHDdYk.js.map → secretGuard-B4-LlMjv.js.map} +1 -1
  134. package/dist/assets/secretGuard-BmmnEbYf.js +1 -0
  135. package/dist/assets/{server-C1jZZ61O.js → server-CQR7NLCz.js} +9565 -461
  136. package/dist/assets/server-CQR7NLCz.js.map +1 -0
  137. package/dist/assets/{sha512-BYId-G-T.js → sha512-DST9fbWH.js} +2 -3
  138. package/dist/assets/{sha512-BYId-G-T.js.map → sha512-DST9fbWH.js.map} +1 -1
  139. package/dist/assets/sshForges-BnvwmNj-.js +539 -0
  140. package/dist/assets/sshForges-BnvwmNj-.js.map +1 -0
  141. package/dist/assets/{storage-Bya5b2Xt.js → storage-BpjdxvO2.js} +243 -34
  142. package/dist/assets/storage-BpjdxvO2.js.map +1 -0
  143. package/dist/assets/text-li76pThX.js +106 -0
  144. package/dist/assets/text-li76pThX.js.map +1 -0
  145. package/dist/assets/{translate-CUuC5szR.js → translate-BcbSWkuq.js} +21 -26
  146. package/dist/assets/{translate-CUuC5szR.js.map → translate-BcbSWkuq.js.map} +1 -1
  147. package/dist/assets/{tree-store-N362nuzZ.js → tree-store-CAchkO_l.js} +22 -6
  148. package/dist/assets/tree-store-CAchkO_l.js.map +1 -0
  149. package/dist/assets/{types-Clyb52K2.js → types-CdWwgvyt.js} +2 -3
  150. package/dist/assets/{types-Clyb52K2.js.map → types-CdWwgvyt.js.map} +1 -1
  151. package/dist/assets/{unbzip2-stream-B1C-JX9L.js → unbzip2-stream-BtkYGpC5.js} +2 -3
  152. package/dist/assets/{unbzip2-stream-B1C-JX9L.js.map → unbzip2-stream-BtkYGpC5.js.map} +1 -1
  153. package/dist/assets/{usdt-DI51znt-.js → usdt-CBJ4Q5Ji.js} +7 -7
  154. package/dist/assets/usdt-CBJ4Q5Ji.js.map +1 -0
  155. package/dist/assets/{waitNotice-Cn0WJ-He.js → waitNotice-BGM0QOS2.js} +27 -4
  156. package/dist/assets/waitNotice-BGM0QOS2.js.map +1 -0
  157. package/dist/assets/{web-DwgdhfcY.js → web-68CYFCl9.js} +314 -91
  158. package/dist/assets/web-68CYFCl9.js.map +1 -0
  159. package/dist/ghostly.mjs +3 -5
  160. package/dist/ghostly.mjs.map +1 -1
  161. package/npm-shrinkwrap.json +225 -200
  162. package/package.json +16 -16
  163. package/dist/assets/api-MYc6QNRs.js.map +0 -1
  164. package/dist/assets/apiKit-CfsNx9ZR.js.map +0 -1
  165. package/dist/assets/appFetch-DVYZOZFw.js +0 -194
  166. package/dist/assets/appFetch-DVYZOZFw.js.map +0 -1
  167. package/dist/assets/apps-Dbw2Hcko.js +0 -2
  168. package/dist/assets/apps-h12II1us.js.map +0 -1
  169. package/dist/assets/arkade-Bw_4PZRG.js.map +0 -1
  170. package/dist/assets/backup-CdEzTq5C.js +0 -2
  171. package/dist/assets/backup-Chvy79SN.js.map +0 -1
  172. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js +0 -6
  173. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +0 -1
  174. package/dist/assets/bitcoindProvider-BvoRh0D5.js +0 -97
  175. package/dist/assets/bitcoindProvider-BvoRh0D5.js.map +0 -1
  176. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js +0 -6
  177. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +0 -1
  178. package/dist/assets/bitcoindevkit_bg-CRkZTSbO.wasm +0 -0
  179. package/dist/assets/buttons-BgoExb4E.js.map +0 -1
  180. package/dist/assets/buttons-DK2aAGat.js +0 -2
  181. package/dist/assets/endpoint-DarqblYE.js.map +0 -1
  182. package/dist/assets/errors-CAh6GLJZ.js.map +0 -1
  183. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js +0 -6
  184. package/dist/assets/fileBytes-BLPZq9YU.js.map +0 -1
  185. package/dist/assets/fileBytes-BtIyoDF2.js +0 -2
  186. package/dist/assets/fileBytesIdb-D8mAK4pF.js +0 -2
  187. package/dist/assets/host-C0NMNQLl.js.map +0 -1
  188. package/dist/assets/hyperdhtRelay-1wzya_0L.js +0 -25
  189. package/dist/assets/hyperdhtRelay-1wzya_0L.js.map +0 -1
  190. package/dist/assets/hyperdhtRelay-Dz7pvcBA.js.map +0 -1
  191. package/dist/assets/irohWeb-caAj4Dms.js.map +0 -1
  192. package/dist/assets/joinTrace-D-fnt2p3.js +0 -2
  193. package/dist/assets/jsonOut-POtMBS_V.js +0 -16
  194. package/dist/assets/jsonOut-POtMBS_V.js.map +0 -1
  195. package/dist/assets/main-C6t5zrD5.js.map +0 -1
  196. package/dist/assets/mainline-DCuGUSZF.js.map +0 -1
  197. package/dist/assets/mints-BaOmx517.js +0 -2
  198. package/dist/assets/mints-j5XAOk4f.js.map +0 -1
  199. package/dist/assets/nwcProvider-PE0wli8n.js +0 -88
  200. package/dist/assets/nwcProvider-PE0wli8n.js.map +0 -1
  201. package/dist/assets/ownDid-C1R5Kd8q.js +0 -282
  202. package/dist/assets/ownDid-C1R5Kd8q.js.map +0 -1
  203. package/dist/assets/ownStatus-BoTf5WqQ.js.map +0 -1
  204. package/dist/assets/profiles-DszHjEJi.js.map +0 -1
  205. package/dist/assets/registry-Da-r6eC3.js.map +0 -1
  206. package/dist/assets/registry-zUZBSHYv.js +0 -2
  207. package/dist/assets/resolve-tUzh4lHh.js +0 -400
  208. package/dist/assets/resolve-tUzh4lHh.js.map +0 -1
  209. package/dist/assets/secretGuard-DCb1I0_B.js +0 -2
  210. package/dist/assets/server-C1jZZ61O.js.map +0 -1
  211. package/dist/assets/src-DJe-OYxd.js.map +0 -1
  212. package/dist/assets/sshForges-C9zTO72R.js +0 -261
  213. package/dist/assets/sshForges-C9zTO72R.js.map +0 -1
  214. package/dist/assets/storage-Bya5b2Xt.js.map +0 -1
  215. package/dist/assets/tree-store-N362nuzZ.js.map +0 -1
  216. package/dist/assets/usdt-DI51znt-.js.map +0 -1
  217. package/dist/assets/waitNotice-Cn0WJ-He.js.map +0 -1
  218. package/dist/assets/web-DwgdhfcY.js.map +0 -1
@@ -1,19 +1,24 @@
1
- import { $i as identityStatement, Cd as randomBytes$1, Ga as VOICE_LIMITS, Go as MESSAGE_CLOCK_SKEW_MS, Ha as sanitizeFileName, Hl as isAppRef, Il as appRef, Io as appCardId, Ja as downsamplePeaks, Ju as normalizeRelayUrl, Ka as VOICE_METER, Kn as withoutVideoMetadata, Lo as appCardUrl, Ol as isAppUrl, Po as STATUS_CARD_LIMITS, Qa as voiceLevel, Ss as parseLocalTarget, To as replySnippet, Ua as sanitizeMime, Un as withoutAudioMetadata, Uo as statusCardBytes, Vo as checkStatusCard, Wa as PLAYABLE_AUDIO, Xa as parseVoiceMeta, Xl as readImageMeta, Xn as stripPictureMetadata, Yu as relayUrlProblem, Za as voiceDownloadName, Zn as withoutPictureMetadata, ai as TYPING_KINDS, bs as GhostlyHttpError, ci as sanitizeTypingStatus, fs as AWAITING_PEER_MS, fu as ownInviteRefusal, hd as sanitizeAvatar, ji as APP_DATA_MAX_BYTES, lr as GROUP_FILE_LIMITS, md as MAX_AVATAR_LENGTH, oi as TYPING_REFRESH_MS, pn as parsePaymentAmount, qa as baseMime, qn as NO_PICTURE_METADATA, qo as claimedTime, uu as inviteLink, wd as toBase64Url, ws as LIMITS, zo as cardLine } from "./src-DJe-OYxd.js";
2
- import { p as fileStore } from "./idb-CEuoNsTv.js";
3
- import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-BLPZq9YU.js";
4
- import { B as removeStored, U as waitingGroupFile, W as IDENTITY_DRAFT_TTL_MS, 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, s as groupPayNoteId, t as DEFAULT_IROH_RELAYS } from "./irohWeb-caAj4Dms.js";
5
- import { s as isAppFetchUrl } from "./appFetch-DVYZOZFw.js";
6
- import { i as parseProofBunker, t as IDENTITY_PROVIDERS } from "./registry-Da-r6eC3.js";
7
- import { n as secretWords, r as findSecret, t as guardText } from "./secretGuard-CsVHDdYk.js";
8
- import { i as localFileError, r as asCliError, t as CliError } from "./errors-CAh6GLJZ.js";
9
- 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-BoTf5WqQ.js";
10
- import { A as settingsOf, D as oneShotWaits, E as oneOf, F as state, I as str, L as transportOffered, M as sinceSeq, N as somebodyJoined, O as ownChatOf, R as waitForState, S as nobodyJoined, T as num, _ as messageOf, a as contactKeyOf, b as noFile, c as findChatOrGroup, d as groupNameOf, f as groupOf, g as list, h as keptForJoin, j as shownName, k as sentAt, l as findGroup, m as inviteTaken, n as chatOf, o as dhtOnly, p as groupPrefixed, r as chatOrGroup, s as findChat, t as bool, w as node, x as noMessage } from "./apiKit-CfsNx9ZR.js";
11
- import { t as childEnv } from "./childEnv-K_IzUqQx.js";
12
- import { t as chatState } from "./waitNotice-Cn0WJ-He.js";
13
- import { a as checkTextSize$1, c as waitForConfirmed, d as waitForMessage, f as waitForRemoval, i as pressable, l as waitForEdit, n as buttonsCard, o as goesOn, s as nobodyElseIn, t as BUTTON_METHODS, u as waitForGroupFrame } from "./buttons-BgoExb4E.js";
14
- import { a as checkShownName } from "./profiles-DszHjEJi.js";
15
- import { t as BACKUP_METHODS } from "./backup-Chvy79SN.js";
16
- import { o as checkedBundle } from "./apps-h12II1us.js";
1
+ import { Aa as appRef, At as sanitizeTypingStatus, 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, Ia as isAppRef, Ja as readImageMeta, Mn as voiceDownloadName, Nn as voiceLevel, On as baseMime, Sa as isAppUrl, Sr as cardLine, Tn as PLAYABLE_AUDIO, gr as STATUS_CARD_LIMITS, io as inviteLink, ji as LIMITS, jn as parseVoiceMeta, jr as claimedTime, ki as parseLocalTarget, kn as downsamplePeaks, kr as MESSAGE_CLOCK_SKEW_MS, n as groupCallSfu, oo as ownInviteRefusal, or as replySnippet, 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-DTQAJG50.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-CLBx5MIv.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-B4-LlMjv.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-DMEhrpkd.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-CVaEzKWQ.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 outOf, d as waitForEdit, f as waitForGroupFrame, i as pressable, l as purgeMessage, m as waitForRemoval, n as buttonsCard, o as goesOn, p as waitForMessage, s as nobodyElseIn, t as BUTTON_METHODS, u as waitForConfirmed } from "./buttons-BvWqHJeh.js";
13
+ import { a as checkShownName } from "./profiles-BFSGqDFC.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 { i as parseProofBunker, t as IDENTITY_PROVIDERS } from "./registry-rXgaZeNn.js";
17
+ import { t as BACKUP_METHODS } from "./backup-DpyvT9Z6.js";
18
+ import { s as isAppFetchUrl } from "./appFetch-D56GsYuq.js";
19
+ import { o as checkedBundle } from "./apps-XnZ8VEuj.js";
20
+ import { m as parsePaymentAmount } from "./paymentIntent-DySU3Ajm.js";
21
+ import { t as chatState } from "./waitNotice-BGM0QOS2.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
- //#region src/typing.ts
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
- //#endregion
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
- /** As `streamBytes`, reading the file only as far as its decoder goes; a kind left to ffmpeg is not read past its head. */
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
- /** As `streamWav`, reading the file a piece of frames at a time until the sink wants no more. */
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
- reject(/* @__PURE__ */ new Error(error.code === "ENOENT" ? "no decoder here for this kind of audio (install ffmpeg to read it)" : `ffmpeg: ${error.message}`));
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
- //#endregion
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
- function mimeOf(path, given) {
730
- return sanitizeMime(given ?? TYPES[extname(path).toLowerCase()] ?? "application/octet-stream");
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, m4a or wav)`);
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 whileUnchanged(path, () => bytes.stage(fileId, source));
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 whileUnchanged(path, () => bytes.stage(file.id, source));
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,
@@ -1330,23 +1362,32 @@ var FILE_METHODS = {
1330
1362
  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
1363
  const force = bool(params, "force");
1332
1364
  const path = str(params, "path");
1333
- if (path && (path.endsWith("/") || path.endsWith(sep)) && !(await stat(named).catch(() => void 0))?.isDirectory()) throw new CliError("bad_request", `${path} names a folder: name a file, or use --dir ${named} (dir over the socket)`);
1365
+ if (path && (path.endsWith("/") || path.endsWith(sep))) {
1366
+ const there = await stat(named).catch(() => void 0);
1367
+ if (!there) throw new CliError("not_found", `No such folder: ${named} (make it first, or name a file in a folder that is there)`);
1368
+ if (!there.isDirectory()) throw new CliError("not_found", `${named} is a file, not a folder: name a file in a folder that is there`);
1369
+ }
1334
1370
  const free = !force && !str(params, "path") && !!stored.metadata.voice;
1335
1371
  const ext = extname(named), stem = named.slice(0, named.length - ext.length);
1372
+ let next = 2;
1336
1373
  const taken = async (target, code) => {
1337
1374
  const there = await stat(target).catch(() => void 0);
1338
- if (there?.isDirectory()) return new CliError("bad_request", `${target} is a folder: name a file, or use --dir ${target} (dir over the socket)`);
1375
+ if (there?.isDirectory() && free && next <= 1e3) return new CliError("confirm", `${target} is a folder`);
1376
+ 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
1377
  if (!(there && !force || code === "EEXIST")) return;
1340
1378
  const replace = `${target} exists: pass --force (force: true over the socket) to replace it`;
1341
1379
  if (path) return new CliError("confirm", replace);
1380
+ if (free && next <= 1e3) return new CliError("confirm", replace);
1342
1381
  let n = 2;
1343
1382
  while (n <= 1e3 && await stat(`${stem} (${n})${ext}`).catch(() => void 0)) n += 1;
1344
- return new CliError("confirm", `${replace}, or --path ${stem} (${n})${ext} (path over the socket) to keep both`);
1383
+ const other = `${stem} (${n})${ext}`;
1384
+ return new CliError("confirm", `${replace}, or --path ${shellWord(other, "<the one in details.path>")} (path over the socket) to keep both`, { path: other });
1345
1385
  };
1346
1386
  let target = named;
1347
- for (let n = 2, refused = await taken(target); refused; n += 1, refused = await taken(target)) {
1348
- if (!free || refused.code !== "confirm" || n > 1e3) throw refused;
1349
- target = `${stem} (${n})${ext}`;
1387
+ for (let refused = await taken(target); refused; refused = await taken(target)) {
1388
+ if (!free || refused.code !== "confirm" || next > 1e3) throw refused;
1389
+ target = `${stem} (${next})${ext}`;
1390
+ next += 1;
1350
1391
  }
1351
1392
  const partial = join(dirname(target), `.ghostly-save-${process.pid}-${toBase64Url(randomBytes$1(6))}.partial`);
1352
1393
  const asked = (error, where) => {
@@ -1387,14 +1428,15 @@ var FILE_METHODS = {
1387
1428
  } else throw new CliError("not_found", "The file's bytes are not on this device");
1388
1429
  await out.close();
1389
1430
  out = null;
1390
- for (let n = 2; !complete; n += 1) try {
1431
+ while (!complete) try {
1391
1432
  await place(partial, target, force);
1392
1433
  complete = true;
1393
1434
  } catch (error) {
1394
1435
  const code = error.code;
1395
1436
  const refused = code === "EEXIST" || code === "EISDIR" || code === "ENOTEMPTY" ? await taken(target, code) : void 0;
1396
- if (free && refused?.code === "confirm" && n <= 1e3) {
1397
- target = `${stem} (${n})${ext}`;
1437
+ if (free && refused?.code === "confirm" && next <= 1e3) {
1438
+ target = `${stem} (${next})${ext}`;
1439
+ next += 1;
1398
1440
  continue;
1399
1441
  }
1400
1442
  throw refused ?? error;
@@ -1415,8 +1457,7 @@ var FILE_METHODS = {
1415
1457
  };
1416
1458
  }
1417
1459
  };
1418
- //#endregion
1419
- //#region src/statusCards.ts
1460
+ // src/statusCards.ts
1420
1461
  /** A card's updates go at most this often: the rest merge into the next, so a chatty bot spends few edits. */
1421
1462
  var CARD_UPDATE_GAP_MS = 2500;
1422
1463
  var paces = /* @__PURE__ */ new WeakMap();
@@ -1876,8 +1917,7 @@ var STATUS_CARD_METHODS = {
1876
1917
  /** 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
1918
  "usage.send": sendUsage
1878
1919
  };
1879
- //#endregion
1880
- //#region src/holds.ts
1920
+ // src/holds.ts
1881
1921
  /**
1882
1922
  * `chat disconnect --hold <minutes>`: a chat kept off its direct link for a while. It is the chat's own "DHT only"
1883
1923
  * choice (WISP 400: either side choosing it keeps both off the live link, so the contact's app does not redial),
@@ -2062,8 +2102,7 @@ function resumeHolds(ctx) {
2062
2102
  if (gone.length) writeHolds(ctx, holds);
2063
2103
  for (const [linkId, hold] of Object.entries(holds)) schedule(ctx, linkId, hold.until);
2064
2104
  }
2065
- //#endregion
2066
- //#region src/views.ts
2105
+ // src/views.ts
2067
2106
  /**
2068
2107
  * A live session carries the chat now, in this run: its link is open and, on a paired chat, the session authenticated
2069
2108
  * on a transport. The engine's own rule for a chat's connection line (`observeTransport`). `textDelivery` alone says
@@ -2342,11 +2381,14 @@ function groupJson(group, showSecret = false) {
2342
2381
  }) } : {},
2343
2382
  community: group.community ?? null,
2344
2383
  picture: !!group.picture,
2384
+ call: group.call ? {
2385
+ sfu: group.call.sfu,
2386
+ e2ee: group.call.e2ee === 1
2387
+ } : null,
2345
2388
  pin: pinJson(group.pin)
2346
2389
  };
2347
2390
  }
2348
- //#endregion
2349
- //#region src/groupAdmin.ts
2391
+ // src/groupAdmin.ts
2350
2392
  /**
2351
2393
  * Group administration and pictures (WISP 1100, phase 3): what the app's group menu and profile screen do. The
2352
2394
  * engine enforces who may do what (the admin); these check the arguments and name members.
@@ -2414,10 +2456,25 @@ async function pictureFrom(path) {
2414
2456
  return checked;
2415
2457
  }
2416
2458
  async function picture(params) {
2459
+ if (bool(params, "clear") && str(params, "path") !== void 0) throw new CliError("bad_request", "clear removes the picture: not with path");
2417
2460
  if (bool(params, "clear")) return null;
2418
2461
  return pictureFrom(str(params, "path", true));
2419
2462
  }
2420
2463
  /**
2464
+ * The node a group's calls go through (WISP 602): an https origin in its one spelling, refused here before anything is
2465
+ * signed. A URL that names an https origin in another spelling (a path, a trailing `/`, capitals) is told that origin.
2466
+ */
2467
+ function callNode(raw, ref, groupId) {
2468
+ const sfu = groupCallSfu(raw);
2469
+ if (sfu) return sfu;
2470
+ let origin;
2471
+ try {
2472
+ const url = new URL(raw);
2473
+ if (url.protocol === "https:" && url.origin.length <= 200) origin = url.origin;
2474
+ } catch {}
2475
+ throw new CliError("bad_request", origin ? `${JSON.stringify(raw)} is not an origin (no path, query or trailing /): ghostly group call ${shellWord(ref, groupId)} --sfu ${origin}` : `${JSON.stringify(raw)} is not an https origin: a call node is like https://call.example.com`);
2476
+ }
2477
+ /**
2421
2478
  * A group this profile administers or is in, not only an invitation: before, the engine answered `group rename`,
2422
2479
  * `picture`, `link`, `rotate` and `invite` on an invitation not yet joined with "Group not found" (engine, exit 1),
2423
2480
  * while `group show` listed it, and `remove`/`admin` said "No member" of a member list it had not received yet.
@@ -2425,12 +2482,21 @@ async function picture(params) {
2425
2482
  function joined(ctx, params, twin) {
2426
2483
  const group = groupOf(ctx, params, twin);
2427
2484
  if (group.status || !group.invitation) return group;
2428
- const ref = str(params, "group", true), shown = /^[\w.:-]+$/.test(ref) ? ref : JSON.stringify(ref);
2485
+ const shown = shellWord(str(params, "group", true), group.id);
2429
2486
  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
2487
  }
2431
2488
  /** The member `params.member` names in `group`, this profile's own name said to be it; by its key only for a grant. */
2432
2489
  var member = (ctx, group, params, grant = false) => findMember(group, str(params, "member", true), settingsOf(ctx).nick, grant);
2433
- var view = (ctx, id, params) => groupJson(state(ctx).groups.find((g) => g.id === id) ?? groupOf(ctx, { group: id }), bool(params, "showSecret"));
2490
+ /**
2491
+ * A group's link and the address that opens it in the app, as `invite create` answers `invite` and `link`. Only the
2492
+ * 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.
2493
+ */
2494
+ var withUrl = (group, link) => ({
2495
+ group,
2496
+ link,
2497
+ ...link && { url: `https://app.ghostly.tools/#/join/${link}` }
2498
+ });
2499
+ var view = (ctx, id, params) => groupJson(groupOf(ctx, { group: id }), bool(params, "showSecret"));
2434
2500
  var GROUP_ADMIN_METHODS = {
2435
2501
  async "group.invite"(ctx, params) {
2436
2502
  const group = joined(ctx, params);
@@ -2448,7 +2514,7 @@ var GROUP_ADMIN_METHODS = {
2448
2514
  groupId: group.id,
2449
2515
  key: removed.key
2450
2516
  });
2451
- const linkOn = !!(state(ctx).groups.find((g) => g.id === group.id) ?? group).entryLink;
2517
+ const linkOn = !!(groupById(ctx, group.id) ?? group).entryLink;
2452
2518
  return {
2453
2519
  ...view(ctx, group.id, params),
2454
2520
  ...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 +2560,8 @@ var GROUP_ADMIN_METHODS = {
2494
2560
  },
2495
2561
  async "group.link"(ctx, params) {
2496
2562
  const group = joined(ctx, params);
2563
+ const out = outOf(group);
2564
+ if (out) throw new CliError("refused", out);
2497
2565
  const on = params.on === void 0 || bool(params, "on"), reset = bool(params, "reset");
2498
2566
  if (!on && reset) throw new CliError("bad_request", "on: false turns the link off: not with reset");
2499
2567
  if (!on) {
@@ -2507,10 +2575,7 @@ var GROUP_ADMIN_METHODS = {
2507
2575
  groupId: group.id,
2508
2576
  ...reset ? { reset: true } : {}
2509
2577
  });
2510
- return {
2511
- group: group.id,
2512
- link
2513
- };
2578
+ return withUrl(group.id, link);
2514
2579
  },
2515
2580
  async "group.picture"(ctx, params) {
2516
2581
  const group = joined(ctx, params);
@@ -2523,14 +2588,35 @@ var GROUP_ADMIN_METHODS = {
2523
2588
  picture: !bool(params, "clear")
2524
2589
  };
2525
2590
  },
2591
+ async "group.call"(ctx, params) {
2592
+ const group = joined(ctx, params);
2593
+ if (group.profile !== "community") throw new CliError("refused", `${group.name} is a private group: only a community group has calls through a node`);
2594
+ const out = outOf(group);
2595
+ if (out) throw new CliError("refused", out);
2596
+ if (!group.isAdmin) throw new CliError("refused", `Only the admin of ${group.name} sets its call node`);
2597
+ const ref = str(params, "group", true), raw = str(params, "sfu");
2598
+ const e2ee = params.e2ee === void 0 || params.e2ee === null ? void 0 : bool(params, "e2ee");
2599
+ let sfu;
2600
+ if (bool(params, "clear") && raw !== void 0) throw new CliError("bad_request", "clear removes the call node: not with sfu");
2601
+ if (bool(params, "clear") && e2ee !== void 0) throw new CliError("bad_request", "clear removes the call node: not with e2ee");
2602
+ if (bool(params, "clear")) sfu = null;
2603
+ else if (raw !== void 0 || e2ee === void 0) sfu = callNode(str(params, "sfu", true), ref, group.id);
2604
+ else if (group.call) sfu = group.call.sfu;
2605
+ else throw new CliError("refused", `${group.name} has no call node: ghostly group call ${shellWord(ref, group.id)} --sfu <https origin>${e2ee ? " --e2ee" : ""}`);
2606
+ await node(ctx).setGroupCall({
2607
+ groupId: group.id,
2608
+ sfu,
2609
+ ...sfu !== null && e2ee !== void 0 && { e2ee }
2610
+ });
2611
+ return view(ctx, group.id, params);
2612
+ },
2526
2613
  async "profile.picture"(ctx, params) {
2527
2614
  const avatar = await picture(params);
2528
2615
  await node(ctx).updateSettings({ settings: { avatar: avatar ?? "" } });
2529
2616
  return { picture: avatar !== null };
2530
2617
  }
2531
2618
  };
2532
- //#endregion
2533
- //#region src/identities.ts
2619
+ // src/identities.ts
2534
2620
  /**
2535
2621
  * Drafts per daemon: a proof made in two steps needs the same process for both. Kept as long as the engine keeps them,
2536
2622
  * and the oldest dropped when a fifth begins as the engine drops it, so what `identity add` promises still completes.
@@ -2853,8 +2939,7 @@ var IDENTITY_METHODS = {
2853
2939
  return IDENTITY_METHODS["identity.contact"](ctx, { chat: link.id });
2854
2940
  }
2855
2941
  };
2856
- //#endregion
2857
- //#region src/x401.ts
2942
+ // src/x401.ts
2858
2943
  /**
2859
2944
  * x401 credentials (WISP 3xx): the holder keys and issued credentials a bot keeps to show a website who stands behind
2860
2945
  * it. Here only keeping them: `x401 fetch`, which presents one, comes later. Claim values are printed only with
@@ -2894,8 +2979,7 @@ var X401_METHODS = {
2894
2979
  return { removed: id };
2895
2980
  }
2896
2981
  };
2897
- //#endregion
2898
- //#region src/services.ts
2982
+ // src/services.ts
2899
2983
  /**
2900
2984
  * 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
2985
  * link, and a contact's app opened here on a loopback port. As on the Desktop: only loopback is reached, redirects are
@@ -3156,6 +3240,18 @@ function serviceOf(ctx, params) {
3156
3240
  return serviceId;
3157
3241
  }
3158
3242
  /**
3243
+ * On, unless `off`; or as the answer's own key (`shared`, `enabled`) says, when a socket client sends it back. Before,
3244
+ * only `off` was read, so `{"shared": false}` shared the service with the contact and `{"enabled": false}` turned it on.
3245
+ * Both, saying the opposite, are refused: neither is guessed.
3246
+ */
3247
+ function onUnlessOff(params, key) {
3248
+ const on = !bool(params, "off");
3249
+ if (params[key] === void 0 || params[key] === null) return on;
3250
+ const said = bool(params, key);
3251
+ 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`);
3252
+ return said;
3253
+ }
3254
+ /**
3159
3255
  * 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
3256
  * `engine`, and one not allowed read as a file (`localFileError`): "Not allowed to write or read the path".
3161
3257
  */
@@ -3220,19 +3316,20 @@ var SERVICE_METHODS = {
3220
3316
  return { removed: serviceId };
3221
3317
  },
3222
3318
  async "service.enable"(ctx, params) {
3319
+ const enabled = onUnlessOff(params, "enabled");
3223
3320
  const serviceId = serviceOf(ctx, params);
3224
3321
  await node(ctx).setServiceEnabled({
3225
3322
  serviceId,
3226
- enabled: !bool(params, "off")
3323
+ enabled
3227
3324
  });
3228
3325
  return {
3229
3326
  service: serviceId,
3230
- enabled: !bool(params, "off")
3327
+ enabled
3231
3328
  };
3232
3329
  },
3233
3330
  async "service.share"(ctx, params) {
3234
3331
  const link = ownChatOf(ctx, params);
3235
- const shared = !bool(params, "off");
3332
+ const shared = onUnlessOff(params, "shared");
3236
3333
  const serviceId = serviceOf(ctx, params);
3237
3334
  await node(ctx).setServiceShared({
3238
3335
  serviceId,
@@ -3326,8 +3423,7 @@ async function closeServicesOf(ctx, peer) {
3326
3423
  if (entry) await closeOpened(entry);
3327
3424
  }));
3328
3425
  }
3329
- //#endregion
3330
- //#region src/calls/api.ts
3426
+ // src/calls/api.ts
3331
3427
  /** Voice calls (WISP 1100 § Calls): the API methods. The audio itself goes over each call's own socket. */
3332
3428
  var CALL_METHODS = {
3333
3429
  async "call.start"(ctx, params) {
@@ -3362,8 +3458,7 @@ var CALL_METHODS = {
3362
3458
  }) };
3363
3459
  }
3364
3460
  };
3365
- //#endregion
3366
- //#region src/appServe.ts
3461
+ // src/appServe.ts
3367
3462
  /** The permissions a bot can be granted: `internet` and `files` are a page's, and no page runs here. */
3368
3463
  var GRANTABLE = ["chat", "name"];
3369
3464
  var servedFile = (dir) => join(dir, "apps.json");
@@ -3469,6 +3564,7 @@ var APP_SERVE_METHODS = {
3469
3564
  const app = servedApp(apps, ref);
3470
3565
  const next = apps.filter((a) => a !== app);
3471
3566
  writeServed(ctx.runtime.paths.dir, next);
3567
+ if (ctx.mode === "daemon") node(ctx).appsCloseOf(app.ref);
3472
3568
  return {
3473
3569
  unserved: app.ref,
3474
3570
  apps: next.length,
@@ -3476,8 +3572,7 @@ var APP_SERVE_METHODS = {
3476
3572
  };
3477
3573
  }
3478
3574
  };
3479
- //#endregion
3480
- //#region src/appEvents.ts
3575
+ // src/appEvents.ts
3481
3576
  /** Per hub: what the contacts have open now, `<chat> <reference>` to the version they said. */
3482
3577
  var peers = /* @__PURE__ */ new WeakMap();
3483
3578
  /** The version of a served app the contact has open in a chat on this session, or undefined. */
@@ -3488,9 +3583,8 @@ function reportAppFrames(hub, node, profileDir) {
3488
3583
  const open = /* @__PURE__ */ new Map();
3489
3584
  peers.set(hub, open);
3490
3585
  /**
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); and the version of each served app's
3493
- * last open since.
3586
+ * Per chat: chat app id to reference, of the apps served when they were learned there; and the list's stamp then
3587
+ * (undefined when an id could not be derived, so the next open tries again).
3494
3588
  */
3495
3589
  const known = /* @__PURE__ */ new Map();
3496
3590
  let count = 0;
@@ -3507,29 +3601,25 @@ function reportAppFrames(hub, node, profileDir) {
3507
3601
  }
3508
3602
  const learnt = {
3509
3603
  ids,
3510
- stamp,
3511
- versions: /* @__PURE__ */ new Map()
3604
+ stamp
3512
3605
  };
3513
3606
  known.set(chat, learnt);
3514
3607
  return learnt;
3515
3608
  };
3516
3609
  /**
3517
- * An open learns the served list again only when it changed since (a stat, no read), or names another version of a
3518
- * served app than its last open did: an app served or unserved since is taken or left from its next open, and a
3519
- * contact repeating opens (up to 50 a second for each of 16 apps) costs no read of the list nor derivation of ids.
3610
+ * An open learns the served list again only when it changed since (a stat, no read): an app served or unserved since
3611
+ * 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
3612
+ * version or alternating two, costs no read of the list nor derivation of ids, which do not depend on the version.
3520
3613
  */
3521
3614
  const current = (chat, frame) => {
3522
3615
  const learnt = known.get(chat);
3523
3616
  if (!learnt) return learn(chat);
3524
3617
  if (!("o" in frame) || frame.o !== "open") return learnt;
3525
- const was = learnt.versions.get(frame.app);
3526
- return learnt.stamp === void 0 || learnt.stamp !== servedStamp(profileDir) || was !== void 0 && was !== frame.v ? learn(chat) : learnt;
3618
+ return learnt.stamp === void 0 || learnt.stamp !== servedStamp(profileDir) ? learn(chat) : learnt;
3527
3619
  };
3528
3620
  return hub.onAppFrame((chat, frame) => {
3529
- const learnt = current(chat, frame);
3530
- const app = learnt.ids.get(frame.app);
3621
+ const app = current(chat, frame).ids.get(frame.app);
3531
3622
  if (!app) return;
3532
- if ("o" in frame && frame.o === "open") learnt.versions.set(frame.app, frame.v);
3533
3623
  const id = `${chat}:${app}:${Date.now()}-${++count}`;
3534
3624
  if ("o" in frame) {
3535
3625
  if (frame.o === "open") open.set(`${chat} ${app}`, frame.v);
@@ -3552,8 +3642,7 @@ function reportAppFrames(hub, node, profileDir) {
3552
3642
  });
3553
3643
  });
3554
3644
  }
3555
- //#endregion
3556
- //#region src/appChat.ts
3645
+ // src/appChat.ts
3557
3646
  /** The chat and the served app a command names, on an engine that speaks apps/1. */
3558
3647
  function target(ctx, params) {
3559
3648
  const app = servedApp(servedApps(ctx.runtime.paths.dir), str(params, "ref", true));
@@ -3671,8 +3760,7 @@ var NOT_SENT = {
3671
3760
  message: `More than 48 frames in a second, or the connection is still sending earlier ones: slow down and send it again`
3672
3761
  }
3673
3762
  };
3674
- //#endregion
3675
- //#region src/wallets.ts
3763
+ // src/wallets.ts
3676
3764
  /**
3677
3765
  * Wallets and payments (WISP 1100, phase 2): the app's wallet deck and a chat's payment sheet, as methods. Test
3678
3766
  * networks move nothing real. On Mainnet every spend passes `confirmedReal`, which the engine requires, only when the
@@ -3722,12 +3810,20 @@ function lightningCard(ctx, params) {
3722
3810
  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
3811
  }
3724
3812
  /**
3813
+ * The card a payment, a request or a wallet command names. "" (an unset variable in a script: `--card "$CARD"`) is a
3814
+ * usage error: taken as not given, it moved money through, or removed, the network's default card or the whole wallet.
3815
+ */
3816
+ function cardParam(params) {
3817
+ if (params.card === "") throw new CliError("usage", "--card needs a Lightning card id (ghostly wallet list)");
3818
+ return str(params, "card");
3819
+ }
3820
+ /**
3725
3821
  * The Lightning card `card` names, checked before the engine is asked: given with another type of wallet it is a usage
3726
3822
  * error, and one not on the network is not_found. Before, the engine dropped it for every type but Lightning, so a card
3727
3823
  * that named nothing removed the whole wallet of that type and the answer echoed the card as removed.
3728
3824
  */
3729
3825
  function cardOf(ctx, params, type) {
3730
- const card = str(params, "card");
3826
+ const card = cardParam(params);
3731
3827
  if (card === void 0) return void 0;
3732
3828
  if (type !== "lightning") throw new CliError("usage", `--card names a Lightning card: not with ${type}`);
3733
3829
  lightningCard(ctx, params);
@@ -3932,7 +4028,7 @@ var engineCode = (error) => error instanceof Error ? error.engineCode : void 0;
3932
4028
  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
4029
  function walletRefusal(error) {
3934
4030
  if (!(error instanceof Error) || error instanceof CliError) return error;
3935
- if (error.name === "SwapUnsettledError") return new CliError("unavailable", error.message);
4031
+ if (error.name === "SwapUnsettledError" || error.unsettled === true) return new CliError("unavailable", error.message);
3936
4032
  const code = WALLET_REFUSALS.find(([pattern]) => pattern.test(error.message))?.[1];
3937
4033
  return code ? new CliError(code, error.message) : error;
3938
4034
  }
@@ -4033,7 +4129,10 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4033
4129
  await federationsOpen(ctx);
4034
4130
  return {
4035
4131
  network: n,
4036
- history: (netView(state(ctx), n)?.history ?? []).slice(0, limit)
4132
+ history: await node(ctx).walletHistory({
4133
+ network: n,
4134
+ limit
4135
+ })
4037
4136
  };
4038
4137
  },
4039
4138
  async "wallet.receive"(ctx, params) {
@@ -4116,7 +4215,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4116
4215
  async "pay"(ctx, params) {
4117
4216
  const comment = memoOf(params, "pay", "comment");
4118
4217
  const text = str(params, "target", true).trim();
4119
- const card = str(params, "card");
4218
+ const card = cardParam(params);
4120
4219
  let invoice = text.replace(/^lightning:/i, "");
4121
4220
  let n;
4122
4221
  let note;
@@ -4204,6 +4303,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4204
4303
  */
4205
4304
  async "chat.request"(ctx, params) {
4206
4305
  const memo = memoOf(params, "request");
4306
+ const card = cardParam(params);
4207
4307
  const link = chatOf(ctx, params);
4208
4308
  const method = params.method === void 0 ? void 0 : oneOf(params, "method", PAY_METHODS, "cashu");
4209
4309
  const n = network(params);
@@ -4219,7 +4319,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4219
4319
  ...memo ? { memo } : {},
4220
4320
  ...method ? { method } : {},
4221
4321
  ...rail ? { rail } : {},
4222
- ...str(params, "card") ? { card: str(params, "card") } : {}
4322
+ ...card ? { card } : {}
4223
4323
  }).catch((error) => {
4224
4324
  throw (!method || method === "cashu") && error instanceof Error && NO_MINT.test(error.message) ? noWalletOf(ctx, n, error) : error;
4225
4325
  });
@@ -4239,8 +4339,12 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4239
4339
  const s = state(ctx);
4240
4340
  const link = ownChatOf(ctx, params, s);
4241
4341
  const paymentId = str(params, "payment", true);
4342
+ const card = cardParam(params);
4242
4343
  const request = s.payments[paymentId];
4243
- if (!request || request.linkId !== link.id || request.kind !== "request") throw new CliError("not_found", `No request ${paymentId} in this chat`);
4344
+ const listed = `(ghostly payment list --chat ${link.id})`;
4345
+ 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}`);
4346
+ if (!request || request.linkId !== link.id) throw new CliError("not_found", `No request ${JSON.stringify(paymentId)} in this chat ${listed}`);
4347
+ if (request.direction !== "in") throw new CliError("bad_request", `${JSON.stringify(paymentId)} is your own request: the contact pays it`);
4244
4348
  const n = paymentNetwork(request);
4245
4349
  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
4350
  const via = params.via === void 0 ? void 0 : oneOf(params, "via", ["lightning"], "lightning");
@@ -4251,7 +4355,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4251
4355
  network: n,
4252
4356
  ...via ? { via } : {},
4253
4357
  ...params.maxFee !== void 0 ? { maxFee: num(params, "maxFee", 0) } : {},
4254
- ...str(params, "card") ? { card: str(params, "card") } : {},
4358
+ ...card ? { card } : {},
4255
4359
  ...real(params)
4256
4360
  });
4257
4361
  return paymentJson(state(ctx).payments[paymentId] ?? request);
@@ -4268,7 +4372,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4268
4372
  };
4269
4373
  }
4270
4374
  const method = oneOf(params, "method", CHAT_METHODS, "cashu");
4271
- const on = bool(params, "on");
4375
+ const on = params.on === void 0 || bool(params, "on");
4272
4376
  const nets = params.networks === void 0 ? void 0 : (() => {
4273
4377
  const value = params.networks;
4274
4378
  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 +4420,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
4316
4420
  }).map(([name, method]) => [name, (ctx, params) => method(ctx, params).catch((error) => {
4317
4421
  throw walletRefusal(error);
4318
4422
  })]));
4319
- //#endregion
4320
- //#region src/api.ts
4423
+ // src/api.ts
4321
4424
  /**
4322
4425
  * 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
4426
  * engine is asked, with a code that says it never goes as it is, not "unavailable", which reads as "try later".
@@ -4560,6 +4663,113 @@ function noRemovalOnItsWay(ctx, linkIds, clearing = false) {
4560
4663
  ];
4561
4664
  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
4665
  }
4666
+ /**
4667
+ * Stages a one-shot `group join` stops waiting at. The link was replaced: knocking again does not get in. The group
4668
+ * has no room yet (`full`, or `blocked` while it waits for every member's app to take more than eight): the engine
4669
+ * goes on knocking until there is room, which a minute's wait seldom sees, so it says that the knock goes on only
4670
+ * while the profile runs.
4671
+ */
4672
+ var NO_ROOM = {
4673
+ full: "No room yet: the group is full",
4674
+ blocked: "No room yet: the group waits for every member's app to take more than eight members"
4675
+ };
4676
+ var JOIN_STOPS = /* @__PURE__ */ new Set(["replaced", ...Object.keys(NO_ROOM)]);
4677
+ /** How long a one-shot `group join` waits to be let in: as long as a one-shot `invite join` waits to pair. */
4678
+ var ONE_SHOT_JOIN_S = 60;
4679
+ /**
4680
+ * 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
4681
+ * in only while its knocks go on, and they stop when the command leaves. It left at once with `{"group": id}` and exit
4682
+ * 0, in 0.5 s, the admin online: the group stayed an invitation at "knocking" and nothing said a daemon had to run for
4683
+ * 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.
4684
+ * A contact's invitation to the group keeps its place and the link is only kept beside it: nothing knocks, so it
4685
+ * answers at once. Not accepted, only `group accept` moves it; accepted, only its welcome does, over the contact's chat.
4686
+ * In a group under the link's id already (`held`, before the join), the link is only kept beside it unless it is this
4687
+ * profile's own group's (the engine's `joinByLink`): nothing knocks, and it answered `"joined": true` for a link whose
4688
+ * group it never joined, with a second group waiting under the id that only `group show`'s `others` said.
4689
+ * Through a daemon the knock goes on after the answer, so it waits for nothing; it answered `{"group": id}` only, with
4690
+ * neither whether it was in nor a word about a link only kept beside a group held.
4691
+ */
4692
+ async function letIn(ctx, groupId, link, held) {
4693
+ const seen = (s) => s.groups.find((g) => g.id === groupId);
4694
+ const id = shellWord(groupId, groupId);
4695
+ const invited = seen(state(ctx))?.invitation;
4696
+ if (invited && !invited.viaLink && !invited.takenBack) {
4697
+ const who = invited.contact || "a contact";
4698
+ if (!invited.accepted) return {
4699
+ group: groupId,
4700
+ joined: false,
4701
+ stage: null,
4702
+ warning: `Not in yet: ${who} invited you to this group and the invitation waits for your answer. Accept it: ghostly group accept ${id}`
4703
+ };
4704
+ return {
4705
+ group: groupId,
4706
+ joined: false,
4707
+ stage: null,
4708
+ 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}`
4709
+ };
4710
+ }
4711
+ const opened = decodeGroupEntryLink(link);
4712
+ const own = held?.entryLink ? decodeGroupEntryLink(held.entryLink) : null;
4713
+ if (held?.status === "active" && opened && own?.host !== opened.host) {
4714
+ const kept = seen(state(ctx))?.others?.some((o) => "link" in o && decodeGroupEntryLink(o.link)?.host === opened.host);
4715
+ const pick = `keep the one you are in (ghostly engine keepGroup '{"groupId":"${groupId}"}') or take the link's instead (ghostly engine switchGroup '{"groupId":"${groupId}","to":"<its link, from group show --show-secret>"}')`;
4716
+ return {
4717
+ group: groupId,
4718
+ joined: false,
4719
+ stage: null,
4720
+ 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`
4721
+ };
4722
+ }
4723
+ if (ctx.mode !== "one-shot") {
4724
+ const now = seen(state(ctx));
4725
+ return {
4726
+ group: groupId,
4727
+ joined: now?.status === "active",
4728
+ stage: now?.invitation?.stage ?? null
4729
+ };
4730
+ }
4731
+ const done = (g) => !g || g.status === "active" || JOIN_STOPS.has(g.invitation?.stage ?? "");
4732
+ const group = await waitForState(ctx, (s) => {
4733
+ const g = seen(s);
4734
+ return done(g) ? { g } : void 0;
4735
+ }, ONE_SHOT_JOIN_S * 1e3, `group ${groupId} to let this profile in`).then(({ g }) => g, (error) => {
4736
+ if (error instanceof CliError && error.code === "timeout") return seen(state(ctx));
4737
+ throw error;
4738
+ });
4739
+ const joined = group?.status === "active", stage = group?.invitation?.stage ?? null;
4740
+ if (joined || !group) return {
4741
+ group: groupId,
4742
+ joined,
4743
+ stage
4744
+ };
4745
+ if (stage === "replaced") return {
4746
+ group: groupId,
4747
+ joined,
4748
+ stage,
4749
+ warning: "This link was replaced or turned off: ask someone in the group for the current link, then ghostly group join <link>"
4750
+ };
4751
+ const show = `keep it running (ghostly daemon --detach), then ghostly group show ${shellWord(groupId, groupId)}`;
4752
+ const full = stage === "full" ? group.invitation?.full : void 0;
4753
+ const noRoom = stage ? NO_ROOM[stage] : void 0;
4754
+ if (noRoom) return {
4755
+ group: groupId,
4756
+ joined,
4757
+ stage,
4758
+ 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}`
4759
+ };
4760
+ if (stage === "admitted") return {
4761
+ group: groupId,
4762
+ joined,
4763
+ stage,
4764
+ 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}`
4765
+ };
4766
+ return {
4767
+ group: groupId,
4768
+ joined,
4769
+ stage,
4770
+ 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}`
4771
+ };
4772
+ }
4563
4773
  var METHODS = {
4564
4774
  ...WALLET_METHODS,
4565
4775
  ...FILE_METHODS,
@@ -4575,6 +4785,7 @@ var METHODS = {
4575
4785
  ...APP_CHAT_METHODS,
4576
4786
  async status(ctx) {
4577
4787
  const s = state(ctx);
4788
+ const seen = ctx.mode === "daemon" ? s.transport.discovery : void 0;
4578
4789
  return {
4579
4790
  version: ctx.version,
4580
4791
  profile: ctx.runtime.paths.name,
@@ -4589,7 +4800,11 @@ var METHODS = {
4589
4800
  groups: s.groups.length,
4590
4801
  discovery: {
4591
4802
  protocol: s.transport.protocol,
4592
- relays: s.transport.relays
4803
+ relays: s.transport.relays,
4804
+ ...seen && {
4805
+ health: seen.relays,
4806
+ via: seen.path?.via ?? null
4807
+ }
4593
4808
  },
4594
4809
  events: { lastSeq: ctx.hub.lastSeq },
4595
4810
  ...ctx.listen && { listen: true }
@@ -5109,6 +5324,7 @@ var METHODS = {
5109
5324
  };
5110
5325
  },
5111
5326
  async "chat.delete"(ctx, params) {
5327
+ const purge = bool(params, "purge"), purged = purge ? { purged: true } : {};
5112
5328
  if (bool(params, "everyone")) {
5113
5329
  const target = chatOrGroup(ctx, str(params, "chat", true));
5114
5330
  const wait = oneOf(params, "wait", [
@@ -5136,6 +5352,7 @@ var METHODS = {
5136
5352
  messageId: message.id
5137
5353
  });
5138
5354
  if (result.error) throw new CliError(result.refused ? "refused" : "unavailable", result.error);
5355
+ if (purge) await purgeMessage(ctx, message);
5139
5356
  if (target.group) {
5140
5357
  const e = result.e;
5141
5358
  const edges = !e ? 0 : wait === "sent" ? await waitForGroupFrame(ctx, target.id, message.id, e, ms) : node(ctx).groupTaken({
@@ -5149,7 +5366,8 @@ var METHODS = {
5149
5366
  deleted: message.id,
5150
5367
  everyone: true,
5151
5368
  sent: edges > 0,
5152
- edges
5369
+ edges,
5370
+ ...purged
5153
5371
  };
5154
5372
  }
5155
5373
  if (wait === "confirmed") await waitForRemoval(ctx, target.linkId, message.id, ms);
@@ -5161,13 +5379,30 @@ var METHODS = {
5161
5379
  confirmed: !node(ctx).removalPending({
5162
5380
  linkId: target.linkId,
5163
5381
  messageId: message.id
5164
- })
5382
+ }),
5383
+ ...purged
5165
5384
  };
5166
5385
  }
5167
- const ref = str(params, "message") ?? "<message>";
5168
- const link = chatNotGroup(ctx, params, "message delete", `${/^[\w.:<>-]+$/.test(ref) ? ref : JSON.stringify(ref)} --everyone`);
5386
+ const ref = str(params, "message") ?? "<message>", typed = str(params, "chat", true);
5387
+ const reachesGroup = (name) => {
5388
+ try {
5389
+ return "group" in findChatOrGroup(state(ctx).links, state(ctx).groups, name);
5390
+ } catch {
5391
+ return false;
5392
+ }
5393
+ };
5394
+ let link;
5395
+ try {
5396
+ 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" : ""}`);
5397
+ } catch (error) {
5398
+ const group = error instanceof CliError ? error.details?.group : void 0;
5399
+ const theirs = typeof group === "string" && ref !== "<message>" ? await messageOf(ctx, `group:${group}`, ref).catch(() => void 0) : void 0;
5400
+ 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 });
5401
+ throw error;
5402
+ }
5169
5403
  const messageId = str(params, "message", true);
5170
- if (!await node(ctx).getMessage(link.id, messageId)) throw noMessage(messageId, {
5404
+ const message = await node(ctx).getMessage(link.id, messageId);
5405
+ if (!message) throw noMessage(messageId, {
5171
5406
  group: false,
5172
5407
  ref: str(params, "chat", true)
5173
5408
  });
@@ -5175,11 +5410,13 @@ var METHODS = {
5175
5410
  linkId: link.id,
5176
5411
  messageId
5177
5412
  });
5413
+ if (purge) await purgeMessage(ctx, message);
5178
5414
  return {
5179
5415
  chat: link.id,
5180
5416
  messageId,
5181
5417
  deleted: messageId,
5182
- everyone
5418
+ everyone,
5419
+ ...purged
5183
5420
  };
5184
5421
  },
5185
5422
  /** 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 +5541,19 @@ var METHODS = {
5304
5541
  });
5305
5542
  let link = null;
5306
5543
  if (profile === "community") ({link} = await node(ctx).enableGroupLink({ groupId }));
5307
- return {
5308
- group: groupId,
5309
- link
5310
- };
5544
+ return withUrl(groupId, link);
5311
5545
  },
5312
5546
  async "group.join"(ctx, params) {
5313
5547
  let groupId;
5548
+ const link = str(params, "link", true);
5549
+ const before = state(ctx).groups;
5314
5550
  try {
5315
- ({groupId} = await node(ctx).joinGroupByLink({ link: str(params, "link", true) }));
5551
+ ({groupId} = await node(ctx).joinGroupByLink({ link }));
5316
5552
  } catch (error) {
5317
5553
  if (error instanceof Error && error.message === "This is not a link to a group") throw new CliError("bad_request", error.message);
5318
5554
  throw error;
5319
5555
  }
5320
- return { group: groupId };
5556
+ return letIn(ctx, groupId, link, before.find((g) => g.id === groupId));
5321
5557
  },
5322
5558
  async "group.list"(ctx, params) {
5323
5559
  const showSecret = bool(params, "showSecret");
@@ -5494,16 +5730,15 @@ var METHODS = {
5494
5730
  sayTyping(ctx, target, typing, word);
5495
5731
  const until = seconds ? Date.now() + seconds * 1e3 : null;
5496
5732
  const kept = seconds ? keepTyping(ctx, target, seconds * 1e3, word) : null;
5497
- const reached = (s) => (s.groups.find((g) => g.id === group.id) ?? group).members.filter((m) => !m.me && m.online && !m.viaHub).length;
5498
- if (kept && ctx.mode === "one-shot") await keepOneShot(ctx, target, kept, (s) => reached(s) > 0);
5499
- const now = state(ctx);
5733
+ const reached = (now) => (now ?? group).members.filter((m) => !m.me && m.online && !m.viaHub).length;
5734
+ if (kept && ctx.mode === "one-shot") await keepOneShot(ctx, target, kept, (s) => reached(s.groups.find((g) => g.id === group.id)) > 0);
5500
5735
  return {
5501
5736
  group: group.id,
5502
5737
  typing,
5503
5738
  ...typing ? { kind } : {},
5504
5739
  ...status ? { status } : {},
5505
- reached: reached(now),
5506
- sendTyping: now.settings.sendTyping !== false,
5740
+ reached: reached(groupById(ctx, group.id)),
5741
+ sendTyping: settingsOf(ctx).sendTyping !== false,
5507
5742
  ...until ? { until } : {},
5508
5743
  ...!kept && ctx.mode === "one-shot" && { note: typing ? ONE_SHOT_TYPING : ONE_SHOT_TYPING_STOP }
5509
5744
  };
@@ -5529,6 +5764,7 @@ var METHODS = {
5529
5764
  },
5530
5765
  async "group.accept"(ctx, params) {
5531
5766
  const group = groupOf(ctx, params);
5767
+ if (!group.invitation) throw new CliError("refused", `${outOf(group) ?? `You are in ${group.name} already`}: there is no invitation to accept`);
5532
5768
  await node(ctx).acceptGroupInvitation({ groupId: group.id });
5533
5769
  return { group: group.id };
5534
5770
  },
@@ -5755,8 +5991,8 @@ function notAGroup(ctx, params, chat, hint) {
5755
5991
  } catch {
5756
5992
  throw error;
5757
5993
  }
5758
- const shown = /^[\w.:-]+$/.test(named) ? named : JSON.stringify(named);
5759
- throw new CliError("not_found", `${JSON.stringify(ref)} is a group, not a chat: ${hint(shown)}`, { group: group.id });
5994
+ const shown = shellWord(named, group.id);
5995
+ throw new CliError("not_found", `${JSON.stringify(ref)} is a group, not a chat: ${hint(shown, group.id)}`, { group: group.id });
5760
5996
  }
5761
5997
  }
5762
5998
  /** The chat a chat command with a group twin names: a group's name says so, with `command`, the twin (see `notAGroup`). */
@@ -5942,14 +6178,16 @@ function quoteChecked(json, message, originals) {
5942
6178
  };
5943
6179
  }
5944
6180
  var API_METHODS = Object.keys(METHODS);
5945
- /** Runs one method of the API: one the table lists itself (`constructor`, which every object has, is none). */
5946
- async function callApi(ctx, method, params = {}) {
6181
+ /**
6182
+ * Runs one method of the API: one the table lists itself (`constructor`, which every object has, is none). `call`: who
6183
+ * asked, from a daemon's connection (`host.ts`).
6184
+ */
6185
+ async function callApi(ctx, method, params = {}, call) {
5947
6186
  const run = Object.hasOwn(METHODS, method) ? METHODS[method] : void 0;
5948
6187
  if (!run) throw new CliError("not_found", `No method ${method}`);
5949
6188
  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));
6189
+ return run(ctx, await withStoredIds(ctx, params), call);
5951
6190
  }
5952
- //#endregion
5953
6191
  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
6192
 
5955
- //# sourceMappingURL=api-MYc6QNRs.js.map
6193
+ //# sourceMappingURL=api-DLzCtePC.js.map