feat(privacy): privacy page, security headers, Chrome fallback for Samsung installs

The 'privacy' refusal on the S23 is Google Play Protect blocking the WebAPK that
Samsung Internet mints (old targetSdkVersion) — a browser-side bug that also hits
other PWAs; Chrome on the same device installs fine. So:

- ui/install-tip.js: detect Samsung Internet on Android and offer the same URL in
  Chrome (intent:// link, copy-link fallback, dismissable, remembered)
- ui/views/privacy.js + #/privacy route + footer link: Thai privacy policy (what is
  stored locally, no cookies/analytics/third-party scripts, how to delete)
- server/publish.mjs: CSP (script-src 'self', style-src 'self' 'unsafe-inline'),
  Referrer-Policy, Permissions-Policy, X-Content-Type-Options on every response
- ui/boot-motion.js: the head inline script moved out so CSP can forbid inline JS
- ui/data.js: admin publish token now lives in sessionStorage (was localStorage)
- theme.css: .notice / .legal components (44px targets), DESIGN.md + README + AGENTS

Verified: installabilityErrors [], fonts load under CSP, all requests same-origin,
notice renders under the header at 360px with 44px buttons and stays dismissed,
privacy page renders 5 sections. VERSION 2026.11.24.6.
This commit is contained in:
Bkk1234 committed 2026-11-24 15:10:32 +07:00
1 parent ddec75b99e
commit 2edbc39805
12 files changed
+346 -20

No files matched your search

+28 -1
View File
@@ -69,11 +69,38 @@ const NO_CACHE = {
"access-control-allow-origin": "*",
};
/**
* Header ด้านความเป็นส่วนตัว/ความปลอดภัย — ติดทุกคำตอบ
* CSP ไม่เปิด 'unsafe-inline' ให้ script (inline script ถูกย้ายไป ui/boot-motion.js แล้ว)
* แต่ยังเปิดให้ style เพราะทั้งแอปใช้ CSS custom property ใน style attribute (--fx-delay, --i)
*/
const SECURITY_HEADERS = {
"referrer-policy": "strict-origin-when-cross-origin",
"x-content-type-options": "nosniff",
"permissions-policy":
"camera=(), microphone=(), geolocation=(), payment=(), usb=(), accelerometer=(), gyroscope=(), magnetometer=()",
"content-security-policy": [
"default-src 'self'",
"script-src 'self'",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data:",
"font-src 'self'",
"connect-src 'self'",
"manifest-src 'self'",
"worker-src 'self'",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"frame-ancestors 'none'",
].join("; "),
};
function sendJson(res, status, body) {
const payload = JSON.stringify(body, null, 2);
res.writeHead(status, {
"content-type": "application/json; charset=utf-8",
"content-length": Buffer.byteLength(payload),
...SECURITY_HEADERS,
...NO_CACHE,
});
res.end(payload);
@@ -259,7 +286,7 @@ async function serveStatic(req, res, pathname) {
return;
}
const ext = path.extname(filePath).toLowerCase();
const headers = { "content-type": MIME[ext] || "application/octet-stream" };
const headers = { "content-type": MIME[ext] || "application/octet-stream", ...SECURITY_HEADERS };
if ([".html", ".css", ".js", ".mjs", ".json"].includes(ext) || ext === "") {
Object.assign(headers, NO_CACHE);
} else {