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

authify-pro2

v1.0.9

Published

This package contains different authentication methods.

Readme

Authify-Pro2

Authify-Pro2 is a comprehensive authentication package for Node.js applications. It provides a set of robust and secure authentication functionalities, including basic authentication, OTP-based authentication, and social authentication with popular platforms like GitHub, Google, Microsoft, and Okta.

Features

  • Basic authentication with secure password hashing
  • OTP (One-Time Password) generation and verification
  • Social authentication with GitHub, Google, Microsoft, and Okta
  • JWT (JSON Web Token) generation and validation
  • Customizable and extensible architecture
  • Easy integration with Express.js applications
  • TypeScript support for enhanced type safety and development experience

Installation

To install Authify-Pro2, use npm:

npm install authify-pro2

Usage

Basic Authentication

import { authBasic } from 'authify-pro2';

// Authenticate user credentials
const isAuthenticated = authBasic.authenticate(enteredPassword, storedPassword, saltValue);

OTP Authentication

import { authOTP } from 'authify-pro2';

// Generate and send OTP
const generatedOTP = await authOTP.generateAndSendOTP(emailAddress);

// Validate OTP
const isValid = authOTP.validateOTP(emailAddress, providedOTP);

Social Authentication

import { authenticateWithOAuth2 } from 'authify-pro2';

// Configuration for extracting user profile
const config = {
  getUserProfile: (profile: any) => ({
    name: profile.name,
    email: profile.email,
    // ...
  }),
};

// Authenticate with OAuth2 provider
const { userProfile, accessTokenValue } = await authenticateWithOAuth2(code, config, providerName);

JWT Tokens

import { tokenHelper } from 'authify-pro2';

// Generate JWT token
const token = tokenHelper.createToken(payload, expiresInSeconds);

// Validate JWT token
const decodedToken = tokenHelper.validateToken(token);

Hashing and Validation

import { hashHelper, validationHelper } from 'authify-pro2';

// Generate salt
const salt = hashHelper.generateSalt();

// Generate hash
const hashedValue = hashHelper.generateHash(inputValue, salt);

// Validate hash
const isValid = hashHelper.validateHash(inputValue, hashValue, salt);

// Validate email
const isValidEmail = validationHelper.isValidEmail(emailAddress);

// Validate password
const isValidPassword = validationHelper.isValidPassword(password);

Configuration

Authify-Pro2 requires the following environment variables to be set:

  • HASH_ALGORITHM: The hashing algorithm to use for password hashing (e.g., 'sha256', 'sha512').
  • JWT_SIGNING_KEY: The secret key used for signing and verifying JWT tokens.

Additionally, for social authentication, you need to provide the necessary configuration for each provider:

  • GITHUB_CLIENT_ID: Client ID for GitHub OAuth2 authentication.
  • GITHUB_CLIENT_SECRET: Client secret for GitHub OAuth2 authentication.
  • GITHUB_REDIRECT_URI: Redirect URI for GitHub OAuth2 authentication.
  • GITHUB_TOKEN_URL: Token URL for GitHub OAuth2 authentication.
  • GITHUB_USER_INFO_URL: User info URL for GitHub OAuth2 authentication.

Similar configuration variables are required for Google, Microsoft, and Okta authentication.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository.

License

This package is open-source and available under the MIT License.

Support

For any questions or support regarding Authify-Pro2, please contact us at [email protected].

Happy authenticating with Authify-Pro2!

Authify-Pro2

Authify-Pro2 is a comprehensive authentication package for Node.js applications. It provides a set of robust and secure authentication functionalities, including basic authentication, OTP-based authentication, social authentication with popular platforms like GitHub, Google, Microsoft, and Okta, and database integration using TypeORM.

Features

  • Basic authentication with secure password hashing
  • OTP (One-Time Password) generation and verification
  • Social authentication with GitHub, Google, Microsoft, and Okta
  • JWT (JSON Web Token) generation and validation
  • Database integration with TypeORM (supports MySQL, PostgreSQL, and MongoDB)
  • Automatic schema synchronization
  • Customizable and extensible architecture
  • Easy integration with Express.js applications
  • TypeScript support for enhanced type safety and development experience

Installation

To install Authify-Pro2, use npm:

npm install authify-pro2

Usage

Database Integration

Initialize the authentication service with your database configuration:

import { AuthifyService } from 'authify-pro2';

const authify = new AuthifyService({
  type: 'mysql', // or 'postgres' or 'mongodb'
  url: 'mysql://user:password@localhost:3306/dbname',
  synchronize: true // WARNING: Only use in development
});

await authify.initialize();

Basic Authentication

// Create a new user
await authify.createUser('[email protected]', 'password123');

// Validate credentials
const isValid = await authify.validateCredentials('[email protected]', 'password123');

OTP Authentication

// Generate and send OTP
const otp = await authify.generateAndSendOTP('[email protected]');

// Validate OTP
const isValid = await authify.validateOTP('[email protected]', providedOTP);

Social Authentication

// Configuration for extracting user profile
const config = {
  getUserProfile: (profile: any) => ({
    name: profile.name,
    email: profile.email,
    // ...
  }),
};

// Authenticate with OAuth2 provider
const result = await authify.handleOAuth2(code, config, 'github');

Direct Authentication Methods

You can also use the core authentication methods without database integration:

import { authBasic, authOTP, authenticateWithOAuth2, tokenHelper } from 'authify-pro2';

// Basic authentication
const isAuthenticated = authBasic.authenticate(enteredPassword, storedPassword, saltValue);

// Generate JWT token
const token = tokenHelper.createToken(payload, expiresInSeconds);

Configuration

Environment Variables

Authify-Pro2 requires the following environment variables:

Core Authentication:

  • HASH_ALGORITHM: The hashing algorithm for password hashing (e.g., 'sha256')
  • JWT_SIGNING_KEY: Secret key for JWT tokens

OAuth Providers:

  • GITHUB_CLIENT_ID: GitHub OAuth2 client ID
  • GITHUB_CLIENT_SECRET: GitHub OAuth2 client secret
  • GITHUB_REDIRECT_URI: GitHub OAuth2 redirect URI
  • GITHUB_TOKEN_URL: GitHub OAuth2 token URL
  • GITHUB_USER_INFO_URL: GitHub OAuth2 user info URL

(Similar variables needed for Google, Microsoft, and Okta)

Database Schema

When using database integration, Authify-Pro2 automatically creates the following tables:

  • users: Stores user information and credentials
  • auth_records: Stores OTP and session records
  • oauth_connections: Stores OAuth provider connections

TypeORM Integration

Supported Databases

  • MySQL/MariaDB
  • PostgreSQL
  • MongoDB

Schema Synchronization

The package supports automatic schema synchronization using TypeORM's synchronize option. Note: This should only be used during development.

const authify = new AuthifyService({
  type: 'mysql',
  url: 'mysql://user:password@localhost:3306/dbname',
  synchronize: true, // Development only
  logging: true // Optional: enables SQL query logging
});

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository.

License

This package is open-source and available under the MIT License.

Support

For any questions or support regarding Authify-Pro2, please contact us at [email protected].

Happy authenticating with Authify-Pro2!