Comparing version 1.4.3 to 1.4.6
{ | ||
"name": "node-uuid", | ||
"version": "1.4.3", | ||
"version": "1.4.6", | ||
"homepage": "https://github.com/broofa/node-uuid", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -5,8 +5,15 @@ { | ||
"description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", | ||
"version": "1.4.3", | ||
"version": "1.4.6", | ||
"author": "Robert Kieffer <robert@broofa.com>", | ||
"contributors": [ | ||
{"name": "Christoph Tavan <dev@tavan.de>", "github": "https://github.com/ctavan"} | ||
{ | ||
"name": "Christoph Tavan <dev@tavan.de>", | ||
"github": "https://github.com/ctavan" | ||
} | ||
], | ||
"keywords": ["uuid", "guid", "rfc4122"], | ||
"keywords": [ | ||
"uuid", | ||
"guid", | ||
"rfc4122" | ||
], | ||
"dependencies": {}, | ||
@@ -19,2 +26,2 @@ "development": {}, | ||
"license": "MIT" | ||
} | ||
} |
{ | ||
"name" : "node-uuid", | ||
"description" : "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", | ||
"url" : "http://github.com/broofa/node-uuid", | ||
"keywords" : ["uuid", "guid", "rfc4122"], | ||
"author" : "Robert Kieffer <robert@broofa.com>", | ||
"contributors" : [ | ||
{"name": "Christoph Tavan <dev@tavan.de>", "github": "https://github.com/ctavan"} | ||
], | ||
"author": { | ||
"email": "robert@broofa.com", | ||
"name": "Robert Kieffer" | ||
}, | ||
"bin": { | ||
"uuid": "./bin/uuid" | ||
}, | ||
"scripts": { | ||
"test": "node test/test.js" | ||
"bugs": { | ||
"url": "https://github.com/broofa/node-uuid/issues" | ||
}, | ||
"lib" : ".", | ||
"main" : "./uuid.js", | ||
"repository" : { "type" : "git", "url" : "https://github.com/broofa/node-uuid.git" }, | ||
"version" : "1.4.3", | ||
"contributors": [ | ||
{ | ||
"name": "AJ ONeal", | ||
"email": "coolaj86@gmail.com" | ||
}, | ||
{ | ||
"name": "Christoph Tavan", | ||
"email": "dev@tavan.de" | ||
} | ||
], | ||
"dependencies": {}, | ||
"description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", | ||
"devDependencies": { | ||
"nyc": "^2.2.0" | ||
}, | ||
"directories": {}, | ||
"homepage": "https://github.com/broofa/node-uuid", | ||
"installable": true, | ||
"keywords": [ | ||
"guid", | ||
"rfc4122", | ||
"uuid" | ||
], | ||
"lib": ".", | ||
"licenses": [ | ||
@@ -25,3 +41,22 @@ { | ||
} | ||
] | ||
], | ||
"main": "./uuid.js", | ||
"maintainers": [ | ||
{ | ||
"name": "broofa", | ||
"email": "robert@broofa.com" | ||
} | ||
], | ||
"name": "node-uuid", | ||
"optionalDependencies": {}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/broofa/node-uuid.git" | ||
}, | ||
"scripts": { | ||
"coverage": "nyc npm test && nyc report", | ||
"test": "node test/test.js" | ||
}, | ||
"url": "http://github.com/broofa/node-uuid", | ||
"version": "1.4.6" | ||
} |
@@ -10,3 +10,5 @@ # node-uuid | ||
* Registered as a [ComponentJS](https://github.com/component/component) [component](https://github.com/component/component/wiki/Components) ('broofa/node-uuid'). | ||
* Cryptographically strong random # generation on supporting platforms | ||
* Cryptographically strong random # generation | ||
* `crypto.randomBytes(n)` in node.js | ||
* `window.crypto.getRandomValues(ta)` in [supported browsers](https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues#Browser_Compatibility) | ||
* 1.1K minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! ) | ||
@@ -13,0 +15,0 @@ * [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html) |
if (!this.uuid) { | ||
// node.js | ||
uuid = require('../uuid'); | ||
if (!/_rb/.test(uuid._rng.toString())) { | ||
throw new Error("should use crypto for node.js"); | ||
} | ||
} | ||
@@ -5,0 +8,0 @@ |
65
uuid.js
@@ -6,4 +6,5 @@ // uuid.js | ||
(function() { | ||
var _global = this; | ||
/*global window, require, define */ | ||
(function(_window) { | ||
'use strict'; | ||
@@ -13,23 +14,30 @@ // Unique ID creation requires a high quality random # generator. We feature | ||
// returns 128-bits of randomness, since that's what's usually required | ||
var _rng; | ||
var _rng, _mathRNG, _nodeRNG, _whatwgRNG; | ||
// Allow for MSIE11 msCrypto | ||
var _crypto = _window.crypto || _window.msCrypto; | ||
// Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html | ||
// | ||
// Moderately fast, high quality | ||
if (typeof(_global.require) == 'function') { | ||
if ('function' === typeof require) { | ||
try { | ||
var _rb = _global.require('crypto').randomBytes; | ||
_rng = _rb && function() {return _rb(16);}; | ||
var _rb = require('crypto').randomBytes; | ||
_nodeRNG = _rng = _rb && function() {return _rb(16);}; | ||
_rng(); | ||
} catch(e) {} | ||
} | ||
if (!_rng && _global.crypto && crypto.getRandomValues) { | ||
if (!_rng && _crypto && _crypto.getRandomValues) { | ||
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto | ||
// | ||
// Moderately fast, high quality | ||
var _rnds8 = new Uint8Array(16); | ||
_rng = function whatwgRNG() { | ||
crypto.getRandomValues(_rnds8); | ||
return _rnds8; | ||
}; | ||
try { | ||
var _rnds8 = new Uint8Array(16); | ||
_whatwgRNG = _rng = function whatwgRNG() { | ||
_crypto.getRandomValues(_rnds8); | ||
return _rnds8; | ||
}; | ||
_rng(); | ||
} catch(e) {} | ||
} | ||
@@ -43,5 +51,5 @@ | ||
var _rnds = new Array(16); | ||
_rng = function() { | ||
_mathRNG = _rng = function() { | ||
for (var i = 0, r; i < 16; i++) { | ||
if ((i & 0x03) === 0) r = Math.random() * 0x100000000; | ||
if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; } | ||
_rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; | ||
@@ -52,6 +60,9 @@ } | ||
}; | ||
if ('undefined' !== typeof console && console.warn) { | ||
console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); | ||
} | ||
} | ||
// Buffer class to use | ||
var BufferClass = typeof(_global.Buffer) == 'function' ? _global.Buffer : Array; | ||
var BufferClass = ('function' === typeof Buffer) ? Buffer : Array; | ||
@@ -125,3 +136,3 @@ // Maps for number <-> hex string conversion | ||
var clockseq = options.clockseq != null ? options.clockseq : _clockseq; | ||
var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq; | ||
@@ -132,7 +143,7 @@ // UUID timestamps are 100 nano-second units since the Gregorian epoch, | ||
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. | ||
var msecs = options.msecs != null ? options.msecs : new Date().getTime(); | ||
var msecs = (options.msecs != null) ? options.msecs : new Date().getTime(); | ||
// Per 4.2.1.2, use count of uuid's generated during the current clock | ||
// cycle to simulate higher resolution clock | ||
var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1; | ||
var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1; | ||
@@ -203,4 +214,4 @@ // Time since last uuid creation (in msecs) | ||
if (typeof(options) == 'string') { | ||
buf = options == 'binary' ? new BufferClass(16) : null; | ||
if (typeof(options) === 'string') { | ||
buf = (options === 'binary') ? new BufferClass(16) : null; | ||
options = null; | ||
@@ -233,2 +244,6 @@ } | ||
uuid.BufferClass = BufferClass; | ||
uuid._rng = _rng; | ||
uuid._mathRNG = _mathRNG; | ||
uuid._nodeRNG = _nodeRNG; | ||
uuid._whatwgRNG = _whatwgRNG; | ||
@@ -241,16 +256,16 @@ if (typeof(module) != 'undefined' && module.exports) { | ||
define(function() {return uuid;}); | ||
} else { | ||
// Publish as global (in browsers) | ||
var _previousRoot = _global.uuid; | ||
var _previousRoot = _window.uuid; | ||
// **`noConflict()` - (browser only) to reset global 'uuid' var** | ||
uuid.noConflict = function() { | ||
_global.uuid = _previousRoot; | ||
_window.uuid = _previousRoot; | ||
return uuid; | ||
}; | ||
_global.uuid = uuid; | ||
_window.uuid = uuid; | ||
} | ||
}).call(this); | ||
})('undefined' !== typeof window ? window : {}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
38988
572
1
0
246
1
2