mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 12:59:12 -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() {
|
goog.scope(function() {
|
||||||
const core = cljs.core;
|
const core = cljs.core;
|
||||||
|
const global = goog.global;
|
||||||
const self = app.common.uuid_impl;
|
const self = app.common.uuid_impl;
|
||||||
|
|
||||||
const fill = (() => {
|
const fill = (() => {
|
||||||
if (typeof window === "object" && typeof window.crypto !== "undefined") {
|
if (typeof global.crypto !== "undefined") {
|
||||||
return (buf) => {
|
return (buf) => {
|
||||||
window.crypto.getRandomValues(buf);
|
global.crypto.getRandomValues(buf);
|
||||||
return buf;
|
|
||||||
};
|
|
||||||
} else if (typeof self === "object" && typeof self.crypto !== "undefined") {
|
|
||||||
return (buf) => {
|
|
||||||
self.crypto.getRandomValues(buf);
|
|
||||||
return buf;
|
return buf;
|
||||||
};
|
};
|
||||||
} else if (typeof require === "function") {
|
} else if (typeof require === "function") {
|
||||||
|
@ -34,7 +30,7 @@ goog.scope(function() {
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// FALLBACK
|
// 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) => {
|
return (buf) => {
|
||||||
for (let i = 0, r; i < buf.length; i++) {
|
for (let i = 0, r; i < buf.length; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue