home-hosted 0.13.0 → 0.20.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 (485) hide show
  1. package/README.md +117 -322
  2. package/bin/home-hosted.mjs +41 -0
  3. package/dist/chunks/account-DiLrSyww.js +359 -0
  4. package/dist/chunks/account-DiLrSyww.js.map +1 -0
  5. package/dist/chunks/add-DEIYVkNK.js +183 -0
  6. package/dist/chunks/add-DEIYVkNK.js.map +1 -0
  7. package/dist/chunks/{archive-DP-XQR8X.js → archive-DFi3qK1c.js} +25 -73
  8. package/dist/chunks/archive-DFi3qK1c.js.map +1 -0
  9. package/dist/chunks/{atomic-C1PfJpE7.js → atomic-SZUwDtGD.js} +3 -6
  10. package/dist/chunks/atomic-SZUwDtGD.js.map +1 -0
  11. package/dist/chunks/{backup-CZcVca2a.js → backup-DnyxIzw0.js} +110 -190
  12. package/dist/chunks/backup-DnyxIzw0.js.map +1 -0
  13. package/dist/chunks/backups-BrrN6cwW.js +2203 -0
  14. package/dist/chunks/backups-BrrN6cwW.js.map +1 -0
  15. package/dist/chunks/bind-DIxrnUst.js +43 -0
  16. package/dist/chunks/bind-DIxrnUst.js.map +1 -0
  17. package/dist/chunks/config-text-DxMOQQnk.js +34 -0
  18. package/dist/chunks/config-text-DxMOQQnk.js.map +1 -0
  19. package/dist/chunks/{contracts-CMBD1TF9.js → contracts-CxZ7u1L3.js} +1239 -1454
  20. package/dist/chunks/contracts-CxZ7u1L3.js.map +1 -0
  21. package/dist/chunks/daemon-BAAYUYQC.js +211 -0
  22. package/dist/chunks/daemon-BAAYUYQC.js.map +1 -0
  23. package/dist/chunks/daemon-log-Ccu-69vB.js +179 -0
  24. package/dist/chunks/daemon-log-Ccu-69vB.js.map +1 -0
  25. package/dist/chunks/deploy-CggSOEkq.js +144 -0
  26. package/dist/chunks/deploy-CggSOEkq.js.map +1 -0
  27. package/dist/chunks/{docker-Cy9Lyvda.js → docker--Un0uLfF.js} +32 -68
  28. package/dist/chunks/docker--Un0uLfF.js.map +1 -0
  29. package/dist/chunks/{down-pKbGCW9d.js → down-CpIN7LEQ.js} +34 -94
  30. package/dist/chunks/down-CpIN7LEQ.js.map +1 -0
  31. package/dist/chunks/exposure-CDJNvOCK.js +229 -0
  32. package/dist/chunks/exposure-CDJNvOCK.js.map +1 -0
  33. package/dist/chunks/import-Bd4VZH0f.js +205 -0
  34. package/dist/chunks/import-Bd4VZH0f.js.map +1 -0
  35. package/dist/chunks/import-plan--fDS_l5r.js +147 -0
  36. package/dist/chunks/import-plan--fDS_l5r.js.map +1 -0
  37. package/dist/chunks/import-write-BTfbeV26.js +42 -0
  38. package/dist/chunks/import-write-BTfbeV26.js.map +1 -0
  39. package/dist/chunks/{init-BZ7hK9Vf.js → init-Bv3oH65x.js} +14 -50
  40. package/dist/chunks/init-Bv3oH65x.js.map +1 -0
  41. package/dist/chunks/job-CYOdN6Ub.js +341 -0
  42. package/dist/chunks/job-CYOdN6Ub.js.map +1 -0
  43. package/dist/chunks/jobs-BX4ahcfh.js +489 -0
  44. package/dist/chunks/jobs-BX4ahcfh.js.map +1 -0
  45. package/dist/chunks/last-stop-DD3lHwo_.js +42 -0
  46. package/dist/chunks/last-stop-DD3lHwo_.js.map +1 -0
  47. package/dist/chunks/layout-D0ysDNav.js +18 -0
  48. package/dist/chunks/layout-D0ysDNav.js.map +1 -0
  49. package/dist/chunks/lazy-kfcBNeqj.js +48 -0
  50. package/dist/chunks/lazy-kfcBNeqj.js.map +1 -0
  51. package/dist/chunks/log-buffer-B7jmn7ts.js +110 -0
  52. package/dist/chunks/log-buffer-B7jmn7ts.js.map +1 -0
  53. package/dist/chunks/log-files-CZL2UhuE.js +488 -0
  54. package/dist/chunks/log-files-CZL2UhuE.js.map +1 -0
  55. package/dist/chunks/{logger-B5U4GD3j.js → logger-BnrKTBHQ.js} +2 -6
  56. package/dist/chunks/logger-BnrKTBHQ.js.map +1 -0
  57. package/dist/chunks/{logs---TI_bxM.js → logs-DxKI6OW2.js} +23 -73
  58. package/dist/chunks/logs-DxKI6OW2.js.map +1 -0
  59. package/dist/chunks/ls-BseUHy_m.js +128 -0
  60. package/dist/chunks/ls-BseUHy_m.js.map +1 -0
  61. package/dist/chunks/migrate-D4w_dXDm.js +268 -0
  62. package/dist/chunks/migrate-D4w_dXDm.js.map +1 -0
  63. package/dist/chunks/{nanny-B-Eu0sFW.js → nanny-BWh7nuvv.js} +21 -14
  64. package/dist/chunks/nanny-BWh7nuvv.js.map +1 -0
  65. package/dist/chunks/{nanny-ChMtq1Zl.js → nanny-BjF2-1pv.js} +3 -3
  66. package/dist/chunks/{nanny-ChMtq1Zl.js.map → nanny-BjF2-1pv.js.map} +1 -1
  67. package/dist/chunks/nanny-DGTXVq5d.js +806 -0
  68. package/dist/chunks/nanny-DGTXVq5d.js.map +1 -0
  69. package/dist/chunks/{nanny-sweep-DErnlPY1.js → nanny-sweep-hjmZ_p7S.js} +14 -24
  70. package/dist/chunks/nanny-sweep-hjmZ_p7S.js.map +1 -0
  71. package/dist/chunks/{nearest-6KgQEDUe.js → nearest-DOx4jySJ.js} +2 -10
  72. package/dist/chunks/nearest-DOx4jySJ.js.map +1 -0
  73. package/dist/chunks/{parse-DhmG26fI.js → parse-DVMPLUDe.js} +47 -72
  74. package/dist/chunks/parse-DVMPLUDe.js.map +1 -0
  75. package/dist/chunks/password-policy-Clq6PGE-.js +9 -0
  76. package/dist/chunks/password-policy-Clq6PGE-.js.map +1 -0
  77. package/dist/chunks/{paths-CGlGDrOU.js → paths-C34-TJLh.js} +32 -56
  78. package/dist/chunks/paths-C34-TJLh.js.map +1 -0
  79. package/dist/chunks/{port-B8WBTRMk.js → port-CnsrxKNR.js} +27 -71
  80. package/dist/chunks/port-CnsrxKNR.js.map +1 -0
  81. package/dist/chunks/process-CboOFPU_.js +192 -0
  82. package/dist/chunks/process-CboOFPU_.js.map +1 -0
  83. package/dist/chunks/{restart-Des4DrAN.js → restart-C0J8dZ2L.js} +11 -29
  84. package/dist/chunks/restart-C0J8dZ2L.js.map +1 -0
  85. package/dist/chunks/run-deploy-DoNDvwT4.js +91 -0
  86. package/dist/chunks/run-deploy-DoNDvwT4.js.map +1 -0
  87. package/dist/chunks/{schema-B240VXcV.js → schema-CZ6f-PHD.js} +7 -20
  88. package/dist/chunks/schema-CZ6f-PHD.js.map +1 -0
  89. package/dist/chunks/secret-MY397r90.js +219 -0
  90. package/dist/chunks/secret-MY397r90.js.map +1 -0
  91. package/dist/chunks/secrets-CG5N4lwY.js +1061 -0
  92. package/dist/chunks/secrets-CG5N4lwY.js.map +1 -0
  93. package/dist/chunks/server-Dm_dXfTW.js +255 -0
  94. package/dist/chunks/server-Dm_dXfTW.js.map +1 -0
  95. package/dist/chunks/server-attention-UQwYXqKe.js +10 -0
  96. package/dist/chunks/server-attention-UQwYXqKe.js.map +1 -0
  97. package/dist/chunks/server-create-D7nvhgBd.js +96 -0
  98. package/dist/chunks/server-create-D7nvhgBd.js.map +1 -0
  99. package/dist/chunks/server-ids-BEQD2rFz.js +23 -0
  100. package/dist/chunks/server-ids-BEQD2rFz.js.map +1 -0
  101. package/dist/chunks/server-vars-DMYmHutL.js +27 -0
  102. package/dist/chunks/server-vars-DMYmHutL.js.map +1 -0
  103. package/dist/chunks/service-C8l-ewNA.js +585 -0
  104. package/dist/chunks/service-C8l-ewNA.js.map +1 -0
  105. package/dist/chunks/{settings-xu-XTfWg.js → settings-CtYDs5PX.js} +62 -78
  106. package/dist/chunks/settings-CtYDs5PX.js.map +1 -0
  107. package/dist/chunks/{setup-temp-CAN4_bA-.js → setup-temp-TAtDmMMU.js} +43 -37
  108. package/dist/chunks/setup-temp-TAtDmMMU.js.map +1 -0
  109. package/dist/chunks/shape-CDGeYl_J.js +9 -0
  110. package/dist/chunks/shape-CDGeYl_J.js.map +1 -0
  111. package/dist/chunks/{src-BtWMFmzZ.js → src-BnzkVy_M.js} +12548 -10576
  112. package/dist/chunks/src-BnzkVy_M.js.map +1 -0
  113. package/dist/chunks/{status-DT1EsA-B.js → status-efbbfYZQ.js} +53 -26
  114. package/dist/chunks/status-efbbfYZQ.js.map +1 -0
  115. package/dist/chunks/store-Bs_Lljjm.js +2082 -0
  116. package/dist/chunks/store-Bs_Lljjm.js.map +1 -0
  117. package/dist/chunks/template-xan58bJh.js +28 -0
  118. package/dist/chunks/template-xan58bJh.js.map +1 -0
  119. package/dist/chunks/token-DDeWfZA4.js +142 -0
  120. package/dist/chunks/token-DDeWfZA4.js.map +1 -0
  121. package/dist/chunks/{ui-D562aqw5.js → ui-BcIAtyxE.js} +68 -79
  122. package/dist/chunks/ui-BcIAtyxE.js.map +1 -0
  123. package/dist/chunks/{ui-dir-CsU3uLNV.js → ui-dir-ClCzVRc3.js} +3 -7
  124. package/dist/chunks/ui-dir-ClCzVRc3.js.map +1 -0
  125. package/dist/chunks/ui-format-CDvvqOoi.js +53 -0
  126. package/dist/chunks/ui-format-CDvvqOoi.js.map +1 -0
  127. package/dist/chunks/{ui-release-DKzVvlLd.js → ui-release-XbJ85pYI.js} +36 -38
  128. package/dist/chunks/ui-release-XbJ85pYI.js.map +1 -0
  129. package/dist/chunks/{ui-revert-EkBBwRTt.js → ui-revert-Dgawq7ze.js} +4 -4
  130. package/dist/chunks/ui-revert-Dgawq7ze.js.map +1 -0
  131. package/dist/chunks/{ui-switch-BnZTdMDd.js → ui-switch-CfQMbZ0g.js} +31 -38
  132. package/dist/chunks/ui-switch-CfQMbZ0g.js.map +1 -0
  133. package/dist/chunks/{ui-update-_xryLYxw.js → ui-update-B3PPivUm.js} +30 -48
  134. package/dist/chunks/ui-update-B3PPivUm.js.map +1 -0
  135. package/dist/chunks/ui-update-CAiH2tFb.js +109 -0
  136. package/dist/chunks/ui-update-CAiH2tFb.js.map +1 -0
  137. package/dist/chunks/{up-Pdz-l6IH.js → up-BQSnYxYd.js} +47 -53
  138. package/dist/chunks/up-BQSnYxYd.js.map +1 -0
  139. package/dist/chunks/{usage-DFrCVXpT.js → usage-KG8TeOio.js} +7 -20
  140. package/dist/chunks/usage-KG8TeOio.js.map +1 -0
  141. package/dist/chunks/{workspaces-DYcfvKV_.js → workspaces-D9akpzU8.js} +80 -68
  142. package/dist/chunks/workspaces-D9akpzU8.js.map +1 -0
  143. package/dist/chunks/{wsl-temperature-BiCI4iK6.js → wsl-temperature-D-_d4Yk1.js} +47 -42
  144. package/dist/chunks/wsl-temperature-D-_d4Yk1.js.map +1 -0
  145. package/dist/cli.js +306 -238
  146. package/dist/cli.js.map +1 -1
  147. package/dist/client.js +76 -29
  148. package/dist/client.js.map +1 -1
  149. package/dist/types/api/acme.d.ts +3 -7
  150. package/dist/types/api/auth/$.routes.d.ts +107 -16
  151. package/dist/types/api/backups.d.ts +5 -5
  152. package/dist/types/api/control.d.ts +747 -38
  153. package/dist/types/api/ddns.d.ts +13 -18
  154. package/dist/types/api/events.d.ts +9 -3
  155. package/dist/types/api/health.d.ts +2 -4
  156. package/dist/types/api/jobs.d.ts +438 -0
  157. package/dist/types/api/logs.d.ts +20 -0
  158. package/dist/types/api/metrics.d.ts +2 -5
  159. package/dist/types/api/notifications.d.ts +3 -6
  160. package/dist/types/api/proxy.d.ts +63 -23
  161. package/dist/types/api/server-ops.d.ts +17 -0
  162. package/dist/types/api/servers/$.routes.d.ts +418 -186
  163. package/dist/types/api/session-required.d.ts +16 -0
  164. package/dist/types/api/settings.d.ts +7 -7
  165. package/dist/types/api/state.d.ts +100 -10
  166. package/dist/types/api/static.d.ts +2 -2
  167. package/dist/types/api/tls.d.ts +2 -5
  168. package/dist/types/api/workspaces/$.routes.d.ts +186 -12
  169. package/dist/types/api/wsl-temperature.d.ts +4 -10
  170. package/dist/types/app.d.ts +4511 -2778
  171. package/dist/types/cli/account.d.ts +23 -0
  172. package/dist/types/cli/add.d.ts +96 -0
  173. package/dist/types/cli/args.d.ts +24 -35
  174. package/dist/types/cli/backup-offline.d.ts +2 -8
  175. package/dist/types/cli/backup.d.ts +12 -21
  176. package/dist/types/cli/down.d.ts +15 -41
  177. package/dist/types/cli/import-plan.d.ts +55 -0
  178. package/dist/types/cli/import-write.d.ts +5 -0
  179. package/dist/types/cli/import.d.ts +86 -0
  180. package/dist/types/cli/io.d.ts +26 -35
  181. package/dist/types/cli/job.d.ts +99 -0
  182. package/dist/types/cli/logs.d.ts +1 -10
  183. package/dist/types/cli/ls.d.ts +57 -0
  184. package/dist/types/cli/migrate.d.ts +31 -8
  185. package/dist/types/cli/nearest.d.ts +1 -9
  186. package/dist/types/cli/run-deploy.d.ts +36 -0
  187. package/dist/types/cli/secret.d.ts +90 -0
  188. package/dist/types/cli/server.d.ts +6 -15
  189. package/dist/types/cli/service.d.ts +135 -0
  190. package/dist/types/cli/setup-temp.d.ts +17 -13
  191. package/dist/types/cli/status.d.ts +7 -1
  192. package/dist/types/cli/token.d.ts +6 -0
  193. package/dist/types/cli/ui-switch.d.ts +3 -14
  194. package/dist/types/cli/ui-update.d.ts +3 -16
  195. package/dist/types/cli/up.d.ts +9 -22
  196. package/dist/types/cli/usage.d.ts +2 -6
  197. package/dist/types/cli.d.ts +1 -10
  198. package/dist/types/client.d.ts +4099 -1142
  199. package/dist/types/config/accounts.d.ts +16 -0
  200. package/dist/types/config/jobs.d.ts +68 -0
  201. package/dist/types/config/layout.d.ts +2 -8
  202. package/dist/types/config/migrations.d.ts +9 -41
  203. package/dist/types/config/parse.d.ts +8 -13
  204. package/dist/types/config/patch.d.ts +1 -6
  205. package/dist/types/config/schema.d.ts +16 -18
  206. package/dist/types/config/secret-parts.d.ts +6 -27
  207. package/dist/types/config/secrets.d.ts +167 -88
  208. package/dist/types/config/seed.d.ts +1 -6
  209. package/dist/types/config/server-ids.d.ts +2 -11
  210. package/dist/types/config/settings.d.ts +13 -49
  211. package/dist/types/config/store.d.ts +17 -54
  212. package/dist/types/config/workspaces.d.ts +24 -56
  213. package/dist/types/helpers/action-result.d.ts +18 -32
  214. package/dist/types/helpers/atomic.d.ts +1 -4
  215. package/dist/types/helpers/backoff.d.ts +0 -1
  216. package/dist/types/helpers/bind.d.ts +3 -11
  217. package/dist/types/helpers/config-text.d.ts +4 -19
  218. package/dist/types/helpers/cookies.d.ts +2 -7
  219. package/dist/types/helpers/copy-tree.d.ts +4 -12
  220. package/dist/types/helpers/daemon-log.d.ts +8 -33
  221. package/dist/types/helpers/daemon.d.ts +20 -70
  222. package/dist/types/helpers/deferred.d.ts +2 -4
  223. package/dist/types/helpers/env-file.d.ts +2 -7
  224. package/dist/types/helpers/error.d.ts +3 -14
  225. package/dist/types/helpers/event-stream.d.ts +18 -10
  226. package/dist/types/helpers/factory.d.ts +2 -3
  227. package/dist/types/helpers/last-stop.d.ts +5 -12
  228. package/dist/types/helpers/logger.d.ts +1 -5
  229. package/dist/types/helpers/open.d.ts +0 -1
  230. package/dist/types/helpers/openapi.d.ts +19 -5
  231. package/dist/types/helpers/paths.d.ts +18 -53
  232. package/dist/types/helpers/restore-lock.d.ts +2 -17
  233. package/dist/types/helpers/runtime.d.ts +3 -13
  234. package/dist/types/helpers/secret-compare.d.ts +2 -10
  235. package/dist/types/helpers/server-create.d.ts +15 -0
  236. package/dist/types/helpers/shell.d.ts +2 -16
  237. package/dist/types/helpers/sse.d.ts +8 -6
  238. package/dist/types/helpers/ui-dir.d.ts +1 -5
  239. package/dist/types/helpers/utf8-chunks.d.ts +2 -8
  240. package/dist/types/helpers/validate.d.ts +2 -4
  241. package/dist/types/helpers/validator.d.ts +8 -4
  242. package/dist/types/helpers/version.d.ts +1 -6
  243. package/dist/types/helpers/workspace.d.ts +24 -16
  244. package/dist/types/index.d.ts +2 -3
  245. package/dist/types/middleware/auth.d.ts +8 -27
  246. package/dist/types/middleware/body-limit.d.ts +10 -0
  247. package/dist/types/middleware/host.d.ts +4 -23
  248. package/dist/types/middleware/loopback.d.ts +1 -8
  249. package/dist/types/middleware/token-scope.d.ts +34 -0
  250. package/dist/types/node-compat.d.ts +43 -0
  251. package/dist/types/openapi-reference.d.ts +4 -19
  252. package/dist/types/openapi.d.ts +5 -8
  253. package/dist/types/providers/archive.d.ts +8 -25
  254. package/dist/types/providers/backup-hook.d.ts +4 -19
  255. package/dist/types/providers/ddns/dyndns2.d.ts +0 -3
  256. package/dist/types/providers/ddns/index.d.ts +2 -3
  257. package/dist/types/providers/ddns/ip.d.ts +2 -12
  258. package/dist/types/providers/ddns/namecheap-api.d.ts +3 -2
  259. package/dist/types/providers/ddns/types.d.ts +6 -32
  260. package/dist/types/providers/ddns/zone.d.ts +1 -4
  261. package/dist/types/providers/docker.d.ts +18 -45
  262. package/dist/types/providers/entry-state.d.ts +4 -9
  263. package/dist/types/providers/health-check.d.ts +1 -5
  264. package/dist/types/providers/host.d.ts +33 -108
  265. package/dist/types/providers/identity.d.ts +9 -34
  266. package/dist/types/providers/log-tail.d.ts +14 -24
  267. package/dist/types/providers/nanny-sweep.d.ts +8 -25
  268. package/dist/types/providers/nanny.d.ts +16 -58
  269. package/dist/types/providers/port.d.ts +28 -83
  270. package/dist/types/providers/proc.d.ts +22 -80
  271. package/dist/types/providers/process.d.ts +12 -36
  272. package/dist/types/providers/proxy/admin.d.ts +11 -0
  273. package/dist/types/providers/proxy/types.d.ts +4 -16
  274. package/dist/types/providers/telegram.d.ts +1 -17
  275. package/dist/types/providers/ui-release.d.ts +15 -25
  276. package/dist/types/providers/webhook.d.ts +8 -29
  277. package/dist/types/providers/wsl-temperature.d.ts +13 -22
  278. package/dist/types/services/acme-challenge.d.ts +2 -16
  279. package/dist/types/services/auth.d.ts +65 -80
  280. package/dist/types/services/backups/archive-safety.d.ts +30 -0
  281. package/dist/types/services/backups/paths.d.ts +31 -0
  282. package/dist/types/services/backups.d.ts +61 -271
  283. package/dist/types/services/config-watch.d.ts +3 -15
  284. package/dist/types/services/control-server.d.ts +6 -10
  285. package/dist/types/services/ddns.d.ts +12 -13
  286. package/dist/types/services/dependencies.d.ts +3 -14
  287. package/dist/types/services/deploy.d.ts +34 -0
  288. package/dist/types/services/events.d.ts +15 -9
  289. package/dist/types/services/exposure.d.ts +13 -63
  290. package/dist/types/services/history.d.ts +5 -14
  291. package/dist/types/services/host-monitor.d.ts +6 -11
  292. package/dist/types/services/init.d.ts +5 -35
  293. package/dist/types/services/job-ledger.d.ts +27 -0
  294. package/dist/types/services/jobs.d.ts +113 -0
  295. package/dist/types/services/log-buffer.d.ts +7 -8
  296. package/dist/types/services/log-files.d.ts +12 -42
  297. package/dist/types/services/log-relay.d.ts +3 -13
  298. package/dist/types/services/nanny.d.ts +3 -10
  299. package/dist/types/services/notifications.d.ts +31 -61
  300. package/dist/types/services/panel.d.ts +32 -78
  301. package/dist/types/services/proxy-certificates/certificates.d.ts +31 -69
  302. package/dist/types/services/proxy-config.d.ts +15 -36
  303. package/dist/types/services/proxy-dns01.d.ts +14 -0
  304. package/dist/types/services/proxy.d.ts +73 -254
  305. package/dist/types/services/scheduler.d.ts +46 -0
  306. package/dist/types/services/state.d.ts +17 -8
  307. package/dist/types/services/supervisor/compose.d.ts +2 -6
  308. package/dist/types/services/supervisor/entry.d.ts +29 -32
  309. package/dist/types/services/supervisor/health.d.ts +8 -31
  310. package/dist/types/services/supervisor/job-run.d.ts +36 -0
  311. package/dist/types/services/supervisor/output.d.ts +13 -77
  312. package/dist/types/services/supervisor/persistent.d.ts +5 -11
  313. package/dist/types/services/supervisor/port-preflight.d.ts +4 -10
  314. package/dist/types/services/supervisor/records.d.ts +27 -60
  315. package/dist/types/services/supervisor/restart-required.d.ts +13 -0
  316. package/dist/types/services/supervisor/spawn.d.ts +3 -5
  317. package/dist/types/services/supervisor/view.d.ts +3 -1
  318. package/dist/types/services/supervisor.d.ts +31 -43
  319. package/dist/types/services/tls.d.ts +6 -17
  320. package/dist/types/services/ui-update.d.ts +19 -17
  321. package/dist/types/services/ui.d.ts +10 -19
  322. package/dist/types/shared/action-outcome.d.ts +2 -7
  323. package/dist/types/shared/api-client.d.ts +133 -177
  324. package/dist/types/shared/api-scopes.d.ts +17 -0
  325. package/dist/types/shared/backup-scope.d.ts +16 -90
  326. package/dist/types/shared/clone.d.ts +2 -11
  327. package/dist/types/shared/contracts/accounts.d.ts +99 -0
  328. package/dist/types/shared/contracts/backups.d.ts +219 -0
  329. package/dist/types/shared/contracts/ddns.d.ts +208 -0
  330. package/dist/types/shared/contracts/frames.d.ts +1395 -0
  331. package/dist/types/shared/contracts/index.d.ts +3 -0
  332. package/dist/types/shared/contracts/logs.d.ts +107 -0
  333. package/dist/types/shared/contracts/proxy.d.ts +303 -0
  334. package/dist/types/shared/contracts.d.ts +852 -1982
  335. package/dist/types/shared/cpu-scale.d.ts +3 -19
  336. package/dist/types/shared/crash-cause.d.ts +8 -0
  337. package/dist/types/shared/cron.d.ts +70 -0
  338. package/dist/types/shared/ddns-form.d.ts +9 -43
  339. package/dist/types/shared/endpoint.d.ts +1 -7
  340. package/dist/types/shared/error-codes.d.ts +438 -0
  341. package/dist/types/shared/error-message.d.ts +1 -7
  342. package/dist/types/shared/fields.d.ts +7 -17
  343. package/dist/types/shared/form-repair.d.ts +1 -5
  344. package/dist/types/shared/generated.d.ts +3 -19
  345. package/dist/types/shared/host-readings.d.ts +25 -128
  346. package/dist/types/shared/lazy.d.ts +1 -1
  347. package/dist/types/shared/live-frames.d.ts +2 -8
  348. package/dist/types/shared/live-series.d.ts +2 -8
  349. package/dist/types/shared/live-store.d.ts +4 -8
  350. package/dist/types/shared/log-download.d.ts +6 -0
  351. package/dist/types/shared/meta.d.ts +6 -0
  352. package/dist/types/shared/password-policy.d.ts +10 -0
  353. package/dist/types/shared/patch-diff.d.ts +13 -72
  354. package/dist/types/shared/port-reading.d.ts +18 -0
  355. package/dist/types/shared/probe-latency.d.ts +3 -21
  356. package/dist/types/shared/proxy-form.d.ts +33 -74
  357. package/dist/types/shared/proxy-validate.d.ts +11 -0
  358. package/dist/types/shared/query-params.d.ts +8 -0
  359. package/dist/types/shared/server-attention.d.ts +2 -27
  360. package/dist/types/shared/server-form.d.ts +15 -54
  361. package/dist/types/shared/server-key.d.ts +1 -12
  362. package/dist/types/shared/server-readings.d.ts +7 -32
  363. package/dist/types/shared/server-url.d.ts +9 -31
  364. package/dist/types/shared/shape.d.ts +1 -16
  365. package/dist/types/shared/stream-access.d.ts +2 -8
  366. package/dist/types/shared/ui-format.d.ts +25 -65
  367. package/docs/API.md +315 -107
  368. package/docs/BACKUPS.md +61 -56
  369. package/docs/CLI.md +255 -49
  370. package/docs/DDNS.md +35 -49
  371. package/docs/JOBS.md +129 -0
  372. package/docs/NOTIFICATIONS.md +58 -90
  373. package/docs/REVERSE_PROXY.md +116 -188
  374. package/docs/SECURITY.md +126 -44
  375. package/docs/SERVERS.md +282 -409
  376. package/docs/UI_CREATION.md +90 -47
  377. package/docs/demo/blank-host-restore.sh +31 -7
  378. package/package.json +15 -6
  379. package/scripts/prepare.mjs +47 -0
  380. package/uis/stock/dist/assets/CopyButton-8mliL0xi.js +1 -0
  381. package/uis/stock/dist/assets/GlobalSettingsView-BINXY77E.js +1 -0
  382. package/uis/stock/dist/assets/LogViewer-kiSnTwdY.js +1 -0
  383. package/uis/stock/dist/assets/LogsView-DDXf_ONs.js +1 -0
  384. package/uis/stock/dist/assets/Modal-lrUuViF2.js +39 -0
  385. package/uis/stock/dist/assets/ProxyView-uXMaJdSQ.js +1 -0
  386. package/uis/stock/dist/assets/ServerDetailView-CW0Vb_c0.js +4 -0
  387. package/uis/stock/dist/assets/SettingsShell-B135xWjJ.js +1 -0
  388. package/uis/stock/dist/assets/SettingsView-BLtWxVkl.js +2 -0
  389. package/uis/stock/dist/assets/de-BIoTrHBQ.js +1 -0
  390. package/uis/stock/dist/assets/es-x4-ih8lH.js +1 -0
  391. package/uis/stock/dist/assets/fr-DatqBBkO.js +1 -0
  392. package/uis/stock/dist/assets/index-CnojaKcA.css +2 -0
  393. package/uis/stock/dist/assets/index-D-CiZReu.js +16 -0
  394. package/uis/stock/dist/assets/ja-CW1703Gw.js +1 -0
  395. package/uis/stock/dist/assets/ko-wFbT4XtK.js +1 -0
  396. package/uis/stock/dist/assets/ru-C1p5C4VN.js +1 -0
  397. package/uis/stock/dist/assets/useUnsavedGuard-BcsXsfCC.js +9 -0
  398. package/uis/stock/dist/assets/vi-CDqr0uie.js +1 -0
  399. package/uis/stock/dist/assets/zh-CN-BJ7iit-X.js +1 -0
  400. package/uis/stock/dist/index.html +4 -3
  401. package/uis/stock/dist/ui.json +3 -3
  402. package/dist/chunks/archive-DP-XQR8X.js.map +0 -1
  403. package/dist/chunks/atomic-C1PfJpE7.js.map +0 -1
  404. package/dist/chunks/backup-CZcVca2a.js.map +0 -1
  405. package/dist/chunks/backups-CFRaWe_m.js +0 -4691
  406. package/dist/chunks/backups-CFRaWe_m.js.map +0 -1
  407. package/dist/chunks/config-text-DifCHhnz.js +0 -50
  408. package/dist/chunks/config-text-DifCHhnz.js.map +0 -1
  409. package/dist/chunks/contracts-CMBD1TF9.js.map +0 -1
  410. package/dist/chunks/daemon-log-BVj8cDEo.js +0 -241
  411. package/dist/chunks/daemon-log-BVj8cDEo.js.map +0 -1
  412. package/dist/chunks/daemon-qKVECISl.js +0 -247
  413. package/dist/chunks/daemon-qKVECISl.js.map +0 -1
  414. package/dist/chunks/docker-Cy9Lyvda.js.map +0 -1
  415. package/dist/chunks/down-pKbGCW9d.js.map +0 -1
  416. package/dist/chunks/init-BZ7hK9Vf.js.map +0 -1
  417. package/dist/chunks/last-stop-C-BXz_XI.js +0 -53
  418. package/dist/chunks/last-stop-C-BXz_XI.js.map +0 -1
  419. package/dist/chunks/layout-DwTtmund.js +0 -24
  420. package/dist/chunks/layout-DwTtmund.js.map +0 -1
  421. package/dist/chunks/lazy-Ce5zEAq1.js +0 -66
  422. package/dist/chunks/lazy-Ce5zEAq1.js.map +0 -1
  423. package/dist/chunks/log-buffer-Dy9HHDMD.js +0 -414
  424. package/dist/chunks/log-buffer-Dy9HHDMD.js.map +0 -1
  425. package/dist/chunks/logger-B5U4GD3j.js.map +0 -1
  426. package/dist/chunks/logs---TI_bxM.js.map +0 -1
  427. package/dist/chunks/migrate-Cfoq-Vgh.js +0 -155
  428. package/dist/chunks/migrate-Cfoq-Vgh.js.map +0 -1
  429. package/dist/chunks/nanny-B-Eu0sFW.js.map +0 -1
  430. package/dist/chunks/nanny-BtWfy0QH.js +0 -1167
  431. package/dist/chunks/nanny-BtWfy0QH.js.map +0 -1
  432. package/dist/chunks/nanny-sweep-DErnlPY1.js.map +0 -1
  433. package/dist/chunks/nearest-6KgQEDUe.js.map +0 -1
  434. package/dist/chunks/parse-DhmG26fI.js.map +0 -1
  435. package/dist/chunks/paths-CGlGDrOU.js.map +0 -1
  436. package/dist/chunks/port-B8WBTRMk.js.map +0 -1
  437. package/dist/chunks/restart-Des4DrAN.js.map +0 -1
  438. package/dist/chunks/schema-B240VXcV.js.map +0 -1
  439. package/dist/chunks/secrets-BieELnZh.js +0 -562
  440. package/dist/chunks/secrets-BieELnZh.js.map +0 -1
  441. package/dist/chunks/server-Bge2r2qQ.js +0 -169
  442. package/dist/chunks/server-Bge2r2qQ.js.map +0 -1
  443. package/dist/chunks/server-ids-DRuNLVCV.js +0 -32
  444. package/dist/chunks/server-ids-DRuNLVCV.js.map +0 -1
  445. package/dist/chunks/set-password-D5vZqqSX.js +0 -43
  446. package/dist/chunks/set-password-D5vZqqSX.js.map +0 -1
  447. package/dist/chunks/set-token-obPiEJYk.js +0 -78
  448. package/dist/chunks/set-token-obPiEJYk.js.map +0 -1
  449. package/dist/chunks/settings-xu-XTfWg.js.map +0 -1
  450. package/dist/chunks/setup-temp-CAN4_bA-.js.map +0 -1
  451. package/dist/chunks/shape-DnTKzjQ2.js +0 -24
  452. package/dist/chunks/shape-DnTKzjQ2.js.map +0 -1
  453. package/dist/chunks/src-BtWMFmzZ.js.map +0 -1
  454. package/dist/chunks/status-DT1EsA-B.js.map +0 -1
  455. package/dist/chunks/ui-D562aqw5.js.map +0 -1
  456. package/dist/chunks/ui-dir-CsU3uLNV.js.map +0 -1
  457. package/dist/chunks/ui-release-DKzVvlLd.js.map +0 -1
  458. package/dist/chunks/ui-revert-EkBBwRTt.js.map +0 -1
  459. package/dist/chunks/ui-switch-BnZTdMDd.js.map +0 -1
  460. package/dist/chunks/ui-update-_xryLYxw.js.map +0 -1
  461. package/dist/chunks/up-Pdz-l6IH.js.map +0 -1
  462. package/dist/chunks/usage-DFrCVXpT.js.map +0 -1
  463. package/dist/chunks/workspaces-DYcfvKV_.js.map +0 -1
  464. package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +0 -1
  465. package/dist/types/cli/set-password.d.ts +0 -14
  466. package/dist/types/cli/set-token.d.ts +0 -21
  467. package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +0 -1
  468. package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +0 -1
  469. package/uis/stock/dist/assets/LogViewer-DIliXy62.js +0 -1
  470. package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +0 -1
  471. package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +0 -39
  472. package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +0 -1
  473. package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +0 -2
  474. package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +0 -1
  475. package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +0 -2
  476. package/uis/stock/dist/assets/de-BRITeb0H.js +0 -1
  477. package/uis/stock/dist/assets/es-B2zIEssV.js +0 -1
  478. package/uis/stock/dist/assets/fr-s0ZOBEqh.js +0 -1
  479. package/uis/stock/dist/assets/index-C1MehbKy.css +0 -2
  480. package/uis/stock/dist/assets/index-CnBN54wF.js +0 -15
  481. package/uis/stock/dist/assets/ja-CU7MR85V.js +0 -1
  482. package/uis/stock/dist/assets/ko-tL5Me6d-.js +0 -1
  483. package/uis/stock/dist/assets/ru-92yrvkNJ.js +0 -1
  484. package/uis/stock/dist/assets/vi-CzvY16k2.js +0 -1
  485. package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +0 -1
@@ -1,562 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { C as errorMessage } from "../cli.js";
3
- import { t as writeFileAtomic } from "./atomic-C1PfJpE7.js";
4
- import { n as readStateFile } from "./config-text-DifCHhnz.js";
5
- import { t as logger } from "./logger-B5U4GD3j.js";
6
- import { t as isRecord } from "./shape-DnTKzjQ2.js";
7
- import process from "node:process";
8
- import fs from "node:fs";
9
- import { Buffer } from "node:buffer";
10
- import crypto from "node:crypto";
11
- //#region src/config/secrets.ts
12
- var secrets_exports = /* @__PURE__ */ __exportAll({
13
- API_TOKEN_PREFIX: () => "hh_",
14
- DEFAULT_DDNS_SECRET: () => "hh",
15
- LEGACY_DEFAULT_PASSWORD: () => "hh",
16
- LEGACY_TELEGRAM_ID: () => LEGACY_TELEGRAM_ID,
17
- SecretsStore: () => SecretsStore,
18
- apiTokenRecord: () => apiTokenRecord,
19
- deriveKey: () => deriveKey,
20
- generateApiToken: () => generateApiToken,
21
- generateInitialPassword: () => generateInitialPassword,
22
- hashApiToken: () => hashApiToken,
23
- hashPassword: () => hashPassword,
24
- verifyApiToken: () => verifyApiToken,
25
- verifyPassword: () => verifyPassword
26
- });
27
- /** Node's scrypt defaults, pinned so a hash stays verifiable across versions. */
28
- var COST = {
29
- N: 16384,
30
- r: 8,
31
- p: 1
32
- };
33
- var KEYLEN = 64;
34
- var SALT_BYTES = 16;
35
- /** Owned by this release, plus `version`: retired, and dropped on the next write rather than carried. */
36
- var KNOWN_SECRET_KEYS = /* @__PURE__ */ new Set([
37
- "password",
38
- "apiToken",
39
- "telegram",
40
- "ddns",
41
- "ddnsKdf",
42
- "version"
43
- ]);
44
- function unknownTopLevel(parsed) {
45
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {};
46
- return Object.fromEntries(Object.entries(parsed).filter(([key]) => !KNOWN_SECRET_KEYS.has(key)));
47
- }
48
- /**
49
- * The id the config migration gives a pre-list Telegram destination, so its stored `{ botToken }`
50
- * still finds an owner after the upgrade.
51
- */
52
- var LEGACY_TELEGRAM_ID = "telegram";
53
- var DDNS_KEYLEN = 32;
54
- var DDNS_IV_BYTES = 12;
55
- var DDNS_AAD_PREFIX = "hh-ddns-v1:";
56
- var DDNS_SEALED_ALGO = "aes-256-gcm";
57
- function deriveKey(password, salt, cost, keylen) {
58
- return crypto.scryptSync(password.normalize("NFKC"), salt, keylen, { ...cost });
59
- }
60
- function hashPassword(password, options = {}) {
61
- const salt = crypto.randomBytes(SALT_BYTES);
62
- return {
63
- algo: "scrypt",
64
- salt: salt.toString("base64"),
65
- hash: deriveKey(password, salt, COST, KEYLEN).toString("base64"),
66
- keylen: KEYLEN,
67
- cost: { ...COST },
68
- updatedAt: options.now ?? Date.now(),
69
- ...options.isDefault === true ? { isDefault: true } : {},
70
- ...options.isDefault === true && options.initial === true ? { initial: password } : {}
71
- };
72
- }
73
- /** A random first-run password: 12 characters from an unambiguous alphabet, ~60 bits. */
74
- function generateInitialPassword() {
75
- const alphabet = "abcdefghjkmnpqrstuvwxyz23456789";
76
- const chars = [...crypto.randomBytes(12)].map((byte) => alphabet[byte % 31]);
77
- return [
78
- chars.slice(0, 4),
79
- chars.slice(4, 8),
80
- chars.slice(8)
81
- ].map((group) => group.join("")).join("-");
82
- }
83
- function verifyPassword(password, record) {
84
- const expected = Buffer.from(record.hash, "base64");
85
- let actual;
86
- try {
87
- actual = deriveKey(password, Buffer.from(record.salt, "base64"), record.cost, record.keylen);
88
- } catch {
89
- return false;
90
- }
91
- if (actual.length !== expected.length) return false;
92
- return crypto.timingSafeEqual(actual, expected);
93
- }
94
- var API_TOKEN_BYTES = 32;
95
- var API_TOKEN_HINT_CHARS = 8;
96
- function generateApiToken() {
97
- return `hh_${crypto.randomBytes(API_TOKEN_BYTES).toString("base64url")}`;
98
- }
99
- function hashApiToken(token) {
100
- return crypto.createHash("sha256").update(token, "utf8").digest("base64");
101
- }
102
- function verifyApiToken(token, record) {
103
- if (token.length === 0) return false;
104
- const expected = Buffer.from(record.hash, "base64");
105
- const actual = Buffer.from(hashApiToken(token), "base64");
106
- if (actual.length !== expected.length) return false;
107
- return crypto.timingSafeEqual(actual, expected);
108
- }
109
- function apiTokenRecord(token, now = Date.now()) {
110
- return {
111
- algo: "sha256",
112
- hash: hashApiToken(token),
113
- hint: token.slice(0, API_TOKEN_HINT_CHARS),
114
- updatedAt: now
115
- };
116
- }
117
- /** A field map: strings only, empty values dropped; anything else reads as absent. */
118
- function readDdnsValues(value) {
119
- if (!isRecord(value)) return {};
120
- const out = {};
121
- for (const [key, field] of Object.entries(value)) if (typeof field === "string" && field.length > 0) out[key] = field;
122
- return out;
123
- }
124
- function isSealedDdns(value) {
125
- return isRecord(value) && value.algo === DDNS_SEALED_ALGO && typeof value.iv === "string" && typeof value.tag === "string" && typeof value.data === "string";
126
- }
127
- function isPlainDdns(value) {
128
- return "plain" in value;
129
- }
130
- /**
131
- * The bot tokens by destination id.
132
- *
133
- * Two shapes read: the map this release writes, and the single `{ botToken }` written before a
134
- * workspace could have more than one Telegram destination. The old one arrives under the id the
135
- * config migration gave the destination it came from, so an upgrade keeps a working Telegram.
136
- */
137
- function readTelegramTokens(value) {
138
- if (!isRecord(value)) return {};
139
- if (typeof value.botToken === "string") return value.botToken.trim().length > 0 ? { [LEGACY_TELEGRAM_ID]: value.botToken.trim() } : {};
140
- const tokens = {};
141
- for (const [id, token] of Object.entries(value)) if (typeof token === "string" && token.trim().length > 0) tokens[id] = token.trim();
142
- return tokens;
143
- }
144
- /**
145
- * Sealed on disk, or `{ provider, values }` waiting for the sealing write. A bare
146
- * field map — written before the provider was recorded — no longer reads, because
147
- * there is nothing to say which provider those fields belong to.
148
- */
149
- function readStoredDdns(value) {
150
- if (!isRecord(value)) return {};
151
- const out = {};
152
- for (const [accountId, entry] of Object.entries(value)) {
153
- if (isSealedDdns(entry)) {
154
- out[accountId] = entry;
155
- continue;
156
- }
157
- if (!isRecord(entry) || typeof entry.provider !== "string" || entry.provider.length === 0) continue;
158
- const values = readDdnsValues(entry.values);
159
- if (Object.keys(values).length === 0) continue;
160
- out[accountId] = {
161
- plain: true,
162
- provider: entry.provider,
163
- values
164
- };
165
- }
166
- return out;
167
- }
168
- function readDdnsKdf(value) {
169
- if (!isRecord(value) || value.algo !== "scrypt" || typeof value.salt !== "string") return null;
170
- const cost = isRecord(value.cost) ? value.cost : {};
171
- const N = Number(cost.N);
172
- const r = Number(cost.r);
173
- const p = Number(cost.p);
174
- if (!Number.isInteger(N) || !Number.isInteger(r) || !Number.isInteger(p) || N < 2 || r < 1 || p < 1) return null;
175
- return {
176
- algo: "scrypt",
177
- cost: {
178
- N,
179
- r,
180
- p
181
- },
182
- salt: value.salt
183
- };
184
- }
185
- function newDdnsKdf() {
186
- return {
187
- algo: "scrypt",
188
- cost: { ...COST },
189
- salt: crypto.randomBytes(SALT_BYTES).toString("base64")
190
- };
191
- }
192
- /** The account id is the AAD, so a sealed entry cannot be moved to another account. */
193
- function ddnsAad(accountId) {
194
- return Buffer.from(`${DDNS_AAD_PREFIX}${accountId}`, "utf8");
195
- }
196
- function sealDdns(accountId, record, key) {
197
- const iv = crypto.randomBytes(DDNS_IV_BYTES);
198
- const cipher = crypto.createCipheriv(DDNS_SEALED_ALGO, key, iv);
199
- cipher.setAAD(ddnsAad(accountId));
200
- const data = Buffer.concat([cipher.update(JSON.stringify(record), "utf8"), cipher.final()]);
201
- return {
202
- algo: DDNS_SEALED_ALGO,
203
- iv: iv.toString("base64"),
204
- tag: cipher.getAuthTag().toString("base64"),
205
- data: data.toString("base64")
206
- };
207
- }
208
- /** Null when the tag does not verify: a different secret, or a file somebody edited. */
209
- function openDdns(accountId, sealed, key) {
210
- try {
211
- const decipher = crypto.createDecipheriv(DDNS_SEALED_ALGO, key, Buffer.from(sealed.iv, "base64"));
212
- decipher.setAAD(ddnsAad(accountId));
213
- decipher.setAuthTag(Buffer.from(sealed.tag, "base64"));
214
- const plain = Buffer.concat([decipher.update(Buffer.from(sealed.data, "base64")), decipher.final()]).toString("utf8");
215
- const parsed = JSON.parse(plain);
216
- if (typeof parsed?.provider !== "string") return null;
217
- const values = readDdnsValues(parsed.values);
218
- return Object.keys(values).length === 0 ? null : {
219
- provider: parsed.provider,
220
- values
221
- };
222
- } catch {
223
- return null;
224
- }
225
- }
226
- /**
227
- * The password hash and the API token are secrets, so they live outside
228
- * `servers.config.json` (which is tracked) in a 0600 file that is git-ignored.
229
- *
230
- * DDNS provider credentials are the one thing here the panel has to replay to a
231
- * third party, so they are sealed with AES-256-GCM under `HHOSTED_DDNS_SECRET`.
232
- * Everything else is a one-way hash and needs no key.
233
- */
234
- var SecretsStore = class {
235
- file;
236
- scope;
237
- cache = null;
238
- cacheKey = "";
239
- error = null;
240
- ddnsKeyCache = null;
241
- warnedAccounts = /* @__PURE__ */ new Set();
242
- warnedDefaultSecret = false;
243
- ddnsSecret;
244
- constructor(file, ddnsSecret, scope = "all") {
245
- this.file = file;
246
- this.scope = scope;
247
- const candidate = (ddnsSecret ?? process.env.HHOSTED_DDNS_SECRET ?? "").trim();
248
- this.ddnsSecret = candidate.length > 0 ? candidate : "hh";
249
- }
250
- /**
251
- * Whether the DDNS credentials are sealed under the built-in key.
252
- *
253
- * Sealing is what stops a leaked *file* — a backup, a committed state directory — from handing over
254
- * the DNS credentials. Under the default the key is the literal `hh`, so anyone holding the file can
255
- * open it. The docs say so; this is the same fact for code that wants to say so at runtime.
256
- */
257
- get usingDefaultDdnsSecret() {
258
- return this.ddnsSecret === "hh";
259
- }
260
- get path() {
261
- return this.file;
262
- }
263
- /**
264
- * Re-reads whenever the file changes on disk, so a password set by
265
- * `home-hosted set-password` (or another process) takes effect without
266
- * restarting `up`.
267
- */
268
- load() {
269
- const key = this.statKey();
270
- if (this.cache !== null && key === this.cacheKey) return this.cache;
271
- this.cache = this.read();
272
- this.cacheKey = key;
273
- return this.cache;
274
- }
275
- statKey() {
276
- try {
277
- const stats = fs.statSync(this.file);
278
- return `${stats.mtimeMs}:${stats.size}`;
279
- } catch {
280
- return "missing";
281
- }
282
- }
283
- get password() {
284
- return this.load().password;
285
- }
286
- get passwordUpdatedAt() {
287
- return this.password?.updatedAt ?? null;
288
- }
289
- get passwordSet() {
290
- return this.password !== null;
291
- }
292
- get usingDefaultPassword() {
293
- return this.password?.isDefault === true;
294
- }
295
- get apiToken() {
296
- return this.load().apiToken;
297
- }
298
- get apiTokenSet() {
299
- return this.apiToken !== null;
300
- }
301
- /** The readable head of the stored token, or null when none is set. */
302
- get apiTokenHint() {
303
- return this.apiToken?.hint ?? null;
304
- }
305
- /** The bot token for one destination, or null when it has none. */
306
- telegramToken(id) {
307
- const token = this.load().telegram[id] ?? "";
308
- return token.length > 0 ? token : null;
309
- }
310
- telegramTokenSet(id) {
311
- return this.telegramToken(id) !== null;
312
- }
313
- /** Every destination id a token is stored for — including one the config no longer declares. */
314
- get telegramTokenIds() {
315
- return Object.keys(this.load().telegram).sort();
316
- }
317
- /**
318
- * The first-run password while it is still the one in use, for a person on this machine.
319
- * A home from before 0.12 still on the shared default reports that one.
320
- */
321
- get initialPassword() {
322
- const record = this.password;
323
- if (record?.isDefault !== true) return null;
324
- if (typeof record.initial === "string" && record.initial.length > 0) return record.initial;
325
- return verifyPassword("hh", record) ? "hh" : null;
326
- }
327
- setPassword(password, options = {}) {
328
- const record = hashPassword(password, options);
329
- this.save({
330
- ...this.load(),
331
- password: record
332
- });
333
- return record;
334
- }
335
- /** Creates the first-run password only when none exists yet. */
336
- ensureDefaultPassword(password) {
337
- if (this.passwordSet) return null;
338
- return this.setPassword(password, {
339
- isDefault: true,
340
- initial: true
341
- });
342
- }
343
- clearPassword() {
344
- this.save({
345
- ...this.load(),
346
- password: null
347
- });
348
- }
349
- setApiToken(token) {
350
- const record = apiTokenRecord(token);
351
- this.save({
352
- ...this.load(),
353
- apiToken: record
354
- });
355
- return record;
356
- }
357
- clearApiToken() {
358
- this.save({
359
- ...this.load(),
360
- apiToken: null
361
- });
362
- }
363
- setTelegramToken(id, token) {
364
- const trimmed = token?.trim() ?? "";
365
- const current = { ...this.load().telegram };
366
- if (trimmed.length > 0) current[id] = trimmed;
367
- else delete current[id];
368
- this.save({
369
- ...this.load(),
370
- telegram: current
371
- });
372
- }
373
- /** Drops every token whose destination is gone, so a deleted target leaves nothing behind. */
374
- forgetTelegramTokens(keep) {
375
- const allowed = new Set(keep);
376
- const current = this.load().telegram;
377
- const next = Object.fromEntries(Object.entries(current).filter(([id]) => allowed.has(id)));
378
- if (Object.keys(next).length !== Object.keys(current).length) this.save({
379
- ...this.load(),
380
- telegram: next
381
- });
382
- }
383
- /** Ids that have something stored, whether or not a config still declares them. */
384
- get ddnsAccountIds() {
385
- return Object.keys(this.load().ddns);
386
- }
387
- /**
388
- * Null when nothing is stored, when the entry belongs to a different provider,
389
- * or when the secret cannot open it.
390
- */
391
- getDdnsCredentials(accountId, provider) {
392
- const stored = this.load().ddns[accountId];
393
- if (stored === void 0) return null;
394
- const record = this.openStored(accountId, stored);
395
- if (record === null) return null;
396
- return record.provider === provider ? record : null;
397
- }
398
- /** An empty field is dropped, so clearing every field forgets the account. */
399
- setDdnsCredentials(accountId, provider, credentials) {
400
- const current = this.load();
401
- const values = readDdnsValues(credentials);
402
- const ddns = { ...current.ddns };
403
- if (Object.keys(values).length === 0) delete ddns[accountId];
404
- else ddns[accountId] = {
405
- plain: true,
406
- provider,
407
- values
408
- };
409
- this.save({
410
- ...current,
411
- ddns
412
- });
413
- }
414
- clearDdnsCredentials(accountId) {
415
- const current = this.load();
416
- if (current.ddns[accountId] === void 0) return;
417
- const ddns = { ...current.ddns };
418
- delete ddns[accountId];
419
- this.save({
420
- ...current,
421
- ddns
422
- });
423
- }
424
- /** Keeps only the accounts a config still declares; returns how many were dropped. */
425
- pruneDdnsCredentials(keep) {
426
- const wanted = new Set(keep);
427
- const current = this.load();
428
- const removed = Object.keys(current.ddns).filter((id) => !wanted.has(id));
429
- if (removed.length === 0) return 0;
430
- const ddns = { ...current.ddns };
431
- for (const id of removed) delete ddns[id];
432
- this.save({
433
- ...current,
434
- ddns
435
- });
436
- return removed.length;
437
- }
438
- openStored(accountId, stored) {
439
- if (isPlainDdns(stored)) return {
440
- provider: stored.provider,
441
- values: stored.values
442
- };
443
- const kdf = this.load().ddnsKdf;
444
- if (kdf === null) {
445
- this.warnOnce(accountId, "the file carries no key parameters");
446
- return null;
447
- }
448
- const record = openDdns(accountId, stored, this.ddnsKey(kdf));
449
- if (record === null) this.warnOnce(accountId, `the entry could not be opened — is HHOSTED_DDNS_SECRET still the one it was sealed with?`);
450
- return record;
451
- }
452
- /** One derivation per file salt, cached for the life of the process. */
453
- ddnsKey(kdf) {
454
- if (this.ddnsKeyCache?.salt === kdf.salt) return this.ddnsKeyCache.key;
455
- const key = deriveKey(this.ddnsSecret, Buffer.from(kdf.salt, "base64"), kdf.cost, DDNS_KEYLEN);
456
- this.ddnsKeyCache = {
457
- salt: kdf.salt,
458
- key
459
- };
460
- return key;
461
- }
462
- warnOnce(accountId, reason) {
463
- if (this.warnedAccounts.has(accountId)) return;
464
- this.warnedAccounts.add(accountId);
465
- logger.warn(`ddns: cannot read the credentials for "${accountId}" — ${reason}`);
466
- }
467
- /**
468
- * A secrets file that exists but cannot be parsed, or null when it is fine (or absent).
469
- *
470
- * `read()` still returns the empty shape — a corrupt file must not authenticate anyone — but
471
- * "unreadable" and "absent" have to stay distinguishable: treated as absent, a truncated
472
- * `.control-secrets.json` reads as a fresh install, and `runControlPlane` then writes a
473
- * **default-password** file over it, destroying the password hash, the API token and every
474
- * Telegram and DDNS credential. Only the caller can refuse the boot, so this is its surface.
475
- */
476
- get configError() {
477
- this.load();
478
- return this.error;
479
- }
480
- read() {
481
- this.error = null;
482
- const empty = {
483
- password: null,
484
- apiToken: null,
485
- telegram: {},
486
- ddns: {},
487
- ddnsKdf: null
488
- };
489
- if (!fs.existsSync(this.file)) return this.inScope(empty);
490
- let text;
491
- try {
492
- text = readStateFile(this.file);
493
- } catch (error) {
494
- this.error = `cannot read ${this.file}: ${errorMessage(error)}`;
495
- return this.inScope(empty);
496
- }
497
- try {
498
- const parsed = JSON.parse(text);
499
- return this.inScope({
500
- password: parsed?.password ?? null,
501
- apiToken: parsed?.apiToken?.hash ? parsed.apiToken : null,
502
- telegram: readTelegramTokens(parsed?.telegram),
503
- ddns: readStoredDdns(parsed?.ddns),
504
- ddnsKdf: readDdnsKdf(parsed?.ddnsKdf),
505
- extra: unknownTopLevel(parsed)
506
- });
507
- } catch (error) {
508
- this.error = `${this.file} is not readable JSON (${errorMessage(error)}) — it was left untouched`;
509
- return this.inScope(empty);
510
- }
511
- }
512
- /** Everything a store does not own is neither read from nor written to its file. */
513
- inScope(contents) {
514
- if (this.scope === "global") return {
515
- ...contents,
516
- telegram: {},
517
- ddns: {},
518
- ddnsKdf: null
519
- };
520
- if (this.scope === "workspace") return {
521
- ...contents,
522
- password: null,
523
- apiToken: null
524
- };
525
- return contents;
526
- }
527
- save(contents) {
528
- if (this.configError !== null) throw new Error(`refusing to write ${this.file}: ${this.error}`);
529
- const sealed = this.sealStored(this.inScope(contents));
530
- const { extra, ...known } = sealed;
531
- writeFileAtomic(this.file, `${JSON.stringify({
532
- ...known,
533
- ...extra
534
- }, null, 2)}\n`, { mode: 384 });
535
- this.cache = sealed;
536
- }
537
- /** Any write seals the entries still sitting in the clear, so the file never keeps both. */
538
- sealStored(contents) {
539
- const plain = Object.entries(contents.ddns).filter((entry) => isPlainDdns(entry[1]));
540
- if (plain.length === 0) return contents;
541
- if (this.usingDefaultDdnsSecret && !this.warnedDefaultSecret) {
542
- this.warnedDefaultSecret = true;
543
- logger.warn(`ddns: credentials are sealed under the built-in key — set HHOSTED_DDNS_SECRET to protect them if this state directory is ever copied or committed (docs/DDNS.md)`);
544
- }
545
- const kdf = contents.ddnsKdf ?? newDdnsKdf();
546
- const key = this.ddnsKey(kdf);
547
- const ddns = { ...contents.ddns };
548
- for (const [accountId, record] of plain) ddns[accountId] = sealDdns(accountId, {
549
- provider: record.provider,
550
- values: record.values
551
- }, key);
552
- return {
553
- ...contents,
554
- ddns,
555
- ddnsKdf: kdf
556
- };
557
- }
558
- };
559
- //#endregion
560
- export { secrets_exports as a, generateInitialPassword as i, SecretsStore as n, verifyApiToken as o, generateApiToken as r, verifyPassword as s, LEGACY_TELEGRAM_ID as t };
561
-
562
- //# sourceMappingURL=secrets-BieELnZh.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secrets-BieELnZh.js","names":[],"sources":["../../src/config/secrets.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\nimport crypto from 'node:crypto'\nimport fs from 'node:fs'\nimport process from 'node:process'\nimport { writeFileAtomic } from '#src/helpers/atomic'\nimport { readStateFile } from '#src/helpers/config-text'\nimport { logger } from '#src/helpers/logger'\nimport { errorMessage } from '#src/shared/error-message'\nimport { isRecord } from '#src/shared/shape'\n\n/** Node's scrypt defaults, pinned so a hash stays verifiable across versions. */\nconst COST = { N: 16384, r: 8, p: 1 } as const\nconst KEYLEN = 64\nconst SALT_BYTES = 16\n\nexport interface PasswordRecord {\n algo: 'scrypt'\n salt: string\n hash: string\n keylen: number\n cost: { N: number, r: number, p: number }\n updatedAt: number\n /** Set for the boot-time default, so the UI can say so and exposure stays blocked. */\n isDefault?: boolean\n /**\n * The generated first-run password, kept in this 0600 file only while it is still in use so\n * `up`/`status` can show it on the machine. Never sent over the API; gone with the first change.\n */\n initial?: string\n}\n\n/**\n * An API token for scripts and agents. Tokens are high-entropy randoms, so a\n * plain SHA-256 is the right hash — scrypt would only make every request pay\n * for a slow KDF it does not need. `hint` is the readable head, kept so a human\n * can tell two tokens apart without the file ever holding the whole secret.\n */\nexport interface ApiTokenRecord {\n algo: 'sha256'\n hash: string\n hint: string\n updatedAt: number\n}\n\n/** One account's provider credentials, with the provider they were entered for. */\nexport interface DdnsCredentialRecord {\n provider: string\n values: Record<string, string>\n}\n\n/** An account's credentials as they sit on disk: sealed, never plaintext. */\ninterface SealedDdnsRecord {\n algo: 'aes-256-gcm'\n iv: string\n tag: string\n data: string\n}\n\n/** Read from a file written before sealing; re-sealed by the next write. */\ninterface PlainDdnsRecord {\n plain: true\n provider: string\n values: Record<string, string>\n}\n\ntype StoredDdnsRecord = SealedDdnsRecord | PlainDdnsRecord\n\n/** One derivation per process: the secret is combined with this per-file salt. */\ninterface DdnsKdfMeta {\n algo: 'scrypt'\n cost: ScryptCost\n salt: string\n}\n\n/**\n * Which halves of the file a store owns. Global secrets (the password hash and\n * the API token) live above the workspaces, in `.hh/.control-secrets.json`;\n * workspace secrets (the Telegram bot token and DDNS credentials) live in that\n * workspace's own `.secrets.json`. `all` is the shape the pre-workspace file had\n * and is still what a backup archive may carry.\n */\nexport type SecretsScope = 'all' | 'global' | 'workspace'\n\ninterface SecretsFile {\n password: PasswordRecord | null\n apiToken: ApiTokenRecord | null\n /**\n * Bot tokens by destination id. A map, not a singleton: a workspace may point at more than one\n * Telegram chat, and each destination carries its own bot.\n */\n telegram: Record<string, string>\n /** Per-DDNS-account credentials, keyed by the account id in the config. */\n ddns: Record<string, StoredDdnsRecord>\n /** How the DDNS key is derived; absent until the first sealed write. */\n ddnsKdf: DdnsKdfMeta | null\n /** Top-level keys this release does not know, carried through a write so a newer release keeps them. */\n extra?: Record<string, unknown>\n}\n\n/** Owned by this release, plus `version`: retired, and dropped on the next write rather than carried. */\nconst KNOWN_SECRET_KEYS = new Set(['password', 'apiToken', 'telegram', 'ddns', 'ddnsKdf', 'version'])\n\nfunction unknownTopLevel(parsed: unknown): Record<string, unknown> {\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))\n return {}\n return Object.fromEntries(Object.entries(parsed).filter(([key]) => !KNOWN_SECRET_KEYS.has(key)))\n}\n\n/**\n * The id the config migration gives a pre-list Telegram destination, so its stored `{ botToken }`\n * still finds an owner after the upgrade.\n */\nexport const LEGACY_TELEGRAM_ID = 'telegram'\n\n/** So a first run is sealed rather than plaintext; set `HHOSTED_DDNS_SECRET` for real protection. */\nexport const DEFAULT_DDNS_SECRET = 'hh'\nconst DDNS_KEYLEN = 32\nconst DDNS_IV_BYTES = 12\nconst DDNS_AAD_PREFIX = 'hh-ddns-v1:'\nconst DDNS_SEALED_ALGO = 'aes-256-gcm'\n\nexport interface ScryptCost { N: number, r: number, p: number }\n\nexport function deriveKey(password: string, salt: Buffer, cost: ScryptCost, keylen: number): Buffer {\n return crypto.scryptSync(password.normalize('NFKC'), salt, keylen, { ...cost })\n}\n\nexport function hashPassword(password: string, options: { now?: number, isDefault?: boolean, initial?: boolean } = {}): PasswordRecord {\n const salt = crypto.randomBytes(SALT_BYTES)\n return {\n algo: 'scrypt',\n salt: salt.toString('base64'),\n hash: deriveKey(password, salt, COST, KEYLEN).toString('base64'),\n keylen: KEYLEN,\n cost: { ...COST },\n updatedAt: options.now ?? Date.now(),\n ...(options.isDefault === true ? { isDefault: true } : {}),\n ...(options.isDefault === true && options.initial === true ? { initial: password } : {}),\n }\n}\n\n/** The pre-0.12 boot password every install shared. Still recognised, never created. */\nexport const LEGACY_DEFAULT_PASSWORD = 'hh'\n\n/** A random first-run password: 12 characters from an unambiguous alphabet, ~60 bits. */\nexport function generateInitialPassword(): string {\n const alphabet = 'abcdefghjkmnpqrstuvwxyz23456789'\n const bytes = crypto.randomBytes(12)\n const chars = [...bytes].map(byte => alphabet[byte % alphabet.length])\n return [chars.slice(0, 4), chars.slice(4, 8), chars.slice(8)].map(group => group.join('')).join('-')\n}\n\nexport function verifyPassword(password: string, record: PasswordRecord): boolean {\n const expected = Buffer.from(record.hash, 'base64')\n let actual: Buffer\n try {\n actual = deriveKey(password, Buffer.from(record.salt, 'base64'), record.cost, record.keylen)\n }\n catch {\n return false\n }\n if (actual.length !== expected.length)\n return false\n return crypto.timingSafeEqual(actual, expected)\n}\n\n/** Visible head of a generated token, so a token is recognisable on sight. */\nexport const API_TOKEN_PREFIX = 'hh_'\nconst API_TOKEN_BYTES = 32\nconst API_TOKEN_HINT_CHARS = 8\n\nexport function generateApiToken(): string {\n return `${API_TOKEN_PREFIX}${crypto.randomBytes(API_TOKEN_BYTES).toString('base64url')}`\n}\n\nexport function hashApiToken(token: string): string {\n return crypto.createHash('sha256').update(token, 'utf8').digest('base64')\n}\n\nexport function verifyApiToken(token: string, record: ApiTokenRecord): boolean {\n if (token.length === 0)\n return false\n const expected = Buffer.from(record.hash, 'base64')\n const actual = Buffer.from(hashApiToken(token), 'base64')\n // A hand-edited or truncated secrets file must not make every request throw.\n if (actual.length !== expected.length)\n return false\n return crypto.timingSafeEqual(actual, expected)\n}\n\nexport function apiTokenRecord(token: string, now = Date.now()): ApiTokenRecord {\n return {\n algo: 'sha256',\n hash: hashApiToken(token),\n hint: token.slice(0, API_TOKEN_HINT_CHARS),\n updatedAt: now,\n }\n}\n\n/** A field map: strings only, empty values dropped; anything else reads as absent. */\nfunction readDdnsValues(value: unknown): Record<string, string> {\n if (!isRecord(value))\n return {}\n const out: Record<string, string> = {}\n for (const [key, field] of Object.entries(value)) {\n if (typeof field === 'string' && field.length > 0)\n out[key] = field\n }\n return out\n}\n\nfunction isSealedDdns(value: unknown): value is SealedDdnsRecord {\n return isRecord(value)\n && value.algo === DDNS_SEALED_ALGO\n && typeof value.iv === 'string'\n && typeof value.tag === 'string'\n && typeof value.data === 'string'\n}\n\nfunction isPlainDdns(value: StoredDdnsRecord): value is PlainDdnsRecord {\n return 'plain' in value\n}\n\n/**\n * The bot tokens by destination id.\n *\n * Two shapes read: the map this release writes, and the single `{ botToken }` written before a\n * workspace could have more than one Telegram destination. The old one arrives under the id the\n * config migration gave the destination it came from, so an upgrade keeps a working Telegram.\n */\nfunction readTelegramTokens(value: unknown): Record<string, string> {\n if (!isRecord(value))\n return {}\n // The legacy singleton.\n if (typeof value.botToken === 'string')\n return value.botToken.trim().length > 0 ? { [LEGACY_TELEGRAM_ID]: value.botToken.trim() } : {}\n const tokens: Record<string, string> = {}\n for (const [id, token] of Object.entries(value)) {\n if (typeof token === 'string' && token.trim().length > 0)\n tokens[id] = token.trim()\n }\n return tokens\n}\n\n/**\n * Sealed on disk, or `{ provider, values }` waiting for the sealing write. A bare\n * field map — written before the provider was recorded — no longer reads, because\n * there is nothing to say which provider those fields belong to.\n */\nfunction readStoredDdns(value: unknown): Record<string, StoredDdnsRecord> {\n if (!isRecord(value))\n return {}\n const out: Record<string, StoredDdnsRecord> = {}\n for (const [accountId, entry] of Object.entries(value)) {\n if (isSealedDdns(entry)) {\n out[accountId] = entry\n continue\n }\n if (!isRecord(entry) || typeof entry.provider !== 'string' || entry.provider.length === 0)\n continue\n const values = readDdnsValues(entry.values)\n if (Object.keys(values).length === 0)\n continue\n out[accountId] = { plain: true, provider: entry.provider, values }\n }\n return out\n}\n\nfunction readDdnsKdf(value: unknown): DdnsKdfMeta | null {\n if (!isRecord(value) || value.algo !== 'scrypt' || typeof value.salt !== 'string')\n return null\n const cost = isRecord(value.cost) ? value.cost : {}\n const N = Number(cost.N)\n const r = Number(cost.r)\n const p = Number(cost.p)\n if (!Number.isInteger(N) || !Number.isInteger(r) || !Number.isInteger(p) || N < 2 || r < 1 || p < 1)\n return null\n return { algo: 'scrypt', cost: { N, r, p }, salt: value.salt }\n}\n\nfunction newDdnsKdf(): DdnsKdfMeta {\n return { algo: 'scrypt', cost: { ...COST }, salt: crypto.randomBytes(SALT_BYTES).toString('base64') }\n}\n\n/** The account id is the AAD, so a sealed entry cannot be moved to another account. */\nfunction ddnsAad(accountId: string): Buffer {\n return Buffer.from(`${DDNS_AAD_PREFIX}${accountId}`, 'utf8')\n}\n\nfunction sealDdns(accountId: string, record: DdnsCredentialRecord, key: Buffer): SealedDdnsRecord {\n const iv = crypto.randomBytes(DDNS_IV_BYTES)\n const cipher = crypto.createCipheriv(DDNS_SEALED_ALGO, key, iv)\n cipher.setAAD(ddnsAad(accountId))\n const data = Buffer.concat([cipher.update(JSON.stringify(record), 'utf8'), cipher.final()])\n return {\n algo: DDNS_SEALED_ALGO,\n iv: iv.toString('base64'),\n tag: cipher.getAuthTag().toString('base64'),\n data: data.toString('base64'),\n }\n}\n\n/** Null when the tag does not verify: a different secret, or a file somebody edited. */\nfunction openDdns(accountId: string, sealed: SealedDdnsRecord, key: Buffer): DdnsCredentialRecord | null {\n try {\n const decipher = crypto.createDecipheriv(DDNS_SEALED_ALGO, key, Buffer.from(sealed.iv, 'base64'))\n decipher.setAAD(ddnsAad(accountId))\n decipher.setAuthTag(Buffer.from(sealed.tag, 'base64'))\n const plain = Buffer.concat([decipher.update(Buffer.from(sealed.data, 'base64')), decipher.final()]).toString('utf8')\n const parsed = JSON.parse(plain) as Partial<DdnsCredentialRecord>\n if (typeof parsed?.provider !== 'string')\n return null\n const values = readDdnsValues(parsed.values)\n return Object.keys(values).length === 0 ? null : { provider: parsed.provider, values }\n }\n catch {\n return null\n }\n}\n\n/**\n * The password hash and the API token are secrets, so they live outside\n * `servers.config.json` (which is tracked) in a 0600 file that is git-ignored.\n *\n * DDNS provider credentials are the one thing here the panel has to replay to a\n * third party, so they are sealed with AES-256-GCM under `HHOSTED_DDNS_SECRET`.\n * Everything else is a one-way hash and needs no key.\n */\nexport class SecretsStore {\n private cache: SecretsFile | null = null\n private cacheKey = ''\n private error: string | null = null\n private ddnsKeyCache: { salt: string, key: Buffer } | null = null\n private readonly warnedAccounts = new Set<string>()\n private warnedDefaultSecret = false\n private readonly ddnsSecret: string\n\n constructor(private readonly file: string, ddnsSecret?: string, private readonly scope: SecretsScope = 'all') {\n const candidate = (ddnsSecret ?? process.env.HHOSTED_DDNS_SECRET ?? '').trim()\n this.ddnsSecret = candidate.length > 0 ? candidate : DEFAULT_DDNS_SECRET\n }\n\n /**\n * Whether the DDNS credentials are sealed under the built-in key.\n *\n * Sealing is what stops a leaked *file* — a backup, a committed state directory — from handing over\n * the DNS credentials. Under the default the key is the literal `hh`, so anyone holding the file can\n * open it. The docs say so; this is the same fact for code that wants to say so at runtime.\n */\n get usingDefaultDdnsSecret(): boolean {\n return this.ddnsSecret === DEFAULT_DDNS_SECRET\n }\n\n get path(): string {\n return this.file\n }\n\n /**\n * Re-reads whenever the file changes on disk, so a password set by\n * `home-hosted set-password` (or another process) takes effect without\n * restarting `up`.\n */\n load(): SecretsFile {\n const key = this.statKey()\n if (this.cache !== null && key === this.cacheKey)\n return this.cache\n this.cache = this.read()\n this.cacheKey = key\n return this.cache\n }\n\n private statKey(): string {\n try {\n const stats = fs.statSync(this.file)\n return `${stats.mtimeMs}:${stats.size}`\n }\n catch {\n return 'missing'\n }\n }\n\n get password(): PasswordRecord | null {\n return this.load().password\n }\n\n get passwordUpdatedAt(): number | null {\n return this.password?.updatedAt ?? null\n }\n\n get passwordSet(): boolean {\n return this.password !== null\n }\n\n get usingDefaultPassword(): boolean {\n return this.password?.isDefault === true\n }\n\n get apiToken(): ApiTokenRecord | null {\n return this.load().apiToken\n }\n\n get apiTokenSet(): boolean {\n return this.apiToken !== null\n }\n\n /** The readable head of the stored token, or null when none is set. */\n get apiTokenHint(): string | null {\n return this.apiToken?.hint ?? null\n }\n\n /** The bot token for one destination, or null when it has none. */\n telegramToken(id: string): string | null {\n const token = this.load().telegram[id] ?? ''\n return token.length > 0 ? token : null\n }\n\n telegramTokenSet(id: string): boolean {\n return this.telegramToken(id) !== null\n }\n\n /** Every destination id a token is stored for — including one the config no longer declares. */\n get telegramTokenIds(): string[] {\n return Object.keys(this.load().telegram).sort()\n }\n\n /**\n * The first-run password while it is still the one in use, for a person on this machine.\n * A home from before 0.12 still on the shared default reports that one.\n */\n get initialPassword(): string | null {\n const record = this.password\n if (record?.isDefault !== true)\n return null\n if (typeof record.initial === 'string' && record.initial.length > 0)\n return record.initial\n return verifyPassword(LEGACY_DEFAULT_PASSWORD, record) ? LEGACY_DEFAULT_PASSWORD : null\n }\n\n setPassword(password: string, options: { isDefault?: boolean, initial?: boolean } = {}): PasswordRecord {\n const record = hashPassword(password, options)\n this.save({ ...this.load(), password: record })\n return record\n }\n\n /** Creates the first-run password only when none exists yet. */\n ensureDefaultPassword(password: string): PasswordRecord | null {\n if (this.passwordSet)\n return null\n return this.setPassword(password, { isDefault: true, initial: true })\n }\n\n clearPassword(): void {\n this.save({ ...this.load(), password: null })\n }\n\n setApiToken(token: string): ApiTokenRecord {\n const record = apiTokenRecord(token)\n this.save({ ...this.load(), apiToken: record })\n return record\n }\n\n clearApiToken(): void {\n this.save({ ...this.load(), apiToken: null })\n }\n\n setTelegramToken(id: string, token: string | null): void {\n const trimmed = token?.trim() ?? ''\n const current = { ...this.load().telegram }\n if (trimmed.length > 0)\n current[id] = trimmed\n else\n delete current[id]\n this.save({ ...this.load(), telegram: current })\n }\n\n /** Drops every token whose destination is gone, so a deleted target leaves nothing behind. */\n forgetTelegramTokens(keep: readonly string[]): void {\n const allowed = new Set(keep)\n const current = this.load().telegram\n const next = Object.fromEntries(Object.entries(current).filter(([id]) => allowed.has(id)))\n if (Object.keys(next).length !== Object.keys(current).length)\n this.save({ ...this.load(), telegram: next })\n }\n\n /** Ids that have something stored, whether or not a config still declares them. */\n get ddnsAccountIds(): string[] {\n return Object.keys(this.load().ddns)\n }\n\n /**\n * Null when nothing is stored, when the entry belongs to a different provider,\n * or when the secret cannot open it.\n */\n getDdnsCredentials(accountId: string, provider: string): DdnsCredentialRecord | null {\n const stored = this.load().ddns[accountId]\n if (stored === undefined)\n return null\n const record = this.openStored(accountId, stored)\n if (record === null)\n return null\n return record.provider === provider ? record : null\n }\n\n /** An empty field is dropped, so clearing every field forgets the account. */\n setDdnsCredentials(accountId: string, provider: string, credentials: Record<string, string>): void {\n const current = this.load()\n const values = readDdnsValues(credentials)\n const ddns = { ...current.ddns }\n if (Object.keys(values).length === 0)\n delete ddns[accountId]\n else\n ddns[accountId] = { plain: true, provider, values }\n this.save({ ...current, ddns })\n }\n\n clearDdnsCredentials(accountId: string): void {\n const current = this.load()\n if (current.ddns[accountId] === undefined)\n return\n const ddns = { ...current.ddns }\n delete ddns[accountId]\n this.save({ ...current, ddns })\n }\n\n /** Keeps only the accounts a config still declares; returns how many were dropped. */\n pruneDdnsCredentials(keep: Iterable<string>): number {\n const wanted = new Set(keep)\n const current = this.load()\n const removed = Object.keys(current.ddns).filter(id => !wanted.has(id))\n if (removed.length === 0)\n return 0\n const ddns = { ...current.ddns }\n for (const id of removed) delete ddns[id]\n this.save({ ...current, ddns })\n return removed.length\n }\n\n private openStored(accountId: string, stored: StoredDdnsRecord): DdnsCredentialRecord | null {\n if (isPlainDdns(stored))\n return { provider: stored.provider, values: stored.values }\n\n const kdf = this.load().ddnsKdf\n if (kdf === null) {\n this.warnOnce(accountId, 'the file carries no key parameters')\n return null\n }\n const record = openDdns(accountId, stored, this.ddnsKey(kdf))\n if (record === null)\n this.warnOnce(accountId, `the entry could not be opened — is HHOSTED_DDNS_SECRET still the one it was sealed with?`)\n return record\n }\n\n /** One derivation per file salt, cached for the life of the process. */\n private ddnsKey(kdf: DdnsKdfMeta): Buffer {\n if (this.ddnsKeyCache?.salt === kdf.salt)\n return this.ddnsKeyCache.key\n const key = deriveKey(this.ddnsSecret, Buffer.from(kdf.salt, 'base64'), kdf.cost, DDNS_KEYLEN)\n this.ddnsKeyCache = { salt: kdf.salt, key }\n return key\n }\n\n private warnOnce(accountId: string, reason: string): void {\n if (this.warnedAccounts.has(accountId))\n return\n this.warnedAccounts.add(accountId)\n logger.warn(`ddns: cannot read the credentials for \"${accountId}\" — ${reason}`)\n }\n\n /**\n * A secrets file that exists but cannot be parsed, or null when it is fine (or absent).\n *\n * `read()` still returns the empty shape — a corrupt file must not authenticate anyone — but\n * \"unreadable\" and \"absent\" have to stay distinguishable: treated as absent, a truncated\n * `.control-secrets.json` reads as a fresh install, and `runControlPlane` then writes a\n * **default-password** file over it, destroying the password hash, the API token and every\n * Telegram and DDNS credential. Only the caller can refuse the boot, so this is its surface.\n */\n get configError(): string | null {\n this.load()\n return this.error\n }\n\n private read(): SecretsFile {\n this.error = null\n const empty: SecretsFile = { password: null, apiToken: null, telegram: {}, ddns: {}, ddnsKdf: null }\n if (!fs.existsSync(this.file))\n return this.inScope(empty)\n let text: string\n try {\n text = readStateFile(this.file)\n }\n catch (error) {\n // Present but unreadable is not absent: permissions or a directory, say.\n this.error = `cannot read ${this.file}: ${errorMessage(error)}`\n return this.inScope(empty)\n }\n try {\n const parsed = JSON.parse(text) as Partial<SecretsFile>\n return this.inScope({\n password: parsed?.password ?? null,\n apiToken: parsed?.apiToken?.hash ? parsed.apiToken : null,\n telegram: readTelegramTokens(parsed?.telegram),\n ddns: readStoredDdns(parsed?.ddns),\n ddnsKdf: readDdnsKdf((parsed as { ddnsKdf?: unknown })?.ddnsKdf),\n extra: unknownTopLevel(parsed),\n })\n }\n catch (error) {\n this.error = `${this.file} is not readable JSON (${errorMessage(error)}) — it was left untouched`\n return this.inScope(empty)\n }\n }\n\n /** Everything a store does not own is neither read from nor written to its file. */\n private inScope(contents: SecretsFile): SecretsFile {\n if (this.scope === 'global')\n return { ...contents, telegram: {}, ddns: {}, ddnsKdf: null }\n if (this.scope === 'workspace')\n return { ...contents, password: null, apiToken: null }\n return contents\n }\n\n private save(contents: SecretsFile): void {\n // Refuse to write over a file this store could not parse. Every writer reaches here\n // through `load()`, so without this the first `set-password`/`set-token` after a bad\n // edit replaces the user's password hash, API token and credentials with the one field\n // being set. `runControlPlane` refuses at boot; this is the same rule for every command\n // that does not boot one.\n if (this.configError !== null)\n throw new Error(`refusing to write ${this.file}: ${this.error}`)\n\n const sealed = this.sealStored(this.inScope(contents))\n const { extra, ...known } = sealed\n writeFileAtomic(this.file, `${JSON.stringify({ ...known, ...extra }, null, 2)}\\n`, { mode: 0o600 })\n this.cache = sealed\n }\n\n /** Any write seals the entries still sitting in the clear, so the file never keeps both. */\n private sealStored(contents: SecretsFile): SecretsFile {\n const plain = Object.entries(contents.ddns)\n .filter((entry): entry is [string, PlainDdnsRecord] => isPlainDdns(entry[1]))\n if (plain.length === 0)\n return contents\n\n // Warned here rather than at startup: this is the moment credentials exist to protect, so a panel\n // with no DDNS accounts stays quiet. The condition and the message are asserted in the test.\n if (this.usingDefaultDdnsSecret && !this.warnedDefaultSecret) {\n this.warnedDefaultSecret = true\n logger.warn(`ddns: credentials are sealed under the built-in key — set HHOSTED_DDNS_SECRET to protect them if this state directory is ever copied or committed (docs/DDNS.md)`)\n }\n\n const kdf = contents.ddnsKdf ?? newDdnsKdf()\n const key = this.ddnsKey(kdf)\n const ddns = { ...contents.ddns }\n for (const [accountId, record] of plain)\n ddns[accountId] = sealDdns(accountId, { provider: record.provider, values: record.values }, key)\n return { ...contents, ddns, ddnsKdf: kdf }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAM,OAAO;CAAE,GAAG;CAAO,GAAG;CAAG,GAAG;AAAE;AACpC,IAAM,SAAS;AACf,IAAM,aAAa;;AAuFnB,IAAM,oCAAoB,IAAI,IAAI;CAAC;CAAY;CAAY;CAAY;CAAQ;CAAW;AAAS,CAAC;AAEpG,SAAS,gBAAgB,QAA0C;CACjE,IAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GACvE,OAAO,CAAC;CACV,OAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,kBAAkB,IAAI,GAAG,CAAC,CAAC;AACjG;;;;;AAMA,IAAa,qBAAqB;AAIlC,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AAIzB,SAAgB,UAAU,UAAkB,MAAc,MAAkB,QAAwB;CAClG,OAAO,OAAO,WAAW,SAAS,UAAU,MAAM,GAAG,MAAM,QAAQ,EAAE,GAAG,KAAK,CAAC;AAChF;AAEA,SAAgB,aAAa,UAAkB,UAAoE,CAAC,GAAmB;CACrI,MAAM,OAAO,OAAO,YAAY,UAAU;CAC1C,OAAO;EACL,MAAM;EACN,MAAM,KAAK,SAAS,QAAQ;EAC5B,MAAM,UAAU,UAAU,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,QAAQ;EAC/D,QAAQ;EACR,MAAM,EAAE,GAAG,KAAK;EAChB,WAAW,QAAQ,OAAO,KAAK,IAAI;EACnC,GAAI,QAAQ,cAAc,OAAO,EAAE,WAAW,KAAK,IAA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