Skip to content

Commit bf1e236

Browse files
committed
r0b08x [chore] 6/6/2024, 3:43:01 PM
1 parent 54fbf3c commit bf1e236

File tree

5 files changed

+55
-8
lines changed

5 files changed

+55
-8
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ https://corifeus.com/redis-ui
1212

1313

1414
---
15-
# 🏍️ The p3x-redis-ui-server package motor that is connected to the p3x-redis-ui-material web user interface v2024.4.253
15+
# 🏍️ The p3x-redis-ui-server package motor that is connected to the p3x-redis-ui-material web user interface v2024.4.254
1616

1717

1818

@@ -122,7 +122,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com) and [corifeus.com
122122
---
123123

124124

125-
[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.253
125+
[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.254
126126

127127
[![NPM](https://img.shields.io/npm/v/p3x-redis-ui-server.svg)](https://www.npmjs.com/package/p3x-redis-ui-server) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)
128128

artifacts/cluster.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com) and [corifeus.com
3535
---
3636

3737

38-
[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.253
38+
[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.254
3939

4040
[![NPM](https://img.shields.io/npm/v/p3x-redis-ui-server.svg)](https://www.npmjs.com/package/p3x-redis-ui-server) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)
4141

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p3x-redis-ui-server",
3-
"version": "2024.4.253",
3+
"version": "2024.4.254",
44
"description": "🏍️ The p3x-redis-ui-server package motor that is connected to the p3x-redis-ui-material web user interface",
55
"corifeus": {
66
"icon": "fas fa-flag-checkered",
@@ -48,11 +48,12 @@
4848
"license": "MIT",
4949
"devDependencies": {
5050
"corifeus-builder": "^2024.4.140",
51-
"nodemon": "^3.1.0"
51+
"nodemon": "^3.1.3"
5252
},
5353
"dependencies-saved": {
5454
"koa-body": "^4.0.4",
55-
"koa-router": "^7.4.0"
55+
"koa-router": "^7.4.0",
56+
"@koa/cors": "^5.0.0"
5657
},
5758
"dependencies": {
5859
"chalk": "^4.1.2",

src/service/koa/index.js

+47-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,53 @@ const koaService = function () {
2020

2121
const path = require('path');
2222
const fs = require('fs');
23+
/*
24+
const cors = require('@koa/cors'); // Added CORS
25+
const crypto = require('crypto');
26+
27+
// Middleware to add a nonce to each request
28+
app.use(async (ctx, next) => {
29+
ctx.state.nonce = crypto.randomBytes(16).toString('base64');
30+
await next();
31+
});
32+
33+
// Middleware to add CSP header
34+
app.use(async (ctx, next) => {
35+
const nonce = ctx.state.nonce;
36+
const csp = `
37+
default-src 'self';
38+
script-src 'self' https://pagead2.googlesyndication.com https://www.googletagmanager.com 'nonce-${nonce}';
39+
style-src 'self' 'unsafe-inline';
40+
img-src * data:;
41+
connect-src *;
42+
font-src *;
43+
object-src 'none';
44+
frame-src 'self' https://*.doubleclick.net https://*.google.com;
45+
`.replace(/\s{2,}/g, ' ').trim(); // Remove extra spaces and trim
2346
47+
ctx.set('Content-Security-Policy', csp);
48+
await next();
49+
});
50+
51+
52+
// Added CORS middleware
53+
app.use(cors({
54+
origin: '*', // Allow all origins
55+
allowMethods: ['GET', 'POST', 'OPTIONS', 'PUT', 'DELETE'],
56+
allowHeaders: ['DNT', 'User-Agent', 'X-Requested-With', 'If-Modified-Since', 'Cache-Control', 'Content-Type', 'Range'],
57+
exposeHeaders: ['Content-Length', 'Content-Range'],
58+
}));
59+
60+
61+
app.use(async (ctx, next) => {
62+
if (ctx.path === '/nonce') {
63+
ctx.body = { nonce: ctx.state.nonce };
64+
} else {
65+
await next();
66+
}
67+
});
68+
*/
69+
2470
const findModulePath = (startPath, targetPath) => {
2571
let currentPath = startPath;
2672
while (currentPath !== path.resolve(currentPath, '..')) { // Check until we reach the root directory
@@ -32,7 +78,7 @@ const koaService = function () {
3278
}
3379
throw new Error('The specified module could not be found in any node_modules directory');
3480
}
35-
81+
3682
const resolvePath = (inputPath) => {
3783
if (inputPath.startsWith('~')) {
3884
const inputPathFromNodeModules = inputPath.substring(1);

src/service/socket.io/socket.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module.exports = (io) => {
9191
readonlyConnections: p3xrs.cfg.readonlyConnections === true,
9292
snapshot: pkg.name !== 'p3x-redis-ui',
9393
treeDividers: dividers,
94-
version: pkg.version
94+
version: pkg.version,
9595
})
9696

9797
socketIoShared.sendStatus({

0 commit comments

Comments
 (0)