UNPKG

cose-kit

Version:

**DEPRECATED:** Use [@auth0/cose](https://www.npmjs.com/package/@auth0/cose).

53 lines (52 loc) 2.97 kB
import { SignatureBase, VerifyOptions } from './SignatureBase.js'; import { COSEBase } from './COSEBase.js'; import { KeyLike } from 'jose'; import { COSEVerifyGetKey } from '../jwks/local.js'; import { UnprotectedHeaders, ProtectedHeaders } from '../headers.js'; /** * Decoded COSE_Sign structure. */ export declare class Sign extends COSEBase { readonly payload: Uint8Array; readonly signatures: Signature[]; constructor(protectedHeaders: Uint8Array | Map<number, unknown>, unprotectedHeaders: Map<number, unknown>, payload: Uint8Array, signatures: Signature[]); getContentForEncoding(): (Uint8Array | Map<number, unknown> | (Uint8Array | Map<number, unknown>)[][] | undefined)[]; /** * * Verifies the signature of this instance using the given key of a single recipient. * * @param key {KeyLike | Uint8Array | COSEVerifyGetKey} - The key to verify the signature with. * @param options {VerifyOptions} - Verify options * @param options.algorithms {Algorithms[]} - List of allowed algorithms * @param options.externalAAD {Uint8Array} - External Additional Associated Data * @param options.detachedPayload {Uint8Array} - The detached payload to verify the signature with. * @returns {Promise<void>} */ verify(key: KeyLike | Uint8Array | COSEVerifyGetKey, options?: VerifyOptions): Promise<void>; verifyX509(roots: string[], options?: VerifyOptions): Promise<void>; static sign(bodyProtectedHeader: ProtectedHeaders | ConstructorParameters<typeof ProtectedHeaders>[0], unprotectedHeaders: UnprotectedHeaders | ConstructorParameters<typeof UnprotectedHeaders>[0] | undefined, payload: Uint8Array, signers: { key: KeyLike | Uint8Array; protectedHeaders: ProtectedHeaders; unprotectedHeaders?: UnprotectedHeaders; }[]): Promise<Sign>; /** * * Decode a COSE_Sign structure from a buffer. * * @param cose {Uint8Array} - The buffer containing the Cose Sign tagged or untagged message. * @returns {Sign} - The decoded COSE_Sign structure. */ static decode(cose: Uint8Array): Sign; static tag: number; } /** * This class represent a single signature inside a COSE_Sign structure. */ export declare class Signature extends SignatureBase { readonly unprotectedHeaders: Map<number, unknown>; readonly signature: Uint8Array; constructor(protectedHeaders: Uint8Array | Map<number, unknown>, unprotectedHeaders: Map<number, unknown>, signature: Uint8Array); private static Signature; verify(key: KeyLike | Uint8Array | COSEVerifyGetKey, bodyProtectedHeaders: Uint8Array | undefined, payload: Uint8Array, options?: VerifyOptions): Promise<void>; static sign(bodyProtectedHeaders: Uint8Array | undefined, protectedHeaders: ProtectedHeaders | ConstructorParameters<typeof ProtectedHeaders>[0], unprotectedHeaders: UnprotectedHeaders | undefined, payload: Uint8Array, key: KeyLike | Uint8Array): Promise<Signature>; }