mybase 1.1.19 → 1.1.21

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.
Files changed (42) hide show
  1. package/package.json +4 -3
  2. package/ts/funcs/Geoip2Paths.js +1 -0
  3. package/ts/funcs/MaxRuntimeHours.d.ts +1 -0
  4. package/ts/funcs/MaxRuntimeHours.js +11 -0
  5. package/ts/funcs/MaxRuntimeHours.ts +7 -0
  6. package/ts/funcs/asJSON.js +1 -0
  7. package/ts/funcs/fileCacheIsValid.js +1 -0
  8. package/ts/funcs/getMysql1.js +26 -36
  9. package/ts/funcs/getMysql2.d.ts +2 -1
  10. package/ts/funcs/getMysql2.js +26 -36
  11. package/ts/funcs/getMysql2.ts +2 -2
  12. package/ts/funcs/hash_sha512.js +1 -0
  13. package/ts/funcs/initMysql2Pool.js +1 -0
  14. package/ts/funcs/int2ip.js +1 -0
  15. package/ts/funcs/ip2int.js +1 -0
  16. package/ts/funcs/isLANIp.js +1 -0
  17. package/ts/funcs/isLocal.js +1 -0
  18. package/ts/funcs/isLoopbackIP.js +1 -0
  19. package/ts/funcs/promiseTimeout.js +1 -0
  20. package/ts/funcs/randomIP.js +1 -0
  21. package/ts/funcs/randomIP6.js +1 -0
  22. package/ts/funcs/randomString.js +1 -0
  23. package/ts/funcs/randomTCPPort.js +46 -58
  24. package/ts/funcs/randomTCPPort.ts +0 -1
  25. package/ts/funcs/randomUTFString.js +1 -0
  26. package/ts/funcs/utcnow.js +1 -0
  27. package/ts/funcs/validEmail.js +1 -0
  28. package/ts/funcs/validIp.js +1 -0
  29. package/ts/funcs/vaultFill.js +23 -33
  30. package/ts/funcs/vaultRead.js +1 -0
  31. package/ts/funcs/wait.js +1 -0
  32. package/ts/global.js +1 -0
  33. package/ts/index.d.ts +1 -0
  34. package/ts/index.js +5 -0
  35. package/ts/index.ts +8 -1
  36. package/ts/models/Timespan.js +52 -0
  37. package/ts/models/Timespan.ts +66 -0
  38. package/ts/models/Unixtime.js +120 -0
  39. package/ts/models/Unixtime.test.ts +98 -0
  40. package/ts/models/Unixtime.ts +144 -0
  41. package/ts/types.js +1 -0
  42. package/tsconfig.json +30 -109
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mybase",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "",
5
5
  "main": "mybase.js",
6
6
  "scripts": {
@@ -25,13 +25,14 @@
25
25
  "validator": "^13.7.0",
26
26
  "@types/debug": "^4.1.12",
27
27
  "@types/ip6addr": "^0.2.6",
28
- "@types/jest": "^29.5.11",
29
28
  "@types/mysql": "^2.15.25",
30
29
  "@types/node": "^20.11.5",
31
- "@types/validator": "^13.11.8"
30
+ "@types/validator": "^13.11.8",
31
+ "@types/request": "^2.48.12"
32
32
  },
33
33
  "devDependencies": {
34
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",
@@ -20,3 +20,4 @@ function Geoip2Paths() {
20
20
  };
21
21
  }
22
22
  exports.Geoip2Paths = Geoip2Paths;
23
+ //# sourceMappingURL=Geoip2Paths.js.map
@@ -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
@@ -0,0 +1,7 @@
1
+
2
+ export function MaxRuntimeHours(hours:number=24) {
3
+ setTimeout(() => {
4
+ console.log(`Max runtime of ${hours} hours reached, exiting`)
5
+ process.exit(0)
6
+ }, hours * 60 * 60 * 1000)
7
+ }
@@ -11,3 +11,4 @@ function asJSON(inputString) {
11
11
  return false;
12
12
  }
13
13
  exports.asJSON = asJSON;
14
+ //# sourceMappingURL=asJSON.js.map
@@ -37,3 +37,4 @@ function fileCacheIsValid(cacheFileName, cache_in_minutes = 60) {
37
37
  return false;
38
38
  }
39
39
  exports.fileCacheIsValid = fileCacheIsValid;
40
+ //# sourceMappingURL=fileCacheIsValid.js.map
@@ -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 __awaiter(this, void 0, void 0, function* () {
44
- return new Promise((resolve, reject) => {
45
- const mysql_client = mysql1.createConnection({
46
- host: config.host,
47
- port: config.port ? config.port : 3306,
48
- user: config.login,
49
- password: config.password,
50
- database: config.db
51
- });
52
- mysql_client.connect((err, res) => {
53
- if (err) {
54
- dbg(`mysql connection has failed to ${config.host}@${config.db}`, err);
55
- return reject(err);
56
- }
57
- dbg(`mysql connection has been established to ${config.host}@${config.db}`);
58
- // install a pinger every 30 seconds to keep the connection alive
59
- if (pingInterval > 0)
60
- setInterval(() => {
61
- mysql_client.ping(function (err) {
62
- if (err)
63
- return console.log(`could not ping mysql ${config.host}@${config.db}`, err.code);
64
- dbg(`mysql ${config.host}@${config.db} is pinging properly`);
65
- });
66
- }, pingInterval);
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
@@ -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<unknown>;
9
+ export declare function getMysql2(config: Mysql2ServerConfiguration, pingInterval?: number): Promise<Connection>;
@@ -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 __awaiter(this, void 0, void 0, function* () {
44
- return new Promise((resolve, reject) => {
45
- const mysql_client = mysql2.createConnection({
46
- host: config.host,
47
- port: config.port ? config.port : 3306,
48
- user: config.login,
49
- password: config.password,
50
- database: config.db
51
- });
52
- mysql_client.connect((err) => {
53
- if (err) {
54
- dbg(`mysql connection has failed to ${config.host}@${config.db}`, err);
55
- return reject(err);
56
- }
57
- dbg(`mysql connection has been established to ${config.host}@${config.db}`);
58
- // install a pinger every 30 seconds to keep the connection alive
59
- if (pingInterval > 0)
60
- setInterval(() => {
61
- mysql_client.ping(function (err) {
62
- if (err)
63
- return console.log(`could not ping mysql ${config.host}@${config.db}`, err.code);
64
- dbg(`mysql ${config.host}@${config.db} is pinging properly`);
65
- });
66
- }, pingInterval);
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
@@ -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,
@@ -8,3 +8,4 @@ function hash_sha512(plainString) {
8
8
  return "";
9
9
  }
10
10
  exports.hash_sha512 = hash_sha512;
11
+ //# sourceMappingURL=hash_sha512.js.map
@@ -36,3 +36,4 @@ function initMysql2Pool(sqlServer) {
36
36
  return mysql2.createPool(connectionUri);
37
37
  }
38
38
  exports.initMysql2Pool = initMysql2Pool;
39
+ //# sourceMappingURL=initMysql2Pool.js.map
@@ -15,3 +15,4 @@ function int2ip(ipInt) {
15
15
  return ip4;
16
16
  }
17
17
  exports.int2ip = int2ip;
18
+ //# sourceMappingURL=int2ip.js.map
@@ -15,3 +15,4 @@ function ip2int(ip) {
15
15
  return ip.split('.').reduce(function (ipInt, octet) { return (ipInt << 8) + parseInt(octet, 10); }, 0) >>> 0;
16
16
  }
17
17
  exports.ip2int = ip2int;
18
+ //# sourceMappingURL=ip2int.js.map
@@ -44,3 +44,4 @@ function isLANIp(ip) {
44
44
  return false;
45
45
  }
46
46
  exports.isLANIp = isLANIp;
47
+ //# sourceMappingURL=isLANIp.js.map
@@ -9,3 +9,4 @@ function isLocal() {
9
9
  return (os_1.default.type() === 'Darwin');
10
10
  }
11
11
  exports.isLocal = isLocal;
12
+ //# sourceMappingURL=isLocal.js.map
@@ -37,3 +37,4 @@ function isLoopbackIP(ip) {
37
37
  return false;
38
38
  }
39
39
  exports.isLoopbackIP = isLoopbackIP;
40
+ //# sourceMappingURL=isLoopbackIP.js.map
@@ -16,3 +16,4 @@ function promiseTimeout(miliseconds, inputPromise, onTimeout = 'TIMEDOUT') {
16
16
  ]);
17
17
  }
18
18
  exports.promiseTimeout = promiseTimeout;
19
+ //# sourceMappingURL=promiseTimeout.js.map
@@ -8,3 +8,4 @@ function randomIP() {
8
8
  return int2ip(Math.random() * Math.pow(2, 32));
9
9
  }
10
10
  exports.randomIP = randomIP;
11
+ //# sourceMappingURL=randomIP.js.map
@@ -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
@@ -5,3 +5,4 @@ function randomString(length = 10, charSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh
5
5
  return Array.from({ length }, () => charSet.charAt(Math.floor(Math.random() * charSet.length))).join('');
6
6
  }
7
7
  exports.randomString = randomString;
8
+ //# sourceMappingURL=randomString.js.map
@@ -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 __awaiter(this, void 0, void 0, function* () {
50
- return new Promise(function (resolve, reject) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- // check if the given port range is valid
53
- if (fromPort > untilPort)
54
- return resolve(false);
55
- // check if the given port range is valid
56
- if (fromPort < 0 || untilPort < 0)
57
- return resolve(false);
58
- // check if the given port range is valid
59
- if (fromPort > 65535 || untilPort > 65535)
60
- return resolve(false);
61
- // 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
62
- // this port number immediately
63
- // this function should be used for testing purposes only
64
- // this function is not suitable for production use
65
- while (true && tries > 0) {
66
- tries--;
67
- let port = Math.floor(Math.random() * (untilPort - fromPort + 1) + fromPort);
68
- let server = net.createServer();
69
- let checkPort = new Promise((resolveInner, reject) => {
70
- server.on('error', (err) => {
71
- // any error should raise problem
72
- resolveInner(false);
73
- });
74
- server.on('listening', () => {
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
@@ -1,4 +1,3 @@
1
- import { wait } from './wait'
2
1
  import * as net from 'net'
3
2
 
4
3
  /**
@@ -28,3 +28,4 @@ function randomUTFString(minLength, maxLength, includeAscii = true) {
28
28
  return result;
29
29
  }
30
30
  exports.randomUTFString = randomUTFString;
31
+ //# sourceMappingURL=randomUTFString.js.map
@@ -5,3 +5,4 @@ function utcnow() {
5
5
  return Math.floor(Date.now() / 1000);
6
6
  }
7
7
  exports.utcnow = utcnow;
8
+ //# sourceMappingURL=utcnow.js.map
@@ -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
@@ -29,3 +29,4 @@ function validIp(IPAddress) {
29
29
  return net.isIP(IPAddress);
30
30
  }
31
31
  exports.validIp = validIp;
32
+ //# sourceMappingURL=validIp.js.map
@@ -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
- return __awaiter(this, void 0, void 0, function* () {
24
- let vaultKeys = Array();
25
- let vaultResults = {};
26
- findVaultKeyMappings(inputObject, vaultKeys);
27
- // read these keys from vault
28
- for (let idx in vaultKeys) {
29
- const val = vaultKeys[idx];
30
- if (typeof val !== "string")
31
- continue;
32
- try {
33
- let got = yield (0, vaultRead_1.vaultRead)(vaultInstance, vaultKeys[idx]);
34
- got['__vaultkey'] = val;
35
- got['__vaultfilled'] = Date.now();
36
- vaultResults[val] = got;
37
- }
38
- catch (err) {
39
- dbg(`Could not read vaultKey '${val}'`, err);
40
- if (!ignoreError)
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
- fillVaultKeyMappings(inputObject, vaultResults, keepCache);
45
- resolve(true);
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
@@ -49,3 +49,4 @@ function vaultRead(vaultInstance, vaultKey, cache_in_minutes = 10) {
49
49
  });
50
50
  }
51
51
  exports.vaultRead = vaultRead;
52
+ //# sourceMappingURL=vaultRead.js.map
package/ts/funcs/wait.js CHANGED
@@ -7,3 +7,4 @@ function wait(seconds = 1) {
7
7
  });
8
8
  }
9
9
  exports.wait = wait;
10
+ //# sourceMappingURL=wait.js.map
package/ts/global.js CHANGED
@@ -13,3 +13,4 @@ try {
13
13
  catch (e) {
14
14
  console.log(e);
15
15
  }
16
+ //# sourceMappingURL=global.js.map
package/ts/index.d.ts CHANGED
@@ -22,3 +22,4 @@ export * from "./funcs/getMysql1";
22
22
  export * from "./funcs/getMysql2";
23
23
  export * from "./funcs/initMysql2Pool";
24
24
  export * from "./funcs/randomUTFString";
25
+ export * from "./funcs/MaxRuntimeHours";
package/ts/index.js CHANGED
@@ -38,3 +38,8 @@ __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
+ // models
43
+ __exportStar(require("./models/Unixtime"), exports);
44
+ __exportStar(require("./models/Timespan"), exports);
45
+ //# sourceMappingURL=index.js.map
package/ts/index.ts CHANGED
@@ -21,4 +21,11 @@ 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"
26
+
27
+
28
+
29
+ // models
30
+ export * from "./models/Unixtime"
31
+ export * from "./models/Timespan"