Socket
Socket
Sign inDemoInstall

generate-password

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.2 to 1.5.0

6

CHANGELOG.md

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

# 1.5.0 / 2020-1-18
Add option to disable lowercase characters in generated passwords.
#### Notable Changes
- [`960858c1c`](https://github.com/brendanashworth/generate-password/commit/960858c1cc7784b259c7d403ab5e26da7f5f32c0) - Document usage of lowercase, make lowercase optional, add tests (Edgardo Carreras)
# 1.4.2 / 2019-6-16

@@ -2,0 +8,0 @@ Includes a performance improvement in the random number generator.

6

package.json
{
"name": "generate-password",
"version": "1.4.2",
"version": "1.5.0",
"description": "Easy library for generating unique passwords.",

@@ -32,5 +32,5 @@ "main": "main.js",

"codecov": "^1.0.1",
"eslint": "^2.13.1",
"eslint": "^6.5.1",
"jscover": "^1.0.0",
"mocha": "^2.0.1",
"mocha": "^7.0.0",
"mocha-lcov-reporter": "^1.2.0",

@@ -37,0 +37,0 @@ "underscore": "^1.7.0"

@@ -50,11 +50,13 @@ # Generate Password [![Build Status](https://travis-ci.org/brendanashworth/generate-password.svg?branch=master)](https://travis-ci.org/brendanashworth/generate-password) [![codecov](https://codecov.io/gh/brendanashworth/generate-password/branch/master/graph/badge.svg)](https://codecov.io/gh/brendanashworth/generate-password)

| Name | Description | Default Value |
|--------------------------|-----------------------------------------------------|---------------|
| length | Integer, length of password. | 10 |
| numbers | Boolean, put numbers in password. | false |
| symbols | Boolean, put symbols in password. | false |
| uppercase | Boolean, use uppercase letters in password. | true |
| numbers* | Boolean, put numbers in password. | false |
| symbols* | Boolean, put symbols in password. | false |
| lowercase* | Boolean, put lowercase in password | true |
| uppercase* | Boolean, use uppercase letters in password. | true |
| excludeSimilarCharacters | Boolean, exclude similar chars, like 'i' and 'l'. | false |
| exclude | String, characters to be excluded from password. | '' |
| strict | Boolean, password must include at least one character from each pool. | false |
*At least one should be true.

@@ -79,9 +79,10 @@ var crypto = require('crypto');

options = options || {};
if (!options.hasOwnProperty('length')) options.length = 10;
if (!options.hasOwnProperty('numbers')) options.numbers = false;
if (!options.hasOwnProperty('symbols')) options.symbols = false;
if (!options.hasOwnProperty('exclude')) options.exclude = '';
if (!options.hasOwnProperty('uppercase')) options.uppercase = true;
if (!options.hasOwnProperty('excludeSimilarCharacters')) options.excludeSimilarCharacters = false;
if (!options.hasOwnProperty('strict')) options.strict = false;
if (!Object.prototype.hasOwnProperty.call(options, 'length')) options.length = 10;
if (!Object.prototype.hasOwnProperty.call(options, 'numbers')) options.numbers = false;
if (!Object.prototype.hasOwnProperty.call(options, 'symbols')) options.symbols = false;
if (!Object.prototype.hasOwnProperty.call(options, 'exclude')) options.exclude = '';
if (!Object.prototype.hasOwnProperty.call(options, 'uppercase')) options.uppercase = true;
if (!Object.prototype.hasOwnProperty.call(options, 'lowercase')) options.lowercase = true;
if (!Object.prototype.hasOwnProperty.call(options, 'excludeSimilarCharacters')) options.excludeSimilarCharacters = false;
if (!Object.prototype.hasOwnProperty.call(options, 'strict')) options.strict = false;

@@ -96,4 +97,9 @@ if (options.strict) {

// Generate character pool
var pool = lowercase;
var pool = '';
// lowercase
if (options.lowercase) {
pool += lowercase;
}
// uppercase

@@ -112,2 +118,7 @@ if (options.uppercase) {

// Throw error if pool is empty.
if (!pool) {
throw new TypeError('At least one rule for pools must be true');
}
// similar characters

@@ -114,0 +125,0 @@ if (options.excludeSimilarCharacters) {

@@ -90,2 +90,23 @@ var assert = require('chai').assert,

it('should generate strict random sequence that has has no lowercase letter', function () {
var passwords = generator.generateMultiple(amountToGenerate, { length: 10, strict: true, lowercase: false });
passwords.forEach(function (password) {
assert.notMatch(password, /[a-z]/, 'password has no lowercase letters');
});
assert.equal(passwords.length, amountToGenerate);
});
it('should generate strict random sequence that has strictly at least one lowercase, one symbol, and one uppercase letter', function () {
var passwords = generator.generateMultiple(amountToGenerate, { length: 10, strict: true, uppercase: true, lowercase: true, symbols: true, numbers: true });
passwords.forEach(function (password) {
assert.match(password, /[a-z]/, 'password has a lowercase letter');
assert.match(password, /[A-Z]/, 'password has a uppercase letter');
assert.match(password, /[!@#$%^&*()+_\-=}{[\]|:;"/?.><,`~]/, 'password has a symbol');
assert.match(password, /[0-9]/, 'password has a number');
});
assert.equal(passwords.length, amountToGenerate);
});
it('should throw an error if rules don\'t correlate with length', function() {

@@ -97,2 +118,8 @@ assert.throws(function() {

it('should throw an error if no rules are applied', function() {
assert.throws(function() {
generator.generate({ length: 10, uppercase: false, lowercase: false, symbols: false, numbers: false });
}, TypeError, 'At least one rule for pools must be true');
});
it('should generate short strict passwords without stack overflow', function(){

@@ -99,0 +126,0 @@ assert.doesNotThrow(function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc