@trust/keychain0.1.2 • Public • Published
KeyChain for use with Web Cryptography API in Node.js
Install the package
$ npm install https://github.com/anvilresearch/keychain.git
Load the module
const KeyChain =
Create a new instance by passing a descriptive object to the
constructor. This object can have any naming or nesting scheme, as long as the last nested object contains parameters describing key generation. At a bare minimum, this must include an
alg property with a JWA algorithm name as its value. Currently,
RS512 are supported.
let keys =a: b: alg: 'RS256'c: d: alg: 'RS256'e: f: alg: 'RS256' modulusLength: 2048 // default is 4096)
This initialized a KeyChain instance but didn't generate keys. To generate keys
according to the object passed to the keychain, call
method returns a promise for the keychain.
Once keys have been generated, they can be accessed as CryptoKey or JWK objects, according to the object structure defined by the caller.
Access CryptoKey objects for Web Crypto API operations:
Access JWK objects:
Key rotation also generates a JWK Set in object and JSON form:
keysjwks // JWK Set objectkeysjwkSet // JWK Set JSON string
$ npm test
Copyright (c) 2016 Anvil Research, Inc.