Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

did-jwt

Package Overview
Dependencies
Maintainers
8
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

did-jwt

Library for Signing and Verifying JWTs compatible uPort and DID standards

  • 5.4.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created

What is did-jwt?

The did-jwt package is a JavaScript library for creating and verifying JSON Web Tokens (JWTs) using Decentralized Identifiers (DIDs). It is commonly used in decentralized applications to handle authentication and authorization processes in a secure and decentralized manner.

What are did-jwt's main functionalities?

Creating a JWT

This feature allows you to create a JSON Web Token (JWT) using a Decentralized Identifier (DID). The code sample demonstrates how to create a JWT with a payload, including an audience, expiration, and a name, and then sign it using a DID.

const { createJWT } = require('did-jwt');
const payload = { aud: 'did:example:receiver', exp: Math.floor(Date.now() / 1000) + 60 * 60, name: 'Alice' };
const signer = { did: 'did:example:alice', signer: async (data) => { /* signing logic */ } };
createJWT(payload, signer).then(jwt => console.log(jwt));

Verifying a JWT

This feature allows you to verify a JSON Web Token (JWT) using a DID. The code sample shows how to verify a JWT by resolving the DID document and checking the signature.

const { verifyJWT } = require('did-jwt');
const jwt = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9...';
const resolver = { resolve: async (did) => { /* DID document resolution logic */ } };
verifyJWT(jwt, { resolver }).then(verified => console.log(verified));

Other packages similar to did-jwt

FAQs

Package last updated on 18 May 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc