mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 23:16:11 +02:00
Fix rng def in nodejs environment.
This commit is contained in:
parent
f0ed85e53f
commit
ac3d44601a
1 changed files with 7 additions and 5 deletions
12
vendor/uuid/rng.js
vendored
12
vendor/uuid/rng.js
vendored
|
@ -9,23 +9,25 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
goog.provide("uuid.rng");
|
goog.provide("uuid.rng");
|
||||||
|
goog.require("cljs.core");
|
||||||
|
|
||||||
goog.scope(function() {
|
goog.scope(function() {
|
||||||
uuid.rng.getBytes = null;
|
const global = goog.global;
|
||||||
|
|
||||||
// Check if nodejs rng is available (high quality);
|
// Check if nodejs rng is available (high quality);
|
||||||
if (goog.global.require !== undefined) {
|
if (cljs.core._STAR_target_STAR_ === "nodejs") {
|
||||||
const crypto = goog.global.require("crypto");
|
const crypto = require("crypto");
|
||||||
|
|
||||||
uuid.rng.getBytes = function(n) {
|
uuid.rng.getBytes = function(n) {
|
||||||
return crypto.randomBytes(n);
|
return crypto.randomBytes(n);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Check if whatwg rng is available (high quality);
|
// Check if whatwg rng is available (high quality);
|
||||||
else if (goog.global.crypto.getRandomValues !== undefined) {
|
else if (global.crypto !== undefined &&
|
||||||
|
global.crypto.getRandomValues !== undefined) {
|
||||||
uuid.rng.getBytes = function(n) {
|
uuid.rng.getBytes = function(n) {
|
||||||
const buf = new Uint8Array(16);
|
const buf = new Uint8Array(16);
|
||||||
goog.global.crypto.getRandomValues(buf);
|
global.crypto.getRandomValues(buf);
|
||||||
return buf;
|
return buf;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue