mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 08:20:45 -05:00
🐛 Fix CSRNG usage on webworker context.
This commit is contained in:
parent
08dce3bcdc
commit
2ac790693a
1 changed files with 4 additions and 8 deletions
|
@ -12,17 +12,13 @@ goog.provide("app.common.uuid_impl");
|
|||
|
||||
goog.scope(function() {
|
||||
const core = cljs.core;
|
||||
const global = goog.global;
|
||||
const self = app.common.uuid_impl;
|
||||
|
||||
const fill = (() => {
|
||||
if (typeof window === "object" && typeof window.crypto !== "undefined") {
|
||||
if (typeof global.crypto !== "undefined") {
|
||||
return (buf) => {
|
||||
window.crypto.getRandomValues(buf);
|
||||
return buf;
|
||||
};
|
||||
} else if (typeof self === "object" && typeof self.crypto !== "undefined") {
|
||||
return (buf) => {
|
||||
self.crypto.getRandomValues(buf);
|
||||
global.crypto.getRandomValues(buf);
|
||||
return buf;
|
||||
};
|
||||
} else if (typeof require === "function") {
|
||||
|
@ -34,7 +30,7 @@ goog.scope(function() {
|
|||
};
|
||||
} else {
|
||||
// FALLBACK
|
||||
console.warn("No high quality RNG available, switching back to Math.random.");
|
||||
console.warn("No SRNG available, switching back to Math.random.");
|
||||
|
||||
return (buf) => {
|
||||
for (let i = 0, r; i < buf.length; i++) {
|
||||
|
|
Loading…
Reference in a new issue