UNPKG

@auth0/cose

Version:
48 lines (47 loc) 2.2 kB
import { KeyLike } from 'jose'; import { COSEBase } from './COSEBase.js'; import { MacProtectedHeaders, UnprotectedHeaders, SupportedMacAlg, MacAlgorithms } from '../headers.js'; type VerifyOptions = { externalAAD?: Uint8Array; detachedPayload?: Uint8Array; algorithms?: MacAlgorithms[]; }; /** * Decoded COSE_Mac0 structure. */ export declare class Mac0 extends COSEBase { readonly payload: Uint8Array; tag: Uint8Array; constructor(protectedHeaders: Map<number, unknown> | Uint8Array, unprotectedHeaders: Map<number, unknown>, payload: Uint8Array, tag: Uint8Array); private static createMAC0; getContentForEncoding(): (Uint8Array | Map<number, unknown> | undefined)[]; /** * Verifies the signature of this instance using the given key. * * @param {KeyLike | Uint8Array} key - The key to verify the signature with. * @param {VerifyOptions} [options] - Verify options * @param {MacAlgorithms[]} [options.algorithms] - List of allowed algorithms * @param {Uint8Array} [options.externalAAD] - External Additional Associated Data * @param {Uint8Array} [options.detachedPayload] - The detached payload to verify the signature with. * @returns {Boolean} - The result of the signature verification. */ verify(key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<void>; get alg(): MacAlgorithms | undefined; get algName(): SupportedMacAlg | undefined; hasSupportedAlg(): boolean; /** * compares the tag of this instance with the tag of the given instance */ areEqual(mac0: Mac0): boolean; static create(protectedHeaders: MacProtectedHeaders | ConstructorParameters<typeof MacProtectedHeaders>[0], unprotectedHeaders: UnprotectedHeaders | ConstructorParameters<typeof UnprotectedHeaders>[0] | undefined, payload: Uint8Array, key: KeyLike | Uint8Array): Promise<Mac0>; /** * * Decode a COSE_Mac0 structure from a buffer. * * @param cose {Uint8Array} - The buffer containing the Cose Mac0 tagged or untagged message. * @returns {Mac0} - The decoded COSE_Mac0 structure. */ static decode(cose: Uint8Array): Mac0; static tag: number; } export {};