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

auth-lib-jwt

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth-lib-jwt

## Overview

latest
npmnpm
Version
1.0.29
Version published
Maintainers
1
Created
Source

Authentication API Library

Overview

This is a reusable library for implementing authentication functionality in Node.js applications. It provides endpoints for user registration, login, logout, and token management (e.g., generating and refreshing access tokens).

Installation

npm i auth-lib-jwt

Endpints

"/authLibCheck";
"/login";
"/signup";
"/refresh-token";
"/getUser";
"/logout";

Usage

import express from "express";
import helmet from "helmet";
import authLib from "auth-lib-jwt";

// Initialize express app
const app = express();

// Initialize authentication library
authLib.initialize({
  // Implement your own logic for these functions
  getUser: () => ({ success: true }),
  addToken: ({}) => ({ success: true }),
  getToken: () => ({ success: true }),
  saveUser: () => ({ success: true }),
  deleteExistingToken: () => ({ success: true }),
});

// Allow BigInt to be serialized to JSON
BigInt.prototype.toJSON = function () {
  return this.toString();
};

// Middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static("public"));
app.use(helmet());

// Routes
app.use(
  "/api/Other-api-routers" // Other api routers
);
app.use("/auth", authLib.getRoutes());

// Define port
const port = process.env.PORT || 3000;

// Start server
app.listen(port, () =>
  console.log(`
🚀 Server ready at: ${port}`)
);

FAQs

Package last updated on 29 Mar 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