summaryrefslogtreecommitdiffstats
path: root/node_modules/randomfill
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/randomfill')
-rw-r--r--node_modules/randomfill/.travis.yml15
-rw-r--r--node_modules/randomfill/.zuul.yml1
-rw-r--r--node_modules/randomfill/LICENSE21
-rw-r--r--node_modules/randomfill/README.md15
-rw-r--r--node_modules/randomfill/browser.js108
-rw-r--r--node_modules/randomfill/index.js7
-rw-r--r--node_modules/randomfill/package.json62
-rw-r--r--node_modules/randomfill/test.js28
8 files changed, 257 insertions, 0 deletions
diff --git a/node_modules/randomfill/.travis.yml b/node_modules/randomfill/.travis.yml
new file mode 100644
index 0000000..69fdf71
--- /dev/null
+++ b/node_modules/randomfill/.travis.yml
@@ -0,0 +1,15 @@
+sudo: false
+language: node_js
+matrix:
+ include:
+ - node_js: '7'
+ env: TEST_SUITE=test
+ - node_js: '6'
+ env: TEST_SUITE=test
+ - node_js: '5'
+ env: TEST_SUITE=test
+ - node_js: '4'
+ env: TEST_SUITE=test
+ - node_js: '4'
+ env: TEST_SUITE=phantom
+script: "npm run-script $TEST_SUITE"
diff --git a/node_modules/randomfill/.zuul.yml b/node_modules/randomfill/.zuul.yml
new file mode 100644
index 0000000..96d9cfb
--- /dev/null
+++ b/node_modules/randomfill/.zuul.yml
@@ -0,0 +1 @@
+ui: tape
diff --git a/node_modules/randomfill/LICENSE b/node_modules/randomfill/LICENSE
new file mode 100644
index 0000000..fea9d48
--- /dev/null
+++ b/node_modules/randomfill/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 crypto-browserify
+
+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.
diff --git a/node_modules/randomfill/README.md b/node_modules/randomfill/README.md
new file mode 100644
index 0000000..1ae13ad
--- /dev/null
+++ b/node_modules/randomfill/README.md
@@ -0,0 +1,15 @@
+randomfill
+===
+
+[![Version](http://img.shields.io/npm/v/randomfill.svg)](https://www.npmjs.org/package/randomfill)
+
+randomfill from node that works in the browser. In node you just get crypto.randomBytes, but in the browser it uses .crypto/msCrypto.getRandomValues
+
+```js
+var randomFill = require('randomfill');
+var buf
+randomFill.randomFillSync(16);//get 16 random bytes
+randomFill.randomFill(16, function (err, resp) {
+ // resp is 16 random bytes
+});
+```
diff --git a/node_modules/randomfill/browser.js b/node_modules/randomfill/browser.js
new file mode 100644
index 0000000..ce34a69
--- /dev/null
+++ b/node_modules/randomfill/browser.js
@@ -0,0 +1,108 @@
+'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')
+ }
+}
+
+function assertSize (size, offset, length) {
+ if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
+ throw new TypeError('size must be a number')
+ }
+
+ if (size > kMaxUint32 || size < 0) {
+ throw new TypeError('size must be a uint32')
+ }
+
+ if (size + offset > length || size > kBufferMaxLength) {
+ throw new RangeError('buffer too small')
+ }
+}
+if ((crypto && crypto.getRandomValues) || !process.browser) {
+ exports.randomFill = randomFill
+ exports.randomFillSync = randomFillSync
+} else {
+ exports.randomFill = oldBrowser
+ exports.randomFillSync = oldBrowser
+}
+function randomFill (buf, offset, size, cb) {
+ if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
+ throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
+ }
+
+ if (typeof offset === 'function') {
+ cb = offset
+ offset = 0
+ size = buf.length
+ } else if (typeof size === 'function') {
+ cb = size
+ size = buf.length - offset
+ } else if (typeof cb !== 'function') {
+ throw new TypeError('"cb" argument must be a function')
+ }
+ assertOffset(offset, buf.length)
+ assertSize(size, offset, buf.length)
+ return actualFill(buf, offset, size, cb)
+}
+
+function actualFill (buf, offset, size, cb) {
+ if (process.browser) {
+ var ourBuf = buf.buffer
+ var uint = new Uint8Array(ourBuf, offset, size)
+ crypto.getRandomValues(uint)
+ if (cb) {
+ process.nextTick(function () {
+ cb(null, buf)
+ })
+ return
+ }
+ return buf
+ }
+ if (cb) {
+ randombytes(size, function (err, bytes) {
+ if (err) {
+ return cb(err)
+ }
+ bytes.copy(buf, offset)
+ cb(null, buf)
+ })
+ return
+ }
+ var bytes = randombytes(size)
+ bytes.copy(buf, offset)
+ return buf
+}
+function randomFillSync (buf, offset, size) {
+ if (typeof offset === 'undefined') {
+ offset = 0
+ }
+ if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
+ throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
+ }
+
+ assertOffset(offset, buf.length)
+
+ if (size === undefined) size = buf.length - offset
+
+ assertSize(size, offset, buf.length)
+
+ return actualFill(buf, offset, size)
+}
diff --git a/node_modules/randomfill/index.js b/node_modules/randomfill/index.js
new file mode 100644
index 0000000..e2b5f7a
--- /dev/null
+++ b/node_modules/randomfill/index.js
@@ -0,0 +1,7 @@
+var crypto = require('crypto')
+if (typeof crypto.randomFill === 'function' && typeof crypto.randomFillSync === 'function') {
+ exports.randomFill = crypto.randomFill
+ exports.randomFillSync = crypto.randomFillSync
+} else {
+ module.exports = require('./browser')
+}
diff --git a/node_modules/randomfill/package.json b/node_modules/randomfill/package.json
new file mode 100644
index 0000000..13f5f63
--- /dev/null
+++ b/node_modules/randomfill/package.json
@@ -0,0 +1,62 @@
+{
+ "_from": "randomfill@^1.0.3",
+ "_id": "randomfill@1.0.4",
+ "_inBundle": false,
+ "_integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==",
+ "_location": "/randomfill",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "randomfill@^1.0.3",
+ "name": "randomfill",
+ "escapedName": "randomfill",
+ "rawSpec": "^1.0.3",
+ "saveSpec": null,
+ "fetchSpec": "^1.0.3"
+ },
+ "_requiredBy": [
+ "/crypto-browserify"
+ ],
+ "_resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz",
+ "_shasum": "c92196fc86ab42be983f1bf31778224931d61458",
+ "_spec": "randomfill@^1.0.3",
+ "_where": "/home/pruss/Dev/3-minute-website/node_modules/crypto-browserify",
+ "author": "",
+ "browser": "browser.js",
+ "bugs": {
+ "url": "https://github.com/crypto-browserify/randomfill/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "randombytes": "^2.0.5",
+ "safe-buffer": "^5.1.0"
+ },
+ "deprecated": false,
+ "description": "random fill from browserify stand alone",
+ "devDependencies": {
+ "phantomjs": "^1.9.9",
+ "standard": "^10.0.2",
+ "tap-spec": "^2.1.2",
+ "tape": "^4.6.3",
+ "zuul": "^3.7.2"
+ },
+ "homepage": "https://github.com/crypto-browserify/randomfill",
+ "keywords": [
+ "crypto",
+ "random"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "randomfill",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/crypto-browserify/randomfill.git"
+ },
+ "scripts": {
+ "local": "zuul --local --no-coverage -- test.js",
+ "phantom": "zuul --phantom -- test.js",
+ "test": "standard && node test.js | tspec"
+ },
+ "version": "1.0.4"
+}
diff --git a/node_modules/randomfill/test.js b/node_modules/randomfill/test.js
new file mode 100644
index 0000000..eff227c
--- /dev/null
+++ b/node_modules/randomfill/test.js
@@ -0,0 +1,28 @@
+var test = require('tape')
+var crypto = require('./browser')
+var Buffer = require('safe-buffer').Buffer
+test('sync', function (t) {
+ t.test('first', function (t) {
+ const buf = Buffer.alloc(10)
+ const before = buf.toString('hex')
+ crypto.randomFillSync(buf, 5, 5)
+ const after = buf.toString('hex')
+ t.notEqual(before, after)
+ t.equal(before.slice(0, 10), after.slice(0, 10))
+ t.end()
+ })
+})
+test('async', function (t) {
+ t.test('first', function (t) {
+ const buf = Buffer.alloc(10)
+ const before = buf.toString('hex')
+ crypto.randomFill(buf, 5, 5, function (err, bufa) {
+ t.error(err)
+ const after = bufa.toString('hex')
+ t.notEqual(before, after)
+ t.equal(before.slice(0, 10), after.slice(0, 10))
+ t.ok(buf === bufa, 'same buffer')
+ t.end()
+ })
+ })
+})