fix(app): generate blob ids without crypto.subtle in non-secure contexts (#42706)

Co-authored-by: OpenCode Vite Investigation <opencode-vite-investigation@local>
This commit is contained in:
Luke Parker
2026-08-15 14:12:57 +10:00
committed by GitHub
parent e8fa6985bc
commit 41f70bfbb1
+4 -1
View File
@@ -22,7 +22,10 @@ function blobUrl(id: string, blob: Blob) {
}
async function blobID(blob: Blob) {
const id = Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", await blob.arrayBuffer())))
const bytes = crypto.subtle
? new Uint8Array(await crypto.subtle.digest("SHA-256", await blob.arrayBuffer()))
: crypto.getRandomValues(new Uint8Array(16))
const id = Array.from(bytes)
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("")
return id