@vulkano/core 1.6.0 → 1.8.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 +3 -0
- package/bootstrap/server.js +96 -2
- package/package.json +12 -11
package/bootstrap/express.js
CHANGED
|
@@ -41,7 +41,10 @@ module.exports = function getExpressConfiguration() {
|
|
|
41
41
|
port: ENV_NODE_PORT || ENV_PORT || expressUserPort || expressSettingsPort || 8000,
|
|
42
42
|
cors: {},
|
|
43
43
|
cookies: {},
|
|
44
|
+
csp: {},
|
|
44
45
|
jwt: {},
|
|
46
|
+
session: {},
|
|
47
|
+
permissionPolicy: {},
|
|
45
48
|
sockets: {},
|
|
46
49
|
redis: {},
|
|
47
50
|
multer: {
|
package/bootstrap/server.js
CHANGED
|
@@ -15,6 +15,7 @@ const helmet = require('helmet');
|
|
|
15
15
|
const timeout = require('connect-timeout');
|
|
16
16
|
const useragent = require('express-useragent');
|
|
17
17
|
const cookieParser = require('cookie-parser');
|
|
18
|
+
const expressSession = require('express-session');
|
|
18
19
|
const { createClient: socketRedis } = require('redis');
|
|
19
20
|
const socketMongoose = require('mongoose');
|
|
20
21
|
const { createAdapter: socketRedisAdapter } = require('@socket.io/redis-adapter');
|
|
@@ -86,12 +87,22 @@ module.exports = function loadServer() {
|
|
|
86
87
|
// ---------------
|
|
87
88
|
// COOKIES - File: app/config/express/cookies.js
|
|
88
89
|
// ---------------
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
const {
|
|
91
|
+
enabled: cookiesEnabled
|
|
92
|
+
} = expressConfig.cookies || {};
|
|
93
|
+
|
|
94
|
+
let cookiesSecretKey = null;
|
|
95
|
+
|
|
96
|
+
if (cookiesEnabled) {
|
|
97
|
+
|
|
98
|
+
cookiesSecretKey = COOKIES_SECRET_KEY || expressConfig.cookies.key || expressConfig.cookies.secret || '';
|
|
99
|
+
|
|
91
100
|
if (!cookiesSecretKey) {
|
|
92
101
|
console.log(' \x1b[33mWARNING\x1b[0m: Set the secret key in the config/express/cookie.js file or COOKIES_SECRET_KEY in the .env file.');
|
|
93
102
|
}
|
|
103
|
+
|
|
94
104
|
vulkano.use(cookieParser(cookiesSecretKey));
|
|
105
|
+
|
|
95
106
|
}
|
|
96
107
|
|
|
97
108
|
// ---------------
|
|
@@ -232,6 +243,89 @@ module.exports = function loadServer() {
|
|
|
232
243
|
});
|
|
233
244
|
}
|
|
234
245
|
|
|
246
|
+
// ---------------
|
|
247
|
+
// Express Session - File: app/config/express/session.js
|
|
248
|
+
// ---------------
|
|
249
|
+
const {
|
|
250
|
+
enabled: sessionEnabled
|
|
251
|
+
} = expressConfig.session || {};
|
|
252
|
+
|
|
253
|
+
if (sessionEnabled) {
|
|
254
|
+
|
|
255
|
+
if (!cookiesEnabled) {
|
|
256
|
+
console.log(' \x1b[41mERROR\x1b[0m: Can not load the Express Session because the Cookies aren\'t enabled');
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
delete expressConfig.session.enabled;
|
|
261
|
+
|
|
262
|
+
vulkano.use(expressSession({ ...expressConfig.session, secret: cookiesSecretKey }));
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ---------------
|
|
267
|
+
// Content Security Policy - File: app/config/express/csp.js
|
|
268
|
+
// ---------------
|
|
269
|
+
const {
|
|
270
|
+
enabled: cspEnabled,
|
|
271
|
+
report: cspReportTo,
|
|
272
|
+
rules: cspRules
|
|
273
|
+
} = expressConfig.csp || {};
|
|
274
|
+
|
|
275
|
+
if (cspEnabled) {
|
|
276
|
+
|
|
277
|
+
if (!Array.isArray(cspRules)) {
|
|
278
|
+
console.error('Vulkano Error: ', 'The Content Security Policy Rules must be an array');
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (cspRules.length > 0) {
|
|
283
|
+
|
|
284
|
+
vulkano.use( (req, res, next) => {
|
|
285
|
+
|
|
286
|
+
if (cspReportTo) {
|
|
287
|
+
res.setHeader('Report-To', JSON.stringify(cspReportTo));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
res.setHeader('Content-Security-Policy', cspRules.join('; '));
|
|
291
|
+
|
|
292
|
+
next();
|
|
293
|
+
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// ---------------
|
|
301
|
+
// Permission Policy - File: app/config/express/permissionPolicy.js
|
|
302
|
+
// ---------------
|
|
303
|
+
const {
|
|
304
|
+
enabled: ppEnabled,
|
|
305
|
+
permissions: ppPermissions
|
|
306
|
+
} = expressConfig.permissionPolicy || {};
|
|
307
|
+
|
|
308
|
+
if (ppEnabled) {
|
|
309
|
+
|
|
310
|
+
if (!Array.isArray(ppPermissions)) {
|
|
311
|
+
console.error('Vulkano Error: ', 'The Permission Policy values must be an array');
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (ppPermissions.length > 0) {
|
|
316
|
+
|
|
317
|
+
vulkano.use( (req, res, next) => {
|
|
318
|
+
|
|
319
|
+
res.setHeader('Permissions-Policy', ppPermissions.join(', '));
|
|
320
|
+
|
|
321
|
+
next();
|
|
322
|
+
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
235
329
|
// ---------------
|
|
236
330
|
// VIEWS
|
|
237
331
|
// ---------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulkano/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "A MVC framework using Express 4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Vulkano Team",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@socket.io/mongo-adapter": "^0.3.2",
|
|
32
32
|
"@socket.io/redis-adapter": "^8.3.0",
|
|
33
|
-
"axios": "^1.
|
|
33
|
+
"axios": "^1.7.2",
|
|
34
34
|
"bluebird": "^3.7.2",
|
|
35
35
|
"body-parser": "^1.20.2",
|
|
36
36
|
"compression": "^1.7.4",
|
|
@@ -41,12 +41,13 @@
|
|
|
41
41
|
"dotenv": "^16.4.5",
|
|
42
42
|
"express": "^4.19.2",
|
|
43
43
|
"express-jwt": "^8.4.1",
|
|
44
|
+
"express-session": "^1.18.0",
|
|
44
45
|
"express-useragent": "^1.0.15",
|
|
45
46
|
"frameguard": "^4.0.0",
|
|
46
47
|
"fs": "^0.0.1-security",
|
|
47
48
|
"fs-extra": "^11.2.0",
|
|
48
49
|
"helmet": "^7.1.0",
|
|
49
|
-
"i18next": "^23.11.
|
|
50
|
+
"i18next": "^23.11.5",
|
|
50
51
|
"include-all": "^4.0.3",
|
|
51
52
|
"jwt-simple": "^0.5.6",
|
|
52
53
|
"moment": "^2.30.1",
|
|
@@ -55,11 +56,11 @@
|
|
|
55
56
|
"mongoose-paginate": "^5.0.3",
|
|
56
57
|
"morgan": "^1.10.0",
|
|
57
58
|
"multer": "^1.4.5-lts.1",
|
|
58
|
-
"nodemon": "^3.1.
|
|
59
|
+
"nodemon": "^3.1.3",
|
|
59
60
|
"nunjucks": "^3.2.4",
|
|
60
61
|
"path": "^0.12.7",
|
|
61
62
|
"promise.prototype.finally": "^3.1.8",
|
|
62
|
-
"redis": "^4.6.
|
|
63
|
+
"redis": "^4.6.14",
|
|
63
64
|
"socket.io": "^4.7.5",
|
|
64
65
|
"socket.io-adapter": "^2.5.4",
|
|
65
66
|
"socket.io-client": "4.7.5",
|
|
@@ -67,18 +68,18 @@
|
|
|
67
68
|
"yargs": "^17.7.2"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@babel/core": "^7.24.
|
|
71
|
-
"@babel/eslint-parser": "^7.24.
|
|
71
|
+
"@babel/core": "^7.24.7",
|
|
72
|
+
"@babel/eslint-parser": "^7.24.7",
|
|
72
73
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
73
|
-
"@babel/plugin-syntax-jsx": "^7.24.
|
|
74
|
-
"@babel/preset-env": "^7.24.
|
|
75
|
-
"@babel/preset-react": "^7.24.
|
|
74
|
+
"@babel/plugin-syntax-jsx": "^7.24.7",
|
|
75
|
+
"@babel/preset-env": "^7.24.7",
|
|
76
|
+
"@babel/preset-react": "^7.24.7",
|
|
76
77
|
"@babel/preset-stage-1": "^7.8.3",
|
|
77
78
|
"eslint": "^8.57.0",
|
|
78
79
|
"eslint-config-airbnb": "^19.0.4",
|
|
79
80
|
"eslint-plugin-import": "^2.29.1",
|
|
80
81
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
81
|
-
"eslint-plugin-react": "^7.34.
|
|
82
|
+
"eslint-plugin-react": "^7.34.2",
|
|
82
83
|
"eslint-plugin-react-hooks": "^4.6.2"
|
|
83
84
|
}
|
|
84
85
|
}
|