new license file version [CI SKIP]

This commit is contained in:
Philipp Dormann 2023-03-15 14:05:18 +00:00
parent 3ea7a015a9
commit d0fe6a2e85
19 changed files with 1110 additions and 2 deletions

View File

@ -0,0 +1 @@
{"version":3,"file":"es.js","sources":["../index.js"],"sourcesContent":["const defaultOptions = [\r\n {\r\n id: 0,\r\n value: \"Too weak\",\r\n minDiversity: 0,\r\n minLength: 0\r\n },\r\n {\r\n id: 1,\r\n value: \"Weak\",\r\n minDiversity: 2,\r\n minLength: 6\r\n },\r\n {\r\n id: 2,\r\n value: \"Medium\",\r\n minDiversity: 4,\r\n minLength: 8\r\n },\r\n {\r\n id: 3,\r\n value: \"Strong\",\r\n minDiversity: 4,\r\n minLength: 10\r\n }\r\n]\r\n\r\nconst passwordStrength = (password, options = defaultOptions, allowedSymbols=\"!\\\"#\\$%&'\\(\\)\\*\\+,-\\./:;<=>\\?@\\[\\\\\\\\\\\\]\\^_`\\{|\\}~\") => {\r\n \r\n let passwordCopy = password || ''\r\n\r\n options[0].minDiversity = 0,\r\n options[0].minLength = 0\r\n\r\n const rules = [\r\n {\r\n regex: \"[a-z]\",\r\n message: 'lowercase'\r\n },\r\n {\r\n regex: '[A-Z]',\r\n message: 'uppercase'\r\n },\r\n {\r\n regex: '[0-9]',\r\n message: 'number'\r\n },\r\n ]\r\n\r\n if (allowedSymbols) {\r\n rules.push({\r\n regex: `[${allowedSymbols}]`,\r\n message: 'symbol'\r\n })\r\n }\r\n\r\n let strength = {}\r\n\r\n strength.contains = rules\r\n .filter(rule => new RegExp(`${rule.regex}`).test(passwordCopy))\r\n .map(rule => rule.message)\r\n\r\n strength.length = passwordCopy.length;\r\n\r\n let fulfilledOptions = options\r\n .filter(option => strength.contains.length >= option.minDiversity)\r\n .filter(option => strength.length >= option.minLength)\r\n .sort((o1, o2) => o2.id - o1.id)\r\n .map(option => ({id: option.id, value: option.value}))\r\n\r\n Object.assign(strength, fulfilledOptions[0])\r\n\r\n return strength;\r\n};\r\n\r\nmodule.exports = {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performs a Codacy security scan
# and integrates the results with the
# GitHub Advanced Security code scanning feature. For more information on
# the Codacy security scan action usage and parameters, see
# https://github.com/codacy/codacy-analysis-cli-action.
# For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli.
name: Codacy Security Scan
on:
push:
branches: [ master, releases/* ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '21 11 * * 2'
jobs:
codacy-security-scan:
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v2
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@1.1.0
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif

View File

@ -0,0 +1,20 @@
import pkg from './package.json';
export default [
{
input: 'index.js',
output: [
{
file: pkg.browser,
format: 'umd',
name: 'chyme',
sourcemap: true
},
{
file: pkg.module,
format: 'es',
sourcemap: true
}
]
}
];

View File

@ -0,0 +1,68 @@
import { expectType } from "tsd";
import { DiversityType, passwordStrength } from "./index";
// Test result types
expectType<string>(passwordStrength("asdfasdf").value);
expectType<number>(passwordStrength("asdfasdf").id);
expectType<number>(passwordStrength("asdfasdf").length);
expectType<DiversityType[]>(passwordStrength("asdfasdf").contains);
// Test options with custom value (string)
expectType<string>(
passwordStrength("asdfasdf", [
{
id: 0,
value: "Too weak",
minDiversity: 0,
minLength: 0,
},
{
id: 1,
value: "Weak",
minDiversity: 2,
minLength: 6,
},
{
id: 2,
value: "Medium",
minDiversity: 4,
minLength: 8,
},
{
id: 3,
value: "Strong",
minDiversity: 4,
minLength: 10,
},
]).value
);
// Test options with custom value (object)
expectType<{ message: string, color: string }>(
passwordStrength("asdfasdf", [
{
id: 0,
value: {message: "Too weak", color: "red"},
minDiversity: 0,
minLength: 0,
},
{
id: 1,
value: {message: "Weak", color: "orange"},
minDiversity: 2,
minLength: 6,
},
{
id: 2,
value: {message: "Medium", color: "yellow"},
minDiversity: 4,
minLength: 8,
},
{
id: 3,
value: {message: "Strong", color: "green"},
minDiversity: 4,
minLength: 10,
},
]).value
);

View File

@ -0,0 +1,48 @@
{
"name": "check-password-strength",
"version": "2.0.7",
"description": "A NPM Password strength checker based from Javascript RegExp. Check passphrase if it's \"Too weak\", \"Weak\", \"Medium\" or \"Strong\"",
"main": "index.js",
"browser": "dist/umd.js",
"module": "dist/es.js",
"types": "index.d.ts",
"scripts": {
"build": "rollup -c",
"test": "jest",
"test:types": "tsd"
},
"repository": {
"type": "git",
"url": "git+https://github.com/deanilvincent/check-password-strength.git"
},
"keywords": [
"npm",
"password",
"strength",
"checker",
"check password strength",
"password strength checker",
"strength checker",
"password checker",
"password checker strength",
"strength password checker",
"check-password-strength",
"password-strength-checker",
"strength-checker",
"password-checker",
"password-checker-strength",
"strength-password-checker",
"pass-strength"
],
"author": "deanilvincent",
"license": "MIT",
"bugs": {
"url": "https://github.com/deanilvincent/check-password-strength/issues"
},
"homepage": "https://github.com/deanilvincent/check-password-strength#readme",
"devDependencies": {
"jest": "^26.4.2",
"rollup": "^2.77.0",
"tsd": "^0.14.0"
}
}

View File

@ -0,0 +1,22 @@
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
- releases/*
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
npm test
displayName: 'npm install and test'

View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpenAPI = void 0;
exports.OpenAPI = {
BASE: '',
VERSION: '0.14.0',
WITH_CREDENTIALS: false,
TOKEN: undefined,
USERNAME: undefined,
PASSWORD: undefined,
HEADERS: undefined,
};

View File

@ -0,0 +1 @@
{"name":"check-password-strength","version":"2.0.7","files":{"LICENSE.md":{"checkedAt":1678889113301,"integrity":"sha512-VqUVGe5gNe6lHbf6vQlrglCD3yHXeW/WGgJBcdrZ4YtPEZ3Sq/w1k6/rMPyQ37/Wq4/hfA8ljsFLRi6INnGN/g==","mode":420,"size":1097},".travis.yml":{"checkedAt":1678889113301,"integrity":"sha512-A/mMgoUpZ2zMgWjlq52EVnyxATfwM3PEbIdM3dujKBHRCalNEKu0rI0YV+F/2BX+XtS1fOsbGAQUmdY4NoTA+A==","mode":420,"size":41},"dist/es.js":{"checkedAt":1678889113300,"integrity":"sha512-6DE0rqS2y++vzS32+uvBzfqsuRuVIaiXqCUDWwWHFB+EigZIgFLKoBkXhBpeD4PfasskBO8ivUFlDXTkmsICvA==","mode":420,"size":1589},"index.js":{"checkedAt":1678889113301,"integrity":"sha512-l0UWsxSks3GIfoKpoKsVfdFBuE1Jv/QI86d23YRkWeqpN6X7LelkvCMOs3gdYJWlWuWTWTWzwRSYfvkuaWJQQQ==","mode":420,"size":1547},"index.test.js":{"checkedAt":1678889113301,"integrity":"sha512-+DNktajWOi93jla9dYdXRYz+Xji2o74RPFhhyml9UvfO8OnuJT9imKR+2qZityErntgBLP1BlEdMsIgfonqi1w==","mode":420,"size":13270},"rollup.config.js":{"checkedAt":1678889113301,"integrity":"sha512-MLFTq2547grcMy1L1IrAcN9iegfh8Y2S6NdeEjXUnfMp/Xs6yi4pBSK5fobmOarHTuvkMY96BdjDXDeaMwjdzw==","mode":420,"size":280},"dist/es.js.map":{"checkedAt":1678889113301,"integrity":"sha512-Cu1Ezu7irLBsUxaA05V0mixehmNYNgmfb8BGntBpyZi1ilG42TcTRYHC14h1P4U0+uxUXCZhokB2Sr2hMj3ltw==","mode":420,"size":3867},"package.json":{"checkedAt":1678889113301,"integrity":"sha512-NpAJqDlTDXOT8z419pt2zV9FGj/BTk8jU+KNaCkN+CrYvep9BqKeGMaRD0m/A6QO4sOjJg6uUtmt6zlu5EPqSg==","mode":420,"size":1353},"dist/umd.js":{"checkedAt":1678889113301,"integrity":"sha512-htBHZPnKsY10UAOzckkIo6ENf5SvYdI1hmby8ofKGYOx1biExxV5H2CNGIw66/mjWORZdRkxZTemPklU9JTlDQ==","mode":420,"size":1859},"dist/umd.js.map":{"checkedAt":1678889113303,"integrity":"sha512-cWU3RJM2WWqsUqk57fHfiAXmVE7XJktVTqGmC5yNImURVdl0yJoXzXihtI13d0XSPhUsC9lp9i9S745pO0TbSw==","mode":420,"size":3879},"README.md":{"checkedAt":1678889113303,"integrity":"sha512-ikko+p8xFvjT1I4E/dV9/hnib603h5+eetyKyoQnIevadSFXWIGedzr0m0HckqRazzqbjHEdyxP+JZy3t+JLeA==","mode":420,"size":7928},"index.d.ts":{"checkedAt":1678889113303,"integrity":"sha512-1GHeFi+GOpCUykLA7h4+hvmKgQGPlQOUSjOodANJ4gH+/uw3YPCGixKGcxKzLxTtonUlB5jV5AwNDIC5L36G4A==","mode":420,"size":644},"index.test-d.ts":{"checkedAt":1678889113303,"integrity":"sha512-MxqEDRwckvBDX6gP6luNlRrQk4wZdHYrm/mGyyBseF1zP1FrFezCb3DLMou9CNKZvQXY4NwMhw4z48nvtXneVA==","mode":420,"size":1513},"azure-pipelines.yml":{"checkedAt":1678889113304,"integrity":"sha512-RU6GklNtAAoveFPKcrvQCKkJNvmjaTfomdXw99mlHCJ2nIuSc1rm7U36KnO7l7nCTKaOqayhWMVIyLbul0JZvQ==","mode":420,"size":458},".github/workflows/codacy-analysis.yml":{"checkedAt":1678889113304,"integrity":"sha512-JbnO1GiKsXrRilYqOK0Ox5vWtugpn7RBq/bI3Nj3t4wH1jd1ZH8UmaZhOUQgU7rXD/4Ei+5Nz4cYhQ9bFe8t6Q==","mode":420,"size":1965}}}

View File

@ -0,0 +1 @@
{"version":3,"file":"umd.js","sources":["../index.js"],"sourcesContent":["const defaultOptions = [\r\n {\r\n id: 0,\r\n value: \"Too weak\",\r\n minDiversity: 0,\r\n minLength: 0\r\n },\r\n {\r\n id: 1,\r\n value: \"Weak\",\r\n minDiversity: 2,\r\n minLength: 6\r\n },\r\n {\r\n id: 2,\r\n value: \"Medium\",\r\n minDiversity: 4,\r\n minLength: 8\r\n },\r\n {\r\n id: 3,\r\n value: \"Strong\",\r\n minDiversity: 4,\r\n minLength: 10\r\n }\r\n]\r\n\r\nconst passwordStrength = (password, options = defaultOptions, allowedSymbols=\"!\\\"#\\$%&'\\(\\)\\*\\+,-\\./:;<=>\\?@\\[\\\\\\\\\\\\]\\^_`\\{|\\}~\") => {\r\n \r\n let passwordCopy = password || ''\r\n\r\n options[0].minDiversity = 0,\r\n options[0].minLength = 0\r\n\r\n const rules = [\r\n {\r\n regex: \"[a-z]\",\r\n message: 'lowercase'\r\n },\r\n {\r\n regex: '[A-Z]',\r\n message: 'uppercase'\r\n },\r\n {\r\n regex: '[0-9]',\r\n message: 'number'\r\n },\r\n ]\r\n\r\n if (allowedSymbols) {\r\n rules.push({\r\n regex: `[${allowedSymbols}]`,\r\n message: 'symbol'\r\n })\r\n }\r\n\r\n let strength = {}\r\n\r\n strength.contains = rules\r\n .filter(rule => new RegExp(`${rule.regex}`).test(passwordCopy))\r\n .map(rule => rule.message)\r\n\r\n strength.length = passwordCopy.length;\r\n\r\n let fulfilledOptions = options\r\n .filter(option => strength.contains.length >= option.minDiversity)\r\n .filter(option => strength.length >= option.minLength)\r\n .sort((o1, o2) => o2.id - o1.id)\r\n .map(option => ({id: option.id, value: option.value}))\r\n\r\n Object.assign(strength, fulfilledOptions[0])\r\n\r\n return strength;\r\n};\r\n\r\nmodule.exports = { passwordStrength, defaultOptions }"],"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&& define.amd ? define(factory) :
factory();
})((function () { 'use strict';
const defaultOptions = [
{
id: 0,
value: "Too weak",
minDiversity: 0,
minLength: 0
},
{
id: 1,
value: "Weak",
minDiversity: 2,
minLength: 6
},
{
id: 2,
value: "Medium",
minDiversity: 4,
minLength: 8
},
{
id: 3,
value: "Strong",
minDiversity: 4,
minLength: 10
}
];
const passwordStrength = (password, options = defaultOptions, allowedSymbols="!\"#\$%&'\(\)\*\+,-\./:;<=>\?@\[\\\\\\]\^_`\{|\}~") => {
let passwordCopy = password || '';
options[0].minDiversity = 0,
options[0].minLength = 0;
const rules = [
{
regex: "[a-z]",
message: 'lowercase'
},
{
regex: '[A-Z]',
message: 'uppercase'
},
{
regex: '[0-9]',
message: 'number'
},
];
if (allowedSymbols) {
rules.push({
regex: `[${allowedSymbols}]`,
message: 'symbol'
});
}
let strength = {};
strength.contains = rules
.filter(rule => new RegExp(`${rule.regex}`).test(passwordCopy))
.map(rule => rule.message);
strength.length = passwordCopy.length;
let fulfilledOptions = options
.filter(option => strength.contains.length >= option.minDiversity)
.filter(option => strength.length >= option.minLength)
.sort((o1, o2) => o2.id - o1.id)
.map(option => ({id: option.id, value: option.value}));
Object.assign(strength, fulfilledOptions[0]);
return strength;
};
module.exports = { passwordStrength, defaultOptions };
}));
//# sourceMappingURL=umd.js.map

View File

@ -0,0 +1,192 @@
# Overview
A simple way to check that password strength of a certain passphrase. A password strength checker based from [Javascript RegEx](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).
[![Build Status](https://travis-ci.org/deanilvincent/check-password-strength.svg?branch=master)](https://travis-ci.org/deanilvincent/check-password-strength)
[![npm](https://img.shields.io/npm/dm/check-password-strength.svg)](https://img.shields.io/npm/dm/check-password-strength.svg)
[![Downloads](https://img.shields.io/npm/dt/check-password-strength.svg)](https://img.shields.io/npm/dt/check-password-strength.svg)
[DEMO 1](https://svelte.dev/repl/b5bf5871c99742e584da244b4bfeac92?version=3.44.3) by [@Ennoriel](https://github.com/Ennoriel)
[DEMO 2](https://check-password-strength.netlify.app/)
## Installation
### Install via Package Manager
`npm i check-password-strength --save`
### Install via Browser Script Tag using [UNPKG](https://unpkg.com/)
`<script src="https://unpkg.com/check-password-strength/dist/umd.js"></script>`
## Setup & Basic Usage
```javascript
const { passwordStrength } = require('check-password-strength')
// OR
import { passwordStrength } from 'check-password-strength'
console.log(passwordStrength('asdfasdf').value)
// Too weak (It will return Too weak if the value doesn't match the RegEx conditions)
console.log(passwordStrength('asdf1234').value)
// Weak
console.log(passwordStrength('Asd1234!').value)
// Medium
console.log(passwordStrength('A@2asdF2020!!*').value)
// Strong
```
## Migration from 1.x.x to 2.0.0
```javascript
// 1.x.x
const whateEverYourFunctionNameWasBefore = require("./index");
// 'contains' attribute of the response object format was
response.contains = [{'message': 'lowercase'}, ...]
```
```javascript
// 2.0.0
const { passwordStrength : whateEverYourFunctionNameWasBefore } = require("./index");
// 'contains' attribute of the response object format is now
response.contains = ['lowercase', ...]
```
## Additional Info
### Object Result
| Property | Desc. |
| -------- | --------------------------------------------------------------- |
| id | **0** = Too weak, **1** = Weak & **2** = Medium, **3** = Strong |
| value | Too weak, Weak, Medium & Strong |
| contains | lowercase, uppercase, symbol and/or number |
| length | length of the password |
### Password Length Default Options
| Name | Mininum Diversity | Mininum Length |
| -------- | ----------------- | -------------- |
| Too weak | 0 | 0 |
| Weak | 2 | 6 |
| Medium | 4 | 8 |
| Strong | 4 | 10 |
```javascript
console.log(passwordStrength('@Sdfasd2020!@#$'))
// output
{
"id": 1,
"value": "Strong",
"contains": ['lowercase', 'uppercase', 'symbol', 'number'],
"length": 15
}
```
### Default Options
The default symbols are based from **Password Special Characters [OWASP](https://owasp.org/www-community/password-special-characters)** list (except for the space)
```
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
```
Thanks for [jlherren](https://github.com/jlherren) & [Ennoriel](https://github.com/Ennoriel) for this suggestion! 👨🏻‍💻👨🏻‍💻
The default options can be required:
```javascript
const { defaultOptions } = require("./index");
```
default options:
```javascript
[
{
id: 0,
value: "Too weak",
minDiversity: 0,
minLength: 0
},
{
id: 1,
value: "Weak",
minDiversity: 2,
minLength: 6
},
{
id: 2,
value: "Medium",
minDiversity: 4,
minLength: 8
},
{
id: 3,
value: "Strong",
minDiversity: 4,
minLength: 10
}
]
```
To override the default options, simply pass your custom array as the second argument:
- id: correspond to the return id attribute.
- value: correspond to the return value attribute.
- minDiversity: between 0 and 4, correspond to the minimum of different criterias ('lowercase', 'uppercase', 'symbol', 'number') that should be met to pass the password strength
- minLength: minimum length of the password that should be met to pass the password strength
The `minDiversity` and `minLength` parameters of the first element cannot be overriden (set to 0 at the beginning of the method). Therefore, the first element should always correspond to a "too weak" option.
```javascript
passwordStrength('myPassword', yourCustomOptions)
```
### RegEx
**Strong**
```
^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*"'()+,-./:;<=>?[\]^_`{|}~])(?=.{10,})
```
**Medium Password RegEx used:**
```
^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*"'()+,-./:;<=>?[\]^_`{|}~])(?=.{8,})
```
| RegEx | Desc. |
| ----------------------------------------- | ------------------------------------------------------------------- |
| ^ | The password string will start this way |
| (?=.*[a-z]) | The string must contain at least 1 lowercase alphabetical character |
| (?=.*[A-Z]) | The string must contain at least 1 uppercase alphabetical character |
| (?=.*[0-9]) | The string must contain at least 1 numeric character |
| (?=.[!"#$%&'()*+,-./:;<=>?@[\\]^_`{\|}~])) | The string must contain at least one special character |
| (?=.{10,}) | The string must be eight characters or longer for Strong strength |
| (?=.{8,}) | The string must be eight characters or longer for Medium strength |
| (?=.{6,}) | Mininum of 6 characters for Weak strength |
## TypeScript type declarations &#9745;
Available starting version `v2.0.3` and above. (Thanks to [@Mesoptier!](https://github.com/Mesoptier))
## Other resources
##### For .NET Project
If you're working with .net core project, I've created a simple nuget package with same RegEx strings to validate a password strength.
You can easily install via Nuget Package Manager or .NET CLI ([Check.Password.Strength](https://github.com/deanilvincent/Check.Password.Strength)). This package uses Regular Expression `new Regex()` derives from `System.Text.RegularExpressions`. You can use this especially if you want to validate the passcode strength on backend services or web apis of your project.
##### Other NPM RegEx validator
I also made another NPM package ([hey-regex](https://www.npmjs.com/package/hey-regex)) that checks common inputs like numbers (whole number and decimal), alpha numeric, email and url. This package only returns `true` or `false` based from the selected function (with RegEx `.test()` inside).
Reference [blog](https://www.thepolyglotdeveloper.com/2015/05/use-regex-to-test-password-strength-in-javascript/).
### Contribute
Feel free to clone or fork this project: `https://github.com/deanilvincent/check-password-strength.git`
Contributions & pull requests are welcome!
I'll be glad if you give this project a ★ on [Github](https://github.com/deanilvincent/check-password-strength) :)
***
Kudos to [@Ennoriel](https://github.com/Ennoriel) and his efforts for making v2.x.x possible!
### License
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/deanilvincent/check-password-strength/blob/master/LICENSE.md/) file for details.

View File

@ -0,0 +1,76 @@
const defaultOptions = [
{
id: 0,
value: "Too weak",
minDiversity: 0,
minLength: 0
},
{
id: 1,
value: "Weak",
minDiversity: 2,
minLength: 6
},
{
id: 2,
value: "Medium",
minDiversity: 4,
minLength: 8
},
{
id: 3,
value: "Strong",
minDiversity: 4,
minLength: 10
}
]
const passwordStrength = (password, options = defaultOptions, allowedSymbols="!\"#\$%&'\(\)\*\+,-\./:;<=>\?@\[\\\\\\]\^_`\{|\}~") => {
let passwordCopy = password || ''
options[0].minDiversity = 0,
options[0].minLength = 0
const rules = [
{
regex: "[a-z]",
message: 'lowercase'
},
{
regex: '[A-Z]',
message: 'uppercase'
},
{
regex: '[0-9]',
message: 'number'
},
]
if (allowedSymbols) {
rules.push({
regex: `[${allowedSymbols}]`,
message: 'symbol'
})
}
let strength = {}
strength.contains = rules
.filter(rule => new RegExp(`${rule.regex}`).test(passwordCopy))
.map(rule => rule.message)
strength.length = passwordCopy.length;
let fulfilledOptions = options
.filter(option => strength.contains.length >= option.minDiversity)
.filter(option => strength.length >= option.minLength)
.sort((o1, o2) => o2.id - o1.id)
.map(option => ({id: option.id, value: option.value}))
Object.assign(strength, fulfilledOptions[0])
return strength;
};
module.exports = { passwordStrength, defaultOptions }

View File

@ -0,0 +1,30 @@
export interface Option<V> {
id: number;
value: V;
minDiversity: number;
minLength: number;
}
export interface FirstOption<V> extends Option<V> {
minDiversity: 0;
minLength: 0;
}
export type Options<V> = [FirstOption<V>, ...Option<V>[]];
export const defaultOptions: Options<string>;
export type DiversityType = "lowercase" | "uppercase" | "symbol" | "number";
export interface Result<V> {
id: number;
value: V;
contains: DiversityType[];
length: number;
}
export function passwordStrength<V = string>(
password: string,
options?: Options<V>,
allowedSymbols?: string,
): Result<V>;

View File

@ -0,0 +1,77 @@
const defaultOptions = [
{
id: 0,
value: "Too weak",
minDiversity: 0,
minLength: 0
},
{
id: 1,
value: "Weak",
minDiversity: 2,
minLength: 6
},
{
id: 2,
value: "Medium",
minDiversity: 4,
minLength: 8
},
{
id: 3,
value: "Strong",
minDiversity: 4,
minLength: 10
}
];
const passwordStrength = (password, options = defaultOptions, allowedSymbols="!\"#\$%&'\(\)\*\+,-\./:;<=>\?@\[\\\\\\]\^_`\{|\}~") => {
let passwordCopy = password || '';
options[0].minDiversity = 0,
options[0].minLength = 0;
const rules = [
{
regex: "[a-z]",
message: 'lowercase'
},
{
regex: '[A-Z]',
message: 'uppercase'
},
{
regex: '[0-9]',
message: 'number'
},
];
if (allowedSymbols) {
rules.push({
regex: `[${allowedSymbols}]`,
message: 'symbol'
});
}
let strength = {};
strength.contains = rules
.filter(rule => new RegExp(`${rule.regex}`).test(passwordCopy))
.map(rule => rule.message);
strength.length = passwordCopy.length;
let fulfilledOptions = options
.filter(option => strength.contains.length >= option.minDiversity)
.filter(option => strength.length >= option.minLength)
.sort((o1, o2) => o2.id - o1.id)
.map(option => ({id: option.id, value: option.value}));
Object.assign(strength, fulfilledOptions[0]);
return strength;
};
module.exports = { passwordStrength, defaultOptions };
//# sourceMappingURL=es.js.map

View File

@ -0,0 +1,39 @@
{
"name": "@odit/lfk-client-js",
"description": "A lib to interact with https://git.odit.services/lfk/backend. Use this version for native JS applications.",
"version": "0.14.0",
"license": "CC-BY-NC-SA-4.0",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://git.odit.services/lfk/lfk-client-js"
},
"keywords": [
"odit",
"odit.services",
"lfk"
],
"author": "ODIT.Services",
"files": [
"dist",
"package.json",
"README.md"
],
"scripts": {
"build": "npm run build:prepare && npm run build:lib && npm run build:compile && npm run build:cleanup",
"build:prepare": "rimraf ./lib ./dist",
"build:lib": "openapi --input ./openapi.json --output ./lib --client fetch",
"build:compile": "tsc",
"build:cleanup": "rimraf ./lib"
},
"bugs": {
"url": "https://git.odit.services/lfk/lfk-client-js/issues"
},
"homepage": "https://git.odit.services/lfk/lfk-client-js/",
"devDependencies": {
"openapi-typescript-codegen": "0.7.0",
"rimraf": "4.1.2",
"typescript": "4.9.5"
}
}

View File

@ -0,0 +1,387 @@
const {passwordStrength: app, defaultOptions} = require("./index");
it("Should not modify the password parameter", () => {
let pwd = "Hello!"
app(pwd)
expect(pwd).toBe("Hello!")
})
it("Should return strength id 3 if password is Strong", () => {
expect(app("A@2asdF2020!!*!").id).toBe(3);
});
//#region INTRODUCE UPDATED DEFAULT SYMBOLS AND TEST EACH SYMBOL
it("Should return strength id 3 if password is Strong with these symbols: !\"#\$%&'\(\)\*\+,-\./:;<=>\?@\[\\]\^_`\{|\}~", () => {
expect(app("A20abcdefg!\"#\$%&'\(\)\*\+,-\./:;<=>\?@\[\\]\^_`\{|\}~").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: !", () => {
expect(app("A20abcdefg!").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: @", () => {
expect(app("A20abcdefg@").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: #", () => {
expect(app("A20abcdefg#").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: ^", () => {
expect(app("A20abcdefg^").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: &", () => {
expect(app("A20abcdefg&").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: *", () => {
expect(app("A20abcdefg*").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: !", () => {
expect(app("A20abcdefg!").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: \"", () => {
expect(app("A20abcdefg\"").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: '", () => {
expect(app("A20abcdefg'").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: (", () => {
expect(app("A20abcdefg(").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: )", () => {
expect(app("A20abcdefg)").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: +", () => {
expect(app("A20abcdefg+").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: ,", () => {
expect(app("A20abcdefg,").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: -", () => {
expect(app("A20abcdefg-").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: .", () => {
expect(app("A20abcdefg.").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: /", () => {
expect(app("A20abcdefg/").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: :", () => {
expect(app("A20abcdefg:").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: ;", () => {
expect(app("A20abcdefg;").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: <", () => {
expect(app("A20abcdefg>").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: =", () => {
expect(app("A20abcdefg=").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: >", () => {
expect(app("A20abcdefg>").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: ?", () => {
expect(app("A20abcdefg?").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: [", () => {
expect(app("A20abcdefg[").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: ]", () => {
expect(app("A20abcdefg]").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: \\", () => {
expect(app("A20abcdefg\\").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: \\", () => {
expect(app("A20abcdefg\\").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: ^", () => {
expect(app("A20abcdefg^").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: _", () => {
expect(app("A20abcdefg_").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: `", () => {
expect(app("A20abcdefg`").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: {", () => {
expect(app("A20abcdefg{").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: }", () => {
expect(app("A20abcdefg}").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: |", () => {
expect(app("A20abcdefg|").id).toBe(3);
});
it("Should return strength id 3 if password is Strong with symbol: ~", () => {
expect(app("A20abcdefg~").id).toBe(3);
});
//#endregion
it("Should return strength id 2 if password is Medium", () => {
expect(app("Asd1234!").id).toBe(2);
});
it("Should return strength id 1 if password is Weak", () => {
expect(app("asdf1234").id).toBe(1);
});
it("Should return strength id 1 if password has two combination of symbol + lowercase", () => {
expect(app("asdf!@#$").id).toBe(1);
});
it("Should return strength id 1 if password has two combination of symbol + uppercase", () => {
expect(app("ASDF!@#$").id).toBe(1);
});
it("Should return strength id 1 if password has two combination of symbol + numeric", () => {
expect(app("1234!@#$").id).toBe(1);
});
it("Should return strength id 0 if password is weak", () => {
expect(app("a").id).toBe(0);
});
it("Should return strength value 'Strong' if password is Medium", () => {
expect(app("A@2asdF2020!!*").value).toBe("Strong");
});
it("Should return strength value 'Medium' if password is Medium", () => {
expect(app("Asd1234!").value).toBe("Medium");
});
it("Should return strength value 'Weak' if password is Weak", () => {
expect(app("Asdf1234").value).toBe("Weak");
});
// pass combination
it("Should return strength value 'Weak' if password has two combination of symbol + lowercase", () => {
expect(app("asdf!@#$").value).toBe("Weak");
});
it("Should return strength value 'Weak' if password has two combination of symbol + uppercase", () => {
expect(app("ASDF!@#$").value).toBe("Weak");
});
it("Should return strength value 'Weak' if password has two combination of symbol + numeric", () => {
expect(app("1234!@#$").value).toBe("Weak");
});
it("Should return strength value 'Too weak' if password is weak", () => {
expect(app("a").value).toBe("Too weak");
});
it("Should return type of number if request for id", () => {
expect(typeof app("a").id).toBe("number");
});
it("Should return type of string if request for value", () => {
expect(typeof app("a").value).toBe("string");
});
it("Should return type of object if requesting directly from the function", () => {
expect(typeof app("a")).toBe("object");
});
// contains
it("Should return true if request for contains is an array", () => {
const arrayData = Array.isArray(app("a").contains);
expect(arrayData).toEqual(true);
});
it("Should return contains of 'lowercase' if the password has lowercase", () => {
const contains = app("lower").contains;
const contain = contains.find((x) => x === "lowercase");
const condition = contain === "lowercase";
expect(condition).toEqual(true);
});
it("Should return contains of 'uppercase' if the password has uppercase", () => {
const contains = app("Uppercase").contains;
const contain = contains.find((x) => x === "uppercase");
const condition = contain === "uppercase";
expect(condition).toEqual(true);
});
it("Should return contains of 'symbol' if the password has symbol", () => {
const contains = app("!test").contains;
const contain = contains.find((x) => x === "symbol");
const condition = contain === "symbol";
expect(condition).toEqual(true);
});
it("Should return contains of 'number' if the password has number", () => {
const contains = app("1234").contains;
const contain = contains.find((x) => x === "number");
const condition = contain === "number";
expect(condition).toEqual(true);
});
it("Should return contains of all criteria (lowercase, uppercase, symbol & number)", () => {
expect(app("asdfASDF!@#$1234").contains).toStrictEqual([
"lowercase",
"uppercase",
"number",
"symbol",
]);
});
it("Should return contains of two or more message if the password has 2 or more message password criteria", () => {
expect(app("asdfASDF").contains).toStrictEqual([
"lowercase",
"uppercase",
]);
});
it("Should return contains length if contains has value", () => {
expect(app("asdfASDF").contains.length).toBe(2);
});
// length
it("Should return numeric length value if request for length", () => {
expect(app("1234").length).toBe(4);
});
it("Should return type of number if request is for length value", () => {
expect(typeof app("1234").length).toBe("number");
});
it("Should return an empty password result if password parameter is null", () => {
expect(app(null).id).toBe(0);
expect(app(null).length).toBe(0);
expect(app(null).contains).toStrictEqual([]);
});
overridenOptions = [
{
id: 0,
value: "Too weak",
minDiversity: 0,
minLength: 0
},
{
id: 1,
value: "Weak",
minDiversity: 2,
minLength: 6
},
{
id: 2,
value: "Medium",
minDiversity: 3,
minLength: 8
},
{
id: 3,
value: "Strong",
minDiversity: 4,
minLength: 10
}
]
it("[overridden options] Should return strength id 0 if password is weak", () => {
expect(app("aB1$", overridenOptions).id).toBe(0);
expect(app("aB1$", overridenOptions).value).toBe("Too weak");
});
it("[overridden options] Should return strength id 1 if password is Weak", () => {
expect(app("abcde123456", overridenOptions).id).toBe(1);
expect(app("abcde123456", overridenOptions).value).toBe("Weak");
});
it("[overridden options] Should return strength id 2 if password is Medium", () => {
expect(app("abcde123456$", overridenOptions).id).toBe(2);
expect(app("abcde123456$", overridenOptions).value).toBe("Medium");
});
it("[overridden options] Should return strength id 3 if password is Strong", () => {
expect(app("abcde123456$B", overridenOptions).id).toBe(3);
expect(app("abcde123456$B", overridenOptions).value).toBe("Strong");
});
it("[overridden options] Should return true if request for contains is an array", () => {
const arrayData = Array.isArray(app("a", overridenOptions).contains);
expect(arrayData).toEqual(true);
});
it("[overridden options] Should return contains of 'lowercase' if the password has lowercase", () => {
const contains = app("lower", overridenOptions).contains;
const contain = contains.find((x) => x === "lowercase");
const condition = contain === "lowercase";
expect(condition).toEqual(true);
});
it("[overridden options] Should return contains of 'uppercase' if the password has uppercase", () => {
const contains = app("Uppercase", overridenOptions).contains;
const contain = contains.find((x) => x === "uppercase");
const condition = contain === "uppercase";
expect(condition).toEqual(true);
});
it("[overridden options] Should return contains of 'symbol' if the password has symbol", () => {
const contains = app("!test", overridenOptions).contains;
const contain = contains.find((x) => x === "symbol");
const condition = contain === "symbol";
expect(condition).toEqual(true);
});
it("[overridden options] Should return contains of 'number' if the password has number", () => {
const contains = app("1234", overridenOptions).contains;
const contain = contains.find((x) => x === "number");
const condition = contain === "number";
expect(condition).toEqual(true);
});
it("[overridden options] Should return the same object with the default option", () => {
expect(app("abcd@")).toStrictEqual(app('abdc@', defaultOptions))
expect(app("abcd@E")).toStrictEqual(app('abdc@E', defaultOptions))
expect(app("abcd@3")).toStrictEqual(app('abdc@3', defaultOptions))
expect(app(null)).toStrictEqual(app(null, defaultOptions))
});
it("[overridden allowedSymbols] Should not contains symbols if the password does not have one", () => {
const contains = app("abcd@", undefined, '$').contains;
expect(contains).toEqual(expect.arrayContaining(['lowercase']));
expect(contains).toEqual(expect.not.arrayContaining(['uppercase']));
expect(contains).toEqual(expect.not.arrayContaining(['number']));
expect(contains).toEqual(expect.not.arrayContaining(['symbol']));
});
it("[overridden allowedSymbols] Should contains symbols if the password have one", () => {
const contains = app("abcd@Ê", undefined, 'Ê').contains;
expect(contains).toEqual(expect.arrayContaining(['lowercase']));
expect(contains).toEqual(expect.not.arrayContaining(['uppercase']));
expect(contains).toEqual(expect.not.arrayContaining(['number']));
expect(contains).toEqual(expect.arrayContaining(['symbol']));
});

File diff suppressed because one or more lines are too long