cose-kit
v1.7.1
Published
This is an early prototype of a RFC8152 COSE library for node.js.
Downloads
1,069
Readme
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
- panva/jose A node.js library for JOSE.
License
MIT