# password-strength-verification

> password strength verification funciton

Latest version **0.0.6** (published 2019-11-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install password-strength-verification
pnpm add password-strength-verification
yarn add password-strength-verification
bun add password-strength-verification
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2019-11-01 |
| First published | 2019-10-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dulianqiang |
| Maintainers | dulianqiang |

## Links

- npm: https://www.npmjs.com/package/password-strength-verification
- Repository: https://github.com/wildcn/password-strength-verification
- Homepage: https://github.com/wildcn/password-strength-verification#readme
- Issues: https://github.com/wildcn/password-strength-verification/issues
- npm.io page: https://npm.io/package/password-strength-verification

## Recent versions

- 0.0.6 (latest) — 2019-11-01
- 0.0.5 — 2019-11-01
- 0.0.4 — 2019-11-01
- 0.0.3 — 2019-10-31
- 0.0.2 — 2019-10-31
- 0.0.1 — 2019-10-31

## README

# Password strength verification

# how to use

```

import PasswordStrengthVerification form 'password-strength-verification';
const configs = {
  passwordFactor: {
    englishLowerCase: true,
    englishUpperCase: true,
    arabicNumber: true,
    specialSymbols: true,
  },
  passwordPolicy: {
    // 忽略大小写
    ignoreCase: true,
    minLength: 8,
    maxLength: 20,
    maxRepeatChars: null,
    // 排查以下校验
    exclusion: ['email', 'website']
  },
  language: "cn"
};
const ps = new PasswordStrength(configs);

const res = ps.validate('#$fdsafasf123');
const res = ps.validate('#$adfa');
if(res === true){
  // continue
}else{
  console.log(res)
  /*
    * { message: "缺少数字", factor: "arabicNumber", val: "adfa" }
  */
}

```

# API
## constructor(options) 
```
// options:
{
  passwordFactor: {
    englishLowerCase: true,
    englishUpperCase: true,
    arabicNumber: true,
    specialSymbols: true
  },
  passwordFactorRules: {
    englishLowerCase: 'abcdefghijklnmopqrstuvwxyz',
    englishUpperCase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    arabicNumber: '0123456789',
    specialSymbolsRules: /([@#$%^&\*?\(\)\[\]\{\}~!<>_\-\+=\|\.,:;”’`\/\\])/g,
  },
  passwordPolicy: {
    ignoreCase: true,
    minLength: 8,
    maxLength: 20,
    maxRepeatChars: null,
    // Prohibit special formats
    exclusion: ['email', 'website', 'blankSpace'],
    // Reject characters other than factor
    lockInFactor:true
  },
  language: "en"
}
```
## validate(val)
```
if(validate(val) === true){
  // continue;
}else{
  return {
    message:'error msg',
    factor:'validate factor if use',
    val
  }
}
```
## setLanguage(lang = 'en')

## mergeLanguage(lang)
```
// lang:
{
  en: {
    error: {
      invalidArguments: 'invalid valid argument',
      invalidRule: 'Missing prerequisite rule',
      unknown: 'unknown Error',
      englishLowerCase: 'Missing lowercase',
      englishUpperCase: 'Missing capital letters',
      arabicNumber: 'Missing arabic number',
      specialSymbols: 'Missing special symbol',
      blankSpace: 'Cannot contain blank space',
      maxLength: 'Maximum character limit exceeded',
      minLength: 'Minimum characters not met',
      email: 'Do not use email address',
      website: 'Do not use web address',
      outOfRange: 'Exceeded allowed character range'
    },
    word: {
      englishLowerCase: 'English small letters',
      englishUpperCase: 'Capital letters',
      arabicNumber: 'Arabic numerals',
      specialSymbols: 'Special symbols'
    }
  }
}
```
## mergeRules(rules)
```
//rules:

{
  email: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
  website: /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/,
  blankSpace: / /g,
}


```

---
_Source: https://npm.io/package/password-strength-verification · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
