@nsshunt/stsutils 1.5.0 → 1.5.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/authutils.js +10 -5
- package/package.json +1 -1
- package/stsutils.js +1 -3
- package/log.js +0 -33
- package/network.js +0 -37
package/authutils.js
CHANGED
|
@@ -22,20 +22,25 @@ class AuthUtils
|
|
|
22
22
|
// http://travistidwell.com/jsencrypt/demo/
|
|
23
23
|
// https://www.csfieldguide.org.nz/en/interactives/rsa-key-generator/
|
|
24
24
|
// https://jwt.io/
|
|
25
|
-
|
|
26
|
-
// This code is for development / non-prod purposes only.
|
|
27
|
-
// For production, the keys to come from a secrets store.
|
|
28
|
-
this.#privateKey = fs.readFileSync(goptions.asprivatekeypath, 'utf8');
|
|
29
|
-
this.#publicKey = fs.readFileSync(goptions.aspublickeypath, 'utf8');
|
|
30
25
|
}
|
|
31
26
|
|
|
27
|
+
// This code is for development / non-prod purposes only.
|
|
28
|
+
// For production, the keys to come from a secrets store.
|
|
32
29
|
get privateKey()
|
|
33
30
|
{
|
|
31
|
+
if (this.#privateKey === null) {
|
|
32
|
+
this.#privateKey = fs.readFileSync(goptions.asprivatekeypath, 'utf8');
|
|
33
|
+
}
|
|
34
34
|
return this.#privateKey;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// This code is for development / non-prod purposes only.
|
|
38
|
+
// For production, the keys to come from a secrets store.
|
|
37
39
|
get publicKey()
|
|
38
40
|
{
|
|
41
|
+
if (this.#publicKey === null) {
|
|
42
|
+
this.#publicKey = fs.readFileSync(goptions.aspublickeypath, 'utf8');
|
|
43
|
+
}
|
|
39
44
|
return this.#publicKey;
|
|
40
45
|
}
|
|
41
46
|
|
package/package.json
CHANGED
package/stsutils.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
let sleep = require('./sleep.js');
|
|
2
2
|
let status = require('./status.js');
|
|
3
|
-
let network = require('./network.js');
|
|
4
3
|
let authutils = require('./authutils.js');
|
|
5
4
|
let stsoptionsbase = require('./stsoptionsbase.js');
|
|
6
5
|
let stsrouterbase = require('./stsrouterbase.js');
|
|
7
|
-
let log = require('./log.js');
|
|
8
6
|
|
|
9
|
-
module.exports = { sleep, status,
|
|
7
|
+
module.exports = { sleep, status, authutils, stsoptionsbase, stsrouterbase };
|
package/log.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const cluster = require('cluster');
|
|
2
|
-
const colors = require('colors');
|
|
3
|
-
const debug = require('debug')(`proc:${process.pid}`);
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Default styles :-
|
|
7
|
-
* Worker messages - green
|
|
8
|
-
* Master messages - cyan + bold
|
|
9
|
-
* IPC Messages - grey. The message command itself will be bold.
|
|
10
|
-
* Signals - yellow (e.g. SIGINT or SIGTERM etc.
|
|
11
|
-
* @param {*} instruments
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
module.exports = (appName, instruments) =>
|
|
15
|
-
{
|
|
16
|
-
return (msg) =>
|
|
17
|
-
{
|
|
18
|
-
let prefix = '';
|
|
19
|
-
let col = null;
|
|
20
|
-
|
|
21
|
-
if (cluster.isMaster)
|
|
22
|
-
{
|
|
23
|
-
prefix = 'M';
|
|
24
|
-
col = colors.bold.cyan;
|
|
25
|
-
} else {
|
|
26
|
-
prefix = 'W';
|
|
27
|
-
col = colors.green;
|
|
28
|
-
}
|
|
29
|
-
let msgEx = col(`${prefix}(${process.pid}) [${appName}]: ${msg}`);
|
|
30
|
-
debug(msgEx);
|
|
31
|
-
instruments.logger.LogMessage(msgEx);
|
|
32
|
-
};
|
|
33
|
-
};
|
package/network.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
|
-
|
|
3
|
-
const GetNetworkInterfaces = () =>
|
|
4
|
-
{
|
|
5
|
-
const nets = os.networkInterfaces();
|
|
6
|
-
let results = { };
|
|
7
|
-
for (const name of Object.keys(nets)) {
|
|
8
|
-
for (const net of nets[name]) {
|
|
9
|
-
// Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
|
|
10
|
-
if (net.family === 'IPv4' && !net.internal) {
|
|
11
|
-
if (!results[name]) {
|
|
12
|
-
results[name] = [];
|
|
13
|
-
}
|
|
14
|
-
results[name].push(net.address);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return results;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const GetFirstNetworkInterface = () =>
|
|
22
|
-
{
|
|
23
|
-
let nics = GetNetworkInterfaces();
|
|
24
|
-
let hostaddr = null;
|
|
25
|
-
for (let nic in nics)
|
|
26
|
-
{
|
|
27
|
-
let val = nics[nic];
|
|
28
|
-
if (val.length > 0)
|
|
29
|
-
{
|
|
30
|
-
hostaddr = val[0];
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return hostaddr;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = { GetNetworkInterfaces, GetFirstNetworkInterface }
|