home-hosted 0.13.1 → 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.
- package/README.md +117 -322
- package/bin/home-hosted.mjs +41 -0
- package/dist/chunks/account-DiLrSyww.js +359 -0
- package/dist/chunks/account-DiLrSyww.js.map +1 -0
- package/dist/chunks/add-DEIYVkNK.js +183 -0
- package/dist/chunks/add-DEIYVkNK.js.map +1 -0
- package/dist/chunks/{archive-DP-XQR8X.js → archive-DFi3qK1c.js} +25 -73
- package/dist/chunks/archive-DFi3qK1c.js.map +1 -0
- package/dist/chunks/{atomic-C1PfJpE7.js → atomic-SZUwDtGD.js} +3 -6
- package/dist/chunks/atomic-SZUwDtGD.js.map +1 -0
- package/dist/chunks/{backup-DeAJ3pbO.js → backup-DnyxIzw0.js} +110 -190
- package/dist/chunks/backup-DnyxIzw0.js.map +1 -0
- package/dist/chunks/backups-BrrN6cwW.js +2203 -0
- package/dist/chunks/backups-BrrN6cwW.js.map +1 -0
- package/dist/chunks/bind-DIxrnUst.js +43 -0
- package/dist/chunks/bind-DIxrnUst.js.map +1 -0
- package/dist/chunks/config-text-DxMOQQnk.js +34 -0
- package/dist/chunks/config-text-DxMOQQnk.js.map +1 -0
- package/dist/chunks/{contracts-CMBD1TF9.js → contracts-CxZ7u1L3.js} +1239 -1454
- package/dist/chunks/contracts-CxZ7u1L3.js.map +1 -0
- package/dist/chunks/daemon-BAAYUYQC.js +211 -0
- package/dist/chunks/daemon-BAAYUYQC.js.map +1 -0
- package/dist/chunks/daemon-log-Ccu-69vB.js +179 -0
- package/dist/chunks/daemon-log-Ccu-69vB.js.map +1 -0
- package/dist/chunks/deploy-CggSOEkq.js +144 -0
- package/dist/chunks/deploy-CggSOEkq.js.map +1 -0
- package/dist/chunks/{docker-Cy9Lyvda.js → docker--Un0uLfF.js} +32 -68
- package/dist/chunks/docker--Un0uLfF.js.map +1 -0
- package/dist/chunks/{down-C59ne5aM.js → down-CpIN7LEQ.js} +34 -94
- package/dist/chunks/down-CpIN7LEQ.js.map +1 -0
- package/dist/chunks/exposure-CDJNvOCK.js +229 -0
- package/dist/chunks/exposure-CDJNvOCK.js.map +1 -0
- package/dist/chunks/import-Bd4VZH0f.js +205 -0
- package/dist/chunks/import-Bd4VZH0f.js.map +1 -0
- package/dist/chunks/import-plan--fDS_l5r.js +147 -0
- package/dist/chunks/import-plan--fDS_l5r.js.map +1 -0
- package/dist/chunks/import-write-BTfbeV26.js +42 -0
- package/dist/chunks/import-write-BTfbeV26.js.map +1 -0
- package/dist/chunks/{init-BZ7hK9Vf.js → init-Bv3oH65x.js} +14 -50
- package/dist/chunks/init-Bv3oH65x.js.map +1 -0
- package/dist/chunks/job-CYOdN6Ub.js +341 -0
- package/dist/chunks/job-CYOdN6Ub.js.map +1 -0
- package/dist/chunks/jobs-BX4ahcfh.js +489 -0
- package/dist/chunks/jobs-BX4ahcfh.js.map +1 -0
- package/dist/chunks/last-stop-DD3lHwo_.js +42 -0
- package/dist/chunks/last-stop-DD3lHwo_.js.map +1 -0
- package/dist/chunks/layout-D0ysDNav.js +18 -0
- package/dist/chunks/layout-D0ysDNav.js.map +1 -0
- package/dist/chunks/lazy-kfcBNeqj.js +48 -0
- package/dist/chunks/lazy-kfcBNeqj.js.map +1 -0
- package/dist/chunks/log-buffer-B7jmn7ts.js +110 -0
- package/dist/chunks/log-buffer-B7jmn7ts.js.map +1 -0
- package/dist/chunks/log-files-CZL2UhuE.js +488 -0
- package/dist/chunks/log-files-CZL2UhuE.js.map +1 -0
- package/dist/chunks/{logger-B5U4GD3j.js → logger-BnrKTBHQ.js} +2 -6
- package/dist/chunks/logger-BnrKTBHQ.js.map +1 -0
- package/dist/chunks/{logs---TI_bxM.js → logs-DxKI6OW2.js} +23 -73
- package/dist/chunks/logs-DxKI6OW2.js.map +1 -0
- package/dist/chunks/ls-BseUHy_m.js +128 -0
- package/dist/chunks/ls-BseUHy_m.js.map +1 -0
- package/dist/chunks/migrate-D4w_dXDm.js +268 -0
- package/dist/chunks/migrate-D4w_dXDm.js.map +1 -0
- package/dist/chunks/{nanny-rewguyXg.js → nanny-BWh7nuvv.js} +21 -14
- package/dist/chunks/nanny-BWh7nuvv.js.map +1 -0
- package/dist/chunks/{nanny-Dnun3hVB.js → nanny-BjF2-1pv.js} +3 -3
- package/dist/chunks/{nanny-Dnun3hVB.js.map → nanny-BjF2-1pv.js.map} +1 -1
- package/dist/chunks/nanny-DGTXVq5d.js +806 -0
- package/dist/chunks/nanny-DGTXVq5d.js.map +1 -0
- package/dist/chunks/{nanny-sweep-ClVuNJRo.js → nanny-sweep-hjmZ_p7S.js} +14 -24
- package/dist/chunks/nanny-sweep-hjmZ_p7S.js.map +1 -0
- package/dist/chunks/{nearest-6KgQEDUe.js → nearest-DOx4jySJ.js} +2 -10
- package/dist/chunks/nearest-DOx4jySJ.js.map +1 -0
- package/dist/chunks/{parse-DhmG26fI.js → parse-DVMPLUDe.js} +47 -72
- package/dist/chunks/parse-DVMPLUDe.js.map +1 -0
- package/dist/chunks/password-policy-Clq6PGE-.js +9 -0
- package/dist/chunks/password-policy-Clq6PGE-.js.map +1 -0
- package/dist/chunks/{paths-CGlGDrOU.js → paths-C34-TJLh.js} +32 -56
- package/dist/chunks/paths-C34-TJLh.js.map +1 -0
- package/dist/chunks/{port-k5VBw8t9.js → port-CnsrxKNR.js} +23 -70
- package/dist/chunks/port-CnsrxKNR.js.map +1 -0
- package/dist/chunks/process-CboOFPU_.js +192 -0
- package/dist/chunks/process-CboOFPU_.js.map +1 -0
- package/dist/chunks/{restart-BYu_E7x5.js → restart-C0J8dZ2L.js} +11 -29
- package/dist/chunks/restart-C0J8dZ2L.js.map +1 -0
- package/dist/chunks/run-deploy-DoNDvwT4.js +91 -0
- package/dist/chunks/run-deploy-DoNDvwT4.js.map +1 -0
- package/dist/chunks/{schema-B240VXcV.js → schema-CZ6f-PHD.js} +7 -20
- package/dist/chunks/schema-CZ6f-PHD.js.map +1 -0
- package/dist/chunks/secret-MY397r90.js +219 -0
- package/dist/chunks/secret-MY397r90.js.map +1 -0
- package/dist/chunks/secrets-CG5N4lwY.js +1061 -0
- package/dist/chunks/secrets-CG5N4lwY.js.map +1 -0
- package/dist/chunks/server-Dm_dXfTW.js +255 -0
- package/dist/chunks/server-Dm_dXfTW.js.map +1 -0
- package/dist/chunks/server-attention-UQwYXqKe.js +10 -0
- package/dist/chunks/server-attention-UQwYXqKe.js.map +1 -0
- package/dist/chunks/server-create-D7nvhgBd.js +96 -0
- package/dist/chunks/server-create-D7nvhgBd.js.map +1 -0
- package/dist/chunks/server-ids-BEQD2rFz.js +23 -0
- package/dist/chunks/server-ids-BEQD2rFz.js.map +1 -0
- package/dist/chunks/server-vars-DMYmHutL.js +27 -0
- package/dist/chunks/server-vars-DMYmHutL.js.map +1 -0
- package/dist/chunks/service-C8l-ewNA.js +585 -0
- package/dist/chunks/service-C8l-ewNA.js.map +1 -0
- package/dist/chunks/{settings-xu-XTfWg.js → settings-CtYDs5PX.js} +62 -78
- package/dist/chunks/settings-CtYDs5PX.js.map +1 -0
- package/dist/chunks/{setup-temp-CAN4_bA-.js → setup-temp-TAtDmMMU.js} +43 -37
- package/dist/chunks/setup-temp-TAtDmMMU.js.map +1 -0
- package/dist/chunks/shape-CDGeYl_J.js +9 -0
- package/dist/chunks/shape-CDGeYl_J.js.map +1 -0
- package/dist/chunks/{src-BOBh9MBf.js → src-BnzkVy_M.js} +12547 -10578
- package/dist/chunks/src-BnzkVy_M.js.map +1 -0
- package/dist/chunks/{status-B6f2-qhs.js → status-efbbfYZQ.js} +53 -26
- package/dist/chunks/status-efbbfYZQ.js.map +1 -0
- package/dist/chunks/store-Bs_Lljjm.js +2082 -0
- package/dist/chunks/store-Bs_Lljjm.js.map +1 -0
- package/dist/chunks/template-xan58bJh.js +28 -0
- package/dist/chunks/template-xan58bJh.js.map +1 -0
- package/dist/chunks/token-DDeWfZA4.js +142 -0
- package/dist/chunks/token-DDeWfZA4.js.map +1 -0
- package/dist/chunks/{ui-D562aqw5.js → ui-BcIAtyxE.js} +68 -79
- package/dist/chunks/ui-BcIAtyxE.js.map +1 -0
- package/dist/chunks/{ui-dir-CsU3uLNV.js → ui-dir-ClCzVRc3.js} +3 -7
- package/dist/chunks/ui-dir-ClCzVRc3.js.map +1 -0
- package/dist/chunks/ui-format-CDvvqOoi.js +53 -0
- package/dist/chunks/ui-format-CDvvqOoi.js.map +1 -0
- package/dist/chunks/{ui-release-DKzVvlLd.js → ui-release-XbJ85pYI.js} +36 -38
- package/dist/chunks/ui-release-XbJ85pYI.js.map +1 -0
- package/dist/chunks/{ui-revert-EkBBwRTt.js → ui-revert-Dgawq7ze.js} +4 -4
- package/dist/chunks/ui-revert-Dgawq7ze.js.map +1 -0
- package/dist/chunks/{ui-switch-BnZTdMDd.js → ui-switch-CfQMbZ0g.js} +31 -38
- package/dist/chunks/ui-switch-CfQMbZ0g.js.map +1 -0
- package/dist/chunks/{ui-update-_xryLYxw.js → ui-update-B3PPivUm.js} +30 -48
- package/dist/chunks/ui-update-B3PPivUm.js.map +1 -0
- package/dist/chunks/ui-update-CAiH2tFb.js +109 -0
- package/dist/chunks/ui-update-CAiH2tFb.js.map +1 -0
- package/dist/chunks/{up-DNZuTi2q.js → up-BQSnYxYd.js} +47 -53
- package/dist/chunks/up-BQSnYxYd.js.map +1 -0
- package/dist/chunks/{usage-BrnDARNM.js → usage-KG8TeOio.js} +7 -20
- package/dist/chunks/usage-KG8TeOio.js.map +1 -0
- package/dist/chunks/{workspaces-DYcfvKV_.js → workspaces-D9akpzU8.js} +80 -68
- package/dist/chunks/workspaces-D9akpzU8.js.map +1 -0
- package/dist/chunks/{wsl-temperature-BiCI4iK6.js → wsl-temperature-D-_d4Yk1.js} +47 -42
- package/dist/chunks/wsl-temperature-D-_d4Yk1.js.map +1 -0
- package/dist/cli.js +306 -238
- package/dist/cli.js.map +1 -1
- package/dist/client.js +76 -29
- package/dist/client.js.map +1 -1
- package/dist/types/api/acme.d.ts +3 -7
- package/dist/types/api/auth/$.routes.d.ts +107 -16
- package/dist/types/api/backups.d.ts +5 -5
- package/dist/types/api/control.d.ts +747 -38
- package/dist/types/api/ddns.d.ts +13 -18
- package/dist/types/api/events.d.ts +9 -3
- package/dist/types/api/health.d.ts +2 -4
- package/dist/types/api/jobs.d.ts +438 -0
- package/dist/types/api/logs.d.ts +20 -0
- package/dist/types/api/metrics.d.ts +2 -5
- package/dist/types/api/notifications.d.ts +3 -6
- package/dist/types/api/proxy.d.ts +63 -23
- package/dist/types/api/server-ops.d.ts +17 -0
- package/dist/types/api/servers/$.routes.d.ts +418 -186
- package/dist/types/api/session-required.d.ts +16 -0
- package/dist/types/api/settings.d.ts +7 -7
- package/dist/types/api/state.d.ts +100 -10
- package/dist/types/api/static.d.ts +2 -2
- package/dist/types/api/tls.d.ts +2 -5
- package/dist/types/api/workspaces/$.routes.d.ts +186 -12
- package/dist/types/api/wsl-temperature.d.ts +4 -10
- package/dist/types/app.d.ts +4511 -2778
- package/dist/types/cli/account.d.ts +23 -0
- package/dist/types/cli/add.d.ts +96 -0
- package/dist/types/cli/args.d.ts +24 -35
- package/dist/types/cli/backup-offline.d.ts +2 -8
- package/dist/types/cli/backup.d.ts +12 -21
- package/dist/types/cli/down.d.ts +15 -41
- package/dist/types/cli/import-plan.d.ts +55 -0
- package/dist/types/cli/import-write.d.ts +5 -0
- package/dist/types/cli/import.d.ts +86 -0
- package/dist/types/cli/io.d.ts +26 -35
- package/dist/types/cli/job.d.ts +99 -0
- package/dist/types/cli/logs.d.ts +1 -10
- package/dist/types/cli/ls.d.ts +57 -0
- package/dist/types/cli/migrate.d.ts +31 -8
- package/dist/types/cli/nearest.d.ts +1 -9
- package/dist/types/cli/run-deploy.d.ts +36 -0
- package/dist/types/cli/secret.d.ts +90 -0
- package/dist/types/cli/server.d.ts +6 -15
- package/dist/types/cli/service.d.ts +135 -0
- package/dist/types/cli/setup-temp.d.ts +17 -13
- package/dist/types/cli/status.d.ts +7 -1
- package/dist/types/cli/token.d.ts +6 -0
- package/dist/types/cli/ui-switch.d.ts +3 -14
- package/dist/types/cli/ui-update.d.ts +3 -16
- package/dist/types/cli/up.d.ts +9 -22
- package/dist/types/cli/usage.d.ts +2 -6
- package/dist/types/cli.d.ts +1 -10
- package/dist/types/client.d.ts +4099 -1142
- package/dist/types/config/accounts.d.ts +16 -0
- package/dist/types/config/jobs.d.ts +68 -0
- package/dist/types/config/layout.d.ts +2 -8
- package/dist/types/config/migrations.d.ts +9 -41
- package/dist/types/config/parse.d.ts +8 -13
- package/dist/types/config/patch.d.ts +1 -6
- package/dist/types/config/schema.d.ts +16 -18
- package/dist/types/config/secret-parts.d.ts +6 -27
- package/dist/types/config/secrets.d.ts +167 -88
- package/dist/types/config/seed.d.ts +1 -6
- package/dist/types/config/server-ids.d.ts +2 -11
- package/dist/types/config/settings.d.ts +13 -49
- package/dist/types/config/store.d.ts +17 -54
- package/dist/types/config/workspaces.d.ts +24 -56
- package/dist/types/helpers/action-result.d.ts +18 -32
- package/dist/types/helpers/atomic.d.ts +1 -4
- package/dist/types/helpers/backoff.d.ts +0 -1
- package/dist/types/helpers/bind.d.ts +3 -11
- package/dist/types/helpers/config-text.d.ts +4 -19
- package/dist/types/helpers/cookies.d.ts +2 -7
- package/dist/types/helpers/copy-tree.d.ts +4 -12
- package/dist/types/helpers/daemon-log.d.ts +8 -33
- package/dist/types/helpers/daemon.d.ts +20 -70
- package/dist/types/helpers/deferred.d.ts +2 -4
- package/dist/types/helpers/env-file.d.ts +2 -7
- package/dist/types/helpers/error.d.ts +3 -14
- package/dist/types/helpers/event-stream.d.ts +18 -10
- package/dist/types/helpers/factory.d.ts +2 -3
- package/dist/types/helpers/last-stop.d.ts +5 -12
- package/dist/types/helpers/logger.d.ts +1 -5
- package/dist/types/helpers/open.d.ts +0 -1
- package/dist/types/helpers/openapi.d.ts +19 -5
- package/dist/types/helpers/paths.d.ts +18 -53
- package/dist/types/helpers/restore-lock.d.ts +2 -17
- package/dist/types/helpers/runtime.d.ts +3 -13
- package/dist/types/helpers/secret-compare.d.ts +2 -10
- package/dist/types/helpers/server-create.d.ts +15 -0
- package/dist/types/helpers/shell.d.ts +2 -16
- package/dist/types/helpers/sse.d.ts +8 -6
- package/dist/types/helpers/ui-dir.d.ts +1 -5
- package/dist/types/helpers/utf8-chunks.d.ts +2 -8
- package/dist/types/helpers/validate.d.ts +2 -4
- package/dist/types/helpers/validator.d.ts +8 -4
- package/dist/types/helpers/version.d.ts +1 -6
- package/dist/types/helpers/workspace.d.ts +24 -16
- package/dist/types/index.d.ts +2 -3
- package/dist/types/middleware/auth.d.ts +8 -27
- package/dist/types/middleware/body-limit.d.ts +10 -0
- package/dist/types/middleware/host.d.ts +4 -23
- package/dist/types/middleware/loopback.d.ts +1 -8
- package/dist/types/middleware/token-scope.d.ts +34 -0
- package/dist/types/node-compat.d.ts +43 -0
- package/dist/types/openapi-reference.d.ts +4 -19
- package/dist/types/openapi.d.ts +5 -8
- package/dist/types/providers/archive.d.ts +8 -25
- package/dist/types/providers/backup-hook.d.ts +4 -19
- package/dist/types/providers/ddns/dyndns2.d.ts +0 -3
- package/dist/types/providers/ddns/index.d.ts +2 -3
- package/dist/types/providers/ddns/ip.d.ts +2 -12
- package/dist/types/providers/ddns/namecheap-api.d.ts +3 -2
- package/dist/types/providers/ddns/types.d.ts +6 -32
- package/dist/types/providers/ddns/zone.d.ts +1 -4
- package/dist/types/providers/docker.d.ts +18 -45
- package/dist/types/providers/entry-state.d.ts +4 -9
- package/dist/types/providers/health-check.d.ts +1 -5
- package/dist/types/providers/host.d.ts +33 -108
- package/dist/types/providers/identity.d.ts +9 -34
- package/dist/types/providers/log-tail.d.ts +14 -24
- package/dist/types/providers/nanny-sweep.d.ts +8 -25
- package/dist/types/providers/nanny.d.ts +16 -58
- package/dist/types/providers/port.d.ts +28 -83
- package/dist/types/providers/proc.d.ts +22 -80
- package/dist/types/providers/process.d.ts +12 -36
- package/dist/types/providers/proxy/admin.d.ts +11 -0
- package/dist/types/providers/proxy/types.d.ts +4 -16
- package/dist/types/providers/telegram.d.ts +1 -17
- package/dist/types/providers/ui-release.d.ts +15 -25
- package/dist/types/providers/webhook.d.ts +8 -29
- package/dist/types/providers/wsl-temperature.d.ts +13 -22
- package/dist/types/services/acme-challenge.d.ts +2 -16
- package/dist/types/services/auth.d.ts +65 -80
- package/dist/types/services/backups/archive-safety.d.ts +30 -0
- package/dist/types/services/backups/paths.d.ts +31 -0
- package/dist/types/services/backups.d.ts +61 -271
- package/dist/types/services/config-watch.d.ts +3 -15
- package/dist/types/services/control-server.d.ts +6 -10
- package/dist/types/services/ddns.d.ts +12 -13
- package/dist/types/services/dependencies.d.ts +3 -14
- package/dist/types/services/deploy.d.ts +34 -0
- package/dist/types/services/events.d.ts +15 -9
- package/dist/types/services/exposure.d.ts +13 -63
- package/dist/types/services/history.d.ts +5 -14
- package/dist/types/services/host-monitor.d.ts +6 -11
- package/dist/types/services/init.d.ts +5 -35
- package/dist/types/services/job-ledger.d.ts +27 -0
- package/dist/types/services/jobs.d.ts +113 -0
- package/dist/types/services/log-buffer.d.ts +7 -8
- package/dist/types/services/log-files.d.ts +12 -42
- package/dist/types/services/log-relay.d.ts +3 -13
- package/dist/types/services/nanny.d.ts +3 -10
- package/dist/types/services/notifications.d.ts +31 -61
- package/dist/types/services/panel.d.ts +32 -78
- package/dist/types/services/proxy-certificates/certificates.d.ts +31 -69
- package/dist/types/services/proxy-config.d.ts +15 -36
- package/dist/types/services/proxy-dns01.d.ts +14 -0
- package/dist/types/services/proxy.d.ts +73 -254
- package/dist/types/services/scheduler.d.ts +46 -0
- package/dist/types/services/state.d.ts +17 -8
- package/dist/types/services/supervisor/compose.d.ts +2 -6
- package/dist/types/services/supervisor/entry.d.ts +29 -32
- package/dist/types/services/supervisor/health.d.ts +8 -31
- package/dist/types/services/supervisor/job-run.d.ts +36 -0
- package/dist/types/services/supervisor/output.d.ts +13 -77
- package/dist/types/services/supervisor/persistent.d.ts +5 -11
- package/dist/types/services/supervisor/port-preflight.d.ts +4 -10
- package/dist/types/services/supervisor/records.d.ts +27 -60
- package/dist/types/services/supervisor/restart-required.d.ts +13 -0
- package/dist/types/services/supervisor/spawn.d.ts +3 -5
- package/dist/types/services/supervisor/view.d.ts +3 -1
- package/dist/types/services/supervisor.d.ts +31 -43
- package/dist/types/services/tls.d.ts +6 -17
- package/dist/types/services/ui-update.d.ts +19 -17
- package/dist/types/services/ui.d.ts +10 -19
- package/dist/types/shared/action-outcome.d.ts +2 -7
- package/dist/types/shared/api-client.d.ts +133 -177
- package/dist/types/shared/api-scopes.d.ts +17 -0
- package/dist/types/shared/backup-scope.d.ts +16 -90
- package/dist/types/shared/clone.d.ts +2 -11
- package/dist/types/shared/contracts/accounts.d.ts +99 -0
- package/dist/types/shared/contracts/backups.d.ts +219 -0
- package/dist/types/shared/contracts/ddns.d.ts +208 -0
- package/dist/types/shared/contracts/frames.d.ts +1395 -0
- package/dist/types/shared/contracts/index.d.ts +3 -0
- package/dist/types/shared/contracts/logs.d.ts +107 -0
- package/dist/types/shared/contracts/proxy.d.ts +303 -0
- package/dist/types/shared/contracts.d.ts +852 -1982
- package/dist/types/shared/cpu-scale.d.ts +3 -19
- package/dist/types/shared/crash-cause.d.ts +8 -0
- package/dist/types/shared/cron.d.ts +70 -0
- package/dist/types/shared/ddns-form.d.ts +9 -43
- package/dist/types/shared/endpoint.d.ts +1 -7
- package/dist/types/shared/error-codes.d.ts +438 -0
- package/dist/types/shared/error-message.d.ts +1 -7
- package/dist/types/shared/fields.d.ts +7 -17
- package/dist/types/shared/form-repair.d.ts +1 -5
- package/dist/types/shared/generated.d.ts +3 -19
- package/dist/types/shared/host-readings.d.ts +25 -128
- package/dist/types/shared/lazy.d.ts +1 -1
- package/dist/types/shared/live-frames.d.ts +2 -8
- package/dist/types/shared/live-series.d.ts +2 -8
- package/dist/types/shared/live-store.d.ts +4 -8
- package/dist/types/shared/log-download.d.ts +6 -0
- package/dist/types/shared/meta.d.ts +6 -0
- package/dist/types/shared/password-policy.d.ts +10 -0
- package/dist/types/shared/patch-diff.d.ts +13 -72
- package/dist/types/shared/port-reading.d.ts +18 -0
- package/dist/types/shared/probe-latency.d.ts +3 -21
- package/dist/types/shared/proxy-form.d.ts +33 -74
- package/dist/types/shared/proxy-validate.d.ts +11 -0
- package/dist/types/shared/query-params.d.ts +8 -0
- package/dist/types/shared/server-attention.d.ts +2 -27
- package/dist/types/shared/server-form.d.ts +15 -54
- package/dist/types/shared/server-key.d.ts +1 -12
- package/dist/types/shared/server-readings.d.ts +7 -32
- package/dist/types/shared/server-url.d.ts +9 -31
- package/dist/types/shared/shape.d.ts +1 -16
- package/dist/types/shared/stream-access.d.ts +2 -8
- package/dist/types/shared/ui-format.d.ts +25 -65
- package/docs/API.md +315 -107
- package/docs/BACKUPS.md +61 -56
- package/docs/CLI.md +255 -49
- package/docs/DDNS.md +35 -49
- package/docs/JOBS.md +129 -0
- package/docs/NOTIFICATIONS.md +58 -90
- package/docs/REVERSE_PROXY.md +116 -188
- package/docs/SECURITY.md +126 -44
- package/docs/SERVERS.md +282 -409
- package/docs/UI_CREATION.md +90 -47
- package/docs/demo/blank-host-restore.sh +31 -7
- package/package.json +15 -6
- package/scripts/prepare.mjs +47 -0
- package/uis/stock/dist/assets/CopyButton-8mliL0xi.js +1 -0
- package/uis/stock/dist/assets/GlobalSettingsView-BINXY77E.js +1 -0
- package/uis/stock/dist/assets/LogViewer-kiSnTwdY.js +1 -0
- package/uis/stock/dist/assets/LogsView-DDXf_ONs.js +1 -0
- package/uis/stock/dist/assets/Modal-lrUuViF2.js +39 -0
- package/uis/stock/dist/assets/ProxyView-uXMaJdSQ.js +1 -0
- package/uis/stock/dist/assets/ServerDetailView-CW0Vb_c0.js +4 -0
- package/uis/stock/dist/assets/SettingsShell-B135xWjJ.js +1 -0
- package/uis/stock/dist/assets/SettingsView-BLtWxVkl.js +2 -0
- package/uis/stock/dist/assets/de-BIoTrHBQ.js +1 -0
- package/uis/stock/dist/assets/es-x4-ih8lH.js +1 -0
- package/uis/stock/dist/assets/fr-DatqBBkO.js +1 -0
- package/uis/stock/dist/assets/index-CnojaKcA.css +2 -0
- package/uis/stock/dist/assets/index-D-CiZReu.js +16 -0
- package/uis/stock/dist/assets/ja-CW1703Gw.js +1 -0
- package/uis/stock/dist/assets/ko-wFbT4XtK.js +1 -0
- package/uis/stock/dist/assets/ru-C1p5C4VN.js +1 -0
- package/uis/stock/dist/assets/useUnsavedGuard-BcsXsfCC.js +9 -0
- package/uis/stock/dist/assets/vi-CDqr0uie.js +1 -0
- package/uis/stock/dist/assets/zh-CN-BJ7iit-X.js +1 -0
- package/uis/stock/dist/index.html +4 -3
- package/uis/stock/dist/ui.json +3 -3
- package/dist/chunks/archive-DP-XQR8X.js.map +0 -1
- package/dist/chunks/atomic-C1PfJpE7.js.map +0 -1
- package/dist/chunks/backup-DeAJ3pbO.js.map +0 -1
- package/dist/chunks/backups-twva7x2n.js +0 -4691
- package/dist/chunks/backups-twva7x2n.js.map +0 -1
- package/dist/chunks/config-text-DifCHhnz.js +0 -50
- package/dist/chunks/config-text-DifCHhnz.js.map +0 -1
- package/dist/chunks/contracts-CMBD1TF9.js.map +0 -1
- package/dist/chunks/daemon-CofN9k6Q.js +0 -247
- package/dist/chunks/daemon-CofN9k6Q.js.map +0 -1
- package/dist/chunks/daemon-log-BVj8cDEo.js +0 -241
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +0 -1
- package/dist/chunks/docker-Cy9Lyvda.js.map +0 -1
- package/dist/chunks/down-C59ne5aM.js.map +0 -1
- package/dist/chunks/init-BZ7hK9Vf.js.map +0 -1
- package/dist/chunks/last-stop-C-BXz_XI.js +0 -53
- package/dist/chunks/last-stop-C-BXz_XI.js.map +0 -1
- package/dist/chunks/layout-DwTtmund.js +0 -24
- package/dist/chunks/layout-DwTtmund.js.map +0 -1
- package/dist/chunks/lazy-Ce5zEAq1.js +0 -66
- package/dist/chunks/lazy-Ce5zEAq1.js.map +0 -1
- package/dist/chunks/log-buffer-Dy9HHDMD.js +0 -414
- package/dist/chunks/log-buffer-Dy9HHDMD.js.map +0 -1
- package/dist/chunks/logger-B5U4GD3j.js.map +0 -1
- package/dist/chunks/logs---TI_bxM.js.map +0 -1
- package/dist/chunks/migrate-Cfoq-Vgh.js +0 -155
- package/dist/chunks/migrate-Cfoq-Vgh.js.map +0 -1
- package/dist/chunks/nanny-COyCJXj9.js +0 -1172
- package/dist/chunks/nanny-COyCJXj9.js.map +0 -1
- package/dist/chunks/nanny-rewguyXg.js.map +0 -1
- package/dist/chunks/nanny-sweep-ClVuNJRo.js.map +0 -1
- package/dist/chunks/nearest-6KgQEDUe.js.map +0 -1
- package/dist/chunks/parse-DhmG26fI.js.map +0 -1
- package/dist/chunks/paths-CGlGDrOU.js.map +0 -1
- package/dist/chunks/port-k5VBw8t9.js.map +0 -1
- package/dist/chunks/restart-BYu_E7x5.js.map +0 -1
- package/dist/chunks/schema-B240VXcV.js.map +0 -1
- package/dist/chunks/secrets-BieELnZh.js +0 -562
- package/dist/chunks/secrets-BieELnZh.js.map +0 -1
- package/dist/chunks/server-By-zktjx.js +0 -169
- package/dist/chunks/server-By-zktjx.js.map +0 -1
- package/dist/chunks/server-ids-DRuNLVCV.js +0 -32
- package/dist/chunks/server-ids-DRuNLVCV.js.map +0 -1
- package/dist/chunks/set-password-D5vZqqSX.js +0 -43
- package/dist/chunks/set-password-D5vZqqSX.js.map +0 -1
- package/dist/chunks/set-token-xJkA1IZp.js +0 -78
- package/dist/chunks/set-token-xJkA1IZp.js.map +0 -1
- package/dist/chunks/settings-xu-XTfWg.js.map +0 -1
- package/dist/chunks/setup-temp-CAN4_bA-.js.map +0 -1
- package/dist/chunks/shape-DnTKzjQ2.js +0 -24
- package/dist/chunks/shape-DnTKzjQ2.js.map +0 -1
- package/dist/chunks/src-BOBh9MBf.js.map +0 -1
- package/dist/chunks/status-B6f2-qhs.js.map +0 -1
- package/dist/chunks/ui-D562aqw5.js.map +0 -1
- package/dist/chunks/ui-dir-CsU3uLNV.js.map +0 -1
- package/dist/chunks/ui-release-DKzVvlLd.js.map +0 -1
- package/dist/chunks/ui-revert-EkBBwRTt.js.map +0 -1
- package/dist/chunks/ui-switch-BnZTdMDd.js.map +0 -1
- package/dist/chunks/ui-update-_xryLYxw.js.map +0 -1
- package/dist/chunks/up-DNZuTi2q.js.map +0 -1
- package/dist/chunks/usage-BrnDARNM.js.map +0 -1
- package/dist/chunks/workspaces-DYcfvKV_.js.map +0 -1
- package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +0 -1
- package/dist/types/cli/set-password.d.ts +0 -14
- package/dist/types/cli/set-token.d.ts +0 -21
- package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +0 -1
- package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +0 -1
- package/uis/stock/dist/assets/LogViewer-DIliXy62.js +0 -1
- package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +0 -1
- package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +0 -39
- package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +0 -1
- package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +0 -2
- package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +0 -1
- package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +0 -2
- package/uis/stock/dist/assets/de-BRITeb0H.js +0 -1
- package/uis/stock/dist/assets/es-B2zIEssV.js +0 -1
- package/uis/stock/dist/assets/fr-s0ZOBEqh.js +0 -1
- package/uis/stock/dist/assets/index-C1MehbKy.css +0 -2
- package/uis/stock/dist/assets/index-CnBN54wF.js +0 -15
- package/uis/stock/dist/assets/ja-CU7MR85V.js +0 -1
- package/uis/stock/dist/assets/ko-tL5Me6d-.js +0 -1
- package/uis/stock/dist/assets/ru-92yrvkNJ.js +0 -1
- package/uis/stock/dist/assets/vi-CzvY16k2.js +0 -1
- package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +0 -1
package/bin/home-hosted.mjs
CHANGED
|
@@ -9,6 +9,29 @@ import path from 'node:path'
|
|
|
9
9
|
import process from 'node:process'
|
|
10
10
|
import { fileURLToPath } from 'node:url'
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Refuse clearly on an old Node, before anything imports the sources.
|
|
14
|
+
*
|
|
15
|
+
* `package.json#engines` says `>=24`, but npm only *warns* by default and `--engine-strict=false` is
|
|
16
|
+
* common; `pnpm dlx` and a global install can both land on whatever `node` is first on `PATH`. Without
|
|
17
|
+
* this the failure is whatever the first modern-API call throws — a `SyntaxError` deep in `dist/`, or
|
|
18
|
+
* `Unknown option --import` from `tsx` — which says nothing about the actual cause.
|
|
19
|
+
*
|
|
20
|
+
* Checked here rather than in `src/` because `src/` is TypeScript: on an old Node it cannot be parsed
|
|
21
|
+
* to run the check. Kept as a literal, matching `package.json#engines`, and
|
|
22
|
+
* `test/scripts/node-floor.test.ts` fails if the two disagree — reading `package.json` at startup would
|
|
23
|
+
* mean an `fs` call before the check that exists to report a missing runtime.
|
|
24
|
+
*/
|
|
25
|
+
const REQUIRED_MAJOR = 24
|
|
26
|
+
const major = Number.parseInt(process.versions.node.split('.')[0] ?? '0', 10)
|
|
27
|
+
if (!(major >= REQUIRED_MAJOR)) {
|
|
28
|
+
process.stderr.write(
|
|
29
|
+
`home-hosted needs Node ${REQUIRED_MAJOR} or newer — this is ${process.versions.node}.\n`
|
|
30
|
+
+ `Install a newer Node (https://nodejs.org) or run it with \`npx node@${REQUIRED_MAJOR} bin/home-hosted.mjs\`.\n`,
|
|
31
|
+
)
|
|
32
|
+
process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
|
|
12
35
|
const root = path.resolve(fileURLToPath(new URL('..', import.meta.url)))
|
|
13
36
|
const built = path.join(root, 'dist', 'cli.js')
|
|
14
37
|
const args = process.argv.slice(2)
|
|
@@ -25,6 +48,24 @@ const child = spawn(process.execPath, commandArgs, {
|
|
|
25
48
|
stdio: 'inherit',
|
|
26
49
|
})
|
|
27
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Forward the signals that mean "stop" to the child, instead of dying and orphaning it.
|
|
53
|
+
*
|
|
54
|
+
* Node does **not** pass a signal to a child: a bare `spawn` child is in no new process group, so the
|
|
55
|
+
* terminal's Ctrl-C reaches both — but `kill <shim>` (what a supervisor, a container runtime or a
|
|
56
|
+
* `systemctl stop` does) hits only this process. Measured: `kill -TERM` on the shim exited 143 while the
|
|
57
|
+
* `up --foreground` child kept running and holding its port. That is the worst shape for a panel — the
|
|
58
|
+
* thing the person meant to stop is still serving, and nothing says so.
|
|
59
|
+
*
|
|
60
|
+
* `SIGKILL` cannot be caught, which is why it is not listed: nothing here could forward it.
|
|
61
|
+
*/
|
|
62
|
+
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
63
|
+
process.on(signal, () => {
|
|
64
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
65
|
+
child.kill(signal)
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
28
69
|
child.once('error', (error) => {
|
|
29
70
|
process.stderr.write(`home-hosted could not start: ${error.message}\n`)
|
|
30
71
|
process.exit(1)
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { D as API_TOKEN_SCOPES, _ as paint, b as promptHidden, f as dim, g as invocation, h as green, p as fail, v as printJson } from "../cli.js";
|
|
2
|
+
import { t as passwordLength } from "./password-policy-Clq6PGE-.js";
|
|
3
|
+
import { c as generateAccountSecret, s as accountIdProblem } from "./secrets-CG5N4lwY.js";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { defineCommand } from "citty";
|
|
6
|
+
//#region src/cli/account.ts
|
|
7
|
+
/**
|
|
8
|
+
* `account` — the panel's credentials, without the API. One account is one credential: `id` + `secret`
|
|
9
|
+
* signs in, and the same pair works as `Authorization: Bearer <id>:<secret>`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* What a new secret's length means for this panel: a refusal when the config exposes it beyond
|
|
13
|
+
* loopback (its next start would refuse), a warning below 8 characters, a note below 12.
|
|
14
|
+
*/
|
|
15
|
+
async function passwordLengthVerdict(password, settings) {
|
|
16
|
+
const length = passwordLength(password);
|
|
17
|
+
if (length >= 12) return {
|
|
18
|
+
refusal: null,
|
|
19
|
+
warning: null
|
|
20
|
+
};
|
|
21
|
+
const { checkExposure, checkProxyExposure } = await import("./exposure-CDJNvOCK.js");
|
|
22
|
+
const exposed = checkExposure(settings.control, true, false, true).blockedReason ?? checkProxyExposure(settings.proxy, settings.control.auth.enabled, true, false, [], true);
|
|
23
|
+
if (exposed !== null) return {
|
|
24
|
+
refusal: `${length} characters is too short for this panel — ${exposed}`,
|
|
25
|
+
warning: null
|
|
26
|
+
};
|
|
27
|
+
if (length < 8) return {
|
|
28
|
+
refusal: null,
|
|
29
|
+
warning: `${length} characters is short and easy to guess — and the panel can't listen beyond loopback until the secret has at least 12`
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
refusal: null,
|
|
33
|
+
warning: `fine on this machine, but the panel can't listen beyond loopback until the secret has at least 12 characters`
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var idArg = {
|
|
37
|
+
type: "positional",
|
|
38
|
+
required: false,
|
|
39
|
+
description: "the account id"
|
|
40
|
+
};
|
|
41
|
+
var scopeArg = {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: `comma-separated, any of ${API_TOKEN_SCOPES.join(", ")} (default: all)`
|
|
44
|
+
};
|
|
45
|
+
var workspaceArg = {
|
|
46
|
+
type: "string",
|
|
47
|
+
alias: "w",
|
|
48
|
+
description: "limit it to these workspaces (comma-separated)"
|
|
49
|
+
};
|
|
50
|
+
var labelArg = {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: "a human label, defaults to the id"
|
|
53
|
+
};
|
|
54
|
+
var jsonArg = {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "print one document on stdout"
|
|
57
|
+
};
|
|
58
|
+
async function openStore() {
|
|
59
|
+
const { SecretsStore } = await import("./secrets-CG5N4lwY.js").then((n) => n.o);
|
|
60
|
+
const { globalSecretsPath } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
61
|
+
return {
|
|
62
|
+
store: new SecretsStore(globalSecretsPath, void 0, "global"),
|
|
63
|
+
path: globalSecretsPath
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function openSettings(write) {
|
|
67
|
+
const { GlobalSettingsStore } = await import("./settings-CtYDs5PX.js").then((n) => n.i);
|
|
68
|
+
const settings = new GlobalSettingsStore();
|
|
69
|
+
settings.load({ write });
|
|
70
|
+
return settings;
|
|
71
|
+
}
|
|
72
|
+
function workspacesOf(raw) {
|
|
73
|
+
return typeof raw === "string" && raw.trim().length > 0 ? raw.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) : void 0;
|
|
74
|
+
}
|
|
75
|
+
function unknownAccount(id) {
|
|
76
|
+
fail(`no account with the id "${id}" — \`${invocation()} account ls\` lists them`);
|
|
77
|
+
}
|
|
78
|
+
/** `HHOSTED_SECRET` when set, held to the same length verdict as `account secret`; else `null`. */
|
|
79
|
+
async function secretFromEnvironment() {
|
|
80
|
+
const secret = process.env.HHOSTED_SECRET;
|
|
81
|
+
if (secret === void 0 || secret.length === 0) return null;
|
|
82
|
+
const verdict = await passwordLengthVerdict(secret, await openSettings(false));
|
|
83
|
+
if (verdict.refusal !== null) fail(verdict.refusal);
|
|
84
|
+
return {
|
|
85
|
+
secret,
|
|
86
|
+
warning: verdict.warning
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var accountLsCommand = defineCommand({
|
|
90
|
+
meta: { name: "ls" },
|
|
91
|
+
args: { json: jsonArg },
|
|
92
|
+
async run({ args }) {
|
|
93
|
+
const { store } = await openStore();
|
|
94
|
+
const accounts = store.listAccounts();
|
|
95
|
+
if (args.json === true) {
|
|
96
|
+
printJson({ accounts });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (accounts.length === 0) {
|
|
100
|
+
process.stdout.write(`no accounts — \`${invocation()} account create admin\`\n`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const account of accounts) {
|
|
104
|
+
const scope = account.scopes.join(",");
|
|
105
|
+
const limit = account.workspaces === void 0 ? "all workspaces" : account.workspaces.join(",");
|
|
106
|
+
const state = account.enabled ? account.isDefault ? "first-run" : "enabled" : "disabled";
|
|
107
|
+
process.stdout.write(`${account.id.padEnd(16)} ${account.label.padEnd(20)} ${scope.padEnd(24)} ${dim(`${state} · ${limit}`)}\n`);
|
|
108
|
+
}
|
|
109
|
+
process.stdout.write(`${dim("a secret is shown once, at creation or when it is set — only a hash is kept")}\n`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
var accountCreateCommand = defineCommand({
|
|
113
|
+
meta: { name: "create" },
|
|
114
|
+
args: {
|
|
115
|
+
id: idArg,
|
|
116
|
+
scope: scopeArg,
|
|
117
|
+
workspace: workspaceArg,
|
|
118
|
+
label: labelArg,
|
|
119
|
+
json: jsonArg
|
|
120
|
+
},
|
|
121
|
+
async run({ args }) {
|
|
122
|
+
const id = String(args.id ?? "");
|
|
123
|
+
if (id.length === 0) fail(`which id? \`${invocation()} account create admin --scope read,lifecycle\``);
|
|
124
|
+
const problem = accountIdProblem(id);
|
|
125
|
+
if (problem !== null) fail(problem);
|
|
126
|
+
const scopes = parseScopes(args.scope);
|
|
127
|
+
const workspaces = workspacesOf(args.workspace);
|
|
128
|
+
const { store } = await openStore();
|
|
129
|
+
let created;
|
|
130
|
+
try {
|
|
131
|
+
created = store.createAccount({
|
|
132
|
+
id,
|
|
133
|
+
...typeof args.label === "string" ? { label: args.label } : {},
|
|
134
|
+
scopes: scopes ?? [...API_TOKEN_SCOPES],
|
|
135
|
+
...workspaces === void 0 ? {} : { workspaces },
|
|
136
|
+
...process.env.HHOSTED_SECRET === void 0 ? {} : { secret: process.env.HHOSTED_SECRET }
|
|
137
|
+
});
|
|
138
|
+
} catch (error) {
|
|
139
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
140
|
+
}
|
|
141
|
+
if (args.json === true) {
|
|
142
|
+
printJson({
|
|
143
|
+
id: created.account.id,
|
|
144
|
+
secret: created.secret
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
process.stdout.write(`${green("created")} ${created.account.id} with ${(scopes ?? [...API_TOKEN_SCOPES]).join(", ")}\n`);
|
|
149
|
+
process.stdout.write(` ${created.secret}\n`);
|
|
150
|
+
process.stdout.write(`${dim(" shown once — only a hash is kept, so copy it now")}\n`);
|
|
151
|
+
process.stdout.write(`${dim(` sign in as ${created.account.id} with it, or send it as \`Authorization: Bearer ${created.account.id}:<secret>\``)}\n`);
|
|
152
|
+
process.stdout.write(`${dim(` otherwise: \`${invocation()} account secret ${created.account.id}\` to set your own, \`${invocation()} account ls\` to list them`)}\n`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
var accountSecretCommand = defineCommand({
|
|
156
|
+
meta: { name: "secret" },
|
|
157
|
+
args: { id: idArg },
|
|
158
|
+
async run({ args }) {
|
|
159
|
+
const id = String(args.id ?? "");
|
|
160
|
+
if (id.length === 0) fail(`which account? \`${invocation()} account secret admin\``);
|
|
161
|
+
const { store, path } = await openStore();
|
|
162
|
+
if (store.account(id) === null) unknownAccount(id);
|
|
163
|
+
const interactive = process.stdin.isTTY === true;
|
|
164
|
+
let secret = process.env.HHOSTED_SECRET;
|
|
165
|
+
if (secret === void 0 && interactive) {
|
|
166
|
+
secret = await promptHidden(`New secret for ${id}: `);
|
|
167
|
+
const again = await promptHidden("Repeat it: ");
|
|
168
|
+
if (secret !== again) fail("the secrets do not match");
|
|
169
|
+
}
|
|
170
|
+
if (secret === void 0 || secret.length === 0) fail("no secret given: run interactively, or set HHOSTED_SECRET for a non-interactive run");
|
|
171
|
+
const verdict = await passwordLengthVerdict(secret, await openSettings(false));
|
|
172
|
+
if (verdict.refusal !== null) fail(verdict.refusal);
|
|
173
|
+
store.setAccountSecret(id, secret);
|
|
174
|
+
process.stdout.write(`${green("secret stored")} for ${id} in ${path} (mode 0600)\n`);
|
|
175
|
+
if (verdict.warning !== null) process.stdout.write(`${paint("33", "note")} ${verdict.warning}\n`);
|
|
176
|
+
process.stdout.write(`${dim("a running panel picks it up immediately; that account's other sessions are signed out")}\n`);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
var accountRevokeCommand = defineCommand({
|
|
180
|
+
meta: { name: "revoke" },
|
|
181
|
+
args: {
|
|
182
|
+
id: idArg,
|
|
183
|
+
json: jsonArg
|
|
184
|
+
},
|
|
185
|
+
async run({ args }) {
|
|
186
|
+
const id = String(args.id ?? "");
|
|
187
|
+
if (id.length === 0) fail(`which account? \`${invocation()} account revoke admin\``);
|
|
188
|
+
const { store } = await openStore();
|
|
189
|
+
if (store.listAccounts().filter((account) => account.id !== id && account.enabled).length === 0) fail("that is the last account that can sign in — create another first, or the panel would have no way in");
|
|
190
|
+
if (!store.revokeAccount(id)) unknownAccount(id);
|
|
191
|
+
if (args.json === true) {
|
|
192
|
+
printJson({
|
|
193
|
+
id,
|
|
194
|
+
revoked: true
|
|
195
|
+
});
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
process.stdout.write(`${green("revoked")} ${id} — its sessions end immediately\n`);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
var accountEditCommand = defineCommand({
|
|
202
|
+
meta: { name: "edit" },
|
|
203
|
+
args: {
|
|
204
|
+
id: idArg,
|
|
205
|
+
scope: scopeArg,
|
|
206
|
+
workspace: workspaceArg,
|
|
207
|
+
label: labelArg,
|
|
208
|
+
enable: {
|
|
209
|
+
type: "boolean",
|
|
210
|
+
description: "re-enable a disabled account"
|
|
211
|
+
},
|
|
212
|
+
disable: {
|
|
213
|
+
type: "boolean",
|
|
214
|
+
description: "refuse this account's credential without deleting it"
|
|
215
|
+
},
|
|
216
|
+
json: jsonArg
|
|
217
|
+
},
|
|
218
|
+
async run({ args }) {
|
|
219
|
+
const id = String(args.id ?? "");
|
|
220
|
+
if (id.length === 0) fail(`which account? \`${invocation()} account edit monitor --scope read\``);
|
|
221
|
+
if (args.enable === true && args.disable === true) fail("--enable and --disable contradict each other");
|
|
222
|
+
const scopes = parseScopes(args.scope);
|
|
223
|
+
const enabled = args.enable === true ? true : args.disable === true ? false : void 0;
|
|
224
|
+
const workspaceLimit = typeof args.workspace === "string" ? workspacesOf(args.workspace) ?? null : void 0;
|
|
225
|
+
const label = typeof args.label === "string" ? args.label : void 0;
|
|
226
|
+
if (enabled === void 0 && workspaceLimit === void 0 && scopes === null && label === void 0) fail("nothing to change: pass --scope, -w/--workspace, --label, --enable or --disable");
|
|
227
|
+
const { store } = await openStore();
|
|
228
|
+
if (store.account(id) === null) unknownAccount(id);
|
|
229
|
+
if (enabled === false && !store.listAccounts().some((account) => account.id !== id && account.enabled)) fail("that is the last account that can sign in — create another first, or the panel would have no way in");
|
|
230
|
+
try {
|
|
231
|
+
store.updateAccount(id, {
|
|
232
|
+
...enabled === void 0 ? {} : { enabled },
|
|
233
|
+
...workspaceLimit === void 0 ? {} : { workspaces: workspaceLimit },
|
|
234
|
+
...scopes === null ? {} : { scopes },
|
|
235
|
+
...label === void 0 ? {} : { label }
|
|
236
|
+
});
|
|
237
|
+
} catch (error) {
|
|
238
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
239
|
+
}
|
|
240
|
+
if (args.json === true) {
|
|
241
|
+
printJson({ account: store.listAccounts().find((account) => account.id === id) });
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
process.stdout.write(`${green("updated")} ${id}${enabled === false ? " — its credential is refused until --enable" : ""}\n`);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
/**
|
|
248
|
+
* The account `reset` acts on with no id: one that can undo whatever locked the person out — an
|
|
249
|
+
* `admin` with no workspace limit first, an enabled one before a disabled one. A read-only monitor
|
|
250
|
+
* would sign in to a panel where it can change nothing.
|
|
251
|
+
*/
|
|
252
|
+
function recoveryTarget(store) {
|
|
253
|
+
const admins = store.listAccounts().filter((account) => account.scopes.includes("admin"));
|
|
254
|
+
const rank = (account) => (account.enabled ? 0 : 2) + (account.workspaces === void 0 ? 0 : 1);
|
|
255
|
+
return [...admins].sort((left, right) => rank(left) - rank(right))[0]?.id ?? "default";
|
|
256
|
+
}
|
|
257
|
+
var accountResetCommand = defineCommand({
|
|
258
|
+
meta: { name: "reset" },
|
|
259
|
+
args: {
|
|
260
|
+
id: idArg,
|
|
261
|
+
json: jsonArg
|
|
262
|
+
},
|
|
263
|
+
async run({ args }) {
|
|
264
|
+
const { store } = await openStore();
|
|
265
|
+
const named = String(args.id ?? "");
|
|
266
|
+
const target = named.length > 0 ? named : recoveryTarget(store);
|
|
267
|
+
const problem = accountIdProblem(target);
|
|
268
|
+
if (problem !== null) fail(problem);
|
|
269
|
+
const chosen = await secretFromEnvironment();
|
|
270
|
+
const secret = chosen?.secret ?? generateAccountSecret();
|
|
271
|
+
const existing = store.account(target);
|
|
272
|
+
const reenabled = existing !== null && existing.enabled !== true;
|
|
273
|
+
if (existing === null) store.createAccount({
|
|
274
|
+
id: target,
|
|
275
|
+
label: target,
|
|
276
|
+
scopes: [...API_TOKEN_SCOPES],
|
|
277
|
+
secret
|
|
278
|
+
});
|
|
279
|
+
else {
|
|
280
|
+
store.setAccountSecret(target, secret);
|
|
281
|
+
if (reenabled) store.updateAccount(target, { enabled: true });
|
|
282
|
+
}
|
|
283
|
+
const authOff = !(await openSettings(false)).control.auth.enabled;
|
|
284
|
+
if (args.json === true) {
|
|
285
|
+
printJson({
|
|
286
|
+
id: target,
|
|
287
|
+
...chosen === null ? { secret } : {},
|
|
288
|
+
...reenabled ? { reenabled: true } : {}
|
|
289
|
+
});
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
process.stdout.write(`${green("reset")} ${target}${reenabled ? " (and enabled it again)" : ""} — sign in with:\n`);
|
|
293
|
+
process.stdout.write(` id ${target}\n`);
|
|
294
|
+
process.stdout.write(` secret ${chosen === null ? secret : dim("the one in HHOSTED_SECRET")}\n`);
|
|
295
|
+
if (chosen !== null && chosen.warning !== null) process.stdout.write(`${paint("33", "note")} ${chosen.warning}\n`);
|
|
296
|
+
if (chosen === null) process.stdout.write(`${dim(" shown once; set your own in Global settings → Accounts after signing in")}\n`);
|
|
297
|
+
if (authOff) process.stdout.write(`${dim(` authentication is off — \`${invocation()} account enable-auth\` turns it back on`)}\n`);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
var accountDisableAuthCommand = defineCommand({
|
|
301
|
+
meta: { name: "disable-auth" },
|
|
302
|
+
args: {},
|
|
303
|
+
async run() {
|
|
304
|
+
(await openSettings(true)).updateControl({ auth: { enabled: false } });
|
|
305
|
+
process.stdout.write(`${green("authentication off")} — the accounts are kept; \`${invocation()} account enable-auth\` turns it back on\n`);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
var accountEnableAuthCommand = defineCommand({
|
|
309
|
+
meta: { name: "enable-auth" },
|
|
310
|
+
args: {},
|
|
311
|
+
async run() {
|
|
312
|
+
const { store } = await openStore();
|
|
313
|
+
if (!store.listAccounts().some((account) => account.enabled)) fail(`no enabled account could sign in afterwards — \`${invocation()} account reset\` first`);
|
|
314
|
+
(await openSettings(true)).updateControl({ auth: { enabled: true } });
|
|
315
|
+
process.stdout.write(`${green("authentication on")} — sign in with an account (\`${invocation()} account ls\` lists them)\n`);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
var ACCOUNT_SUBCOMMANDS = [
|
|
319
|
+
"create",
|
|
320
|
+
"ls",
|
|
321
|
+
"edit",
|
|
322
|
+
"secret",
|
|
323
|
+
"revoke",
|
|
324
|
+
"reset",
|
|
325
|
+
"disable-auth",
|
|
326
|
+
"enable-auth"
|
|
327
|
+
];
|
|
328
|
+
var accountCommand = defineCommand({
|
|
329
|
+
meta: { name: "account" },
|
|
330
|
+
args: { command: {
|
|
331
|
+
type: "positional",
|
|
332
|
+
required: false
|
|
333
|
+
} },
|
|
334
|
+
subCommands: {
|
|
335
|
+
"create": accountCreateCommand,
|
|
336
|
+
"ls": accountLsCommand,
|
|
337
|
+
"edit": accountEditCommand,
|
|
338
|
+
"secret": accountSecretCommand,
|
|
339
|
+
"revoke": accountRevokeCommand,
|
|
340
|
+
"reset": accountResetCommand,
|
|
341
|
+
"disable-auth": accountDisableAuthCommand,
|
|
342
|
+
"enable-auth": accountEnableAuthCommand
|
|
343
|
+
},
|
|
344
|
+
run({ args }) {
|
|
345
|
+
if (!ACCOUNT_SUBCOMMANDS.includes(String(args.command ?? ""))) fail(`use \`${invocation()} account ${ACCOUNT_SUBCOMMANDS.join("|")}\``);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
/** The scopes a `--scope` flag names, or `null` for "every scope". */
|
|
349
|
+
function parseScopes(raw) {
|
|
350
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return null;
|
|
351
|
+
const wanted = raw.split(",").map((scope) => scope.trim()).filter((scope) => scope.length > 0);
|
|
352
|
+
const unknown = wanted.filter((scope) => !API_TOKEN_SCOPES.includes(scope));
|
|
353
|
+
if (unknown.length > 0) fail(`unknown scope${unknown.length === 1 ? "" : "s"}: ${unknown.join(", ")} — expected any of ${API_TOKEN_SCOPES.join(", ")}`);
|
|
354
|
+
return [...new Set(wanted)];
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
export { accountCommand };
|
|
358
|
+
|
|
359
|
+
//# sourceMappingURL=account-DiLrSyww.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-DiLrSyww.js","names":[],"sources":["../../src/cli/account.ts"],"sourcesContent":["import type { ControlConfig, ProxyConfig } from '#src/shared/contracts'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { dim, fail, green, invocation, paint, printJson, promptHidden } from '#src/cli/io'\nimport { accountIdProblem, API_TOKEN_SCOPES, generateAccountSecret } from '#src/config/secrets'\nimport { EXPOSED_PASSWORD_MIN_LENGTH, passwordLength, WEAK_PASSWORD_LENGTH } from '#src/shared/password-policy'\n\n/**\n * `account` — the panel's credentials, without the API. One account is one credential: `id` + `secret`\n * signs in, and the same pair works as `Authorization: Bearer <id>:<secret>`.\n */\n\n/**\n * What a new secret's length means for this panel: a refusal when the config exposes it beyond\n * loopback (its next start would refuse), a warning below 8 characters, a note below 12.\n */\nexport async function passwordLengthVerdict(password: string, settings: { control: ControlConfig, proxy: ProxyConfig }): Promise<{ refusal: string | null, warning: string | null }> {\n const length = passwordLength(password)\n if (length >= EXPOSED_PASSWORD_MIN_LENGTH)\n return { refusal: null, warning: null }\n const { checkExposure, checkProxyExposure } = await import('#src/services/exposure')\n // Only `target: \"panel\"` routes: no ports are passed, so an `external` upstream is not resolved here.\n const exposed = checkExposure(settings.control, true, false, true).blockedReason\n ?? checkProxyExposure(settings.proxy, settings.control.auth.enabled, true, false, [], true)\n if (exposed !== null)\n return { refusal: `${length} characters is too short for this panel — ${exposed}`, warning: null }\n if (length < WEAK_PASSWORD_LENGTH)\n return { refusal: null, warning: `${length} characters is short and easy to guess — and the panel can't listen beyond loopback until the secret has at least ${EXPOSED_PASSWORD_MIN_LENGTH}` }\n return { refusal: null, warning: `fine on this machine, but the panel can't listen beyond loopback until the secret has at least ${EXPOSED_PASSWORD_MIN_LENGTH} characters` }\n}\n\nconst idArg = { type: 'positional', required: false, description: 'the account id' } as const\nconst scopeArg = { type: 'string', description: `comma-separated, any of ${API_TOKEN_SCOPES.join(', ')} (default: all)` } as const\nconst workspaceArg = { type: 'string', alias: 'w', description: 'limit it to these workspaces (comma-separated)' } as const\nconst labelArg = { type: 'string', description: 'a human label, defaults to the id' } as const\nconst jsonArg = { type: 'boolean', description: 'print one document on stdout' } as const\n\ntype SecretsStore = import('#src/config/secrets').SecretsStore\n\nasync function openStore(): Promise<{ store: SecretsStore, path: string }> {\n const { SecretsStore } = await import('#src/config/secrets')\n const { globalSecretsPath } = await import('#src/helpers/paths')\n return { store: new SecretsStore(globalSecretsPath, undefined, 'global'), path: globalSecretsPath }\n}\n\nasync function openSettings(write: boolean): Promise<import('#src/config/settings').GlobalSettingsStore> {\n const { GlobalSettingsStore } = await import('#src/config/settings')\n const settings = new GlobalSettingsStore()\n settings.load({ write })\n return settings\n}\n\nfunction workspacesOf(raw: unknown): string[] | undefined {\n return typeof raw === 'string' && raw.trim().length > 0\n ? raw.split(',').map(entry => entry.trim()).filter(entry => entry.length > 0)\n : undefined\n}\n\nfunction unknownAccount(id: string): never {\n fail(`no account with the id \"${id}\" — \\`${invocation()} account ls\\` lists them`)\n}\n\n/** `HHOSTED_SECRET` when set, held to the same length verdict as `account secret`; else `null`. */\nasync function secretFromEnvironment(): Promise<{ secret: string, warning: string | null } | null> {\n const secret = process.env.HHOSTED_SECRET\n if (secret === undefined || secret.length === 0)\n return null\n const verdict = await passwordLengthVerdict(secret, await openSettings(false))\n if (verdict.refusal !== null)\n fail(verdict.refusal)\n return { secret, warning: verdict.warning }\n}\n\nconst accountLsCommand = defineCommand({\n meta: { name: 'ls' },\n args: { json: jsonArg },\n async run({ args }) {\n const { store } = await openStore()\n const accounts = store.listAccounts()\n if (args.json === true) {\n printJson({ accounts })\n return\n }\n if (accounts.length === 0) {\n process.stdout.write(`no accounts — \\`${invocation()} account create admin\\`\\n`)\n return\n }\n for (const account of accounts) {\n const scope = account.scopes.join(',')\n const limit = account.workspaces === undefined ? 'all workspaces' : account.workspaces.join(',')\n const state = account.enabled ? (account.isDefault ? 'first-run' : 'enabled') : 'disabled'\n process.stdout.write(`${account.id.padEnd(16)} ${account.label.padEnd(20)} ${scope.padEnd(24)} ${dim(`${state} · ${limit}`)}\\n`)\n }\n process.stdout.write(`${dim('a secret is shown once, at creation or when it is set — only a hash is kept')}\\n`)\n },\n})\n\nconst accountCreateCommand = defineCommand({\n meta: { name: 'create' },\n args: { id: idArg, scope: scopeArg, workspace: workspaceArg, label: labelArg, json: jsonArg },\n async run({ args }) {\n const id = String(args.id ?? '')\n if (id.length === 0)\n fail(`which id? \\`${invocation()} account create admin --scope read,lifecycle\\``)\n const problem = accountIdProblem(id)\n if (problem !== null)\n fail(problem)\n const scopes = parseScopes(args.scope)\n const workspaces = workspacesOf(args.workspace)\n const { store } = await openStore()\n let created: { account: { id: string }, secret: string }\n try {\n created = store.createAccount({\n id,\n ...(typeof args.label === 'string' ? { label: args.label } : {}),\n scopes: (scopes ?? [...API_TOKEN_SCOPES]) as never,\n ...(workspaces === undefined ? {} : { workspaces }),\n ...(process.env.HHOSTED_SECRET === undefined ? {} : { secret: process.env.HHOSTED_SECRET }),\n })\n }\n catch (error) {\n fail(error instanceof Error ? error.message : String(error))\n }\n if (args.json === true) {\n printJson({ id: created.account.id, secret: created.secret })\n return\n }\n process.stdout.write(`${green('created')} ${created.account.id} with ${(scopes ?? [...API_TOKEN_SCOPES]).join(', ')}\\n`)\n process.stdout.write(` ${created.secret}\\n`)\n process.stdout.write(`${dim(' shown once — only a hash is kept, so copy it now')}\\n`)\n process.stdout.write(`${dim(` sign in as ${created.account.id} with it, or send it as \\`Authorization: Bearer ${created.account.id}:<secret>\\``)}\\n`)\n // The hint carries this home's `--home`.\n process.stdout.write(`${dim(` otherwise: \\`${invocation()} account secret ${created.account.id}\\` to set your own, \\`${invocation()} account ls\\` to list them`)}\\n`)\n },\n})\n\nconst accountSecretCommand = defineCommand({\n meta: { name: 'secret' },\n args: { id: idArg },\n async run({ args }) {\n const id = String(args.id ?? '')\n if (id.length === 0)\n fail(`which account? \\`${invocation()} account secret admin\\``)\n const { store, path } = await openStore()\n if (store.account(id) === null)\n unknownAccount(id)\n const interactive = process.stdin.isTTY === true\n let secret = process.env.HHOSTED_SECRET\n if (secret === undefined && interactive) {\n secret = await promptHidden(`New secret for ${id}: `)\n const again = await promptHidden('Repeat it: ')\n if (secret !== again)\n fail('the secrets do not match')\n }\n if (secret === undefined || secret.length === 0)\n fail('no secret given: run interactively, or set HHOSTED_SECRET for a non-interactive run')\n\n const verdict = await passwordLengthVerdict(secret, await openSettings(false))\n if (verdict.refusal !== null)\n fail(verdict.refusal)\n\n store.setAccountSecret(id, secret)\n process.stdout.write(`${green('secret stored')} for ${id} in ${path} (mode 0600)\\n`)\n if (verdict.warning !== null)\n process.stdout.write(`${paint('33', 'note')} ${verdict.warning}\\n`)\n process.stdout.write(`${dim('a running panel picks it up immediately; that account\\'s other sessions are signed out')}\\n`)\n },\n})\n\nconst accountRevokeCommand = defineCommand({\n meta: { name: 'revoke' },\n args: { id: idArg, json: jsonArg },\n async run({ args }) {\n const id = String(args.id ?? '')\n if (id.length === 0)\n fail(`which account? \\`${invocation()} account revoke admin\\``)\n const { store } = await openStore()\n const remaining = store.listAccounts().filter(account => account.id !== id && account.enabled)\n if (remaining.length === 0)\n fail('that is the last account that can sign in — create another first, or the panel would have no way in')\n if (!store.revokeAccount(id))\n unknownAccount(id)\n if (args.json === true) {\n printJson({ id, revoked: true })\n return\n }\n process.stdout.write(`${green('revoked')} ${id} — its sessions end immediately\\n`)\n },\n})\n\nconst accountEditCommand = defineCommand({\n meta: { name: 'edit' },\n args: {\n id: idArg,\n scope: scopeArg,\n workspace: workspaceArg,\n label: labelArg,\n enable: { type: 'boolean', description: 're-enable a disabled account' },\n disable: { type: 'boolean', description: 'refuse this account\\'s credential without deleting it' },\n json: jsonArg,\n },\n async run({ args }) {\n const id = String(args.id ?? '')\n if (id.length === 0)\n fail(`which account? \\`${invocation()} account edit monitor --scope read\\``)\n if (args.enable === true && args.disable === true)\n fail('--enable and --disable contradict each other')\n const scopes = parseScopes(args.scope)\n const enabled = args.enable === true ? true : args.disable === true ? false : undefined\n // `-w \"\"` clears the limit; an absent flag keeps it.\n const workspaceLimit = typeof args.workspace === 'string' ? (workspacesOf(args.workspace) ?? null) : undefined\n const label = typeof args.label === 'string' ? args.label : undefined\n if (enabled === undefined && workspaceLimit === undefined && scopes === null && label === undefined)\n fail('nothing to change: pass --scope, -w/--workspace, --label, --enable or --disable')\n const { store } = await openStore()\n if (store.account(id) === null)\n unknownAccount(id)\n if (enabled === false && !store.listAccounts().some(account => account.id !== id && account.enabled))\n fail('that is the last account that can sign in — create another first, or the panel would have no way in')\n try {\n store.updateAccount(id, {\n ...(enabled === undefined ? {} : { enabled }),\n ...(workspaceLimit === undefined ? {} : { workspaces: workspaceLimit }),\n ...(scopes === null ? {} : { scopes: scopes as never }),\n ...(label === undefined ? {} : { label }),\n })\n }\n catch (error) {\n fail(error instanceof Error ? error.message : String(error))\n }\n if (args.json === true) {\n printJson({ account: store.listAccounts().find(account => account.id === id) })\n return\n }\n process.stdout.write(`${green('updated')} ${id}${enabled === false ? ' — its credential is refused until --enable' : ''}\\n`)\n },\n})\n\n/**\n * The account `reset` acts on with no id: one that can undo whatever locked the person out — an\n * `admin` with no workspace limit first, an enabled one before a disabled one. A read-only monitor\n * would sign in to a panel where it can change nothing.\n */\nfunction recoveryTarget(store: SecretsStore): string {\n const admins = store.listAccounts().filter(account => account.scopes.includes('admin'))\n const rank = (account: (typeof admins)[number]): number => (account.enabled ? 0 : 2) + (account.workspaces === undefined ? 0 : 1)\n return [...admins].sort((left, right) => rank(left) - rank(right))[0]?.id ?? 'default'\n}\n\nconst accountResetCommand = defineCommand({\n meta: { name: 'reset' },\n args: { id: idArg, json: jsonArg },\n async run({ args }) {\n const { store } = await openStore()\n const named = String(args.id ?? '')\n const target = named.length > 0 ? named : recoveryTarget(store)\n const problem = accountIdProblem(target)\n if (problem !== null)\n fail(problem)\n const chosen = await secretFromEnvironment()\n const secret = chosen?.secret ?? generateAccountSecret()\n const existing = store.account(target)\n const reenabled = existing !== null && existing.enabled !== true\n if (existing === null) {\n store.createAccount({ id: target, label: target, scopes: [...API_TOKEN_SCOPES], secret })\n }\n else {\n store.setAccountSecret(target, secret)\n // Resetting a disabled account is a person locked out who means to sign in with it.\n if (reenabled)\n store.updateAccount(target, { enabled: true })\n }\n const authOff = !(await openSettings(false)).control.auth.enabled\n if (args.json === true) {\n // A secret the person chose is theirs already; only a generated one is printed.\n printJson({ id: target, ...(chosen === null ? { secret } : {}), ...(reenabled ? { reenabled: true } : {}) })\n return\n }\n process.stdout.write(`${green('reset')} ${target}${reenabled ? ' (and enabled it again)' : ''} — sign in with:\\n`)\n process.stdout.write(` id ${target}\\n`)\n process.stdout.write(` secret ${chosen === null ? secret : dim('the one in HHOSTED_SECRET')}\\n`)\n if (chosen !== null && chosen.warning !== null)\n process.stdout.write(`${paint('33', 'note')} ${chosen.warning}\\n`)\n if (chosen === null)\n process.stdout.write(`${dim(' shown once; set your own in Global settings → Accounts after signing in')}\\n`)\n if (authOff)\n process.stdout.write(`${dim(` authentication is off — \\`${invocation()} account enable-auth\\` turns it back on`)}\\n`)\n },\n})\n\nconst accountDisableAuthCommand = defineCommand({\n meta: { name: 'disable-auth' },\n args: {},\n async run() {\n const settings = await openSettings(true)\n settings.updateControl({ auth: { enabled: false } })\n process.stdout.write(`${green('authentication off')} — the accounts are kept; \\`${invocation()} account enable-auth\\` turns it back on\\n`)\n },\n})\n\nconst accountEnableAuthCommand = defineCommand({\n meta: { name: 'enable-auth' },\n args: {},\n async run() {\n const { store } = await openStore()\n if (!store.listAccounts().some(account => account.enabled))\n fail(`no enabled account could sign in afterwards — \\`${invocation()} account reset\\` first`)\n const settings = await openSettings(true)\n settings.updateControl({ auth: { enabled: true } })\n process.stdout.write(`${green('authentication on')} — sign in with an account (\\`${invocation()} account ls\\` lists them)\\n`)\n },\n})\n\nexport const ACCOUNT_SUBCOMMANDS = ['create', 'ls', 'edit', 'secret', 'revoke', 'reset', 'disable-auth', 'enable-auth'] as const\n\nexport const accountCommand = defineCommand({\n meta: { name: 'account' },\n // Declared so `account` alone answers with this command's usage instead of citty's `No command specified.`\n args: { command: { type: 'positional', required: false } },\n subCommands: {\n 'create': accountCreateCommand,\n 'ls': accountLsCommand,\n 'edit': accountEditCommand,\n 'secret': accountSecretCommand,\n 'revoke': accountRevokeCommand,\n 'reset': accountResetCommand,\n 'disable-auth': accountDisableAuthCommand,\n 'enable-auth': accountEnableAuthCommand,\n },\n run({ args }) {\n if (!(ACCOUNT_SUBCOMMANDS as readonly string[]).includes(String(args.command ?? '')))\n fail(`use \\`${invocation()} account ${ACCOUNT_SUBCOMMANDS.join('|')}\\``)\n },\n})\n\n/** The scopes a `--scope` flag names, or `null` for \"every scope\". */\nfunction parseScopes(raw: unknown): string[] | null {\n if (typeof raw !== 'string' || raw.trim().length === 0)\n return null\n const wanted = raw.split(',').map(scope => scope.trim()).filter(scope => scope.length > 0)\n const unknown = wanted.filter(scope => !(API_TOKEN_SCOPES as readonly string[]).includes(scope))\n if (unknown.length > 0)\n fail(`unknown scope${unknown.length === 1 ? '' : 's'}: ${unknown.join(', ')} — expected any of ${API_TOKEN_SCOPES.join(', ')}`)\n return [...new Set(wanted)]\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,eAAsB,sBAAsB,UAAkB,UAAuH;CACnL,MAAM,SAAS,eAAe,QAAQ;CACtC,IAAI,UAAA,IACF,OAAO;EAAE,SAAS;EAAM,SAAS;CAAK;CACxC,MAAM,EAAE,eAAe,uBAAuB,MAAM,OAAO;CAE3D,MAAM,UAAU,cAAc,SAAS,SAAS,MAAM,OAAO,IAAI,CAAC,CAAC,iBAC9D,mBAAmB,SAAS,OAAO,SAAS,QAAQ,KAAK,SAAS,MAAM,OAAO,CAAC,GAAG,IAAI;CAC5F,IAAI,YAAY,MACd,OAAO;EAAE,SAAS,GAAG,OAAO,4CAA4C;EAAW,SAAS;CAAK;CACnG,IAAI,SAAA,GACF,OAAO;EAAE,SAAS;EAAM,SAAS,GAAG,OAAO;CAAkJ;CAC/L,OAAO;EAAE,SAAS;EAAM,SAAS;CAA2I;AAC9K;AAEA,IAAM,QAAQ;CAAE,MAAM;CAAc,UAAU;CAAO,aAAa;AAAiB;AACnF,IAAM,WAAW;CAAE,MAAM;CAAU,aAAa,2BAA2B,iBAAiB,KAAK,IAAI,EAAE;AAAiB;AACxH,IAAM,eAAe;CAAE,MAAM;CAAU,OAAO;CAAK,aAAa;AAAiD;AACjH,IAAM,WAAW;CAAE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UAAS,CAAE,iBAAuC,SAAS,KAAK,CAAC;CAC/F,IAAI,QAAQ,SAAS,GACnB,KAAK,gBAAgB,QAAQ,WAAW,IAAI,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI,EAAE,qBAAqB,iBAAiB,KAAK,IAAI,GAAG;CAChI,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC;AAC5B"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { E as errorMessage, _ as paint, f as dim, g as invocation, h as green, p as fail } from "../cli.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { defineCommand, parseArgs } from "citty";
|
|
4
|
+
//#region src/cli/add.ts
|
|
5
|
+
/**
|
|
6
|
+
* `add <id> [--port N] [--cwd DIR] [--workspace W] [--persistent] [--autostart] [--secret-env NAME]… -- <command> [args…]`
|
|
7
|
+
*
|
|
8
|
+
* Through the running panel when it is up, otherwise into `servers.config.json` with the same
|
|
9
|
+
* validation. The entry is not started.
|
|
10
|
+
*/
|
|
11
|
+
var addArgs = {
|
|
12
|
+
id: {
|
|
13
|
+
type: "positional",
|
|
14
|
+
required: false,
|
|
15
|
+
description: "the new server id (a-z, 0-9, - and _)"
|
|
16
|
+
},
|
|
17
|
+
port: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "the port it listens on"
|
|
20
|
+
},
|
|
21
|
+
cwd: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "its working directory"
|
|
24
|
+
},
|
|
25
|
+
workspace: {
|
|
26
|
+
type: "string",
|
|
27
|
+
alias: "w",
|
|
28
|
+
description: "the workspace to add it to (default: the default workspace)"
|
|
29
|
+
},
|
|
30
|
+
persistent: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
description: "keep it running when the panel stops"
|
|
33
|
+
},
|
|
34
|
+
autostart: {
|
|
35
|
+
type: "boolean",
|
|
36
|
+
description: "start it whenever the panel starts"
|
|
37
|
+
},
|
|
38
|
+
secretEnv: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "declare a secret environment variable (repeatable, or comma-separated)"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var ID_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
44
|
+
var ID_RULE = "lowercase letters, digits, - and _, starting with a letter or digit";
|
|
45
|
+
/** The create body for these flags, or the sentence that refuses them; the caller checks the schema. */
|
|
46
|
+
function buildServerEntry(input) {
|
|
47
|
+
const id = input.id?.trim() ?? "";
|
|
48
|
+
if (id.length === 0) return { error: "add needs a server id — `add <id> -- <command> [args…]`" };
|
|
49
|
+
if (!ID_PATTERN.test(id)) return { error: `invalid server id "${id}": use ${ID_RULE}` };
|
|
50
|
+
const [command, ...args] = input.command;
|
|
51
|
+
if (command === void 0 || command.trim().length === 0) return { error: `add needs the command after \`--\` — \`add ${id} -- node server.js\`` };
|
|
52
|
+
const warnings = [];
|
|
53
|
+
if (/\s/.test(command.trim())) {
|
|
54
|
+
const [program, ...rest] = command.trim().split(/\s+/);
|
|
55
|
+
warnings.push(`the command "${command}" contains a space, so it is run as one program of that name, not as a shell line — to run ${program} with arguments, leave them unquoted: \`add ${id} -- ${[
|
|
56
|
+
program,
|
|
57
|
+
...rest,
|
|
58
|
+
...args
|
|
59
|
+
].join(" ")}\``);
|
|
60
|
+
}
|
|
61
|
+
const secretEnv = [...new Set((input.secretEnv ?? []).flatMap((value) => value.split(",")).map((name) => name.trim()).filter((name) => name.length > 0))];
|
|
62
|
+
const badName = secretEnv.find((name) => !/^[A-Z_]\w*$/i.test(name));
|
|
63
|
+
if (badName !== void 0) return { error: `invalid --secret-env name "${badName}": a letter or underscore, then letters, digits or underscores` };
|
|
64
|
+
let port;
|
|
65
|
+
if (input.port !== void 0) {
|
|
66
|
+
const raw = input.port.trim();
|
|
67
|
+
port = /^\d+$/.test(raw) ? Number.parseInt(raw, 10) : NaN;
|
|
68
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65535) return { error: `invalid port: ${input.port}` };
|
|
69
|
+
}
|
|
70
|
+
if (input.cwd !== void 0 && input.cwd.trim().length === 0) return { error: "--cwd needs a directory" };
|
|
71
|
+
return {
|
|
72
|
+
entry: {
|
|
73
|
+
id,
|
|
74
|
+
command,
|
|
75
|
+
args,
|
|
76
|
+
...port === void 0 ? {} : { port },
|
|
77
|
+
...input.cwd === void 0 ? {} : { cwd: input.cwd },
|
|
78
|
+
...input.persistent === true ? { persistent: true } : {},
|
|
79
|
+
...input.autostart === true ? { autostart: true } : {},
|
|
80
|
+
...secretEnv.length === 0 ? {} : { secretEnv }
|
|
81
|
+
},
|
|
82
|
+
warnings
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Every value given to `--secret-env`, in either spelling, from the words before `--`. */
|
|
86
|
+
function secretEnvFlags(declaration) {
|
|
87
|
+
const values = [];
|
|
88
|
+
for (let index = 0; index < declaration.length; index++) {
|
|
89
|
+
const word = declaration[index];
|
|
90
|
+
if (word === "--secret-env" || word === "--secretEnv") {
|
|
91
|
+
const value = declaration[index + 1];
|
|
92
|
+
if (value !== void 0) values.push(value);
|
|
93
|
+
index += 1;
|
|
94
|
+
} else if (word.startsWith("--secret-env=") || word.startsWith("--secretEnv=")) values.push(word.slice(word.indexOf("=") + 1));
|
|
95
|
+
}
|
|
96
|
+
return values;
|
|
97
|
+
}
|
|
98
|
+
function commandAfterDashes(rawArgs) {
|
|
99
|
+
const index = rawArgs.indexOf("--");
|
|
100
|
+
return index === -1 ? [] : rawArgs.slice(index + 1);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The words before the first `--`. citty's positional filler reads the whole argv, so without this
|
|
104
|
+
* `add -- node server.js` would bind `id = "node"`.
|
|
105
|
+
*/
|
|
106
|
+
function declarationAfterDashes(rawArgs) {
|
|
107
|
+
const index = rawArgs.indexOf("--");
|
|
108
|
+
return index === -1 ? [...rawArgs] : rawArgs.slice(0, index);
|
|
109
|
+
}
|
|
110
|
+
async function runAdd(input, workspace) {
|
|
111
|
+
const built = buildServerEntry(input);
|
|
112
|
+
if ("error" in built) fail(built.error);
|
|
113
|
+
const { entry, warnings } = built;
|
|
114
|
+
const id = String(entry.id);
|
|
115
|
+
for (const warning of warnings) process.stderr.write(`${paint("33", "note")} ${warning}\n`);
|
|
116
|
+
const { serverCreateSchema } = await import("./contracts-CxZ7u1L3.js").then((n) => n.l);
|
|
117
|
+
const { type } = await import("arktype");
|
|
118
|
+
const checked = serverCreateSchema(entry);
|
|
119
|
+
if (checked instanceof type.errors) fail(`invalid server: ${checked.summary}`);
|
|
120
|
+
const { readRuntime, requestControl, runtimeIsAlive } = await import("./daemon-BAAYUYQC.js");
|
|
121
|
+
const runtime = readRuntime();
|
|
122
|
+
const live = runtime !== null && await runtimeIsAlive(runtime);
|
|
123
|
+
const where = workspace === void 0 || workspace.length === 0 ? "" : `?workspace=${encodeURIComponent(workspace)}`;
|
|
124
|
+
let workspaceId = workspace;
|
|
125
|
+
if (live) {
|
|
126
|
+
const answer = await requestControl(runtime, `/_hh/servers${where}`, 15e3, "POST", entry);
|
|
127
|
+
if (answer === null) fail(`the control panel is not answering on ${runtime.probeUrl}`);
|
|
128
|
+
if (answer.status === 404 && answer.body?.code !== "UNKNOWN_WORKSPACE") fail(`the panel on ${runtime.url} is home-hosted ${runtime.version}, which cannot add a server from the CLI — restart it on this release, or use the panel`);
|
|
129
|
+
if (answer.status !== 201) fail(answer.body?.message ?? `the panel answered ${answer.status}`);
|
|
130
|
+
} else workspaceId = await addOffline(entry, workspace);
|
|
131
|
+
const label = workspaceId === void 0 || workspaceId.length === 0 || workspaceId === "default" ? id : `${workspaceId}/${id}`;
|
|
132
|
+
const flag = workspace === void 0 || workspace.length === 0 ? "" : ` -w ${workspace}`;
|
|
133
|
+
process.stdout.write(`${green("added")} ${label}\n`);
|
|
134
|
+
const secretEnv = entry.secretEnv ?? [];
|
|
135
|
+
if (secretEnv.length > 0) process.stdout.write(`${dim(`set ${secretEnv.length === 1 ? "its secret" : "each secret"}: ${secretEnv.map((name) => `\`${invocation()} secret set ${id} ${name}${flag}\``).join(", ")}`)}\n`);
|
|
136
|
+
if (live) process.stdout.write(`${dim(`not started${entry.autostart === true ? " (autostart applies when the panel starts)" : ""} — \`${invocation()} start ${id}${flag}\``)}\n`);
|
|
137
|
+
else process.stdout.write(`${dim(`the panel is not running — \`${invocation()} up\`${entry.autostart === true ? ` starts it with ${id}` : `, then \`${invocation()} start ${id}${flag}\``}`)}\n`);
|
|
138
|
+
}
|
|
139
|
+
async function addOffline(entry, workspace) {
|
|
140
|
+
const { readDefaultWorkspaceId, WorkspaceRegistry } = await import("./workspaces-D9akpzU8.js").then((n) => n.i);
|
|
141
|
+
const { WorkspaceStore } = await import("./store-Bs_Lljjm.js").then((n) => n.n);
|
|
142
|
+
const { addServerEntry } = await import("./server-create-D7nvhgBd.js").then((n) => n.r);
|
|
143
|
+
const { workspaceServersPath, workspaceSettingsPath, workspacesPath } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
144
|
+
const fs = await import("node:fs");
|
|
145
|
+
const id = workspace === void 0 || workspace.length === 0 ? readDefaultWorkspaceId(workspacesPath) : workspace;
|
|
146
|
+
if (fs.existsSync(workspacesPath)) {
|
|
147
|
+
const registry = new WorkspaceRegistry(workspacesPath);
|
|
148
|
+
registry.load({ write: false });
|
|
149
|
+
if (registry.configError !== null) fail(`cannot read ${workspacesPath}: ${registry.configError}`);
|
|
150
|
+
if (!registry.all().some((known) => known.id === id)) fail(`unknown workspace "${id}" — add it in the panel first (known: ${registry.all().map((known) => known.id).join(", ")})`);
|
|
151
|
+
} else if (id !== "default") fail(`unknown workspace "${id}" — this home has only the default workspace`);
|
|
152
|
+
const store = new WorkspaceStore(id, workspaceSettingsPath(id), workspaceServersPath(id));
|
|
153
|
+
store.load();
|
|
154
|
+
if (store.pendingMigrations.length > 0) fail(`${store.path} needs ${store.pendingMigrations.length} migration(s) first — \`${invocation()} migrate\``);
|
|
155
|
+
if (store.configError !== null) fail(`refusing to write ${store.path}: ${store.configError}`);
|
|
156
|
+
try {
|
|
157
|
+
addServerEntry(store, entry);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
fail(errorMessage(error));
|
|
160
|
+
}
|
|
161
|
+
return id;
|
|
162
|
+
}
|
|
163
|
+
var addCommand = defineCommand({
|
|
164
|
+
meta: { name: "add" },
|
|
165
|
+
args: addArgs,
|
|
166
|
+
run: async ({ args, rawArgs }) => {
|
|
167
|
+
const workspace = typeof args.workspace === "string" ? args.workspace.trim() : void 0;
|
|
168
|
+
const declared = parseArgs(declarationAfterDashes(rawArgs), addArgs);
|
|
169
|
+
await runAdd({
|
|
170
|
+
id: typeof declared.id === "string" ? declared.id : void 0,
|
|
171
|
+
port: args.port,
|
|
172
|
+
cwd: args.cwd,
|
|
173
|
+
persistent: args.persistent,
|
|
174
|
+
autostart: args.autostart,
|
|
175
|
+
secretEnv: secretEnvFlags(declarationAfterDashes(rawArgs)),
|
|
176
|
+
command: commandAfterDashes(rawArgs)
|
|
177
|
+
}, workspace);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//#endregion
|
|
181
|
+
export { addCommand };
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=add-DEIYVkNK.js.map
|