home-hosted 0.11.0 → 0.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.
- package/README.md +273 -628
- package/dist/chunks/archive-DpCwA8Nf.js +339 -0
- package/dist/chunks/archive-DpCwA8Nf.js.map +1 -0
- package/dist/chunks/atomic-CEfCUfkQ.js +25 -0
- package/dist/chunks/atomic-CEfCUfkQ.js.map +1 -0
- package/dist/chunks/backup-CPrJVPJI.js +797 -0
- package/dist/chunks/backup-CPrJVPJI.js.map +1 -0
- package/dist/chunks/backups-Bd2SF2qd.js +4346 -0
- package/dist/chunks/backups-Bd2SF2qd.js.map +1 -0
- package/dist/chunks/config-text-DifCHhnz.js +50 -0
- package/dist/chunks/config-text-DifCHhnz.js.map +1 -0
- package/dist/chunks/contracts-ku5ypHXJ.js +2256 -0
- package/dist/chunks/contracts-ku5ypHXJ.js.map +1 -0
- package/dist/chunks/daemon-TwXk5vb8.js +215 -0
- package/dist/chunks/daemon-TwXk5vb8.js.map +1 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js +241 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +1 -0
- package/dist/chunks/docker-CGv4Uv7w.js +436 -0
- package/dist/chunks/docker-CGv4Uv7w.js.map +1 -0
- package/dist/chunks/down-BlX5X3bm.js +378 -0
- package/dist/chunks/down-BlX5X3bm.js.map +1 -0
- package/dist/chunks/init-DdmqHVra.js +263 -0
- package/dist/chunks/init-DdmqHVra.js.map +1 -0
- package/dist/chunks/last-stop-BZ08Z89-.js +52 -0
- package/dist/chunks/last-stop-BZ08Z89-.js.map +1 -0
- package/dist/chunks/layout-D74TGUnr.js +24 -0
- package/dist/chunks/layout-D74TGUnr.js.map +1 -0
- package/dist/chunks/log-buffer-HnP0jKhZ.js +350 -0
- package/dist/chunks/log-buffer-HnP0jKhZ.js.map +1 -0
- package/dist/chunks/logger-B5U4GD3j.js +13 -0
- package/dist/chunks/logger-B5U4GD3j.js.map +1 -0
- package/dist/chunks/logs-gI_69Q1P.js +265 -0
- package/dist/chunks/logs-gI_69Q1P.js.map +1 -0
- package/dist/chunks/migrate-BTlsibvF.js +155 -0
- package/dist/chunks/migrate-BTlsibvF.js.map +1 -0
- package/dist/chunks/nanny-20aBXL1o.js +1069 -0
- package/dist/chunks/nanny-20aBXL1o.js.map +1 -0
- package/dist/chunks/nanny-CjnnrIpm.js +132 -0
- package/dist/chunks/nanny-CjnnrIpm.js.map +1 -0
- package/dist/chunks/nanny-DUaAfCV-.js +39 -0
- package/dist/chunks/nanny-DUaAfCV-.js.map +1 -0
- package/dist/chunks/nanny-sweep-Ca9kPAVi.js +104 -0
- package/dist/chunks/nanny-sweep-Ca9kPAVi.js.map +1 -0
- package/dist/chunks/nearest-6KgQEDUe.js +41 -0
- package/dist/chunks/nearest-6KgQEDUe.js.map +1 -0
- package/dist/chunks/parse-B9owE47G.js +383 -0
- package/dist/chunks/parse-B9owE47G.js.map +1 -0
- package/dist/chunks/paths-BT94q6-w.js +172 -0
- package/dist/chunks/paths-BT94q6-w.js.map +1 -0
- package/dist/chunks/port-B8WBTRMk.js +333 -0
- package/dist/chunks/port-B8WBTRMk.js.map +1 -0
- package/dist/chunks/restart-UZgeDukG.js +126 -0
- package/dist/chunks/restart-UZgeDukG.js.map +1 -0
- package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/chunks/schema-o7Lgk0V1.js +102 -0
- package/dist/chunks/schema-o7Lgk0V1.js.map +1 -0
- package/dist/chunks/secrets-D7PdYh71.js +544 -0
- package/dist/chunks/secrets-D7PdYh71.js.map +1 -0
- package/dist/chunks/server-BuIeSsRu.js +169 -0
- package/dist/chunks/server-BuIeSsRu.js.map +1 -0
- package/dist/chunks/server-ids-DRuNLVCV.js +32 -0
- package/dist/chunks/server-ids-DRuNLVCV.js.map +1 -0
- package/dist/chunks/set-password-DegMumPh.js +43 -0
- package/dist/chunks/set-password-DegMumPh.js.map +1 -0
- package/dist/chunks/set-token-21d1FTDC.js +78 -0
- package/dist/chunks/set-token-21d1FTDC.js.map +1 -0
- package/dist/chunks/settings-BVSBnIwJ.js +332 -0
- package/dist/chunks/settings-BVSBnIwJ.js.map +1 -0
- package/dist/chunks/setup-temp-XiuAtiW2.js +150 -0
- package/dist/chunks/setup-temp-XiuAtiW2.js.map +1 -0
- package/dist/chunks/shape-DnTKzjQ2.js +24 -0
- package/dist/chunks/shape-DnTKzjQ2.js.map +1 -0
- package/dist/chunks/src-BL97vLVb.js +11153 -0
- package/dist/chunks/src-BL97vLVb.js.map +1 -0
- package/dist/chunks/status-EuWdRq8Q.js +119 -0
- package/dist/chunks/status-EuWdRq8Q.js.map +1 -0
- package/dist/chunks/ui-DbPuwddJ.js +323 -0
- package/dist/chunks/ui-DbPuwddJ.js.map +1 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js +39 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js.map +1 -0
- package/dist/chunks/ui-release-DKzVvlLd.js +312 -0
- package/dist/chunks/ui-release-DKzVvlLd.js.map +1 -0
- package/dist/chunks/ui-revert-BhqOAhmM.js +27 -0
- package/dist/chunks/ui-revert-BhqOAhmM.js.map +1 -0
- package/dist/chunks/ui-switch-CMoslPO2.js +150 -0
- package/dist/chunks/ui-switch-CMoslPO2.js.map +1 -0
- package/dist/chunks/ui-update-TTBBoDik.js +272 -0
- package/dist/chunks/ui-update-TTBBoDik.js.map +1 -0
- package/dist/chunks/up-C4H13hBw.js +196 -0
- package/dist/chunks/up-C4H13hBw.js.map +1 -0
- package/dist/chunks/usage-CSBgLRN5.js +85 -0
- package/dist/chunks/usage-CSBgLRN5.js.map +1 -0
- package/dist/chunks/workspaces-CAln2sQ7.js +221 -0
- package/dist/chunks/workspaces-CAln2sQ7.js.map +1 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js +322 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +1 -0
- package/dist/cli.js +218 -25205
- package/dist/cli.js.map +1 -1
- package/dist/client.js +120 -0
- package/dist/client.js.map +1 -0
- package/dist/types/api/acme.d.ts +24 -0
- package/dist/types/api/auth/$.routes.d.ts +103 -0
- package/dist/types/api/backups.d.ts +179 -0
- package/dist/types/api/control.d.ts +469 -0
- package/dist/types/api/ddns.d.ts +432 -0
- package/dist/types/api/events.d.ts +21 -0
- package/dist/types/api/health.d.ts +27 -0
- package/dist/types/api/logs.d.ts +95 -0
- package/dist/types/api/metrics.d.ts +19 -0
- package/dist/types/api/notifications.d.ts +141 -0
- package/dist/types/api/proxy.d.ts +1128 -0
- package/dist/types/api/servers/$.routes.d.ts +1318 -0
- package/dist/types/api/settings.d.ts +642 -0
- package/dist/types/api/state.d.ts +492 -0
- package/dist/types/api/static.d.ts +11 -0
- package/dist/types/api/tls.d.ts +112 -0
- package/dist/types/api/workspaces/$.routes.d.ts +797 -0
- package/dist/types/api/wsl-temperature.d.ts +113 -0
- package/dist/types/app.d.ts +6080 -0
- package/dist/types/cli/args.d.ts +75 -0
- package/dist/types/cli/backup-offline.d.ts +23 -0
- package/dist/types/cli/backup.d.ts +79 -0
- package/dist/types/cli/down.d.ts +75 -0
- package/dist/types/cli/init.d.ts +60 -0
- package/dist/types/cli/io.d.ts +65 -0
- package/dist/types/cli/logs.d.ts +64 -0
- package/dist/types/cli/migrate.d.ts +33 -0
- package/dist/types/cli/nanny.d.ts +19 -0
- package/dist/types/cli/nearest.d.ts +10 -0
- package/dist/types/cli/restart.d.ts +42 -0
- package/dist/types/cli/server.d.ts +68 -0
- package/dist/types/cli/set-password.d.ts +14 -0
- package/dist/types/cli/set-token.d.ts +21 -0
- package/dist/types/cli/setup-temp.d.ts +65 -0
- package/dist/types/cli/status.d.ts +14 -0
- package/dist/types/cli/ui-revert.d.ts +3 -0
- package/dist/types/cli/ui-switch.d.ts +27 -0
- package/dist/types/cli/ui-update.d.ts +72 -0
- package/dist/types/cli/up.d.ts +90 -0
- package/dist/types/cli/usage.d.ts +23 -0
- package/dist/types/cli.d.ts +12 -0
- package/dist/types/client.d.ts +6284 -0
- package/dist/types/config/layout.d.ts +11 -0
- package/dist/types/config/migrations.d.ts +69 -0
- package/dist/types/config/parse.d.ts +54 -0
- package/dist/types/config/patch.d.ts +20 -0
- package/dist/types/config/schema.d.ts +318 -0
- package/dist/types/config/secret-parts.d.ts +48 -0
- package/dist/types/config/secrets.d.ts +206 -0
- package/dist/types/config/seed.d.ts +30 -0
- package/dist/types/config/server-ids.d.ts +14 -0
- package/dist/types/config/settings.d.ts +74 -0
- package/dist/types/config/store.d.ts +132 -0
- package/dist/types/config/workspaces.d.ts +96 -0
- package/dist/types/helpers/action-result.d.ts +46 -0
- package/dist/types/helpers/atomic.d.ts +9 -0
- package/dist/types/helpers/backoff.d.ts +7 -0
- package/dist/types/helpers/bind.d.ts +16 -0
- package/dist/types/helpers/config-text.d.ts +23 -0
- package/dist/types/helpers/cookies.d.ts +19 -0
- package/dist/types/helpers/copy-tree.d.ts +15 -0
- package/dist/types/helpers/daemon-log.d.ts +45 -0
- package/dist/types/helpers/daemon.d.ts +122 -0
- package/dist/types/helpers/deferred.d.ts +7 -0
- package/dist/types/helpers/env-file.d.ts +20 -0
- package/dist/types/helpers/error.d.ts +18 -0
- package/dist/types/helpers/factory.d.ts +6 -0
- package/dist/types/helpers/last-stop.d.ts +20 -0
- package/dist/types/helpers/logger.d.ts +7 -0
- package/dist/types/helpers/open.d.ts +2 -0
- package/dist/types/helpers/openapi.d.ts +46 -0
- package/dist/types/helpers/paths.d.ts +94 -0
- package/dist/types/helpers/restore-lock.d.ts +32 -0
- package/dist/types/helpers/runtime.d.ts +18 -0
- package/dist/types/helpers/secret-compare.d.ts +13 -0
- package/dist/types/helpers/shell.d.ts +19 -0
- package/dist/types/helpers/sse.d.ts +23 -0
- package/dist/types/helpers/template.d.ts +8 -0
- package/dist/types/helpers/ui-dir.d.ts +11 -0
- package/dist/types/helpers/validate.d.ts +7 -0
- package/dist/types/helpers/validator.d.ts +12 -0
- package/dist/types/helpers/version.d.ts +10 -0
- package/dist/types/helpers/workspace.d.ts +25 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/middleware/auth.d.ts +37 -0
- package/dist/types/middleware/host.d.ts +29 -0
- package/dist/types/middleware/loopback.d.ts +18 -0
- package/dist/types/openapi-reference.d.ts +22 -0
- package/dist/types/openapi.d.ts +34 -0
- package/dist/types/providers/archive.d.ts +54 -0
- package/dist/types/providers/backup-hook.d.ts +34 -0
- package/dist/types/providers/ddns/cloudflare.d.ts +2 -0
- package/dist/types/providers/ddns/desec.d.ts +2 -0
- package/dist/types/providers/ddns/digitalocean.d.ts +2 -0
- package/dist/types/providers/ddns/duckdns.d.ts +2 -0
- package/dist/types/providers/ddns/dyndns2.d.ts +15 -0
- package/dist/types/providers/ddns/dynu.d.ts +2 -0
- package/dist/types/providers/ddns/freedns.d.ts +2 -0
- package/dist/types/providers/ddns/gandi.d.ts +2 -0
- package/dist/types/providers/ddns/godaddy.d.ts +2 -0
- package/dist/types/providers/ddns/henet.d.ts +3 -0
- package/dist/types/providers/ddns/index.d.ts +12 -0
- package/dist/types/providers/ddns/ip.d.ts +27 -0
- package/dist/types/providers/ddns/namecheap-api.d.ts +13 -0
- package/dist/types/providers/ddns/namecheap.d.ts +6 -0
- package/dist/types/providers/ddns/noip.d.ts +2 -0
- package/dist/types/providers/ddns/porkbun.d.ts +2 -0
- package/dist/types/providers/ddns/spaceship.d.ts +7 -0
- package/dist/types/providers/ddns/types.d.ts +98 -0
- package/dist/types/providers/ddns/zone.d.ts +11 -0
- package/dist/types/providers/docker.d.ts +117 -0
- package/dist/types/providers/entry-state.d.ts +15 -0
- package/dist/types/providers/health-check.d.ts +27 -0
- package/dist/types/providers/host.d.ts +147 -0
- package/dist/types/providers/identity.d.ts +54 -0
- package/dist/types/providers/log-tail.d.ts +29 -0
- package/dist/types/providers/nanny-sweep.d.ts +51 -0
- package/dist/types/providers/nanny.d.ts +94 -0
- package/dist/types/providers/port.d.ts +142 -0
- package/dist/types/providers/proc.d.ts +116 -0
- package/dist/types/providers/process.d.ts +61 -0
- package/dist/types/providers/proxy/caddy.d.ts +2 -0
- package/dist/types/providers/proxy/index.d.ts +7 -0
- package/dist/types/providers/proxy/types.d.ts +54 -0
- package/dist/types/providers/server-vars.d.ts +4 -0
- package/dist/types/providers/telegram.d.ts +32 -0
- package/dist/types/providers/ui-release.d.ts +113 -0
- package/dist/types/providers/webhook.d.ts +64 -0
- package/dist/types/providers/wsl-temperature.d.ts +69 -0
- package/dist/types/services/acme-challenge.d.ts +44 -0
- package/dist/types/services/auth.d.ts +145 -0
- package/dist/types/services/backups.d.ts +352 -0
- package/dist/types/services/config-watch.d.ts +40 -0
- package/dist/types/services/control-server.d.ts +58 -0
- package/dist/types/services/ddns.d.ts +67 -0
- package/dist/types/services/dependencies.d.ts +21 -0
- package/dist/types/services/events.d.ts +17 -0
- package/dist/types/services/exposure.d.ts +33 -0
- package/dist/types/services/history.d.ts +36 -0
- package/dist/types/services/host-monitor.d.ts +32 -0
- package/dist/types/services/init.d.ts +71 -0
- package/dist/types/services/log-buffer.d.ts +28 -0
- package/dist/types/services/log-files.d.ts +87 -0
- package/dist/types/services/log-relay.d.ts +36 -0
- package/dist/types/services/nanny.d.ts +14 -0
- package/dist/types/services/notifications.d.ts +124 -0
- package/dist/types/services/panel.d.ts +194 -0
- package/dist/types/services/proxy-config.d.ts +83 -0
- package/dist/types/services/proxy.d.ts +454 -0
- package/dist/types/services/state.d.ts +41 -0
- package/dist/types/services/supervisor/compose.d.ts +17 -0
- package/dist/types/services/supervisor/entry.d.ts +139 -0
- package/dist/types/services/supervisor/health.d.ts +55 -0
- package/dist/types/services/supervisor/pending-load.d.ts +6 -0
- package/dist/types/services/supervisor/persistent.d.ts +55 -0
- package/dist/types/services/supervisor/port-preflight.d.ts +45 -0
- package/dist/types/services/supervisor/records.d.ts +38 -0
- package/dist/types/services/supervisor/spawn.d.ts +15 -0
- package/dist/types/services/supervisor/view.d.ts +4 -0
- package/dist/types/services/supervisor.d.ts +113 -0
- package/dist/types/services/tls.d.ts +48 -0
- package/dist/types/services/ui-update.d.ts +44 -0
- package/dist/types/services/ui.d.ts +50 -0
- package/dist/types/shared/api-client.d.ts +137 -0
- package/dist/types/shared/backup-scope.d.ts +109 -0
- package/dist/types/shared/clone.d.ts +14 -0
- package/dist/types/shared/contracts.d.ts +4233 -0
- package/dist/types/shared/cpu-scale.d.ts +25 -0
- package/dist/types/shared/ddns-form.d.ts +62 -0
- package/dist/types/shared/endpoint.d.ts +8 -0
- package/dist/types/shared/error-message.d.ts +8 -0
- package/dist/types/shared/fields.d.ts +21 -0
- package/dist/types/shared/generated.d.ts +26 -0
- package/dist/types/shared/host-readings.d.ts +185 -0
- package/dist/types/shared/patch-diff.d.ts +94 -0
- package/dist/types/shared/probe-latency.d.ts +25 -0
- package/dist/types/shared/proxy-form.d.ts +182 -0
- package/dist/types/shared/server-attention.d.ts +37 -0
- package/dist/types/shared/server-key.d.ts +13 -0
- package/dist/types/shared/server-readings.d.ts +55 -0
- package/dist/types/shared/server-url.d.ts +43 -0
- package/dist/types/shared/shape.d.ts +17 -0
- package/dist/types/shared/ui-format.d.ts +89 -0
- package/docs/API.md +180 -0
- package/docs/BACKUPS.md +97 -0
- package/docs/CLI.md +122 -0
- package/docs/DDNS.md +9 -1
- package/docs/RESTORE_DEMO.md +1 -1
- package/docs/REVERSE_PROXY.md +2 -2
- package/docs/SECURITY.md +82 -0
- package/docs/SERVERS.md +41 -13
- package/docs/UI_CREATION.md +82 -291
- package/package.json +18 -8
- package/uis/stock/dist/assets/de-DyGrM1KK.js +1 -0
- package/uis/stock/dist/assets/es-BebHdc0E.js +1 -0
- package/uis/stock/dist/assets/fr-DsDTrxhI.js +1 -0
- package/uis/stock/dist/assets/index-6LANO2Ua.css +2 -0
- package/uis/stock/dist/assets/{index-KdyqrVv8.js → index-D06cUZbM.js} +15 -12
- package/uis/stock/dist/assets/ja-D3RARJjW.js +1 -0
- package/uis/stock/dist/assets/ko-CKI3dFoD.js +1 -0
- package/uis/stock/dist/assets/ru-DEU5ujXt.js +1 -0
- package/uis/stock/dist/assets/vi-ULKPnasj.js +1 -0
- package/uis/stock/dist/assets/zh-CN-tCvnOxWy.js +1 -0
- package/uis/stock/dist/index.html +2 -2
- package/uis/stock/dist/ui.json +3 -3
- package/uis/stock/dist/assets/de-0YLueNal.js +0 -1
- package/uis/stock/dist/assets/es-FCHhRmn2.js +0 -1
- package/uis/stock/dist/assets/fr-C69Z8o0z.js +0 -1
- package/uis/stock/dist/assets/index-Cok5msAO.css +0 -2
- package/uis/stock/dist/assets/ja-Chz9YOqR.js +0 -1
- package/uis/stock/dist/assets/ko-CtXZ2x1l.js +0 -1
- package/uis/stock/dist/assets/ru-D_jE64xN.js +0 -1
- package/uis/stock/dist/assets/vi-sxSffss7.js +0 -1
- package/uis/stock/dist/assets/zh-CN-ChTpf29X.js +0 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
export interface PasswordRecord {
|
|
3
|
+
algo: 'scrypt';
|
|
4
|
+
salt: string;
|
|
5
|
+
hash: string;
|
|
6
|
+
keylen: number;
|
|
7
|
+
cost: {
|
|
8
|
+
N: number;
|
|
9
|
+
r: number;
|
|
10
|
+
p: number;
|
|
11
|
+
};
|
|
12
|
+
updatedAt: number;
|
|
13
|
+
/** Set for the boot-time default, so the UI can say so and exposure stays blocked. */
|
|
14
|
+
isDefault?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The generated first-run password, kept in this 0600 file only while it is still in use so
|
|
17
|
+
* `up`/`status` can show it on the machine. Never sent over the API; gone with the first change.
|
|
18
|
+
*/
|
|
19
|
+
initial?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An API token for scripts and agents. Tokens are high-entropy randoms, so a
|
|
23
|
+
* plain SHA-256 is the right hash — scrypt would only make every request pay
|
|
24
|
+
* for a slow KDF it does not need. `hint` is the readable head, kept so a human
|
|
25
|
+
* can tell two tokens apart without the file ever holding the whole secret.
|
|
26
|
+
*/
|
|
27
|
+
export interface ApiTokenRecord {
|
|
28
|
+
algo: 'sha256';
|
|
29
|
+
hash: string;
|
|
30
|
+
hint: string;
|
|
31
|
+
updatedAt: number;
|
|
32
|
+
}
|
|
33
|
+
/** One account's provider credentials, with the provider they were entered for. */
|
|
34
|
+
export interface DdnsCredentialRecord {
|
|
35
|
+
provider: string;
|
|
36
|
+
values: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
/** An account's credentials as they sit on disk: sealed, never plaintext. */
|
|
39
|
+
interface SealedDdnsRecord {
|
|
40
|
+
algo: 'aes-256-gcm';
|
|
41
|
+
iv: string;
|
|
42
|
+
tag: string;
|
|
43
|
+
data: string;
|
|
44
|
+
}
|
|
45
|
+
/** Read from a file written before sealing; re-sealed by the next write. */
|
|
46
|
+
interface PlainDdnsRecord {
|
|
47
|
+
plain: true;
|
|
48
|
+
provider: string;
|
|
49
|
+
values: Record<string, string>;
|
|
50
|
+
}
|
|
51
|
+
type StoredDdnsRecord = SealedDdnsRecord | PlainDdnsRecord;
|
|
52
|
+
/** One derivation per process: the secret is combined with this per-file salt. */
|
|
53
|
+
interface DdnsKdfMeta {
|
|
54
|
+
algo: 'scrypt';
|
|
55
|
+
cost: ScryptCost;
|
|
56
|
+
salt: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Which halves of the file a store owns. Global secrets (the password hash and
|
|
60
|
+
* the API token) live above the workspaces, in `.hh/.control-secrets.json`;
|
|
61
|
+
* workspace secrets (the Telegram bot token and DDNS credentials) live in that
|
|
62
|
+
* workspace's own `.secrets.json`. `all` is the shape the pre-workspace file had
|
|
63
|
+
* and is still what a backup archive may carry.
|
|
64
|
+
*/
|
|
65
|
+
export type SecretsScope = 'all' | 'global' | 'workspace';
|
|
66
|
+
interface SecretsFile {
|
|
67
|
+
password: PasswordRecord | null;
|
|
68
|
+
apiToken: ApiTokenRecord | null;
|
|
69
|
+
/**
|
|
70
|
+
* Bot tokens by destination id. A map, not a singleton: a workspace may point at more than one
|
|
71
|
+
* Telegram chat, and each destination carries its own bot.
|
|
72
|
+
*/
|
|
73
|
+
telegram: Record<string, string>;
|
|
74
|
+
/** Per-DDNS-account credentials, keyed by the account id in the config. */
|
|
75
|
+
ddns: Record<string, StoredDdnsRecord>;
|
|
76
|
+
/** How the DDNS key is derived; absent until the first sealed write. */
|
|
77
|
+
ddnsKdf: DdnsKdfMeta | null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The id the config migration gives a pre-list Telegram destination, so its stored `{ botToken }`
|
|
81
|
+
* still finds an owner after the upgrade.
|
|
82
|
+
*/
|
|
83
|
+
export declare const LEGACY_TELEGRAM_ID = "telegram";
|
|
84
|
+
/** So a first run is sealed rather than plaintext; set `HHOSTED_DDNS_SECRET` for real protection. */
|
|
85
|
+
export declare const DEFAULT_DDNS_SECRET = "hh";
|
|
86
|
+
export interface ScryptCost {
|
|
87
|
+
N: number;
|
|
88
|
+
r: number;
|
|
89
|
+
p: number;
|
|
90
|
+
}
|
|
91
|
+
export declare function deriveKey(password: string, salt: Buffer, cost: ScryptCost, keylen: number): Buffer;
|
|
92
|
+
export declare function hashPassword(password: string, options?: {
|
|
93
|
+
now?: number;
|
|
94
|
+
isDefault?: boolean;
|
|
95
|
+
initial?: boolean;
|
|
96
|
+
}): PasswordRecord;
|
|
97
|
+
/** The pre-0.12 boot password every install shared. Still recognised, never created. */
|
|
98
|
+
export declare const LEGACY_DEFAULT_PASSWORD = "hh";
|
|
99
|
+
/** A random first-run password: 12 characters from an unambiguous alphabet, ~60 bits. */
|
|
100
|
+
export declare function generateInitialPassword(): string;
|
|
101
|
+
export declare function verifyPassword(password: string, record: PasswordRecord): boolean;
|
|
102
|
+
/** Visible head of a generated token, so a token is recognisable on sight. */
|
|
103
|
+
export declare const API_TOKEN_PREFIX = "hh_";
|
|
104
|
+
export declare function generateApiToken(): string;
|
|
105
|
+
export declare function hashApiToken(token: string): string;
|
|
106
|
+
export declare function verifyApiToken(token: string, record: ApiTokenRecord): boolean;
|
|
107
|
+
export declare function apiTokenRecord(token: string, now?: number): ApiTokenRecord;
|
|
108
|
+
/**
|
|
109
|
+
* The password hash and the API token are secrets, so they live outside
|
|
110
|
+
* `servers.config.json` (which is tracked) in a 0600 file that is git-ignored.
|
|
111
|
+
*
|
|
112
|
+
* DDNS provider credentials are the one thing here the panel has to replay to a
|
|
113
|
+
* third party, so they are sealed with AES-256-GCM under `HHOSTED_DDNS_SECRET`.
|
|
114
|
+
* Everything else is a one-way hash and needs no key.
|
|
115
|
+
*/
|
|
116
|
+
export declare class SecretsStore {
|
|
117
|
+
private readonly file;
|
|
118
|
+
private readonly scope;
|
|
119
|
+
private cache;
|
|
120
|
+
private cacheKey;
|
|
121
|
+
private error;
|
|
122
|
+
private ddnsKeyCache;
|
|
123
|
+
private readonly warnedAccounts;
|
|
124
|
+
private warnedDefaultSecret;
|
|
125
|
+
private readonly ddnsSecret;
|
|
126
|
+
constructor(file: string, ddnsSecret?: string, scope?: SecretsScope);
|
|
127
|
+
/**
|
|
128
|
+
* Whether the DDNS credentials are sealed under the built-in key.
|
|
129
|
+
*
|
|
130
|
+
* Sealing is what stops a leaked *file* — a backup, a committed state directory — from handing over
|
|
131
|
+
* the DNS credentials. Under the default the key is the literal `hh`, so anyone holding the file can
|
|
132
|
+
* open it. The docs say so; this is the same fact for code that wants to say so at runtime.
|
|
133
|
+
*/
|
|
134
|
+
get usingDefaultDdnsSecret(): boolean;
|
|
135
|
+
get path(): string;
|
|
136
|
+
/**
|
|
137
|
+
* Re-reads whenever the file changes on disk, so a password set by
|
|
138
|
+
* `home-hosted set-password` (or another process) takes effect without
|
|
139
|
+
* restarting `up`.
|
|
140
|
+
*/
|
|
141
|
+
load(): SecretsFile;
|
|
142
|
+
private statKey;
|
|
143
|
+
get password(): PasswordRecord | null;
|
|
144
|
+
get passwordUpdatedAt(): number | null;
|
|
145
|
+
get passwordSet(): boolean;
|
|
146
|
+
get usingDefaultPassword(): boolean;
|
|
147
|
+
get apiToken(): ApiTokenRecord | null;
|
|
148
|
+
get apiTokenSet(): boolean;
|
|
149
|
+
/** The readable head of the stored token, or null when none is set. */
|
|
150
|
+
get apiTokenHint(): string | null;
|
|
151
|
+
/** The bot token for one destination, or null when it has none. */
|
|
152
|
+
telegramToken(id: string): string | null;
|
|
153
|
+
telegramTokenSet(id: string): boolean;
|
|
154
|
+
/** Every destination id a token is stored for — including one the config no longer declares. */
|
|
155
|
+
get telegramTokenIds(): string[];
|
|
156
|
+
/**
|
|
157
|
+
* The first-run password while it is still the one in use, for a person on this machine.
|
|
158
|
+
* A home from before 0.12 still on the shared default reports that one.
|
|
159
|
+
*/
|
|
160
|
+
get initialPassword(): string | null;
|
|
161
|
+
setPassword(password: string, options?: {
|
|
162
|
+
isDefault?: boolean;
|
|
163
|
+
initial?: boolean;
|
|
164
|
+
}): PasswordRecord;
|
|
165
|
+
/** Creates the first-run password only when none exists yet. */
|
|
166
|
+
ensureDefaultPassword(password: string): PasswordRecord | null;
|
|
167
|
+
clearPassword(): void;
|
|
168
|
+
setApiToken(token: string): ApiTokenRecord;
|
|
169
|
+
clearApiToken(): void;
|
|
170
|
+
setTelegramToken(id: string, token: string | null): void;
|
|
171
|
+
/** Drops every token whose destination is gone, so a deleted target leaves nothing behind. */
|
|
172
|
+
forgetTelegramTokens(keep: readonly string[]): void;
|
|
173
|
+
/** Ids that have something stored, whether or not a config still declares them. */
|
|
174
|
+
get ddnsAccountIds(): string[];
|
|
175
|
+
/**
|
|
176
|
+
* Null when nothing is stored, when the entry belongs to a different provider,
|
|
177
|
+
* or when the secret cannot open it.
|
|
178
|
+
*/
|
|
179
|
+
getDdnsCredentials(accountId: string, provider: string): DdnsCredentialRecord | null;
|
|
180
|
+
/** An empty field is dropped, so clearing every field forgets the account. */
|
|
181
|
+
setDdnsCredentials(accountId: string, provider: string, credentials: Record<string, string>): void;
|
|
182
|
+
clearDdnsCredentials(accountId: string): void;
|
|
183
|
+
/** Keeps only the accounts a config still declares; returns how many were dropped. */
|
|
184
|
+
pruneDdnsCredentials(keep: Iterable<string>): number;
|
|
185
|
+
private openStored;
|
|
186
|
+
/** One derivation per file salt, cached for the life of the process. */
|
|
187
|
+
private ddnsKey;
|
|
188
|
+
private warnOnce;
|
|
189
|
+
/**
|
|
190
|
+
* A secrets file that exists but cannot be parsed, or null when it is fine (or absent).
|
|
191
|
+
*
|
|
192
|
+
* `read()` still returns the empty shape — a corrupt file must not authenticate anyone — but
|
|
193
|
+
* "unreadable" and "absent" have to stay distinguishable: treated as absent, a truncated
|
|
194
|
+
* `.control-secrets.json` reads as a fresh install, and `runControlPlane` then writes a
|
|
195
|
+
* **default-password** file over it, destroying the password hash, the API token and every
|
|
196
|
+
* Telegram and DDNS credential. Only the caller can refuse the boot, so this is its surface.
|
|
197
|
+
*/
|
|
198
|
+
get configError(): string | null;
|
|
199
|
+
private read;
|
|
200
|
+
/** Everything a store does not own is neither read from nor written to its file. */
|
|
201
|
+
private inScope;
|
|
202
|
+
private save;
|
|
203
|
+
/** Any write seals the entries still sitting in the clear, so the file never keeps both. */
|
|
204
|
+
private sealStored;
|
|
205
|
+
}
|
|
206
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Written when `$HHOSTED_HOME` has no state yet. Every seed stays empty of
|
|
3
|
+
* servers on purpose: home-hosted ships none, so what a user supervises is
|
|
4
|
+
* theirs to declare. The rest is default policy, which the settings pages can
|
|
5
|
+
* change.
|
|
6
|
+
*/
|
|
7
|
+
/** `$HHOSTED_HOME/.hh/settings.json`. */
|
|
8
|
+
export declare const SEED_GLOBAL_SETTINGS: {
|
|
9
|
+
readonly $schema: "./settings.schema.json";
|
|
10
|
+
readonly control: {
|
|
11
|
+
readonly port: 3999;
|
|
12
|
+
readonly host: "local";
|
|
13
|
+
readonly openBrowser: false;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/** `$HHOSTED_HOME/.hh/<id>/settings.json`. */
|
|
17
|
+
export declare const SEED_WORKSPACE_SETTINGS: {
|
|
18
|
+
readonly $schema: "./settings.schema.json";
|
|
19
|
+
readonly defaults: {
|
|
20
|
+
readonly enabled: true;
|
|
21
|
+
readonly autostart: false;
|
|
22
|
+
readonly bind: "local";
|
|
23
|
+
readonly onPortConflict: "block";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/** `$HHOSTED_HOME/.hh/<id>/servers.config.json`. */
|
|
27
|
+
export declare const SEED_SERVERS_FILE: {
|
|
28
|
+
readonly $schema: "./servers.config.schema.json";
|
|
29
|
+
readonly servers: readonly [];
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server ids a workspace's `servers.config.json` declares — or `null` when the file cannot
|
|
3
|
+
* answer, which is a different fact from "it declares none".
|
|
4
|
+
*
|
|
5
|
+
* Read-only and tolerant on purpose. `WorkspaceStore.load()` *seeds* a missing file, so a
|
|
6
|
+
* diagnostic command that reached for it would write to the state root it was only reading; and a
|
|
7
|
+
* config this release cannot parse must not turn a log lookup into a refusal. Both of those
|
|
8
|
+
* collapse to `null`, and every caller then answers as it did before, because "I cannot tell"
|
|
9
|
+
* is not "there is no such entry".
|
|
10
|
+
*
|
|
11
|
+
* The entries are not validated against `serverSchema`: this answers which *files* may exist
|
|
12
|
+
* (`<id>.log`), and an entry with a bad field still writes a log under its own id.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readDeclaredServerIds(file: string): string[] | null;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ResolvedGlobalConfig } from './schema.js';
|
|
2
|
+
import type { BackupsConfig, ControlConfig, HostConfig, ProxyConfig, ProxyPatch, SettingsPatch } from '../shared/contracts.js';
|
|
3
|
+
export declare class ConfigError extends Error {
|
|
4
|
+
name: string;
|
|
5
|
+
/**
|
|
6
|
+
* The *kind* of config problem, when a caller has to branch on it rather than just report it.
|
|
7
|
+
* `UNKNOWN_SERVER` is the one case today: the servers route answers 404 for a missing id and 400
|
|
8
|
+
* for an invalid patch, and it decided that by matching the message text.
|
|
9
|
+
*/
|
|
10
|
+
readonly code: 'UNKNOWN_SERVER' | undefined;
|
|
11
|
+
constructor(message: string, code?: 'UNKNOWN_SERVER');
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The panel-wide settings file (`$HHOSTED_HOME/.hh/settings.json`): the listener,
|
|
15
|
+
* authentication, TLS policy, host vitals and backups. Nothing here belongs to a
|
|
16
|
+
* workspace, which is why it sits above them.
|
|
17
|
+
*/
|
|
18
|
+
export declare class GlobalSettingsStore {
|
|
19
|
+
private readonly file;
|
|
20
|
+
private readonly seed;
|
|
21
|
+
private raw;
|
|
22
|
+
/** The bytes behind the live settings, so a watcher can tell a real edit from our own write. */
|
|
23
|
+
private lastText;
|
|
24
|
+
private resolvedConfig;
|
|
25
|
+
private error;
|
|
26
|
+
/** A JSON parse failure, kept apart from a schema problem so `apply()` cannot clear it. */
|
|
27
|
+
private parseError;
|
|
28
|
+
private warnings;
|
|
29
|
+
private schemaVersion;
|
|
30
|
+
private readonly listeners;
|
|
31
|
+
constructor(file?: string, seed?: Record<string, unknown>);
|
|
32
|
+
get path(): string;
|
|
33
|
+
get config(): ResolvedGlobalConfig;
|
|
34
|
+
get control(): ControlConfig;
|
|
35
|
+
get host(): HostConfig;
|
|
36
|
+
get backups(): BackupsConfig;
|
|
37
|
+
get proxy(): ProxyConfig;
|
|
38
|
+
get configError(): string | null;
|
|
39
|
+
/** Keys a newer release wrote that this one ignores; nothing to refuse over. */
|
|
40
|
+
get configWarnings(): string[];
|
|
41
|
+
get configSchemaVersion(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Steps that would have to run before this release could use the file.
|
|
44
|
+
*
|
|
45
|
+
* A file that cannot be **parsed** has no schema to plan from, and `migrate` refuses one it
|
|
46
|
+
* cannot read rather than lifting it — so claiming a migration here sends the person to the one
|
|
47
|
+
* command guaranteed not to help. Measured: a truncated `.hh/settings.json` made `up` say
|
|
48
|
+
* "needs 1 migration(s)" and `migrate` answer "cannot read … Unexpected end of JSON input". The
|
|
49
|
+
* workspace pair already excluded the parse failure (`WorkspaceStore.pendingMigrations`); this is
|
|
50
|
+
* the same rule on the global file, which is the one the startup guard reads first.
|
|
51
|
+
*/
|
|
52
|
+
get pendingMigrations(): import("./migrations.js").ConfigMigration[];
|
|
53
|
+
get rawConfig(): Record<string, unknown>;
|
|
54
|
+
onChange(listener: () => void): () => void;
|
|
55
|
+
load(): void;
|
|
56
|
+
reloadFromDisk(): {
|
|
57
|
+
changed: boolean;
|
|
58
|
+
applied: boolean;
|
|
59
|
+
error: string | null;
|
|
60
|
+
};
|
|
61
|
+
private read;
|
|
62
|
+
private notify;
|
|
63
|
+
updateControl(patch: NonNullable<SettingsPatch['control']>): ControlConfig;
|
|
64
|
+
updateHost(patch: NonNullable<SettingsPatch['host']>): HostConfig;
|
|
65
|
+
updateBackups(patch: NonNullable<SettingsPatch['backups']>): BackupsConfig;
|
|
66
|
+
/** The reverse proxy. `routes` is a list a patch replaces; `dns01` merges key by key. */
|
|
67
|
+
updateProxy(patch: ProxyPatch): ProxyConfig;
|
|
68
|
+
/** Regenerates `settings.schema.json` for editor autocomplete, beside the file it describes. */
|
|
69
|
+
writeJsonSchema(): void;
|
|
70
|
+
private parseGroup;
|
|
71
|
+
private commit;
|
|
72
|
+
private resolveFallback;
|
|
73
|
+
private apply;
|
|
74
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { ConfigMigration } from './migrations.js';
|
|
2
|
+
import type { ResolvedServersFile, ResolvedWorkspaceConfig, ResolvedWorkspaceSettings } from './schema.js';
|
|
3
|
+
import type { DdnsConfig, DdnsPatch, LogsConfig, NotificationsConfig, ServerConfig, ServerDefaults, ServerPatch, WorkspaceSettingsPatch } from '../shared/contracts.js';
|
|
4
|
+
import { ConfigError } from './settings.js';
|
|
5
|
+
export { ConfigError };
|
|
6
|
+
export type { ResolvedServersFile, ResolvedWorkspaceSettings };
|
|
7
|
+
/**
|
|
8
|
+
* One workspace's state: its settings file (`defaults`, `logs`, `notifications`,
|
|
9
|
+
* `ddns`) and its servers file, kept apart because they are written by different
|
|
10
|
+
* pages and read by different parts of the panel.
|
|
11
|
+
*
|
|
12
|
+
* Reads stay tolerant in both: an unknown key is reported and skipped, never
|
|
13
|
+
* fatal, so a file written by a newer release still opens the page that edits it.
|
|
14
|
+
* A file this release cannot even parse never replaces what is already running —
|
|
15
|
+
* neither the resolved config nor the `raw` every write patches.
|
|
16
|
+
*/
|
|
17
|
+
export declare class WorkspaceStore {
|
|
18
|
+
private readonly workspaceId;
|
|
19
|
+
private readonly settingsFile;
|
|
20
|
+
private readonly serversFile;
|
|
21
|
+
private readonly seedSettings;
|
|
22
|
+
private readonly seedServers;
|
|
23
|
+
private rawSettings;
|
|
24
|
+
private rawServers;
|
|
25
|
+
private liveSettings;
|
|
26
|
+
private liveServers;
|
|
27
|
+
private lastSettingsText;
|
|
28
|
+
private lastServersText;
|
|
29
|
+
private resolvedConfig;
|
|
30
|
+
/** A JSON parse failure, kept apart from a schema problem so `apply()` cannot clear it. */
|
|
31
|
+
private settingsParseError;
|
|
32
|
+
private serversParseError;
|
|
33
|
+
private settingsError;
|
|
34
|
+
private serversError;
|
|
35
|
+
private warnings;
|
|
36
|
+
private settingsSchemaVersion;
|
|
37
|
+
private serversSchemaVersion;
|
|
38
|
+
private readonly listeners;
|
|
39
|
+
constructor(workspaceId: string, settingsFile: string, serversFile: string, seedSettings?: Record<string, unknown>, seedServers?: Record<string, unknown>);
|
|
40
|
+
get id(): string;
|
|
41
|
+
/** The servers config; the runtime, the watcher and the docs call it that. */
|
|
42
|
+
get path(): string;
|
|
43
|
+
get settingsPath(): string;
|
|
44
|
+
get config(): ResolvedWorkspaceConfig;
|
|
45
|
+
get servers(): ServerConfig[];
|
|
46
|
+
get defaults(): ServerDefaults;
|
|
47
|
+
get logs(): LogsConfig;
|
|
48
|
+
get notifications(): NotificationsConfig;
|
|
49
|
+
get ddns(): DdnsConfig;
|
|
50
|
+
get configError(): string | null;
|
|
51
|
+
get configWarnings(): string[];
|
|
52
|
+
get configSchemaVersion(): number;
|
|
53
|
+
/**
|
|
54
|
+
* The steps a workspace's files need, counting **both** sides.
|
|
55
|
+
*
|
|
56
|
+
* The two files are stamped independently — a person may hand-write `servers.config.json`
|
|
57
|
+
* (which is unstamped, and so reads as schema 1) beside a `settings.json` the panel wrote at
|
|
58
|
+
* the current schema. `configSchemaVersion` answers `max()` because that is the shape *this
|
|
59
|
+
* release* understands of the pair, but the migrations that have to run belong to the **older**
|
|
60
|
+
* file: `planConfigMigrations` is monotonic, so the lower version is the one with steps.
|
|
61
|
+
* Reading `max()` here reported *no* pending migration while the reader was refusing the file
|
|
62
|
+
* for needing one, which left the startup branch that says `run migrate` unreachable and sent
|
|
63
|
+
* the person to "fix or install" instead.
|
|
64
|
+
*
|
|
65
|
+
* A file that cannot be **parsed** is not a migration candidate, though: a schema number can only
|
|
66
|
+
* be read from a file that is JSON, and `migrate` refuses one it cannot read rather than lifting
|
|
67
|
+
* it. The startup guard prints this list as "run migrate", so a broken file must not appear
|
|
68
|
+
* here — it belongs in `configError`'s "fix …" advice alone.
|
|
69
|
+
*/
|
|
70
|
+
get pendingMigrations(): ConfigMigration[];
|
|
71
|
+
onChange(listener: () => void): () => void;
|
|
72
|
+
/** How many listeners are attached; a disposed owner must not add to it. */
|
|
73
|
+
get listenerCount(): number;
|
|
74
|
+
getServer(id: string): ServerConfig | undefined;
|
|
75
|
+
load(): void;
|
|
76
|
+
/**
|
|
77
|
+
* The watcher's entry point: re-reads the files only when their bytes changed.
|
|
78
|
+
*
|
|
79
|
+
* `changed` means the bytes on disk differ from the last trusted read, `applied`
|
|
80
|
+
* means that difference produced a usable config. A revision this release cannot
|
|
81
|
+
* parse is reported in the state frame while the running config is kept, which is
|
|
82
|
+
* what stops an editor's typo from stopping every server — or from bricking the
|
|
83
|
+
* next Save, which patches the raw object this method must therefore leave alone.
|
|
84
|
+
*/
|
|
85
|
+
reloadFromDisk(): {
|
|
86
|
+
changed: boolean;
|
|
87
|
+
applied: boolean;
|
|
88
|
+
error: string | null;
|
|
89
|
+
};
|
|
90
|
+
private markGone;
|
|
91
|
+
private read;
|
|
92
|
+
private notify;
|
|
93
|
+
updateServer(id: string, patch: ServerPatch): ServerConfig;
|
|
94
|
+
updateDefaults(patch: NonNullable<WorkspaceSettingsPatch['defaults']>): ServerDefaults;
|
|
95
|
+
updateLogs(patch: NonNullable<WorkspaceSettingsPatch['logs']>): LogsConfig;
|
|
96
|
+
updateNotifications(patch: NonNullable<WorkspaceSettingsPatch['notifications']>): NotificationsConfig;
|
|
97
|
+
/**
|
|
98
|
+
* The DDNS block merges its two nested groups and **replaces** `accounts` and
|
|
99
|
+
* `domains`: those are lists, and a key-by-key merge cannot express removing a
|
|
100
|
+
* hostname. A whole-block patch (the `PUT /api/ddns` route) lands the same way.
|
|
101
|
+
*/
|
|
102
|
+
updateDdns(patch: DdnsPatch): DdnsConfig;
|
|
103
|
+
addServer(input: Record<string, unknown>): ServerConfig;
|
|
104
|
+
/**
|
|
105
|
+
* Creates the entry, or replaces a same-id one outright — "make it so".
|
|
106
|
+
*
|
|
107
|
+
* `addServer` refuses a duplicate and `updateServer` only patches an existing entry, so a config
|
|
108
|
+
* management pass had to GET, diff, then POST or PATCH, and a re-run of an unchanged declaration
|
|
109
|
+
* got `400 INVALID_SERVER` for its trouble. A replace is what a declarative caller means: the
|
|
110
|
+
* body is the whole entry, not a patch.
|
|
111
|
+
*
|
|
112
|
+
* Returns whether it created or replaced, so the route can answer 201 or 200 honestly.
|
|
113
|
+
*/
|
|
114
|
+
putServer(input: Record<string, unknown>): {
|
|
115
|
+
server: ServerConfig;
|
|
116
|
+
created: boolean;
|
|
117
|
+
};
|
|
118
|
+
removeServer(id: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* Regenerates both JSON schemas for editor autocomplete, beside the files they
|
|
121
|
+
* describe — derived from this store's own paths, never from a module-level
|
|
122
|
+
* default, so a store over a custom root cannot write into `$HHOSTED_HOME`.
|
|
123
|
+
*/
|
|
124
|
+
writeJsonSchema(): void;
|
|
125
|
+
private writeSchema;
|
|
126
|
+
private parseGroup;
|
|
127
|
+
private validateServer;
|
|
128
|
+
private commitSettings;
|
|
129
|
+
private commitServers;
|
|
130
|
+
private apply;
|
|
131
|
+
private resolveSettingsFallback;
|
|
132
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Workspace } from '../shared/contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* The workspace registry: which workspaces exist, in the order the selector shows
|
|
4
|
+
* them. Kept apart from any workspace's own files so it can be read before they
|
|
5
|
+
* are, and so creating or removing one is a single small write.
|
|
6
|
+
*/
|
|
7
|
+
export declare const workspacesFileSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
8
|
+
workspaces: {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
}[];
|
|
12
|
+
$schema?: string | undefined;
|
|
13
|
+
meta?: {
|
|
14
|
+
writtenBy: import("arktype/internal/attributes.ts").Default<string, "">;
|
|
15
|
+
schema: import("arktype/internal/attributes.ts").Default<number, 1>;
|
|
16
|
+
} | undefined;
|
|
17
|
+
}, {}>;
|
|
18
|
+
/**
|
|
19
|
+
* The *kind* of registry failure, when a caller has to branch on it rather than just report it.
|
|
20
|
+
* The workspaces route answers 404 for an unknown id, 409 for a conflict and 400 otherwise, and it
|
|
21
|
+
* decided that by matching the message text.
|
|
22
|
+
*/
|
|
23
|
+
export type WorkspaceErrorCode = 'UNKNOWN_WORKSPACE' | 'WORKSPACE_EXISTS';
|
|
24
|
+
/**
|
|
25
|
+
* The workspace a command acts in when none was named: `default` if the host declares it, else the
|
|
26
|
+
* first one it declares.
|
|
27
|
+
*
|
|
28
|
+
* **The panel already answers this question, and the CLI was answering a different one.** Every
|
|
29
|
+
* workspace-scoped `/api` and `/_hh` route resolves an omitted `?workspace` through
|
|
30
|
+
* `PanelService.requireWorkspace` → `WorkspaceRegistry.defaultId`, i.e. this rule. The two CLI
|
|
31
|
+
* commands that take a workspace id read `DEFAULT_WORKSPACE_ID` literally instead — so on a host
|
|
32
|
+
* whose registry lists one workspace that is not called `default` (a colleague's panel, or one
|
|
33
|
+
* where `default` was removed), `start <id>` reached that workspace while `logs <id>` looked in
|
|
34
|
+
* `.hh/default/.logs/`, a directory that does not exist. Measured: `logs` answered "no output yet"
|
|
35
|
+
* and exited 0 for a log that was on disk, on the one command a diagnostic session starts with.
|
|
36
|
+
*
|
|
37
|
+
* One function, called by every surface that asks, so a third caller cannot re-derive it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function defaultWorkspaceId(workspaces: ReadonlyArray<Readonly<{
|
|
40
|
+
id: string;
|
|
41
|
+
}>>): string;
|
|
42
|
+
/**
|
|
43
|
+
* `defaultWorkspaceId`, for a command that has a registry file and no panel.
|
|
44
|
+
*
|
|
45
|
+
* Tolerant for the same reason the panel's own startup guard is the one that refuses a broken
|
|
46
|
+
* registry: a diagnostic command reading one log must not be the thing that fails loudly about a
|
|
47
|
+
* file it only needed one id from. Missing, unparseable or empty falls back to `default`, which is
|
|
48
|
+
* what the seed declares.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readDefaultWorkspaceId(file: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* The workspace ids a registry declares — or `null` when it cannot answer.
|
|
53
|
+
*
|
|
54
|
+
* `readDefaultWorkspaceId`'s sibling for a command that must tell "that workspace does not exist"
|
|
55
|
+
* from "I cannot tell": a diagnostic that answers an empty log for a typo'd `--workspace` is the
|
|
56
|
+
* same false answer as one that answers it for a typo'd server id. `null` keeps the caller silent
|
|
57
|
+
* on a registry it could not read, because unreadable is not "it names none".
|
|
58
|
+
*
|
|
59
|
+
* An **empty** registry is `null` too, for the same reason its sibling falls back to `default`: a
|
|
60
|
+
* registry listing nothing is what a hand-edit or a partially written file looks like, and the panel
|
|
61
|
+
* treats it as `default` rather than as "no workspace exists". Answering `[]` there made `logs <id>`
|
|
62
|
+
* refuse the default workspace that `start` and the panel both serve.
|
|
63
|
+
*/
|
|
64
|
+
export declare function readWorkspaceIds(file: string): string[] | null;
|
|
65
|
+
export declare class WorkspaceError extends Error {
|
|
66
|
+
name: string;
|
|
67
|
+
readonly code: WorkspaceErrorCode | undefined;
|
|
68
|
+
constructor(message: string, code?: WorkspaceErrorCode);
|
|
69
|
+
}
|
|
70
|
+
/** `My Project AB!` -> `my-project-ab`, and never an empty id. */
|
|
71
|
+
export declare function slugifyWorkspaceId(label: string, taken?: Iterable<string>): string;
|
|
72
|
+
export declare class WorkspaceRegistry {
|
|
73
|
+
private readonly file;
|
|
74
|
+
private list;
|
|
75
|
+
private error;
|
|
76
|
+
private readonly listeners;
|
|
77
|
+
constructor(file?: string);
|
|
78
|
+
get path(): string;
|
|
79
|
+
/** Blocking problems; the caller refuses to start on one, exactly as for configs. */
|
|
80
|
+
get configError(): string | null;
|
|
81
|
+
all(): Workspace[];
|
|
82
|
+
get(id: string): Workspace | undefined;
|
|
83
|
+
has(id: string): boolean;
|
|
84
|
+
/** The id a workspace-scoped request resolves to when none is given. */
|
|
85
|
+
get defaultId(): string;
|
|
86
|
+
onChange(listener: () => void): () => void;
|
|
87
|
+
load(): void;
|
|
88
|
+
create(input: {
|
|
89
|
+
id?: string;
|
|
90
|
+
label?: string;
|
|
91
|
+
}): Workspace;
|
|
92
|
+
rename(id: string, label: string): Workspace;
|
|
93
|
+
remove(id: string): Workspace;
|
|
94
|
+
private commit;
|
|
95
|
+
private notify;
|
|
96
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DetailedError } from '@namesmt/utils';
|
|
2
|
+
/** The internal marker. A symbol so it never survives `JSON.stringify`. */
|
|
3
|
+
export declare const UNKNOWN_SERVER: unique symbol;
|
|
4
|
+
/** What a per-server action (`start`/`stop`/`restart`/`free-port`) answers with. */
|
|
5
|
+
export interface ActionResult {
|
|
6
|
+
ok: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Set when the failure was "no such entry" rather than "this entry cannot act".
|
|
10
|
+
*
|
|
11
|
+
* The status rule needs the *kind* of failure, and a message is not a kind: any text beginning
|
|
12
|
+
* `unknown server` — a future "unknown serverless runtime" — was read as a missing id, telling the
|
|
13
|
+
* client to fix an id that was fine.
|
|
14
|
+
*
|
|
15
|
+
* A **symbol**, so it is internal: it carries the meaning to `statusForAction` without joining the
|
|
16
|
+
* JSON a client receives, which would be an unintended wire change. `missingServer()` is the only
|
|
17
|
+
* writer.
|
|
18
|
+
*/
|
|
19
|
+
[UNKNOWN_SERVER]?: true;
|
|
20
|
+
}
|
|
21
|
+
/** The one shape a missing entry takes, so the marker and the message cannot drift apart. */
|
|
22
|
+
export declare function missingServer(id: string): ActionResult;
|
|
23
|
+
/**
|
|
24
|
+
* The same failure where the caller throws instead of answering — the route side of `missingServer()`.
|
|
25
|
+
*
|
|
26
|
+
* `api/logs.ts` and `api/servers/$.routes.ts` each carried a byte-identical private copy of this, with
|
|
27
|
+
* six call sites between them. Two copies of a wire contract (the message, the 404, the `UNKNOWN_SERVER`
|
|
28
|
+
* code) is the drift that already happened once for `request`: a change landing in one UI and not the
|
|
29
|
+
* other. Defining it beside the message keeps one owner for the wording.
|
|
30
|
+
*/
|
|
31
|
+
export declare function unknownServerError(id: string): DetailedError;
|
|
32
|
+
/**
|
|
33
|
+
* The stable code for a failed action, so a script branches on it rather than on English.
|
|
34
|
+
*
|
|
35
|
+
* Two values, not one per message: a missing id is what the caller must fix, and everything else
|
|
36
|
+
* ("disabled", "stopping", "port in use") is the entry refusing right now. `code` is added beside
|
|
37
|
+
* `ok`/`error` rather than replacing them, because an older UI reads those.
|
|
38
|
+
*/
|
|
39
|
+
export declare function actionCode(result: ActionResult): string;
|
|
40
|
+
/** What a lifecycle route puts on the wire. A success carries no code — a code names a failure. */
|
|
41
|
+
export declare function actionAnswer(result: ActionResult): ActionResult & {
|
|
42
|
+
code?: string;
|
|
43
|
+
message?: string;
|
|
44
|
+
};
|
|
45
|
+
/** Unknown ids are 404; a server that exists but cannot act is a 409. */
|
|
46
|
+
export declare function statusForAction(result: ActionResult): 200 | 404 | 409;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface WriteFileOptions {
|
|
2
|
+
/** Applied to the temp file before the rename, so secrets never exist world-readable. */
|
|
3
|
+
mode?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Write via a temp file in the same directory, then rename: readers never see a
|
|
7
|
+
* half-written file, and a crash cannot truncate the previous config.
|
|
8
|
+
*/
|
|
9
|
+
export declare function writeFileAtomic(file: string, content: string, options?: WriteFileOptions): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface BackoffOptions {
|
|
2
|
+
baseDelayMs: number;
|
|
3
|
+
factor: number;
|
|
4
|
+
maxDelayMs: number;
|
|
5
|
+
}
|
|
6
|
+
/** Exponential backoff: base * factor^(attempt - 1), capped at maxDelayMs. */
|
|
7
|
+
export declare function computeBackoff(attempt: number, options: BackoffOptions): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This machine's first non-internal IPv4 address, or null when it has none.
|
|
3
|
+
*
|
|
4
|
+
* Cached for `LAN_ADDRESS_TTL_MS`: the call is expensive and its answer is read per server per
|
|
5
|
+
* state frame. The cache is module state, which is acceptable here for the same reason
|
|
6
|
+
* `appVersion()`'s is — the answer is a property of the host, not of a workspace, and nothing in
|
|
7
|
+
* a test changes the interfaces it observes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function lanAddress(now?: number): string | null;
|
|
10
|
+
/** Forgets the cached address. A test that simulates a network change calls this first. */
|
|
11
|
+
export declare function forgetLanAddress(): void;
|
|
12
|
+
export declare function bindHost(bind: string): string;
|
|
13
|
+
/** Address a human should open, which is never `0.0.0.0`. */
|
|
14
|
+
export declare function displayHost(bind: string): string;
|
|
15
|
+
/** True when the bind value makes the port reachable from outside this machine. */
|
|
16
|
+
export declare function isExposed(bind: string): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/**
|
|
3
|
+
* Decodes a hand-editable state file the way the editors that write them save it.
|
|
4
|
+
*
|
|
5
|
+
* A file the panel invites a person to hand-edit arrives the way their editor saved it, and the
|
|
6
|
+
* editors that write one on Windows prepend a **byte-order mark**: PowerShell's
|
|
7
|
+
* `Set-Content -Encoding UTF8` (5.1) and `Out-File`/`>` (UTF-16LE) both do, and Notepad writes one
|
|
8
|
+
* for a "UTF-8 with BOM" save. For JSON the refusal is a parse error naming an invisible character
|
|
9
|
+
* — `Unexpected token '\uFEFF'` — so the person is told their JSON is broken when it is not. For a
|
|
10
|
+
* `KEY=value` file it is quieter: every key carries a NUL and is dropped, so the process starts
|
|
11
|
+
* without the secrets the file exists to hold.
|
|
12
|
+
*
|
|
13
|
+
* Stripping the mark is not a silent coercion: a BOM is not content, and a file whose real
|
|
14
|
+
* content is unchanged parses to the same object with or without it. UTF-16 is decoded rather
|
|
15
|
+
* than refused because that is what `>` produces on Windows, and it is recognisable from its own
|
|
16
|
+
* prefix — a file in neither encoding still fails loudly in the reader above.
|
|
17
|
+
*
|
|
18
|
+
* Read as a `Buffer`, never with `'utf8'`: a `'utf8'` read of UTF-16LE text has already lost
|
|
19
|
+
* the information this needs to tell them apart.
|
|
20
|
+
*/
|
|
21
|
+
export declare function decodeStateFile(bytes: Buffer): string;
|
|
22
|
+
/** `decodeStateFile` for a path. Missing files still throw `ENOENT`, as a caller expects. */
|
|
23
|
+
export declare function readStateFile(file: string): string;
|