@rocket.chat/houston 0.27.0-next.3 → 2.1.8
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/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.interruptible = interruptible;
|
|
37
|
+
exports.confirm = confirm;
|
|
38
|
+
exports.hiddenPrompt = hiddenPrompt;
|
|
39
|
+
/**
|
|
40
|
+
* The hidden prompt, the only kind of prompt this CLI asks (every `prompt` here hides what
|
|
41
|
+
* is typed), the yes/no confirmation (`confirm`), and the interrupt handling every question
|
|
42
|
+
* shares.
|
|
43
|
+
*
|
|
44
|
+
* WHERE EACH BYTE GOES, measured against the frozen CLI on a pseudo-terminal: the question
|
|
45
|
+
* goes to STDOUT with its trailing spaces stripped -- `Password for bob:` -- and the
|
|
46
|
+
* password read then opens `/dev/tty`, turns ECHO off, writes a space there, reads one
|
|
47
|
+
* line, restores the terminal and writes a newline there. Nothing typed is ever shown, and
|
|
48
|
+
* the terminal is read even when stdin is a file. This asked a readline question on stdin
|
|
49
|
+
* with the prompt on stderr and echo ON, so every character of a password typed into
|
|
50
|
+
* `users add --ask-password` or `users passwd --ask-password` was printed back to the
|
|
51
|
+
* terminal, and it refused with exit 2 whenever stdin was not a terminal.
|
|
52
|
+
*
|
|
53
|
+
* WITHOUT `/dev/tty` -- no controlling terminal: a detached job, cron -- the read falls back
|
|
54
|
+
* to stdin: echo off on it if it is a terminal, else `Warning: Password input may be
|
|
55
|
+
* echoed.` and a plain line read. Either way the space before the answer and the newline
|
|
56
|
+
* after it go to STDERR. The fallback's other line, the previous implementation's runtime
|
|
57
|
+
* warning (`GetPassWarning: ...`, with the library file and line it came from), is about
|
|
58
|
+
* that runtime rather than houston, and is not reproduced.
|
|
59
|
+
*
|
|
60
|
+
* The line runs up to and excluding one `\n`, a `\r` before it kept, the last line without
|
|
61
|
+
* one taken as it is. End of input and Ctrl-C are both an abort: a newline on stdout and
|
|
62
|
+
* `Aborted.`. On the terminal the line is edited by readline rather than by the kernel's
|
|
63
|
+
* line discipline, so only the editing keys differ (a mid-line Ctrl-D deletes forward here
|
|
64
|
+
* and delivers the partial line there).
|
|
65
|
+
*/
|
|
66
|
+
const fs = __importStar(require("node:fs"));
|
|
67
|
+
const readline = __importStar(require("node:readline"));
|
|
68
|
+
const node_stream_1 = require("node:stream");
|
|
69
|
+
const tty = __importStar(require("node:tty"));
|
|
70
|
+
const float_text_1 = require("../../lib/float-text");
|
|
71
|
+
const app_1 = require("../app");
|
|
72
|
+
/**
|
|
73
|
+
* A question under Ctrl-C: an interrupted QUESTION is an abort, `Aborted.` on stderr and
|
|
74
|
+
* exit 1, with an `end` record saying 1 -- not the silent 130 of an interrupt anywhere else
|
|
75
|
+
* in a command. MEASURED against the previous implementation, by `kill -INT` and by Ctrl-C
|
|
76
|
+
* typed on a pseudo-terminal: `down --name <ws> --volumes` leaves its question on stdout
|
|
77
|
+
* with no newline and then `Aborted.`; `users add <name> --ask-password` writes a newline
|
|
78
|
+
* to stdout first, which the hidden prompt does because the password read leaves the
|
|
79
|
+
* cursor on the question's line (`hidden`).
|
|
80
|
+
*
|
|
81
|
+
* Holding a SIGINT listener while the question waits is also what tells `runMain`'s handler
|
|
82
|
+
* that this command answers the interrupt itself. On a terminal, readline in terminal mode
|
|
83
|
+
* reads Ctrl-C as a keypress and raises no signal; with no `SIGINT` listener on the interface
|
|
84
|
+
* it rejected the pending question with an AbortError, which reached the contract's last
|
|
85
|
+
* line as an unhandled error -- a JS stack, an `error` record with `trace: true` and exit 1
|
|
86
|
+
* (measured on Node 24.20: `users add bob --ask-password`, Ctrl-C at the password).
|
|
87
|
+
*/
|
|
88
|
+
async function interruptible(source, answer, hidden) {
|
|
89
|
+
let abort = () => undefined;
|
|
90
|
+
const interrupted = new Promise((_resolve, reject) => {
|
|
91
|
+
abort = () => {
|
|
92
|
+
if (hidden)
|
|
93
|
+
process.stdout.write('\n');
|
|
94
|
+
reject(new app_1.Aborted());
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
process.once('SIGINT', abort);
|
|
98
|
+
source?.once('SIGINT', abort);
|
|
99
|
+
try {
|
|
100
|
+
return await Promise.race([answer, interrupted]);
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
process.off('SIGINT', abort);
|
|
104
|
+
source?.off('SIGINT', abort);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Swallows readline's own echo and cursor movement: nothing typed may reach a terminal. */
|
|
108
|
+
function muted() {
|
|
109
|
+
return new node_stream_1.Writable({
|
|
110
|
+
write(_chunk, _encoding, done) {
|
|
111
|
+
done();
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** One line from a terminal in raw mode, echo swallowed; null at end of input (Ctrl-D). */
|
|
116
|
+
async function terminalLine(input) {
|
|
117
|
+
const rl = readline.createInterface({ input, output: muted(), terminal: true });
|
|
118
|
+
try {
|
|
119
|
+
return await interruptible(rl, new Promise((resolve) => {
|
|
120
|
+
rl.once('line', resolve);
|
|
121
|
+
rl.once('close', () => {
|
|
122
|
+
resolve(null);
|
|
123
|
+
});
|
|
124
|
+
}), true);
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
rl.close(); // leaves raw mode: the terminal's own echo is back
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Stdin's lines across prompts: the second prompt reads the line after the first, from the
|
|
132
|
+
* same buffer, as a buffered stdin does. Paused between reads, so a pipe left open does not
|
|
133
|
+
* hold the process. The hidden prompt reads it only when stdin is not a terminal;
|
|
134
|
+
* `confirm` always, since its terminal is read in cooked mode, a line at a time.
|
|
135
|
+
*/
|
|
136
|
+
class StdinLines {
|
|
137
|
+
constructor() {
|
|
138
|
+
this.buffer = Buffer.alloc(0);
|
|
139
|
+
this.ended = false;
|
|
140
|
+
/** The read in flight's release, while one is. */
|
|
141
|
+
this.reading = null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Abandons the read in flight: its listeners off and stdin paused. A question a Ctrl-C
|
|
145
|
+
* interrupted leaves one behind, and stdin still flowing holds the process open after
|
|
146
|
+
* `Aborted.` for as long as the pipe feeding it does.
|
|
147
|
+
*/
|
|
148
|
+
stop() {
|
|
149
|
+
this.reading?.();
|
|
150
|
+
}
|
|
151
|
+
async next() {
|
|
152
|
+
for (;;) {
|
|
153
|
+
const at = this.buffer.indexOf(0x0a);
|
|
154
|
+
if (at >= 0) {
|
|
155
|
+
const line = this.buffer.subarray(0, at).toString('utf8');
|
|
156
|
+
this.buffer = this.buffer.subarray(at + 1);
|
|
157
|
+
return line;
|
|
158
|
+
}
|
|
159
|
+
if (this.ended) {
|
|
160
|
+
if (this.buffer.length === 0)
|
|
161
|
+
return null;
|
|
162
|
+
const line = this.buffer.toString('utf8');
|
|
163
|
+
this.buffer = Buffer.alloc(0);
|
|
164
|
+
return line;
|
|
165
|
+
}
|
|
166
|
+
await this.fill();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
fill() {
|
|
170
|
+
const stdin = process.stdin;
|
|
171
|
+
return new Promise((resolve, reject) => {
|
|
172
|
+
const onData = (chunk) => {
|
|
173
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
174
|
+
settle();
|
|
175
|
+
};
|
|
176
|
+
const onEnd = () => {
|
|
177
|
+
this.ended = true;
|
|
178
|
+
settle();
|
|
179
|
+
};
|
|
180
|
+
const onError = (error) => {
|
|
181
|
+
release();
|
|
182
|
+
reject(error);
|
|
183
|
+
};
|
|
184
|
+
const release = () => {
|
|
185
|
+
this.reading = null;
|
|
186
|
+
stdin.off('data', onData);
|
|
187
|
+
stdin.off('end', onEnd);
|
|
188
|
+
stdin.off('error', onError);
|
|
189
|
+
stdin.pause();
|
|
190
|
+
};
|
|
191
|
+
const settle = () => {
|
|
192
|
+
release();
|
|
193
|
+
resolve();
|
|
194
|
+
};
|
|
195
|
+
this.reading = release;
|
|
196
|
+
stdin.on('data', onData);
|
|
197
|
+
stdin.once('end', onEnd);
|
|
198
|
+
stdin.once('error', onError);
|
|
199
|
+
stdin.resume();
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let stdinLines = null;
|
|
204
|
+
/** `open('/dev/tty', O_RDWR | O_NOCTTY)`, or null where that fails and the read uses stdin. */
|
|
205
|
+
function openTerminal() {
|
|
206
|
+
try {
|
|
207
|
+
return fs.openSync('/dev/tty', fs.constants.O_RDWR | fs.constants.O_NOCTTY);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** The password read's answer, or null at end of input. */
|
|
214
|
+
async function readHiddenLine() {
|
|
215
|
+
const fd = openTerminal();
|
|
216
|
+
if (fd !== null) {
|
|
217
|
+
const input = new tty.ReadStream(fd);
|
|
218
|
+
try {
|
|
219
|
+
fs.writeSync(fd, ' ');
|
|
220
|
+
const line = await terminalLine(input);
|
|
221
|
+
if (line !== null)
|
|
222
|
+
fs.writeSync(fd, '\n');
|
|
223
|
+
return line;
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
input.destroy();
|
|
227
|
+
fs.closeSync(fd); // the stream does not close a descriptor it was handed
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (process.stdin.isTTY) {
|
|
231
|
+
process.stderr.write(' ');
|
|
232
|
+
const line = await terminalLine(process.stdin);
|
|
233
|
+
if (line !== null)
|
|
234
|
+
process.stderr.write('\n');
|
|
235
|
+
return line;
|
|
236
|
+
}
|
|
237
|
+
process.stderr.write('Warning: Password input may be echoed.\n ');
|
|
238
|
+
stdinLines ?? (stdinLines = new StdinLines());
|
|
239
|
+
const line = await interruptible(null, stdinLines.next(), true);
|
|
240
|
+
if (line !== null)
|
|
241
|
+
process.stderr.write('\n');
|
|
242
|
+
return line;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* A yes/no question with a default of no, a "no" ending the command, which is every
|
|
246
|
+
* question this CLI asks before destroying something (`down --volumes`, `prune`'s
|
|
247
|
+
* `Continue?` and `Delete the cluster?`, `edge delete`, `cluster delete`).
|
|
248
|
+
*
|
|
249
|
+
* It LOOPS: the answer is lower-cased and stripped (`stripText`); `y`/`yes` is yes, `n`/`no`
|
|
250
|
+
* and the empty answer are no, and anything else writes `Error: invalid input` to stdout
|
|
251
|
+
* and asks again. End of input and Ctrl-C are an abort, with NOTHING written -- no newline
|
|
252
|
+
* after the question, unlike the hidden prompt's. On a stdin that is not a terminal the
|
|
253
|
+
* line is the next one with its one `\n` removed, so a `\r` before it is part of the answer
|
|
254
|
+
* until the strip removes it; the lines come from the process's one stdin buffer, so an
|
|
255
|
+
* answer already read ahead is not lost between attempts.
|
|
256
|
+
*
|
|
257
|
+
* An earlier version read ONE line and took anything but y/yes as no, stripped with `trim()`:
|
|
258
|
+
* `x` then `y` deleted the data in the established CLI and aborted here; a BOM before `y`
|
|
259
|
+
* (which `stripText` keeps) aborted there and deleted here; `\x1cy` or `y\x85` (which it
|
|
260
|
+
* removes and `trim()` does not) the other way round; and end of input wrote a newline the
|
|
261
|
+
* established CLI does not.
|
|
262
|
+
*/
|
|
263
|
+
async function confirm(question) {
|
|
264
|
+
for (;;) {
|
|
265
|
+
process.stdout.write(`${question} [y/N]: `);
|
|
266
|
+
const lines = (stdinLines ?? (stdinLines = new StdinLines()));
|
|
267
|
+
let line;
|
|
268
|
+
try {
|
|
269
|
+
line = await interruptible(null, lines.next(), false);
|
|
270
|
+
}
|
|
271
|
+
finally {
|
|
272
|
+
lines.stop();
|
|
273
|
+
}
|
|
274
|
+
if (line === null)
|
|
275
|
+
return false;
|
|
276
|
+
const value = (0, float_text_1.stripText)(line.toLowerCase());
|
|
277
|
+
if (value === 'y' || value === 'yes')
|
|
278
|
+
return true;
|
|
279
|
+
if (value === 'n' || value === 'no' || value === '')
|
|
280
|
+
return false;
|
|
281
|
+
process.stdout.write('Error: invalid input\n');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/** The hidden prompt: the question, then a read that shows nothing typed. */
|
|
285
|
+
async function hiddenPrompt(question) {
|
|
286
|
+
// An empty entry is asked again, question and all, where this took '' as the password
|
|
287
|
+
// and refused it as too short -- `users add bob --ask-password` with Enter pressed first.
|
|
288
|
+
for (;;) {
|
|
289
|
+
process.stdout.write(`${question}:`);
|
|
290
|
+
const line = await readHiddenLine();
|
|
291
|
+
if (line === null) {
|
|
292
|
+
// End of input or Ctrl-C: a newline, then the abort.
|
|
293
|
+
process.stdout.write('\n');
|
|
294
|
+
throw new app_1.Aborted();
|
|
295
|
+
}
|
|
296
|
+
if (line !== '')
|
|
297
|
+
return line;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usersCommand = usersCommand;
|
|
4
|
+
/**
|
|
5
|
+
* `users`: who may sign in to the web GUI, managed from the terminal.
|
|
6
|
+
*
|
|
7
|
+
* It PRINTS AS IT GOES, as `users` always has.
|
|
8
|
+
*
|
|
9
|
+
* An earlier version returned a payload and drew it afterwards, which cannot say what
|
|
10
|
+
* `users` says WHEN it says it: the `'Lucy.Felix' becomes 'lucy-felix'` note comes before the
|
|
11
|
+
* prompt, and before the conflict of `users add BOB` where bob exists, so a renderer that
|
|
12
|
+
* runs only on success never printed it; and the first-run line is decided by a read of the
|
|
13
|
+
* accounts made AFTER the password is on screen. The payload's renderer had also lost most of
|
|
14
|
+
* what is printed around it -- the two lines on why a password is shown once, the role
|
|
15
|
+
* an added account got and the first-run link it spent, the roles-bound-the-GUI lines after a
|
|
16
|
+
* role change, the second line of the empty listing, and in the listing the created date, the
|
|
17
|
+
* EFFECTIVE role (`roleOf`, where it showed the raw column: `[52]` for a legacy timestamp
|
|
18
|
+
* line, `[ADMIN]`, `[superuser]`), the `(implicit)` marker and its three lines, and the
|
|
19
|
+
* password as the panel's LABEL, which is two columns wider for a one- or two-letter name.
|
|
20
|
+
*
|
|
21
|
+
* `json: none`, so what this prints and the code it exits with are the whole contract. Every
|
|
22
|
+
* prose line is stdout, as the CLI has always written it off a terminal; a call that is wrong
|
|
23
|
+
* (a missing name or role, an unknown action) is a `ValidationError` (exit 2), a typed password
|
|
24
|
+
* that does not match its repeat a plain `ReproError` (exit 1), and a service refusal
|
|
25
|
+
* propagates with its own class.
|
|
26
|
+
*/
|
|
27
|
+
const errors_1 = require("../../lib/errors");
|
|
28
|
+
const format_1 = require("../../lib/format");
|
|
29
|
+
const render_1 = require("../render");
|
|
30
|
+
const prompt_1 = require("./prompt");
|
|
31
|
+
function usersService() {
|
|
32
|
+
return require('../../core/users');
|
|
33
|
+
}
|
|
34
|
+
/** The accounts, including the pre-roles implicit-admin migration state. */
|
|
35
|
+
function listGuiUsers(io) {
|
|
36
|
+
const users = usersService();
|
|
37
|
+
const rows = users.listUsers();
|
|
38
|
+
if (rows.length === 0) {
|
|
39
|
+
(0, render_1.say)(io, 'no users yet — add one with `houston users add <name>`');
|
|
40
|
+
(0, render_1.say)(io, ' or just run `houston serve` — it prints a one-time link that creates the first one.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// The role read per row, as the service reads it: the EFFECTIVE role of the name
|
|
44
|
+
// normalised, so a column the service reads as admin shows as admin, and a stored name
|
|
45
|
+
// that is not in normalised form finds no account and shows `[]`. An account linked to
|
|
46
|
+
// Okta says which Okta email signs in as it.
|
|
47
|
+
const okta = require('../../core/sso-identities').linked();
|
|
48
|
+
(0, render_1.writePanel)(io, 'GUI users', rows.map((user) => {
|
|
49
|
+
const email = okta.get(user.name)?.email;
|
|
50
|
+
return [
|
|
51
|
+
user.name,
|
|
52
|
+
`${user.createdAt} [${users.roleOf(user.name)}${user.role ? '' : ' (implicit)'}]` +
|
|
53
|
+
(email === undefined ? '' : ` okta ${email}`),
|
|
54
|
+
];
|
|
55
|
+
}));
|
|
56
|
+
const implicit = users.implicitAdmins();
|
|
57
|
+
if (implicit.length > 0) {
|
|
58
|
+
(0, render_1.say)(io, ' (implicit) = the role column is blank, which means admin. That is the\n' +
|
|
59
|
+
' migration for accounts made before roles existed, not a default.');
|
|
60
|
+
(0, render_1.say)(io, ` narrow one with: houston users role ${implicit[0]} member`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** The authority, and the sessions revoked so it takes effect now. */
|
|
64
|
+
async function changeGuiUserRole(io, name, role) {
|
|
65
|
+
const users = usersService();
|
|
66
|
+
if (!role)
|
|
67
|
+
throw new errors_1.ValidationError(`\`users role ${name}\` needs a role (${users.ROLES.join(' | ')})`);
|
|
68
|
+
const user = await users.setRole(name, role);
|
|
69
|
+
// A role change signs the account out everywhere once its role is written, under
|
|
70
|
+
// `locks/sessions.lock`, so a demotion reaches a browser that is already open rather than
|
|
71
|
+
// waiting out a seven-day session. This build wrote the role and kept every session: the
|
|
72
|
+
// demoted person stayed signed in and nothing said otherwise. The service does not revoke,
|
|
73
|
+
// on purpose -- a role is not a credential -- so each front end does it, as the GUI's role
|
|
74
|
+
// route already did.
|
|
75
|
+
const ended = await require('../../core/sessions').revokeUser(name);
|
|
76
|
+
(0, render_1.say)(io, `✓ ${(0, format_1.quotedText)(user.name)} is now ${user.role}.`);
|
|
77
|
+
if (ended)
|
|
78
|
+
(0, render_1.say)(io, ` ${ended} active session(s) signed out, so it takes effect now.`);
|
|
79
|
+
(0, render_1.say)(io, ' roles bound the GUI. The CLI has no roles: anyone with a shell on this box\n' +
|
|
80
|
+
' is already in the docker group. A readonly user with an ssh key is not readonly.');
|
|
81
|
+
}
|
|
82
|
+
/** The account goes, and the service ends its sessions. */
|
|
83
|
+
async function removeGuiUser(io, name) {
|
|
84
|
+
const ended = await usersService().remove(name);
|
|
85
|
+
(0, render_1.say)(io, `✓ user ${(0, format_1.quotedText)(name)} removed.`);
|
|
86
|
+
if (ended)
|
|
87
|
+
(0, render_1.say)(io, ` ${ended} active session(s) signed out.`);
|
|
88
|
+
}
|
|
89
|
+
/** `link-sso`: approve the exact-name Okta link an admin account never makes on its own. */
|
|
90
|
+
async function linkSso(io, name) {
|
|
91
|
+
await require('../../core/sso').approveLink(name);
|
|
92
|
+
(0, render_1.say)(io, `✓ the Okta user whose username is ${(0, format_1.quotedText)(name)} may now sign in as it.`);
|
|
93
|
+
(0, render_1.say)(io, ' The link is made at their next Okta sign-in. Only that exact name links: a\n' +
|
|
94
|
+
' different Okta username is a different houston account.');
|
|
95
|
+
}
|
|
96
|
+
/** `unlink-sso`: the Okta link becomes a tombstone; the account and its password stay. */
|
|
97
|
+
async function unlinkSso(io, name) {
|
|
98
|
+
const ended = await require('../../core/sso').unlink(name);
|
|
99
|
+
(0, render_1.say)(io, `✓ ${(0, format_1.quotedText)(name)} no longer signs in with Okta; its houston password still works.`);
|
|
100
|
+
if (ended)
|
|
101
|
+
(0, render_1.say)(io, ` ${ended} active session(s) signed out.`);
|
|
102
|
+
(0, render_1.say)(io, ` to allow it again: houston users link-sso ${name}`);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The request validated, and a password minted or asked for.
|
|
106
|
+
*
|
|
107
|
+
* In the established order: the NAME -- for `passwd` as much as `add` -- before anything is
|
|
108
|
+
* said or asked; the note on what the name became; the prompt; then the role, so a bad role
|
|
109
|
+
* is refused after the prompt and before the password's length is looked at.
|
|
110
|
+
*/
|
|
111
|
+
async function passwordForUser(io, request, name, prompt) {
|
|
112
|
+
const users = usersService();
|
|
113
|
+
users.requireValidName(name);
|
|
114
|
+
if (name !== request.name) {
|
|
115
|
+
(0, render_1.say)(io, ` ${(0, format_1.quotedText)(request.name)} becomes ${(0, format_1.quotedText)(name)} — an account name becomes part of a ` +
|
|
116
|
+
'workspace name, and therefore a DNS label.');
|
|
117
|
+
}
|
|
118
|
+
let password;
|
|
119
|
+
let minted;
|
|
120
|
+
if (request.askPassword) {
|
|
121
|
+
password = await prompt(`Password for ${name}`, true);
|
|
122
|
+
if (password !== (await prompt('Repeat', true))) {
|
|
123
|
+
throw new errors_1.ReproError('the two passwords do not match');
|
|
124
|
+
}
|
|
125
|
+
minted = false;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
password = users.mintPassword();
|
|
129
|
+
minted = true;
|
|
130
|
+
}
|
|
131
|
+
if (request.role && request.action === 'passwd') {
|
|
132
|
+
throw new errors_1.ValidationError('`users passwd` takes no role — change one with ' +
|
|
133
|
+
`\`houston users role ${name} ${request.role}\``);
|
|
134
|
+
}
|
|
135
|
+
if (request.role)
|
|
136
|
+
users.requireValidRole(request.role);
|
|
137
|
+
return [password, minted];
|
|
138
|
+
}
|
|
139
|
+
/** The one moment a generated credential exists in readable form. */
|
|
140
|
+
function reportGuiPassword(io, action, added, ended, minted, name, password) {
|
|
141
|
+
(0, render_1.say)(io, `✓ user ${(0, format_1.quotedText)(name)} ${action === 'add' ? 'added' : 'password changed'}.`);
|
|
142
|
+
if (minted) {
|
|
143
|
+
// `(password, "")`: the password is the LABEL, so its cell carries the two spaces a
|
|
144
|
+
// label is followed by.
|
|
145
|
+
(0, render_1.writePanel)(io, `password for ${name}`, [[password, '']]);
|
|
146
|
+
(0, render_1.say)(io, ' Shown once. houston keeps only a scrypt hash, so nobody — including you —\n' +
|
|
147
|
+
' can read it back. Send it over something the person can delete afterwards.');
|
|
148
|
+
}
|
|
149
|
+
if (action === 'passwd' && ended)
|
|
150
|
+
(0, render_1.say)(io, ` ${ended} active session(s) signed out.`);
|
|
151
|
+
if (action === 'add' && added !== null) {
|
|
152
|
+
// Only the FIRST account is made an admin regardless: a later admin was told the same,
|
|
153
|
+
// as if it had been forced on it.
|
|
154
|
+
const first = usersService().listUsers().length === 1;
|
|
155
|
+
(0, render_1.say)(io, ` role: ${added.role}` +
|
|
156
|
+
(first
|
|
157
|
+
? ' (the first account has to be an admin, or nobody could promote anyone)'
|
|
158
|
+
: ` — change it with \`houston users role ${name} <role>\``));
|
|
159
|
+
if (first) {
|
|
160
|
+
(0, render_1.say)(io, ' `houston serve` will now ask for this login, and the first-run link is spent.');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Add an account, or replace its password, never from argv. */
|
|
165
|
+
async function setGuiPassword(io, request, name, prompt) {
|
|
166
|
+
const users = usersService();
|
|
167
|
+
const [password, minted] = await passwordForUser(io, request, name, prompt);
|
|
168
|
+
let ended = 0;
|
|
169
|
+
let added = null;
|
|
170
|
+
if (request.action === 'add') {
|
|
171
|
+
// `add` is handed the NORMALISED role, the typed one having been validated in
|
|
172
|
+
// `passwordForUser` just after the prompt. Passing argv through stored it as typed:
|
|
173
|
+
// `users add dave ADMIN` wrote `:ADMIN` and audited `role=ADMIN`, and a role that led
|
|
174
|
+
// with a line break (`$'\nmember'`, or `\r`, which `splitTextLines` breaks at) split the
|
|
175
|
+
// account's line, so the member just created read back as an IMPLICIT admin. Validated
|
|
176
|
+
// before it is normalised, because `normaliseRole` reads anything unknown as admin:
|
|
177
|
+
// `reedonly` must stay a refusal.
|
|
178
|
+
added = await users.add(name, password, request.role ? users.normaliseRole(request.role) : '');
|
|
179
|
+
}
|
|
180
|
+
else
|
|
181
|
+
ended = await users.setPassword(name, password);
|
|
182
|
+
reportGuiPassword(io, request.action, added, ended, minted, name, password);
|
|
183
|
+
}
|
|
184
|
+
const USERS_ACTIONS = ['list', 'add', 'passwd', 'remove', 'role', 'link-sso', 'unlink-sso'];
|
|
185
|
+
/**
|
|
186
|
+
* `users`, in its established order: the TYPED name is tested for emptiness, then normalised,
|
|
187
|
+
* then each action checks what it checks.
|
|
188
|
+
*
|
|
189
|
+
* An earlier version tested the NORMALISED name, so `users remove '!!!'` said "needs a name"
|
|
190
|
+
* (exit 1) where the established answer looks up '' and is NOT_FOUND (exit 4); it validated
|
|
191
|
+
* the name only inside `add`, so `users passwd` with a 33-character name was "no user" (exit
|
|
192
|
+
* 4), not the length refusal (exit 2); and it prompted before validating anything, so `add <33
|
|
193
|
+
* chars> --ask-password` asked for a password it was going to refuse.
|
|
194
|
+
*
|
|
195
|
+
* An unknown action is refused as unknown before any of that, naming the actions, as
|
|
196
|
+
* `cluster`, `edge` and `config` refuse theirs: `users frob` said "`users frob` needs a name,
|
|
197
|
+
* e.g. `houston users frob alice`", which then answered "unknown action".
|
|
198
|
+
*
|
|
199
|
+
* One normalisation for every branch, so `role`, `remove` and `passwd` find the account that
|
|
200
|
+
* `add` created and every line printed names it the way the file spells it -- the service
|
|
201
|
+
* normalises too, but it cannot fix what this layer PRINTS. The typed name is kept for the
|
|
202
|
+
* one line that says what it became.
|
|
203
|
+
*/
|
|
204
|
+
async function usersCommand(io, request, prompt = (question) => (0, prompt_1.hiddenPrompt)(question)) {
|
|
205
|
+
const { action } = request;
|
|
206
|
+
if (!USERS_ACTIONS.includes(action)) {
|
|
207
|
+
throw new errors_1.ValidationError(`unknown action ${(0, format_1.quotedText)(action)} (want: ${USERS_ACTIONS.join(' | ')})`);
|
|
208
|
+
}
|
|
209
|
+
if (action === 'list') {
|
|
210
|
+
listGuiUsers(io);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (!request.name) {
|
|
214
|
+
throw new errors_1.ValidationError(`\`users ${action}\` needs a name, e.g. \`houston users ${action} alice\``);
|
|
215
|
+
}
|
|
216
|
+
const name = usersService().normalizeName(request.name);
|
|
217
|
+
if (action === 'role')
|
|
218
|
+
return await changeGuiUserRole(io, name, request.role);
|
|
219
|
+
if (action === 'remove')
|
|
220
|
+
return await removeGuiUser(io, name);
|
|
221
|
+
if (action === 'link-sso')
|
|
222
|
+
return await linkSso(io, name);
|
|
223
|
+
if (action === 'unlink-sso')
|
|
224
|
+
return await unlinkSso(io, name);
|
|
225
|
+
return await setGuiPassword(io, request, name, prompt);
|
|
226
|
+
}
|