Changesets · Branches · Tags · Compare
| Changeset | 65e539131667f51bb7933d2deed65e8d0b971b02a871639f652ad455785dd20e |
|---|---|
| Author | Gemini CLI <gemini@example.com> · 2026-05-25 13:49 -04:00 |
| Committer | Gemini CLI <gemini@example.com> · 2026-05-25 13:49 -04:00 |
| Parents | 00530dc98475 |
6 files changed
modified next.config.ts +14 −1
| @@ -12,7 +12,20 @@ | ||
| 12 | 12 | { protocol: 'https', hostname: '**' }, |
| 13 | 13 | ], |
| 14 | 14 | }, |
| 15 | - | |
| 15 | + async headers() { | |
| 16 | + return [ | |
| 17 | + { | |
| 18 | + source: '/(.*)', | |
| 19 | + headers: [ | |
| 20 | + { key: 'Content-Security-Policy', value: "default-src 'self' 'unsafe-inline' 'unsafe-eval' https: wss: data: blob:;" }, | |
| 21 | + { key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains' }, | |
| 22 | + { key: 'X-Content-Type-Options', value: 'nosniff' }, | |
| 23 | + { key: 'X-Frame-Options', value: 'SAMEORIGIN' }, | |
| 24 | + { key: 'X-XSS-Protection', value: '1; mode=block' }, | |
| 25 | + ], | |
| 26 | + }, | |
| 27 | + ]; | |
| 28 | + }, | |
| 16 | 29 | }; |
| 17 | 30 | |
| 18 | 31 | export default nextConfig; |
modified src/app/api/cctv/greece.ts +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import type { CctvCamera } from './types'; |
| 2 | 2 | |
| 3 | -const IPCAMLIVE_API_SECRET = '65586c9ba88ef'; | |
| 3 | +const IPCAMLIVE_API_SECRET = process.env.IPCAMLIVE_API_SECRET || ''; | |
| 4 | 4 | |
| 5 | 5 | const ATTiki_ODOS_CAMERAS = [ |
| 6 | 6 | { alias: 'cam128', name: 'I/C D. Plakentias', city: 'Athens', lat: 38.0208, lng: 23.8578 }, |
modified src/app/api/github-webhook/route.ts +25 −3
| @@ -1,9 +1,30 @@ | ||
| 1 | 1 | import { NextResponse } from 'next/server'; |
| 2 | +import crypto from 'crypto'; | |
| 2 | 3 | |
| 3 | 4 | export async function POST(request: Request) { |
| 4 | 5 | try { |
| 5 | - // Parse the incoming GitHub Webhook payload | |
| 6 | - const payload = await request.json(); | |
| 6 | + const payloadText = await request.text(); | |
| 7 | + const signature = request.headers.get('x-hub-signature-256'); | |
| 8 | + const secret = process.env.GITHUB_WEBHOOK_SECRET; | |
| 9 | + | |
| 10 | + if (secret) { | |
| 11 | + if (!signature) { | |
| 12 | + return NextResponse.json({ error: 'Unauthorized: Missing signature' }, { status: 401 }); | |
| 13 | + } | |
| 14 | + const hmac = crypto.createHmac('sha256', secret); | |
| 15 | + const digest = 'sha256=' + hmac.update(payloadText).digest('hex'); | |
| 16 | + | |
| 17 | + // Use timingSafeEqual to prevent timing attacks | |
| 18 | + try { | |
| 19 | + if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(digest))) { | |
| 20 | + return NextResponse.json({ error: 'Unauthorized: Invalid signature' }, { status: 401 }); | |
| 21 | + } | |
| 22 | + } catch { | |
| 23 | + return NextResponse.json({ error: 'Unauthorized: Invalid signature format' }, { status: 401 }); | |
| 24 | + } | |
| 25 | + } | |
| 26 | + | |
| 27 | + const payload = JSON.parse(payloadText); | |
| 7 | 28 | |
| 8 | 29 | // Forward the payload to the local OSIRIS Discord Bot running on Port 3005 |
| 9 | 30 | // Using the Tailscale internal IP of the host server |
| @@ -11,8 +32,9 @@ | ||
| 11 | 32 | method: 'POST', |
| 12 | 33 | headers: { |
| 13 | 34 | 'Content-Type': 'application/json', |
| 35 | + ...(signature ? { 'x-hub-signature-256': signature } : {}) | |
| 14 | 36 | }, |
| 15 | - body: JSON.stringify(payload), | |
| 37 | + body: payloadText, | |
| 16 | 38 | }); |
| 17 | 39 | |
| 18 | 40 | if (!response.ok) { |
modified src/app/api/satellites/route.ts +30 −17
| @@ -183,30 +183,43 @@ | ||
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | +let globalCachedSats: any[] = []; | |
| 187 | +let globalCacheTime = 0; | |
| 188 | + | |
| 186 | 189 | export async function GET() { |
| 187 | 190 | try { |
| 188 | - // Fetch all groups in parallel for maximum speed & resilience | |
| 189 | - const results = await Promise.allSettled( | |
| 190 | - TLE_SOURCES.map(src => fetchTLEFromSource(src)) | |
| 191 | - ); | |
| 192 | - | |
| 193 | - const allSats: any[] = []; | |
| 194 | - const seen = new Set<string>(); | |
| 195 | - | |
| 196 | - for (const result of results) { | |
| 197 | - if (result.status === 'fulfilled' && result.value) { | |
| 198 | - const parsed = parseTLE(result.value); | |
| 199 | - for (const sat of parsed) { | |
| 200 | - if (!seen.has(sat.name)) { | |
| 201 | - seen.add(sat.name); | |
| 202 | - allSats.push(sat); | |
| 191 | + const nowTime = Date.now(); | |
| 192 | + let allSats: any[] = globalCachedSats; | |
| 193 | + let source = 'memory-cache'; | |
| 194 | + | |
| 195 | + if (globalCachedSats.length === 0 || nowTime - globalCacheTime > 3600000) { // 1 hour cache | |
| 196 | + const results = await Promise.allSettled( | |
| 197 | + TLE_SOURCES.map(src => fetchTLEFromSource(src)) | |
| 198 | + ); | |
| 199 | + | |
| 200 | + const fetchedSats: any[] = []; | |
| 201 | + const seen = new Set<string>(); | |
| 202 | + | |
| 203 | + for (const result of results) { | |
| 204 | + if (result.status === 'fulfilled' && result.value) { | |
| 205 | + const parsed = parseTLE(result.value); | |
| 206 | + for (const sat of parsed) { | |
| 207 | + if (!seen.has(sat.name)) { | |
| 208 | + seen.add(sat.name); | |
| 209 | + fetchedSats.push(sat); | |
| 210 | + } | |
| 203 | 211 | } |
| 204 | 212 | } |
| 205 | 213 | } |
| 214 | + | |
| 215 | + if (fetchedSats.length > 0) { | |
| 216 | + globalCachedSats = fetchedSats; | |
| 217 | + globalCacheTime = nowTime; | |
| 218 | + allSats = fetchedSats; | |
| 219 | + source = 'celestrak-groups'; | |
| 220 | + } | |
| 206 | 221 | } |
| 207 | 222 | |
| 208 | - const source = allSats.length > 0 ? 'celestrak-groups' : 'none'; | |
| 209 | - | |
| 210 | 223 | // Sample for performance (max 2000 satellites) |
| 211 | 224 | const sampled = allSats.length > 2000 |
| 212 | 225 | ? allSats.filter((_, i) => i % Math.ceil(allSats.length / 2000) === 0) |
modified src/app/layout.tsx +0 −3
| @@ -173,8 +173,6 @@ | ||
| 173 | 173 | }, |
| 174 | 174 | }; |
| 175 | 175 | |
| 176 | -import { Analytics } from "@vercel/analytics/next"; | |
| 177 | - | |
| 178 | 176 | import ErrorBoundary from '@/components/ErrorBoundary'; |
| 179 | 177 | |
| 180 | 178 | export default function RootLayout({ |
| @@ -204,7 +202,6 @@ | ||
| 204 | 202 | <ErrorBoundary name="OSIRIS Core"> |
| 205 | 203 | {children} |
| 206 | 204 | </ErrorBoundary> |
| 207 | - <Analytics /> | |
| 208 | 205 | </body> |
| 209 | 206 | </html> |
| 210 | 207 | ); |
modified src/middleware.ts +1 −1
| @@ -14,7 +14,7 @@ | ||
| 14 | 14 | screen: "1920x1080", |
| 15 | 15 | title: "OSIRIS", |
| 16 | 16 | url: url, |
| 17 | - website: "cd8f216c-fc3f-45f5-ba1a-e10309a61d18" | |
| 17 | + website: process.env.UMAMI_WEBSITE_ID || "cd8f216c-fc3f-45f5-ba1a-e10309a61d18" | |
| 18 | 18 | }; |
| 19 | 19 | |
| 20 | 20 | const pageView = fetch('http://umami-umami-1:3000/api/send', { |