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

mbkauthe

v4.3.3

Published

MBKTech's reusable authentication system for Node.js applications.

Readme

MBKAuthe - Node.js Authentication System

Version License Node.js Publish

MBKAuthe is a production-ready authentication system for Node.js with Express and PostgreSQL. Features include secure login, 2FA, role-based access, OAuth (GitHub & Google), multi-session support, and multi-app user management.

✨ Key Features

  • Secure password authentication (PBKDF2)
  • PostgreSQL session management
  • Multi-session support (configurable concurrent sessions per user)
  • Optional TOTP-based 2FA with trusted devices
  • OAuth login (GitHub & Google)
  • Role-based access: SuperAdmin, NormalUser, Guest
  • CSRF protection & rate limiting
  • Easy Express.js integration
  • Customizable Handlebars templates
  • Session fixation prevention
  • Dynamic profile picture routing with session caching
  • Modern responsive UI with desktop two-column layout

📦 Installation

npm install mbkauthe

🚀 Quick Start

1. Configure Environment

Copy-Item .env.example .env

See docs/env.md.

2. Set Up Database
Run docs/db.sql to create tables and a default SuperAdmin (support / 12345678). Change the password immediately. See docs/db.md.

3. Integrate with Express

import express from 'express';
import mbkauthe, { validateSession, checkRolePermission } from 'mbkauthe';
import dotenv from 'dotenv';
dotenv.config();

const app = express();
app.use(mbkauthe);

app.get('/dashboard', validateSession, (req, res) => res.send(`Welcome ${req.session.user.username}!`));
app.get('/admin', validateSession, checkRolePermission(['SuperAdmin']), (req, res) => res.send('Admin Panel'));

app.listen(3000);

🧪 Testing

npm test
npm run test:watch
npm run dev

🔧 Core API

  • Session Validation: validateSession
  • Role Check: checkRolePermission(['Role'])
  • Combined: validateSessionAndRole(['SuperAdmin', 'NormalUser'])
  • API Token Auth: authenticate(process.env.API_TOKEN)

🔐 Security

  • Rate limiting, CSRF protection, secure cookies
  • Password hashing (PBKDF2, 100k iterations)
  • PostgreSQL-backed sessions with automatic cleanup
  • OAuth with state validation and secure callbacks

📱 Two-Factor Authentication

Enable via MBKAUTH_TWO_FA_ENABLE=true. Trusted devices can skip 2FA for a set duration.

🔄 OAuth Integration

GitHub / Google OAuth: Configure apps and credentials via .env or mbkautheVar. Users must link accounts before login.

🎨 Customization

  • Redirect URL: mbkautheVar={"loginRedirectURL":"/dashboard"}
  • Custom Views: views/loginmbkauthe.handlebars, 2fa.handlebars, Error/dError.handlebars
  • Database Access: import { dblogin } from 'mbkauthe'; const result = await dblogin.query('SELECT * FROM "Users"');

🚢 Deployment

Checklist for production:

  • IS_DEPLOYED=true
  • Strong secrets for SESSION_SECRET_KEY & Main_SECRET_TOKEN
  • HTTPS enabled
  • Correct DOMAIN & COOKIE_EXPIRE_TIME
  • Use environment variables for all secrets

Vercel: Supports shared OAuth credentials via mbkauthShared.

📚 Documentation

📝 License

GPL v2.0 — see LICENSE

👨‍💻 Author

Muhammad Bin Khalid
📧 [email protected] | [email protected]
🔗 GitHub @MIbnEKhalid

🔗 Links


Made with ❤️ by MBKTech.org