cose-to-jwk

1.1.0 • Public • Published

cose-to-jwk

Build Status Coverage Status

This was created to convert CBOR Object Signing and Encryption (COSE) to JSON Web Key (JWK). I specifically needed this for WebAuthn and I'm using it with jwk-to-pem to create PEM strings that work with Node.js's Crypto library.

Example

const coseToJwk = require("cose-to-jwk");
 
// Buffer, ArrayBuffer, Uint8Array, etc. also accepted
const coseArray = [
    0xA5, 0x01, 0x02, 0x03, 0x26, 0x20, 0x01, 0x21, 0x58, 0x20, 0xBB, 0x11, 0xCD, 0xDD, 0x6E, 0x9E,
    0x86, 0x9D, 0x15, 0x59, 0x72, 0x9A, 0x30, 0xD8, 0x9E, 0xD4, 0x9F, 0x36, 0x31, 0x52, 0x42, 0x15,
    0x96, 0x12, 0x71, 0xAB, 0xBB, 0xE2, 0x8D, 0x7B, 0x73, 0x1F, 0x22, 0x58, 0x20, 0xDB, 0xD6, 0x39,
    0x13, 0x2E, 0x2E, 0xE5, 0x61, 0x96, 0x5B, 0x83, 0x05, 0x30, 0xA6, 0xA0, 0x24, 0xF1, 0x09, 0x88,
    0x88, 0xF3, 0x13, 0x55, 0x05, 0x15, 0x92, 0x11, 0x84, 0xC8, 0x6A, 0xCA, 0xC3
];
 
var jwk = coseToJwk(coseArray);

Notes:

  • This currently only supports ECDSA and RSA. GitHub pull requests or issues for other crypto suites are welcome.
  • This doesn't do any other COSE things (signing, decrypting, etc.)
  • This could probably use more testing (although it's not very sophisticated)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    2,247
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    2,247
  • 1.0.0
    0
  • 0.9.0
    0

Package Sidebar

Install

npm i cose-to-jwk

Weekly Downloads

1,908

Version

1.1.0

License

MIT

Unpacked Size

87.5 kB

Total Files

7

Last publish

Collaborators

  • apowers313