npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

complete-auth-toolkit

v2.0.1

Published

A comprehensive authentication toolkit with JWT, bcrypt and more.

Readme

complete-auth-toolkit

A comprehensive authentication toolkit for Node.js, providing JWT handling, password hashing and validation, secure token generation, OTP, and more. Perfect for building secure authentication flows in your applications.

Features

  • JWT: Access/refresh token generation and verification
  • Password: Hashing, verification, random password generation, and strength validation
  • Utils: Secure token, fingerprint, and OTP generation

Installation

npm install complete-auth-toolkit

Usage

import {
  // JWT
  generateAccessToken,
  verifyAccessToken,
  generateRefreshToken,
  verifyRefreshToken,
  refreshAccessToken,
  // Password
  hashPassword,
  verifyPassword,
  generateRandomPassword,
  validatePasswordStrength,
  // Utils
  generateSecureToken,
  generateFingerprint,
  generateOtp
} from "complete-auth-toolkit";

// Example: Generate and verify a JWT
const token = generateAccessToken({ userId: 123 }, "your-secret", { expiresIn: "1h" });
const data = verifyAccessToken(token, "your-secret");
// data : {
//   success : true,
//   payload : { userId : 123 },
//   error: null
// }

// Example: Hash and verify a password
const hash = await hashPassword("myPassword123");
const result = await verifyPassword("myPassword123", hash);
// result : {
//   success: true,
//   isValid: true,
//   error: null
// }

// Example: Generate a secure random password
const randomPassword = generateRandomPassword(16);

// Example: Validate password strength
const strongPassword = 'StrongP@ssw0rd!';
const weakPassword = 'weak';
const strongResult = validatePasswordStrength(strongPassword);
const weakResult = validatePasswordStrength(weakPassword);
// strongResult: {
//   isValid: true,
//   score: 5,
//   strength: 'strong',
//   requirements: {
//     minLength: 8,
//     hasUppercase: true,
//     hasLowercase: true,
//     hasNumber: true,
//     hasSpecialChar: true,
//     isNotCommon: true
//   }
// }
// weakResult: {
//   isValid: false,
//   score: 2,
//   strength: 'weak',
//   requirements: {
//     minLength: 8,
//     hasUppercase: false,
//     hasLowercase: true,
//     hasNumber: false,
//     hasSpecialChar: false,
//     isNotCommon: true
//   }
// }

// Example: Generate a secure token
const secureToken = generateSecureToken(32);

// Example: Generate a fingerprint
const ipAddress = req.ip; // or req.headers['x-forwarded-for'] || req.connection.remoteAddress
const userAgent = req.headers['user-agent'];
const fingerprint = generateFingerprint(ipAddress, userAgent);

// Example: Generate an OTP
const otp = generateOtp(6);

API Reference

JWT

  • generateAccessToken(payload, secret, options?)
    • Returns a signed JWT access token.
  • verifyAccessToken(token, secret)
    • Verifies and decodes a JWT access token.
  • generateRefreshToken(payload, secret, options?)
    • Returns a signed JWT refresh token.
  • verifyRefreshToken(token, secret)
    • Verifies and decodes a JWT refresh token.
  • refreshAccessToken(refreshToken, secret, options?)
    • Generates a new access token from a valid refresh token.

Password

  • hashPassword(password)
    • Returns a hashed password (async).
  • verifyPassword(password, hash)
    • Verifies a password against a hash (async).
  • generateRandomPassword(length)
    • Generates a random password of specified length.
  • validatePasswordStrength(password)
    • Checks password strength, returns an object:
    • isValid (boolean): Whether the password is strong
    • score (number): Password strength score (0-5)
    • strength ("weak" | "strong"): Strength label
    • requirements (object):
      • minLength (boolean)
      • hasUppercase (boolean)
      • hasLowercase (boolean)
      • hasNumber (boolean)
      • hasSpecialChar (boolean)
      • isNotCommon (boolean)

Utils

  • generateSecureToken(length)
    • Generates a cryptographically secure random token.
  • generateFingerprint(ipAddress, userAgent)
    • Generates a unique fingerprint string based on IP address and user agent.
  • generateOtp(length)
    • Generates a numeric OTP of specified length.

Contributing

Contributions are welcome! Please open issues or pull requests for improvements or bug fixes.

License

MIT