2026-03-05 00:04:26 -06:00
|
|
|
import { SECURITY_HEADERS } from "./http-security";
|
|
|
|
|
|
|
|
|
|
export function secureHeaders(contentType?: string) {
|
|
|
|
|
return {
|
|
|
|
|
...SECURITY_HEADERS,
|
|
|
|
|
...(contentType ? { "Content-Type": contentType } : {}),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function securePluginHeaders() {
|
|
|
|
|
return {
|
|
|
|
|
...SECURITY_HEADERS,
|
|
|
|
|
"X-Frame-Options": "SAMEORIGIN",
|
2026-04-15 20:16:12 -05:00
|
|
|
"Content-Security-Policy": "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' wss: ws:; object-src 'none'; base-uri 'self'; frame-ancestors 'self'",
|
2026-03-05 00:04:26 -06:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-06 18:24:33 -05:00
|
|
|
const MIME_TYPES: Record<string, string> = {
|
|
|
|
|
".html": "text/html; charset=utf-8",
|
|
|
|
|
".css": "text/css; charset=utf-8",
|
|
|
|
|
".js": "text/javascript; charset=utf-8",
|
|
|
|
|
".json": "application/json",
|
|
|
|
|
".png": "image/png",
|
|
|
|
|
".jpg": "image/jpeg",
|
|
|
|
|
".jpeg": "image/jpeg",
|
|
|
|
|
".webp": "image/webp",
|
|
|
|
|
".gif": "image/gif",
|
2026-05-10 02:19:12 -05:00
|
|
|
".svg": "image/svg+xml",
|
|
|
|
|
".ico": "image/x-icon",
|
|
|
|
|
".woff": "font/woff",
|
|
|
|
|
".woff2": "font/woff2",
|
|
|
|
|
".ttf": "font/ttf",
|
|
|
|
|
".eot": "application/vnd.ms-fontobject",
|
2026-05-06 18:24:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function mimeType(filePath: string) {
|
|
|
|
|
const dot = filePath.lastIndexOf(".");
|
|
|
|
|
if (dot !== -1) return MIME_TYPES[filePath.slice(dot).toLowerCase()] ?? "application/octet-stream";
|
2026-03-05 00:04:26 -06:00
|
|
|
return "application/octet-stream";
|
|
|
|
|
}
|