kobe-jws-jwk

20.12.1 • Public • Published

Dependency Status License

This project is deprecated. node-jws now accepts arbitrary keys (can add kid) and the JWK can be converted to PEM format easily with rsa-pem-from-mod-exp and the .shim() never worked right. We should submit a PR to node-jws to support JWK(S)

node-jws-jwk

This is basically just node-jws augmented so that secretOrKey can be a JWK or set of JWKs.

Install

$ npm install jws-jwk

Example

var jws = require('jws-jwk');

var signature = getJWSFromSomwhere();
var jwk = { kid: '1234', kty: 'RSA', n: '12345...XYZ=', e: 'AQAB' };

if (jws.verify(signature, jwk)) {
  // Do stuff here, signature was verified using the JWK
}

Overriding node-jws

You might want to make it so when other code you are using does the following, the module in the variable jws is augmented.

var jws = require('jws');

One reason to do this is to make modules using node-jws work with JWKs, e.g. jsonwebtoken. Requiring node-jws-jwk like so will add its augmented functions to the node-jws module:

var jws = require('jws-jwk').shim();

In-Browser Usage

This module shims in jsrsasign when browserified to make jws.verify work in-browser (with JWKs and normally).

References

  1. node-jws
  2. JSON Web Key (JWK) Draft 31

Readme

Keywords

none

Package Sidebar

Install

npm i kobe-jws-jwk

Weekly Downloads

4

Version

20.12.1

License

Apache-2.0

Unpacked Size

21.2 kB

Total Files

8

Last publish

Collaborators

  • tce_developers