Lightweight password strength checker for seamless authentication protection
npm install pswderbash
npm install pswder
`
Usage
$3
`javascript
const { validatePassword } = require("pswder");
const result = validatePassword("My$ecure123");
console.log(result);
// Output:
// {
// strength: "Strong",
// suggestions: ["Your password is strong! No changes needed."]
// }
`
$3
`javascript
const { checkPasswordBreach } = require("pswder");
(async () => {
const result = await checkPasswordBreach("password123");
console.log(result);
// Output:
// {
// isBreached: true,
// message: "This password has been found in a breach. Avoid reusing this password for email or sensitive accounts."
// }
})();
`
API Reference
$3
Validates the strength of a password.
---
#### Parameters
- password _(string)_: The password to validate.
---
#### Returns
An object containing:
- strength _(string)_: Categorized as one of:
- Weak: Missing multiple requirements or very short.
- Moderate: Meets some requirements but lacks key security features.
- Strong: Meets all or most security requirements.
- suggestions _(array)_: A list of actionable suggestions to enhance the password's strength.
---
#### Example
`javascript
const { validatePassword } = require("pswder");
const result = validatePassword("WeakPass");
console.log(result);
// Output:
// {
// strength: "Weak",
// suggestions: [
// "Password should be at least 8 characters long.",
// "Add at least one special character (e.g., !, @, #, $).",
// "Add at least one numeric digit (e.g., 1, 2, 3)."
// ]
// }
`
---
$3
Checks if a password is present in known data breaches.
---
#### Parameters:
- password _(string)_: The password to check.
---
#### Returns
- isBreached (boolean): Whether the password has been found in a breach.
- message` (string): Details about the breach status.