Code Monkey home page Code Monkey logo

ankansaha / jwt-destroy Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 108 KB

JWT-Destroy is an enhanced version of the popular JSONWebToken npm package. It extends its functionality by offering manual expiry control, allowing developers to easily manage token expiration within their applications.

Home Page: https://github.com/AnkanSaha/jwt-destroy/pkgs/npm/jwt-destroy

License: GNU General Public License v3.0

TypeScript 100.00%
destroy jsonwebtoken jwt

jwt-destroy's Introduction

JWT-Destroy: The Ultimate JWT Tool

JWT-Destroy is a powerful superset of the popular jsonwebtoken npm package. It provides seamless integration with jsonwebtoken's features, allowing you to effortlessly generate and verify tokens. Additionally, with manual token expiry capabilities, JWT-Destroy empowers you with precise control over token lifetimes.

Installation

npm install jwt-destroy@latest  # Install the latest version

Usage

const {jwt} = require('jwt-destroy');

// Register a secret key
const Operation = new jwt('secret'); // secret is the secret key by default if not provided

// Generate a token
const token = Operation.generate({id: 1, name: 'John Doe'}, '1h'); // 1h is the expiry time by default if not provided

// Generate a Login token
const token = Operation.generateLoginToken({id: 1, name: 'John Doe'}, 5, '1h'); // 1h is the expiry time by default if not provided

// Verify a token
const payload = Operation.decode(token); // Returns the payload if the token is valid, else returns a object with error message

// Destroy a token
Operation.destroy(token); // Destroys the token if it is valid & return a new Destroyed JWT object, else returns a object with error message

Async/Await

const {jwt} = require('jwt-destroy');

// Register a secret key
const operation = new jwt('secret'); // secret is the secret key by default if not provided

// Generate a token

const token = await operation.generate({id: 1, name: 'John Doe'}, '1h'); // 1h is the expiry time by default if not provided

// Verify a token

const payload = await operation.decode(token); // Returns the payload if the token is valid, else returns a object with error message

// Destroy a token

const destroyedToken = await operation.destroy(token); // Destroys the token if it is valid & return a new Destroyed JWT object, else returns a object with error message

Make sure to explore this package to its full potential by using this package in your projects. Happy Coding!

jwt-destroy's People

Contributors

ankansaha avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.