Skip to content

fix(web): clearer create errors, focus management, stripped password links, safe file downloads - #181

Merged
dillonstreator merged 2 commits into
mainfrom
fix/web-errors-focus-file-download
Nov 28, 2026
Merged

dillonstreator merged 2 commits into
mainfrom
fix/web-errors-focus-file-download

Conversation

@dillonstreator

Copy link
Copy Markdown
Member

What was wrong

  • Oversized secrets failed with a raw "unexpected status code 413" (CFYI-UX-001). The form accepts files up to 1 MB. After encoding and encryption, the request body grows to about 1.8x the file size, and the default server limit is 100 KB, so most attachments are rejected. A 429 looked just as cryptic.
  • Focus was lost after creating a secret (CFYI-A11Y-001). The form and its focused submit button unmount and the success view mounts, which leaves keyboard and screen-reader users on <body>. The same happened on the recipient's status screens.
  • Password-protected links without ?p=true (CFYI-UX-002). When a chat app stripped the query, the reader got the no-password flow, used up a failed attempt, and saw "invalid link". The key's 2. prefix already marks a password-protected secret.
  • Shared-file download used an unchecked, sender-supplied URL (CFYI-CRYPTO-005). The "Download file" button set href straight from the decrypted payload, so it could send the recipient to another site.

What changed

  • lib/createError.ts: 413 and 429 errors from create map to new translated messages (create.errors.tooLarge, create.errors.rateLimited). Other errors keep their message, as before.
  • The success <h2> and the StatusCard <h1> (tabIndex={-1}) are focused when they mount. The card that holds the credentials form opts out, because its inputs already autoFocus.
  • isPasswordProtectedLink: ?p or a 2.-prefixed fragment key means the secret is password-protected.
  • safeFileDownloadUrl: only data: URLs are downloaded. Anything else shows a translated error.
  • New strings are in all five locales (en, es, de, fr, zh) and typed in TranslationKeys.
  • Changeset: @crypt.fyi/core and @crypt.fyi/web patch.

How it was tested

  • pnpm build, pnpm typecheck, pnpm lint (0 errors; the existing core warning), pnpm format:check: pass.
  • Unit tests: web 13 pass (7 new), core 65, cli 15, extension 14, desktop 58, theme 12: pass. Server: 27 pass, run against a temporary Redis container.
  • pnpm test:e2e: 7 pass, including a new e2e/focus.spec.ts. That spec checks that the success heading is focused after create and the gate heading after opening a link. It also checks that a password link with ?p=true removed still asks for the password and unlocks. Both new e2e tests fail with main's components.

For the reviewer

  • The real limit mismatch remains. The form still says "max 1 MB", while the default BODY_LIMIT_BYTES is 100 KB. You could lower MAX_FILE_SIZE, raise the server default, or expose the limit to the client (an API addition). Users now get a clear message, but the right limit is your call.
  • Focusing the status-card heading also happens on first load of a secret link, which moves focus past the skip link.
  • No focus is set after "View secret" reveals the content; the content view has no heading to target.

Left out

  • Mapping a create 400 to the server's msg, which needs a core client change to read the body. A11Y-002 (hard-coded English strings, aria-label on <pre>), CRYPTO-007 (clearing the key from history, a UX trade-off on refresh), PRIV-002 (self-hosting the badge), HDR-001 (CSP additions, which need a CSP and e2e review) and DEBT-001: not done here.

A secret over the server's body limit failed with a bare 'unexpected
status code 413' toast, and 429 looked the same. Show translated
messages instead. Move focus to the success heading after creating a
secret and to the heading of each recipient status card, so keyboard
and screen reader users are not left on the page body.
…iles

A password-protected link whose query was stripped showed the
no-password flow and used up a failed attempt; the 2. key prefix already
marks it. The file download used the sender-supplied content as the
link target without checking it, so it could point anywhere; only data
URLs are downloaded now.
@dillonstreator
dillonstreator merged commit 34c254e into main Nov 28, 2026
15 checks passed
@dillonstreator
dillonstreator deleted the fix/web-errors-focus-file-download branch November 28, 2026 19:32
@github-actions github-actions Bot mentioned this pull request Nov 28, 2026
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.

1 participant