Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -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"

View File

@@ -0,0 +1 @@
ui: tape

View File

@@ -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.

View File

@@ -0,0 +1,14 @@
randombytes
===
[![Version](http://img.shields.io/npm/v/randombytes.svg)](https://www.npmjs.org/package/randombytes) [![Build Status](https://travis-ci.org/crypto-browserify/randombytes.svg?branch=master)](https://travis-ci.org/crypto-browserify/randombytes)
randombytes 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 randomBytes = require('randombytes');
randomBytes(16);//get 16 random bytes
randomBytes(16, function (err, resp) {
// resp is 16 random bytes
});
```

View File

@@ -0,0 +1,38 @@
'use strict'
function oldBrowser () {
throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
}
var Buffer = require('safe-buffer').Buffer
var crypto = global.crypto || global.msCrypto
if (crypto && crypto.getRandomValues) {
module.exports = randomBytes
} else {
module.exports = oldBrowser
}
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)
// 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)
}
// 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)
})
}
return bytes
}

View File

@@ -0,0 +1 @@
module.exports = require('crypto').randomBytes

View File

@@ -0,0 +1,68 @@
{
"_args": [
[
"randombytes@2.0.5",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "randombytes@2.0.5",
"_id": "randombytes@2.0.5",
"_inBundle": false,
"_integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==",
"_location": "/react-scripts/randombytes",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "randombytes@2.0.5",
"name": "randombytes",
"escapedName": "randombytes",
"rawSpec": "2.0.5",
"saveSpec": null,
"fetchSpec": "2.0.5"
},
"_requiredBy": [
"/react-scripts/browserify-rsa",
"/react-scripts/crypto-browserify",
"/react-scripts/diffie-hellman",
"/react-scripts/public-encrypt",
"/react-scripts/randomfill"
],
"_resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz",
"_spec": "2.0.5",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": "",
"browser": "browser.js",
"bugs": {
"url": "https://github.com/crypto-browserify/randombytes/issues"
},
"dependencies": {
"safe-buffer": "^5.1.0"
},
"description": "random bytes 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/randombytes",
"keywords": [
"crypto",
"random"
],
"license": "MIT",
"main": "index.js",
"name": "randombytes",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/crypto-browserify/randombytes.git"
},
"scripts": {
"local": "zuul --local --no-coverage -- test.js",
"phantom": "zuul --phantom -- test.js",
"test": "standard && node test.js | tspec"
},
"version": "2.0.5"
}

View File

@@ -0,0 +1,56 @@
var test = require('tape')
var randomBytes = require('./')
test('sync', function (t) {
t.plan(4)
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)
})
test('async', function (t) {
t.plan(4)
randomBytes(0, function (err, resp) {
if (err) throw err
t.equals(resp.length, 0, 'len: ' + 0)
})
randomBytes(3, function (err, resp) {
if (err) throw err
t.equals(resp.length, 3, 'len: ' + 3)
})
randomBytes(30, function (err, resp) {
if (err) throw err
t.equals(resp.length, 30, 'len: ' + 30)
})
randomBytes(300, function (err, resp) {
if (err) throw err
t.equals(resp.length, 300, 'len: ' + 300)
})
})
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')
})
})
})
}