@vulkano/core 1.16.1 → 1.17.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/bootstrap/express.js +1 -0
- package/bootstrap/server.js +6 -6
- package/database/scaffold.js +18 -1
- package/libs/Encrypter.js +7 -3
- package/package.json +3 -3
- package/responses/vsr.js +1 -1
package/bootstrap/express.js
CHANGED
package/bootstrap/server.js
CHANGED
|
@@ -61,7 +61,9 @@ module.exports = function loadServer() {
|
|
|
61
61
|
app.vulkano = vulkano;
|
|
62
62
|
|
|
63
63
|
// Settings
|
|
64
|
-
|
|
64
|
+
// trustProxy: true = trust all proxies, 1 = trust one hop (recommended behind a single LB)
|
|
65
|
+
const trustProxy = expressConfig.trustProxy !== undefined ? expressConfig.trustProxy : 1;
|
|
66
|
+
vulkano.set('trust proxy', trustProxy);
|
|
65
67
|
|
|
66
68
|
// ---------------
|
|
67
69
|
// PORT - File: app/config/express/settings.js
|
|
@@ -148,7 +150,7 @@ module.exports = function loadServer() {
|
|
|
148
150
|
vulkano.use( (req, res, next) => {
|
|
149
151
|
|
|
150
152
|
const proto = req.secure ? 'https' : 'http';
|
|
151
|
-
const forwarded = req.headers['x-
|
|
153
|
+
const forwarded = req.headers['x-forwarded-proto'] || null;
|
|
152
154
|
const currentProtocol = (forwarded || proto).split('://')[0];
|
|
153
155
|
req.protocol = currentProtocol;
|
|
154
156
|
|
|
@@ -173,12 +175,10 @@ module.exports = function loadServer() {
|
|
|
173
175
|
tmpCustomHeaders = tmpCustomHeaders.concat(expressConfig.cors.headers || []);
|
|
174
176
|
res.header('Access-Control-Allow-Origin', expressConfig.cors.origin);
|
|
175
177
|
res.header('Access-Control-Allow-Headers', tmpCustomHeaders.join(', '));
|
|
176
|
-
|
|
177
|
-
res.header('Access-Control-Allow-Origin', '*');
|
|
178
|
-
res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept');
|
|
178
|
+
res.header('Access-Control-Allow-Methods', 'GET,PUT,PATCH,POST,DELETE,OPTIONS');
|
|
179
179
|
}
|
|
180
|
+
|
|
180
181
|
res.header('Allow', 'GET,PUT,PATCH,POST,DELETE,OPTIONS');
|
|
181
|
-
res.header('Access-Control-Allow-Methods', 'GET,PUT,PATCH,POST,DELETE,OPTIONS');
|
|
182
182
|
|
|
183
183
|
res.status(200).end();
|
|
184
184
|
|
package/database/scaffold.js
CHANGED
|
@@ -80,13 +80,30 @@ module.exports = {
|
|
|
80
80
|
*/
|
|
81
81
|
update(_id, data) {
|
|
82
82
|
|
|
83
|
+
// Blocklist: these fields are never writable from outside
|
|
84
|
+
const BLOCKED = ['_id', 'createdAt', '__v'];
|
|
85
|
+
const sanitized = { ...data };
|
|
86
|
+
BLOCKED.forEach((field) => delete sanitized[field]);
|
|
87
|
+
|
|
88
|
+
// Allowlist: if fillable is defined and non-empty, only those fields pass through
|
|
89
|
+
const { fillable } = this;
|
|
90
|
+
let filtered = sanitized;
|
|
91
|
+
if (Array.isArray(fillable) && fillable.length > 0) {
|
|
92
|
+
filtered = {};
|
|
93
|
+
fillable.forEach((field) => {
|
|
94
|
+
if (sanitized[field] !== undefined) {
|
|
95
|
+
filtered[field] = sanitized[field];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
83
100
|
return this.getByField(_id)
|
|
84
101
|
.then( (record) => {
|
|
85
102
|
|
|
86
103
|
// Merge current info with incoming values
|
|
87
104
|
const merged = {
|
|
88
105
|
...record,
|
|
89
|
-
...
|
|
106
|
+
...filtered,
|
|
90
107
|
updatedAt: Date.now()
|
|
91
108
|
};
|
|
92
109
|
|
package/libs/Encrypter.js
CHANGED
|
@@ -2,10 +2,14 @@ const crypto = require('crypto');
|
|
|
2
2
|
|
|
3
3
|
class Encrypter {
|
|
4
4
|
|
|
5
|
-
constructor(encryptionKey) {
|
|
5
|
+
constructor(encryptionKey, opts = {}) {
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const { encryption } = (typeof app !== 'undefined' && app.config) ? app.config : {};
|
|
8
|
+
const salt = opts.salt || (encryption && encryption.salt) || process.env.ENCRYPTION_SALT || 'vulkano-salt-v1';
|
|
9
|
+
const algorithm = opts.algorithm || (encryption && encryption.algorithm) || process.env.ENCRYPTION_ALGORITHM || 'aes-256-cbc';
|
|
10
|
+
|
|
11
|
+
this.algorithm = algorithm;
|
|
12
|
+
this.key = crypto.scryptSync(encryptionKey, salt, 32);
|
|
9
13
|
|
|
10
14
|
}
|
|
11
15
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulkano/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "A MVC framework using Express 4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Vulkano Team",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": ">=20"
|
|
9
9
|
},
|
|
10
10
|
"main": "app.js",
|
|
11
11
|
"scripts": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"nunjucks": "^3.2.4",
|
|
54
54
|
"redis": "^5.12.1",
|
|
55
55
|
"socket.io": "^4.8.1",
|
|
56
|
-
"undici": "^
|
|
56
|
+
"undici": "^6.25.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@babel/core": "^7.26.9",
|
package/responses/vsr.js
CHANGED
|
@@ -76,7 +76,7 @@ module.exports = function VSRPromise(promiseToRun, httpStatusCode) {
|
|
|
76
76
|
errorCode: message.code || '001',
|
|
77
77
|
errorName: message.name || 'BadRequest',
|
|
78
78
|
detail: message.message || message.error || message.invalidAttributes || message.toString(),
|
|
79
|
-
output: message
|
|
79
|
+
...(app.PRODUCTION ? {} : { output: message })
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
})
|