Initial
This commit is contained in:
4
resources/app/node_modules/random-bytes/HISTORY.md
generated
vendored
Normal file
4
resources/app/node_modules/random-bytes/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
1.0.0 / 2016-01-17
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
21
resources/app/node_modules/random-bytes/LICENSE
generated
vendored
Normal file
21
resources/app/node_modules/random-bytes/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
101
resources/app/node_modules/random-bytes/index.js
generated
vendored
Normal file
101
resources/app/node_modules/random-bytes/index.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/*!
|
||||
* random-bytes
|
||||
* Copyright(c) 2016 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var crypto = require('crypto')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var generateAttempts = crypto.randomBytes === crypto.pseudoRandomBytes ? 1 : 3
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = randomBytes
|
||||
module.exports.sync = randomBytesSync
|
||||
|
||||
/**
|
||||
* Generates strong pseudo-random bytes.
|
||||
*
|
||||
* @param {number} size
|
||||
* @param {function} [callback]
|
||||
* @return {Promise}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function randomBytes(size, callback) {
|
||||
// validate callback is a function, if provided
|
||||
if (callback !== undefined && typeof callback !== 'function') {
|
||||
throw new TypeError('argument callback must be a function')
|
||||
}
|
||||
|
||||
// require the callback without promises
|
||||
if (!callback && !global.Promise) {
|
||||
throw new TypeError('argument callback is required')
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
// classic callback style
|
||||
return generateRandomBytes(size, generateAttempts, callback)
|
||||
}
|
||||
|
||||
return new Promise(function executor(resolve, reject) {
|
||||
generateRandomBytes(size, generateAttempts, function onRandomBytes(err, str) {
|
||||
if (err) return reject(err)
|
||||
resolve(str)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates strong pseudo-random bytes sync.
|
||||
*
|
||||
* @param {number} size
|
||||
* @return {Buffer}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function randomBytesSync(size) {
|
||||
var err = null
|
||||
|
||||
for (var i = 0; i < generateAttempts; i++) {
|
||||
try {
|
||||
return crypto.randomBytes(size)
|
||||
} catch (e) {
|
||||
err = e
|
||||
}
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates strong pseudo-random bytes.
|
||||
*
|
||||
* @param {number} size
|
||||
* @param {number} attempts
|
||||
* @param {function} callback
|
||||
* @private
|
||||
*/
|
||||
|
||||
function generateRandomBytes(size, attempts, callback) {
|
||||
crypto.randomBytes(size, function onRandomBytes(err, buf) {
|
||||
if (!err) return callback(null, buf)
|
||||
if (!--attempts) return callback(err)
|
||||
setTimeout(generateRandomBytes.bind(null, size, attempts, callback), 10)
|
||||
})
|
||||
}
|
||||
22
resources/app/node_modules/random-bytes/package.json
generated
vendored
Normal file
22
resources/app/node_modules/random-bytes/package.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "random-bytes",
|
||||
"description": "URL and cookie safe UIDs",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"repository": "crypto-utils/random-bytes",
|
||||
"devDependencies": {
|
||||
"bluebird": "3.1.1",
|
||||
"istanbul": "0.4.2",
|
||||
"mocha": "2.3.4",
|
||||
"proxyquire": "1.2.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user