fix(app): guard randomUUID in insecure browser contexts (#13237)

Co-authored-by: Selim <31136147+selimerunkut@users.noreply.github.com>
This commit is contained in:
Adam
2026-02-11 19:05:15 -06:00
committed by GitHub
parent aea68c386a
commit 81ca2df6ad
5 changed files with 98 additions and 6 deletions

View File

@@ -0,0 +1,12 @@
const fallback = () => Math.random().toString(16).slice(2)
export function uuid() {
const c = globalThis.crypto
if (!c || typeof c.randomUUID !== "function") return fallback()
if (typeof globalThis.isSecureContext === "boolean" && !globalThis.isSecureContext) return fallback()
try {
return c.randomUUID()
} catch {
return fallback()
}
}