jose
Version:
JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes
41 lines (40 loc) • 1.69 kB
TypeScript
import type * as t from '../../types.d.ts';
/** Produces JWE Compact Serialization using authenticated encryption. */
export declare class CompactEncrypt {
#private;
/**
* Creates an encryptor for JWE Compact Serialization.
*
* @param plaintext Binary representation of the plaintext to encrypt.
*/
constructor(plaintext: Uint8Array);
/**
* Sets a content encryption key instead of generating a random one for the JWE "enc" algorithm.
* May only be called once.
*
* @deprecated Use only for testing and vector validation.
*/
setContentEncryptionKey(cek: Uint8Array): this;
/**
* Sets the content encryption IV instead of generating a random one for the JWE "enc" algorithm.
* May only be called once.
*
* @deprecated Use only for testing and vector validation.
*/
setInitializationVector(iv: Uint8Array): this;
/** Sets the JWE Protected Header. May only be called once. */
setProtectedHeader(protectedHeader: t.CompactJWEHeaderParameters): this;
/**
* Sets key management inputs such as ECDH-ES "apu"/"apv" or PBES2 "p2c". Use this method instead
* of header setters; the resulting parameters are added to the JOSE Header. May only be called
* once.
*/
setKeyManagementParameters(parameters: t.JWEKeyManagementHeaderParameters): this;
/**
* Encrypts the plaintext and returns the JWE Compact Serialization.
*
* @param key Public key or shared secret. See
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
*/
encrypt(key: t.KeyInput, options?: t.EncryptOptions): Promise<string>;
}