Skip to content

bugfix: support Trino over plain HTTP (secure-context UUID fallback) - #382

Open
F3l1x1vo wants to merge 1 commit into
mainfrom
bugfix/crypto-http
Open

F3l1x1vo wants to merge 1 commit into
mainfrom
bugfix/crypto-http

Conversation

@F3l1x1vo

Copy link
Copy Markdown
Collaborator

crypto.randomUUID() is only exposed in secure contexts. Over plain HTTP on a non-localhost host it is undefined, so every client-side call threw TypeError: crypto.randomUUID is not a function.

tabStore is built at module scope, so the throw happened during hydration of /trino: SSR succeeded (Node has a global crypto) and the browser received 200, but the page stayed blank and nothing rendered.

Add randomUUID() in $lib/utils/uuid.js, which keeps the native fast path and falls back to crypto.getRandomValues() (not secure-context gated), and use it at the four client-side call sites:

  • tab-store (fatal — module-scope init)
  • toast store
  • storage connection ids
  • upload entries

Server-side code keeps using node:crypto.

Adds unit tests for the fallback and a browser regression test that removes crypto.randomUUID, and documents the secure-context constraint in AGENTS.md.

Note: this only fixes the crash. HTTP-only deployment remains inadvisable — Trino credentials travel as Basic auth, and the cookie Secure flag and SvelteKit ORIGIN/CSRF settings still need configuring for plain HTTP.

`crypto.randomUUID()` is only exposed in secure contexts. Over plain HTTP on
a non-localhost host it is `undefined`, so every client-side call threw
`TypeError: crypto.randomUUID is not a function`.

`tabStore` is built at module scope, so the throw happened during hydration
of /trino: SSR succeeded (Node has a global crypto) and the browser received
200, but the page stayed blank and nothing rendered.

Add `randomUUID()` in `$lib/utils/uuid.js`, which keeps the native fast path
and falls back to `crypto.getRandomValues()` (not secure-context gated), and
use it at the four client-side call sites:

- tab-store (fatal — module-scope init)
- toast store
- storage connection ids
- upload entries

Server-side code keeps using `node:crypto`.

Adds unit tests for the fallback and a browser regression test that removes
`crypto.randomUUID`, and documents the secure-context constraint in AGENTS.md.

Note: this only fixes the crash. HTTP-only deployment remains inadvisable —
Trino credentials travel as Basic auth, and the cookie `Secure` flag and
SvelteKit `ORIGIN`/CSRF settings still need configuring for plain HTTP.
@F3l1x1vo
F3l1x1vo requested a review from Bohreromir October 15, 2026 09:16
@F3l1x1vo F3l1x1vo self-assigned this Oct 15, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 58.31% 2885 / 4947
🔵 Statements 62.9% 4131 / 6567
🔵 Functions 69.43% 1095 / 1577
🔵 Branches 49.29% 1507 / 3057
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/components/storage/modals/upload/UploadModal.svelte 81.65% 49.2% 82.88% 77.57% 71-72, 103, 113-115, 131-133, 152-154, 168-172, 232-286, 300-302, 325, 427-430
src/lib/storage/connection-storage.ts 95.83% 100% 94.11% 95% 39, 131
src/lib/stores/tab-store.svelte.ts 41.79% 19.67% 43.24% 49.09% 58-70, 76, 80-86, 102, 111, 116, 121-128, 148, 159, 174-175, 180-183, 188, 199-255, 266-272
src/lib/stores/toast.svelte.ts 50% 40% 25% 71.42% 17-23
src/lib/utils/uuid.ts 100% 100% 100% 100%
Generated in workflow #1076 for commit a33ee6c by the Vitest Coverage Report Action

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