@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
@@ -0,0 +1,150 @@
1
+ // ../core/src/engineErrors.ts
2
+ /**
3
+ * The engine's known errors: a stable code each, and its English text with the values in it. The engine throws
4
+ * `engineError(code, values)`; the text is the one it always wrote, so the CLI and every log keep printing the same.
5
+ * The app's pages get only the text (it crosses the engine's RPC and is kept on payments and operations as a string),
6
+ * and `parseEngineError` finds the code and the values back in it, to say it in the app's language. A text that is
7
+ * none of these (a mint's own words, a provider's) stays as it is.
8
+ *
9
+ * `{name}` in a template is a value: a host or domain (no spaces), a network ("Mainnet" or "Testnet"), a chain's name,
10
+ * an ecash unit ("usd"), an amount (digits, with the separators of whatever locale wrote it), or a server's own `{reason}`
11
+ * (one line, last in its text).
12
+ */
13
+ var ENGINE_ERRORS = {
14
+ mintUnreachable: "Could not reach {host}. Check the address: it should be a Cashu mint.",
15
+ lnurlUnreachable: "Could not reach {host}. It may be down, or not allow web apps to read it (CORS).",
16
+ hostUnreachable: "Could not reach {host}",
17
+ networkUnreachable: "Could not reach the network",
18
+ hostTimedOut: "{host} did not answer in time",
19
+ networkTimedOut: "The network did not answer in time",
20
+ testMintOnMainnet: "This is a test mint, and its sats are worth nothing: add it to a Testnet Cashu wallet",
21
+ realMintOnTestnet: "This mint holds real sats: add it to a Mainnet Cashu wallet",
22
+ mintHoldsSats: "Move your sats out of this mint before removing it",
23
+ lastMint: "This is the last mint of your {network} Cashu wallet: remove the wallet to remove it",
24
+ invalidMintUrl: "That is not a valid mint URL",
25
+ mintNotHttps: "Mints must use https",
26
+ notEnoughSats: "Not enough sats in your wallet",
27
+ notEnoughForFee: "Not enough sats in your wallet: {amount} sats leave room for the fee",
28
+ mintsNoAnyAmount: "None of your mints can pay an invoice with no amount",
29
+ noSharedMint: "You share no mint with this contact",
30
+ ecashAlreadySpent: "This ecash was already spent somewhere else",
31
+ ecashBeingReceived: "This ecash is already being received",
32
+ ecashFeeTakesAll: "The mint keeps all {amount} sats of this ecash as its fee to take it in: nothing was redeemed, and its sender can still take it back",
33
+ ecashOtherUnit: "This ecash is in {unit}: only sat ecash can be redeemed here",
34
+ reviewedEcashSpent: "The ecash for this payment was already spent somewhere else. Nothing was sent, and your balance now shows what the mint still holds.",
35
+ reviewedSatsGone: "The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.",
36
+ mintFailedQuote: "{host} could not take this payment right now, and no sats left your wallet: try again later. The mint said: {reason}",
37
+ mintFailedFaucet: "{host} could not give test coins right now: try again later. The mint said: {reason}",
38
+ mintFailedInvoice: "{host} could not create an invoice right now: try again later. The mint said: {reason}",
39
+ lightningFeeTooHigh: "The Lightning fee ({fee} sats) is too high",
40
+ lightningRefused: "The mint refused this Lightning payment, and no sats left your wallet: it is safe to try again. The mint said: {reason}",
41
+ invoiceExpired: "That invoice has expired",
42
+ lnurlExactly: "{domain} asks for exactly {amount} sats",
43
+ lnurlRange: "{domain} takes between {min} and {max} sats",
44
+ feeAboveLimit: "The fee exceeds your limit",
45
+ cashuFeeAboveLimit: "Cashu fee exceeds your limit",
46
+ invalidMaxFee: "Invalid maximum fee",
47
+ methodUnavailable: "This payment method is unavailable",
48
+ unknownPaymentIntent: "Unknown payment intent",
49
+ paymentExpired: "Payment request expired or has an invalid expiry",
50
+ requestHasPayment: "This request already has a payment. Reconcile it before trying again.",
51
+ requestPaymentInFlight: "This request already has a payment; reconcile it instead",
52
+ requestNotAwaiting: "This request is no longer awaiting payment. Check its status before spending.",
53
+ reconnectBeforeApprove: "Reconnect the data link before approving. Your review was saved.",
54
+ cannotSubmitAgain: "This payment cannot be submitted again. Reconcile its existing transaction.",
55
+ alreadySubmitted: "This payment was already submitted or could not be saved",
56
+ sentAfterReview: "A payment from this wallet was sent after this review was made. Create a new review",
57
+ cannotCancelSubmitted: "A submitted payment cannot be cancelled; reconcile it instead",
58
+ outcomeUnknown: "Outcome unknown. Check the existing payment; do not send another.",
59
+ notYetConfirmed: "Not yet confirmed. No second payment was sent.",
60
+ couldNotVerify: "Could not verify this payment yet. No second payment was sent.",
61
+ paymentTakenBack: "This payment was taken back. The sats are in your wallet.",
62
+ parkedSigned: "Needs your decision: this payment was signed before this copy of your profile took over. It is never sent again from here. Check it before you pay again.",
63
+ contactAway: "Your contact is offline. Nothing was sent: pay once the chat is live.",
64
+ contactNoWallet: "Your contact has no wallet yet: they need one to pay or be paid",
65
+ contactNoPayments: "Your contact has payments off in this chat, or needs an updated Ghostly",
66
+ realMoneyUnconfirmed: "This pays with real money: confirm it with Send real money first. Nothing was sent.",
67
+ mainnetPaymentOnTestnet: "This is a Mainnet payment (real money): a Testnet wallet never pays it. Use a Mainnet wallet.",
68
+ testnetPaymentOnMainnet: "This is a Testnet payment (test coins): a Mainnet wallet never pays it. Use a Testnet wallet.",
69
+ usdtRpcUnavailable: "USDT RPC unavailable",
70
+ usdtNotEnoughTokens: "Insufficient token balance",
71
+ usdtNotEnoughGas: "Insufficient ETH for gas",
72
+ usdtGasAboveLimit: "Estimated maximum gas exceeds your limit",
73
+ usdtNeedsSepoliaGas: "This needs a little Sepolia ETH for gas first",
74
+ fedimintNotInvite: "That is not a Fedimint invite code: it starts with fed1",
75
+ fedimintAlreadyJoined: "You already joined this federation",
76
+ fedimintConnecting: "Wait for the federation to connect",
77
+ fedimintNotEnough: "Not enough in this federation",
78
+ fedimintRedeemUnheard: "Could not hear from the federation about these notes: if they don't show in your balance soon, paste them again",
79
+ fedimintRealOnTestnet: "This federation holds real bitcoin: it belongs in a Mainnet Fedimint wallet",
80
+ fedimintTestOnMainnet: "This federation is on {chain}, a test network: it belongs in a Testnet Fedimint wallet",
81
+ walletAway: "{wallet} can't be used here. Use it on {device}.",
82
+ walletAwayUnnamed: "{wallet} can't be used here: its home is another device.",
83
+ serviceShareFull: "A contact can reach at most {max} of your apps: take one back from them before sharing another",
84
+ groupTurnUnconfirmed: "Can't check which device is active, so the group was not changed. Try again in a moment.",
85
+ groupNoCall: "This group has no calls: its admin has not set a call server",
86
+ groupCallNotMember: "You are not in this group, so you can't join its call",
87
+ groupCallRefused: "{host} did not let you into the group's call. Try again in a minute.",
88
+ groupCallBusy: "{host} is busy. Try the call again in a minute.",
89
+ groupCallFailed: "{host} could not start the group's call. Try again later."
90
+ };
91
+ /**
92
+ * An error the engine knows: `engineCode` travels with it inside the engine, the text everywhere. Not `code`: the
93
+ * CLI reads a `code` as its own exit code, and Node's errors carry one of theirs.
94
+ */
95
+ var EngineError = class extends Error {
96
+ engineCode;
97
+ values;
98
+ constructor(engineCode, values = {}) {
99
+ super(engineText(engineCode, values));
100
+ this.engineCode = engineCode;
101
+ this.values = values;
102
+ }
103
+ };
104
+ /** The English text of `code` with its values in it, exactly as the engine writes it. */
105
+ function engineText(code, values = {}) {
106
+ return ENGINE_ERRORS[code].replace(/\{(\w+)\}/g, (_, name) => name in values ? String(values[name]) : `{${name}}`);
107
+ }
108
+ var engineError = (code, values) => new EngineError(code, values);
109
+ /** What each kind of value looks like in a text: never a space in a host, a network by its name, an amount as digits. */
110
+ var VALUE = {
111
+ host: "(\\S+)",
112
+ domain: "(\\S+)",
113
+ chain: "(\\S+)",
114
+ unit: "(\\S+)",
115
+ network: "(Mainnet|Testnet)",
116
+ amount: "(\\d[\\d.,\\u00a0\\u202f' ]*?)",
117
+ fee: "(\\d[\\d.,\\u00a0\\u202f' ]*?)",
118
+ min: "(\\d[\\d.,\\u00a0\\u202f' ]*?)",
119
+ max: "(\\d[\\d.,\\u00a0\\u202f' ]*?)"
120
+ };
121
+ var escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
122
+ var PATTERNS = Object.keys(ENGINE_ERRORS).map((code) => {
123
+ const names = [];
124
+ const source = ENGINE_ERRORS[code].split(/(\{\w+\})/).map((part) => {
125
+ const value = /^\{(\w+)\}$/.exec(part);
126
+ if (!value) return escape(part);
127
+ names.push(value[1]);
128
+ return VALUE[value[1]] ?? "(.+?)";
129
+ }).join("");
130
+ return {
131
+ code,
132
+ names,
133
+ pattern: new RegExp(`^${source}$`)
134
+ };
135
+ });
136
+ /** The code and values of a text the engine wrote, or null for any other text (it is then shown as it is). */
137
+ function parseEngineError(text) {
138
+ const trimmed = text.trim();
139
+ for (const { code, names, pattern } of PATTERNS) {
140
+ const match = pattern.exec(trimmed);
141
+ if (match) return {
142
+ code,
143
+ values: Object.fromEntries(names.map((name, i) => [name, match[i + 1]]))
144
+ };
145
+ }
146
+ return null;
147
+ }
148
+ export { parseEngineError as i, engineError as n, engineText as r, EngineError as t };
149
+
150
+ //# sourceMappingURL=engineErrors--9hfgKlK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engineErrors--9hfgKlK.js","names":[],"sources":["../../../core/src/engineErrors.ts"],"sourcesContent":["/**\n * The engine's known errors: a stable code each, and its English text with the values in it. The engine throws\n * `engineError(code, values)`; the text is the one it always wrote, so the CLI and every log keep printing the same.\n * The app's pages get only the text (it crosses the engine's RPC and is kept on payments and operations as a string),\n * and `parseEngineError` finds the code and the values back in it, to say it in the app's language. A text that is\n * none of these (a mint's own words, a provider's) stays as it is.\n *\n * `{name}` in a template is a value: a host or domain (no spaces), a network (\"Mainnet\" or \"Testnet\"), a chain's name,\n * an ecash unit (\"usd\"), an amount (digits, with the separators of whatever locale wrote it), or a server's own `{reason}`\n * (one line, last in its text).\n */\nexport const ENGINE_ERRORS = {\n // Reaching a mint, a server, the network.\n mintUnreachable: \"Could not reach {host}. Check the address: it should be a Cashu mint.\",\n lnurlUnreachable: \"Could not reach {host}. It may be down, or not allow web apps to read it (CORS).\",\n hostUnreachable: \"Could not reach {host}\",\n networkUnreachable: \"Could not reach the network\",\n hostTimedOut: \"{host} did not answer in time\",\n networkTimedOut: \"The network did not answer in time\",\n // Cashu mints.\n testMintOnMainnet: \"This is a test mint, and its sats are worth nothing: add it to a Testnet Cashu wallet\",\n realMintOnTestnet: \"This mint holds real sats: add it to a Mainnet Cashu wallet\",\n mintHoldsSats: \"Move your sats out of this mint before removing it\",\n lastMint: \"This is the last mint of your {network} Cashu wallet: remove the wallet to remove it\",\n invalidMintUrl: \"That is not a valid mint URL\",\n mintNotHttps: \"Mints must use https\",\n notEnoughSats: \"Not enough sats in your wallet\",\n notEnoughForFee: \"Not enough sats in your wallet: {amount} sats leave room for the fee\",\n mintsNoAnyAmount: \"None of your mints can pay an invoice with no amount\",\n noSharedMint: \"You share no mint with this contact\",\n ecashAlreadySpent: \"This ecash was already spent somewhere else\",\n ecashBeingReceived: \"This ecash is already being received\",\n ecashFeeTakesAll: \"The mint keeps all {amount} sats of this ecash as its fee to take it in: nothing was redeemed, and its sender can still take it back\",\n ecashOtherUnit: \"This ecash is in {unit}: only sat ecash can be redeemed here\",\n reviewedEcashSpent: \"The ecash for this payment was already spent somewhere else. Nothing was sent, and your balance now shows what the mint still holds.\",\n reviewedSatsGone: \"The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.\",\n // A mint that failed (a server error, a closed connection), not refused: nothing happened, and it may work later.\n mintFailedQuote: \"{host} could not take this payment right now, and no sats left your wallet: try again later. The mint said: {reason}\",\n mintFailedFaucet: \"{host} could not give test coins right now: try again later. The mint said: {reason}\",\n mintFailedInvoice: \"{host} could not create an invoice right now: try again later. The mint said: {reason}\",\n // Lightning.\n lightningFeeTooHigh: \"The Lightning fee ({fee} sats) is too high\",\n lightningRefused: \"The mint refused this Lightning payment, and no sats left your wallet: it is safe to try again. The mint said: {reason}\",\n invoiceExpired: \"That invoice has expired\",\n lnurlExactly: \"{domain} asks for exactly {amount} sats\",\n lnurlRange: \"{domain} takes between {min} and {max} sats\",\n // A reviewed payment, from its review to its outcome (paymentAdapters/coordinator.ts, persistence.ts, node.ts).\n feeAboveLimit: \"The fee exceeds your limit\",\n cashuFeeAboveLimit: \"Cashu fee exceeds your limit\",\n invalidMaxFee: \"Invalid maximum fee\",\n methodUnavailable: \"This payment method is unavailable\",\n unknownPaymentIntent: \"Unknown payment intent\",\n paymentExpired: \"Payment request expired or has an invalid expiry\",\n requestHasPayment: \"This request already has a payment. Reconcile it before trying again.\",\n requestPaymentInFlight: \"This request already has a payment; reconcile it instead\",\n requestNotAwaiting: \"This request is no longer awaiting payment. Check its status before spending.\",\n reconnectBeforeApprove: \"Reconnect the data link before approving. Your review was saved.\",\n cannotSubmitAgain: \"This payment cannot be submitted again. Reconcile its existing transaction.\",\n alreadySubmitted: \"This payment was already submitted or could not be saved\",\n sentAfterReview: \"A payment from this wallet was sent after this review was made. Create a new review\",\n cannotCancelSubmitted: \"A submitted payment cannot be cancelled; reconcile it instead\",\n outcomeUnknown: \"Outcome unknown. Check the existing payment; do not send another.\",\n notYetConfirmed: \"Not yet confirmed. No second payment was sent.\",\n couldNotVerify: \"Could not verify this payment yet. No second payment was sent.\",\n paymentTakenBack: \"This payment was taken back. The sats are in your wallet.\",\n parkedSigned: \"Needs your decision: this payment was signed before this copy of your profile took over. It is never sent again from here. Check it before you pay again.\",\n // Paying in a chat.\n contactAway: \"Your contact is offline. Nothing was sent: pay once the chat is live.\",\n contactNoWallet: \"Your contact has no wallet yet: they need one to pay or be paid\",\n contactNoPayments: \"Your contact has payments off in this chat, or needs an updated Ghostly\",\n // Real money and test coins.\n realMoneyUnconfirmed: \"This pays with real money: confirm it with Send real money first. Nothing was sent.\",\n mainnetPaymentOnTestnet: \"This is a Mainnet payment (real money): a Testnet wallet never pays it. Use a Mainnet wallet.\",\n testnetPaymentOnMainnet: \"This is a Testnet payment (test coins): a Mainnet wallet never pays it. Use a Testnet wallet.\",\n // USDT.\n usdtRpcUnavailable: \"USDT RPC unavailable\",\n usdtNotEnoughTokens: \"Insufficient token balance\",\n usdtNotEnoughGas: \"Insufficient ETH for gas\",\n usdtGasAboveLimit: \"Estimated maximum gas exceeds your limit\",\n usdtNeedsSepoliaGas: \"This needs a little Sepolia ETH for gas first\",\n // Fedimint.\n fedimintNotInvite: \"That is not a Fedimint invite code: it starts with fed1\",\n fedimintAlreadyJoined: \"You already joined this federation\",\n fedimintConnecting: \"Wait for the federation to connect\",\n fedimintNotEnough: \"Not enough in this federation\",\n fedimintRedeemUnheard: \"Could not hear from the federation about these notes: if they don't show in your balance soon, paste them again\",\n fedimintRealOnTestnet: \"This federation holds real bitcoin: it belongs in a Mainnet Fedimint wallet\",\n fedimintTestOnMainnet: \"This federation is on {chain}, a test network: it belongs in a Testnet Fedimint wallet\",\n walletAway: \"{wallet} can't be used here. Use it on {device}.\",\n walletAwayUnnamed: \"{wallet} can't be used here: its home is another device.\",\n // Web apps shared with a contact.\n serviceShareFull: \"A contact can reach at most {max} of your apps: take one back from them before sharing another\",\n // One profile on several devices (WISP 06).\n groupTurnUnconfirmed: \"Can't check which device is active, so the group was not changed. Try again in a moment.\",\n // Group calls through the group's node (WISP 602).\n groupNoCall: \"This group has no calls: its admin has not set a call server\",\n groupCallNotMember: \"You are not in this group, so you can't join its call\",\n groupCallRefused: \"{host} did not let you into the group's call. Try again in a minute.\",\n groupCallBusy: \"{host} is busy. Try the call again in a minute.\",\n groupCallFailed: \"{host} could not start the group's call. Try again later.\",\n} as const;\n\nexport type EngineErrorCode = keyof typeof ENGINE_ERRORS;\nexport type EngineErrorValues = Record<string, string | number>;\n\n/**\n * An error the engine knows: `engineCode` travels with it inside the engine, the text everywhere. Not `code`: the\n * CLI reads a `code` as its own exit code, and Node's errors carry one of theirs.\n */\nexport class EngineError extends Error {\n constructor(readonly engineCode: EngineErrorCode, readonly values: EngineErrorValues = {}) {\n super(engineText(engineCode, values));\n }\n}\n\n/** The English text of `code` with its values in it, exactly as the engine writes it. */\nexport function engineText(code: EngineErrorCode, values: EngineErrorValues = {}): string {\n return ENGINE_ERRORS[code].replace(/\\{(\\w+)\\}/g, (_, name: string) => (name in values ? String(values[name]) : `{${name}}`));\n}\n\nexport const engineError = (code: EngineErrorCode, values?: EngineErrorValues): EngineError => new EngineError(code, values);\n\n/** What each kind of value looks like in a text: never a space in a host, a network by its name, an amount as digits. */\nconst VALUE: Record<string, string> = {\n host: \"(\\\\S+)\", domain: \"(\\\\S+)\", chain: \"(\\\\S+)\", unit: \"(\\\\S+)\", network: \"(Mainnet|Testnet)\",\n amount: \"(\\\\d[\\\\d.,\\\\u00a0\\\\u202f' ]*?)\", fee: \"(\\\\d[\\\\d.,\\\\u00a0\\\\u202f' ]*?)\", min: \"(\\\\d[\\\\d.,\\\\u00a0\\\\u202f' ]*?)\", max: \"(\\\\d[\\\\d.,\\\\u00a0\\\\u202f' ]*?)\",\n};\nconst escape = (text: string) => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\nconst PATTERNS = (Object.keys(ENGINE_ERRORS) as EngineErrorCode[]).map((code) => {\n const names: string[] = [];\n const source = ENGINE_ERRORS[code].split(/(\\{\\w+\\})/).map((part) => {\n const value = /^\\{(\\w+)\\}$/.exec(part);\n if (!value) return escape(part);\n names.push(value[1]);\n return VALUE[value[1]] ?? \"(.+?)\";\n }).join(\"\");\n return { code, names, pattern: new RegExp(`^${source}$`) };\n});\n\n/** The code and values of a text the engine wrote, or null for any other text (it is then shown as it is). */\nexport function parseEngineError(text: string): { code: EngineErrorCode; values: Record<string, string> } | null {\n const trimmed = text.trim();\n for (const { code, names, pattern } of PATTERNS) {\n const match = pattern.exec(trimmed);\n if (match) return { code, values: Object.fromEntries(names.map((name, i) => [name, match[i + 1]])) };\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,gBAAgB;CAE3B,iBAAiB;CACjB,kBAAkB;CAClB,iBAAiB;CACjB,oBAAoB;CACpB,cAAc;CACd,iBAAiB;CAEjB,mBAAmB;CACnB,mBAAmB;CACnB,eAAe;CACf,UAAU;CACV,gBAAgB;CAChB,cAAc;CACd,eAAe;CACf,iBAAiB;CACjB,kBAAkB;CAClB,cAAc;CACd,mBAAmB;CACnB,oBAAoB;CACpB,kBAAkB;CAClB,gBAAgB;CAChB,oBAAoB;CACpB,kBAAkB;CAElB,iBAAiB;CACjB,kBAAkB;CAClB,mBAAmB;CAEnB,qBAAqB;CACrB,kBAAkB;CAClB,gBAAgB;CAChB,cAAc;CACd,YAAY;CAEZ,eAAe;CACf,oBAAoB;CACpB,eAAe;CACf,mBAAmB;CACnB,sBAAsB;CACtB,gBAAgB;CAChB,mBAAmB;CACnB,wBAAwB;CACxB,oBAAoB;CACpB,wBAAwB;CACxB,mBAAmB;CACnB,kBAAkB;CAClB,iBAAiB;CACjB,uBAAuB;CACvB,gBAAgB;CAChB,iBAAiB;CACjB,gBAAgB;CAChB,kBAAkB;CAClB,cAAc;CAEd,aAAa;CACb,iBAAiB;CACjB,mBAAmB;CAEnB,sBAAsB;CACtB,yBAAyB;CACzB,yBAAyB;CAEzB,oBAAoB;CACpB,qBAAqB;CACrB,kBAA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I,OAAO,IAAI,OAAO,EAAE;CAAE;AAC3D,CAAC;;AAGD,SAAgB,iBAAiB,MAAgF;CAC/G,MAAM,UAAU,KAAK,KAAK;CAC1B,KAAK,MAAM,EAAE,MAAM,OAAO,aAAa,UAAU;EAC/C,MAAM,QAAQ,QAAQ,KAAK,OAAO;EAClC,IAAI,OAAO,OAAO;GAAE;GAAM,QAAQ,OAAO,YAAY,MAAM,KAAK,MAAM,MAAM,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;EAAE;CACrG;CACA,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
- import { t as fromBase64Url } from "./codec-BnMg-Grj.js";
2
- //#region ../browser/src/backup/envelope.ts
1
+ import { t as fromBase64Url } from "./codec-B2rH1mfx.js";
2
+ // ../browser/src/backup/envelope.ts
3
3
  var BACKUP_MEDIA_TYPE = "application/vnd.ghostly.backup+json";
4
4
  var ITERATIONS = 6e5;
5
5
  async function keyFrom(passphrase, salt, iterations) {
@@ -75,7 +75,6 @@ async function open(text, passphrase) {
75
75
  const plain = envelope.compression === "gzip" ? await through(body, new DecompressionStream("gzip")) : body;
76
76
  return new TextDecoder().decode(plain);
77
77
  }
78
- //#endregion
79
78
  export { MAX_BACKUP_BYTES as n, open as r, BACKUP_MEDIA_TYPE as t };
80
79
 
81
- //# sourceMappingURL=envelope-CdV7vHVZ.js.map
80
+ //# sourceMappingURL=envelope-Bi2kMqbp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"envelope-CdV7vHVZ.js","names":[],"sources":["../../../browser/src/backup/envelope.ts"],"sourcesContent":["import { fromBase64Url, toBase64Url } from \"./codec\";\n\n/** The clear part of a bundle (WISP 05): only what decryption needs. */\nexport interface Envelope {\n format: \"ghostly-backup\";\n version: 1;\n kdf: { name: \"PBKDF2-SHA256\"; iterations: number; salt: string };\n cipher: { name: \"AES-256-GCM\"; iv: string };\n compression: \"gzip\" | \"none\";\n ciphertext: string;\n}\nexport const BACKUP_MEDIA_TYPE = \"application/vnd.ghostly.backup+json\";\nconst ITERATIONS = 600_000;\n\nasync function keyFrom(passphrase: string, salt: Uint8Array, iterations: number): Promise<CryptoKey> {\n const material = await crypto.subtle.importKey(\"raw\", new TextEncoder().encode(passphrase), \"PBKDF2\", false, [\"deriveKey\"]);\n return crypto.subtle.deriveKey({ name: \"PBKDF2\", hash: \"SHA-256\", salt: salt as BufferSource, iterations }, material, { name: \"AES-GCM\", length: 256 }, false, [\"encrypt\", \"decrypt\"]);\n}\n/** A profile with years of files is large, but not this large: past it, a bundle is refused, not read. */\nexport const MAX_BACKUP_BYTES = 1024 * 1024 * 1024;\n\nasync function through(bytes: Uint8Array, stream: CompressionStream | DecompressionStream): Promise<Uint8Array> {\n const reader = new Blob([bytes as BlobPart]).stream().pipeThrough(stream).getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n for (let next = await reader.read(); !next.done; next = await reader.read()) {\n size += next.value.length;\n if (size > MAX_BACKUP_BYTES) { await reader.cancel(); throw new Error(\"This backup is too large to restore\"); }\n chunks.push(next.value);\n }\n const out = new Uint8Array(size);\n let at = 0;\n for (const chunk of chunks) { out.set(chunk, at); at += chunk.length; }\n return out;\n}\n\n/**\n * The clear header is authenticated with the ciphertext (AES-GCM associated data): changing any of it,\n * the compression included, makes the bundle fail to open instead of being read differently.\n */\nconst header = (e: Pick<Envelope, \"format\" | \"version\" | \"kdf\" | \"cipher\" | \"compression\">) =>\n new TextEncoder().encode([e.format, e.version, e.kdf.name, e.kdf.iterations, e.kdf.salt, e.cipher.name, e.cipher.iv, e.compression].join(\"\\n\"));\nconst canCompress = () => typeof CompressionStream !== \"undefined\";\n\n/** Compresses and encrypts a payload under a passphrase the person chose. */\nexport async function seal(payload: string, passphrase: string): Promise<string> {\n if (passphrase.length < 12) throw new Error(\"Use at least 12 characters for the backup passphrase\");\n const salt = crypto.getRandomValues(new Uint8Array(16)), iv = crypto.getRandomValues(new Uint8Array(12));\n const plain = new TextEncoder().encode(payload);\n const compression = canCompress() ? \"gzip\" : \"none\";\n const body = compression === \"gzip\" ? await through(plain, new CompressionStream(\"gzip\")) : plain;\n const clear = { format: \"ghostly-backup\", version: 1, kdf: { name: \"PBKDF2-SHA256\", iterations: ITERATIONS, salt: toBase64Url(salt) }, cipher: { name: \"AES-256-GCM\", iv: toBase64Url(iv) }, compression } as const;\n const ciphertext = new Uint8Array(await crypto.subtle.encrypt({ name: \"AES-GCM\", iv, additionalData: header(clear) as BufferSource }, await keyFrom(passphrase, salt, ITERATIONS), body as BufferSource));\n const envelope: Envelope = { ...clear, ciphertext: toBase64Url(ciphertext) };\n return JSON.stringify(envelope);\n}\n\n/** Checks, decrypts and decompresses a bundle. Nothing from a bundle is used before this succeeds. */\nexport async function open(text: string, passphrase: string): Promise<string> {\n if (text.length > MAX_BACKUP_BYTES * 1.4) throw new Error(\"This backup is too large to restore\");\n let envelope: Envelope;\n try { envelope = JSON.parse(text) as Envelope; } catch { throw new Error(\"This is not a Ghostly backup\"); }\n if (envelope?.format !== \"ghostly-backup\") throw new Error(\"This is not a Ghostly backup\");\n if (envelope.version !== 1) throw new Error(\"This backup comes from a newer Ghostly; update to restore it\");\n if (envelope.kdf?.name !== \"PBKDF2-SHA256\" || !(envelope.kdf.iterations >= ITERATIONS) || envelope.kdf.iterations > 10_000_000 || envelope.cipher?.name !== \"AES-256-GCM\" || ![\"gzip\", \"none\"].includes(envelope.compression)) throw new Error(\"Unsupported backup encryption\");\n let body: Uint8Array;\n try {\n body = new Uint8Array(await crypto.subtle.decrypt({ name: \"AES-GCM\", iv: fromBase64Url(envelope.cipher.iv) as BufferSource, additionalData: header(envelope) as BufferSource }, await keyFrom(passphrase, fromBase64Url(envelope.kdf.salt), envelope.kdf.iterations), fromBase64Url(envelope.ciphertext) as BufferSource));\n } catch { throw new Error(\"Wrong passphrase, or the backup was changed\"); }\n const plain = envelope.compression === \"gzip\" ? await through(body, new DecompressionStream(\"gzip\")) : body;\n return new TextDecoder().decode(plain);\n}\n"],"mappings":";;AAWA,IAAa,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AAI,KAAK,SAAA,cAAiC,MAAM,IAAI,MAAM,qCAAqC;CAC/F,IAAI;CACJ,IAAI;EAAE,WAAW,KAAK,MAAM,IAAI;CAAe,QAAQ;EAAE,MAAM,IAAI,MAAM,8BAA8B;CAAG;CAC1G,IAAI,UAAU,WAAW,kBAAkB,MAAM,IAAI,MAAM,8BAA8B;CACzF,IAAI,SAAS,YAAY,GAAG,MAAM,IAAI,MAAM,8DAA8D;CAC1G,IAAI,SAAS,KAAK,SAAS,mBAAmB,EAAE,SAAS,IAAI,cAAc,eAAe,SAAS,IAAI,aAAa,OAAc,SAAS,QAAQ,SAAS,iBAAiB,CAAC,CAAC,QAAQ,MAAM,CAAC,CAAC,SAAS,SAAS,WAAW,GAAG,MAAM,IAAI,MAAM,+BAA+B;CAC9Q,IAAI;CACJ,IAAI;EACF,OAAO,IAAI,WAAW,MAAM,OAAO,OAAO,QAAQ;GAAE,MAAM;GAAW,IAAI,cAAc,SAAS,OAAO,EAAE;GAAmB,gBAAgB,OAAO,QAAQ;EAAkB,GAAG,MAAM,QAAQ,YAAY,cAAc,SAAS,IAAI,IAAI,GAAG,SAAS,IAAI,UAAU,GAAG,cAAc,SAAS,UAAU,CAAiB,CAAC;CAC3T,QAAQ;EAAE,MAAM,IAAI,MAAM,6CAA6C;CAAG;CAC1E,MAAM,QAAQ,SAAS,gBAAgB,SAAS,MAAM,QAAQ,MAAM,IAAI,oBAAoB,MAAM,CAAC,IAAI;CACvG,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;AACvC"}
1
+ {"version":3,"file":"envelope-Bi2kMqbp.js","names":[],"sources":["../../../browser/src/backup/envelope.ts"],"sourcesContent":["import { fromBase64Url, toBase64Url } from \"./codec\";\n\n/** The clear part of a bundle (WISP 05): only what decryption needs. */\nexport interface Envelope {\n format: \"ghostly-backup\";\n version: 1;\n kdf: { name: \"PBKDF2-SHA256\"; iterations: number; salt: string };\n cipher: { name: \"AES-256-GCM\"; iv: string };\n compression: \"gzip\" | \"none\";\n ciphertext: string;\n}\nexport const BACKUP_MEDIA_TYPE = \"application/vnd.ghostly.backup+json\";\nconst ITERATIONS = 600_000;\n\nasync function keyFrom(passphrase: string, salt: Uint8Array, iterations: number): Promise<CryptoKey> {\n const material = await crypto.subtle.importKey(\"raw\", new TextEncoder().encode(passphrase), \"PBKDF2\", false, [\"deriveKey\"]);\n return crypto.subtle.deriveKey({ name: \"PBKDF2\", hash: \"SHA-256\", salt: salt as BufferSource, iterations }, material, { name: \"AES-GCM\", length: 256 }, false, [\"encrypt\", \"decrypt\"]);\n}\n/** A profile with years of files is large, but not this large: past it, a bundle is refused, not read. */\nexport const MAX_BACKUP_BYTES = 1024 * 1024 * 1024;\n\nasync function through(bytes: Uint8Array, stream: CompressionStream | DecompressionStream): Promise<Uint8Array> {\n const reader = new Blob([bytes as BlobPart]).stream().pipeThrough(stream).getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n for (let next = await reader.read(); !next.done; next = await reader.read()) {\n size += next.value.length;\n if (size > MAX_BACKUP_BYTES) { await reader.cancel(); throw new Error(\"This backup is too large to restore\"); }\n chunks.push(next.value);\n }\n const out = new Uint8Array(size);\n let at = 0;\n for (const chunk of chunks) { out.set(chunk, at); at += chunk.length; }\n return out;\n}\n\n/**\n * The clear header is authenticated with the ciphertext (AES-GCM associated data): changing any of it,\n * the compression included, makes the bundle fail to open instead of being read differently.\n */\nconst header = (e: Pick<Envelope, \"format\" | \"version\" | \"kdf\" | \"cipher\" | \"compression\">) =>\n new TextEncoder().encode([e.format, e.version, e.kdf.name, e.kdf.iterations, e.kdf.salt, e.cipher.name, e.cipher.iv, e.compression].join(\"\\n\"));\nconst canCompress = () => typeof CompressionStream !== \"undefined\";\n\n/** Compresses and encrypts a payload under a passphrase the person chose. */\nexport async function seal(payload: string, passphrase: string): Promise<string> {\n if (passphrase.length < 12) throw new Error(\"Use at least 12 characters for the backup passphrase\");\n const salt = crypto.getRandomValues(new Uint8Array(16)), iv = crypto.getRandomValues(new Uint8Array(12));\n const plain = new TextEncoder().encode(payload);\n const compression = canCompress() ? \"gzip\" : \"none\";\n const body = compression === \"gzip\" ? await through(plain, new CompressionStream(\"gzip\")) : plain;\n const clear = { format: \"ghostly-backup\", version: 1, kdf: { name: \"PBKDF2-SHA256\", iterations: ITERATIONS, salt: toBase64Url(salt) }, cipher: { name: \"AES-256-GCM\", iv: toBase64Url(iv) }, compression } as const;\n const ciphertext = new Uint8Array(await crypto.subtle.encrypt({ name: \"AES-GCM\", iv, additionalData: header(clear) as BufferSource }, await keyFrom(passphrase, salt, ITERATIONS), body as BufferSource));\n const envelope: Envelope = { ...clear, ciphertext: toBase64Url(ciphertext) };\n return JSON.stringify(envelope);\n}\n\n/** Checks, decrypts and decompresses a bundle. Nothing from a bundle is used before this succeeds. */\nexport async function open(text: string, passphrase: string): Promise<string> {\n if (text.length > MAX_BACKUP_BYTES * 1.4) throw new Error(\"This backup is too large to restore\");\n let envelope: Envelope;\n try { envelope = JSON.parse(text) as Envelope; } catch { throw new Error(\"This is not a Ghostly backup\"); }\n if (envelope?.format !== \"ghostly-backup\") throw new Error(\"This is not a Ghostly backup\");\n if (envelope.version !== 1) throw new Error(\"This backup comes from a newer Ghostly; update to restore it\");\n if (envelope.kdf?.name !== \"PBKDF2-SHA256\" || !(envelope.kdf.iterations >= ITERATIONS) || envelope.kdf.iterations > 10_000_000 || envelope.cipher?.name !== \"AES-256-GCM\" || ![\"gzip\", \"none\"].includes(envelope.compression)) throw new Error(\"Unsupported backup encryption\");\n let body: Uint8Array;\n try {\n body = new Uint8Array(await crypto.subtle.decrypt({ name: \"AES-GCM\", iv: fromBase64Url(envelope.cipher.iv) as BufferSource, additionalData: header(envelope) as BufferSource }, await keyFrom(passphrase, fromBase64Url(envelope.kdf.salt), envelope.kdf.iterations), fromBase64Url(envelope.ciphertext) as BufferSource));\n } catch { throw new Error(\"Wrong passphrase, or the backup was changed\"); }\n const plain = envelope.compression === \"gzip\" ? await through(body, new DecompressionStream(\"gzip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AAI,CAAC;;AAiBhJ,eAAsB,KAAK,MAAc,YAAqC;CAC5E,IAAI,KAAK,SAAA,cAAiC,MAAM,IAAI,MAAM,qCAAqC;CAC/F,IAAI;CACJ,IAAI;EAAE,WAAW,KAAK,MAAM,IAAI;CAAe,QAAQ;EAAE,MAAM,IAAI,MAAM,8BAA8B;CAAG;CAC1G,IAAI,UAAU,WAAW,kBAAkB,MAAM,IAAI,MAAM,8BAA8B;CACzF,IAAI,SAAS,YAAY,GAAG,MAAM,IAAI,MAAM,8DAA8D;CAC1G,IAAI,SAAS,KAAK,SAAS,mBAAmB,EAAE,SAAS,IAAI,cAAc,eAAe,SAAS,IAAI,aAAa,OAAc,SAAS,QAAQ,SAAS,iBAAiB,CAAC,CAAC,QAAQ,MAAM,CAAC,CAAC,SAAS,SAAS,WAAW,GAAG,MAAM,IAAI,MAAM,+BAA+B;CAC9Q,IAAI;CACJ,IAAI;EACF,OAAO,IAAI,WAAW,MAAM,OAAO,OAAO,QAAQ;GAAE,MAAM;GAAW,IAAI,cAAc,SAAS,OAAO,EAAE;GAAmB,gBAAgB,OAAO,QAAQ;EAAkB,GAAG,MAAM,QAAQ,YAAY,cAAc,SAAS,IAAI,IAAI,GAAG,SAAS,IAAI,UAAU,GAAG,cAAc,SAAS,UAAU,CAAiB,CAAC;CAC3T,QAAQ;EAAE,MAAM,IAAI,MAAM,6CAA6C;CAAG;CAC1E,MAAM,QAAQ,SAAS,gBAAgB,SAAS,MAAM,QAAQ,MAAM,IAAI,oBAAoB,MAAM,CAAC,IAAI;CACvG,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;AACvC"}
@@ -1,4 +1,4 @@
1
- //#region src/errors.ts
1
+ // src/errors.ts
2
2
  /** `interrupted`: Ctrl-C (SIGINT) ended the command, 128 + 2 as a shell says of a command its signal ended. */
3
3
  var EXIT = {
4
4
  engine: 1,
@@ -64,6 +64,7 @@ var ENGINE_CODES = {
64
64
  hostUnreachable: "unavailable",
65
65
  networkUnreachable: "unavailable",
66
66
  usdtRpcUnavailable: "unavailable",
67
+ mintFailedInvoice: "unavailable",
67
68
  hostTimedOut: "timeout",
68
69
  networkTimedOut: "timeout",
69
70
  invalidMintUrl: "bad_request",
@@ -76,7 +77,8 @@ var ENGINE_CODES = {
76
77
  ecashFeeTakesAll: "refused",
77
78
  lightningRefused: "refused",
78
79
  contactNoWallet: "refused",
79
- contactNoPayments: "refused"
80
+ contactNoPayments: "refused",
81
+ serviceShareFull: "refused"
80
82
  };
81
83
  /** `details.reason` of an engine error a bot tells apart from others of its code. */
82
84
  var ENGINE_REASONS = {
@@ -170,7 +172,6 @@ function localFileError(error, file) {
170
172
  });
171
173
  }
172
174
  }
173
- //#endregion
174
175
  export { localFileError as i, EXIT as n, asCliError as r, CliError as t };
175
176
 
176
- //# sourceMappingURL=errors-CAh6GLJZ.js.map
177
+ //# sourceMappingURL=errors-DDLFO4Gf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-DDLFO4Gf.js","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["/**\n * Errors that reach a bot: a stable `code` to branch on, a message for people, and the exit status the CLI\n * leaves with (WISP 1100 § Exit codes). The daemon sends `{code, message}` over the socket; the CLI prints\n * `{\"error\": {code, message}}` on stdout and exits with `exit`.\n */\nexport type ErrorCode =\n | \"bad_request\" | \"usage\" | \"not_found\" | \"refused\" | \"unavailable\" | \"confirm\" | \"timeout\"\n | \"engine\" | \"busy\" | \"internal\" | \"interrupted\";\n\n/** `interrupted`: Ctrl-C (SIGINT) ended the command, 128 + 2 as a shell says of a command its signal ended. */\nexport const EXIT: Record<ErrorCode, number> = {\n engine: 1, refused: 1, unavailable: 1, bad_request: 1, busy: 1, internal: 1,\n usage: 2, not_found: 3, timeout: 4, confirm: 5, interrupted: 130,\n};\n\nexport class CliError extends Error {\n constructor(readonly code: ErrorCode, message: string, readonly details?: Record<string, unknown>) {\n super(message);\n this.name = \"CliError\";\n }\n toJSON(): { code: ErrorCode; message: string; details?: Record<string, unknown> } {\n return { code: this.code, message: this.message, ...(this.details ? { details: this.details } : {}) };\n }\n}\n\n/** Anything thrown, as the error a bot sees: the engine's own refusals keep their words. */\nexport function asCliError(error: unknown): CliError {\n if (error instanceof CliError) return error;\n if (error && typeof error === \"object\" && \"code\" in error && \"message\" in error && typeof (error as { code: unknown }).code === \"string\"\n && Object.hasOwn(EXIT, (error as { code: string }).code)) return new CliError((error as { code: ErrorCode }).code, String((error as { message: unknown }).message));\n // A contact the chat's link could not reach (its `GhostlyHttpError` \"unreachable\"): not there now, not the engine failing.\n if (error instanceof Error && (error as { code?: unknown }).code === \"unreachable\") return new CliError(\"unavailable\", error.message);\n const known = engineKnown(error) ?? contactNoRail(error);\n if (known) return known;\n const full = noRoomError(error);\n if (full) return full;\n const local = localFileError(error);\n if (local) return local;\n const unopened = profileOpenError(error);\n if (unopened) return unopened;\n const message = error instanceof Error ? error.message : String(error);\n if (/real money|confirmedReal|Mainnet/i.test(message) && /confirm/i.test(message)) return new CliError(\"confirm\", message);\n if (/other network|cross-network|network does not match/i.test(message)) return new CliError(\"refused\", message);\n // A member asking for a group's admin-only change, one removed from the group (or gone) asking for any, an invitation\n // already answered: not allowed, not the engine failing.\n if (/^Only the admin |^You are no longer in this group$|^No invitation to (accept|decline)$/.test(message)) return new CliError(\"refused\", message);\n // `group invite` to a contact whose app is closed: try again once they are online.\n if (message === \"This contact is not connected right now. Invite them when they are online.\") return new CliError(\"unavailable\", message);\n // `group invite` the group or the contact's app cannot take: one already in, a full group, an app too old for it.\n if (/^This contact is already a member$|^A group holds \\d+ members at most$|^A group grows past \\d+ only when |^Their app (does not take part in groups|takes groups of \\d+ at most)|^This group runs through hubs, which their app /.test(message)) return new CliError(\"refused\", message);\n // `group invite` into a community: it has no invitations, its link is how people join.\n if (message === \"Share the group's link with them: anyone who opens it joins\") return new CliError(\"bad_request\", message);\n return new CliError(\"engine\", message);\n}\n\n/**\n * The engine's known errors (`EngineError`, packages/core engineErrors.ts) a bot branches on, by their `engineCode`: a\n * host or the network not answering is `unavailable` (try again later), one too slow `timeout`, a value the person gave\n * `bad_request`, money that is not there `refused`, a contact that offers no way of paying `refused` with its reason in\n * `details.reason`. Any other keeps `engine`. Read by its shape, as `profileOpenError`.\n */\nconst ENGINE_CODES: Record<string, ErrorCode> = {\n mintUnreachable: \"unavailable\", lnurlUnreachable: \"unavailable\", hostUnreachable: \"unavailable\", networkUnreachable: \"unavailable\", usdtRpcUnavailable: \"unavailable\", mintFailedInvoice: \"unavailable\",\n hostTimedOut: \"timeout\", networkTimedOut: \"timeout\",\n invalidMintUrl: \"bad_request\", mintNotHttps: \"bad_request\", invalidMaxFee: \"bad_request\",\n notEnoughSats: \"refused\", notEnoughForFee: \"refused\", mintsNoAnyAmount: \"refused\", ecashAlreadySpent: \"refused\", ecashFeeTakesAll: \"refused\", lightningRefused: \"refused\", contactNoWallet: \"refused\", contactNoPayments: \"refused\",\n serviceShareFull: \"refused\",\n};\n/** `details.reason` of an engine error a bot tells apart from others of its code. */\nconst ENGINE_REASONS: Record<string, string> = { contactNoWallet: \"contact_no_wallet\", contactNoPayments: \"contact_payments_off\" };\n\nfunction engineKnown(error: unknown): CliError | undefined {\n if (!(error instanceof Error)) return undefined;\n const { engineCode, values } = error as { engineCode?: unknown; values?: { host?: unknown } };\n if (typeof engineCode !== \"string\" || !Object.hasOwn(ENGINE_CODES, engineCode)) return undefined;\n // The app's reason for a Lightning address it could not read (a browser's CORS) is no reason in a terminal.\n if (engineCode === \"lnurlUnreachable\" && typeof values?.host === \"string\") return new CliError(\"unavailable\", `Could not reach ${values.host}`);\n const details = Object.hasOwn(ENGINE_REASONS, engineCode) ? { reason: ENGINE_REASONS[engineCode] } : undefined;\n // The contact's next step, for a contact that is a bot too.\n if (engineCode === \"contactNoWallet\") return new CliError(\"refused\", `${error.message} (on a CLI: ghostly wallet create cashu)`, details);\n return new CliError(ENGINE_CODES[engineCode], error.message, details);\n}\n\n/** The engine's names of the ways of paying (payments.ts `METHOD_NAME`), as `wallet create` takes them; Bark is the app's only. */\nconst RAILS: Record<string, string | null> = { Cashu: \"cashu\", Lightning: \"lightning\", Ark: \"arkade\", USDT: \"usdt\", Bark: null, \"on-chain Bitcoin\": \"bitcoin\", Fedimint: \"fedimint\", Spark: \"spark\" };\n\n/**\n * A contact with no wallet of the way of paying or the network asked (`chat request --method arkade`, a Mainnet `chat\n * pay` to a contact with Testnet Cashu only): the engine says it in words alone. `refused` with `contact_no_wallet` and\n * the contact's next step, as a contact with no wallet at all is said. Before, `engine`, which a bot may retry.\n */\nfunction contactNoRail(error: unknown): CliError | undefined {\n const said = error instanceof Error ? /^Your contact has no (Mainnet|Testnet) (.+) wallet$/.exec(error.message) : null;\n if (!said || !Object.hasOwn(RAILS, said[2])) return undefined;\n const type = RAILS[said[2]];\n const step = type ? ` (on a CLI: ghostly wallet create ${type}${said[1] === \"Mainnet\" ? \" --network mainnet\" : \"\"})` : \"\";\n return new CliError(\"refused\", `${said[0]}${step}`, { reason: \"contact_no_wallet\" });\n}\n\n/**\n * A change the profile's store could not put on disk (`storage.ts` refuses its transaction with a QuotaExceededError;\n * the engine's `committed` wraps it in its own words, the store's as the cause): `unavailable`, try again once there is\n * room, in the store's words, which name the profile's folder. Before, a daemon on a full disk answered done.\n */\nfunction noRoomError(error: unknown): CliError | undefined {\n let said: string | undefined, found = false;\n for (let at = error, depth = 0; at && typeof at === \"object\" && depth < 4; at = (at as { cause?: unknown }).cause, depth++) {\n if ((at as { name?: unknown }).name !== \"QuotaExceededError\") continue;\n found = true;\n const message = (at as { message?: unknown }).message;\n if (typeof message === \"string\" && message.startsWith(\"No room left\")) said = message;\n }\n return found ? new CliError(\"unavailable\", said ?? \"No room left on the disk: free some space, then try again\") : undefined;\n}\n\n/**\n * The profile's database did not open (the engine's `ProfileOpenError`, packages/browser/src/shared/idb.ts): `engine`\n * (exit 1) with the engine's own words, which name the versions when a newer ghostly stored it, and the reason and\n * the versions in `details` for a bot. Read by its shape: this module is also the thin client's, which loads no engine.\n */\nfunction profileOpenError(error: unknown): CliError | undefined {\n if (!(error instanceof Error) || error.name !== \"ProfileOpenError\") return undefined;\n const failure = (error as { failure?: { reason?: unknown; storedVersion?: unknown; supportedVersion?: unknown } }).failure;\n if (!failure || typeof failure.reason !== \"string\") return undefined;\n return new CliError(\"engine\", error.message, {\n reason: failure.reason === \"newer\" ? \"newer_profile\" : `profile_${failure.reason}`,\n ...(typeof failure.storedVersion === \"number\" ? { storedVersion: failure.storedVersion } : {}),\n ...(typeof failure.supportedVersion === \"number\" ? { supportedVersion: failure.supportedVersion } : {}),\n });\n}\n\n/**\n * A file or folder on this machine the command could not open (`file save --dir`, `profile backup --out`): the\n * person's path, not the engine refusing, so it says so with the code a bot branches on. Before, a folder that did\n * not exist was `engine` (exit 1) with Node's `ENOENT: no such file or directory, open '…'`. `file`: the path read, for\n * an error that names none (a folder read as a file).\n */\nexport function localFileError(error: unknown, file?: string): CliError | undefined {\n if (!error || typeof error !== \"object\" || typeof (error as { syscall?: unknown }).syscall !== \"string\") return undefined;\n const { code, path } = error as { code?: unknown; path?: unknown };\n const where = typeof path === \"string\" ? path : file ?? \"the path\";\n if (code === \"ENOENT\" || code === \"ENOTDIR\") return new CliError(\"not_found\", `No such file or folder: ${where}`);\n // A symbolic link to itself (or a ring of them) leads nowhere: before, Node's raw \"ELOOP: …, stat\" as `engine`.\n if (code === \"ELOOP\") return new CliError(\"not_found\", `No such file or folder: ${where} (its symbolic links go round in a loop)`);\n if (code === \"EACCES\" || code === \"EPERM\" || code === \"EROFS\") return new CliError(\"refused\", `Not allowed to write or read ${where}`);\n if (code === \"EISDIR\") return new CliError(\"bad_request\", `${where} is a folder: name a file`);\n // A file where a folder is to be made (`store sign --out`, `app publish --key`/`--out`): Node's \"EEXIST: file already\n // exists, mkdir '…'\" was `engine`. Named as `file save --dir` names one.\n if (code === \"EEXIST\" && (error as { syscall: string }).syscall === \"mkdir\") return new CliError(\"not_found\", `${where} is a file, not a folder`);\n if (code === \"ENAMETOOLONG\") return new CliError(\"bad_request\", `A name in ${where} is too long for this file system (at most 255 bytes)`);\n // A full disk (or a quota) answered Node's raw \"ENOSPC: no space left on device, write\" as `engine`, naming nothing\n // (agents#1710). `unavailable`: it works again once there is room, with nothing lost.\n if (code === \"ENOSPC\" || code === \"EDQUOT\") {\n const at = typeof path === \"string\" ? path : file;\n return new CliError(\"unavailable\", at ? `No room left for ${at}: free some space, then try again` : \"No room left on the disk: free some space, then try again\", { reason: \"no_space\", errno: code, ...(at && { path: at }) });\n }\n return undefined;\n}\n"],"mappings":";;AAUA,IAAa,OAAkC;CAC7C,QAAQ;CAAG,SAAS;CAAG,aAAa;CAAG,aAAa;CAAG,MAAM;CAAG,UAAU;CAC1E,OAAO;CAAG,WAAW;CAAG,SAAS;CAAG,SAAS;CAAG,aAAa;AAC/D;AAEA,IAAa,WAAb,cAA8B,MAAM;CACb;CAA2C;CAAhE,YAAY,MAA0B,SAAiB,SAA4C;EACjG,MAAM,OAAO;EADM,KAAA,OAAA;EAA2C,KAAA,UAAA;EAE9D,KAAK,OAAO;CACd;CACA,SAAkF;EAChF,OAAO;GAAE,MAAM,KAAK;GAAM,SAAS,KAAK;GAAS,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;EAAG;CACtG;AACF;;AAGA,SAAgB,WAAW,OAA0B;CACnD,IAAI,iBAAiB,UAAU,OAAO;CACtC,IAAI,SAAS,OAAO,UAAU,YAAY,UAAU,SAAS,aAAa,SAAS,OAAQ,MAA4B,SAAS,YAC3H,OAAO,OAAO,MAAO,MAA2B,IAAI,GAAG,OAAO,IAAI,SAAU,MAA8B,MAAM,OAAQ,MAA+B,OAAO,CAAC;CAEpK,IAAI,iBAAiB,SAAU,MAA6B,SAAS,eAAe,OAAO,IAAI,SAAS,eAAe,MAAM,OAAO;CACpI,MAAM,QAAQ,YAAY,KAAK,KAAK,cAAc,KAAK;CACvD,IAAI,OAAO,OAAO;CAClB,MAAM,OAAO,YAAY,KAA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A6D;GAAE,QAAQ;GAAY,OAAO;GAAM,GAAI,MAAM,EAAE,MAAM,GAAG;EAAG,CAAC;CAC/N;AAEF"}
@@ -1,7 +1,7 @@
1
- import { yd as stripHidden } from "./src-DJe-OYxd.js";
2
- //#region ../browser/src/engine/paymentAdapters/fedimintSdk.ts
1
+ import { a as stripHidden } from "./text-li76pThX.js";
2
+ // ../browser/src/engine/paymentAdapters/fedimintSdk.ts
3
3
  var fedimintDatabase = (id) => `ghostly-fedimint-${id}.db`;
4
- var MODULE_WASM = () => import("./fedimint_client_wasm_bg-BtHHlFpp.js");
4
+ var MODULE_WASM = () => import("./fedimint_client_wasm_bg-Cr5xGD-w.js");
5
5
  /** The SDK checks it with an assert: any other length kills the worker. One client per database, always this name. */
6
6
  var CLIENT_NAME = "dd5135b2-c228-41b7-a4f9-3b6e7afe3088";
7
7
  var NETWORKS = {
@@ -346,7 +346,6 @@ async function fedimintSdkOn(platform) {
346
346
  };
347
347
  return sdk;
348
348
  }
349
- //#endregion
350
349
  export { fedimintSdkOn as n, loadFedimintSdk as r, fedimintDatabase as t };
351
350
 
352
- //# sourceMappingURL=fedimintSdk-CPFfVK-G.js.map
351
+ //# sourceMappingURL=fedimintSdk-D-6H9Pe7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fedimintSdk-CPFfVK-G.js","names":[],"sources":["../../../browser/src/engine/paymentAdapters/fedimintSdk.ts"],"sourcesContent":["import { stripHidden, type BitcoinNetwork } from \"@ghostly/core\";\n\n/**\n * The part of the Fedimint web SDK (`@fedimint/core`, WebAssembly client in a worker) Ghostly uses, behind an\n * interface small enough to fake in tests. The client runs in a worker, on a file it reads and writes through a sync\n * access handle: in a browser, a module worker and the origin-private file system; on Node, the CLI's\n * `worker_threads` worker and a file of the profile (`FedimintPlatform`).\n *\n * One client database per joined federation (`ghostly-fedimint-<id>.db`, one file): the SDK's services are bound to one client per database, and each database is held by one worker.\n * Every database of a profile and mode is given the same mnemonic; the client derives a different secret per\n * federation from it. Amounts are millisatoshis, as the SDK counts them.\n */\nexport interface FederationGuardian { name: string; url: string }\nexport interface FederationInfo {\n federationId: string;\n /** `meta.federation_name`, when the guardians set one. */\n name?: string;\n guardians: FederationGuardian[];\n /** Core consensus version, `major.minor`. */\n consensusVersion: string;\n /** The Bitcoin network of its wallet module. Unknown when the federation has no v1 wallet module. */\n network?: BitcoinNetwork;\n /** Module kinds (`mint`, `ln`, `wallet`, `meta`…). The SDK uses `mint`, `ln` and `wallet` (v1). */\n modules: string[];\n /** `meta.welcome_message`, shortened. */\n welcome?: string;\n}\n\n/** Out-of-band notes, parsed offline (signatures and prefix only: whether they are spent is the federation's to say). */\nexport interface ParsedNotes { amountMsats: number; federationIdPrefix: string; federationId?: string }\n\n/** Where a spend of notes stands. `canceled` = taken back (reissued to us); `taken` = the recipient redeemed them. */\nexport type SpendState = \"created\" | \"canceling\" | \"canceled\" | \"taken\" | \"refunded\";\n/** A redeem (reissue) of notes we were given. */\nexport type RedeemState = \"created\" | \"issuing\" | \"done\" | \"failed\";\nexport type ReceiveState = \"open\" | \"funded\" | \"claimed\" | \"canceled\";\nexport interface PayOutcome { state: \"pending\" | \"paid\" | \"failed\"; preimage?: string; error?: string }\n\nexport interface FedimintOperation {\n id: string;\n /** Module: `mint`, `ln`, `wallet`. */\n kind: string;\n /** What it was: `spend_oob`, `reissuance`, `receive`, `pay`… as the SDK names it. */\n variant?: string;\n createdAt: number;\n amountMsats?: number;\n /** The SDK's final outcome, once there is one. */\n outcome?: unknown;\n /** What Ghostly asked to be kept with it (`extra_meta`): the payment id it belongs to. */\n ghostly?: string;\n /** Lightning: the invoice it paid or was paid on, and the fee it paid (msats). */\n invoice?: string;\n feeMsats?: number;\n}\n\nexport interface FedimintClient {\n readonly federationId: string;\n info(): Promise<FederationInfo>;\n balance(): Promise<number>;\n /** Called with every new balance, until the returned function is called. */\n onBalance(listener: (msats: number) => void): () => void;\n parseNotes(notes: string): Promise<ParsedNotes>;\n /** Takes notes out of the wallet, as a bearer string. Unredeemed after `cancelAfterSecs`, they come back by themselves. */\n spend(amountMsats: number, options: { cancelAfterSecs: number; ghostly: string }): Promise<{ notes: string; operationId: string }>;\n /** Asks to take notes back: they are reissued to us unless the recipient redeemed them first. */\n cancelSpend(operationId: string): Promise<void>;\n /** The latest state within `waitMs` (it returns early on a final one). Undefined: the client knows no such operation. */\n spendState(operationId: string, waitMs: number): Promise<SpendState | undefined>;\n redeem(notes: string, ghostly: string): Promise<string>;\n /** Rejects when the client could not say (its error is not the reissue's `Failed`). */\n redeemState(operationId: string, waitMs: number): Promise<RedeemState | undefined>;\n createInvoice(amountMsats: number, description: string, expirySecs: number, ghostly: string): Promise<{ operationId: string; invoice: string }>;\n receiveState(operationId: string, waitMs: number): Promise<ReceiveState | undefined>;\n /** What the federation's gateway would charge to pay this amount, in msats. Undefined: no gateway. */\n gatewayFee(amountMsats: number): Promise<number | undefined>;\n payInvoice(invoice: string, ghostly: string): Promise<{ operationId: string; feeMsats: number; internal: boolean }>;\n payState(operationId: string, internal: boolean, waitMs: number): Promise<PayOutcome>;\n operations(limit: number): Promise<FedimintOperation[]>;\n /** Ends the worker; the database stays. */\n close(): Promise<void>;\n}\n\nexport interface FedimintSdk {\n preview(invite: string): Promise<FederationInfo>;\n /** Joins (or, `recover`, restores from the federation's backup of this mnemonic) into a new database. */\n join(params: { database: string; mnemonic: string; invite: string; recover: boolean }): Promise<FedimintClient>;\n /** Opens a database joined before. */\n open(params: { database: string; mnemonic: string }): Promise<FedimintClient>;\n /** Deletes a database: only one that never held money (a failed join). */\n remove(database: string): Promise<void>;\n /** Whether this device has the database (a profile restored from a backup has the records, not the files). */\n exists(database: string): Promise<boolean>;\n}\n\nexport const fedimintDatabase = (id: string) => `ghostly-fedimint-${id}.db`;\n\n// ── The real SDK ───────────────────────────────────────────────────────────────────────────────────────────\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json };\nconst MODULE_WASM = () => import(\"@fedimint/fedimint-client-wasm-bundler/fedimint_client_wasm_bg.wasm?url\");\n/** The SDK checks it with an assert: any other length kills the worker. One client per database, always this name. */\nconst CLIENT_NAME = \"dd5135b2-c228-41b7-a4f9-3b6e7afe3088\";\nconst NETWORKS: Record<string, BitcoinNetwork> = { bitcoin: \"bitcoin\", signet: \"signet\", testnet: \"testnet\", testnet4: \"testnet\", regtest: \"regtest\", mutinynet: \"mutinynet\" };\n/**\n * A v1 wallet (or Lightning) module's client config comes consensus-encoded as hex (`config` from a joined client,\n * `unknown_module_hex` in a preview); its network is the chain's magic, a u32 as a compact-size integer (`fe` +\n * four bytes, little-endian). Exactly one network must be found, or it stays unknown.\n */\nconst MAGIC: [string, BitcoinNetwork][] = [[\"fed9b4bef9\", \"bitcoin\"], [\"fe0709110b\", \"testnet\"], [\"fe283f161c\", \"testnet\"], [\"fe40cf030a\", \"signet\"], [\"fecb2ddfa5\", \"mutinynet\"], [\"fedab5bffa\", \"regtest\"]];\nfunction moduleNetwork(module: { network?: unknown; config?: unknown; unknown_module_hex?: unknown }): BitcoinNetwork | undefined {\n if (typeof module.network === \"string\") return NETWORKS[module.network];\n const encoded = typeof module.config === \"string\" ? module.config : module.unknown_module_hex;\n if (typeof encoded !== \"string\" || !/^[0-9a-f]*$/i.test(encoded)) return undefined;\n const hex = encoded.toLowerCase();\n const found = [...new Set(MAGIC.filter(([magic]) => hex.includes(magic)).map(([, network]) => network))];\n return found.length === 1 ? found[0] : undefined;\n}\nconst hex = (value: unknown) => typeof value === \"string\" ? value : Array.isArray(value) ? value.map((b) => Number(b).toString(16).padStart(2, \"0\")).join(\"\") : undefined;\n\nlet compiling: Promise<WebAssembly.Module> | undefined;\n/** Compiled once per page (11 MB): each worker is handed the module, not the bytes. */\nfunction compiled(): Promise<WebAssembly.Module> {\n return compiling ??= (async () => {\n const url = (await MODULE_WASM()).default;\n const response = await fetch(url);\n // A server that sends the wrong MIME type cannot stream: compile from the bytes instead.\n try { return await WebAssembly.compileStreaming(response.clone()); } catch { return WebAssembly.compile(await response.arrayBuffer()); }\n })().catch((error) => { compiling = undefined; throw error; });\n}\n\n/** A transport of `@fedimint/core` onto our own worker (fedimintWorker.ts). */\nasync function browserTransport() {\n const [{ Transport }, module] = await Promise.all([import(\"@fedimint/types\"), compiled()]);\n class WorkerTransport extends Transport {\n readonly logger = { debug() {}, info() {}, warn() {}, error() {} };\n private readonly worker = new Worker(new URL(\"./fedimintWorker.ts\", import.meta.url), { type: \"module\" });\n constructor() {\n super();\n this.worker.onmessage = (event) => this.messageHandler(event.data);\n this.worker.onerror = (event) => { event.preventDefault(); this.messageHandler({ type: \"error\", error: `The Fedimint client stopped: ${event.message || \"unknown error\"}` }); };\n }\n postMessage(message: { type: string; payload?: Json; requestId?: number }) {\n // The worker gets the compiled module with its init, and nothing to log.\n this.worker.postMessage(message.type === \"init\" ? { ...message, payload: { ...(message.payload as object), module } } : message);\n }\n terminate() { this.worker.terminate(); }\n }\n return new WorkerTransport();\n}\n\nconst text = (value: unknown, max = 200) => typeof value === \"string\" ? value.slice(0, max) : undefined;\n/** A federation's or a guardian's name: without the characters that hide text or reorder it, so it reads as what it is. */\nconst name = (value: unknown, max: number) => typeof value === \"string\" ? text(stripHidden(value).replace(/\\s+/g, \" \").trim(), max) : undefined;\nconst errorText = (error: unknown) => error instanceof Error ? error.message : typeof error === \"string\" ? error : JSON.stringify(error);\n\nexport function federationInfo(federationId: string, config: unknown): FederationInfo {\n const c = config as { global?: { api_endpoints?: Record<string, { url?: unknown; name?: unknown }>; consensus_version?: { major?: unknown; minor?: unknown }; meta?: Record<string, unknown> }; modules?: Record<string, { kind?: unknown; network?: unknown; config?: unknown; unknown_module_hex?: unknown }> };\n const endpoints = Object.entries(c?.global?.api_endpoints ?? {}).sort(([a], [b]) => Number(a) - Number(b));\n const modules = Object.values(c?.modules ?? {});\n // The wallet module says it; a federation without one (Lightning and ecash only) says it through its Lightning module.\n const network = modules.filter((m) => m?.kind === \"wallet\").map(moduleNetwork).find(Boolean) ?? modules.filter((m) => m?.kind === \"ln\").map(moduleNetwork).find(Boolean);\n const version = c?.global?.consensus_version;\n return {\n federationId,\n name: name(c?.global?.meta?.federation_name, 80) || undefined,\n guardians: endpoints.slice(0, 64).map(([peer, e]) => ({ name: name(e?.name, 80) || `Guardian ${peer}`, url: text(e?.url, 300) ?? \"\" })),\n consensusVersion: `${Number(version?.major ?? 0)}.${Number(version?.minor ?? 0)}`,\n network,\n modules: [...new Set(modules.map((m) => (typeof m?.kind === \"string\" ? m.kind.slice(0, 32) : \"\")).filter(Boolean))],\n welcome: text(c?.global?.meta?.welcome_message, 280),\n };\n}\n\n/** The first value a subscription gives that is final, or the last one within `waitMs`. */\nfunction watch<S>(subscribe: (onState: (state: S) => void, onError: (error: string) => void) => () => void, final: (state: S) => boolean, waitMs: number): Promise<S | undefined> {\n return new Promise((resolve) => {\n let last: S | undefined, done = false, cancel: () => void = () => {};\n const finish = () => { if (done) return; done = true; clearTimeout(timer); cancel(); resolve(last); };\n const timer = setTimeout(finish, waitMs);\n cancel = subscribe((state) => { last = state; if (final(state)) finish(); }, () => finish());\n });\n}\n\nconst SPEND: Record<string, SpendState> = { Created: \"created\", UserCanceledProcessing: \"canceling\", UserCanceledSuccess: \"canceled\", UserCanceledFailure: \"taken\", Success: \"taken\", Refunded: \"refunded\" };\nconst spendFinal = (s: SpendState) => s === \"canceled\" || s === \"taken\" || s === \"refunded\";\nconst REDEEM: Record<string, RedeemState> = { Created: \"created\", Issuing: \"issuing\", Done: \"done\" };\nconst receiveOf = (s: unknown): ReceiveState => s === \"claimed\" ? \"claimed\" : s === \"funded\" || s === \"awaiting_funds\" ? \"funded\" : typeof s === \"object\" && s && \"canceled\" in s ? \"canceled\" : \"open\";\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- the SDK's own types are loose unions of JSON; this is where they are narrowed. */\nclass RealClient implements FedimintClient {\n constructor(readonly federationId: string, private wallet: any, private director: any, private end: () => void) {}\n async info() { return federationInfo(this.federationId, await this.wallet.federation.getConfig()); }\n balance(): Promise<number> { return this.wallet.balance.getBalance(); }\n onBalance(listener: (msats: number) => void) { return this.wallet.balance.subscribeBalance(listener, () => {}); }\n async parseNotes(notes: string): Promise<ParsedNotes> {\n const parsed = await this.director.parseOobNotes(notes);\n return { amountMsats: Number(parsed.total_amount), federationIdPrefix: String(parsed.federation_id_prefix), federationId: parsed.federation_id ?? undefined };\n }\n async spend(amountMsats: number, { cancelAfterSecs, ghostly }: { cancelAfterSecs: number; ghostly: string }) {\n const { notes, operation_id } = await this.wallet.mint.spendNotes(amountMsats, cancelAfterSecs, false, { ghostly });\n return { notes: String(notes), operationId: String(operation_id) };\n }\n cancelSpend(operationId: string): Promise<void> { return this.wallet.mint.tryCancelSpendNotes(operationId); }\n spendState(operationId: string, waitMs: number) {\n return watch<SpendState>((ok, fail) => this.wallet.mint.subscribeSpendNotes(operationId, (s: string) => ok(SPEND[s] ?? \"created\"), fail), spendFinal, waitMs);\n }\n redeem(notes: string, ghostly: string): Promise<string> { return this.wallet.mint.reissueExternalNotes(notes, { ghostly }); }\n async redeemState(operationId: string, waitMs: number) {\n let error: unknown;\n const state = await watch<RedeemState>((ok, fail) => this.wallet.mint.subscribeReissueExternalNotes(operationId, (s: unknown) => ok(typeof s === \"string\" ? REDEEM[s] ?? \"created\" : s && typeof s === \"object\" && \"Failed\" in s ? \"failed\" : \"created\"), (e: string) => { error ??= e; fail(e); }), (s) => s === \"done\" || s === \"failed\", waitMs);\n // Only the reissue's own `Failed` is failed: an error of the client or its subscription says nothing of the notes.\n if (error !== undefined && state !== \"done\" && state !== \"failed\") throw new Error(`The Fedimint client could not say how the redeem stands: ${errorText(error)}`);\n return state;\n }\n async createInvoice(amountMsats: number, description: string, expirySecs: number, ghostly: string) {\n const { operation_id, invoice } = await this.wallet.lightning.createInvoice(amountMsats, description, expirySecs, undefined, { ghostly });\n return { operationId: String(operation_id), invoice: String(invoice) };\n }\n receiveState(operationId: string, waitMs: number) {\n return watch<ReceiveState>((ok, fail) => this.wallet.lightning.subscribeLnReceive(operationId, (s: unknown) => ok(receiveOf(s)), fail), (s) => s === \"claimed\" || s === \"canceled\", waitMs);\n }\n async gatewayFee(amountMsats: number) {\n await this.wallet.lightning.updateGatewayCache().catch(() => {});\n const gateway = await this.wallet.lightning.getAvailableGateway().catch(() => null);\n const fees = gateway?.fees;\n if (!fees) return undefined;\n return Number(fees.base_msat ?? 0) + Math.ceil(amountMsats * Number(fees.proportional_millionths ?? 0) / 1_000_000);\n }\n async payInvoice(invoice: string, ghostly: string) {\n const paid = await this.wallet.lightning.payInvoice(invoice, undefined, { ghostly });\n const internal = \"internal\" in paid.payment_type;\n return { operationId: String(internal ? paid.payment_type.internal : paid.payment_type.lightning), feeMsats: Number(paid.fee ?? 0), internal };\n }\n async payState(operationId: string, internal: boolean, waitMs: number): Promise<PayOutcome> {\n const state = await watch<unknown>((ok, fail) => internal ? this.wallet.lightning.subscribeInternalPayment(operationId, ok, fail) : this.wallet.lightning.subscribeLnPay(operationId, ok, fail),\n (s) => typeof s === \"object\" && !!s && (\"success\" in s || \"preimage\" in s || \"refunded\" in s || \"refund_success\" in s || \"unexpected_error\" in s || \"funding_failed\" in s) || s === \"canceled\", waitMs);\n if (state && typeof state === \"object\") {\n const s = state as Record<string, any>;\n // A payment out through the gateway ends in `success`; one to the same federation (internal) in `preimage` (bytes).\n if (s.success?.preimage || s.preimage) return { state: \"paid\", preimage: hex(s.success?.preimage ?? s.preimage) };\n if (\"refunded\" in s || \"refund_success\" in s || \"funding_failed\" in s) return { state: \"failed\", error: errorText(s.refunded?.gateway_error ?? s.funding_failed?.error ?? \"The gateway gave the payment back\") };\n if (\"unexpected_error\" in s) return { state: \"pending\", error: errorText(s.unexpected_error) };\n }\n if (state === \"canceled\") return { state: \"failed\", error: \"Canceled before it was funded\" };\n return { state: \"pending\" };\n }\n async operations(limit: number): Promise<FedimintOperation[]> {\n const list: [{ creation_time?: { secs_since_epoch?: number }; operation_id?: string }, { operation_module_kind?: string; meta?: any; outcome?: any }][] = await this.wallet.federation.listOperations(limit);\n return list.map(([key, log]) => {\n const variant = log.meta?.variant && typeof log.meta.variant === \"object\" ? Object.keys(log.meta.variant)[0] : undefined;\n const detail = variant ? log.meta.variant[variant] : undefined;\n return {\n id: String(key.operation_id ?? \"\"), kind: String(log.operation_module_kind ?? \"\"), variant,\n createdAt: Number(key.creation_time?.secs_since_epoch ?? 0) * 1000,\n amountMsats: typeof log.meta?.amount === \"number\" ? log.meta.amount : typeof detail?.requested_amount === \"number\" ? detail.requested_amount : undefined,\n outcome: log.outcome?.outcome, ghostly: typeof log.meta?.extra_meta?.ghostly === \"string\" ? log.meta.extra_meta.ghostly : undefined,\n invoice: typeof detail?.invoice === \"string\" ? detail.invoice : undefined,\n feeMsats: typeof detail?.fee === \"number\" ? detail.fee : undefined,\n };\n });\n }\n async close() { try { await this.wallet.cleanup(); } catch { /* already gone */ } this.end(); }\n}\n\n/**\n * Where the client runs: a worker per database, and the files the databases are. The browser's is a module worker on\n * the origin-private file system (below); a headless Ghostly on Node brings its own (packages/cli/src/runtime/fedimint.ts).\n */\nexport interface FedimintPlatform {\n /** A `@fedimint/types` Transport onto a new worker of its own, which one database will be opened in. */\n transport(): Promise<{ terminate(): void }>;\n exists(database: string): Promise<boolean>;\n /** Deletes a database, and is done when there is none. */\n remove(database: string): Promise<void>;\n}\n\nconst BROWSER: FedimintPlatform = {\n transport: browserTransport,\n async exists(database) {\n const root = await navigator.storage.getDirectory();\n try { const file = await (await root.getFileHandle(database)).getFile(); return file.size > 0; } catch { return false; }\n },\n async remove(database) {\n const root = await navigator.storage.getDirectory();\n await root.removeEntry(database).catch((error: unknown) => { if ((error as { name?: string })?.name !== \"NotFoundError\") throw error; });\n },\n};\n\nlet loading: Promise<FedimintSdk> | undefined;\n/** Loads the SDK on first use: profiles that never join a federation never fetch its 11 MB. */\nexport function loadFedimintSdk(): Promise<FedimintSdk> {\n return loading ??= fedimintSdkOn(BROWSER).catch((error) => { loading = undefined; throw error; });\n}\n\n/** The SDK on a platform's workers and files. */\nexport async function fedimintSdkOn(platform: FedimintPlatform): Promise<FedimintSdk> {\n const { WalletDirector } = await import(\"@fedimint/core\");\n /** A director on its own worker and database, with the mnemonic in place. */\n const director = async (database: string, mnemonic?: string) => {\n const t = await platform.transport();\n const d = new WalletDirector(t as any, database, true);\n try {\n await d.initialize(database);\n if (mnemonic && !(await d.hasMnemonicSet())) await d.setMnemonic(mnemonic.trim().split(/\\s+/));\n return { director: d, end: () => t.terminate() };\n } catch (error) { t.terminate(); throw error; }\n };\n const client = async (database: string, mnemonic: string, start: (wallet: any) => Promise<void>) => {\n const { director: d, end } = await director(database, mnemonic);\n try {\n const wallet = await d.createWallet();\n await start(wallet);\n return new RealClient(await wallet.federation.getFederationId(), wallet, d, end);\n } catch (error) { end(); throw error; }\n };\n const sdk: FedimintSdk = {\n async preview(invite) {\n // A scratch database of its own: previewing joins nothing.\n const database = fedimintDatabase(`preview-${crypto.randomUUID()}`);\n const { director: d, end } = await director(database);\n try { const preview = await d.previewFederation(invite.trim()); return federationInfo(preview.federation_id, preview.config); }\n finally { end(); await sdk.remove(database).catch(() => {}); }\n },\n join: ({ database, mnemonic, invite, recover }) => client(database, mnemonic, async (wallet) => {\n // joinFederation says false instead of throwing; its reason goes to the (silenced) logger.\n if (!(await wallet.joinFederation(invite.trim(), { clientName: CLIENT_NAME, forceRecover: recover }))) throw new Error(\"Could not join the federation: its guardians did not answer, or the invite code is not valid\");\n }),\n open: ({ database, mnemonic }) => client(database, mnemonic, (wallet) => wallet.open(CLIENT_NAME)),\n exists: (database) => platform.exists(database),\n remove: (database) => platform.remove(database),\n };\n return sdk;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"],"mappings":";;AA8FA,IAAa,oBAAoB,OAAe,oBAAoB,GAAG;AAKvE,IAAM,oBAAoB,OAAO;;AAEjC,IAAM,cAAc;AACpB,IAAM,WAA2C;CAAE,SAAS;CAAW,QAAQ;CAAU,SAAS;CAAW,UAAU;CAAW,SAAS;CAAW,WAAW;AAAY;;;;;;AAM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OAAO,KAAK,CAAC;IAAG,OAAO,eAAe,QAAQ,eAAe,QAAQ,MAAM;GAAG,UACtH;IAAE,IAAI;IAAG,MAAM,IAAI,OAAO,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;GAAG;EAC/D;EACA,OAAO,EAAE,UAAU,UAAU,QAAQ,cAAc,OAAO,UAAU,UAAU,OAAO,WAAW;GAE9F,IAAI,CAAE,MAAM,OAAO,eAAe,OAAO,KAAK,GAAG;IAAE,YAAY;IAAa,cAAc;GAAQ,CAAC,GAAI,MAAM,IAAI,MAAM,8FAA8F;EACvN,CAAC;EACD,OAAO,EAAE,UAAU,eAAe,OAAO,UAAU,WAAW,WAAW,OAAO,KAAK,WAAW,CAAC;EACjG,SAAS,aAAa,SAAS,OAAO,QAAQ;EAC9C,SAAS,aAAa,SAAS,OAAO,QAAQ;CAChD;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"fedimintSdk-D-6H9Pe7.js","names":[],"sources":["../../../browser/src/engine/paymentAdapters/fedimintSdk.ts"],"sourcesContent":["import { stripHidden, type BitcoinNetwork } from \"@ghostly/core\";\n\n/**\n * The part of the Fedimint web SDK (`@fedimint/core`, WebAssembly client in a worker) Ghostly uses, behind an\n * interface small enough to fake in tests. The client runs in a worker, on a file it reads and writes through a sync\n * access handle: in a browser, a module worker and the origin-private file system; on Node, the CLI's\n * `worker_threads` worker and a file of the profile (`FedimintPlatform`).\n *\n * One client database per joined federation (`ghostly-fedimint-<id>.db`, one file): the SDK's services are bound to one client per database, and each database is held by one worker.\n * Every database of a profile and mode is given the same mnemonic; the client derives a different secret per\n * federation from it. Amounts are millisatoshis, as the SDK counts them.\n */\nexport interface FederationGuardian { name: string; url: string }\nexport interface FederationInfo {\n federationId: string;\n /** `meta.federation_name`, when the guardians set one. */\n name?: string;\n guardians: FederationGuardian[];\n /** Core consensus version, `major.minor`. */\n consensusVersion: string;\n /** The Bitcoin network of its wallet module. Unknown when the federation has no v1 wallet module. */\n network?: BitcoinNetwork;\n /** Module kinds (`mint`, `ln`, `wallet`, `meta`…). The SDK uses `mint`, `ln` and `wallet` (v1). */\n modules: string[];\n /** `meta.welcome_message`, shortened. */\n welcome?: string;\n}\n\n/** Out-of-band notes, parsed offline (signatures and prefix only: whether they are spent is the federation's to say). */\nexport interface ParsedNotes { amountMsats: number; federationIdPrefix: string; federationId?: string }\n\n/** Where a spend of notes stands. `canceled` = taken back (reissued to us); `taken` = the recipient redeemed them. */\nexport type SpendState = \"created\" | \"canceling\" | \"canceled\" | \"taken\" | \"refunded\";\n/** A redeem (reissue) of notes we were given. */\nexport type RedeemState = \"created\" | \"issuing\" | \"done\" | \"failed\";\nexport type ReceiveState = \"open\" | \"funded\" | \"claimed\" | \"canceled\";\nexport interface PayOutcome { state: \"pending\" | \"paid\" | \"failed\"; preimage?: string; error?: string }\n\nexport interface FedimintOperation {\n id: string;\n /** Module: `mint`, `ln`, `wallet`. */\n kind: string;\n /** What it was: `spend_oob`, `reissuance`, `receive`, `pay`… as the SDK names it. */\n variant?: string;\n createdAt: number;\n amountMsats?: number;\n /** The SDK's final outcome, once there is one. */\n outcome?: unknown;\n /** What Ghostly asked to be kept with it (`extra_meta`): the payment id it belongs to. */\n ghostly?: string;\n /** Lightning: the invoice it paid or was paid on, and the fee it paid (msats). */\n invoice?: string;\n feeMsats?: number;\n}\n\nexport interface FedimintClient {\n readonly federationId: string;\n info(): Promise<FederationInfo>;\n balance(): Promise<number>;\n /** Called with every new balance, until the returned function is called. */\n onBalance(listener: (msats: number) => void): () => void;\n parseNotes(notes: string): Promise<ParsedNotes>;\n /** Takes notes out of the wallet, as a bearer string. Unredeemed after `cancelAfterSecs`, they come back by themselves. */\n spend(amountMsats: number, options: { cancelAfterSecs: number; ghostly: string }): Promise<{ notes: string; operationId: string }>;\n /** Asks to take notes back: they are reissued to us unless the recipient redeemed them first. */\n cancelSpend(operationId: string): Promise<void>;\n /** The latest state within `waitMs` (it returns early on a final one). Undefined: the client knows no such operation. */\n spendState(operationId: string, waitMs: number): Promise<SpendState | undefined>;\n redeem(notes: string, ghostly: string): Promise<string>;\n /** Rejects when the client could not say (its error is not the reissue's `Failed`). */\n redeemState(operationId: string, waitMs: number): Promise<RedeemState | undefined>;\n createInvoice(amountMsats: number, description: string, expirySecs: number, ghostly: string): Promise<{ operationId: string; invoice: string }>;\n receiveState(operationId: string, waitMs: number): Promise<ReceiveState | undefined>;\n /** What the federation's gateway would charge to pay this amount, in msats. Undefined: no gateway. */\n gatewayFee(amountMsats: number): Promise<number | undefined>;\n payInvoice(invoice: string, ghostly: string): Promise<{ operationId: string; feeMsats: number; internal: boolean }>;\n payState(operationId: string, internal: boolean, waitMs: number): Promise<PayOutcome>;\n operations(limit: number): Promise<FedimintOperation[]>;\n /** Ends the worker; the database stays. */\n close(): Promise<void>;\n}\n\nexport interface FedimintSdk {\n preview(invite: string): Promise<FederationInfo>;\n /** Joins (or, `recover`, restores from the federation's backup of this mnemonic) into a new database. */\n join(params: { database: string; mnemonic: string; invite: string; recover: boolean }): Promise<FedimintClient>;\n /** Opens a database joined before. */\n open(params: { database: string; mnemonic: string }): Promise<FedimintClient>;\n /** Deletes a database: only one that never held money (a failed join). */\n remove(database: string): Promise<void>;\n /** Whether this device has the database (a profile restored from a backup has the records, not the files). */\n exists(database: string): Promise<boolean>;\n}\n\nexport const fedimintDatabase = (id: string) => `ghostly-fedimint-${id}.db`;\n\n// ── The real SDK ───────────────────────────────────────────────────────────────────────────────────────────\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json };\nconst MODULE_WASM = () => import(\"@fedimint/fedimint-client-wasm-bundler/fedimint_client_wasm_bg.wasm?url\");\n/** The SDK checks it with an assert: any other length kills the worker. One client per database, always this name. */\nconst CLIENT_NAME = \"dd5135b2-c228-41b7-a4f9-3b6e7afe3088\";\nconst NETWORKS: Record<string, BitcoinNetwork> = { bitcoin: \"bitcoin\", signet: \"signet\", testnet: \"testnet\", testnet4: \"testnet\", regtest: \"regtest\", mutinynet: \"mutinynet\" };\n/**\n * A v1 wallet (or Lightning) module's client config comes consensus-encoded as hex (`config` from a joined client,\n * `unknown_module_hex` in a preview); its network is the chain's magic, a u32 as a compact-size integer (`fe` +\n * four bytes, little-endian). Exactly one network must be found, or it stays unknown.\n */\nconst MAGIC: [string, BitcoinNetwork][] = [[\"fed9b4bef9\", \"bitcoin\"], [\"fe0709110b\", \"testnet\"], [\"fe283f161c\", \"testnet\"], [\"fe40cf030a\", \"signet\"], [\"fecb2ddfa5\", \"mutinynet\"], [\"fedab5bffa\", \"regtest\"]];\nfunction moduleNetwork(module: { network?: unknown; config?: unknown; unknown_module_hex?: unknown }): BitcoinNetwork | undefined {\n if (typeof module.network === \"string\") return NETWORKS[module.network];\n const encoded = typeof module.config === \"string\" ? module.config : module.unknown_module_hex;\n if (typeof encoded !== \"string\" || !/^[0-9a-f]*$/i.test(encoded)) return undefined;\n const hex = encoded.toLowerCase();\n const found = [...new Set(MAGIC.filter(([magic]) => hex.includes(magic)).map(([, network]) => network))];\n return found.length === 1 ? found[0] : undefined;\n}\nconst hex = (value: unknown) => typeof value === \"string\" ? value : Array.isArray(value) ? value.map((b) => Number(b).toString(16).padStart(2, \"0\")).join(\"\") : undefined;\n\nlet compiling: Promise<WebAssembly.Module> | undefined;\n/** Compiled once per page (11 MB): each worker is handed the module, not the bytes. */\nfunction compiled(): Promise<WebAssembly.Module> {\n return compiling ??= (async () => {\n const url = (await MODULE_WASM()).default;\n const response = await fetch(url);\n // A server that sends the wrong MIME type cannot stream: compile from the bytes instead.\n try { return await WebAssembly.compileStreaming(response.clone()); } catch { return WebAssembly.compile(await response.arrayBuffer()); }\n })().catch((error) => { compiling = undefined; throw error; });\n}\n\n/** A transport of `@fedimint/core` onto our own worker (fedimintWorker.ts). */\nasync function browserTransport() {\n const [{ Transport }, module] = await Promise.all([import(\"@fedimint/types\"), compiled()]);\n class WorkerTransport extends Transport {\n readonly logger = { debug() {}, info() {}, warn() {}, error() {} };\n private readonly worker = new Worker(new URL(\"./fedimintWorker.ts\", import.meta.url), { type: \"module\" });\n constructor() {\n super();\n this.worker.onmessage = (event) => this.messageHandler(event.data);\n this.worker.onerror = (event) => { event.preventDefault(); this.messageHandler({ type: \"error\", error: `The Fedimint client stopped: ${event.message || \"unknown error\"}` }); };\n }\n postMessage(message: { type: string; payload?: Json; requestId?: number }) {\n // The worker gets the compiled module with its init, and nothing to log.\n this.worker.postMessage(message.type === \"init\" ? { ...message, payload: { ...(message.payload as object), module } } : message);\n }\n terminate() { this.worker.terminate(); }\n }\n return new WorkerTransport();\n}\n\nconst text = (value: unknown, max = 200) => typeof value === \"string\" ? value.slice(0, max) : undefined;\n/** A federation's or a guardian's name: without the characters that hide text or reorder it, so it reads as what it is. */\nconst name = (value: unknown, max: number) => typeof value === \"string\" ? text(stripHidden(value).replace(/\\s+/g, \" \").trim(), max) : undefined;\nconst errorText = (error: unknown) => error instanceof Error ? error.message : typeof error === \"string\" ? error : JSON.stringify(error);\n\nexport function federationInfo(federationId: string, config: unknown): FederationInfo {\n const c = config as { global?: { api_endpoints?: Record<string, { url?: unknown; name?: unknown }>; consensus_version?: { major?: unknown; minor?: unknown }; meta?: Record<string, unknown> }; modules?: Record<string, { kind?: unknown; network?: unknown; config?: unknown; unknown_module_hex?: unknown }> };\n const endpoints = Object.entries(c?.global?.api_endpoints ?? {}).sort(([a], [b]) => Number(a) - Number(b));\n const modules = Object.values(c?.modules ?? {});\n // The wallet module says it; a federation without one (Lightning and ecash only) says it through its Lightning module.\n const network = modules.filter((m) => m?.kind === \"wallet\").map(moduleNetwork).find(Boolean) ?? modules.filter((m) => m?.kind === \"ln\").map(moduleNetwork).find(Boolean);\n const version = c?.global?.consensus_version;\n return {\n federationId,\n name: name(c?.global?.meta?.federation_name, 80) || undefined,\n guardians: endpoints.slice(0, 64).map(([peer, e]) => ({ name: name(e?.name, 80) || `Guardian ${peer}`, url: text(e?.url, 300) ?? \"\" })),\n consensusVersion: `${Number(version?.major ?? 0)}.${Number(version?.minor ?? 0)}`,\n network,\n modules: [...new Set(modules.map((m) => (typeof m?.kind === \"string\" ? m.kind.slice(0, 32) : \"\")).filter(Boolean))],\n welcome: text(c?.global?.meta?.welcome_message, 280),\n };\n}\n\n/** The first value a subscription gives that is final, or the last one within `waitMs`. */\nfunction watch<S>(subscribe: (onState: (state: S) => void, onError: (error: string) => void) => () => void, final: (state: S) => boolean, waitMs: number): Promise<S | undefined> {\n return new Promise((resolve) => {\n let last: S | undefined, done = false, cancel: () => void = () => {};\n const finish = () => { if (done) return; done = true; clearTimeout(timer); cancel(); resolve(last); };\n const timer = setTimeout(finish, waitMs);\n cancel = subscribe((state) => { last = state; if (final(state)) finish(); }, () => finish());\n });\n}\n\nconst SPEND: Record<string, SpendState> = { Created: \"created\", UserCanceledProcessing: \"canceling\", UserCanceledSuccess: \"canceled\", UserCanceledFailure: \"taken\", Success: \"taken\", Refunded: \"refunded\" };\nconst spendFinal = (s: SpendState) => s === \"canceled\" || s === \"taken\" || s === \"refunded\";\nconst REDEEM: Record<string, RedeemState> = { Created: \"created\", Issuing: \"issuing\", Done: \"done\" };\nconst receiveOf = (s: unknown): ReceiveState => s === \"claimed\" ? \"claimed\" : s === \"funded\" || s === \"awaiting_funds\" ? \"funded\" : typeof s === \"object\" && s && \"canceled\" in s ? \"canceled\" : \"open\";\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- the SDK's own types are loose unions of JSON; this is where they are narrowed. */\nclass RealClient implements FedimintClient {\n constructor(readonly federationId: string, private wallet: any, private director: any, private end: () => void) {}\n async info() { return federationInfo(this.federationId, await this.wallet.federation.getConfig()); }\n balance(): Promise<number> { return this.wallet.balance.getBalance(); }\n onBalance(listener: (msats: number) => void) { return this.wallet.balance.subscribeBalance(listener, () => {}); }\n async parseNotes(notes: string): Promise<ParsedNotes> {\n const parsed = await this.director.parseOobNotes(notes);\n return { amountMsats: Number(parsed.total_amount), federationIdPrefix: String(parsed.federation_id_prefix), federationId: parsed.federation_id ?? undefined };\n }\n async spend(amountMsats: number, { cancelAfterSecs, ghostly }: { cancelAfterSecs: number; ghostly: string }) {\n const { notes, operation_id } = await this.wallet.mint.spendNotes(amountMsats, cancelAfterSecs, false, { ghostly });\n return { notes: String(notes), operationId: String(operation_id) };\n }\n cancelSpend(operationId: string): Promise<void> { return this.wallet.mint.tryCancelSpendNotes(operationId); }\n spendState(operationId: string, waitMs: number) {\n return watch<SpendState>((ok, fail) => this.wallet.mint.subscribeSpendNotes(operationId, (s: string) => ok(SPEND[s] ?? \"created\"), fail), spendFinal, waitMs);\n }\n redeem(notes: string, ghostly: string): Promise<string> { return this.wallet.mint.reissueExternalNotes(notes, { ghostly }); }\n async redeemState(operationId: string, waitMs: number) {\n let error: unknown;\n const state = await watch<RedeemState>((ok, fail) => this.wallet.mint.subscribeReissueExternalNotes(operationId, (s: unknown) => ok(typeof s === \"string\" ? REDEEM[s] ?? \"created\" : s && typeof s === \"object\" && \"Failed\" in s ? \"failed\" : \"created\"), (e: string) => { error ??= e; fail(e); }), (s) => s === \"done\" || s === \"failed\", waitMs);\n // Only the reissue's own `Failed` is failed: an error of the client or its subscription says nothing of the notes.\n if (error !== undefined && state !== \"done\" && state !== \"failed\") throw new Error(`The Fedimint client could not say how the redeem stands: ${errorText(error)}`);\n return state;\n }\n async createInvoice(amountMsats: number, description: string, expirySecs: number, ghostly: string) {\n const { operation_id, invoice } = await this.wallet.lightning.createInvoice(amountMsats, description, expirySecs, undefined, { ghostly });\n return { operationId: String(operation_id), invoice: String(invoice) };\n }\n receiveState(operationId: string, waitMs: number) {\n return watch<ReceiveState>((ok, fail) => this.wallet.lightning.subscribeLnReceive(operationId, (s: unknown) => ok(receiveOf(s)), fail), (s) => s === \"claimed\" || s === \"canceled\", waitMs);\n }\n async gatewayFee(amountMsats: number) {\n await this.wallet.lightning.updateGatewayCache().catch(() => {});\n const gateway = await this.wallet.lightning.getAvailableGateway().catch(() => null);\n const fees = gateway?.fees;\n if (!fees) return undefined;\n return Number(fees.base_msat ?? 0) + Math.ceil(amountMsats * Number(fees.proportional_millionths ?? 0) / 1_000_000);\n }\n async payInvoice(invoice: string, ghostly: string) {\n const paid = await this.wallet.lightning.payInvoice(invoice, undefined, { ghostly });\n const internal = \"internal\" in paid.payment_type;\n return { operationId: String(internal ? paid.payment_type.internal : paid.payment_type.lightning), feeMsats: Number(paid.fee ?? 0), internal };\n }\n async payState(operationId: string, internal: boolean, waitMs: number): Promise<PayOutcome> {\n const state = await watch<unknown>((ok, fail) => internal ? this.wallet.lightning.subscribeInternalPayment(operationId, ok, fail) : this.wallet.lightning.subscribeLnPay(operationId, ok, fail),\n (s) => typeof s === \"object\" && !!s && (\"success\" in s || \"preimage\" in s || \"refunded\" in s || \"refund_success\" in s || \"unexpected_error\" in s || \"funding_failed\" in s) || s === \"canceled\", waitMs);\n if (state && typeof state === \"object\") {\n const s = state as Record<string, any>;\n // A payment out through the gateway ends in `success`; one to the same federation (internal) in `preimage` (bytes).\n if (s.success?.preimage || s.preimage) return { state: \"paid\", preimage: hex(s.success?.preimage ?? s.preimage) };\n if (\"refunded\" in s || \"refund_success\" in s || \"funding_failed\" in s) return { state: \"failed\", error: errorText(s.refunded?.gateway_error ?? s.funding_failed?.error ?? \"The gateway gave the payment back\") };\n if (\"unexpected_error\" in s) return { state: \"pending\", error: errorText(s.unexpected_error) };\n }\n if (state === \"canceled\") return { state: \"failed\", error: \"Canceled before it was funded\" };\n return { state: \"pending\" };\n }\n async operations(limit: number): Promise<FedimintOperation[]> {\n const list: [{ creation_time?: { secs_since_epoch?: number }; operation_id?: string }, { operation_module_kind?: string; meta?: any; outcome?: any }][] = await this.wallet.federation.listOperations(limit);\n return list.map(([key, log]) => {\n const variant = log.meta?.variant && typeof log.meta.variant === \"object\" ? Object.keys(log.meta.variant)[0] : undefined;\n const detail = variant ? log.meta.variant[variant] : undefined;\n return {\n id: String(key.operation_id ?? \"\"), kind: String(log.operation_module_kind ?? \"\"), variant,\n createdAt: Number(key.creation_time?.secs_since_epoch ?? 0) * 1000,\n amountMsats: typeof log.meta?.amount === \"number\" ? log.meta.amount : typeof detail?.requested_amount === \"number\" ? detail.requested_amount : undefined,\n outcome: log.outcome?.outcome, ghostly: typeof log.meta?.extra_meta?.ghostly === \"string\" ? log.meta.extra_meta.ghostly : undefined,\n invoice: typeof detail?.invoice === \"string\" ? detail.invoice : undefined,\n feeMsats: typeof detail?.fee === \"number\" ? detail.fee : undefined,\n };\n });\n }\n async close() { try { await this.wallet.cleanup(); } catch { /* already gone */ } this.end(); }\n}\n\n/**\n * Where the client runs: a worker per database, and the files the databases are. The browser's is a module worker on\n * the origin-private file system (below); a headless Ghostly on Node brings its own (packages/cli/src/runtime/fedimint.ts).\n */\nexport interface FedimintPlatform {\n /** A `@fedimint/types` Transport onto a new worker of its own, which one database will be opened in. */\n transport(): Promise<{ terminate(): void }>;\n exists(database: string): Promise<boolean>;\n /** Deletes a database, and is done when there is none. */\n remove(database: string): Promise<void>;\n}\n\nconst BROWSER: FedimintPlatform = {\n transport: browserTransport,\n async exists(database) {\n const root = await navigator.storage.getDirectory();\n try { const file = await (await root.getFileHandle(database)).getFile(); return file.size > 0; } catch { return false; }\n },\n async remove(database) {\n const root = await navigator.storage.getDirectory();\n await root.removeEntry(database).catch((error: unknown) => { if ((error as { name?: string })?.name !== \"NotFoundError\") throw error; });\n },\n};\n\nlet loading: Promise<FedimintSdk> | undefined;\n/** Loads the SDK on first use: profiles that never join a federation never fetch its 11 MB. */\nexport function loadFedimintSdk(): Promise<FedimintSdk> {\n return loading ??= fedimintSdkOn(BROWSER).catch((error) => { loading = undefined; throw error; });\n}\n\n/** The SDK on a platform's workers and files. */\nexport async function fedimintSdkOn(platform: FedimintPlatform): Promise<FedimintSdk> {\n const { WalletDirector } = await import(\"@fedimint/core\");\n /** A director on its own worker and database, with the mnemonic in place. */\n const director = async (database: string, mnemonic?: string) => {\n const t = await platform.transport();\n const d = new WalletDirector(t as any, database, true);\n try {\n await d.initialize(database);\n if (mnemonic && !(await d.hasMnemonicSet())) await d.setMnemonic(mnemonic.trim().split(/\\s+/));\n return { director: d, end: () => t.terminate() };\n } catch (error) { t.terminate(); throw error; }\n };\n const client = async (database: string, mnemonic: string, start: (wallet: any) => Promise<void>) => {\n const { director: d, end } = await director(database, mnemonic);\n try {\n const wallet = await d.createWallet();\n await start(wallet);\n return new RealClient(await wallet.federation.getFederationId(), wallet, d, end);\n } catch (error) { end(); throw error; }\n };\n const sdk: FedimintSdk = {\n async preview(invite) {\n // A scratch database of its own: previewing joins nothing.\n const database = fedimintDatabase(`preview-${crypto.randomUUID()}`);\n const { director: d, end } = await director(database);\n try { const preview = await d.previewFederation(invite.trim()); return federationInfo(preview.federation_id, preview.config); }\n finally { end(); await sdk.remove(database).catch(() => {}); }\n },\n join: ({ database, mnemonic, invite, recover }) => client(database, mnemonic, async (wallet) => {\n // joinFederation says false instead of throwing; its reason goes to the (silenced) logger.\n if (!(await wallet.joinFederation(invite.trim(), { clientName: CLIENT_NAME, forceRecover: recover }))) throw new Error(\"Could not join the federation: its guardians did not answer, or the invite code is not valid\");\n }),\n open: ({ database, mnemonic }) => client(database, mnemonic, (wallet) => wallet.open(CLIENT_NAME)),\n exists: (database) => platform.exists(database),\n remove: (database) => platform.remove(database),\n };\n return sdk;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"],"mappings":";;AA8FA,IAAa,oBAAoB,OAAe,oBAAoB,GAAG;AAKvE,IAAM,oBAAoB,OAAO;;AAEjC,IAAM,cAAc;AACpB,IAAM,WAA2C;CAAE,SAAS;CAAW,QAAQ;CAAU,SAAS;CAAW,UAAU;CAAW,SAAS;CAAW,WAAW;AAAY;;;;;;AAM7K,IAAM,QAAoC;CAAC,CAAC,cAAc,SAAS;CAAG,CAAC,cAAc,SAAS;CAAG,CAAC,cAAc,SAAS;CAAG,CAAC,cAAc,QAAQ;CAAG,CAAC,cAAc,WAAW;CAAG,CAAC,cAAc,SAAS;AAAC;AAC5M,SAAS,cAAc,QAA2G;CAChI,IAAI,OAAO,OAAO,YAAY,UAAU,OA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GAE9F,IAAI,CAAE,MAAM,OAAO,eAAe,OAAO,KAAK,GAAG;IAAE,YAAY;IAAa,cAAc;GAAQ,CAAC,GAAI,MAAM,IAAI,MAAM,8FAA8F;EACvN,CAAC;EACD,OAAO,EAAE,UAAU,eAAe,OAAO,UAAU,WAAW,WAAW,OAAO,KAAK,WAAW,CAAC;EACjG,SAAS,aAAa,SAAS,OAAO,QAAQ;EAC9C,SAAS,aAAa,SAAS,OAAO,QAAQ;CAChD;CACA,OAAO;AACT"}
@@ -0,0 +1,5 @@
1
+ // ../../node_modules/@fedimint/fedimint-client-wasm-bundler/fedimint_client_wasm_bg.wasm?url
2
+ var fedimint_client_wasm_bg_default = new URL("./fedimint_client_wasm_bg-DeFtkIv6.wasm", import.meta.url).href;
3
+ export { fedimint_client_wasm_bg_default as default };
4
+
5
+ //# sourceMappingURL=fedimint_client_wasm_bg-Cr5xGD-w.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fedimint_client_wasm_bg-BtHHlFpp.js","names":["import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"sources":["../../../../node_modules/@fedimint/fedimint-client-wasm-bundler/fedimint_client_wasm_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"ignoreList":[0],"mappings":";AAAA,IAAA,kCAAe,IAAA,IAAA,2CAAA,YAAA,GAAmD,CAAA,CAAnDA"}
1
+ {"version":3,"file":"fedimint_client_wasm_bg-Cr5xGD-w.js","names":["import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"sources":["../../../../node_modules/@fedimint/fedimint-client-wasm-bundler/fedimint_client_wasm_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"ignoreList":[0],"mappings":";AAAA,IAAA,kCAAe,IAAA,IAAA,2CAAA,YAAA,GAAmD,CAAA,CAAnDA"}
@@ -0,0 +1 @@
1
+ export { f as FILE_BYTES_STEP, t as NO_ROOM_TO_PLAY, n as SMALL_FILE_BYTES, r as blobDigest, i as checkFileId, p as digestText, a as dropFileSpace, o as fileBytes, s as fileBytesOf, c as fileSpace, l as registerFileBytes, u as removeFileBytes, d as resetFileBytes } from "./fileBytes-CfvUXdSy.js";
@@ -1,6 +1,6 @@
1
- import { u as databaseName } from "./idb-CEuoNsTv.js";
1
+ import { u as databaseName } from "./idb-ewvbqyDI.js";
2
2
  import { sha256 } from "@noble/hashes/sha2.js";
3
- //#region ../browser/src/shared/fileBytesCommon.ts
3
+ // ../browser/src/shared/fileBytesCommon.ts
4
4
  /** What `fileBytes.ts` and its worker share: the worker is built alone, so this imports nothing. */
5
5
  /** Reads and copies move this much at a time. */
6
6
  var FILE_BYTES_STEP = 1048576;
@@ -16,8 +16,7 @@ function digestText(bytes) {
16
16
  }
17
17
  return out;
18
18
  }
19
- //#endregion
20
- //#region ../browser/src/shared/fileBytes.ts
19
+ // ../browser/src/shared/fileBytes.ts
21
20
  /** Why `FileBytes.stream` refused a file this device holds: no room on the disk for the player's copy of it. */
22
21
  var NO_ROOM_TO_PLAY = "no_room_to_play";
23
22
  /** Files sent from memory-sized sources stay whole in IndexedDB; anything larger goes through a `FileBytes`. */
@@ -59,7 +58,7 @@ async function blobDigest(blob, onProgress) {
59
58
  }
60
59
  return digestText(hash.digest());
61
60
  }
62
- var makers = /* @__PURE__ */ new Map([["opfs", () => import("./fileBytesOpfs-DBS0kbPT.js").then((m) => m.OpfsFileBytes.open())], ["idb", () => import("./fileBytesIdb-D8mAK4pF.js").then((m) => new m.IdbFileBytes())]]);
61
+ var makers = /* @__PURE__ */ new Map([["opfs", () => import("./fileBytesOpfs-DRUYLER4.js").then((m) => m.OpfsFileBytes.open())], ["idb", () => import("./fileBytesIdb-B0zzJ6p7.js").then((m) => new m.IdbFileBytes())]]);
63
62
  var made = /* @__PURE__ */ new Map();
64
63
  var preferred = ["opfs", "idb"];
65
64
  /** How a backend is made. The platform registers its own (Desktop: `native`) before anything uses it. */
@@ -100,7 +99,6 @@ function resetFileBytes(order = ["opfs", "idb"]) {
100
99
  made.clear();
101
100
  preferred = order;
102
101
  }
103
- //#endregion
104
102
  export { dropFileSpace as a, fileSpace as c, resetFileBytes as d, FILE_BYTES_STEP as f, checkFileId as i, registerFileBytes as l, SMALL_FILE_BYTES as n, fileBytes as o, digestText as p, blobDigest as r, fileBytesOf as s, NO_ROOM_TO_PLAY as t, removeFileBytes as u };
105
103
 
106
- //# sourceMappingURL=fileBytes-BLPZq9YU.js.map
104
+ //# sourceMappingURL=fileBytes-CfvUXdSy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileBytes-CfvUXdSy.js","names":[],"sources":["../../../browser/src/shared/fileBytesCommon.ts","../../../browser/src/shared/fileBytes.ts"],"sourcesContent":["/** What `fileBytes.ts` and its worker share: the worker is built alone, so this imports nothing. */\n\n/** Reads and copies move this much at a time. */\nexport const FILE_BYTES_STEP = 1024 * 1024;\n\nconst BASE64URL = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\";\n\n/** base64url without padding (the worker has no @ghostly/core). */\nexport function digestText(bytes: Uint8Array): string {\n let out = \"\";\n for (let i = 0; i < bytes.length; i += 3) {\n const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);\n out += BASE64URL[(n >> 18) & 63] + BASE64URL[(n >> 12) & 63];\n if (i + 1 < bytes.length) out += BASE64URL[(n >> 6) & 63];\n if (i + 2 < bytes.length) out += BASE64URL[n & 63];\n }\n return out;\n}\n","import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { databaseName } from \"./idb\";\nimport { digestText, FILE_BYTES_STEP } from \"./fileBytesCommon\";\n\n/**\n * Where the bytes of a file live when they may be more than memory holds: a file sent or received in a chat.\n * Every implementation keeps one file per id under the profile's space (`databaseName()`), is written in\n * order (`append` at the stored size, `truncate` to go back), and is read in ranges, so no caller ever needs\n * the whole file at once.\n *\n * - `opfs`: the origin-private file system, written by a worker with sync access handles (web, extension).\n * - `native`: a real file in the app's data folder, through Rust (Desktop).\n * - `idb`: 1 MiB records in IndexedDB, where neither of those exists (and in tests).\n */\nexport interface FileBytes {\n readonly kind: FileBytesKind;\n /** Copies a picked file in, hashing it on the way. Resolves to its SHA-256, base64url. */\n stage(id: string, source: Blob, onProgress?: (copied: number) => void): Promise<string>;\n /** Writes at `offset`, which must be the stored size. Resolves once written; `flush` makes it durable. */\n append(id: string, offset: number, bytes: Uint8Array): Promise<void>;\n /** What was appended so far survives a crash. */\n flush(id: string): Promise<void>;\n /** Writing is over for now: flushed, and the file let go so it can be read elsewhere. */\n close(id: string): Promise<void>;\n /** Bytes stored, or null when there is no such file. */\n size(id: string): Promise<number | null>;\n /** Cuts the file to `size` bytes (a transfer going back to its last durable point). */\n truncate(id: string, size: number): Promise<void>;\n /** At most `length` bytes from `offset`; fewer only at the end of the file. */\n read(id: string, offset: number, length: number): Promise<Uint8Array>;\n /** SHA-256 of what is stored, base64url: read back from storage, so it checks what was written. */\n digest(id: string): Promise<string>;\n /**\n * The file as a Blob to show or save, backed by storage rather than memory, or null where this platform\n * cannot hand one out (Desktop, above `NATIVE_BLOB_MAX`: saved with `save` instead).\n */\n blob(id: string, type: string): Promise<Blob | null>;\n remove(id: string): Promise<void>;\n /** Removes every file whose id starts with `prefix` (\"\" for all of this space). */\n removeWhere(prefix: string): Promise<void>;\n /** Bytes this device can still take for files, or null when the platform does not say. */\n room(): Promise<number | null>;\n /** Saves a copy where the person chooses, where the platform has a dialog for it. False when they cancelled. */\n save?(id: string, name: string): Promise<boolean>;\n /**\n * A URL a `<video>` or `<audio>` plays the stored file from, served in ranges by the platform (Desktop, for a file\n * too large for `blob`), or null when there is no such file. The URL works until `release`. Rejects with\n * `NO_ROOM_TO_PLAY` when the disk has no room for the copy the player makes of it (Linux's WebKitGTK): save it instead.\n */\n stream?(id: string, type: string): Promise<FileStream | null>;\n /**\n * What this space's files take on disk, where they are real files (Desktop): the files, and the copies staged for a\n * save (a backup, a file on its way through the save dialog) apart. Absent elsewhere: there the browser's own\n * estimate counts them.\n */\n usage?(): Promise<FileUsage>;\n /** Removes another profile's folder (a deleted profile). IndexedDB pieces go with the profile's database. */\n dropSpace?(space: string): Promise<void>;\n /**\n * The same storage for another profile's space: a backup of a profile that is not the active one reads its files\n * through it, and a restore writes a new profile's files through it before that profile exists. Absent where files\n * are pieces in the profile's own database (`idb`): those are read and written with that database.\n */\n forSpace?(space: string): FileBytes;\n /**\n * Another space's stored file `fromId` under `id` here as well, nothing read or written: one file with two names (a\n * move back to a device whose frozen copy holds it). A write to either name gives that name a file of its own first,\n * so the other keeps its bytes. Absent where storage has no such names (`opfs`, `idb`); rejects where the disk has\n * none: copy instead.\n */\n link?(fromSpace: string, fromId: string, id: string): Promise<void>;\n}\n\nexport type FileBytesKind = \"opfs\" | \"native\" | \"idb\";\n\n/** Bytes a space's files take (`FileBytes.usage`): the files and how many, and the copies staged for a save. */\nexport interface FileUsage { files: number; count: number; staged: number }\n\n/** Why `FileBytes.stream` refused a file this device holds: no room on the disk for the player's copy of it. */\nexport const NO_ROOM_TO_PLAY = \"no_room_to_play\";\n\n/** A stored file being served to a media element: its URL, and how to stop serving it. */\nexport interface FileStream {\n url: string;\n release(): void;\n}\n\n/** Files sent from memory-sized sources stay whole in IndexedDB; anything larger goes through a `FileBytes`. */\nexport const SMALL_FILE_BYTES = 16 * 1024 * 1024;\n\nexport { FILE_BYTES_STEP, digestText } from \"./fileBytesCommon\";\n\nconst ID = /^[A-Za-z0-9_-]{1,200}$/;\nconst SPACE = /^[A-Za-z0-9_.-]{1,100}$/;\n\n/** A file id every backend accepts as a file name as it is: never a path. */\nexport function checkFileId(id: string): string {\n if (!ID.test(id)) throw new Error(\"Invalid file id\");\n return id;\n}\n\n/** This profile's folder name. */\nexport function fileSpace(): string {\n const space = databaseName();\n if (!SPACE.test(space)) throw new Error(\"Invalid profile space\");\n return space;\n}\n\n/**\n * SHA-256 of a Blob, read a step at a time: memory stays at one step. Read with `slice().arrayBuffer()`, not\n * `stream()`: in WebKit a Blob kept in IndexedDB that reads fine in slices failed as a stream (\"The object can not be\n * found here\"), which failed a voice note after all its bytes had arrived.\n */\nexport async function blobDigest(blob: Blob, onProgress?: (done: number) => void): Promise<string> {\n // A Blob this side holds in memory anyway (at most `SMALL_FILE_BYTES`, a send's small path): the platform's digest, off\n // the page's script. noble's, a step at a time on the main thread, was 16 long tasks of 65-90 ms for 16 MiB on a\n // phone-class CPU, ~13-16x slower than crypto.subtle (agents#1765). Read whole with `arrayBuffer()` too, not `stream()`.\n const subtle = globalThis.crypto?.subtle;\n if (subtle && blob.size <= SMALL_FILE_BYTES) {\n const bytes = await blob.arrayBuffer();\n if (bytes.byteLength !== blob.size) throw new Error(\"The file is shorter than it says\");\n const digest = new Uint8Array(await subtle.digest(\"SHA-256\", bytes));\n onProgress?.(blob.size);\n return digestText(digest);\n }\n const hash = sha256.create();\n for (let done = 0; done < blob.size;) {\n const part = new Uint8Array(await blob.slice(done, Math.min(blob.size, done + FILE_BYTES_STEP)).arrayBuffer());\n if (!part.length) throw new Error(\"The file is shorter than it says\");\n hash.update(part);\n done += part.length;\n onProgress?.(done);\n }\n return digestText(hash.digest());\n}\n\ntype Maker = () => Promise<FileBytes | null>;\nconst makers = new Map<FileBytesKind, Maker>([\n [\"opfs\", () => import(\"./fileBytesOpfs\").then((m) => m.OpfsFileBytes.open())],\n [\"idb\", () => import(\"./fileBytesIdb\").then((m) => new m.IdbFileBytes())],\n]);\nconst made = new Map<FileBytesKind, Promise<FileBytes | null>>();\nlet preferred: FileBytesKind[] = [\"opfs\", \"idb\"];\n\n/** How a backend is made. The platform registers its own (Desktop: `native`) before anything uses it. */\nexport function registerFileBytes(kind: FileBytesKind, make: Maker, prefer = false): void {\n makers.set(kind, make);\n made.delete(kind);\n if (prefer) preferred = [kind, ...preferred.filter((k) => k !== kind)];\n}\n\n/** The backend of this kind, or null where this platform has none. */\nexport function fileBytesOf(kind: FileBytesKind): Promise<FileBytes | null> {\n let backend = made.get(kind);\n if (!backend) {\n const make = makers.get(kind);\n backend = make ? make().catch(() => null) : Promise.resolve(null);\n made.set(kind, backend);\n }\n return backend;\n}\n\n/** Where new files go: the first backend this platform has. */\nexport async function fileBytes(): Promise<FileBytes> {\n for (const kind of preferred) {\n const backend = await fileBytesOf(kind);\n if (backend) return backend;\n }\n throw new Error(\"This device has no storage for files\");\n}\n\n/** \"Clear all data\" and a deleted chat: the bytes of its files go with it, wherever they are. */\nexport async function removeFileBytes(prefix = \"\"): Promise<void> {\n await Promise.all([...makers.keys()].map(async (kind) => (await fileBytesOf(kind))?.removeWhere(prefix)));\n}\n\n/** A deleted profile's files, wherever they are. */\nexport async function dropFileSpace(space: string): Promise<void> {\n if (!SPACE.test(space)) throw new Error(\"Invalid profile space\");\n await Promise.all([...makers.keys()].map(async (kind) => (await fileBytesOf(kind))?.dropSpace?.(space)));\n}\n\n/** Tests: forget what was made and which backend comes first. */\nexport function resetFileBytes(order: FileBytesKind[] = [\"opfs\", \"idb\"]): void {\n made.clear();\n preferred = order;\n}\n"],"mappings":";;;;;AAGA,IAAa,kBAAkB;AAE/B,IAAM,YAAY;;AAGlB,SAAgB,WAAW,OAA2B;CACpD,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxC,MAAM,IAAK,MAAM,MAAM,MAAQ,MAAM,IAAI,MAAM,MAAM,KAAM,MAAM,IAAI,MAAM;EAC3E,OAAO,UAAW,KAAK,KAAM,MAAM,UAAW,KAAK,KAAM;EACzD,IAAI,IAAI,IAAI,MAAM,QAAQ,OAAO,UAAW,KAAK,IAAK;EACtD,IAAI,IAAI,IAAI,MAAM,QAAQ,OAAO,UAAU,IAAI;CACjD;CACA,OAAO;AACT;;;AC8DA,IAAa,kBAAkB;;AAS/B,IAAa,mBAAmB;AAIhC,IAAM,KAAK;AACX,IAAM,QAAQ;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TES_STEP, i as checkFileId, p as digestText } from "./fileBytes-CfvUXdSy.js";
2
2
  import { mkdir, open, readdir, rm, stat, statfs } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { createHash } from "node:crypto";
5
- //#region src/runtime/fileBytes.ts
5
+ // src/runtime/fileBytes.ts
6
6
  /**
7
7
  * Files as real files in the profile's folder (`files/<space>/<id>`, 0600 in 0700 folders), the Node twin of the
8
8
  * Desktop's `native` backend (`shared/fileBytesNative.ts`, which goes through Rust). Registered as `native` and
@@ -151,7 +151,6 @@ var NodeFileBytes = class {
151
151
  });
152
152
  }
153
153
  };
154
- //#endregion
155
154
  export { NodeFileBytes };
156
155
 
157
- //# sourceMappingURL=fileBytes-B0z9A6Le.js.map
156
+ //# sourceMappingURL=fileBytes-tj6-VZcB.js.map