Fix random.js for IE11
This commit is contained in:
parent
d28eb4406d
commit
79309b6a88
|
@ -79,8 +79,10 @@ module.exports = {
|
|||
if (!(buf instanceof Uint8Array)) {
|
||||
throw new Error('Invalid type: buf not an Uint8Array');
|
||||
}
|
||||
if (typeof window !== 'undefined' && window.crypto) {
|
||||
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
|
||||
window.crypto.getRandomValues(buf);
|
||||
} else if (typeof window !== 'undefined' && typeof window.msCrypto === 'object' && typeof window.msCrypto.getRandomValues === 'function') {
|
||||
window.msCrypto.getRandomValues(buf);
|
||||
} else if (nodeCrypto) {
|
||||
var bytes = nodeCrypto.randomBytes(buf.length);
|
||||
buf.set(bytes);
|
||||
|
|
Loading…
Reference in New Issue
Block a user