password-generator
Advanced tools
Comparing version 2.2.0 to 2.2.1
/* | ||
* password-generator | ||
* Copyright(c) 2011-2015 Bermi Ferrer <bermi@bermilabs.com> | ||
* Copyright(c) 2011-2019 Bermi Ferrer <bermi@bermilabs.com> | ||
* MIT Licensed | ||
@@ -8,6 +8,6 @@ */ | ||
var localName, consonant, letter, password, vowel; | ||
letter = /[a-zA-Z]$/; | ||
vowel = /[aeiouAEIOU]$/; | ||
consonant = /[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$/; | ||
var localName, consonant, letter, password, vowel, rand, getRandomValues; | ||
letter = /[a-z]$/i; | ||
vowel = /[aeiou]$/i; | ||
consonant = /[bcdfghjklmnpqrstvwxyz]$/i; | ||
@@ -20,3 +20,3 @@ | ||
// var localPasswordGeneratorLibraryName = 'pass'; | ||
localName = root.localPasswordGeneratorLibraryName || "generatePassword", | ||
localName = root.localPasswordGeneratorLibraryName || "generatePassword"; | ||
@@ -80,3 +80,3 @@ password = function (length, memorable, pattern, prefix) { | ||
function rand(min, max) { | ||
rand = function (min, max) { | ||
var key, value, arr = new Uint8Array(max); | ||
@@ -87,3 +87,3 @@ getRandomValues(arr); | ||
value = arr[key]; | ||
if (value > min && value < max) { | ||
if (value >= min && value < max) { | ||
return value; | ||
@@ -94,6 +94,6 @@ } | ||
return rand(min, max); | ||
} | ||
}; | ||
function getRandomValues(buf) { | ||
getRandomValues = function (buf) { | ||
if (root.crypto && root.crypto.getRandomValues) { | ||
@@ -109,3 +109,3 @@ root.crypto.getRandomValues(buf); | ||
} | ||
} | ||
}; | ||
@@ -112,0 +112,0 @@ |
@@ -1,6 +0,7 @@ | ||
/*! password-generator - v1.0.1 (2015-09-24) | ||
/*! password-generator - v2.2.1 (2019-11-01) | ||
* ----------------- | ||
* Copyright(c) 2011-2015 Bermi Ferrer <bermi@bermilabs.com> | ||
* Copyright(c) 2011-2019 Bermi Ferrer <bermi@bermilabs.com> | ||
* https://github.com/bermi/password-generator | ||
* MIT Licensed | ||
*/ | ||
(function(e){function o(e,t){var n,r,i=new Uint8Array(t);u(i);for(n in i)if(i.hasOwnProperty(n)){r=i[n];if(r>e&&r<t)return r}return o(e,t)}function u(t){if(e.crypto&&e.crypto.getRandomValues)e.crypto.getRandomValues(t);else if(typeof e.msCrypto=="object"&&typeof e.msCrypto.getRandomValues=="function")e.msCrypto.getRandomValues(t);else{if(module.exports!==i||typeof require=="undefined")throw new Error("No secure random number generator available.");var n=require("crypto").randomBytes(t.length);t.set(n)}}var t,n,r,i,s;r=/[a-zA-Z]$/,s=/[aeiouAEIOU]$/,n=/[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$/,t=e.localPasswordGeneratorLibraryName||"generatePassword",i=function(e,t,r,i){var u="",a,f,l=[];e==null&&(e=10),t==null&&(t=!0),r==null&&(r=/\w/),i==null&&(i="");if(!t){for(f=33;126>f;f+=1)u=String.fromCharCode(f),u.match(r)&&l.push(u);if(!l.length)throw new Error("Could not find characters that match the password pattern "+r+". Patterns must match individual "+"characters, not the password as a whole.")}while(i.length<e)t?(i.match(n)?r=s:r=n,a=o(33,126),u=String.fromCharCode(a)):u=l[o(0,l.length)],t&&(u=u.toLowerCase()),u.match(r)&&(i=""+i+u);return i},(typeof exports!="undefined"?exports:e)[t]=i,typeof exports!="undefined"&&typeof module!="undefined"&&module.exports&&(module.exports=i)})(this); | ||
!function(t){var e,i,o,l,d,a;l=/[aeiou]$/i,i=/[bcdfghjklmnpqrstvwxyz]$/i,e=t.localPasswordGeneratorLibraryName||"generatePassword",o=function(e,r,t,o){var n,a,s="",u=[];if(null==e&&(e=10),null==r&&(r=!0),null==t&&(t=/\w/),null==o&&(o=""),!r){for(a=33;a<126;a+=1)(s=String.fromCharCode(a)).match(t)&&u.push(s);if(!u.length)throw new Error("Could not find characters that match the password pattern "+t+". Patterns must match individual characters, not the password as a whole.")}for(;o.length<e;)s=r?(t=o.match(i)?l:i,n=d(33,126),String.fromCharCode(n)):u[d(0,u.length)],r&&(s=s.toLowerCase()),s.match(t)&&(o=""+o+s);return o},d=function(e,r){var t,o,n=new Uint8Array(r);for(t in a(n),n)if(n.hasOwnProperty(t)&&e<=(o=n[t])&&o<r)return o;return d(e,r)},a=function(e){if(t.crypto&&t.crypto.getRandomValues)t.crypto.getRandomValues(e);else if("object"==typeof t.msCrypto&&"function"==typeof t.msCrypto.getRandomValues)t.msCrypto.getRandomValues(e);else{if(module.exports!==o||"undefined"==typeof require)throw new Error("No secure random number generator available.");var r=require("crypto").randomBytes(e.length);e.set(r)}},("undefined"!=typeof exports?exports:t)[e]=o,"undefined"!=typeof exports&&"undefined"!=typeof module&&module.exports&&(module.exports=o)}(this); |
@@ -33,3 +33,3 @@ var argv = require('yargs-parser')(process.argv.slice(2)); | ||
MEMORABLE = 'memorable'; | ||
generatePassword = require('./password-generator'), | ||
generatePassword = require('./password-generator'); | ||
pattern = argv.p || null; | ||
@@ -40,3 +40,3 @@ if (argv.h) { | ||
memorable = argv.c || MEMORABLE; | ||
if (pattern) { | ||
@@ -43,0 +43,0 @@ pattern = new RegExp(pattern); |
/* | ||
* password-generator | ||
* Copyright(c) 2011-2015 Bermi Ferrer <bermi@bermilabs.com> | ||
* Copyright(c) 2011-2019 Bermi Ferrer <bermi@bermilabs.com> | ||
* MIT Licensed | ||
@@ -8,3 +8,3 @@ */ | ||
var localName, consonant, letter, password, vowel; | ||
var localName, consonant, letter, password, vowel, rand, getRandomValues; | ||
letter = /[a-z]$/i; | ||
@@ -20,3 +20,3 @@ vowel = /[aeiou]$/i; | ||
// var localPasswordGeneratorLibraryName = 'pass'; | ||
localName = root.localPasswordGeneratorLibraryName || "generatePassword", | ||
localName = root.localPasswordGeneratorLibraryName || "generatePassword"; | ||
@@ -80,3 +80,3 @@ password = function (length, memorable, pattern, prefix) { | ||
function rand(min, max) { | ||
rand = function (min, max) { | ||
var key, value, arr = new Uint8Array(max); | ||
@@ -87,3 +87,3 @@ getRandomValues(arr); | ||
value = arr[key]; | ||
if (value > min && value < max) { | ||
if (value >= min && value < max) { | ||
return value; | ||
@@ -94,6 +94,6 @@ } | ||
return rand(min, max); | ||
} | ||
}; | ||
function getRandomValues(buf) { | ||
getRandomValues = function (buf) { | ||
if (root.crypto && root.crypto.getRandomValues) { | ||
@@ -109,3 +109,3 @@ root.crypto.getRandomValues(buf); | ||
} | ||
} | ||
}; | ||
@@ -112,0 +112,0 @@ |
{ | ||
"name": "password-generator", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Memorable password generator. For the command line, Node.js and the browser.", | ||
@@ -29,8 +29,12 @@ "author": "Bermi Ferrer <bermi@bermilabs.com>", | ||
"dependencies": { | ||
"yargs-parser": "^8.0.0" | ||
"yargs-parser": "^16.0.0" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "0.2.0", | ||
"grunt": "0.3.17", | ||
"mocha": "2.2.5" | ||
"expect.js": "^0.3.1", | ||
"grunt": "^1.0.4", | ||
"grunt-contrib-concat": "^1.0.1", | ||
"grunt-contrib-jshint": "^2.1.0", | ||
"grunt-contrib-uglify": "^4.0.1", | ||
"grunt-contrib-watch": "^1.1.0", | ||
"mocha": "6.2.2" | ||
}, | ||
@@ -37,0 +41,0 @@ "scripts": { |
@@ -64,4 +64,11 @@ (function (root) { | ||
it('should include the lower ASCII characters issue #25', function () { | ||
var pass = generatePassword(100, false, /[Aa]/); | ||
expect(pass.length).to.be(100); | ||
expect(pass).to.match(/A/); | ||
expect(pass).to.match(/a/); | ||
}); | ||
}); | ||
}(this)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
24425
399
7
18
+ Addedcamelcase@5.3.1(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedyargs-parser@16.1.0(transitive)
- Removedcamelcase@4.1.0(transitive)
- Removedyargs-parser@8.1.0(transitive)
Updatedyargs-parser@^16.0.0