Interchangeably use RSA & ECDSA with PEM and JWK for Signing, Verifying, CSR generation and JOSE. Ugh... that was a mouthful. :)
Go to file
AJ ONeal 1a0e92eb52 typo fix 2019-02-23 02:27:52 -07:00
.gitignore v1.0.0: just wrap Rasha and Eckles for now 2019-02-23 02:27:20 -07:00
README.md v1.0.0: just wrap Rasha and Eckles for now 2019-02-23 02:27:20 -07:00
keypairs.js v1.0.0: just wrap Rasha and Eckles for now 2019-02-23 02:27:20 -07:00
package-lock.json v1.0.0: just wrap Rasha and Eckles for now 2019-02-23 02:27:20 -07:00
package.json typo fix 2019-02-23 02:27:52 -07:00

README.md

Keypairs for node.js

Lightweight JavaScript RSA and ECDSA utils that work on Windows, Mac, and Linux using modern node.js APIs (no need for C compiler).

A thin wrapper around Eckles.js (ECDSA) and Rasha.js (RSA).

Features

  • Generate keypairs
    • RSA
    • ECDSA (P-256, P-384)
  • PEM-to-JWK
  • JWK-to-PEM
  • SHA256 JWK Thumbprints
  • JWK fetching. See Keyfetch.js
    • OIDC
    • Auth0

Usage

A brief (albeit somewhat nonsensical) introduction to the APIs:

Keypairs.generate().then(function (jwk) {
  return Keypairs.export({ jwk: jwk }).then(function (pem) {
    return Keypairs.import({ pem: pem }).then(function (jwk) {
      return Keypairs.thumbprint({ jwk: jwk }).then(function (thumb) {
        console.log(thumb);
      });
    });
  });
});

By default ECDSA keys will be used since they've had native support in node much longer than RSA has, and they're smaller, and faster to generate.

API

Each of these return a Promise.

  • Keypairs.generate(options)
    • options example { kty: 'RSA', modulusLength: 2048 }
    • options example { kty: 'ECDSA', namedCurve: 'P-256' }
  • Keypairs.import(options)
    • options example { pem: '...' }
  • Keypairs.export(options)
    • options example { jwk: jwk }
    • options example { jwk: jwk, public: true }
  • Keypairs.thumbprint({ jwk: jwk })

Full Documentation

Keypairs.js provides a 1-to-1 mapping to the Rasha.js and Eckles.js APIs.

The full RSA documentation is at Rasha.js

The full ECDSA documentation is at Eckles.js

Any option you pass to Keypairs will be passed directly to the corresponding API of either Rasha or Eckles.