refactor(auth): standardize session management and security

- Centralize secret retrieval using `getAdminSessionSecret`
- Replace manual session parsing with `verifyRequestAdminSession` utility
- Tighten API validation and improve security headers handling
- Enforce environment variable security for production deployments
This commit is contained in:
Team Dark Devil committed 2026-11-18 05:18:55 +06:00
1 parent 34519c07df
commit 177ed4a844
78 files changed
+6748 -3157

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
<rect width="512" height="512" fill="#0a0a0b" />
<rect x="24" y="24" width="464" height="464" fill="#111113" stroke="#2e2e33" stroke-width="8" />
<rect x="112" y="112" width="288" height="288" fill="#a3e635" />
<rect x="192" y="192" width="128" height="128" fill="#0a0a0b" />
<rect x="232" y="232" width="48" height="48" fill="#e8e8ea" />
</svg>

After

Width:  |  Height:  |  Size: 444 B

+16 -6
View File
@@ -1,21 +1,31 @@
{
"name": "DataStack - Realtime Data Platform",
"id": "/",
"name": "DataStack - Realtime Data Collection Platform",
"short_name": "DataStack",
"description": "Self-hosted universal realtime data collection engine",
"description": "Self-hosted universal realtime data collection engine with Socket.IO ingestion, Redis buffer, JWT client auth, CSV batch rotation, and /vcon/ admin panel.",
"start_url": "/vcon/dashboard",
"scope": "/",
"display": "standalone",
"background_color": "#0b0f17",
"theme_color": "#2563eb",
"background_color": "#0a0a0b",
"theme_color": "#0a0a0b",
"icons": [
{
"src": "/icon-192.png",
"sizes": "192x192",
"type": "image/png"
"type": "image/png",
"purpose": "any"
},
{
"src": "/icon-512.png",
"sizes": "512x512",
"type": "image/png"
"type": "image/png",
"purpose": "any"
},
{
"src": "/icon-maskable-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
]
}
+45 -7
View File
@@ -1,5 +1,13 @@
const CACHE_NAME = 'datastack-cache-v1';
const STATIC_ASSETS = ['/', '/vcon/dashboard', '/manifest.json'];
const CACHE_NAME = 'datastack-cache-v2';
const STATIC_ASSETS = [
'/',
'/manifest.json',
'/icon.svg',
'/icon-192.png',
'/icon-512.png',
'/icon-maskable-512.png',
'/apple-touch-icon.png',
];
self.addEventListener('install', (event) => {
event.waitUntil(
@@ -22,13 +30,43 @@ self.addEventListener('activate', (event) => {
});
self.addEventListener('fetch', (event) => {
// Let WebSocket and API requests pass through
if (event.request.url.includes('/socket.io/') || event.request.url.includes('/api/')) {
const { request } = event;
if (request.method !== 'GET') return;
let url;
try {
url = new URL(request.url);
} catch {
return;
}
// Only handle same-origin GET requests; never intercept WebSocket, HMR, or API routes
if (url.origin !== self.location.origin) return;
if (
url.pathname.startsWith('/socket.io/') ||
url.pathname.startsWith('/api/') ||
url.pathname.startsWith('/_next/webpack-hmr')
) {
return;
}
event.respondWith(
fetch(event.request).catch(() => {
return caches.match(event.request);
})
fetch(request)
.then((response) => {
if (response && response.ok && response.type === 'basic') {
const clone = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, clone)).catch(() => {});
}
return response;
})
.catch(async () => {
const cached = await caches.match(request);
if (cached) return cached;
return new Response('Offline — network unavailable.', {
status: 503,
statusText: 'Service Unavailable',
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
})
);
});