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

login-auth-services

v2.4.2

Published

Authentication services for Google, GitHub, Microsoft, okta and multi-factor authentication using OTP.

Readme

Login Auth Services

npm license

Login Auth Services is a robust authentication package supporting multiple OAuth providers (Google, GitHub, Microsoft, and Okta) with multi-factor authentication (OTP). It also includes a sync-db command to synchronize your database schema using TypeORM.

🚀 Features

  • 🔒 OAuth Authentication for:
    • Google
    • GitHub
    • Microsoft
    • Okta
  • 🔑 Multi-Factor Authentication (MFA) using One-Time Password (OTP)
  • 🛠 Database Agnostic - Works with any database supported by TypeORM
  • 🔄 Database Synchronization via sync-db command
  • 🔐 JWT-based Authentication
  • 📧 Email verification & password reset using Nodemailer
  • 📦 Easily Integrates with Express.js

📦 Installation

Install via npm:

npm install login-auth-services

or using yarn:

yarn add login-auth-services

📌 TypeORM & Database Setup

This package uses TypeORM for database interactions. You can use any relational database (MySQL, PostgreSQL, SQLite, etc.).

1️⃣ Configure database.config.ts

Create a database.config.ts file to configure TypeORM's DataSource:

import { DataSource } from "typeorm";
import dotenv from "dotenv";

dotenv.config();

export const AppDataSource = new DataSource({
  type: process.env.DATABASE_TYPE as any,
  host: process.env.DATABASE_HOST,
  port: Number(process.env.DATABASE_PORT),
  username: process.env.DATABASE_USERNAME,
  password: process.env.DATABASE_PASSWORD,
  database: process.env.DATABASE_NAME,
  synchronize: false, // Use sync-db instead
  logging: false,
  entities: ["src/entity/*.ts"],
});

AppDataSource.initialize()
  .then(() => console.log("Database connected"))
  .catch((err) => console.error("Database connection failed", err));

2️⃣ Define Entities

Entities define the database structure. Example User entity:

import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  email: string;

  @Column()
  password: string;
}

🔄 Sync Database

This package includes a sync-db command to synchronize your database schema with TypeORM entities.

Running sync-db

Run the following command to apply migrations and synchronize the database:

npx sync-db

This will automatically update the database schema based on TypeORM entities. Ensure synchronize is disabled in database.config.ts to avoid conflicts.


🔑 Authentication Usage

Google OAuth Login

import { GoogleAuthService } from "login-auth-services";

const googleAuth = new GoogleAuthService({
  clientId: "your-client-id",
  clientSecret: "your-client-secret",
  redirectUri: "your-redirect-uri",
});

app.get("/auth/google", async (req, res) => {
  const url = googleAuth.getAuthUrl();
  res.redirect(url);
});

app.get("/auth/google/callback", async (req, res) => {
  const token = await googleAuth.getAccessToken(req.query.code);
  res.json(token);
});

GitHub OAuth Login

import { GitHubAuthService } from "login-auth-services";

const githubAuth = new GitHubAuthService({
  clientId: "your-client-id",
  clientSecret: "your-client-secret",
  redirectUri: "your-redirect-uri",
});

app.get("/auth/github", async (req, res) => {
  const url = githubAuth.getAuthUrl();
  res.redirect(url);
});

app.get("/auth/github/callback", async (req, res) => {
  const token = await githubAuth.getAccessToken(req.query.code);
  res.json(token);
});

📧 Email Verification & Password Reset

Send Verification Email

import { sendVerificationEmail } from "login-auth-services";

await sendVerificationEmail(user.email, user.verificationCode);

📌 Custom Login Authentication

Register User

import { registerUser } from "login-auth-services";

const user = await registerUser({
  email: "[email protected]",
  password: "securepassword",
});

Login User

import { loginUser } from "login-auth-services";

const token = await loginUser({
  email: "[email protected]",
  password: "securepassword",
});

Verify OTP for Multi-Factor Authentication

import { verifyOTP } from "login-auth-services";

const isValid = await verifyOTP({
  email: "[email protected]",
  otp: "123456",
});

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙌 Contributions

Contributions, issues, and feature requests are welcome! Feel free to fork, submit PRs, or open issues on GitHub.


📝 Author

Harshil Patel
📧 Email: [[email protected]]


This README includes TypeORM configuration, database synchronization with sync-db, and entity setup.