mybase 1.1.18 → 1.1.20
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/package.json +7 -6
- package/ts/funcs/Geoip2Paths.js +1 -0
- package/ts/funcs/MaxRuntimeHours.d.ts +1 -0
- package/ts/funcs/MaxRuntimeHours.js +11 -0
- package/ts/funcs/MaxRuntimeHours.ts +7 -0
- package/ts/funcs/asJSON.js +1 -0
- package/ts/funcs/fileCacheIsValid.js +1 -0
- package/ts/funcs/getMysql1.js +26 -36
- package/ts/funcs/getMysql2.d.ts +2 -1
- package/ts/funcs/getMysql2.js +26 -36
- package/ts/funcs/getMysql2.ts +2 -2
- package/ts/funcs/hash_sha512.js +1 -0
- package/ts/funcs/initMysql2Pool.js +1 -0
- package/ts/funcs/int2ip.js +1 -0
- package/ts/funcs/ip2int.js +1 -0
- package/ts/funcs/isLANIp.js +1 -0
- package/ts/funcs/isLocal.js +1 -0
- package/ts/funcs/isLoopbackIP.js +1 -0
- package/ts/funcs/isLoopbackIP.test.ts +3 -3
- package/ts/funcs/promiseTimeout.js +1 -0
- package/ts/funcs/randomIP.js +1 -0
- package/ts/funcs/randomIP6.js +1 -0
- package/ts/funcs/randomString.js +1 -0
- package/ts/funcs/randomTCPPort.js +46 -58
- package/ts/funcs/randomTCPPort.ts +0 -1
- package/ts/funcs/randomUTFString.js +1 -0
- package/ts/funcs/utcnow.js +1 -0
- package/ts/funcs/validEmail.js +1 -0
- package/ts/funcs/validIp.js +1 -0
- package/ts/funcs/vaultFill.js +23 -33
- package/ts/funcs/vaultRead.js +1 -0
- package/ts/funcs/wait.js +1 -0
- package/ts/global.js +1 -0
- package/ts/index.d.ts +1 -0
- package/ts/index.js +2 -0
- package/ts/index.ts +2 -1
- package/ts/types.js +1 -0
- package/tsconfig.json +30 -109
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mybase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "mybase.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,16 +22,17 @@
|
|
|
22
22
|
"node-vault": "^0.10.2",
|
|
23
23
|
"psl": "^1.9.0",
|
|
24
24
|
"punycode": "^2.1.1",
|
|
25
|
-
"validator": "^13.7.0"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@jest/globals": "^29.7.0",
|
|
25
|
+
"validator": "^13.7.0",
|
|
29
26
|
"@types/debug": "^4.1.12",
|
|
30
27
|
"@types/ip6addr": "^0.2.6",
|
|
31
|
-
"@types/jest": "^29.5.11",
|
|
32
28
|
"@types/mysql": "^2.15.25",
|
|
33
29
|
"@types/node": "^20.11.5",
|
|
34
30
|
"@types/validator": "^13.11.8",
|
|
31
|
+
"@types/request": "^2.48.12"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@jest/globals": "^29.7.0",
|
|
35
|
+
"@types/jest": "^29.5.11",
|
|
35
36
|
"chai": "^4.2.0",
|
|
36
37
|
"jest": "^29.7.0",
|
|
37
38
|
"mocha": "^8.2.1",
|
package/ts/funcs/Geoip2Paths.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MaxRuntimeHours(hours?: number): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MaxRuntimeHours = void 0;
|
|
4
|
+
function MaxRuntimeHours(hours = 24) {
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
console.log(`Max runtime of ${hours} hours reached, exiting`);
|
|
7
|
+
process.exit(0);
|
|
8
|
+
}, hours * 60 * 60 * 1000);
|
|
9
|
+
}
|
|
10
|
+
exports.MaxRuntimeHours = MaxRuntimeHours;
|
|
11
|
+
//# sourceMappingURL=MaxRuntimeHours.js.map
|
package/ts/funcs/asJSON.js
CHANGED
package/ts/funcs/getMysql1.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -39,34 +30,33 @@ exports.getMysql1 = void 0;
|
|
|
39
30
|
const mysql1 = __importStar(require("mysql"));
|
|
40
31
|
const debug_1 = __importDefault(require("debug"));
|
|
41
32
|
const dbg = (0, debug_1.default)("getMysql1");
|
|
42
|
-
function getMysql1(config, pingInterval = 0) {
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
resolve(mysql_client);
|
|
68
|
-
});
|
|
33
|
+
async function getMysql1(config, pingInterval = 0) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const mysql_client = mysql1.createConnection({
|
|
36
|
+
host: config.host,
|
|
37
|
+
port: config.port ? config.port : 3306,
|
|
38
|
+
user: config.login,
|
|
39
|
+
password: config.password,
|
|
40
|
+
database: config.db
|
|
41
|
+
});
|
|
42
|
+
mysql_client.connect((err, res) => {
|
|
43
|
+
if (err) {
|
|
44
|
+
dbg(`mysql connection has failed to ${config.host}@${config.db}`, err);
|
|
45
|
+
return reject(err);
|
|
46
|
+
}
|
|
47
|
+
dbg(`mysql connection has been established to ${config.host}@${config.db}`);
|
|
48
|
+
// install a pinger every 30 seconds to keep the connection alive
|
|
49
|
+
if (pingInterval > 0)
|
|
50
|
+
setInterval(() => {
|
|
51
|
+
mysql_client.ping(function (err) {
|
|
52
|
+
if (err)
|
|
53
|
+
return console.log(`could not ping mysql ${config.host}@${config.db}`, err.code);
|
|
54
|
+
dbg(`mysql ${config.host}@${config.db} is pinging properly`);
|
|
55
|
+
});
|
|
56
|
+
}, pingInterval);
|
|
57
|
+
resolve(mysql_client);
|
|
69
58
|
});
|
|
70
59
|
});
|
|
71
60
|
}
|
|
72
61
|
exports.getMysql1 = getMysql1;
|
|
62
|
+
//# sourceMappingURL=getMysql1.js.map
|
package/ts/funcs/getMysql2.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Connection } from "mysql2";
|
|
1
2
|
export type Mysql2ServerConfiguration = {
|
|
2
3
|
host: string;
|
|
3
4
|
port: number;
|
|
@@ -5,4 +6,4 @@ export type Mysql2ServerConfiguration = {
|
|
|
5
6
|
password: string;
|
|
6
7
|
db: string;
|
|
7
8
|
};
|
|
8
|
-
export declare function getMysql2(config: Mysql2ServerConfiguration, pingInterval?: number): Promise<
|
|
9
|
+
export declare function getMysql2(config: Mysql2ServerConfiguration, pingInterval?: number): Promise<Connection>;
|
package/ts/funcs/getMysql2.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -39,34 +30,33 @@ exports.getMysql2 = void 0;
|
|
|
39
30
|
const mysql2 = __importStar(require("mysql2"));
|
|
40
31
|
const debug_1 = __importDefault(require("debug"));
|
|
41
32
|
const dbg = (0, debug_1.default)("getMysql2");
|
|
42
|
-
function getMysql2(config, pingInterval = 0) {
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
resolve(mysql_client);
|
|
68
|
-
});
|
|
33
|
+
async function getMysql2(config, pingInterval = 0) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const mysql_client = mysql2.createConnection({
|
|
36
|
+
host: config.host,
|
|
37
|
+
port: config.port ? config.port : 3306,
|
|
38
|
+
user: config.login,
|
|
39
|
+
password: config.password,
|
|
40
|
+
database: config.db
|
|
41
|
+
});
|
|
42
|
+
mysql_client.connect((err) => {
|
|
43
|
+
if (err) {
|
|
44
|
+
dbg(`mysql connection has failed to ${config.host}@${config.db}`, err);
|
|
45
|
+
return reject(err);
|
|
46
|
+
}
|
|
47
|
+
dbg(`mysql connection has been established to ${config.host}@${config.db}`);
|
|
48
|
+
// install a pinger every 30 seconds to keep the connection alive
|
|
49
|
+
if (pingInterval > 0)
|
|
50
|
+
setInterval(() => {
|
|
51
|
+
mysql_client.ping(function (err) {
|
|
52
|
+
if (err)
|
|
53
|
+
return console.log(`could not ping mysql ${config.host}@${config.db}`, err.code);
|
|
54
|
+
dbg(`mysql ${config.host}@${config.db} is pinging properly`);
|
|
55
|
+
});
|
|
56
|
+
}, pingInterval);
|
|
57
|
+
resolve(mysql_client);
|
|
69
58
|
});
|
|
70
59
|
});
|
|
71
60
|
}
|
|
72
61
|
exports.getMysql2 = getMysql2;
|
|
62
|
+
//# sourceMappingURL=getMysql2.js.map
|
package/ts/funcs/getMysql2.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as mysql2 from "mysql2"
|
|
2
|
-
import { QueryError } from "mysql2"
|
|
2
|
+
import { QueryError,Connection } from "mysql2"
|
|
3
3
|
import debug from "debug"
|
|
4
4
|
const dbg = debug("getMysql2")
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ export type Mysql2ServerConfiguration = {
|
|
|
11
11
|
db: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export async function getMysql2(config: Mysql2ServerConfiguration, pingInterval: number = 0) {
|
|
14
|
+
export async function getMysql2(config: Mysql2ServerConfiguration, pingInterval: number = 0):Promise<Connection> {
|
|
15
15
|
return new Promise((resolve, reject) => {
|
|
16
16
|
const mysql_client = mysql2.createConnection({
|
|
17
17
|
host: config.host,
|
package/ts/funcs/hash_sha512.js
CHANGED
package/ts/funcs/int2ip.js
CHANGED
package/ts/funcs/ip2int.js
CHANGED
package/ts/funcs/isLANIp.js
CHANGED
package/ts/funcs/isLocal.js
CHANGED
package/ts/funcs/isLoopbackIP.js
CHANGED
|
@@ -63,10 +63,10 @@ describe('isLoopbackIP', () => {
|
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
test('random ips should not be Loopback', () => {
|
|
66
|
-
for(let i=0;i<
|
|
67
|
-
let ip =
|
|
66
|
+
for(let i=0;i<10;i++){
|
|
67
|
+
let ip = randomIP()
|
|
68
68
|
console.log(ip)
|
|
69
|
-
expect(ip).toBe(false)
|
|
69
|
+
expect(isLoopbackIP(ip)).toBe(false)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
})
|
package/ts/funcs/randomIP.js
CHANGED
package/ts/funcs/randomIP6.js
CHANGED
|
@@ -14,3 +14,4 @@ function randomIP6() {
|
|
|
14
14
|
return ip6_1.default.abbreviate(ip6_1.default.normalize(((_a = bytes.toString('hex').match(/.{1,4}/g)) === null || _a === void 0 ? void 0 : _a.join(':')) || '0000:0000:0000:0000:0000:0000:0000:0000'));
|
|
15
15
|
}
|
|
16
16
|
exports.randomIP6 = randomIP6;
|
|
17
|
+
//# sourceMappingURL=randomIP6.js.map
|
package/ts/funcs/randomString.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
26
|
exports.randomTCPPort = void 0;
|
|
36
27
|
const net = __importStar(require("net"));
|
|
@@ -45,56 +36,53 @@ const net = __importStar(require("net"));
|
|
|
45
36
|
* @param tries the number of tries to find a port number
|
|
46
37
|
* @param host the host to bind to
|
|
47
38
|
*/
|
|
48
|
-
function randomTCPPort(timeout = 1000, fromPort = 1025, untilPort = 65534, tries = 1000, host = '127.0.0.1') {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
resolveInner(true);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
server.listen(port, host);
|
|
79
|
-
let result = yield checkPort;
|
|
80
|
-
if (result) {
|
|
81
|
-
let to = setTimeout(() => {
|
|
82
|
-
return resolve(port);
|
|
83
|
-
}, 1000);
|
|
84
|
-
server.on('close', () => {
|
|
85
|
-
clearTimeout(to);
|
|
86
|
-
return resolve(port);
|
|
87
|
-
});
|
|
88
|
-
server.close();
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
else
|
|
92
|
-
server.close();
|
|
93
|
-
}
|
|
94
|
-
if (tries === 0)
|
|
95
|
-
return resolve(false);
|
|
39
|
+
async function randomTCPPort(timeout = 1000, fromPort = 1025, untilPort = 65534, tries = 1000, host = '127.0.0.1') {
|
|
40
|
+
return new Promise(async function (resolve, reject) {
|
|
41
|
+
// check if the given port range is valid
|
|
42
|
+
if (fromPort > untilPort)
|
|
43
|
+
return resolve(false);
|
|
44
|
+
// check if the given port range is valid
|
|
45
|
+
if (fromPort < 0 || untilPort < 0)
|
|
46
|
+
return resolve(false);
|
|
47
|
+
// check if the given port range is valid
|
|
48
|
+
if (fromPort > 65535 || untilPort > 65535)
|
|
49
|
+
return resolve(false);
|
|
50
|
+
// this function shall return a random port number that is not in use and we should validate this port number by trying to listen to it and releasing
|
|
51
|
+
// this port number immediately
|
|
52
|
+
// this function should be used for testing purposes only
|
|
53
|
+
// this function is not suitable for production use
|
|
54
|
+
while (true && tries > 0) {
|
|
55
|
+
tries--;
|
|
56
|
+
let port = Math.floor(Math.random() * (untilPort - fromPort + 1) + fromPort);
|
|
57
|
+
let server = net.createServer();
|
|
58
|
+
let checkPort = new Promise((resolveInner, reject) => {
|
|
59
|
+
server.on('error', (err) => {
|
|
60
|
+
// any error should raise problem
|
|
61
|
+
resolveInner(false);
|
|
62
|
+
});
|
|
63
|
+
server.on('listening', () => {
|
|
64
|
+
resolveInner(true);
|
|
65
|
+
});
|
|
96
66
|
});
|
|
97
|
-
|
|
67
|
+
server.listen(port, host);
|
|
68
|
+
let result = await checkPort;
|
|
69
|
+
if (result) {
|
|
70
|
+
let to = setTimeout(() => {
|
|
71
|
+
return resolve(port);
|
|
72
|
+
}, 1000);
|
|
73
|
+
server.on('close', () => {
|
|
74
|
+
clearTimeout(to);
|
|
75
|
+
return resolve(port);
|
|
76
|
+
});
|
|
77
|
+
server.close();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
else
|
|
81
|
+
server.close();
|
|
82
|
+
}
|
|
83
|
+
if (tries === 0)
|
|
84
|
+
return resolve(false);
|
|
98
85
|
});
|
|
99
86
|
}
|
|
100
87
|
exports.randomTCPPort = randomTCPPort;
|
|
88
|
+
//# sourceMappingURL=randomTCPPort.js.map
|
package/ts/funcs/utcnow.js
CHANGED
package/ts/funcs/validEmail.js
CHANGED
|
@@ -18,3 +18,4 @@ function validEmail(email) {
|
|
|
18
18
|
return (/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/).test(email);
|
|
19
19
|
}
|
|
20
20
|
exports.validEmail = validEmail;
|
|
21
|
+
//# sourceMappingURL=validEmail.js.map
|
package/ts/funcs/validIp.js
CHANGED
package/ts/funcs/vaultFill.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.vaultFill = void 0;
|
|
13
4
|
const debug_1 = require("debug");
|
|
@@ -19,31 +10,29 @@ function vaultFill(vaultInstance, inputObject, ignoreError = false, keepCache =
|
|
|
19
10
|
// if you call it again, it does reload the configuration
|
|
20
11
|
// v2.2
|
|
21
12
|
// supports keepCache - if vault fails, we will keep previous values instead of filling with false
|
|
22
|
-
return new Promise(function (resolve, reject) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
vaultResults[val] = false;
|
|
42
|
-
}
|
|
13
|
+
return new Promise(async function (resolve, reject) {
|
|
14
|
+
let vaultKeys = Array();
|
|
15
|
+
let vaultResults = {};
|
|
16
|
+
findVaultKeyMappings(inputObject, vaultKeys);
|
|
17
|
+
// read these keys from vault
|
|
18
|
+
for (let idx in vaultKeys) {
|
|
19
|
+
const val = vaultKeys[idx];
|
|
20
|
+
if (typeof val !== "string")
|
|
21
|
+
continue;
|
|
22
|
+
try {
|
|
23
|
+
let got = await (0, vaultRead_1.vaultRead)(vaultInstance, vaultKeys[idx]);
|
|
24
|
+
got['__vaultkey'] = val;
|
|
25
|
+
got['__vaultfilled'] = Date.now();
|
|
26
|
+
vaultResults[val] = got;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
dbg(`Could not read vaultKey '${val}'`, err);
|
|
30
|
+
if (!ignoreError)
|
|
31
|
+
vaultResults[val] = false;
|
|
43
32
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
}
|
|
34
|
+
fillVaultKeyMappings(inputObject, vaultResults, keepCache);
|
|
35
|
+
resolve(true);
|
|
47
36
|
});
|
|
48
37
|
}
|
|
49
38
|
exports.vaultFill = vaultFill;
|
|
@@ -94,3 +83,4 @@ function fillVaultKeyMappings(config, vaultResults, keepCache = true) {
|
|
|
94
83
|
}
|
|
95
84
|
}
|
|
96
85
|
}
|
|
86
|
+
//# sourceMappingURL=vaultFill.js.map
|
package/ts/funcs/vaultRead.js
CHANGED
package/ts/funcs/wait.js
CHANGED
package/ts/global.js
CHANGED
package/ts/index.d.ts
CHANGED
package/ts/index.js
CHANGED
|
@@ -38,3 +38,5 @@ __exportStar(require("./funcs/getMysql1"), exports);
|
|
|
38
38
|
__exportStar(require("./funcs/getMysql2"), exports);
|
|
39
39
|
__exportStar(require("./funcs/initMysql2Pool"), exports);
|
|
40
40
|
__exportStar(require("./funcs/randomUTFString"), exports);
|
|
41
|
+
__exportStar(require("./funcs/MaxRuntimeHours"), exports);
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
package/ts/index.ts
CHANGED
|
@@ -21,4 +21,5 @@ export * from "./funcs/isLANIp"
|
|
|
21
21
|
export * from "./funcs/getMysql1"
|
|
22
22
|
export * from "./funcs/getMysql2"
|
|
23
23
|
export * from "./funcs/initMysql2Pool"
|
|
24
|
-
export * from "./funcs/randomUTFString"
|
|
24
|
+
export * from "./funcs/randomUTFString"
|
|
25
|
+
export * from "./funcs/MaxRuntimeHours"
|
package/ts/types.js
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,113 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
// "
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
-
|
|
46
|
-
/* JavaScript Support */
|
|
47
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
-
|
|
51
|
-
/* Emit */
|
|
52
|
-
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
59
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
-
|
|
76
|
-
/* Interop Constraints */
|
|
77
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
-
|
|
84
|
-
/* Type Checking */
|
|
85
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
-
|
|
105
|
-
/* Completeness */
|
|
106
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2017",
|
|
4
|
+
"experimentalDecorators": true,
|
|
5
|
+
"emitDecoratorMetadata": true,
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"moduleResolution" : "Node",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noImplicitReturns": true, // Report error when not all code paths in function return a value
|
|
12
|
+
"noUnusedLocals": true, // Report errors on unused locals
|
|
13
|
+
// "noUnusedParameters": true, // Report errors on unused parameters
|
|
14
|
+
"noFallthroughCasesInSwitch": true, // Report errors for fallthrough cases in switch statement
|
|
15
|
+
// "noUncheckedIndexedAccess": true, // Include 'undefined' in index signature results
|
|
16
|
+
"noImplicitAny": true, // Raise error on expressions and declarations with an implied 'any' type
|
|
17
|
+
"strictNullChecks": true, // Enable strict null checking
|
|
18
|
+
"strictFunctionTypes": true, // Ensure function parameter types match
|
|
19
|
+
"strictBindCallApply": true, // Ensure 'bind', 'call', and 'apply' methods match function types
|
|
20
|
+
"strictPropertyInitialization": true, // Ensure non-undefined class properties are initialized in the constructor
|
|
21
|
+
"alwaysStrict": true, // Parse in strict mode and emit "use strict" for each source file
|
|
22
|
+
"sourceMap": true,
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
"baseUrl": ".",
|
|
25
|
+
"paths": {
|
|
26
|
+
"@root/*": ["./*"],
|
|
27
|
+
"@models/*": ["./models/*"],
|
|
28
|
+
"@inc/*": ["./inc/ts/*"]
|
|
29
|
+
}
|
|
109
30
|
},
|
|
110
31
|
"exclude": [
|
|
111
|
-
"**/*.test.ts"
|
|
32
|
+
"**/*.test.ts"
|
|
112
33
|
]
|
|
113
|
-
}
|
|
34
|
+
}
|