hof 22.11.9 → 22.12.0
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/CHANGELOG.md +20 -0
- package/config/hof-defaults.js +1 -1
- package/lib/encryption.js +43 -17
- package/lib/sessions.js +5 -2
- package/lib/settings.js +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 2025-11-20, Version 22.12.0 (Stable), @dk4g @jamiecarterHO
|
|
2
|
+
|
|
3
|
+
### Infrastructure
|
|
4
|
+
- Updated CI/CD pipeline to test against Node.js 20.x, 22.x, and 24.x
|
|
5
|
+
- Updated Redis testing versions to 7 and 8
|
|
6
|
+
- Added `NODE_VERSION` environment variable for consistent Node.js version across jobs
|
|
7
|
+
- Updated release process to use Node.js 24 for tagging and publishing operations
|
|
8
|
+
|
|
9
|
+
### Security
|
|
10
|
+
- Replaced deprecated `crypto.createCipher`/`crypto.createDecipher` with `crypto.createCipheriv`/`crypto.createDecipheriv`
|
|
11
|
+
- Added proper initialisation vector (IV) handling for enhanced security
|
|
12
|
+
- Enforced 32-byte session secret requirement for AES-256 encryption compatibility
|
|
13
|
+
- Removed insecure default session secret ('changethis') - now requires explicit configuration
|
|
14
|
+
|
|
15
|
+
### Migration Notes
|
|
16
|
+
- **Session Reset Required**: Due to enhanced encryption security, existing user sessions will be invalidated and users will need to re-authenticate after this update
|
|
17
|
+
- **Session Secret**: You must now set a unique `SESSION_SECRET` environment variable of exactly 32 bytes for encryption compatibility.
|
|
18
|
+
For testing purposes, you can use the following command to generate a random value. For production environments, consult a security expert or refer to official cryptographic guidelines to generate a secure secret
|
|
19
|
+
`node -e "console.log(require('crypto').randomBytes(16).toString('hex'))"`
|
|
20
|
+
|
|
1
21
|
## 2025-11-15, Version 22.11.0 (Stable), @Rhodine-orleans-lindsay
|
|
2
22
|
|
|
3
23
|
### Changed
|
package/config/hof-defaults.js
CHANGED
package/lib/encryption.js
CHANGED
|
@@ -1,23 +1,49 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
1
|
'use strict';
|
|
3
2
|
|
|
4
|
-
const crypto = require('crypto');
|
|
3
|
+
const crypto = require('node:crypto');
|
|
5
4
|
const algorithm = 'aes-256-cbc';
|
|
5
|
+
const ivLength = 16;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return dec;
|
|
7
|
+
/**
|
|
8
|
+
* Creates an encryption utility with AES-256-CBC algorithm.
|
|
9
|
+
* Provides encrypt and decrypt methods that use a random IV for each encryption operation.
|
|
10
|
+
*
|
|
11
|
+
* @module encryption
|
|
12
|
+
* @param {string|Buffer} secret - Must be exactly 32 bytes
|
|
13
|
+
* @returns {Object} Encryption utility object
|
|
14
|
+
* @throws {Error} If secret is not exactly 32 bytes
|
|
15
|
+
*/
|
|
16
|
+
module.exports = secret => {
|
|
17
|
+
const encryptionKey = Buffer.from(secret, 'utf8');
|
|
18
|
+
if (encryptionKey.byteLength !== 32) {
|
|
19
|
+
throw new Error(`Encryption secret must be exactly 32 bytes. Provided: ${encryptionKey.byteLength} bytes.`);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
return {
|
|
23
|
+
encrypt: text => {
|
|
24
|
+
try {
|
|
25
|
+
const iv = crypto.randomBytes(ivLength);
|
|
26
|
+
const cipher = crypto.createCipheriv(algorithm, encryptionKey, iv);
|
|
27
|
+
let encrypted = cipher.update(text, 'utf8');
|
|
28
|
+
encrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
29
|
+
return iv.toString('hex') + ':' + encrypted.toString('hex');
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new Error(`Encryption failed: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
decrypt: text => {
|
|
36
|
+
try {
|
|
37
|
+
const textParts = text.split(':');
|
|
38
|
+
const iv = Buffer.from(textParts.shift(), 'hex');
|
|
39
|
+
const encryptedText = Buffer.from(textParts.join(':'), 'hex');
|
|
40
|
+
const decipher = crypto.createDecipheriv(algorithm, encryptionKey, iv);
|
|
41
|
+
let decrypted = decipher.update(encryptedText);
|
|
42
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
43
|
+
return decrypted.toString('utf8');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new Error(`Decryption failed: ${error.message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
package/lib/sessions.js
CHANGED
|
@@ -10,8 +10,11 @@ const secureHttps = config => config.protocol === 'https' || config.env === 'pro
|
|
|
10
10
|
module.exports = (app, config) => {
|
|
11
11
|
const logger = config.logger || console;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const secretBuffer = Buffer.from(config.session.secret, 'utf8');
|
|
14
|
+
if (secretBuffer.byteLength !== 32) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Session secret must be exactly 32 bytes. Current: ${secretBuffer.byteLength} bytes.`
|
|
17
|
+
);
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
app.use(cookieParser(config.session.secret, {
|
package/lib/settings.js
CHANGED
|
@@ -42,7 +42,7 @@ module.exports = async (app, config) => {
|
|
|
42
42
|
viewsArray.slice().reverse().forEach(view => {
|
|
43
43
|
const customViewPath = path.resolve(config.root, view);
|
|
44
44
|
try {
|
|
45
|
-
fs.accessSync(customViewPath, fs.F_OK);
|
|
45
|
+
fs.accessSync(customViewPath, fs.constants.F_OK);
|
|
46
46
|
} catch (err) {
|
|
47
47
|
throw new Error(`Cannot find views at ${customViewPath}`);
|
|
48
48
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hof",
|
|
3
3
|
"description": "A bootstrap for HOF projects",
|
|
4
|
-
"version": "22.
|
|
4
|
+
"version": "22.12.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": "HomeOffice",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
10
|
-
"npm": ">=6.14.0"
|
|
9
|
+
"node": ">=14.0.0"
|
|
11
10
|
},
|
|
12
11
|
"bin": {
|
|
13
12
|
"hof-build": "./bin/hof-build",
|