dce-expresskit 4.0.0-beta.3 → 4.0.0-beta.5
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/genEncodedSecret.ts +11 -14
- package/genSalt.ts +15 -0
- package/package.json +3 -2
- package/src/helpers/initServer.ts +3 -5
package/genEncodedSecret.ts
CHANGED
|
@@ -39,7 +39,7 @@ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
39
39
|
|
|
40
40
|
// Get salt
|
|
41
41
|
console.log('Encoding salt on the *receiving* server')
|
|
42
|
-
const
|
|
42
|
+
const salt = await prompt('Salt: ');
|
|
43
43
|
|
|
44
44
|
// Get host
|
|
45
45
|
console.log('Hostname of the *receiving* server');
|
|
@@ -49,23 +49,19 @@ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
49
49
|
console.log('This is the server that sends requests to the receiving server.\n');
|
|
50
50
|
|
|
51
51
|
// Get key
|
|
52
|
-
console.log('Short unique key for the *sending* server')
|
|
53
|
-
const key = await prompt('Key: ');
|
|
52
|
+
console.log('Short unique key for the *sending* server (only letters and dashes, no whitespace)')
|
|
53
|
+
const key = (await prompt('Key: ')).trim();
|
|
54
54
|
|
|
55
55
|
// Get description
|
|
56
56
|
console.log('Human-readable description of the *sending* server')
|
|
57
57
|
const description = await prompt('Description: ');
|
|
58
58
|
|
|
59
|
-
//
|
|
60
|
-
let secret =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
secret = '';
|
|
64
|
-
for (let i = 0; i < 32; i++) {
|
|
65
|
-
secret += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
66
|
-
}
|
|
67
|
-
console.log('Generated a random secret. If you have one in mind, use --secret=...');
|
|
59
|
+
// Generate a random secret
|
|
60
|
+
let secret = '';
|
|
61
|
+
for (let i = 0; i < 32; i++) {
|
|
62
|
+
secret += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
68
63
|
}
|
|
64
|
+
secret = Buffer.from(secret).toString('base64');
|
|
69
65
|
|
|
70
66
|
// Encryption process based on:
|
|
71
67
|
// https://medium.com/@tony.infisical/guide-to-nodes-crypto-module-for-encryption-decryption-65c077176980
|
|
@@ -74,9 +70,10 @@ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
74
70
|
const iv = crypto.randomBytes(12).toString('base64');
|
|
75
71
|
|
|
76
72
|
// Create a cipher
|
|
73
|
+
console.log('salt', salt, Buffer.from(salt, 'base64'));
|
|
77
74
|
const cipher = crypto.createCipheriv(
|
|
78
75
|
'aes-256-gcm',
|
|
79
|
-
Buffer.from(
|
|
76
|
+
Buffer.from(salt, 'base64'),
|
|
80
77
|
Buffer.from(iv, 'base64'),
|
|
81
78
|
);
|
|
82
79
|
|
|
@@ -100,7 +97,7 @@ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
100
97
|
console.log('\n\n');
|
|
101
98
|
console.log('––––– Done! What\'s Next: –––––');
|
|
102
99
|
console.log('');
|
|
103
|
-
console.log('On the *sending* server,
|
|
100
|
+
console.log('On the *sending* server, !!APPEND!! the following to the DCEKIT_CROSS_SERVER_CREDENTIALS env var:');
|
|
104
101
|
console.log(`|${host}:${key}:${secret}|`);
|
|
105
102
|
console.log('');
|
|
106
103
|
console.log('On the *receiving* server, add an entry to its "CrossServerCredential" collection:');
|
package/genSalt.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// All chars for randomizer
|
|
2
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
3
|
+
|
|
4
|
+
// Generate a random salt
|
|
5
|
+
let salt = '';
|
|
6
|
+
for (let i = 0; i < 32; i++) {
|
|
7
|
+
salt += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
8
|
+
}
|
|
9
|
+
salt = Buffer.from(salt).toString('base64');
|
|
10
|
+
|
|
11
|
+
// Generates 32 byte salt
|
|
12
|
+
console.log('New *receiving* server salt:')
|
|
13
|
+
|
|
14
|
+
Buffer.from("Hello World").toString('base64')
|
|
15
|
+
console.log(salt);
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dce-expresskit",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.5",
|
|
4
4
|
"description": "Shared functions, helpers, and tools for Harvard DCE Express-based servers",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc --project ./tsconfig.json",
|
|
9
|
-
"gen-cross-server-secret": "npx tsx genEncodedSecret.ts"
|
|
9
|
+
"gen-cross-server-secret": "npx tsx genEncodedSecret.ts",
|
|
10
|
+
"gen-cross-server-salt": "npx tsx genSalt.ts"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
@@ -9,13 +9,11 @@ import {
|
|
|
9
9
|
ErrorWithCode,
|
|
10
10
|
ParamType,
|
|
11
11
|
LogFunction,
|
|
12
|
+
LOG_REVIEW_ROUTE_PATH_PREFIX,
|
|
13
|
+
LOG_ROUTE_PATH,
|
|
14
|
+
LOG_REVIEW_STATUS_ROUTE,
|
|
12
15
|
} from 'dce-reactkit';
|
|
13
16
|
|
|
14
|
-
// Import internal constants of dce-reactkit
|
|
15
|
-
import LOG_REVIEW_ROUTE_PATH_PREFIX from 'dce-reactkit/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX';
|
|
16
|
-
import LOG_ROUTE_PATH from 'dce-reactkit/src/constants/LOG_ROUTE_PATH';
|
|
17
|
-
import LOG_REVIEW_STATUS_ROUTE from 'dce-reactkit/src/constants/LOG_REVIEW_STATUS_ROUTE';
|
|
18
|
-
|
|
19
17
|
// Import shared helpers
|
|
20
18
|
import genRouteHandler from './genRouteHandler';
|
|
21
19
|
|