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

node-jose

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

node-jose

A JavaScript implementation of the JSON Object Signing and Encryption (JOSE) for current web browsers and node.js-based servers

  • 0.5.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is node-jose?

The node-jose package is a comprehensive library for handling JSON Object Signing and Encryption (JOSE) in Node.js. It provides tools for creating, parsing, and validating JSON Web Tokens (JWT), JSON Web Signatures (JWS), JSON Web Encryption (JWE), and JSON Web Keys (JWK).

What are node-jose's main functionalities?

JSON Web Key (JWK) Management

This feature allows you to create and manage JSON Web Keys (JWK). The code sample demonstrates how to generate an RSA key and output its JSON representation.

const jose = require('node-jose');

async function createJWK() {
  const keystore = jose.JWK.createKeyStore();
  const key = await keystore.generate('RSA', 2048, { alg: 'RS256', use: 'sig' });
  console.log(key.toJSON(true));
}

createJWK();

JSON Web Signature (JWS)

This feature allows you to create JSON Web Signatures (JWS). The code sample demonstrates how to sign a message using an RSA key and output the resulting JWS in compact format.

const jose = require('node-jose');

async function createJWS() {
  const keystore = jose.JWK.createKeyStore();
  const key = await keystore.generate('RSA', 2048, { alg: 'RS256', use: 'sig' });
  const input = 'Hello, world!';
  const jws = await jose.JWS.createSign({ format: 'compact' }, key).update(input).final();
  console.log(jws);
}

createJWS();

JSON Web Encryption (JWE)

This feature allows you to create JSON Web Encryption (JWE). The code sample demonstrates how to encrypt a message using an RSA key and output the resulting JWE in compact format.

const jose = require('node-jose');

async function createJWE() {
  const keystore = jose.JWK.createKeyStore();
  const key = await keystore.generate('RSA', 2048, { alg: 'RSA-OAEP', use: 'enc' });
  const input = 'Hello, world!';
  const jwe = await jose.JWE.createEncrypt({ format: 'compact' }, key).update(input).final();
  console.log(jwe);
}

createJWE();

JSON Web Token (JWT) Handling

This feature allows you to create and handle JSON Web Tokens (JWT). The code sample demonstrates how to create a signed JWT with a payload and output the resulting token in compact format.

const jose = require('node-jose');

async function createJWT() {
  const keystore = jose.JWK.createKeyStore();
  const key = await keystore.generate('RSA', 2048, { alg: 'RS256', use: 'sig' });
  const payload = { sub: '1234567890', name: 'John Doe', iat: 1516239022 };
  const token = await jose.JWS.createSign({ format: 'compact' }, key).update(JSON.stringify(payload)).final();
  console.log(token);
}

createJWT();

Other packages similar to node-jose

Keywords

FAQs

Package last updated on 30 Nov 2015

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