New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jwt-auths-module

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwt-auths-module

This package provides functions for managing user authentication, including password hashing, password comparison for authentication, and JWT token verification

latest
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

JWT AUTHENTICATION

This package provides functions for managing user authentication, including password hashing, password comparison for authentication, and JWT token verification

This package provides functions for managing user authentication, including:

  • password hashing
  • password comparison and token creation for authentication
  • Jwt token verification

Installing

coming soon

Usage

1. hashPassowrd

This function hash password using bcrypt

Example

const { hashPassword } = require("<package-name>");

hashPassword(password)
  .then((hashPassword) => {
    // save user info in your db with hashPassword
  })
  .catch((err) => {
    console.error(err);
  });

2. authenticateUser

This function compares a password with a hashed password and creates a JWT token if the passwords match.

Example

const { authenticateUser } = require("<package-name>");

authenticateUser(hashedPassword, myPassword, userId, mySecretKey)
  .then((token) => {
    // return the token
  })
  .catch((err) => {
    console.error(err);
  });

3. VerifyToken

This function intercepts an HTTP request and verifies the JWT token in the request headers.

Example

const express = require("express");
const { verifyJwtToken } = require("<package-name>");

const app = express();
const secretKey = "mySecretKey";

app.use(verifyJwtToken(secretKey));

app.get("/protected-route", (req, res) => {
  res.send(`Hello, user ${req.ID}`);
});

app.listen(3000, () => {
  console.log("Server started on port 3000");
});

FAQs

Package last updated on 15 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts