Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nodesolidserver/keychain
KeyChain for use with Web Cryptography API in Node.js
https://github.com/nodesolidserver/keychain
running-code
Last synced: about 2 months ago
JSON representation
KeyChain for use with Web Cryptography API in Node.js
- Host: GitHub
- URL: https://github.com/nodesolidserver/keychain
- Owner: nodeSolidServer
- License: mit
- Created: 2018-06-06T18:55:42.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2021-06-12T03:34:25.000Z (over 3 years ago)
- Last Synced: 2024-11-14T10:12:40.571Z (about 2 months ago)
- Topics: running-code
- Language: JavaScript
- Homepage:
- Size: 372 KB
- Stars: 5
- Watchers: 12
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# KeyChain for use with Web Cryptography API in Node.js
## Usage
Install the package
```bash
$ npm install https://github.com/anvilresearch/keychain.git
```Load the module
```javascript
const KeyChain = require('keychain')
```Create a new instance by passing a descriptive object to the `KeyChain`
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, `RS256`, `RS384`, and `RS512` are supported.```javascript
let keys = new KeyChain({
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 `rotate()`. The `rotate()`
method returns a promise for the keychain.```javascript
keys.rotate()
```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:
```javascript
keys.a.b.privateKey
keys.a.b.publicKey
```Access JWK objects:
```javascript
keys.a.b.privateJwk
keys.a.b.publicJwk
```Key rotation also generates a JWK Set in object and JSON form:
```javascript
keys.jwks // JWK Set object
keys.jwkSet // JWK Set JSON string
```## Running tests
### Nodejs
```bash
$ npm test
```## MIT License
[The MIT License](LICENSE.md)
Copyright (c) 2016 Anvil Research, Inc.
Copyright (c) 2017-2019 The Solid Project