Editor image uploads via Blossom (4 public servers) - #9
Merged
Conversation
Adds public/js/blossom.js — click the image button, drag, or paste an image and it uploads to public Blossom servers (blossom.band primary + BUD-04 mirror to blossom.nostr.build / nostr.download / cdn.nostrcheck.me) and inserts the markdown. Auth is a NbreadSigner-signed kind-24242 event; the returned URL is validated as a clean https:// destination before it's spliced into the post (rejects markdown-breakout chars). Uploads reuse the in-page signers (extension / NIP-46 / pasted key); the Amber NIP-55 redirect signer falls back to the URL template. All inserts go through the existing execCommand undo seam.
Opens connect-src to the four Blossom origins so browser uploads reach them; script-src and every other directive are unchanged, and BLOG_CSP (blog subdomains, JS-free) is untouched. img-src * already covered displaying the results.
This was referenced Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds image upload to the editor. Click the image button, drag, or paste an image and it uploads to public Blossom servers and inserts the markdown — no more hand-pasting URLs.
How
public/js/blossom.js— uploads a NbreadSigner-signed kind-24242 Blossom auth event + the raw blob viaPUT /uploadto blossom.band (primary, indefinite retention), then BUD-04 mirrors to blossom.nostr.build / nostr.download / cdn.nostrcheck.me for redundancy. All four were live-probed (real anonymous signed upload + CORS preflight) before selection.execCommandseam, so native undo survives; an![uploading…]()placeholder is swapped for the finalon success.connect-srcopens to exactly those fourhttps://origins.script-srcand every other directive are unchanged; BLOG_CSP is untouched (blog subdomains stay JS-free);img-src *already displayed the results.Security
Adversarially reviewed (CSP-regression, upload/secret handling, editor UX). Fixes applied:
https://evil/x.png) [phish](…)to escape; the returned URL is rejected if it contains whitespace,(),<>, quotes, or backtick, on top of thehttps://-only check.textContent.Known low-severity, accepted: the returned image host isn't pinned to the upload server (harmless — an https image under
img-src *), and the optional sha256 integrity check is skipped if a server omits it.Durability caveat (Approach A)
Images live on public servers, hedged by 4-way mirroring, not first-party-durable — the tradeoff of attaching public servers vs. running our own R2 Blossom. Content-addressing means any mirror can re-serve a blob by its sha256 if one dies.
Testing
856/856 tests (45 files);
wrangler deploy --dry-rungreen; vendor drift clean. Newtest/unit/blossom.spec.tscovers the pure helpers (auth-event shape, base64url encoding, file validation, URL validation).docs/manual-signer-tests.md§9 covers the real-device upload path.