badmfck-api-server 6.0.1 → 6.0.3

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.
@@ -1 +1,2 @@
1
1
  export declare function HashPassword(target: "monitor" | "deployer"): Promise<void>;
2
+ export declare function ProjectToken(mode: "generate" | "hash"): Promise<void>;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HashPassword = HashPassword;
7
+ exports.ProjectToken = ProjectToken;
7
8
  const crypto_1 = __importDefault(require("crypto"));
8
9
  const promises_1 = require("readline/promises");
9
10
  const process_1 = require("process");
@@ -89,3 +90,36 @@ async function HashPassword(target) {
89
90
  console.log(dim(" The hash is salted — running this again for the same password gives a different, equally valid hash."));
90
91
  }
91
92
  }
93
+ async function ProjectToken(mode) {
94
+ const { red, green, yellow, dim, bold } = (0, cliCommon_1.palette)();
95
+ if (!process_1.stdin.isTTY) {
96
+ console.error(red("✗ project-token needs an interactive terminal — its output is a secret and must not land in CI logs."));
97
+ process.exit(1);
98
+ }
99
+ let token;
100
+ if (mode === "generate") {
101
+ token = crypto_1.default.randomBytes(32).toString("hex");
102
+ }
103
+ else {
104
+ console.log(bold("\nHash an existing project token") + dim(" (the project config on the deployer)"));
105
+ token = (await askHidden("Token: ")).trim();
106
+ if (!token) {
107
+ console.error(red("✗ Token is required."));
108
+ process.exit(1);
109
+ }
110
+ if (token.length < 32)
111
+ console.log(yellow(` ⚠ This token is short (${token.length} chars). Consider generating a new one: npx badmfck project-token`));
112
+ }
113
+ const hash = await PasswordHash_1.PasswordHash.hash(token);
114
+ console.log("");
115
+ if (mode === "generate") {
116
+ console.log(green(bold("✓ New project token")));
117
+ console.log(`\n deploy.json (your project, keep out of git): "token": ${JSON.stringify(token)}`);
118
+ console.log(` project config on the deployer: "token": ${JSON.stringify(hash)}\n`);
119
+ }
120
+ else {
121
+ console.log(green(bold("✓ Put this in the project config on the deployer instead of the plain token:")));
122
+ console.log(`\n "token": ${JSON.stringify(hash)}\n`);
123
+ }
124
+ console.log(dim(" The hash is salted — running this again gives a different, equally valid hash."));
125
+ }
@@ -2,6 +2,13 @@ import { BaseService } from '../BaseService';
2
2
  export interface IDeploymentNotifier extends BaseService {
3
3
  notifyEmailStatus(email: string, status: string, project: string, user: string): Promise<void>;
4
4
  notifySMSStatus(phone: string, text: string, user: string): Promise<void>;
5
+ notifyReview(email: string, info: {
6
+ project: string;
7
+ user: string;
8
+ link: string;
9
+ expiresAt: number;
10
+ mode: "any" | "all";
11
+ }): Promise<boolean>;
5
12
  }
6
13
  export declare class Notifier extends BaseService implements IDeploymentNotifier {
7
14
  SMS_URL: string;
@@ -12,5 +19,12 @@ export declare class Notifier extends BaseService implements IDeploymentNotifier
12
19
  });
13
20
  init(): Promise<void>;
14
21
  notifyEmailStatus(email: string, status: string, project: string, user: string): Promise<void>;
22
+ notifyReview(email: string, info: {
23
+ project: string;
24
+ user: string;
25
+ link: string;
26
+ expiresAt: number;
27
+ mode: "any" | "all";
28
+ }): Promise<boolean>;
15
29
  notifySMSStatus(phone: string, text: string, user: string): Promise<void>;
16
30
  }
@@ -37,6 +37,28 @@ class Notifier extends BaseService_1.BaseService {
37
37
  (0, LogService_1.logError)(e);
38
38
  }
39
39
  }
40
+ async notifyReview(email, info) {
41
+ const esc = (v) => String(v).replace(/[&<>"']/g, c => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
42
+ const title = `Deploy review: ${info.project} (uploaded by ${info.user})`;
43
+ const text = `<p><b>${esc(info.user)}</b> uploaded a new version of <b>${esc(info.project)}</b>. It is not deployed until it is reviewed`
44
+ + (info.mode === "all" ? " by every reviewer" : "") + `.</p>`
45
+ + `<p><a href="${esc(info.link)}">Review the changes</a> — sign in with your reviewer login, password and 2FA code.</p>`
46
+ + `<p>The link is personal and valid until ${esc(new Date(info.expiresAt).toISOString())}, or until a newer upload replaces it. `
47
+ + `Don't forward it. If you didn't expect this, decline and tell the team.</p>`;
48
+ const token = (0, crypto_1.createHash)("sha256").update(this.SMS_KEY + email + title + text).digest("base64");
49
+ try {
50
+ const response = await __1.Http.post(this.SMS_URL + "/api/mail/send", { to: email, text: title, html: text }, {
51
+ headers: { "authorization": token, "Content-Type": "application/json" }
52
+ });
53
+ if (!response.ok)
54
+ (0, LogService_1.logError)(`Review mail to ${email} failed: HTTP ${response.status ?? "network error"}`);
55
+ return response.ok;
56
+ }
57
+ catch (e) {
58
+ (0, LogService_1.logError)(e);
59
+ return false;
60
+ }
61
+ }
40
62
  async notifySMSStatus(phone, text, user) {
41
63
  const finalText = `${text} (by ${user})`;
42
64
  const token = (0, crypto_1.createHash)("sha256").update(this.SMS_KEY + phone + finalText + "").digest("base64");
@@ -0,0 +1,62 @@
1
+ import { UploadedFile } from "express-fileupload";
2
+ export interface IReviewDecision {
3
+ tokenHash: string;
4
+ decision: "accept" | "decline" | null;
5
+ at: number | null;
6
+ ip: string | null;
7
+ }
8
+ export type TReviewState = "pending" | "deploying" | "deployed" | "failed" | "declined" | "expired";
9
+ export interface IPendingReview {
10
+ project: string;
11
+ state: TReviewState;
12
+ result?: {
13
+ at: number;
14
+ message: string;
15
+ slot?: string | null;
16
+ activeThisDeploy?: boolean;
17
+ };
18
+ sha256: string;
19
+ size: number;
20
+ uploadedBy: string;
21
+ uploadedFrom: string | null;
22
+ uploadedAt: number;
23
+ expiresAt: number;
24
+ mode: "any" | "all";
25
+ reviewers: Record<string, IReviewDecision>;
26
+ }
27
+ export declare class ReviewStore {
28
+ readonly dir: string;
29
+ constructor(projectsPath: string);
30
+ static hashToken(token: string): string;
31
+ private file;
32
+ archivePath(project: string): string;
33
+ lastArchivePath(project: string): string;
34
+ private ensureDir;
35
+ private static sha256File;
36
+ private writeJson;
37
+ create(project: string, file: UploadedFile, meta: {
38
+ uploadedBy: string;
39
+ uploadedFrom: string | null;
40
+ mode: "any" | "all";
41
+ reviewers: string[];
42
+ ttlMs: number;
43
+ }): Promise<{
44
+ pending: IPendingReview;
45
+ tokens: Record<string, string>;
46
+ replaced: boolean;
47
+ }>;
48
+ get(project: string): IPendingReview | null;
49
+ save(pending: IPendingReview): void;
50
+ findByToken(token: string): {
51
+ pending: IPendingReview;
52
+ reviewer: string;
53
+ } | null;
54
+ archiveIntact(pending: IPendingReview): Promise<boolean>;
55
+ journal(project: string, event: string, details: Record<string, unknown>): void;
56
+ dropArchive(project: string): void;
57
+ sweep(): string[];
58
+ remove(project: string): void;
59
+ stageBaseline(project: string, archive: string): void;
60
+ commitBaseline(project: string): void;
61
+ dropStagedBaseline(project: string): void;
62
+ }
@@ -0,0 +1,186 @@
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.ReviewStore = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const crypto_1 = __importDefault(require("crypto"));
10
+ const NAME_RE = /^[A-Za-z0-9._-]+$/;
11
+ class ReviewStore {
12
+ dir;
13
+ constructor(projectsPath) {
14
+ this.dir = path_1.default.resolve(projectsPath, ".review");
15
+ }
16
+ static hashToken(token) {
17
+ return crypto_1.default.createHash("sha256").update(String(token)).digest("hex");
18
+ }
19
+ file(project, kind) {
20
+ if (!NAME_RE.test(project))
21
+ throw new Error("invalid project name");
22
+ return path_1.default.join(this.dir, `${project}.${kind}`);
23
+ }
24
+ archivePath(project) { return this.file(project, "pending.tgz"); }
25
+ lastArchivePath(project) { return this.file(project, "last.tgz"); }
26
+ ensureDir() {
27
+ fs_1.default.mkdirSync(this.dir, { recursive: true, mode: 0o700 });
28
+ }
29
+ static sha256File(file) {
30
+ return new Promise((resolve, reject) => {
31
+ const h = crypto_1.default.createHash("sha256");
32
+ fs_1.default.createReadStream(file).on("data", d => h.update(d)).on("error", reject).on("end", () => resolve(h.digest("hex")));
33
+ });
34
+ }
35
+ writeJson(file, value) {
36
+ const tmp = file + ".tmp";
37
+ fs_1.default.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf-8", mode: 0o600 });
38
+ fs_1.default.renameSync(tmp, file);
39
+ }
40
+ async create(project, file, meta) {
41
+ this.ensureDir();
42
+ const replaced = this.get(project) !== null;
43
+ this.remove(project);
44
+ const archive = this.archivePath(project);
45
+ await new Promise((resolve, reject) => file.mv(archive, (err) => err ? reject(err) : resolve()));
46
+ fs_1.default.chmodSync(archive, 0o600);
47
+ const tokens = {};
48
+ const reviewers = {};
49
+ for (const login of meta.reviewers) {
50
+ const token = crypto_1.default.randomBytes(32).toString("base64url");
51
+ tokens[login] = token;
52
+ reviewers[login] = { tokenHash: ReviewStore.hashToken(token), decision: null, at: null, ip: null };
53
+ }
54
+ const now = Date.now();
55
+ const pending = {
56
+ project,
57
+ state: "pending",
58
+ sha256: await ReviewStore.sha256File(archive),
59
+ size: fs_1.default.statSync(archive).size,
60
+ uploadedBy: meta.uploadedBy,
61
+ uploadedFrom: meta.uploadedFrom,
62
+ uploadedAt: now,
63
+ expiresAt: now + meta.ttlMs,
64
+ mode: meta.mode,
65
+ reviewers,
66
+ };
67
+ this.writeJson(this.file(project, "pending.json"), pending);
68
+ return { pending, tokens, replaced };
69
+ }
70
+ get(project) {
71
+ try {
72
+ const p = JSON.parse(fs_1.default.readFileSync(this.file(project, "pending.json"), "utf-8"));
73
+ return p && typeof p === "object" && p.project === project ? p : null;
74
+ }
75
+ catch {
76
+ return null;
77
+ }
78
+ }
79
+ save(pending) {
80
+ this.writeJson(this.file(pending.project, "pending.json"), pending);
81
+ }
82
+ findByToken(token) {
83
+ if (typeof token !== "string" || token.length < 20 || token.length > 200)
84
+ return null;
85
+ const hash = Buffer.from(ReviewStore.hashToken(token), "hex");
86
+ let entries;
87
+ try {
88
+ entries = fs_1.default.readdirSync(this.dir);
89
+ }
90
+ catch {
91
+ return null;
92
+ }
93
+ for (const f of entries) {
94
+ if (!f.endsWith(".pending.json"))
95
+ continue;
96
+ const pending = this.get(f.slice(0, -".pending.json".length));
97
+ if (!pending || pending.expiresAt < Date.now())
98
+ continue;
99
+ for (const [login, r] of Object.entries(pending.reviewers)) {
100
+ const stored = Buffer.from(String(r.tokenHash), "hex");
101
+ if (stored.length === hash.length && crypto_1.default.timingSafeEqual(stored, hash))
102
+ return { pending, reviewer: login };
103
+ }
104
+ }
105
+ return null;
106
+ }
107
+ async archiveIntact(pending) {
108
+ try {
109
+ return (await ReviewStore.sha256File(this.archivePath(pending.project))) === pending.sha256;
110
+ }
111
+ catch {
112
+ return false;
113
+ }
114
+ }
115
+ journal(project, event, details) {
116
+ try {
117
+ this.ensureDir();
118
+ const file = path_1.default.join(this.dir, `${project}.history.jsonl`);
119
+ if (!NAME_RE.test(project))
120
+ return;
121
+ try {
122
+ if (fs_1.default.statSync(file).size > 1024 * 1024)
123
+ fs_1.default.renameSync(file, file + ".1");
124
+ }
125
+ catch { }
126
+ fs_1.default.appendFileSync(file, JSON.stringify({ at: new Date().toISOString(), event, ...details }) + "\n", { encoding: "utf-8", mode: 0o600 });
127
+ }
128
+ catch { }
129
+ }
130
+ dropArchive(project) {
131
+ try {
132
+ fs_1.default.rmSync(this.archivePath(project), { force: true });
133
+ }
134
+ catch { }
135
+ }
136
+ sweep() {
137
+ const expired = [];
138
+ let entries;
139
+ try {
140
+ entries = fs_1.default.readdirSync(this.dir);
141
+ }
142
+ catch {
143
+ return expired;
144
+ }
145
+ for (const f of entries) {
146
+ if (!f.endsWith(".pending.json"))
147
+ continue;
148
+ const pending = this.get(f.slice(0, -".pending.json".length));
149
+ if (!pending || pending.state !== "pending" || pending.expiresAt >= Date.now())
150
+ continue;
151
+ pending.state = "expired";
152
+ pending.result = { at: Date.now(), message: "Nobody decided in time — upload again to restart the review." };
153
+ this.save(pending);
154
+ this.dropArchive(pending.project);
155
+ this.journal(pending.project, "expired", { sha256: pending.sha256 });
156
+ expired.push(pending.project);
157
+ }
158
+ return expired;
159
+ }
160
+ remove(project) {
161
+ for (const kind of ["pending.json", "pending.tgz"])
162
+ try {
163
+ fs_1.default.rmSync(this.file(project, kind), { force: true });
164
+ }
165
+ catch { }
166
+ }
167
+ stageBaseline(project, archive) {
168
+ this.ensureDir();
169
+ const incoming = this.file(project, "incoming.tgz");
170
+ fs_1.default.copyFileSync(archive, incoming);
171
+ fs_1.default.chmodSync(incoming, 0o600);
172
+ }
173
+ commitBaseline(project) {
174
+ try {
175
+ fs_1.default.renameSync(this.file(project, "incoming.tgz"), this.lastArchivePath(project));
176
+ }
177
+ catch { }
178
+ }
179
+ dropStagedBaseline(project) {
180
+ try {
181
+ fs_1.default.rmSync(this.file(project, "incoming.tgz"), { force: true });
182
+ }
183
+ catch { }
184
+ }
185
+ }
186
+ exports.ReviewStore = ReviewStore;
@@ -0,0 +1,21 @@
1
+ export interface ISecretsSettings {
2
+ dir?: string;
3
+ file?: string;
4
+ }
5
+ export declare class SecretsInjector {
6
+ static resolvePath(project: string, slot: string | null, settings: ISecretsSettings | undefined, defaultDir: string | undefined, destinationRoot: string): {
7
+ path?: string;
8
+ error?: string;
9
+ };
10
+ static write(file: string, values: Record<string, unknown>): void;
11
+ static verify(file: string, values: Record<string, unknown>): string | null;
12
+ static expression(file: string, key: string): string;
13
+ static transform(source: string, keys: Set<string>, file: string): {
14
+ content: string;
15
+ rewritten: number;
16
+ leftover: boolean;
17
+ };
18
+ private static endsInBlockComment;
19
+ private static rewriteLiteral;
20
+ static parses(source: string): boolean;
21
+ }
@@ -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.SecretsInjector = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const vm_1 = __importDefault(require("vm"));
10
+ const PLACEHOLDER = /_\{\{([A-Za-z0-9_]+)\}\}_/g;
11
+ class SecretsInjector {
12
+ static resolvePath(project, slot, settings, defaultDir, destinationRoot) {
13
+ const file = settings?.file?.trim(), dir = (settings?.dir?.trim() || defaultDir?.trim() || "");
14
+ let target;
15
+ if (file) {
16
+ if (!path_1.default.isAbsolute(file))
17
+ return { error: `secrets.file must be an absolute path ("${file}")` };
18
+ const ext = path_1.default.extname(file) || ".json";
19
+ target = slot ? path_1.default.join(path_1.default.dirname(file), `${path_1.default.basename(file, path_1.default.extname(file))}-${slot}${ext}`) : file;
20
+ }
21
+ else if (dir) {
22
+ if (!path_1.default.isAbsolute(dir))
23
+ return { error: `the secrets directory must be an absolute path ("${dir}")` };
24
+ target = path_1.default.join(dir, `${project}${slot ? "-" + slot : ""}.json`);
25
+ }
26
+ else {
27
+ return { error: "secrets is enabled, but neither secrets.dir / secrets.file nor secrets_dir in setup.json is set" };
28
+ }
29
+ target = path_1.default.resolve(target);
30
+ const root = path_1.default.resolve(destinationRoot);
31
+ if (target === root || target.startsWith(root + path_1.default.sep))
32
+ return { error: `the secrets file must live outside the deploy folder ("${target}" is inside "${root}")` };
33
+ return { path: target };
34
+ }
35
+ static write(file, values) {
36
+ fs_1.default.mkdirSync(path_1.default.dirname(file), { recursive: true, mode: 0o700 });
37
+ const tmp = file + ".tmp";
38
+ fs_1.default.writeFileSync(tmp, JSON.stringify(values, null, 2), { encoding: "utf-8", mode: 0o600 });
39
+ fs_1.default.chmodSync(tmp, 0o600);
40
+ fs_1.default.renameSync(tmp, file);
41
+ }
42
+ static verify(file, values) {
43
+ try {
44
+ fs_1.default.accessSync(file, fs_1.default.constants.R_OK);
45
+ const back = JSON.parse(fs_1.default.readFileSync(file, "utf-8"));
46
+ const missing = Object.keys(values).filter(k => !Object.prototype.hasOwnProperty.call(back, k));
47
+ return missing.length ? `${file} lacks ${missing.join(", ")}` : null;
48
+ }
49
+ catch (e) {
50
+ return `${file} is not readable: ${e?.message ?? e}`;
51
+ }
52
+ }
53
+ static expression(file, key) {
54
+ const p = JSON.stringify(file);
55
+ return `(function(k){var s=globalThis.__badmfckSecrets||(globalThis.__badmfckSecrets=JSON.parse(require("fs").readFileSync(${p},"utf8")));`
56
+ + `if(!Object.prototype.hasOwnProperty.call(s,k))throw new Error("secret \\""+k+"\\" is missing in "+${p});return String(s[k]);})(${JSON.stringify(key)})`;
57
+ }
58
+ static transform(source, keys, file) {
59
+ let rewritten = 0, inBlockComment = false;
60
+ const lines = source.split("\n");
61
+ for (let n = 0; n < lines.length; n++) {
62
+ const line = lines[n];
63
+ if (!inBlockComment && line.indexOf("_{{") === -1) {
64
+ inBlockComment = SecretsInjector.endsInBlockComment(line, false);
65
+ continue;
66
+ }
67
+ const defuse = (text) => text.replace(/_\{\{/g, "_{ {");
68
+ let out = "", i = 0;
69
+ while (i < line.length) {
70
+ if (inBlockComment) {
71
+ const end = line.indexOf("*/", i);
72
+ if (end === -1) {
73
+ out += defuse(line.slice(i));
74
+ i = line.length;
75
+ break;
76
+ }
77
+ out += defuse(line.slice(i, end + 2));
78
+ i = end + 2;
79
+ inBlockComment = false;
80
+ continue;
81
+ }
82
+ const c = line[i];
83
+ if (c === "/" && line[i + 1] === "/") {
84
+ out += defuse(line.slice(i));
85
+ i = line.length;
86
+ break;
87
+ }
88
+ if (c === "/" && line[i + 1] === "*") {
89
+ inBlockComment = true;
90
+ out += "/*";
91
+ i += 2;
92
+ continue;
93
+ }
94
+ if (c === '"' || c === "'" || c === "`") {
95
+ let j = i + 1;
96
+ while (j < line.length && line[j] !== c)
97
+ j += line[j] === "\\" ? 2 : 1;
98
+ if (j >= line.length) {
99
+ out += line.slice(i);
100
+ i = line.length;
101
+ break;
102
+ }
103
+ const literal = line.slice(i, j + 1);
104
+ const rep = SecretsInjector.rewriteLiteral(literal, c, keys, file);
105
+ if (rep !== literal)
106
+ rewritten++;
107
+ out += rep;
108
+ i = j + 1;
109
+ continue;
110
+ }
111
+ out += c;
112
+ i++;
113
+ }
114
+ lines[n] = out;
115
+ }
116
+ const content = lines.join("\n");
117
+ let leftover = false;
118
+ for (const m of content.matchAll(PLACEHOLDER))
119
+ if (keys.has(m[1])) {
120
+ leftover = true;
121
+ break;
122
+ }
123
+ return { content, rewritten, leftover };
124
+ }
125
+ static endsInBlockComment(line, open) {
126
+ let i = 0;
127
+ while (i < line.length) {
128
+ if (open) {
129
+ const e = line.indexOf("*/", i);
130
+ if (e === -1)
131
+ return true;
132
+ open = false;
133
+ i = e + 2;
134
+ continue;
135
+ }
136
+ const c = line[i];
137
+ if (c === "/" && line[i + 1] === "/")
138
+ return false;
139
+ if (c === "/" && line[i + 1] === "*") {
140
+ open = true;
141
+ i += 2;
142
+ continue;
143
+ }
144
+ if (c === '"' || c === "'" || c === "`") {
145
+ let j = i + 1;
146
+ while (j < line.length && line[j] !== c)
147
+ j += line[j] === "\\" ? 2 : 1;
148
+ i = j + 1;
149
+ continue;
150
+ }
151
+ i++;
152
+ }
153
+ return open;
154
+ }
155
+ static rewriteLiteral(literal, quote, keys, file) {
156
+ const body = literal.slice(1, -1);
157
+ if (quote === "`" && body.includes("${"))
158
+ return literal;
159
+ const parts = [];
160
+ let last = 0, found = false;
161
+ for (const m of body.matchAll(PLACEHOLDER)) {
162
+ if (!keys.has(m[1]))
163
+ continue;
164
+ found = true;
165
+ const before = body.slice(last, m.index);
166
+ if (before)
167
+ parts.push(quote + before + quote);
168
+ parts.push(SecretsInjector.expression(file, m[1]));
169
+ last = m.index + m[0].length;
170
+ }
171
+ if (!found)
172
+ return literal;
173
+ const after = body.slice(last);
174
+ if (after)
175
+ parts.push(quote + after + quote);
176
+ return "(" + (parts.length === 1 ? parts[0] : `""+` + parts.join("+")) + ")";
177
+ }
178
+ static parses(source) {
179
+ try {
180
+ new vm_1.default.Script(`(function (exports, require, module, __filename, __dirname) {${source}\n})`);
181
+ return true;
182
+ }
183
+ catch {
184
+ return false;
185
+ }
186
+ }
187
+ }
188
+ exports.SecretsInjector = SecretsInjector;
@@ -16,6 +16,7 @@ function usage() {
16
16
  console.error(" badmfck backups [config.json] — list deploy backups");
17
17
  console.error(" badmfck restore [config.json] [backup] [--yes] — restore a backup (asks which, and confirms)");
18
18
  console.error(" badmfck hash-password [--deployer] — hash a password for the monitor (or deployer setup.json)");
19
+ console.error(" badmfck project-token [--hash] — new project token + its hash (or hash an existing one)");
19
20
  console.error("");
20
21
  console.error("Config path is optional (auto-discovers deploy/ folder → deploy.json when omitted).");
21
22
  console.error("Via npm, prefix args with -- e.g. npm run deploy -- deploy/custom.json");
@@ -102,6 +103,15 @@ async function main() {
102
103
  await (0, HashPassword_1.HashPassword)(rest.includes("--deployer") ? "deployer" : "monitor");
103
104
  break;
104
105
  }
106
+ case "project-token": {
107
+ const unknown = rest.filter(a => a !== "--hash");
108
+ if (unknown.length) {
109
+ console.error("project-token takes no arguments except --hash — an existing token is asked interactively.");
110
+ process.exit(1);
111
+ }
112
+ await (0, HashPassword_1.ProjectToken)(rest.includes("--hash") ? "hash" : "generate");
113
+ break;
114
+ }
105
115
  case "status": {
106
116
  const { scheme, config } = parseArgs(rest);
107
117
  if (scheme) {
@@ -0,0 +1,23 @@
1
+ import { APIServiceOptions } from "../APIService";
2
+ import { BaseEndpoint } from "../BaseEndpoint";
3
+ import { HTTPRequestVO, TransferPacketVO } from "../structures/Interfaces";
4
+ import { DeployerService } from "../deployment/DeployerService";
5
+ export declare class Review extends BaseEndpoint {
6
+ private deployer;
7
+ private apiServiceOptions;
8
+ ignoreInDocumentation: boolean;
9
+ private indexHtmlFile;
10
+ private auth;
11
+ constructor(deployer: DeployerService, apiServiceOptions: APIServiceOptions);
12
+ private gate;
13
+ private session;
14
+ private static view;
15
+ html(req: HTTPRequestVO): Promise<TransferPacketVO>;
16
+ info(req: HTTPRequestVO): Promise<TransferPacketVO>;
17
+ login(req: HTTPRequestVO): Promise<TransferPacketVO>;
18
+ enroll2fa(req: HTTPRequestVO): Promise<TransferPacketVO>;
19
+ details(req: HTTPRequestVO): Promise<TransferPacketVO>;
20
+ diff(req: HTTPRequestVO): Promise<TransferPacketVO>;
21
+ decide(req: HTTPRequestVO): Promise<TransferPacketVO>;
22
+ logout(req: HTTPRequestVO): Promise<TransferPacketVO>;
23
+ }