Files
archived-phantomlink/scripts/inject-csp.mjs
T
pevnitskyparitshith184 f456aca92c v1.5.2: true E2E session encryption, auto-backup, stability fixes
- X25519 session key exchange (Ed25519-signed, TOFU for new devices);
  messages, voice, file chunks now AES-256-GCM encrypted on the wire
- Fix get_messages deadlock with file/image/voice messages
- Fix upsert_device wiping ip/port/avatar; upsert_conversation preserves unread/pinned/muted
- Fix route scan replies (Hello alias registration) and cap scan at 4096 hosts
- File transfer: size caps, SHA-256 verification on receive
- Auto-backup with master-key-derived backup key + rotation; backups now include attachments; import falls back to internal backup key
- Lock on system sleep / window blur; clipboard clear honors configured delay
- CSP: allow media-src for voice playback; async long-running commands; configurable listen port
2026-11-05 13:34:23 +08:00

29 lines
841 B
JavaScript
Executable File

import { readFileSync, writeFileSync } from "node:fs";
const CSP = [
"default-src 'self'",
"script-src 'self'",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob:",
// data:/blob: needed for in-app playback of voice messages
"media-src 'self' data: blob:",
"connect-src ipc: http://ipc.localhost",
"font-src 'self' data:",
"object-src 'none'",
"base-uri 'none'",
"form-action 'none'",
].join("; ");
const file = "dist/index.html";
const html = readFileSync(file, "utf8");
if (!html.includes("Content-Security-Policy")) {
const injected = html.replace(
"<head>",
`<head>\n <meta http-equiv="Content-Security-Policy" content="${CSP}" />`,
);
writeFileSync(file, injected);
console.log("[inject-csp] CSP injected");
} else {
console.log("[inject-csp] CSP already present, skipping");
}