@bmfk/api 0.0.0-stage → 1.0.1
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/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +1293 -2
- package/dist/apiServer/APIService.d.ts +125 -0
- package/dist/apiServer/APIService.js +769 -0
- package/dist/apiServer/BaseEndpoint.d.ts +90 -0
- package/dist/apiServer/BaseEndpoint.js +314 -0
- package/dist/apiServer/BaseService.d.ts +17 -0
- package/dist/apiServer/BaseService.js +39 -0
- package/dist/apiServer/DBService.d.ts +131 -0
- package/dist/apiServer/DBService.js +290 -0
- package/dist/apiServer/DocumentService.d.ts +9 -0
- package/dist/apiServer/DocumentService.js +65 -0
- package/dist/apiServer/LocalRequest.d.ts +3 -0
- package/dist/apiServer/LocalRequest.js +6 -0
- package/dist/apiServer/LogService.d.ts +78 -0
- package/dist/apiServer/LogService.js +349 -0
- package/dist/apiServer/MonitorService.d.ts +102 -0
- package/dist/apiServer/MonitorService.js +615 -0
- package/dist/apiServer/StatService.d.ts +4 -0
- package/dist/apiServer/StatService.js +10 -0
- package/dist/apiServer/TimeframeService.d.ts +28 -0
- package/dist/apiServer/TimeframeService.js +97 -0
- package/dist/apiServer/WebSocketServer.d.ts +39 -0
- package/dist/apiServer/WebSocketServer.js +173 -0
- package/dist/apiServer/db/IDBAdapter.d.ts +14 -0
- package/dist/apiServer/db/IDBAdapter.js +2 -0
- package/dist/apiServer/db/MysqlAdapter.d.ts +72 -0
- package/dist/apiServer/db/MysqlAdapter.js +869 -0
- package/dist/apiServer/db/PostgresAdapter.d.ts +41 -0
- package/dist/apiServer/db/PostgresAdapter.js +73 -0
- package/dist/apiServer/deployment/AccessConfigWizard.d.ts +5 -0
- package/dist/apiServer/deployment/AccessConfigWizard.js +254 -0
- package/dist/apiServer/deployment/Activate.d.ts +4 -0
- package/dist/apiServer/deployment/Activate.js +124 -0
- package/dist/apiServer/deployment/BackupManager.d.ts +33 -0
- package/dist/apiServer/deployment/BackupManager.js +174 -0
- package/dist/apiServer/deployment/Backups.d.ts +2 -0
- package/dist/apiServer/deployment/Backups.js +44 -0
- package/dist/apiServer/deployment/BlueGreenState.d.ts +31 -0
- package/dist/apiServer/deployment/BlueGreenState.js +150 -0
- package/dist/apiServer/deployment/Bundler.d.ts +12 -0
- package/dist/apiServer/deployment/Bundler.js +178 -0
- package/dist/apiServer/deployment/ConfigService.d.ts +203 -0
- package/dist/apiServer/deployment/ConfigService.js +195 -0
- package/dist/apiServer/deployment/Deploy.d.ts +4 -0
- package/dist/apiServer/deployment/Deploy.js +404 -0
- package/dist/apiServer/deployment/DeployKeyWizard.d.ts +2 -0
- package/dist/apiServer/deployment/DeployKeyWizard.js +84 -0
- package/dist/apiServer/deployment/Deployer.d.ts +13 -0
- package/dist/apiServer/deployment/Deployer.js +96 -0
- package/dist/apiServer/deployment/DeployerInit.d.ts +25 -0
- package/dist/apiServer/deployment/DeployerInit.js +214 -0
- package/dist/apiServer/deployment/DeployerService.d.ts +378 -0
- package/dist/apiServer/deployment/DeployerService.js +1553 -0
- package/dist/apiServer/deployment/HashPassword.d.ts +3 -0
- package/dist/apiServer/deployment/HashPassword.js +126 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.d.ts +1 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.js +202 -0
- package/dist/apiServer/deployment/MigrateProject.d.ts +31 -0
- package/dist/apiServer/deployment/MigrateProject.js +335 -0
- package/dist/apiServer/deployment/NginxHelper.d.ts +10 -0
- package/dist/apiServer/deployment/NginxHelper.js +111 -0
- package/dist/apiServer/deployment/Notifier.d.ts +30 -0
- package/dist/apiServer/deployment/Notifier.js +82 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.js +148 -0
- package/dist/apiServer/deployment/Restore.d.ts +2 -0
- package/dist/apiServer/deployment/Restore.js +89 -0
- package/dist/apiServer/deployment/ReviewStore.d.ts +62 -0
- package/dist/apiServer/deployment/ReviewStore.js +186 -0
- package/dist/apiServer/deployment/SecretsInjector.d.ts +21 -0
- package/dist/apiServer/deployment/SecretsInjector.js +189 -0
- package/dist/apiServer/deployment/SetupConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/SetupConfigWizard.js +238 -0
- package/dist/apiServer/deployment/Status.d.ts +2 -0
- package/dist/apiServer/deployment/Status.js +83 -0
- package/dist/apiServer/deployment/TelegramNotifier.d.ts +8 -0
- package/dist/apiServer/deployment/TelegramNotifier.js +23 -0
- package/dist/apiServer/deployment/Watchdog.d.ts +15 -0
- package/dist/apiServer/deployment/Watchdog.js +65 -0
- package/dist/apiServer/deployment/Wizards.d.ts +1 -0
- package/dist/apiServer/deployment/Wizards.js +83 -0
- package/dist/apiServer/deployment/cli.d.ts +2 -0
- package/dist/apiServer/deployment/cli.js +224 -0
- package/dist/apiServer/deployment/cliCommon.d.ts +27 -0
- package/dist/apiServer/deployment/cliCommon.js +110 -0
- package/dist/apiServer/deployment/cliPrompt.d.ts +5 -0
- package/dist/apiServer/deployment/cliPrompt.js +38 -0
- package/dist/apiServer/deployment/resolveConfig.d.ts +19 -0
- package/dist/apiServer/deployment/resolveConfig.js +139 -0
- package/dist/apiServer/documentation/Documentation.d.ts +18 -0
- package/dist/apiServer/documentation/Documentation.js +143 -0
- package/dist/apiServer/documentation/index.html +460 -0
- package/dist/apiServer/external/MicroserviceClient.d.ts +28 -0
- package/dist/apiServer/external/MicroserviceClient.js +144 -0
- package/dist/apiServer/external/MicroserviceHost.d.ts +52 -0
- package/dist/apiServer/external/MicroserviceHost.js +183 -0
- package/dist/apiServer/external/MicroserviceHostController.d.ts +6 -0
- package/dist/apiServer/external/MicroserviceHostController.js +65 -0
- package/dist/apiServer/helper/AppDataPath.d.ts +9 -0
- package/dist/apiServer/helper/AppDataPath.js +81 -0
- package/dist/apiServer/helper/ClientIp.d.ts +3 -0
- package/dist/apiServer/helper/ClientIp.js +33 -0
- package/dist/apiServer/helper/DataProvider.d.ts +18 -0
- package/dist/apiServer/helper/DataProvider.js +57 -0
- package/dist/apiServer/helper/IpAllowList.d.ts +8 -0
- package/dist/apiServer/helper/IpAllowList.js +40 -0
- package/dist/apiServer/helper/JSONStableStringify.d.ts +1 -0
- package/dist/apiServer/helper/JSONStableStringify.js +15 -0
- package/dist/apiServer/helper/PasswordHash.d.ts +5 -0
- package/dist/apiServer/helper/PasswordHash.js +52 -0
- package/dist/apiServer/helper/Sleep.d.ts +1 -0
- package/dist/apiServer/helper/Sleep.js +5 -0
- package/dist/apiServer/helper/Trace.d.ts +8 -0
- package/dist/apiServer/helper/Trace.js +30 -0
- package/dist/apiServer/helper/UID.d.ts +16 -0
- package/dist/apiServer/helper/UID.js +98 -0
- package/dist/apiServer/helper/Validator.d.ts +86 -0
- package/dist/apiServer/helper/Validator.js +560 -0
- package/dist/apiServer/helper/YYYYMMDDHH.d.ts +2 -0
- package/dist/apiServer/helper/YYYYMMDDHH.js +31 -0
- package/dist/apiServer/helper/ZipUtils.d.ts +6 -0
- package/dist/apiServer/helper/ZipUtils.js +28 -0
- package/dist/apiServer/http/Http.d.ts +183 -0
- package/dist/apiServer/http/Http.js +627 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.d.ts +19 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.js +124 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.d.ts +40 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.js +150 -0
- package/dist/apiServer/monitor/AccessStore.d.ts +27 -0
- package/dist/apiServer/monitor/AccessStore.js +163 -0
- package/dist/apiServer/monitor/LogFiles.d.ts +34 -0
- package/dist/apiServer/monitor/LogFiles.js +109 -0
- package/dist/apiServer/monitor/Monitor.d.ts +54 -0
- package/dist/apiServer/monitor/Monitor.js +447 -0
- package/dist/apiServer/monitor/MonitorAuth.d.ts +87 -0
- package/dist/apiServer/monitor/MonitorAuth.js +474 -0
- package/dist/apiServer/monitor/ProcessMonitor.d.ts +177 -0
- package/dist/apiServer/monitor/ProcessMonitor.js +468 -0
- package/dist/apiServer/monitor/SystemInfo.d.ts +70 -0
- package/dist/apiServer/monitor/SystemInfo.js +217 -0
- package/dist/apiServer/monitor/ThreatMonitor.d.ts +73 -0
- package/dist/apiServer/monitor/ThreatMonitor.js +239 -0
- package/dist/apiServer/monitor/index.html +591 -0
- package/dist/apiServer/review/Review.d.ts +23 -0
- package/dist/apiServer/review/Review.js +149 -0
- package/dist/apiServer/review/ReviewAuth.d.ts +56 -0
- package/dist/apiServer/review/ReviewAuth.js +147 -0
- package/dist/apiServer/review/ReviewDiff.d.ts +43 -0
- package/dist/apiServer/review/ReviewDiff.js +175 -0
- package/dist/apiServer/review/index.html +501 -0
- package/dist/apiServer/routes/Liveness.d.ts +7 -0
- package/dist/apiServer/routes/Liveness.js +27 -0
- package/dist/apiServer/routes/Readiness.d.ts +13 -0
- package/dist/apiServer/routes/Readiness.js +20 -0
- package/dist/apiServer/security/BlockedIps.d.ts +46 -0
- package/dist/apiServer/security/BlockedIps.js +185 -0
- package/dist/apiServer/structures/DefaultErrors.d.ts +36 -0
- package/dist/apiServer/structures/DefaultErrors.js +52 -0
- package/dist/apiServer/structures/HTTPStatus.d.ts +7 -0
- package/dist/apiServer/structures/HTTPStatus.js +11 -0
- package/dist/apiServer/structures/Interfaces.d.ts +55 -0
- package/dist/apiServer/structures/Interfaces.js +2 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +110 -0
- package/dist/signal/Signal.d.ts +23 -0
- package/dist/signal/Signal.js +85 -0
- package/package.json +88 -4
|
@@ -0,0 +1,335 @@
|
|
|
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.rootExportNames = rootExportNames;
|
|
7
|
+
exports.migrateSource = migrateSource;
|
|
8
|
+
exports.migratePackageJson = migratePackageJson;
|
|
9
|
+
exports.projectTypeScript = projectTypeScript;
|
|
10
|
+
exports.migrateModels = migrateModels;
|
|
11
|
+
exports.planMigration = planMigration;
|
|
12
|
+
exports.MigrateProject = MigrateProject;
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const cliCommon_1 = require("./cliCommon");
|
|
16
|
+
const OLD_PKG = "badmfck-api-server";
|
|
17
|
+
const OLD_SIGNAL = "badmfck-signal";
|
|
18
|
+
const NEW_PKG = "@bmfk/api";
|
|
19
|
+
const SOURCE_EXT = new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
20
|
+
const SKIP_DIRS = new Set(["node_modules", "dist", "bin", "build", "coverage", ".git", ".next", "website"]);
|
|
21
|
+
function rootExportNames(indexFile) {
|
|
22
|
+
const text = fs_1.default.readFileSync(indexFile, "utf-8");
|
|
23
|
+
const names = new Set();
|
|
24
|
+
for (const m of text.matchAll(/export\s+(?:type\s+)?\{([^}]*)\}/g))
|
|
25
|
+
for (const part of m[1].split(",")) {
|
|
26
|
+
const n = part.trim().replace(/^type\s+/, "").split(/\s+as\s+/).pop()?.trim();
|
|
27
|
+
if (n)
|
|
28
|
+
names.add(n);
|
|
29
|
+
}
|
|
30
|
+
for (const m of text.matchAll(/export\s+(?:declare\s+)?(?:const|function|class|interface|type|enum)\s+([A-Za-z_$][\w$]*)/g))
|
|
31
|
+
names.add(m[1]);
|
|
32
|
+
return names;
|
|
33
|
+
}
|
|
34
|
+
function sourceFiles(dir, out = []) {
|
|
35
|
+
for (const e of fs_1.default.readdirSync(dir, { withFileTypes: true })) {
|
|
36
|
+
if (e.isDirectory()) {
|
|
37
|
+
if (!SKIP_DIRS.has(e.name) && !e.name.startsWith("."))
|
|
38
|
+
sourceFiles(path_1.default.join(dir, e.name), out);
|
|
39
|
+
}
|
|
40
|
+
else if (e.isFile() && SOURCE_EXT.has(path_1.default.extname(e.name)) && !e.name.endsWith(".d.ts")) {
|
|
41
|
+
out.push(path_1.default.join(dir, e.name));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
const lineOf = (text, index) => text.slice(0, index).split("\n").length;
|
|
47
|
+
const isOld = (spec) => spec === OLD_PKG || spec.startsWith(OLD_PKG + "/") || spec === OLD_SIGNAL;
|
|
48
|
+
function parseNamed(braced) {
|
|
49
|
+
return braced.split(",").map(s => s.trim()).filter(Boolean).map(s => {
|
|
50
|
+
const type = /^type\s+/.test(s);
|
|
51
|
+
const [name, alias] = s.replace(/^type\s+/, "").split(/\s+as\s+/).map(x => x.trim());
|
|
52
|
+
return { name, alias, type };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const printNamed = (n) => n.map(x => (x.type ? "type " : "") + x.name + (x.alias && x.alias !== x.name ? " as " + x.alias : "")).join(", ");
|
|
56
|
+
function migrateSource(text, rel, exported) {
|
|
57
|
+
const notes = [];
|
|
58
|
+
let changes = 0;
|
|
59
|
+
const unknown = (names, at) => {
|
|
60
|
+
const missing = names.filter(n => !exported.has(n));
|
|
61
|
+
if (missing.length)
|
|
62
|
+
notes.push(`${rel}:${lineOf(text, at)} — not in ${NEW_PKG} 1.0: ${missing.join(", ")} (see docs: migration)`);
|
|
63
|
+
};
|
|
64
|
+
const importRe = /import\s+(type\s+)?((?:(?!\bfrom\b|;|\bimport\b)[\s\S])+?)\s+from\s+(["'])([^"']+)\3(\s*;)?/g;
|
|
65
|
+
let out = text.replace(importRe, (whole, typeOnly, spec, _q, from, semi, at) => {
|
|
66
|
+
if (!isOld(from))
|
|
67
|
+
return whole;
|
|
68
|
+
spec = spec.trim();
|
|
69
|
+
const deep = from !== OLD_PKG && from !== OLD_SIGNAL;
|
|
70
|
+
const star = spec.match(/^\*\s+as\s+([\w$]+)$/);
|
|
71
|
+
if (star) {
|
|
72
|
+
changes++;
|
|
73
|
+
if (new RegExp(`\\b${star[1]}\\.default\\b`).test(text))
|
|
74
|
+
notes.push(`${rel}:${lineOf(text, at)} — ${star[1]}.default: ${NEW_PKG} has no default export; use the named export`);
|
|
75
|
+
return `import ${typeOnly ?? ""}* as ${star[1]} from "${NEW_PKG}"${semi ?? ""}`;
|
|
76
|
+
}
|
|
77
|
+
const m = spec.match(/^([\w$]+)?\s*,?\s*(?:\{([\s\S]*)\})?$/);
|
|
78
|
+
if (!m) {
|
|
79
|
+
notes.push(`${rel}:${lineOf(text, at)} — import from "${from}" not understood; change it by hand`);
|
|
80
|
+
return whole;
|
|
81
|
+
}
|
|
82
|
+
const named = m[2] !== undefined ? parseNamed(m[2]) : [];
|
|
83
|
+
if (m[1]) {
|
|
84
|
+
if (from === OLD_SIGNAL || /\/Signal$/.test(from))
|
|
85
|
+
named.unshift({ name: "Signal", alias: m[1], type: false });
|
|
86
|
+
else if (/structures\/DefaultErrors$/.test(from))
|
|
87
|
+
named.unshift({ name: "DefaultErrors", alias: m[1], type: false });
|
|
88
|
+
else {
|
|
89
|
+
notes.push(`${rel}:${lineOf(text, at)} — default import "${m[1]}" from "${from}": ${NEW_PKG} has none; import the named export`);
|
|
90
|
+
return whole;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else if (deep && named.length === 0) {
|
|
94
|
+
return whole;
|
|
95
|
+
}
|
|
96
|
+
unknown(named.map(n => n.name), at);
|
|
97
|
+
changes++;
|
|
98
|
+
return `import ${typeOnly ?? ""}{ ${printNamed(named)} } from "${NEW_PKG}"${semi ?? ""}`;
|
|
99
|
+
});
|
|
100
|
+
for (const m of out.matchAll(/(?:const|let|var)\s+\{([^}]*)\}\s*=\s*require\((["'])([^"']+)\2\)/g))
|
|
101
|
+
if (isOld(m[3]))
|
|
102
|
+
unknown(m[1].split(",").map(s => s.trim().split(":")[0].trim()).filter(Boolean), m.index ?? 0);
|
|
103
|
+
for (const m of out.matchAll(/require\((["'])([^"']+)\1\)\.default\b/g))
|
|
104
|
+
if (isOld(m[2]))
|
|
105
|
+
notes.push(`${rel}:${lineOf(out, m.index ?? 0)} — require("${m[2]}").default: use the named export of ${NEW_PKG}`);
|
|
106
|
+
out = out.replace(/(require\(|import\(|from\s+)(["'])([^"']+)\2/g, (whole, head, q, spec) => {
|
|
107
|
+
if (!isOld(spec))
|
|
108
|
+
return whole;
|
|
109
|
+
changes++;
|
|
110
|
+
return `${head}${q}${NEW_PKG}${q}`;
|
|
111
|
+
});
|
|
112
|
+
for (const m of out.matchAll(/\bsecurityKey\s*:/g))
|
|
113
|
+
notes.push(`${rel}:${lineOf(out, m.index ?? 0)} — securityKey: shared-key microservice calls are gone; give the caller and the host keys (npx bmfk ms-key: kid, privateKey, hostPublicKey on the client; privateKey, clients on the host)`);
|
|
114
|
+
for (const m of out.matchAll(/new\s+Signal(?:<[^>]*>)?\(\s*[^()]*,/g))
|
|
115
|
+
notes.push(`${rel}:${lineOf(out, m.index ?? 0)} — new Signal(name, …): only the name is taken now; subscribe the handler with .subscribe()`);
|
|
116
|
+
return { text: out, changes, notes };
|
|
117
|
+
}
|
|
118
|
+
function migratePackageJson(text) {
|
|
119
|
+
const pkg = JSON.parse(text);
|
|
120
|
+
const notes = [];
|
|
121
|
+
let changes = 0;
|
|
122
|
+
for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
|
|
123
|
+
const deps = pkg[field];
|
|
124
|
+
if (!deps)
|
|
125
|
+
continue;
|
|
126
|
+
if (deps[OLD_PKG] !== undefined) {
|
|
127
|
+
const next = {};
|
|
128
|
+
for (const [k, v] of Object.entries(deps)) {
|
|
129
|
+
if (k === OLD_PKG)
|
|
130
|
+
next[NEW_PKG] = "^1.0.0";
|
|
131
|
+
else
|
|
132
|
+
next[k] = v;
|
|
133
|
+
}
|
|
134
|
+
pkg[field] = next;
|
|
135
|
+
changes++;
|
|
136
|
+
}
|
|
137
|
+
if (pkg[field][OLD_SIGNAL] !== undefined) {
|
|
138
|
+
delete pkg[field][OLD_SIGNAL];
|
|
139
|
+
changes++;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const scripts = pkg.scripts ?? {};
|
|
143
|
+
for (const [name, cmd] of Object.entries(scripts)) {
|
|
144
|
+
let next = cmd.replace(/node\s+-e\s+(['"])require\(\\?["']badmfck-api-server\\?["']\)\.(Deploy|Activate)\(\s*(?:\\?["']([^"'\\]*)\\?["'])?\s*\)\s*;?\s*\1/g, (_w, _q, fn, cfg) => `bmfk ${fn.toLowerCase()}${cfg ? " " + cfg : ""}`);
|
|
145
|
+
next = next.replace(/(^|[\s;&|(])badmfck(?=\s|$)/g, "$1bmfk");
|
|
146
|
+
if (next !== cmd) {
|
|
147
|
+
scripts[name] = next;
|
|
148
|
+
changes++;
|
|
149
|
+
}
|
|
150
|
+
if (next.includes(OLD_PKG))
|
|
151
|
+
notes.push(`package.json scripts.${name} still mentions ${OLD_PKG}: "${next}" — change it by hand`);
|
|
152
|
+
}
|
|
153
|
+
const node = String(pkg.engines?.node ?? "");
|
|
154
|
+
const major = Number(node.match(/(\d+)/)?.[1]);
|
|
155
|
+
if (node && major < 24)
|
|
156
|
+
notes.push(`package.json engines.node is "${node}" — ${NEW_PKG} needs Node.js 24 or later`);
|
|
157
|
+
const indent = text.match(/^[ \t]+(?=")/m)?.[0] ?? " ";
|
|
158
|
+
return { text: JSON.stringify(pkg, null, indent) + (text.endsWith("\n") ? "\n" : ""), changes, notes };
|
|
159
|
+
}
|
|
160
|
+
function projectTypeScript(dir) {
|
|
161
|
+
try {
|
|
162
|
+
const ts = require(require.resolve("typescript", { paths: [dir] }));
|
|
163
|
+
return typeof ts.createSourceFile === "function" ? ts : null;
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const isIdentifier = (s) => /^[A-Za-z_$][\w$]*$/.test(s);
|
|
170
|
+
function migrateModels(text, rel, ts) {
|
|
171
|
+
const kind = /\.(tsx|jsx)$/.test(rel) ? ts.ScriptKind.TSX : /\.(js|mjs|cjs)$/.test(rel) ? ts.ScriptKind.JS : ts.ScriptKind.TS;
|
|
172
|
+
const sf = ts.createSourceFile(rel, text, ts.ScriptTarget.Latest, true, kind);
|
|
173
|
+
const notes = [];
|
|
174
|
+
const edits = [];
|
|
175
|
+
const roots = new Set();
|
|
176
|
+
const consts = new Map();
|
|
177
|
+
const unwrap = (e) => {
|
|
178
|
+
while (ts.isAsExpression(e) || ts.isParenthesizedExpression(e) || (ts.isSatisfiesExpression && ts.isSatisfiesExpression(e)))
|
|
179
|
+
e = e.expression;
|
|
180
|
+
return e;
|
|
181
|
+
};
|
|
182
|
+
const nameOf = (n) => ts.isIdentifier(n) || ts.isStringLiteral(n) || ts.isNumericLiteral(n) ? n.text : null;
|
|
183
|
+
const named = [];
|
|
184
|
+
const collect = (node) => {
|
|
185
|
+
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
|
|
186
|
+
const init = unwrap(node.initializer);
|
|
187
|
+
if (ts.isObjectLiteralExpression(init))
|
|
188
|
+
consts.set(node.name.text, init);
|
|
189
|
+
}
|
|
190
|
+
if (ts.isPropertyAssignment(node) && nameOf(node.name) === "validationModel") {
|
|
191
|
+
const init = unwrap(node.initializer);
|
|
192
|
+
if (ts.isObjectLiteralExpression(init))
|
|
193
|
+
roots.add(init);
|
|
194
|
+
else if (ts.isIdentifier(init))
|
|
195
|
+
named.push(init.text);
|
|
196
|
+
}
|
|
197
|
+
if (ts.isObjectLiteralExpression(node) && node.properties.some((p) => p.name && (nameOf(p.name) ?? "").startsWith("$__")))
|
|
198
|
+
roots.add(node);
|
|
199
|
+
ts.forEachChild(node, collect);
|
|
200
|
+
};
|
|
201
|
+
collect(sf);
|
|
202
|
+
for (const n of named) {
|
|
203
|
+
const o = consts.get(n);
|
|
204
|
+
if (o)
|
|
205
|
+
roots.add(o);
|
|
206
|
+
}
|
|
207
|
+
const seen = new Set();
|
|
208
|
+
const walk = (obj) => {
|
|
209
|
+
if (seen.has(obj))
|
|
210
|
+
return;
|
|
211
|
+
seen.add(obj);
|
|
212
|
+
const keys = new Set(obj.properties.map((p) => (p.name && nameOf(p.name)) ?? ""));
|
|
213
|
+
const optionBounds = (key) => obj.properties.some((p) => {
|
|
214
|
+
if (!ts.isPropertyAssignment(p) || nameOf(p.name) !== `$__${key}`)
|
|
215
|
+
return false;
|
|
216
|
+
const o = unwrap(p.initializer);
|
|
217
|
+
return ts.isObjectLiteralExpression(o) && o.properties.some((q) => q.name && ["min", "max"].includes(nameOf(q.name) ?? ""));
|
|
218
|
+
});
|
|
219
|
+
for (const p of obj.properties) {
|
|
220
|
+
if (!ts.isPropertyAssignment(p))
|
|
221
|
+
continue;
|
|
222
|
+
const key = nameOf(p.name);
|
|
223
|
+
if (key === null || key.startsWith("$__"))
|
|
224
|
+
continue;
|
|
225
|
+
const init = unwrap(p.initializer);
|
|
226
|
+
let value = null;
|
|
227
|
+
if (ts.isNumericLiteral(init))
|
|
228
|
+
value = Number(init.text);
|
|
229
|
+
else if (ts.isPrefixUnaryExpression(init) && init.operator === ts.SyntaxKind.MinusToken && ts.isNumericLiteral(init.operand))
|
|
230
|
+
value = -Number(init.operand.text);
|
|
231
|
+
if (value !== null && value !== 0) {
|
|
232
|
+
const line = sf.getLineAndCharacterOfPosition(p.getStart(sf)).line + 1;
|
|
233
|
+
if (keys.has(`$__${key}_min`) || keys.has(`$__${key}_max`) || optionBounds(key)) {
|
|
234
|
+
notes.push(`${rel}:${line} — "${key}: ${value}" also has min/max: 6.x applied both, 1.0 only min/max. Set the sample to 0 and check the bounds`);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const bound = `$__${key}_${value > 0 ? "max" : "min"}`;
|
|
238
|
+
edits.push({ at: init.getStart(sf), end: init.getEnd(), text: "0" });
|
|
239
|
+
edits.push({ at: p.getEnd(), end: p.getEnd(), text: `, ${isIdentifier(bound) ? bound : JSON.stringify(bound)}: ${Math.abs(value)}` });
|
|
240
|
+
}
|
|
241
|
+
else if (ts.isObjectLiteralExpression(init)) {
|
|
242
|
+
walk(init);
|
|
243
|
+
}
|
|
244
|
+
else if (ts.isArrayLiteralExpression(init)) {
|
|
245
|
+
for (const el of init.elements) {
|
|
246
|
+
const e = unwrap(el);
|
|
247
|
+
if (ts.isObjectLiteralExpression(e))
|
|
248
|
+
walk(e);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
for (const r of roots)
|
|
254
|
+
walk(r);
|
|
255
|
+
let out = text;
|
|
256
|
+
for (const e of edits.sort((a, b) => b.at - a.at))
|
|
257
|
+
out = out.slice(0, e.at) + e.text + out.slice(e.end);
|
|
258
|
+
return { text: out, changes: edits.length / 2, notes };
|
|
259
|
+
}
|
|
260
|
+
function planMigration(dir, exported) {
|
|
261
|
+
const plan = { files: [], notes: [] };
|
|
262
|
+
const ts = projectTypeScript(dir);
|
|
263
|
+
if (!ts)
|
|
264
|
+
plan.notes.push(`validation models were NOT checked: this needs TypeScript 5 in the project — run \`npm i -D typescript@5\` and migrate again (at startup the service also lists number samples that 6.x took as bounds)`);
|
|
265
|
+
const pkgFile = path_1.default.join(dir, "package.json");
|
|
266
|
+
if (fs_1.default.existsSync(pkgFile)) {
|
|
267
|
+
const before = fs_1.default.readFileSync(pkgFile, "utf-8");
|
|
268
|
+
const r = migratePackageJson(before);
|
|
269
|
+
if (r.changes)
|
|
270
|
+
plan.files.push({ file: pkgFile, before, after: r.text, changes: r.changes });
|
|
271
|
+
plan.notes.push(...r.notes);
|
|
272
|
+
}
|
|
273
|
+
for (const file of sourceFiles(dir)) {
|
|
274
|
+
const before = fs_1.default.readFileSync(file, "utf-8");
|
|
275
|
+
const rel = path_1.default.relative(dir, file);
|
|
276
|
+
let text = before, changes = 0;
|
|
277
|
+
if (ts && /validationModel|\$__/.test(before)) {
|
|
278
|
+
const m = migrateModels(text, rel, ts);
|
|
279
|
+
text = m.text;
|
|
280
|
+
changes += m.changes;
|
|
281
|
+
plan.notes.push(...m.notes);
|
|
282
|
+
}
|
|
283
|
+
if (text.includes(OLD_PKG) || text.includes(OLD_SIGNAL) || /\bsecurityKey\s*:/.test(text)) {
|
|
284
|
+
const r = migrateSource(text, rel, exported);
|
|
285
|
+
text = r.text;
|
|
286
|
+
changes += r.changes;
|
|
287
|
+
plan.notes.push(...r.notes);
|
|
288
|
+
}
|
|
289
|
+
if (changes)
|
|
290
|
+
plan.files.push({ file, before, after: text, changes });
|
|
291
|
+
}
|
|
292
|
+
return plan;
|
|
293
|
+
}
|
|
294
|
+
async function MigrateProject(args) {
|
|
295
|
+
const { red, green, yellow, dim, bold } = (0, cliCommon_1.palette)();
|
|
296
|
+
const write = args.includes("--write");
|
|
297
|
+
const dirs = args.filter(a => a !== "--write");
|
|
298
|
+
if (dirs.length > 1) {
|
|
299
|
+
console.error(red("✗ migrate takes one folder"));
|
|
300
|
+
process.exit(1);
|
|
301
|
+
}
|
|
302
|
+
const dir = path_1.default.resolve(dirs[0] ?? ".");
|
|
303
|
+
if (!fs_1.default.existsSync(path_1.default.join(dir, "package.json"))) {
|
|
304
|
+
console.error(red(`✗ no package.json in ${dir} — run it in the project folder`));
|
|
305
|
+
process.exit(1);
|
|
306
|
+
}
|
|
307
|
+
const index = [path_1.default.join(__dirname, "..", "..", "index.d.ts"), path_1.default.join(__dirname, "..", "..", "index.ts")].find(f => fs_1.default.existsSync(f));
|
|
308
|
+
if (!index) {
|
|
309
|
+
console.error(red("✗ can't find the package index to compare names against"));
|
|
310
|
+
process.exit(1);
|
|
311
|
+
}
|
|
312
|
+
const plan = planMigration(dir, rootExportNames(index));
|
|
313
|
+
console.log(bold(`\nbmfk migrate — ${dir}\n`));
|
|
314
|
+
if (!plan.files.length)
|
|
315
|
+
console.log(dim(" nothing to change"));
|
|
316
|
+
for (const f of plan.files)
|
|
317
|
+
console.log(` ${write ? green("✓") : "•"} ${path_1.default.relative(dir, f.file)} ${dim(`(${f.changes} change${f.changes > 1 ? "s" : ""})`)}`);
|
|
318
|
+
if (plan.notes.length) {
|
|
319
|
+
console.log(bold(yellow(`\nTo do by hand (${plan.notes.length}):`)));
|
|
320
|
+
for (const n of plan.notes)
|
|
321
|
+
console.log(` ${yellow("!")} ${n}`);
|
|
322
|
+
}
|
|
323
|
+
console.log(bold("\nAlso check:"));
|
|
324
|
+
console.log(" - MySQL values starting with \"_\" (host, user, database, password) were decrypted by 6.x; 1.0 uses them as written.");
|
|
325
|
+
console.log(" - Services that call each other move to 1.0 together: 6.x and 1.0 can't call each other.");
|
|
326
|
+
console.log(" - Deploy with a 1.0 deployer: copy setup.json, the project configs and <project>_state_.json into its folders.");
|
|
327
|
+
console.log(" - Node.js 24 or later on the servers.");
|
|
328
|
+
if (!write) {
|
|
329
|
+
console.log(dim(`\nNothing written. Run again with --write to apply, then: npm install && npx tsc --noEmit\n`));
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
for (const f of plan.files)
|
|
333
|
+
fs_1.default.writeFileSync(f.file, f.after, "utf-8");
|
|
334
|
+
console.log(green(`\n✓ ${plan.files.length} file(s) written. Next: npm install && npx tsc --noEmit\n`));
|
|
335
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IError } from "../structures/Interfaces";
|
|
2
|
+
export declare const DEFAULT_SERVER_TEMPLATE = "# Seeded by deployer for _{{DOMAIN}}_. SAFE TO EDIT.\n# Deployer NEVER overwrites this file after the initial seed.\n# Add SSL by running: certbot --nginx -d _{{DOMAIN}}_\n\nserver {\n server_name _{{DOMAIN}}_;\n listen 80;\n\n location / {\n proxy_pass http://_{{UPSTREAM}}_;\n proxy_http_version 1.1;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n # WebSocket: pass the upgrade handshake through to the app.\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n proxy_read_timeout 60s;\n }\n}\n";
|
|
3
|
+
export declare class NginxHelper {
|
|
4
|
+
static writeUpstream(filePath: string, upstreamName: string, port: string): IError | null;
|
|
5
|
+
static seedServerConfig(filePath: string, template: string, values: Record<string, string>): {
|
|
6
|
+
seeded: boolean;
|
|
7
|
+
error?: IError;
|
|
8
|
+
};
|
|
9
|
+
static runHook(cmd: string[] | undefined | null): Promise<string | null>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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.NginxHelper = exports.DEFAULT_SERVER_TEMPLATE = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
const LogService_1 = require("../LogService");
|
|
12
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
13
|
+
exports.DEFAULT_SERVER_TEMPLATE = `# Seeded by deployer for _{{DOMAIN}}_. SAFE TO EDIT.
|
|
14
|
+
# Deployer NEVER overwrites this file after the initial seed.
|
|
15
|
+
# Add SSL by running: certbot --nginx -d _{{DOMAIN}}_
|
|
16
|
+
|
|
17
|
+
server {
|
|
18
|
+
server_name _{{DOMAIN}}_;
|
|
19
|
+
listen 80;
|
|
20
|
+
|
|
21
|
+
location / {
|
|
22
|
+
proxy_pass http://_{{UPSTREAM}}_;
|
|
23
|
+
proxy_http_version 1.1;
|
|
24
|
+
proxy_set_header Host $host;
|
|
25
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
26
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
27
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
28
|
+
# WebSocket: pass the upgrade handshake through to the app.
|
|
29
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
30
|
+
proxy_set_header Connection "upgrade";
|
|
31
|
+
proxy_read_timeout 60s;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
class NginxHelper {
|
|
36
|
+
static writeUpstream(filePath, upstreamName, port) {
|
|
37
|
+
const content = `# Auto-generated by deployer on each activate — do not edit.
|
|
38
|
+
upstream ${upstreamName} {
|
|
39
|
+
server 127.0.0.1:${port};
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
try {
|
|
43
|
+
const tmp = filePath + ".tmp";
|
|
44
|
+
try {
|
|
45
|
+
fs_1.default.unlinkSync(tmp);
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
fs_1.default.writeFileSync(tmp, content, "utf-8");
|
|
49
|
+
fs_1.default.renameSync(tmp, filePath);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
return { code: 48, message: "Failed to write nginx upstream file: " + String(e?.message ?? e), httpStatus: 500 };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static seedServerConfig(filePath, template, values) {
|
|
57
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
58
|
+
return { seeded: false };
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
let content = template;
|
|
62
|
+
for (const [key, value] of Object.entries(values)) {
|
|
63
|
+
content = content.replaceAll(`_{{${key}}}_`, value);
|
|
64
|
+
}
|
|
65
|
+
const leftover = content.match(/_\{\{[A-Za-z0-9_]+\}\}_/g);
|
|
66
|
+
if (leftover && leftover.length > 0) {
|
|
67
|
+
const unique = [...new Set(leftover)];
|
|
68
|
+
(0, LogService_1.logWarn)("Unresolved placeholders in seeded nginx server config " + filePath + ": " + unique.join(", "));
|
|
69
|
+
}
|
|
70
|
+
const tmp = filePath + ".tmp";
|
|
71
|
+
try {
|
|
72
|
+
fs_1.default.unlinkSync(tmp);
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
fs_1.default.writeFileSync(tmp, content, "utf-8");
|
|
76
|
+
fs_1.default.renameSync(tmp, filePath);
|
|
77
|
+
return { seeded: true };
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
return { seeded: false, error: { code: 49, message: "Failed to seed nginx server config: " + String(e?.message ?? e), httpStatus: 500 } };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
static async runHook(cmd) {
|
|
84
|
+
if (!Array.isArray(cmd))
|
|
85
|
+
return null;
|
|
86
|
+
const filtered = cmd.filter(s => typeof s === "string" && s.length > 0);
|
|
87
|
+
if (filtered.length === 0)
|
|
88
|
+
return null;
|
|
89
|
+
if (!path_1.default.isAbsolute(filtered[0])) {
|
|
90
|
+
const err = "nginx hook command must be an absolute path, got: " + filtered[0];
|
|
91
|
+
(0, LogService_1.logError)(err);
|
|
92
|
+
return err;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const result = await execFileAsync(filtered[0], filtered.slice(1), {
|
|
96
|
+
timeout: 30_000,
|
|
97
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
98
|
+
env: { PATH: process.env.PATH ?? "/usr/bin:/bin" },
|
|
99
|
+
});
|
|
100
|
+
if (result.stderr)
|
|
101
|
+
(0, LogService_1.logWarn)("nginx hook stderr:", result.stderr);
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
const err = String(e?.stderr || e?.message || e);
|
|
106
|
+
(0, LogService_1.logError)("nginx hook failed:", err);
|
|
107
|
+
return err;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.NginxHelper = NginxHelper;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseService } from '../BaseService';
|
|
2
|
+
export interface IDeploymentNotifier extends BaseService {
|
|
3
|
+
notifyEmailStatus(email: string, status: string, project: string, user: string): Promise<void>;
|
|
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>;
|
|
12
|
+
}
|
|
13
|
+
export declare class Notifier extends BaseService implements IDeploymentNotifier {
|
|
14
|
+
SMS_URL: string;
|
|
15
|
+
SMS_KEY: string;
|
|
16
|
+
constructor({ URL, KEY }: {
|
|
17
|
+
URL: string;
|
|
18
|
+
KEY: string;
|
|
19
|
+
});
|
|
20
|
+
init(): Promise<void>;
|
|
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>;
|
|
29
|
+
notifySMSStatus(phone: string, text: string, user: string): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Notifier = void 0;
|
|
4
|
+
const LogService_1 = require("../LogService");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const BaseService_1 = require("../BaseService");
|
|
7
|
+
const Http_1 = require("../http/Http");
|
|
8
|
+
class Notifier extends BaseService_1.BaseService {
|
|
9
|
+
SMS_URL;
|
|
10
|
+
SMS_KEY;
|
|
11
|
+
constructor({ URL, KEY }) {
|
|
12
|
+
super("Notifier");
|
|
13
|
+
this.SMS_URL = URL;
|
|
14
|
+
this.SMS_KEY = KEY;
|
|
15
|
+
}
|
|
16
|
+
async init() {
|
|
17
|
+
super.init();
|
|
18
|
+
}
|
|
19
|
+
async notifyEmailStatus(email, status, project, user) {
|
|
20
|
+
const text = `${project} deployment <b>${status}</b> by <b>${user}</b> ${new Date().toISOString()}`;
|
|
21
|
+
const title = `Deployment: ${project} - ${status} (${user})`;
|
|
22
|
+
const token = (0, crypto_1.createHash)("sha256").update(this.SMS_KEY + email + title + text).digest("base64");
|
|
23
|
+
let response = null;
|
|
24
|
+
try {
|
|
25
|
+
response = await Http_1.Http.post(this.SMS_URL + "/api/mail/send", {
|
|
26
|
+
to: email,
|
|
27
|
+
text: title,
|
|
28
|
+
html: text
|
|
29
|
+
}, {
|
|
30
|
+
headers: {
|
|
31
|
+
"authorization": token,
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
(0, LogService_1.logError)(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async notifyReview(email, info) {
|
|
41
|
+
const esc = (v) => String(v).replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[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 Http_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
|
+
}
|
|
62
|
+
async notifySMSStatus(phone, text, user) {
|
|
63
|
+
const finalText = `${text} (by ${user})`;
|
|
64
|
+
const token = (0, crypto_1.createHash)("sha256").update(this.SMS_KEY + phone + finalText + "").digest("base64");
|
|
65
|
+
let response = null;
|
|
66
|
+
try {
|
|
67
|
+
response = await Http_1.Http.post(this.SMS_URL + "/api/sms", {
|
|
68
|
+
to: phone,
|
|
69
|
+
content: finalText
|
|
70
|
+
}, {
|
|
71
|
+
headers: {
|
|
72
|
+
"authorization": token,
|
|
73
|
+
"Content-Type": "application/json"
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
(0, LogService_1.logError)(e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.Notifier = Notifier;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ProjectConfigWizard(): Promise<void>;
|