cose-kit
Version:
**DEPRECATED:** Use [@auth0/cose](https://www.npmjs.com/package/@auth0/cose).
95 lines (94 loc) • 2.75 kB
TypeScript
import { KeyType } from "./kty.js";
import { Curve } from "./curve.js";
import { TypedMap } from "@jfromaniello/typedmap";
import { Algorithms } from "../headers.js";
import { GenerateKeyPairOptions, JWK, importJWK } from "jose";
import { COSEKeyParam } from "./params.js";
import { KeyOps } from './key_ops.js';
export declare const JWKFromCOSEValue: Map<string, (v: unknown) => string>;
export declare const JWKToCOSEValue: Map<string, (v: unknown) => KeyType | Uint8Array | Algorithms | KeyOps[]>;
export declare class COSEKey extends TypedMap<[
COSEKeyParam.KeyType,
KeyType
] | [
COSEKeyParam.KeyID,
Uint8Array
] | [
COSEKeyParam.Algorithm,
Algorithms
] | [
COSEKeyParam.KeyOps,
KeyOps[]
] | [
COSEKeyParam.BaseIV,
Uint8Array
] | [
COSEKeyParam.Curve,
Curve
] | [
COSEKeyParam.x,
Uint8Array
] | [
COSEKeyParam.y,
Uint8Array
] | [
COSEKeyParam.d,
Uint8Array
] | [
COSEKeyParam.k,
Uint8Array
]> {
/**
* Import a COSEKey either decoded as Map<number, unknown> or as an encoded CBOR.
*
* @param data {Uint8Array | Map<number, unknown>}
* @returns
*/
static import(data: Uint8Array | Map<number, unknown>): COSEKey;
/**
*
* Create a COSEKey from a JWK.
*
* @param jwk {JWK} - A JWK.
* @returns
*/
static fromJWK(jwk: JWK): COSEKey;
/**
*
* Generate a random COSEKey for the provided alg.
*
* @param alg {Algorithms} - The algorithm to use.
* @param [options] {Omit<GenerateKeyPairOptions, 'extractable'>} - The options to use.
* @param [options.crv] {Curve} - The curve to use for EC keys.
* @param [options.modulusLength] {number} - The modulus length to use for RSA keys.
* @returns
*/
static generate(alg: Algorithms, options?: Omit<GenerateKeyPairOptions, 'extractable'>): Promise<{
privateKey: COSEKey;
publicKey: COSEKey;
}>;
/**
*
* Returns a JWK representation of the COSEKey.
*
* @returns {JWK} - The JWK representation of the COSEKey.
*/
toJWK(): JWK;
/**
* Create a KeyLike from the COSEKey.
*
* KeyLike are runtime-specific classes representing asymmetric keys or symmetric secrets.
* These are instances of CryptoKey and additionally KeyObject in Node.js runtime.
* Uint8Array instances are also accepted as symmetric secret representation only.
*
* @returns {ReturnType<typeof importJWK> } - The KeyLike representation of the COSEKey.
*/
toKeyLike(): ReturnType<typeof importJWK>;
/**
*
* Encode the COSEKey as a CBOR buffer.
*
* @returns {Uint8Array} - The encoded COSEKey.
*/
encode(): Uint8Array;
}