mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-12-05 14:26:23 +01:00
Make the web dev server work from another machine (#665)
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
48889b6550
commit
a822cc93d4
7 files changed
+154
-78
No files matched your search
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Random ids that do not need a secure context.
|
||||
*
|
||||
* `crypto.randomUUID` exists only on HTTPS and localhost, so a tab opened at
|
||||
* `http://some-host:1424` — a self-hosted instance reached from another machine —
|
||||
* throws on it before anything renders. `crypto.getRandomValues` carries no such
|
||||
* restriction, and nothing here needs UUID semantics: these ids identify a tab and
|
||||
* a stream within one page, and only have to not collide with each other.
|
||||
*/
|
||||
export function randomId(bytes = 8): string {
|
||||
const buf = new Uint8Array(bytes);
|
||||
crypto.getRandomValues(buf);
|
||||
return Array.from(buf, (b) => b.toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
Reference in new issue
Block a user