Skip to content

Sentinel PasswordFlexible Password Validation

Accessible, customizable password validation for JavaScript and React

Sentinel Password

Quick Start

npm install @sentinel-password/core
typescript
import { validatePassword } from '@sentinel-password/core'

const result = validatePassword('MyP@ssw0rd!', {
  minLength: 8,
  maxLength: 128,
  requireUppercase: true,
  requireLowercase: true,
  requireDigit: true,
  requireSymbol: true,
  checkCommonPasswords: true
})

if (result.valid) {
  console.log('Password is valid!')
} else {
  console.log('Suggestions:', result.feedback.suggestions)
}

React Integration

typescript
import { usePasswordValidator } from '@sentinel-password/react'

function SignupForm() {
  const { password, setPassword, result } = usePasswordValidator({
    minLength: 8,
    requireUppercase: true
  })

  return (
    <div>
      <input 
        type="password" 
        value={password} 
        onChange={(e) => setPassword(e.target.value)} 
      />
      {result && !result.valid && result.feedback.suggestions.map((suggestion, index) => (
        <p key={index}>{suggestion}</p>
      ))}
    </div>
  )
}

Ready-to-Use Components

typescript
import { PasswordInput } from '@sentinel-password/react-components'

function App() {
  return (
    <PasswordInput
      label="Create Password"
      onValidationChange={(result) => console.log(result)}
    />
  )
}

Optional: Entropy & Crack-Time Estimation

typescript
import { validatePassword } from '@sentinel-password/core'
import { estimateEntropy } from '@sentinel-password/entropy'

const rule = validatePassword(pwd)
const ent = estimateEntropy(pwd)

console.log(ent.bits)                          // ~28
console.log(ent.score)                         // 0–4 (aligns with core's StrengthScore)
console.log(ent.crackTime.offlineSlowHash.display)  // "5 hours"
console.log(ent.patterns)                      // ['l33t', 'capitalization']

The entropy package is intentionally decoupled from core. Install it only when you want a "how long would this survive a brute-force attack?" signal in addition to rule-based validity. See the Entropy API reference for details.

Released under the MIT License.