Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
function oldBrowser () {
throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
}
var safeBuffer = require('safe-buffer')
var randombytes = require('randombytes')
var Buffer = safeBuffer.Buffer
var kBufferMaxLength = safeBuffer.kMaxLength
var crypto = global.crypto || global.msCrypto
var kMaxUint32 = Math.pow(2, 32) - 1
function assertOffset (offset, length) {
if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
throw new TypeError('offset must be a number')
}
if (offset > kMaxUint32 || offset < 0) {
throw new TypeError('offset must be a uint32')
}
if (offset > kBufferMaxLength || offset > length) {
throw new RangeError('offset out of range')
}
}