Comparing version 4.0.0-rc5 to 4.0.0-rc6
@@ -13,15 +13,17 @@ 'use strict'; | ||
let randomBytes; | ||
if (typeof window !== 'undefined') { | ||
if (window.crypto && window.crypto.getRandomValues) { | ||
randomBytes = size => window.crypto.getRandomValues(new Uint8Array(size)); | ||
} else { | ||
randomBytes = size => { | ||
const result = new Uint8Array(size); | ||
for (let i = 0; i < size; ++i) result[i] = Math.floor(Math.random() * 256); | ||
return result; | ||
}; | ||
function insecureRandomBytes(size) { | ||
const result = new Uint8Array(size); | ||
for (let i = 0; i < size; ++i) result[i] = Math.floor(Math.random() * 256); | ||
return result; | ||
} | ||
let randomBytes = insecureRandomBytes; | ||
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) { | ||
randomBytes = size => window.crypto.getRandomValues(new Uint8Array(size)); | ||
} else { | ||
try { | ||
randomBytes = require('crypto').randomBytes; | ||
} catch (e) { | ||
// keep the fallback | ||
} | ||
} else { | ||
randomBytes = require('crypto').randomBytes; | ||
} | ||
@@ -28,0 +30,0 @@ |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "4.0.0-rc5", | ||
"version": "4.0.0-rc6", | ||
"author": "Christian Amor Kvalheim <christkv@gmail.com>", | ||
@@ -57,3 +57,3 @@ "license": "Apache-2.0", | ||
"browser": { | ||
"./index.js": "./dist/bson.browser.umd.js", | ||
"./lib/bson.js": "./dist/bson.browser.umd.js", | ||
"./dist/bson.esm.js": "./dist/bson.browser.esm.js" | ||
@@ -60,0 +60,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
917084
23837