UNPKG

cose-kit

Version:

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

61 lines (60 loc) 3.01 kB
import { KeyLike } from 'jose'; import { COSEBase } from './COSEBase.js'; import { EncryptionAlgorithms, SupportedEncryptionAlgorithms, EncryptProtectedHeaders, UnprotectedHeaders } from '../headers.js'; export type DecryptOptions = { externalAAD?: Uint8Array; detachedPayload?: Uint8Array; algorithms?: EncryptionAlgorithms[]; }; /** * Decoded COSE_Encrypt0 structure. */ export declare class Encrypt0 extends COSEBase { readonly ciphertext: Uint8Array; constructor(protectedHeaders: Map<number, unknown> | Uint8Array, unprotectedHeaders: Map<number, unknown>, ciphertext: Uint8Array); /** * Create the COSE_Encrypt0 structure for Aditional authenticated data. * * @param protectedHeaders * @param applicationHeaders * @param ciphertext * @returns */ private static createEncrypt0AAD; getContentForEncoding(): (Uint8Array | Map<number, unknown> | undefined)[]; /** * * Decode a COSE_Encrypt0 structure from a buffer. * * @param cose {Uint8Array} - The buffer containing the Cose Encrypt0 tagged or untagged message. * @returns {Encrypt0} - The decoded COSE_Encrypt0 structure. */ static decode(cose: Uint8Array): Encrypt0; /** * Decrypt and verify the instance using the given key. * * @param {KeyLike | Uint8Array} key - The key to verify the signature with. * @param {VerifyOptions} [options] - Decrypt options. * @param {EncryptionAlgorithms[]} [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. */ decrypt(key: KeyLike | Uint8Array, options?: DecryptOptions): Promise<Uint8Array>; get alg(): EncryptionAlgorithms | undefined; get algName(): SupportedEncryptionAlgorithms | undefined; hasSupportedAlg(): boolean; /** * * Create and encrypt a COSE_Encrypt0 message. * * @param protectedHeaders {EncryptProtectedHeaders | ConstructorParameters<typeof EncryptProtectedHeaders>[0]} - The protected headers * @param unprotectedHeaders {UnprotectedHeaders | ConstructorParameters<typeof UnprotectedHeaders>[0] | undefined} - The unprotected headers * @param content {Uint8Array} - The content to encrypt * @param key {KeyLike | Uint8Array} - The key to use to encrypt the content * @param [externalAAD] {Uint8Array} - External Additional Associated Data * @returns {Promise<Encrypt0>} */ static encrypt(protectedHeaders: EncryptProtectedHeaders | ConstructorParameters<typeof EncryptProtectedHeaders>[0], unprotectedHeaders: UnprotectedHeaders | ConstructorParameters<typeof UnprotectedHeaders>[0] | undefined, content: Uint8Array, key: KeyLike | Uint8Array, externalAAD?: Uint8Array): Promise<Encrypt0>; static tag: number; }