feat: harden support, localize knowledge and add operator availability [skip ci]
Source-only publication of reviewed commit 64e96a7f423673dc29ad56485be9fc79bce8af1c.
Passed in isolation: focused frontend/backend tests, race checks, TypeScript typecheck, lint, Go compilation, Flowgram build, and deterministic SDK build/tests.
Not accepted as a production release: Next.js export/native assembly remains blocked by environment memory limits; browser interaction and MySQL staging acceptance remain unverified. No production server, database/schema, runtime configuration, deployment, release tag, or workflow execution was performed.
Expected source tree: 0a4a7528e9.
This commit is contained in:
13
web/lib/message-file-identity.ts
Normal file
13
web/lib/message-file-identity.ts
Normal 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])
|
||||
}
|
||||
Reference in New Issue
Block a user