Skip to content

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

Merged
Hona merged 2 commits into
anomalyco:v2from
Hona:blob-id-fallback
Aug 15, 2026
Merged

fix(app): generate blob ids without crypto.subtle in non-secure contexts#42706
Hona merged 2 commits into
anomalyco:v2from
Hona:blob-id-fallback

Conversation

@Hona

@Hona Hona commented Aug 15, 2026

Copy link
Copy Markdown
Member

Fixes #41706

Problem

blobID() calls crypto.subtle.digest unconditionally. Browsers do not expose crypto.subtle over plain HTTP on a non-localhost origin, so pasting an image from http://<server-ip>:4096 throws.

Fix

Keep SHA-256 content addressing when crypto.subtle is available. Otherwise, generate a 128-bit ID with crypto.getRandomValues(), which is available in insecure contexts.

The fallback does not read or synchronously hash the blob. Deduplication is disabled only on the insecure HTTP path.

This supersedes #41710, which uses Math.random() and Date.now() for the fallback ID.

@Hona
Hona requested a review from Brendonovich as a code owner August 15, 2026 03:42
Copilot AI lite review requested due to automatic review settings August 15, 2026 03:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes image paste failures in the web UI when accessed over plain HTTP on non-localhost origins by avoiding unconditional use of crypto.subtle and introducing a deterministic hashing fallback for blob IDs.

Changes:

  • Compute blob IDs using SHA-256 via crypto.subtle.digest when available.
  • Fall back to a deterministic pure-JS FNV-1a-based hash when crypto.subtle is unavailable (non-secure contexts).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/app/src/utils/draft-store.ts Outdated
Comment on lines 25 to 28
const bytes = new Uint8Array(await blob.arrayBuffer())
if (!crypto.subtle) return insecureContextID(bytes)
const id = Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)))
.map((byte) => byte.toString(16).padStart(2, "0"))
@Hona Hona changed the title fix(app): hash blob ids without crypto.subtle in non-secure contexts fix(app): generate blob ids without crypto.subtle in non-secure contexts Aug 15, 2026
@Hona
Hona merged commit 41f70bf into anomalyco:v2 Aug 15, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants