cracklibjs
TypeScript icon, indicating that this package has built-in type declarations

4.0.16 • Public • Published

cracklibjs

Pure JS Cracklib-inspired library for Node.

npm version CircleCI codecov Known Vulnerabilities

Donate


Installation

npm i cracklibjs

Usage

import cracklib from 'cracklibjs'
// if you're using `require`, you'll need to `require('cracklibjs').default`

const pw = process.argv[2] // or something

// Init with options. The wordlist is parsed here, so future calls
// don't have to do all that work again.
// `check: (word: string) => PasswordValidationError | string (word)`
const check = cracklib() // cracklib(options)
// The `options` param is optional.
// type Options = {
//   dict: string = '/usr/share/dict/words'; path to dictionary file
//   minLength: number = 8; minimum password length
//   loose: bool = false; see below for loose vs strict
// }

const validate = (pw) => {
  try {
    return check(pw)
  } catch (e) {
    return e.message // example: 'Password is too short'
  }
}

The loose option, when true, disables:

  • Case-insensitive checks
  • Reversed string checks
  • md5, sha1, sha256, and sha512 checks

Questions

  • Why?
    • The npm package cracklib isn't a vanilla JS solution, has external dependencies, and may not build on all Unix-like systems and future versions of Node.
  • I have more than one word list, what should I do?
  • This seems slow!
    • Don't initialize more than once. Initialization can be slow, depending on your word list and your machine. Hopefully the actual check is fast.

LICENSE

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.0.161latest

Version History

VersionDownloads (Last 7 Days)Published
4.0.161
4.0.150
4.0.140
4.0.130
4.0.120
4.0.110
4.0.100
4.0.90
4.0.80
4.0.70
4.0.60
4.0.50
4.0.40
4.0.30
4.0.20
4.0.10
4.0.00
3.0.70
3.0.60
3.0.50
3.0.40
3.0.30
3.0.20
3.0.10
3.0.00
2.0.40
2.0.30
2.0.20
2.0.10
2.0.00
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00
0.11.10
0.11.00
0.10.40
0.10.30
0.10.20
0.10.10
0.10.00
0.9.20
0.9.10
0.9.00
0.8.00
0.7.00
0.6.00
0.5.10
0.5.00
0.4.10
0.4.00
0.3.00
0.2.20
0.2.10
0.2.00
0.1.10
0.1.00
0.0.10

Package Sidebar

Install

npm i cracklibjs

Weekly Downloads

1

Version

4.0.16

License

MIT

Unpacked Size

507 kB

Total Files

10

Last publish

Collaborators

  • zacanger