JSON Web Key
npm install json-web-key``sh`
$ npm install --save json-web-key
`js`
var JSONWebKey = require( 'json-web-key' )
`js`
// Constructing a JWK from PEM data
var webKey = JSONWebKey.fromPEM( '-----BEGIN PUBLIC KEY-----\nMIIBIjANB...' )
`js`
// Constructing a JWK from JSON data
var webKey = JSONWebKey.fromJSON({
"kty": "RSA",
"n": "oL9U7lsMfBGZiFO...",
"e": "AQAB"
})
`js``
// Formatting as JSON
webKey.toJSON() // -> Object
JSON.stringify( webKey ) // -> String
* JSONWebKey
* new JSONWebKey()
* .PEM : Object
* .getPEMBuffer(pem) ⇒ Buffer
* .fromPEM(pem) ⇒ JSONWebKey
* .fromJSON(json) ⇒ JSONWebKey
Kind: static property of JSONWebKey
Kind: static method of JSONWebKey
| Param | Type |
| --- | --- |
| pem | String | Buffer |
Kind: static method of JSONWebKey
| Param | Type |
| --- | --- |
| pem | String | Buffer |
Kind: static method of JSONWebKey
| Param | Type |
| --- | --- |
| json | Object | String |