Repository navigation
Conversation
devzain15
force-pushed
the
fix/random-uuid-fallback
branch
2 times, most recently
from
October 24, 2026 09:58
a03ecd2 to
29725e5
Compare
Browsers only expose crypto.randomUUID in secure contexts, so sending a message or opening a commit photo on a plain http dev site threw "crypto.randomUUID is not a function". Build the uuid from crypto.getRandomValues when the native function is absent. Closes dev-null-sh#620
devzain15
force-pushed
the
fix/random-uuid-fallback
branch
from
October 24, 2026 09:58
29725e5 to
9171957
Compare
Author
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.
Summary
Browsers only expose
crypto.randomUUIDin secure contexts, so on a plain http dev site (for example Herd'shttp://*.test) sending a remote message threwUncaught TypeError: crypto.randomUUID is not a function, and opening a commit photo hit the same call. Both now work in insecure contexts: the uuid comes fromcrypto.randomUUIDwhen the browser has it, and is otherwise built as an RFC 4122 v4 uuid fromcrypto.getRandomValues, which is available everywhere.Closes #620.
Changes
resources/js/lib/utils.ts: newrandomUuid()helper that prefers the native function and otherwise assembles a v4 uuid (version nibble4, variant bits10) from 16 random bytes.resources/js/lib/chat.tsandresources/js/lib/commit-photo.ts: the fourcrypto.randomUUID()call sites use the helper. Production behaviour on https is unchanged.tests/Unit/RandomUuid.test.ts: covers the native path and the fallback's shape and uniqueness, stubbingcrypto.randomUUIDonly for the duration of each test.Validation
Local, Node 22.22.2:
node --experimental-strip-types --test tests/Unit/RandomUuid.test.ts: 2 passed.bun run test:unit: 129 passed, 1 failed. The failure isSeriesStash.test.ts, which shells out to vitest and fails onCannot find package '@/actions/...'because the Wayfinder-generated modules are absent in this environment; unrelated to this change.bun run test:lint: no errors in the changed files;vp fmt --checkon the four changed files is clean. The remaining errors are allTS2307for the missing generated@/actionsand@/routesmodules.bun run test:types: 257 errors, allTS2307for the same missing generated modules.composer test:lint,test:type-coverage,pest) could not run locally (PHP 8.4 installed, repo needs 8.5; no vendor). The diff touches no PHP, so hosted CI is the authority for those.No UI, layout or mobile interaction changes, so visual and device verification do not apply.
Independent review
Reviewed by a separate read-only Claude Code agent, base
8adba04(upstreamproduction), head = this branch's single commit. Verdict: PASS on correctness (v4 version nibble and variant bits, 36-char layout, native path preferred), regressions (no remaining directcrypto.randomUUIDcalls, no other tests depend on it,node --testisolates files per process), architecture and style (minimal helper beside the other pure helpers inutils.ts, sorted imports, matches existing test conventions), and tests. The reviewer re-ran the new test (2 passed),vp fmt --checkandtscon the test tsconfig, and verified the nativecrypto.randomUUIDis intact after the test file runs. Limits: the reviewer had the same environment as above (no generated Wayfinder modules, no PHP).Limitations
The fallback path was exercised only in Node's test runner by removing
crypto.randomUUID, not in a browser served over plain http.