cose-kit
TypeScript icon, indicating that this package has built-in type declarations

1.7.1 • Public • Published

This is an early prototype of a RFC8152 COSE library for node.js.

It is inspired by and uses panva/jose.

Example:

const { importJWK } = require('jose');
const { coseVerify }  = require('cose-kit');

const key = await importJWK(jwk);

const cose = Buffer.from(coseHEX, 'hex');

const { isValid } = await coseVerify(cose, key);

Multi-signature:

const { importJWK } = require('jose');
const { coseVerifyMultiSignature }  = require('cose-kit');

const key = await importJWK(jwk);

const cose = Buffer.from(coseHEX, 'hex');

const { isValid } = await coseVerifyMultiSignature(cose, [ key ]);

X509 certificates:

const { coseVerifyX509 }  = require('cose-kit');

const caRoots = [
  `-----BEGIN CERTIFICATE-----...`
];

const cose = Buffer.from(coseHEX, 'hex');

const { isValid } = await coseVerifyX509(cose, caRoots);

Signing a payload:

const { importJWK } = require('jose');
const { coseSign }  = require('cose-kit');

const key = await importJWK(jwk);

const cose = await coseSign(
  { alg: 'ES256' },
  { ctyp: 0 },
  Buffer.from('hello world', 'utf8'),
  key
);

Using COSE keys:

const { coseSign, importCOSEKey }  = require('cose-kit');
const key = await importCOSEKey(coseKey);
const cose = await coseSign(
  { alg: 'ES256' },
  { ctyp: 0 },
  Buffer.from('hello world', 'utf8'),
  key
);

Credits

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i cose-kit

Weekly Downloads

160

Version

1.7.1

License

MIT

Unpacked Size

196 kB

Total Files

144

Last publish

Collaborators

  • jfromaniello