badmfck-api-server 6.0.7 → 6.0.9
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 +30 -2
- package/dist/apiServer/deployment/AccessConfigWizard.d.ts +5 -1
- package/dist/apiServer/deployment/AccessConfigWizard.js +70 -2
- package/dist/apiServer/deployment/MigrateConfigsWizard.d.ts +1 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.js +188 -0
- package/dist/apiServer/deployment/cli.js +16 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -295,7 +295,8 @@ monitorAuthDir: "/var/lib/my-service", // where 2FA enrollments are kept
|
|
|
295
295
|
for 30 minutes.
|
|
296
296
|
- **Change access without a restart.** Instead of an inline object, `access` can be a path to a JSON
|
|
297
297
|
file with the same shape: `access: "/etc/my-service/access.json"`. `npx badmfck access-config` creates
|
|
298
|
-
and edits this file from a menu.
|
|
298
|
+
and edits this file from a menu. Run in the project folder, it finds the path the code assigns to
|
|
299
|
+
`access` (a string literal in `src/` or the compiled `bin/`/`dist/`), or takes it as an argument. Passwords are typed hidden and stored as hashes, and the result is
|
|
299
300
|
checked with the service's own validator. The file is watched, and changes apply
|
|
300
301
|
within a second, without a restart or a redeploy:
|
|
301
302
|
|
|
@@ -711,7 +712,8 @@ git: it holds credentials.
|
|
|
711
712
|
| `badmfck hash-password [--deployer]` | hash a password for the monitor or `setup.json` |
|
|
712
713
|
| `badmfck project-token [--hash]` | generate a project token and its hash, or hash an existing token |
|
|
713
714
|
| `badmfck project-config` | build a project config for the deployer step by step (plus a `deploy.json` skeleton) |
|
|
714
|
-
| `badmfck access-config` | create or edit `access.json`: monitor and documentation users, roles, passwords, allowed addresses |
|
|
715
|
+
| `badmfck access-config [file]` | create or edit `access.json`: monitor and documentation users, roles, passwords, allowed addresses |
|
|
716
|
+
| `badmfck migrate-configs [folder] [--yes]` | hash the secrets of old `setup.json`, project configs and `access.json` files in place |
|
|
715
717
|
|
|
716
718
|
To pass a config path through npm, use `--`: `npm run deploy -- deploy/prod.json`.
|
|
717
719
|
|
|
@@ -1036,6 +1038,32 @@ so no restart is needed.
|
|
|
1036
1038
|
|
|
1037
1039
|
---
|
|
1038
1040
|
|
|
1041
|
+
## Upgrading to 6.x
|
|
1042
|
+
|
|
1043
|
+
6.x stores secrets only as hashes and refuses plain text, while 5.x doesn't understand hashes. Upgrade
|
|
1044
|
+
each part and convert its files right after:
|
|
1045
|
+
|
|
1046
|
+
1. **CLI.** Update the CLI on the machines you deploy from. The new CLI also works with old deployers.
|
|
1047
|
+
2. **Deployer.** Upgrade the deployer, then run `npx badmfck migrate-configs <projects folder>`. It
|
|
1048
|
+
picks up the folder's `setup.json` and every project config at once. Add `--yes` to skip the
|
|
1049
|
+
confirmation, for example in a script. It hashes the
|
|
1050
|
+
passwords in `setup.json` and the token of every project config, and renames the old `username`
|
|
1051
|
+
field to `login`. Every hash is computed from the value already in the file, so clients keep their
|
|
1052
|
+
`deploy.json` unchanged.
|
|
1053
|
+
3. **Apps.** Upgrade each app, then convert its `access.json` with the same command. Monitor users
|
|
1054
|
+
keep their passwords; documentation passwords stay as they are. An app that sets `access` as an
|
|
1055
|
+
inline object needs the passwords in that object replaced with hashes (`npx badmfck hash-password`),
|
|
1056
|
+
or moved to a file with `npx badmfck access-config`.
|
|
1057
|
+
|
|
1058
|
+
Before changing anything, `migrate-configs` shows what it will change and flags weak passwords (short,
|
|
1059
|
+
or the same as the login). It copies the originals into a `.pre-hash-backup-*` folder (permissions
|
|
1060
|
+
`700`) and verifies every new hash. Delete that folder once deploys and sign-ins work, because it holds
|
|
1061
|
+
the plain secrets.
|
|
1062
|
+
|
|
1063
|
+
Also removed in 6.x: the old `MysqlService` (use `DBService`).
|
|
1064
|
+
|
|
1065
|
+
---
|
|
1066
|
+
|
|
1039
1067
|
## License
|
|
1040
1068
|
|
|
1041
1069
|
MIT
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findAccessPaths = findAccessPaths;
|
|
6
7
|
exports.AccessConfigWizard = AccessConfigWizard;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -20,14 +21,81 @@ const ROLES = {
|
|
|
20
21
|
it: "dashboard and logs",
|
|
21
22
|
analytic: "dashboard only",
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
function findAccessPaths(root) {
|
|
25
|
+
const found = [];
|
|
26
|
+
const re = /\baccess\s*[:=]\s*(["'`])([^"'`\n]+?\.json)\1/g;
|
|
27
|
+
let files = 0;
|
|
28
|
+
const visit = (dir, depth) => {
|
|
29
|
+
if (depth > 8 || files > 3000)
|
|
30
|
+
return;
|
|
31
|
+
let entries;
|
|
32
|
+
try {
|
|
33
|
+
entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
for (const e of entries) {
|
|
39
|
+
if (e.name === "node_modules" || e.name.startsWith("."))
|
|
40
|
+
continue;
|
|
41
|
+
const abs = path_1.default.join(dir, e.name);
|
|
42
|
+
if (e.isDirectory()) {
|
|
43
|
+
visit(abs, depth + 1);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (!e.isFile() || !/\.(ts|js|cjs|mjs)$/.test(e.name) || e.name.endsWith(".d.ts"))
|
|
47
|
+
continue;
|
|
48
|
+
files++;
|
|
49
|
+
let text;
|
|
50
|
+
try {
|
|
51
|
+
if (fs_1.default.statSync(abs).size > 1024 * 1024)
|
|
52
|
+
continue;
|
|
53
|
+
text = fs_1.default.readFileSync(abs, "utf-8");
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
for (const m of text.matchAll(re)) {
|
|
59
|
+
if (found.some(f => f.path === m[2]))
|
|
60
|
+
continue;
|
|
61
|
+
const line = text.slice(0, m.index).split("\n").length;
|
|
62
|
+
found.push({ path: m[2], where: `${path_1.default.relative(root, abs)}:${line}` });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
for (const sub of ["src", "bin", "dist"]) {
|
|
67
|
+
const dir = path_1.default.join(root, sub);
|
|
68
|
+
if (fs_1.default.existsSync(dir))
|
|
69
|
+
visit(dir, 0);
|
|
70
|
+
}
|
|
71
|
+
return found;
|
|
72
|
+
}
|
|
73
|
+
async function AccessConfigWizard(fileArg) {
|
|
24
74
|
const { red, green, yellow, dim, bold } = (0, cliCommon_1.palette)();
|
|
25
75
|
if (!process_1.stdin.isTTY) {
|
|
26
76
|
console.error(red("✗ access-config needs an interactive terminal — it asks for passwords."));
|
|
27
77
|
process.exit(1);
|
|
28
78
|
}
|
|
29
79
|
console.log(bold("\nAccess file for the monitor and the documentation") + dim(" (the service re-reads it on change)"));
|
|
30
|
-
|
|
80
|
+
let file;
|
|
81
|
+
if (fileArg) {
|
|
82
|
+
file = path_1.default.resolve(fileArg);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const found = findAccessPaths(process.cwd());
|
|
86
|
+
if (found.length === 1) {
|
|
87
|
+
console.log(dim(` This project's access file (from ${found[0].where}): ${found[0].path}`));
|
|
88
|
+
file = path_1.default.resolve(await (0, cliPrompt_1.ask)("File", found[0].path));
|
|
89
|
+
}
|
|
90
|
+
else if (found.length > 1) {
|
|
91
|
+
found.forEach((f, i) => console.log(` ${i + 1}) ${f.path} ${dim("— " + f.where)}`));
|
|
92
|
+
const pick = await (0, cliPrompt_1.askValid)("File (number or path)", "1", v => /^\d+$/.test(v) && !found[+v - 1] ? "no such number" : null);
|
|
93
|
+
file = path_1.default.resolve(/^\d+$/.test(pick) ? found[+pick - 1].path : pick);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
file = path_1.default.resolve(await (0, cliPrompt_1.ask)("File", "access.json"));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
31
99
|
let doc = { monitor: [], documentation: [] };
|
|
32
100
|
if (fs_1.default.existsSync(file)) {
|
|
33
101
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MigrateConfigsWizard(folder?: string, assumeYes?: boolean): Promise<void>;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MigrateConfigsWizard = MigrateConfigsWizard;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
10
|
+
const process_1 = require("process");
|
|
11
|
+
const PasswordHash_1 = require("../helper/PasswordHash");
|
|
12
|
+
const MonitorAuth_1 = require("../monitor/MonitorAuth");
|
|
13
|
+
const cliCommon_1 = require("./cliCommon");
|
|
14
|
+
const cliPrompt_1 = require("./cliPrompt");
|
|
15
|
+
const sha256 = (s) => crypto_1.default.createHash("sha256").update(s).digest("hex");
|
|
16
|
+
async function MigrateConfigsWizard(folder, assumeYes = false) {
|
|
17
|
+
const { red, green, yellow, dim, bold } = (0, cliCommon_1.palette)();
|
|
18
|
+
if (!process_1.stdin.isTTY && !assumeYes) {
|
|
19
|
+
console.error(red("✗ migrate-configs asks for confirmation — run it in a terminal, or add --yes."));
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
console.log(bold("\nMove deployer and access files to hashed secrets") + dim(assumeYes ? " (--yes: no confirmation)" : " (nothing is written before you confirm)"));
|
|
23
|
+
console.log(yellow(" Run this right after upgrading to 6.x: older versions don't understand hashes, newer ones refuse plain text.\n"));
|
|
24
|
+
let setupFile, projectsDir, accessFiles;
|
|
25
|
+
if (folder) {
|
|
26
|
+
if (!fs_1.default.existsSync(folder) || !fs_1.default.statSync(folder).isDirectory()) {
|
|
27
|
+
console.error(red(`✗ ${folder} is not a folder.`));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
projectsDir = folder;
|
|
31
|
+
const inside = path_1.default.join(folder, "setup.json");
|
|
32
|
+
if (fs_1.default.existsSync(inside))
|
|
33
|
+
setupFile = inside;
|
|
34
|
+
else if (assumeYes) {
|
|
35
|
+
setupFile = "";
|
|
36
|
+
console.log(yellow(` ⚠ No setup.json in ${folder} — deployer users are not converted.`));
|
|
37
|
+
}
|
|
38
|
+
else
|
|
39
|
+
setupFile = await (0, cliPrompt_1.ask)(`No setup.json in ${folder}. Deployer setup.json (empty = skip)`, "");
|
|
40
|
+
accessFiles = [];
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const defSetup = ["setup.json", "projects/setup.json"].find(f => fs_1.default.existsSync(f)) ?? "";
|
|
44
|
+
setupFile = await (0, cliPrompt_1.ask)("Deployer setup.json (empty = skip)", defSetup);
|
|
45
|
+
projectsDir = await (0, cliPrompt_1.ask)("Folder with project configs (empty = skip)", setupFile ? path_1.default.dirname(setupFile) : "");
|
|
46
|
+
accessFiles = (0, cliPrompt_1.list)(await (0, cliPrompt_1.ask)("access.json files of apps, comma-separated (empty = skip)", ""));
|
|
47
|
+
}
|
|
48
|
+
const plans = [];
|
|
49
|
+
const readJson = (file) => {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(fs_1.default.readFileSync(file, "utf-8"));
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.log(red(` ✗ ${file}: ${e?.code === "ENOENT" ? "not found" : "not valid JSON"} — skipped`));
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const plain = (v) => typeof v === "string" && v.length > 0 && !PasswordHash_1.PasswordHash.isHash(v);
|
|
59
|
+
if (setupFile) {
|
|
60
|
+
const doc = readJson(setupFile);
|
|
61
|
+
if (doc) {
|
|
62
|
+
const plan = { file: path_1.default.resolve(setupFile), doc, changes: [], notes: [] };
|
|
63
|
+
(doc.users ?? []).forEach((u, i) => {
|
|
64
|
+
if (u && u.login === undefined && typeof u.username === "string") {
|
|
65
|
+
plan.notes.push(`users[${i}]: "username" renamed to "login" (${u.username})`);
|
|
66
|
+
u.login = u.username;
|
|
67
|
+
delete u.username;
|
|
68
|
+
}
|
|
69
|
+
if (u && plain(u.password)) {
|
|
70
|
+
if (u.password === u.login)
|
|
71
|
+
plan.notes.push(`deployer user "${u.login}": the password is the same as the login — change it (npx badmfck hash-password --deployer, and the client's deploy.json)`);
|
|
72
|
+
else if (MonitorAuth_1.MonitorAuth.passwordPolicyError(u.password))
|
|
73
|
+
plan.notes.push(`deployer user "${u.login}": password shorter than 12 characters — change it (npx badmfck hash-password --deployer, and the client's deploy.json)`);
|
|
74
|
+
const secret = sha256(u.login + ":" + u.password);
|
|
75
|
+
plan.changes.push({ file: plan.file, label: `deployer user "${u.login}"`, secret,
|
|
76
|
+
apply: (d, h) => { d.users[i].password = h; }, read: d => d.users[i].password });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
(doc.reviewers ?? []).forEach((r, i) => {
|
|
80
|
+
if (r && plain(r.password)) {
|
|
81
|
+
if (r.password === r.login)
|
|
82
|
+
plan.notes.push(`reviewer "${r.login}": the password is the same as the login — change it later`);
|
|
83
|
+
else if (MonitorAuth_1.MonitorAuth.passwordPolicyError(r.password))
|
|
84
|
+
plan.notes.push(`reviewer "${r.login}": password shorter than 12 characters — change it later`);
|
|
85
|
+
plan.changes.push({ file: plan.file, label: `reviewer "${r.login}"`, secret: r.password,
|
|
86
|
+
apply: (d, h) => { d.reviewers[i].password = h; }, read: d => d.reviewers[i].password });
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
plans.push(plan);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (projectsDir) {
|
|
93
|
+
let names = [];
|
|
94
|
+
try {
|
|
95
|
+
names = fs_1.default.readdirSync(projectsDir).filter(n => n.endsWith(".json")).sort();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
console.log(red(` ✗ ${projectsDir}: not a readable folder — skipped`));
|
|
99
|
+
}
|
|
100
|
+
for (const n of names) {
|
|
101
|
+
const file = path_1.default.resolve(projectsDir, n);
|
|
102
|
+
if (setupFile && file === path_1.default.resolve(setupFile))
|
|
103
|
+
continue;
|
|
104
|
+
if (n.endsWith("_state_.json"))
|
|
105
|
+
continue;
|
|
106
|
+
const doc = readJson(file);
|
|
107
|
+
if (!doc || typeof doc !== "object" || typeof doc.name !== "string" || typeof doc.token !== "string")
|
|
108
|
+
continue;
|
|
109
|
+
const plan = { file, doc, changes: [], notes: [] };
|
|
110
|
+
if (plain(doc.token)) {
|
|
111
|
+
if (doc.token.length < 32)
|
|
112
|
+
plan.notes.push(`project "${doc.name}": short token (${doc.token.length} chars) — consider a new one: npx badmfck project-token`);
|
|
113
|
+
plan.changes.push({ file, label: `project token "${doc.name}"`, secret: doc.token,
|
|
114
|
+
apply: (d, h) => { d.token = h; }, read: d => d.token });
|
|
115
|
+
}
|
|
116
|
+
plans.push(plan);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const f of accessFiles) {
|
|
120
|
+
const doc = readJson(f);
|
|
121
|
+
if (!doc)
|
|
122
|
+
continue;
|
|
123
|
+
const plan = { file: path_1.default.resolve(f), doc, changes: [], notes: [] };
|
|
124
|
+
(doc.monitor ?? []).forEach((u, i) => {
|
|
125
|
+
if (u && plain(u.password)) {
|
|
126
|
+
if (u.password === u.login)
|
|
127
|
+
plan.notes.push(`monitor user "${u.login}": the password is the same as the login — change it later (npx badmfck access-config)`);
|
|
128
|
+
else if (MonitorAuth_1.MonitorAuth.passwordPolicyError(u.password))
|
|
129
|
+
plan.notes.push(`monitor user "${u.login}": password shorter than 12 characters — change it later (npx badmfck access-config)`);
|
|
130
|
+
plan.changes.push({ file: plan.file, label: `monitor user "${u.login}"`, secret: u.password,
|
|
131
|
+
apply: (d, h) => { d.monitor[i].password = h; }, read: d => d.monitor[i].password });
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
plans.push(plan);
|
|
135
|
+
}
|
|
136
|
+
const todo = plans.filter(p => p.changes.length || p.notes.some(n => n.includes("renamed")));
|
|
137
|
+
console.log("\n" + bold("Report"));
|
|
138
|
+
for (const p of plans) {
|
|
139
|
+
const head = p.changes.length ? yellow(`${p.changes.length} to hash`) : green("already hashed");
|
|
140
|
+
console.log(` ${p.file} ${head}`);
|
|
141
|
+
for (const c of p.changes)
|
|
142
|
+
console.log(dim(` • ${c.label}`));
|
|
143
|
+
for (const n of p.notes)
|
|
144
|
+
console.log(yellow(` ⚠ ${n}`));
|
|
145
|
+
}
|
|
146
|
+
if (!todo.length) {
|
|
147
|
+
console.log(green("\n✓ Nothing to change."));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!assumeYes && !(await (0, cliPrompt_1.yes)(`\nHash ${todo.reduce((n, p) => n + p.changes.length, 0)} value(s) in ${todo.length} file(s)?`, false))) {
|
|
151
|
+
console.log(dim("Nothing was changed."));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
155
|
+
const backupDir = path_1.default.resolve(path_1.default.dirname(todo[0].file), `.pre-hash-backup-${stamp}`);
|
|
156
|
+
fs_1.default.mkdirSync(backupDir, { recursive: true, mode: 0o700 });
|
|
157
|
+
for (const [i, p] of todo.entries()) {
|
|
158
|
+
const copy = path_1.default.join(backupDir, `${i + 1}-${path_1.default.basename(p.file)}`);
|
|
159
|
+
fs_1.default.copyFileSync(p.file, copy);
|
|
160
|
+
fs_1.default.chmodSync(copy, 0o600);
|
|
161
|
+
}
|
|
162
|
+
let failed = 0;
|
|
163
|
+
for (const p of todo) {
|
|
164
|
+
for (const c of p.changes)
|
|
165
|
+
c.apply(p.doc, await PasswordHash_1.PasswordHash.hash(c.secret));
|
|
166
|
+
const tmp = p.file + ".tmp";
|
|
167
|
+
fs_1.default.writeFileSync(tmp, JSON.stringify(p.doc, null, 4) + "\n", { encoding: "utf-8", mode: 0o600 });
|
|
168
|
+
fs_1.default.chmodSync(tmp, 0o600);
|
|
169
|
+
fs_1.default.renameSync(tmp, p.file);
|
|
170
|
+
const back = JSON.parse(fs_1.default.readFileSync(p.file, "utf-8"));
|
|
171
|
+
for (const c of p.changes) {
|
|
172
|
+
if (await PasswordHash_1.PasswordHash.verify(c.secret, c.read(back)))
|
|
173
|
+
continue;
|
|
174
|
+
failed++;
|
|
175
|
+
console.log(red(` ✗ ${p.file}: ${c.label} did not verify — restore it from ${backupDir}`));
|
|
176
|
+
}
|
|
177
|
+
console.log((failed ? yellow : green)(` ✓ ${p.file}`) + dim(" (0600)"));
|
|
178
|
+
}
|
|
179
|
+
console.log("");
|
|
180
|
+
if (failed) {
|
|
181
|
+
console.log(red(`✗ ${failed} value(s) did not verify. The originals are in ${backupDir}.`));
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
console.log(green("✓ Done. A running 6.x deployer and apps pick the files up without a restart."));
|
|
185
|
+
console.log(yellow(` The originals (with the plain secrets) are in ${backupDir}.`));
|
|
186
|
+
console.log(yellow(" Check that deploys and monitor sign-in work, then delete that folder:"));
|
|
187
|
+
console.log(` rm -rf ${JSON.stringify(backupDir)}`);
|
|
188
|
+
}
|
|
@@ -10,6 +10,7 @@ const BackupManager_1 = require("./BackupManager");
|
|
|
10
10
|
const HashPassword_1 = require("./HashPassword");
|
|
11
11
|
const ProjectConfigWizard_1 = require("./ProjectConfigWizard");
|
|
12
12
|
const AccessConfigWizard_1 = require("./AccessConfigWizard");
|
|
13
|
+
const MigrateConfigsWizard_1 = require("./MigrateConfigsWizard");
|
|
13
14
|
function usage() {
|
|
14
15
|
console.error("Usage:");
|
|
15
16
|
console.error(" badmfck deploy [config.json] — build + upload the current project");
|
|
@@ -20,7 +21,8 @@ function usage() {
|
|
|
20
21
|
console.error(" badmfck hash-password [--deployer] — hash a password for the monitor (or deployer setup.json)");
|
|
21
22
|
console.error(" badmfck project-token [--hash] — new project token + its hash (or hash an existing one)");
|
|
22
23
|
console.error(" badmfck project-config — build a project config for the deployer, step by step");
|
|
23
|
-
console.error(" badmfck access-config
|
|
24
|
+
console.error(" badmfck access-config [file] — create or edit access.json (found in the project's code if omitted)");
|
|
25
|
+
console.error(" badmfck migrate-configs [folder] [--yes] — hash the secrets of old setup.json, project configs and access.json files");
|
|
24
26
|
console.error("");
|
|
25
27
|
console.error("Config path is optional (auto-discovers deploy/ folder → deploy.json when omitted).");
|
|
26
28
|
console.error("Via npm, prefix args with -- e.g. npm run deploy -- deploy/custom.json");
|
|
@@ -107,12 +109,22 @@ async function main() {
|
|
|
107
109
|
await (0, HashPassword_1.HashPassword)(rest.includes("--deployer") ? "deployer" : "monitor");
|
|
108
110
|
break;
|
|
109
111
|
}
|
|
112
|
+
case "migrate-configs": {
|
|
113
|
+
const assumeYes = rest.includes("--yes") || rest.includes("-y");
|
|
114
|
+
const folders = rest.filter(a => a !== "--yes" && a !== "-y");
|
|
115
|
+
if (folders.length > 1 || folders.some(a => a.startsWith("-"))) {
|
|
116
|
+
console.error("Usage: badmfck migrate-configs [folder] [--yes]");
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
await (0, MigrateConfigsWizard_1.MigrateConfigsWizard)(folders[0], assumeYes);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
110
122
|
case "access-config": {
|
|
111
|
-
if (rest.length) {
|
|
112
|
-
console.error("access-config takes
|
|
123
|
+
if (rest.length > 1) {
|
|
124
|
+
console.error("access-config takes at most one argument: the path to the access file.");
|
|
113
125
|
process.exit(1);
|
|
114
126
|
}
|
|
115
|
-
await (0, AccessConfigWizard_1.AccessConfigWizard)();
|
|
127
|
+
await (0, AccessConfigWizard_1.AccessConfigWizard)(rest[0]);
|
|
116
128
|
break;
|
|
117
129
|
}
|
|
118
130
|
case "project-config": {
|