Node-sodium-jwt - Fast sodium-based crypto for signing and verifying json web tokens (JWT)

Overview

node-sodium-jwt

npm version npm monthly downloads npm license github main workflow

Features

Fast sodium-based crypto for hashing json web tokens (JWT)

  • Relies on sodium-native to perform crypto.
  • Built with TypeScript for static type checking with exported types along the library.

Install

npm install @mgcrea/node-sodium-jwt --save

Quickstart

Sign a jwt

import {signSync} from '@mgcrea/node-sodium-jwt';

const payload: Payload = {
  sub: 7,
  iat: new Date('2022-01-03T16:37:48.612Z').getTime(),
};
// Must be 32 bytes long
const secretKey = '0DfgJOaVrb2quroZavPLp7KJm+hTCBN6hZKnsKQSM+o=';
const jwt = signSync(payload, secretKey);

Verify a jwt

import {verifySync} from '@mgcrea/node-sodium-jwt';

const jwt =
  'eyJhbGciOiJIUzUxMlQiLCJ0eXAiOiJKV1QifQ.eyJzdWIiOjcsImlhdCI6MTY0MTIyNzg2ODYxMn0.a3_bFmeD5vugh3p998QXTdPbAuAJFQzCm-2MfmRVEAg';
const secretKey = '0DfgJOaVrb2quroZavPLp7KJm+hTCBN6hZKnsKQSM+o=';
const {header, payload, rotated} = verifySync(payload, secretKey);

Generate a new secretKey

Generate a new secretKey from the bundled cli:

node_modules/.bin/node-sodium-jwt random-bytes

Sign a jwt via CLI

Copy a freshly generated secretKey from the bundled cli:

node_modules/.bin/node-sodium-jwt sign '{"sub": "1"}' '0DfgJOaVrb2quroZavPLp7KJm+hTCBN6hZKnsKQSM+o='

Verify a jwt via CLI

echo -n 'eyJhbGciOiJIUzUxMlQiLCJ0eXAiOiJKV1QifQ.eyJzdWIiOiIxIn0.QdubXBylKLNswV8-b44StbaNQr3SYhqwRBTMn6A6-JM' | node_modules/.bin/node-sodium-jwt verify '0DfgJOaVrb2quroZavPLp7KJm+hTCBN6hZKnsKQSM+o='

Authors

License

The MIT License

Copyright (c) 2022 Olivier Louvignes <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You might also like...

Building an API on nodejs with registration system, authentication, CRUD of projects and tasks.

api-token-express Building an API on nodejs with registration system, authentication, CRUD of projects and tasks. API endpoints POST { "username":

Jan 15, 2022

Authenticated server-side rendering with Nuxt 3 and Firebase 9

Authenticated server-side rendering with Nuxt 3 and Firebase 9.

Dec 23, 2022

Container Image Signing & Verifying on Ethereum [Testnet]

Container Image Signing & Verifying on Ethereum [Testnet]

cosigneth An experimental decentralized application for storing and verifying container image signatures as an NFT on Ethereum cosigneth, is a decentr

Jul 4, 2022

Free, open-source crypto trading bot, automated bitcoin / cryptocurrency trading software, algorithmic trading bots. Visually design your crypto trading bot, leveraging an integrated charting system, data-mining, backtesting, paper trading, and multi-server crypto bot deployments.

Free, open-source crypto trading bot, automated bitcoin / cryptocurrency trading software, algorithmic trading bots. Visually design your crypto trading bot, leveraging an integrated charting system, data-mining, backtesting, paper trading, and multi-server crypto bot deployments.

Free, open-source crypto trading bot, automated bitcoin / cryptocurrency trading software, algorithmic trading bots. Visually design your crypto trading bot, leveraging an integrated charting system, data-mining, backtesting, paper trading, and multi-server crypto bot deployments.

Jan 1, 2023

Receive crypto payments from anywhere around the world, options including native tokens (MATIC, ETHER,BUSD), Tokens (USDT,BUSD), NFTs and more.

Receive crypto payments from anywhere around the world, options including native tokens (MATIC, ETHER,BUSD), Tokens (USDT,BUSD), NFTs and more.

Receive payments for service rendered in crypto using different options. Go borderless with bonpay, gain access to varities of crypto assets, safe and

Nov 11, 2022

Node.js module for verifying Plumo proofs and reading states based on it

plumo-verifier Node.js module for verifying Plumo proofs and reading states based on it. Plumo is a SNARK-based light client verifier for the Celo blo

Dec 15, 2022

Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

Jan 5, 2022

Ed25519 signing and verification applet.

Ed25519 Applet Live demo: https://cyphr.me/ed25519_applet/ed.html This tool can run locally and offline git clone this project to a local directory. g

Oct 1, 2022

Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

May 18, 2022

Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

May 3, 2022

Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

Jan 3, 2023

Digital Identifier is a secure, decentralized, anonymous and tampered proof way of maintaining and verifying all essential identity-based documents to create a unique digital identity of a person.

Digital Identifier is a secure, decentralized, anonymous and tampered proof way of maintaining and verifying all essential identity-based documents to create a unique digital identity of a person.

Digital Identifier 🧐 To design and develop a secure, decentralized, anonymous and tampered proof way of maintaining and verifying all essential ident

Dec 17, 2022

Sodium is an advanced v13.6.0 discord client.

Sodium Client ➥ English Sodium is an advanced open-source client template for 13.0.6 version of Discord. It's a strict typed client like TypeScript bu

Nov 14, 2022

🌈 Put a date and a crypto, optionally a quantity of that crypto, to see how much has augmented/increased in dollars & percentage

crypif Put a date and a crypto, optionally a quantity of that crypto, to see how much has augmented/increased in dollars & percentage Figma I still ha

Apr 4, 2022

Crypto-tracker - Get crypto currency data in one click. Followed by a few more clicks.

https://crypto-tracker-ayaanzaveri08.vercel.app/ Crypto Tracker Crypto Tracker tracks crypto with the CoinGecko API. This app uses the React framework

Apr 30, 2022

A collection of crypto tokens (metadata, logos, links)

@deliquid/token-list (beta) A multi-chain collection of crypto tokens, including metadata, logos, and more. Installation npm i @deliquid/token-list Ba

Jun 3, 2022

JSON Hero is an open-source, beautiful JSON explorer for the web that lets you browse, search and navigate your JSON files at speed. 🚀

JSON Hero is an open-source, beautiful JSON explorer for the web that lets you browse, search and navigate your JSON files at speed. 🚀

JSON Hero makes reading and understand JSON files easy by giving you a clean and beautiful UI packed with extra features.

Jan 9, 2023

FIXYL is a tool for testing and verifying software that uses the FIX protocol.

FIXYL is a tool for testing and verifying software that uses the FIX protocol.

FIXYL FIXYL is a tool for testing and verifying software that uses the FIX protocol. It allows establishing FIX sessions and exchanging (and manipulat

Dec 29, 2022

zkPoB is a mobile compatible tool that lets anyone prove they own a Bufficorn (or any NFT) without revealing which Buffi they own or the address they are verifying themselves with

zkPoB is a mobile compatible tool that lets anyone prove they own a Bufficorn (or any NFT) without revealing which Buffi they own or the address they are verifying themselves with

zkPoB is a mobile compatible tool that lets anyone prove they own a Bufficorn (or any NFT) without revealing which Buffi they own or the address they are verifying themselves with

Aug 25, 2022
Owner
Olivier Louvignes
Olivier Louvignes
This package allows you to use Okta as your identity provider for use with Netlify's Role-based access control with JWT.

netlify-okta-auth This package allows you to use Okta as your identity provider for use with Netlify's Role-based access control with JWT. Who is this

Twilio Labs 8 Sep 17, 2022
The authentication-server is a node app that handles user registration, authentication & authorization with JWT.

Authentication Server The authentication-server is a node app that handles user registration, authentication & authorization with JWT. Here is the REP

Oğuz Çolak 18 Jul 24, 2022
Simple JWT Auth With TRPC prisma & next

Simple JWT Auth With TRPC prisma & next A sample JWT authentication using prisma, @trpc/server @trpc/client @trpc/react in Next.js Simple Usage copy .

Aris Riswanto 4 Aug 23, 2022
Tutorial Project : NodeJs API Multi Authorization Middleware with JWT

Tutorial How to Create API with multi route prefixs as well as Multi Authorization in NodeJs Installation npm install .env modify database informatio

Aung Kyaw Nyunt 10 Dec 10, 2022
Role based authentication for NodeJS and ExpressJS

Authentication service made for ExpressJS and MongoDB using JWT. We tried to make it as clean and structured as possible. We also provide this documentation on how to install and integrate it with your own application.

null 4 Oct 3, 2021
node.js auth package (password, facebook, & more) for Connect and Express apps

everyauth Authentication and authorization (password, facebook, & more) for your node.js Connect and Express apps. There is a NodeTuts screencast of e

Brian Noguchi 3.5k Dec 17, 2022
An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser

Node-Casbin News: still worry about how to write the correct node-casbin policy? Casbin online editor is coming to help! node-casbin is a powerful and

Casbin 2.1k Dec 27, 2022
Simple, unobtrusive authentication for Node.js.

Passport Passport is Express-compatible authentication middleware for Node.js. Passport's sole purpose is to authenticate requests, which it does thro

Jared Hanson 21k Jan 7, 2023
node.js/express module to authenticate users without password

Passwordless Passwordless is a modern node.js module for Express that allows authentication and authorization without passwords by simply sending one-

Florian Heinemann 2k Dec 14, 2022
An easy to use authentication system that can easily be built in to your Express + HBS web apps.

yoAuth An easy to use authentication system that can easily be built in to your Express + HBS web apps. Currently only supports local authentication,

null 2 Jan 21, 2022