fix: harden identity, live access, drafts and setup (review only)

Source-reviewed hardening changes and regression tests. UNBUILT / UNTESTED: not a deployable release. Go formatting, compilation, automated regression tests, full frontend validation and staging acceptance remain required. See docs/hardening/VALIDATION.md. Main remains the original clean snapshot; no upstream Git history imported.
This commit is contained in:
2026-10-16 12:15:20 +00:00
parent e57610a27c
commit 63e0457886
86 changed files with 5174 additions and 1929 deletions

View File

@@ -0,0 +1,13 @@
/**
* Retry identity for a selected attachment. A file picker returns a fresh File
* object on reselection; metadata alone can also collide across different bytes.
*/
export async function getMessageFileIdentity(file: Pick<File, "name" | "type" | "arrayBuffer">) {
const bytes = await file.arrayBuffer()
const subtle = globalThis.crypto?.subtle
// Self-hosted HTTP deployments may lack WebCrypto. Exact bytes provide a
// collision-free in-memory fallback, rather than silently weakening the key.
const digest = subtle ? await subtle.digest("SHA-256", bytes) : bytes
const key = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("")
return JSON.stringify([file.name, file.type, subtle ? "sha256" : "bytes", key])
}