nav tabs on admin dashboard
This commit is contained in:
30
node_modules/randombytes/browser.js
generated
vendored
30
node_modules/randombytes/browser.js
generated
vendored
@@ -1,5 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
// limit of Crypto.getRandomValues()
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
||||
var MAX_BYTES = 65536
|
||||
|
||||
// Node supports requesting up to this number of bytes
|
||||
// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
|
||||
var MAX_UINT32 = 4294967295
|
||||
|
||||
function oldBrowser () {
|
||||
throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
|
||||
}
|
||||
@@ -15,19 +23,23 @@ if (crypto && crypto.getRandomValues) {
|
||||
|
||||
function randomBytes (size, cb) {
|
||||
// phantomjs needs to throw
|
||||
if (size > 65536) throw new Error('requested too many random bytes')
|
||||
// in case browserify isn't using the Uint8Array version
|
||||
var rawBytes = new global.Uint8Array(size)
|
||||
if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')
|
||||
|
||||
var bytes = Buffer.allocUnsafe(size)
|
||||
|
||||
// This will not work in older browsers.
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
||||
if (size > 0) { // getRandomValues fails on IE if size == 0
|
||||
crypto.getRandomValues(rawBytes)
|
||||
if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
|
||||
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
||||
for (var generated = 0; generated < size; generated += MAX_BYTES) {
|
||||
// buffer.slice automatically checks if the end is past the end of
|
||||
// the buffer so we don't have to here
|
||||
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES))
|
||||
}
|
||||
} else {
|
||||
crypto.getRandomValues(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: phantomjs doesn't like a buffer being passed here
|
||||
var bytes = Buffer.from(rawBytes.buffer)
|
||||
|
||||
if (typeof cb === 'function') {
|
||||
return process.nextTick(function () {
|
||||
cb(null, bytes)
|
||||
|
||||
10
node_modules/randombytes/package.json
generated
vendored
10
node_modules/randombytes/package.json
generated
vendored
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"_from": "randombytes@^2.0.0",
|
||||
"_id": "randombytes@2.0.6",
|
||||
"_id": "randombytes@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
|
||||
"_integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
|
||||
"_location": "/randombytes",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
@@ -22,8 +22,8 @@
|
||||
"/public-encrypt",
|
||||
"/randomfill"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
|
||||
"_shasum": "d302c522948588848a8d300c932b44c24231da80",
|
||||
"_resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
||||
"_shasum": "df6f84372f0270dc65cdf6291349ab7a473d4f2a",
|
||||
"_spec": "randombytes@^2.0.0",
|
||||
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\crypto-browserify",
|
||||
"author": "",
|
||||
@@ -61,5 +61,5 @@
|
||||
"phantom": "zuul --phantom -- test.js",
|
||||
"test": "standard && node test.js | tspec"
|
||||
},
|
||||
"version": "2.0.6"
|
||||
"version": "2.1.0"
|
||||
}
|
||||
|
||||
65
node_modules/randombytes/test.js
generated
vendored
65
node_modules/randombytes/test.js
generated
vendored
@@ -1,16 +1,29 @@
|
||||
var test = require('tape')
|
||||
var randomBytes = require('./')
|
||||
var MAX_BYTES = 65536
|
||||
var MAX_UINT32 = 4294967295
|
||||
|
||||
test('sync', function (t) {
|
||||
t.plan(4)
|
||||
t.plan(9)
|
||||
t.equals(randomBytes(0).length, 0, 'len: ' + 0)
|
||||
t.equals(randomBytes(3).length, 3, 'len: ' + 3)
|
||||
t.equals(randomBytes(30).length, 30, 'len: ' + 30)
|
||||
t.equals(randomBytes(300).length, 300, 'len: ' + 300)
|
||||
t.equals(randomBytes(17 + MAX_BYTES).length, 17 + MAX_BYTES, 'len: ' + 17 + MAX_BYTES)
|
||||
t.equals(randomBytes(MAX_BYTES * 100).length, MAX_BYTES * 100, 'len: ' + MAX_BYTES * 100)
|
||||
t.throws(function () {
|
||||
randomBytes(MAX_UINT32 + 1)
|
||||
})
|
||||
t.throws(function () {
|
||||
t.equals(randomBytes(-1))
|
||||
})
|
||||
t.throws(function () {
|
||||
t.equals(randomBytes('hello'))
|
||||
})
|
||||
})
|
||||
|
||||
test('async', function (t) {
|
||||
t.plan(4)
|
||||
t.plan(9)
|
||||
|
||||
randomBytes(0, function (err, resp) {
|
||||
if (err) throw err
|
||||
@@ -35,22 +48,34 @@ test('async', function (t) {
|
||||
|
||||
t.equals(resp.length, 300, 'len: ' + 300)
|
||||
})
|
||||
|
||||
randomBytes(17 + MAX_BYTES, function (err, resp) {
|
||||
if (err) throw err
|
||||
|
||||
t.equals(resp.length, 17 + MAX_BYTES, 'len: ' + 17 + MAX_BYTES)
|
||||
})
|
||||
|
||||
randomBytes(MAX_BYTES * 100, function (err, resp) {
|
||||
if (err) throw err
|
||||
|
||||
t.equals(resp.length, MAX_BYTES * 100, 'len: ' + MAX_BYTES * 100)
|
||||
})
|
||||
|
||||
t.throws(function () {
|
||||
randomBytes(MAX_UINT32 + 1, function () {
|
||||
t.ok(false, 'should not get here')
|
||||
})
|
||||
})
|
||||
|
||||
t.throws(function () {
|
||||
randomBytes(-1, function () {
|
||||
t.ok(false, 'should not get here')
|
||||
})
|
||||
})
|
||||
|
||||
t.throws(function () {
|
||||
randomBytes('hello', function () {
|
||||
t.ok(false, 'should not get here')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
if (process.browser) {
|
||||
test('requesting to much throws', function (t) {
|
||||
t.plan(1)
|
||||
t.throws(function () {
|
||||
randomBytes(65537)
|
||||
})
|
||||
})
|
||||
|
||||
test('requesting to much throws async', function (t) {
|
||||
t.plan(1)
|
||||
t.throws(function () {
|
||||
randomBytes(65537, function () {
|
||||
t.ok(false, 'should not get here')
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user