Socket
Socket
Sign inDemoInstall

uid-safe

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uid-safe - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

6

HISTORY.md

@@ -0,1 +1,7 @@

1.1.0 / 2015-02-01
==================
* Use `crypto.randomBytes`, if available
* deps: base64-url@1.2.1
1.0.3 / 2015-01-31

@@ -2,0 +8,0 @@ ==================

29

index.js

@@ -14,3 +14,3 @@ /*!

var Promise
var pseudoRandomBytes = require('crypto').pseudoRandomBytes
var crypto = require('crypto')
var escape = require('base64-url').escape

@@ -60,3 +60,7 @@

function uidSync(length) {
return toString(pseudoRandomBytes(length))
try {
return toString(crypto.randomBytes(length))
} catch (e) {
return toString(crypto.pseudoRandomBytes(length))
}
}

@@ -73,3 +77,3 @@

function generateUid(length, callback) {
pseudoRandomBytes(length, function (err, buf) {
randomBytes(length, function (err, buf) {
if (err) return callback(err)

@@ -81,2 +85,21 @@ callback(null, toString(buf))

/**
* Get some random bytes.
*
* @param {number} length
* @param {function} callback
* @return {Buffer}
* @private
*/
function randomBytes(length, callback) {
crypto.randomBytes(length, function (err, buf) {
if (!err) return callback(null, buf)
crypto.pseudoRandomBytes(length, function (err, buf) {
if (err) return callback(err)
callback(null, buf)
})
})
}
/**
* Change a Buffer into a string.

@@ -83,0 +106,0 @@ *

9

package.json
{
"name": "uid-safe",
"description": "URL and cookie safe UIDs",
"version": "1.0.3",
"version": "1.1.0",
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",

@@ -12,3 +12,3 @@ "contributors": [

"dependencies": {
"base64-url": "1.2.0",
"base64-url": "1.2.1",
"native-or-bluebird": "~1.1.2"

@@ -18,4 +18,5 @@ },

"bluebird": "2",
"istanbul": "0",
"mocha": "~2.1.0"
"istanbul": "0.3.5",
"mocha": "~2.1.0",
"proxyquire": "~1.2.0"
},

@@ -22,0 +23,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc