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

authmate-js

v1.1.3

Published

Authentication package with MongoDB, JWT, and bcrypt

Readme

🌟 authmate-js 🌟

npm version License: ISC GitHub

Secure Authentication Solution for Node.js Applications
A comprehensive and secure authentication package with MongoDB, JWT, and bcrypt for Node.js applications. This package helps you implement user authentication quickly and securely, with tokens managed internally (never exposed to clients)! 🚀


🚀 Installation

Install the package using npm or yarn:

npm install authmate-js
# or
yarn add authmate-js

📋 Prerequisites

  • MongoDB connection (local or Atlas)
  • Node.js environment
  • Set up .env file with:
    JWT_SECRET=your_jwt_secret_here
    MONGO_URI=your_mongodb_connection_string

🌟 Features

  • User registration (signup)
  • User authentication (login)
  • Secure token management (tokens never exposed to clients)
  • Password encryption with bcrypt
  • User data retrieval
  • Logout functionality
  • Database connection handling

📖 Usage/Examples

Basic Implementation

import { signup, login, getUser, allusers, logout, connectDb } from 'authmate-js';

// First connect to MongoDB
await connectDb();

// Register a new user
const signupResult = await signup('User Name', '[email protected]', 'password123');
console.log(signupResult);
// { message: "User created successfully", user: { name: "User Name", email: "[email protected]" } }

// Login with credentials
const loginResult = await login('[email protected]', 'password123');
console.log(loginResult);
// { message: "Login successful", token: "jwt_token_here" }

const token = loginResult.token;

// Get user information with token
const userResult = await getUser(token);
console.log(userResult);


// Get all users
const allUsersResult = await allusers();
console.log(allUsersResult);
// { users: [{ _id: "...", name: "User Name", email: "[email protected]" }, ...] }

// Logout user
const logoutResult = await logout(token);
console.log(logoutResult);
// { message: "Logout successful", clearCookie: "token=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0" }

signup(name, email, password)

Registers a new user.

const result = await signup('User Name', '[email protected]', 'password123');

Returns:

  • Success: { message: "User created successfully", user: { name, email } }
  • Error: { error: "Error message" }

login(email, password)

Authenticates a user and returns a JWT token.

const result = await login('[email protected]', 'password123');

Returns:

  • Success: { message: "Login successful", token: "jwt_token_here" }
  • Error: { error: "Error message" }

Tech Stack

Client: Javascript,Express,Node,Mongodb

Server: Node, Express

🚀 About Me

I'm a full-stack developer passionate about building scalable web applications. I specialize in the MERN stack and Next js And experience integrating AI into web projects. I enjoy solving complex problems, optimizing performance, and working on real-time applications. Besides coding, I actively participate in coding competitions and tech events. Always eager to learn and explore new technologies! 🚀

Appendix

Proficient in MERN Stack, TypeScript,Next js and AI-powered web applications.

Experienced in real-time applications using Socket.IO.

Skilled in database management with MongoDB, Prisma, and Appwrite.

Strong problem-solving abilities with 400+ DSA problems solved.

Active in coding competitions and university tech events. Passionate about building scalable and high-performance applications.

getUser(token)

Retrieves user information based on JWT token.

const result = await getUser('jwt_token_here');

Returns:

  • Success: { user: { _id, name, email } }
  • Error: { error: "Error message" }

allusers()

Gets a list of all users (without password information).

const result = await allusers();

Returns:

  • Success: { users: [{ _id, name, email }, ...] }
  • Error: { error: "Error message" }

logout(token)

Handles user logout.

const result = await logout('jwt_token_here');

Returns:

  • Success: { message: "Logout successful", clearCookie: "..." }
  • Error: { error: "Error message" }

verifytoken(token)

Verifies a JWT token and returns user information.

const result = await verifytoken('jwt_token_here');

Returns:

  • Success: { success: true, user: { _id, name, email } }
  • Error: { message: "Error message" }

🔧 Error Handling

All functions return objects with either success data or error information.

Success response example:

{
  message: "Login successful",
  token: "jwt_token_here"
}

Error response example:

{
  error: "Invalid credentials"
}

📄 License

ISC

👨‍💻 Author

Yogesh Tiwari


🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

🌟 Support

Give a ⭐️ if this project helped you!