/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/app/src/utils/uuid.ts
12 строк
359 B
Adam
fix(app): guard randomUUID in insecure browser contexts (#13237)
12 фев 2026, 04:05
Не верифицирован
12 фев 2026, 04:05
81ca2df
Код
Авторство
О чём код?
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() } }