cose-kit
Version:
**DEPRECATED:** Use [@auth0/cose](https://www.npmjs.com/package/@auth0/cose).
68 lines (67 loc) • 3.82 kB
TypeScript
import { COSEBase } from './COSEBase.js';
import { Direct, EncryptProtectedHeaders, EncryptionAlgorithms, SupportedEncryptionAlgorithms, UnprotectedHeaders } from '../headers.js';
import { KeyLike } from 'jose';
import { DecryptOptions } from './Encrypt0.js';
import { COSEKey } from "../key/COSEKey.js";
/**
* Decoded COSE_Encrypt0 structure.
*/
export declare class Encrypt extends COSEBase {
readonly ciphertext: Uint8Array;
readonly recipients: Recipient[];
constructor(protectedHeaders: Uint8Array | Map<number, unknown>, unprotectedHeaders: Map<number, unknown>, ciphertext: Uint8Array, recipients: Recipient[]);
/**
* Create the COSE_Encrypt0 structure for Aditional authenticated data.
*
* @param protectedHeaders
* @param applicationHeaders
* @param ciphertext
* @returns
*/
private static createAAD;
getContentForEncoding(): (Uint8Array | Map<number, unknown> | 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): Encrypt;
/**
* 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: COSEKey | 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: COSEKey | KeyLike | Uint8Array, externalAAD: Uint8Array | undefined, recipients: Recipient[]): Promise<Encrypt>;
static tag: number;
}
export declare class Recipient extends COSEBase {
readonly ciphertext?: Uint8Array | undefined;
readonly recipients?: Recipient[] | undefined;
constructor(protectedHeaders: Uint8Array | Map<number, unknown>, unprotectedHeaders: Map<number, unknown>, ciphertext?: Uint8Array | undefined, recipients?: Recipient[] | undefined);
static create(protectedHeaders: EncryptProtectedHeaders | ConstructorParameters<typeof EncryptProtectedHeaders>[0], unprotectedHeaders: UnprotectedHeaders | ConstructorParameters<typeof UnprotectedHeaders>[0] | undefined): Recipient;
get alg(): EncryptionAlgorithms | Direct | undefined;
get algName(): SupportedEncryptionAlgorithms | undefined;
hasSupportedAlg(): boolean;
}