badmfck-api-server 5.0.8 → 5.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/dist/apiServer/APIService.d.ts +3 -0
- package/dist/apiServer/APIService.js +3 -3
- package/dist/apiServer/BaseEndpoint.js +2 -2
- package/dist/apiServer/LogService.d.ts +3 -0
- package/dist/apiServer/LogService.js +15 -4
- package/dist/apiServer/MysqlService.js +19 -19
- package/dist/apiServer/TimeframeService.js +3 -3
- package/dist/apiServer/db/MysqlAdapter.js +1 -1
- package/dist/apiServer/deployment/DeployerService.js +4 -4
- package/dist/apiServer/deployment/Notifier.js +3 -2
- package/dist/apiServer/external/ExternalService.js +3 -2
- package/dist/apiServer/external/MicroserviceClient.js +3 -2
- package/dist/apiServer/monitor/Monitor.d.ts +5 -0
- package/dist/apiServer/monitor/Monitor.js +114 -30
- package/dist/apiServer/monitor/MonitorAuth.d.ts +69 -0
- package/dist/apiServer/monitor/MonitorAuth.js +310 -0
- package/dist/apiServer/monitor/index.html +80 -68
- package/monitoring.help.md +266 -0
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ import { IDeployerServiceOptions } from './deployment/DeployerService';
|
|
|
8
8
|
import { IBlueGreenState, IBlueGreenStateOptions } from './deployment/BlueGreenState';
|
|
9
9
|
import { ILogFilesOptions } from './monitor/LogFiles';
|
|
10
10
|
export interface IMonitorUser {
|
|
11
|
+
totpSecret?: string;
|
|
12
|
+
role?: "admin" | "it" | "analytic";
|
|
11
13
|
login: string;
|
|
12
14
|
password: string;
|
|
13
15
|
}
|
|
@@ -56,6 +58,7 @@ export interface APIServiceOptions<TInterceptor = unknown> {
|
|
|
56
58
|
metricsDir?: string;
|
|
57
59
|
blueGreenWatchMs?: number;
|
|
58
60
|
logFiles?: ILogFilesOptions;
|
|
61
|
+
monitorAuthFile?: string;
|
|
59
62
|
}
|
|
60
63
|
type InferInterceptor<T> = T extends IInterceptor<infer U> ? U : unknown;
|
|
61
64
|
export declare const getDefaultOptions: <I extends IInterceptor<any> | undefined>(overrides?: Omit<Partial<APIServiceOptions<InferInterceptor<NonNullable<I>>>>, "interceptor"> & {
|
|
@@ -370,7 +370,7 @@ class APIService extends BaseService_1.BaseService {
|
|
|
370
370
|
httpRequest.preproducerResult = preproducerResult;
|
|
371
371
|
}
|
|
372
372
|
catch (e) {
|
|
373
|
-
|
|
373
|
+
(0, LogService_1.logError)(e);
|
|
374
374
|
let details = `${e}`;
|
|
375
375
|
let stack = undefined;
|
|
376
376
|
if (DefaultErrors_1.ErrorUtils.isError(e)) {
|
|
@@ -426,7 +426,7 @@ class APIService extends BaseService_1.BaseService {
|
|
|
426
426
|
result = await i.__execute(httpRequest);
|
|
427
427
|
}
|
|
428
428
|
catch (e) {
|
|
429
|
-
|
|
429
|
+
(0, LogService_1.logError)(e);
|
|
430
430
|
let stack = "";
|
|
431
431
|
let message = "";
|
|
432
432
|
if (e instanceof Error) {
|
|
@@ -604,7 +604,7 @@ class APIService extends BaseService_1.BaseService {
|
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
catch (e) {
|
|
607
|
-
|
|
607
|
+
(0, LogService_1.logError)(e);
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
if (req && !ignoreHttpLogging)
|
|
@@ -240,7 +240,7 @@ class BaseEndpoint {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
catch (e) {
|
|
243
|
-
|
|
243
|
+
(0, LogService_1.logError)("Error during stream cleanup:", e);
|
|
244
244
|
}
|
|
245
245
|
try {
|
|
246
246
|
if (!res.writableEnded)
|
|
@@ -291,7 +291,7 @@ class BaseEndpoint {
|
|
|
291
291
|
});
|
|
292
292
|
req.raw?.on?.("close", cleanup);
|
|
293
293
|
stream.on('error', (err) => {
|
|
294
|
-
|
|
294
|
+
(0, LogService_1.logError)("Stream error:", err);
|
|
295
295
|
cleanup();
|
|
296
296
|
try {
|
|
297
297
|
res.destroy?.(err);
|
|
@@ -68,5 +68,8 @@ export declare class LogService extends BaseService {
|
|
|
68
68
|
private static readonly PAN_CANDIDATE_REGEX;
|
|
69
69
|
private static isLuhnValid;
|
|
70
70
|
static sanitizeDeep(value: any, depth?: number): any;
|
|
71
|
+
private static readonly CARD_IIN_RE;
|
|
72
|
+
private static readonly AGGRESSIVE_PAN_MASKING;
|
|
73
|
+
private static looksLikePAN;
|
|
71
74
|
static maskPAN(text: string): string;
|
|
72
75
|
}
|
|
@@ -263,11 +263,11 @@ class LogService extends BaseService_1.BaseService {
|
|
|
263
263
|
[/(Bearer|Basic|Digest)\s+[A-Za-z0-9\-._~+\/=]+/gi, "$1 <REDACTED>"],
|
|
264
264
|
[/%B\d{13,19}\^[^?]{2,50}\^\d{4,}[^?]*\?/g, "<REDACTED TRACK1>"],
|
|
265
265
|
[/;\d{13,19}=\d{4,}[^?]*\?/g, "<REDACTED TRACK2>"],
|
|
266
|
-
[/("(?:password|passwd|pwd|secret|api[_-]?key|api[_-]?secret|client[_-]?secret|access[_-]?key|private[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|token|authorization|cookie|set[_-]?cookie|session[_-]?id|sess[_-]?id|sid|cvv2?|cvc2?|cvn|cav2?|cid|security[_-]?code|card[_-]?verification[_-]?(?:value|code)?|pin|pin[_-]?block|encrypted[_-]?pin|iso[_-]?9564|exp|expiry|expiration|expiration[_-]?date|exp[_-]?date|exp[_-]?month|exp[_-]?year|cardholder[_-]?name|holder[_-]?name|card[_-]?holder)"\s*:\s*)"[^"]*"/gi, '$1"<REDACTED>"'],
|
|
267
|
-
[/("(?:cvv2?|cvc2?|pin|exp[_-]?month|exp[_-]?year|service[_-]?code)"\s*:\s*)(-?\d+)/gi, '$1"<REDACTED>"'],
|
|
266
|
+
[/("(?:password|passwd|pwd|secret|api[_-]?key|api[_-]?secret|client[_-]?secret|access[_-]?key|private[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|token|authorization|cookie|set[_-]?cookie|session[_-]?id|sess[_-]?id|sid|cvv2?|cvc2?|cvn|cav2?|cid|security[_-]?code|card[_-]?verification[_-]?(?:value|code)?|pin|pin[_-]?block|encrypted[_-]?pin|iso[_-]?9564|exp|expiry|expiration|expiration[_-]?date|exp[_-]?date|exp[_-]?month|exp[_-]?year|cardholder[_-]?name|holder[_-]?name|card[_-]?holder|pan|dpan|primary[_-]?account[_-]?number|application[_-]?primary[_-]?account[_-]?number|card[_-]?number|card[_-]?no|account[_-]?number|application[_-]?expiration[_-]?date|online[_-]?payment[_-]?cryptogram|cryptogram|emv[_-]?data|track[12]?[_-]?data)"\s*:\s*)"[^"]*"/gi, '$1"<REDACTED>"'],
|
|
267
|
+
[/("(?:cvv2?|cvc2?|pin|exp[_-]?month|exp[_-]?year|service[_-]?code|pan|dpan|primary[_-]?account[_-]?number|application[_-]?primary[_-]?account[_-]?number|card[_-]?number|account[_-]?number)"\s*:\s*)(-?\d+)/gi, '$1"<REDACTED>"'],
|
|
268
268
|
[/([?&;](?:password|passwd|pwd|secret|token|access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|apikey|auth|authorization|session|session[_-]?id|sid|cvv2?|cvc2?|pin|pan|signature|sig)=)[^&\s"'<>;]*/gi, "$1<REDACTED>"],
|
|
269
269
|
];
|
|
270
|
-
static SENSITIVE_KEY_RE = /^(?:authorization|proxy-authorization|cookie|set-cookie|x-api-key|api[_-]?key|apikey|password|passwd|pwd|secret|client[_-]?secret|access[_-]?key|private[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|token|session[_-]?id|sess[_-]?id|sid|cvv2?|cvc2?|cvn|cav2?|security[_-]?code|card[_-]?verification[_-]?(?:value|code)?|pin|pin[_-]?block|pan|card[_-]?number|exp|expiry|expiration|exp[_-]?date|exp[_-]?month|exp[_-]?year|cardholder[_-]?name|holder[_-]?name|card[_-]?holder)$/i;
|
|
270
|
+
static SENSITIVE_KEY_RE = /^(?:authorization|proxy-authorization|cookie|set-cookie|x-api-key|api[_-]?key|apikey|password|passwd|pwd|secret|client[_-]?secret|access[_-]?key|private[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|token|session[_-]?id|sess[_-]?id|sid|cvv2?|cvc2?|cvn|cav2?|security[_-]?code|card[_-]?verification[_-]?(?:value|code)?|pin|pin[_-]?block|pan|card[_-]?number|exp|expiry|expiration|exp[_-]?date|exp[_-]?month|exp[_-]?year|cardholder[_-]?name|holder[_-]?name|card[_-]?holder|pan|dpan|primary[_-]?account[_-]?number|application[_-]?primary[_-]?account[_-]?number|card[_-]?number|card[_-]?no|account[_-]?number|application[_-]?expiration[_-]?date|online[_-]?payment[_-]?cryptogram|cryptogram|emv[_-]?data|track[12]?[_-]?data)$/i;
|
|
271
271
|
static sanitize(text) {
|
|
272
272
|
if (!text || text.length < 3)
|
|
273
273
|
return text;
|
|
@@ -338,12 +338,23 @@ class LogService extends BaseService_1.BaseService {
|
|
|
338
338
|
}
|
|
339
339
|
return String(value);
|
|
340
340
|
}
|
|
341
|
+
static CARD_IIN_RE = /^(?:4|5[1-5]|2[2-7]|3[47]|35|6011|64[4-9]|65|62|3(?:0[0-5]|[68]))/;
|
|
342
|
+
static AGGRESSIVE_PAN_MASKING = true;
|
|
343
|
+
static looksLikePAN(digits) {
|
|
344
|
+
if (digits.length < 13 || digits.length > 19)
|
|
345
|
+
return false;
|
|
346
|
+
if (LogService.isLuhnValid(digits))
|
|
347
|
+
return true;
|
|
348
|
+
return LogService.AGGRESSIVE_PAN_MASKING && LogService.CARD_IIN_RE.test(digits);
|
|
349
|
+
}
|
|
341
350
|
static maskPAN(text) {
|
|
342
351
|
if (!text || text.length < 13)
|
|
343
352
|
return text;
|
|
344
353
|
return text.replace(LogService.PAN_CANDIDATE_REGEX, (match) => {
|
|
345
354
|
const digits = match.replace(/\D/g, "");
|
|
346
|
-
|
|
355
|
+
if (!LogService.looksLikePAN(digits))
|
|
356
|
+
return match;
|
|
357
|
+
return "xxxx...xxxx" + digits.slice(-4);
|
|
347
358
|
});
|
|
348
359
|
}
|
|
349
360
|
}
|
|
@@ -101,14 +101,14 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
101
101
|
}
|
|
102
102
|
this.transactions = this.transactions.filter(i => !removedIDs.includes(i.id));
|
|
103
103
|
if (this.debug && count - this.transactions.length > 0)
|
|
104
|
-
|
|
104
|
+
(0, LogService_1.logInfo)("Removed: ", count - this.transactions.length);
|
|
105
105
|
if (Date.now() - this.lastSuccessQueryTime > this.pingInterval) {
|
|
106
106
|
if (!this.pool)
|
|
107
107
|
return;
|
|
108
108
|
for (let i = 0; i < this.options.connectionLimit; i++) {
|
|
109
109
|
exports.DEPRECATED_REQ_MYSQL_QUERY.request({ query: "SELECT 1 @NOLIMIT", fields: [] });
|
|
110
110
|
if (this.debug)
|
|
111
|
-
|
|
111
|
+
(0, LogService_1.logInfo)("Ping mysql on each connection in pool");
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}, 1000 * 30);
|
|
@@ -162,14 +162,14 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
162
162
|
promises.push(this.execute(query, i.rollbackQuery ?? null, i.transactionID ?? 0, i.throwable ?? false, i.calculateCount ?? false));
|
|
163
163
|
}
|
|
164
164
|
if (this.debug) {
|
|
165
|
-
|
|
165
|
+
(0, LogService_1.logInfo)("Execute queries: ", data.length);
|
|
166
166
|
for (let i of data)
|
|
167
|
-
|
|
167
|
+
(0, LogService_1.logInfo)(i);
|
|
168
168
|
}
|
|
169
169
|
const result = await Promise.all(promises);
|
|
170
170
|
for (let i of result) {
|
|
171
171
|
if (i.error && i.error.code === "CONN_ERR") {
|
|
172
|
-
|
|
172
|
+
(0, LogService_1.logError)("Connection error, was destroyed, recreate pool");
|
|
173
173
|
await this.recreatePool();
|
|
174
174
|
}
|
|
175
175
|
if (i.error && (i.error.fatal || i.error.throwable))
|
|
@@ -191,11 +191,11 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
191
191
|
}
|
|
192
192
|
const tid = MysqlService.nextTransactionID++;
|
|
193
193
|
if (this.debug)
|
|
194
|
-
|
|
194
|
+
(0, LogService_1.logInfo)("Begin transaction with id ", tid);
|
|
195
195
|
try {
|
|
196
196
|
await conn.query("START TRANSACTION");
|
|
197
197
|
if (this.debug)
|
|
198
|
-
|
|
198
|
+
(0, LogService_1.logInfo)("Transaction started");
|
|
199
199
|
}
|
|
200
200
|
catch (e) {
|
|
201
201
|
this.rollbackTransaction({ id: tid, conn: conn, timestamp: Date.now(), queries: [{ sql: "START TRANSACTION", status: "error" }] });
|
|
@@ -208,7 +208,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
208
208
|
queries: []
|
|
209
209
|
});
|
|
210
210
|
if (this.debug)
|
|
211
|
-
|
|
211
|
+
(0, LogService_1.logInfo)("Transactions pool: ", this.transactions);
|
|
212
212
|
return tid;
|
|
213
213
|
};
|
|
214
214
|
exports.DEPRECATED_REQ_MYSQL_TQUERY.listener = async (data) => {
|
|
@@ -226,7 +226,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
226
226
|
let err = null;
|
|
227
227
|
let sqlData = null;
|
|
228
228
|
if (this.debug)
|
|
229
|
-
|
|
229
|
+
(0, LogService_1.logInfo)("Execute query on transaction: ", trx.id);
|
|
230
230
|
try {
|
|
231
231
|
sqlData = await trx.conn.query(query);
|
|
232
232
|
}
|
|
@@ -251,7 +251,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
if (this.debug)
|
|
254
|
-
|
|
254
|
+
(0, LogService_1.logInfo)("Query execution status:", err ? err.message : "completed");
|
|
255
255
|
trx.queries.push({ sql: query, status: err ? err.message : "completed" });
|
|
256
256
|
return {
|
|
257
257
|
data: sqlData ? sqlData[0] : null,
|
|
@@ -289,10 +289,10 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
if (this.debug)
|
|
292
|
-
|
|
292
|
+
(0, LogService_1.logInfo)("Commit transaction:", trx.id);
|
|
293
293
|
this.transactions = this.transactions.filter(i => i.id !== tid);
|
|
294
294
|
if (this.debug)
|
|
295
|
-
|
|
295
|
+
(0, LogService_1.logInfo)("Transaction pool:", this.transactions);
|
|
296
296
|
const err = await this.commit(trx);
|
|
297
297
|
return err;
|
|
298
298
|
};
|
|
@@ -312,7 +312,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
312
312
|
async rollbackTransaction(trx, donNotRemove) {
|
|
313
313
|
let err = null;
|
|
314
314
|
try {
|
|
315
|
-
|
|
315
|
+
(0, LogService_1.logInfo)("Rollback started", trx.conn.threadId);
|
|
316
316
|
await trx.conn.rollback();
|
|
317
317
|
await trx.conn.commit();
|
|
318
318
|
trx.conn.removeAllListeners();
|
|
@@ -320,7 +320,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
320
320
|
if (!donNotRemove)
|
|
321
321
|
this.transactions = this.transactions.filter(i => i.id !== trx.id);
|
|
322
322
|
if (this.debug)
|
|
323
|
-
|
|
323
|
+
(0, LogService_1.logInfo)("Rollback complete", trx.conn.threadId);
|
|
324
324
|
}
|
|
325
325
|
catch (e) {
|
|
326
326
|
(0, LogService_1.logCrit)("${MysqlService.js}", "Can't rollback transaction", trx.queries);
|
|
@@ -330,7 +330,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
330
330
|
return err;
|
|
331
331
|
}
|
|
332
332
|
async finishApp() {
|
|
333
|
-
|
|
333
|
+
(0, LogService_1.logInfo)("Finishing mysql service");
|
|
334
334
|
for (let i of this.transactions)
|
|
335
335
|
this.rollbackTransaction(i);
|
|
336
336
|
if (this.pool) {
|
|
@@ -375,7 +375,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
375
375
|
this.failReportFileStreamName = file;
|
|
376
376
|
}
|
|
377
377
|
if (this.debug)
|
|
378
|
-
|
|
378
|
+
(0, LogService_1.logInfo)("Store transaction fail report: ", file, trx.queries, message);
|
|
379
379
|
if (!this.failReportFileStream)
|
|
380
380
|
this.failReportFileStream = fs_1.default.createWriteStream(file, { flags: 'a' });
|
|
381
381
|
this.failReportFileStream.write(JSON.stringify({ queries: trx.queries, time: trx.timestamp, date, message }) + "\n}EOB{\n", err => {
|
|
@@ -437,7 +437,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
437
437
|
(0, LogService_1.logInfo)("${MysqlService.js}", "MYSQL CONNECTION ENQUEUED");
|
|
438
438
|
});
|
|
439
439
|
if (this.debug)
|
|
440
|
-
|
|
440
|
+
(0, LogService_1.logInfo)("Check mysql connection");
|
|
441
441
|
return new Promise(async (resolve, reject) => {
|
|
442
442
|
try {
|
|
443
443
|
const conn = await this.pool?.getConnection();
|
|
@@ -610,13 +610,13 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
610
610
|
if (transactionID && transactionID > 0) {
|
|
611
611
|
conn = this.transactions.find(i => i.id === transactionID)?.conn ?? null;
|
|
612
612
|
if (this.debug)
|
|
613
|
-
|
|
613
|
+
(0, LogService_1.logInfo)("Execute query on transaction: ", conn?.threadId);
|
|
614
614
|
}
|
|
615
615
|
else {
|
|
616
616
|
conn = await this.pool.getConnection();
|
|
617
617
|
}
|
|
618
618
|
if (this.debug)
|
|
619
|
-
|
|
619
|
+
(0, LogService_1.logInfo)("Execute query", conn?.threadId);
|
|
620
620
|
if (!conn) {
|
|
621
621
|
(0, LogService_1.logCrit)("${MysqlService.js}", `No connection created!`);
|
|
622
622
|
resolve({
|
|
@@ -62,7 +62,7 @@ class TimeframeService extends BaseService_1.BaseService {
|
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
64
|
this.intervalId = setInterval(() => {
|
|
65
|
-
this.loop().catch(
|
|
65
|
+
this.loop().catch(e => (0, LogService_1.logError)("Timeframe loop failed:", e));
|
|
66
66
|
}, this.TICK_INTERVAL_MS);
|
|
67
67
|
}
|
|
68
68
|
async loop() {
|
|
@@ -109,10 +109,10 @@ class TimeframeService extends BaseService_1.BaseService {
|
|
|
109
109
|
exports.S_TIMEFRAME_TASK_EXECUTED.invoke(task);
|
|
110
110
|
}
|
|
111
111
|
catch (e) {
|
|
112
|
-
|
|
112
|
+
(0, LogService_1.logError)(`Task ${task.name} error:`, e);
|
|
113
113
|
task.retries = (task.retries || 0) + 1;
|
|
114
114
|
if (task.retries > (task.maxRetries ?? 0)) {
|
|
115
|
-
|
|
115
|
+
(0, LogService_1.logWarn)(`Task ${task.name} failed too many times. Dropping.`);
|
|
116
116
|
this.tasks = this.tasks.filter(t => t !== task);
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
@@ -222,7 +222,7 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
222
222
|
throw result;
|
|
223
223
|
}
|
|
224
224
|
if (found.backup) {
|
|
225
|
-
|
|
225
|
+
(0, LogService_1.logInfo)("TODO: backup");
|
|
226
226
|
}
|
|
227
227
|
if (found.unpack) {
|
|
228
228
|
const unpackResult = await this.unpack(found.destination, uploadPath, found.install, found.ignoreDirectoryClean);
|
|
@@ -237,7 +237,7 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
237
237
|
}
|
|
238
238
|
if (found.chmod && found.chmod > 1) {
|
|
239
239
|
try {
|
|
240
|
-
|
|
240
|
+
(0, LogService_1.logInfo)("Try to execute: ", `chmod -R ${found.chmod} ${found.destination}`);
|
|
241
241
|
(0, child_process_1.execFileSync)("chmod", ["-R", String(found.chmod), found.destination]);
|
|
242
242
|
}
|
|
243
243
|
catch (e) {
|
|
@@ -662,7 +662,7 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
662
662
|
}
|
|
663
663
|
let hash2 = crypto_1.default.createHash("md5").update(content).digest("hex");
|
|
664
664
|
if (hash !== hash2) {
|
|
665
|
-
|
|
665
|
+
(0, LogService_1.logInfo)("Values was changed in " + filePath);
|
|
666
666
|
fs_1.default.writeFileSync(filePath, content, "utf-8");
|
|
667
667
|
}
|
|
668
668
|
const leftover = content.match(/_\{\{[A-Za-z0-9_]+\}\}_/g);
|
|
@@ -727,7 +727,7 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
727
727
|
(0, child_process_1.execFileSync)("npm", ["--prefix", tmpDir, npmCmd, "--ignore-scripts"]);
|
|
728
728
|
}
|
|
729
729
|
catch (e) {
|
|
730
|
-
|
|
730
|
+
(0, LogService_1.logError)(e);
|
|
731
731
|
(0, LogService_1.logError)(e);
|
|
732
732
|
resolve({ code: 17, message: "Can't install", httpStatus: 500 });
|
|
733
733
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Notifier = void 0;
|
|
4
|
+
const LogService_1 = require("../LogService");
|
|
4
5
|
const crypto_1 = require("crypto");
|
|
5
6
|
const BaseService_1 = require("../BaseService");
|
|
6
7
|
const __1 = require("../..");
|
|
@@ -33,7 +34,7 @@ class Notifier extends BaseService_1.BaseService {
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
catch (e) {
|
|
36
|
-
|
|
37
|
+
(0, LogService_1.logError)(e);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
async notifySMSStatus(phone, text, user) {
|
|
@@ -52,7 +53,7 @@ class Notifier extends BaseService_1.BaseService {
|
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
catch (e) {
|
|
55
|
-
|
|
56
|
+
(0, LogService_1.logError)(e);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.ExternalService = exports.REQ_XT = exports.REQ_EXTERNAL_CALL = void 0;
|
|
40
|
+
const LogService_1 = require("../LogService");
|
|
40
41
|
const badmfck_signal_1 = require("badmfck-signal");
|
|
41
42
|
const BaseService_1 = require("../BaseService");
|
|
42
43
|
const DefaultErrors_1 = __importStar(require("../structures/DefaultErrors"));
|
|
@@ -48,7 +49,7 @@ exports.REQ_EXTERNAL_CALL = new badmfck_signal_1.Req(undefined, "REQ_EXTERNAL_CA
|
|
|
48
49
|
exports.REQ_XT = new badmfck_signal_1.Req(undefined, "REQ_XT");
|
|
49
50
|
exports.REQ_XT.listener = async ({ id, req }) => {
|
|
50
51
|
if (ExternalService.allInstances.length === 0) {
|
|
51
|
-
|
|
52
|
+
(0, LogService_1.logError)("ExternalService.allInstances.length === 0");
|
|
52
53
|
return { error: { ...DefaultErrors_1.default.BAD_REQUEST, details: "no external services" } };
|
|
53
54
|
}
|
|
54
55
|
for (let i of ExternalService.allInstances) {
|
|
@@ -59,7 +60,7 @@ exports.REQ_XT.listener = async ({ id, req }) => {
|
|
|
59
60
|
};
|
|
60
61
|
exports.REQ_EXTERNAL_CALL.listener = async ({ id, requestName, requestData }) => {
|
|
61
62
|
if (ExternalService.allInstances.length === 0) {
|
|
62
|
-
|
|
63
|
+
(0, LogService_1.logError)("ExternalService.allInstances.length === 0");
|
|
63
64
|
return { ...DefaultErrors_1.default.BAD_REQUEST, details: "no external service found: " + id + ", requestName:" + requestName, stack: [requestData] };
|
|
64
65
|
}
|
|
65
66
|
for (let i of ExternalService.allInstances) {
|
|
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.MicroserviceClient = exports.REQ_MICROSERVICE_CALL = void 0;
|
|
40
|
+
const LogService_1 = require("../LogService");
|
|
40
41
|
const badmfck_signal_1 = require("badmfck-signal");
|
|
41
42
|
const BaseService_1 = require("../BaseService");
|
|
42
43
|
const DefaultErrors_1 = __importStar(require("../structures/DefaultErrors"));
|
|
@@ -96,14 +97,14 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
96
97
|
}, { headers });
|
|
97
98
|
if (!resp.ok && resp.details?.network) {
|
|
98
99
|
if (attempt < maxAttempts) {
|
|
99
|
-
|
|
100
|
+
(0, LogService_1.logInfo)(`Retrying microservice call... (attempt ${attempt}/${maxAttempts})`);
|
|
100
101
|
await TimeframeService_1.TimeframeService.wait(attemptTimeout * attempt);
|
|
101
102
|
continue;
|
|
102
103
|
}
|
|
103
104
|
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, stack: [this.options.host, req], details: "Network connection lost after multiple retries, attempts: " + attempt };
|
|
104
105
|
}
|
|
105
106
|
if (!resp.ok) {
|
|
106
|
-
|
|
107
|
+
(0, LogService_1.logInfo)(`Microservice call error response:`, resp);
|
|
107
108
|
const remoteError = resp.error?.error;
|
|
108
109
|
if (DefaultErrors_1.ErrorUtils.isError(remoteError))
|
|
109
110
|
return remoteError;
|
|
@@ -2,6 +2,7 @@ import { Signal } from "badmfck-signal";
|
|
|
2
2
|
import { APIServiceOptions } from "../APIService";
|
|
3
3
|
import { BaseEndpoint } from "../BaseEndpoint";
|
|
4
4
|
import { HTTPRequestVO, TransferPacketVO } from "../structures/Interfaces";
|
|
5
|
+
import { TMonitorCapability } from "./MonitorAuth";
|
|
5
6
|
export interface IUserAction {
|
|
6
7
|
action: string;
|
|
7
8
|
}
|
|
@@ -30,6 +31,9 @@ export declare class Monitor extends BaseEndpoint {
|
|
|
30
31
|
sysinfo(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
31
32
|
procinfo(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
32
33
|
fdreport(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
34
|
+
login(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
35
|
+
enroll2fa(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
36
|
+
logout(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
33
37
|
restart(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
34
38
|
httpstats(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
35
39
|
inventory(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
@@ -40,5 +44,6 @@ export declare class Monitor extends BaseEndpoint {
|
|
|
40
44
|
metricsWeek(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
41
45
|
connections(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
42
46
|
db(req: HTTPRequestVO): Promise<TransferPacketVO>;
|
|
47
|
+
requireAccess(req: HTTPRequestVO, capability: TMonitorCapability): Promise<string>;
|
|
43
48
|
checkAuthentication(req: HTTPRequestVO): Promise<string>;
|
|
44
49
|
}
|