Code Monkey home page Code Monkey logo

simple-password-generator's Introduction

simple-password-generator

npm Codacy Badge Maintainability Test Coverage AppVeyor Snyk Vulnerabilities for GitHub Repo

Makes generating simple or complex, appropriate passwords a breeze.

  • Passwords can have a minimum or maximum length.

  • Passwords can include words, letters, numbers, and symbols.

  • Passwords are scanned with zxcvbn-typescript to reduce their guessability.

  • Passwords are translated with unleet, and scanned using badwords to make sure they are appropriate.

Installation

npm install @cityssm/simple-password-generator

Usage

import { generatePassword } from "@cityssm/simple-password-generator";

generatePassword();
= "carPoetDRIVING%38"

generatePassword({ minLength: 15, pattern: "wnWnX" });
= "curious6COMPOSITION7B"

generatePassword({ pattern: 'xxxXXXnnns', doShufflePattern: true });
= "c0O4WG@od9"

Options

Option Description Default
minLength The minimum password length. 8
maxLength The maximum password length. 50
pattern The format the password should use. "wCnn"
doShufflePattern Whether the pattern should be ordered randomly or not. false
minScore The minimum allowable zxcvbn guessability score, where 0 is "too guessable" and 4 is "very unguessable" 2
retries The number of times the generator should try to generate a password before failing and returning null. 20

Note that if your pattern cannot generate a password within your set minLength and maxLength, the generatePassword() function may return a null value.

Pattern Options

Pattern Character Description Example
w Lower case word word
W Upper case word WORD
C Capitalized word Word
x Lower case letter a
X Upper case letter A
n Number 9
s Symbol @

simple-password-generator's People

Contributors

codacy-badger avatar dangowans avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

simple-password-generator's Issues

Cannot find module 'cuss/index.json'.

A lot of problems occur after the installation of the latest release.

TS2732: Cannot find module 'cuss/index.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.
3 | import { generatePasswordFromPattern } from "./passwordGenerator";
4 | import { unleet } from "@cityssm/unleet";

5 | import * as cussWordsObject from "cuss/index.json";
| ^^^^^^^^^^^^^^^^^
6 |
7 |
8 | /*

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:46:1
TS2322: Type 'null' is not assignable to type 'string[]'.
44 | });
45 |

46 | cussWordsUnfiltered = null;
| ^^^^^^^^^^^^^^^^^^^
47 |
48 |
49 | const _hasCussWord = (unleetedString: string) => {

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:90:39
TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
Type 'undefined' is not assignable to type 'number'.
88 | const generateOptions = Object.assign({}, defaultGenerateOptions, userGenerateOptions);
89 |

90 | generateOptions.minScore = Math.min(generateOptions.minScore, 4);
| ^^^^^^^^^^^^^^^^^^^^^^^^
91 |
92 | let passwordPattern = generateOptions.pattern;
93 |

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:96:37
TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
94 | // Shuffle the pattern if necessary
95 | if (generateOptions.doShufflePattern) {

96 | passwordPattern = shuffleString(passwordPattern);
| ^^^^^^^^^^^^^^^
97 | }
98 |
99 | let retries = generateOptions.retries;

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:102:10
TS2532: Object is possibly 'undefined'.
100 |
101 | // Loop through retries

102 | while (retries > 0) {
| ^^^^^^^
103 |
104 | const potentialPassword = generatePasswordFromPattern(passwordPattern);
105 |

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:104:59
TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
102 | while (retries > 0) {
103 |

104 | const potentialPassword = generatePasswordFromPattern(passwordPattern);
| ^^^^^^^^^^^^^^^
105 |
106 | // Check length, check for potential cuss words
107 | if (potentialPassword.length >= generateOptions.minLength &&

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:107:37
TS2532: Object is possibly 'undefined'.
105 |
106 | // Check length, check for potential cuss words

107 | if (potentialPassword.length >= generateOptions.minLength &&
| ^^^^^^^^^^^^^^^^^^^^^^^^^
108 | potentialPassword.length <= generateOptions.maxLength &&
109 | zxcvbn(potentialPassword).score >= generateOptions.minScore &&
110 | !hasCussWord(potentialPassword)) {

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:108:35
TS2532: Object is possibly 'undefined'.
106 | // Check length, check for potential cuss words
107 | if (potentialPassword.length >= generateOptions.minLength &&

108 | potentialPassword.length <= generateOptions.maxLength &&
| ^^^^^^^^^^^^^^^^^^^^^^^^^
109 | zxcvbn(potentialPassword).score >= generateOptions.minScore &&
110 | !hasCussWord(potentialPassword)) {
111 |

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:109:7
TS2349: This expression is not callable.
Type '{ default: (password: string, userInputs?: string[] | undefined) => ZXCVBNResult; }' has no call signatures.
107 | if (potentialPassword.length >= generateOptions.minLength &&
108 | potentialPassword.length <= generateOptions.maxLength &&

109 | zxcvbn(potentialPassword).score >= generateOptions.minScore &&
| ^^^^^^
110 | !hasCussWord(potentialPassword)) {
111 |
112 | return potentialPassword;

ERROR in node_modules/@cityssm/simple-password-generator/index.ts:115:5
TS2532: Object is possibly 'undefined'.
113 | }
114 |

115 | retries -= 1;
| ^^^^^^^
116 | }
117 |
118 | return null;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.