jose
Version:
JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes
52 lines (51 loc) • 2.4 kB
TypeScript
import type * as t from '../../types.d.ts';
/** Configures an individual recipient in a General JWE. */
export interface Recipient {
/** Sets the JWE Per-Recipient Unprotected Header. May only be called once. */
setUnprotectedHeader(unprotectedHeader: t.JWEHeaderParameters): Recipient;
/**
* 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): Recipient;
/**
* Adds another recipient to the enclosing {@link GeneralEncrypt} and returns its configuration.
*
* @param key Public key or shared secret. See
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
*/
addRecipient(key: t.KeyInput, options?: t.CritOption): Recipient;
/**
* Encrypts for all recipients on the enclosing {@link GeneralEncrypt}, using their configured
* keys.
*/
encrypt(): Promise<t.GeneralJWE>;
/** Returns the enclosing {@link GeneralEncrypt} instance. */
done(): GeneralEncrypt;
}
/** Produces general JWE JSON Serialization using authenticated encryption. */
export declare class GeneralEncrypt {
#private;
/**
* Creates an encryptor for general JWE JSON Serialization.
*
* @param plaintext Binary representation of the plaintext to encrypt.
*/
constructor(plaintext: Uint8Array);
/**
* Adds a recipient and returns its configuration.
*
* @param key Public key or shared secret. See
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
*/
addRecipient(key: t.KeyInput, options?: t.CritOption): Recipient;
/** Sets the JWE Protected Header. May only be called once. */
setProtectedHeader(protectedHeader: t.JWEHeaderParameters): this;
/** Sets the JWE Shared Unprotected Header. May only be called once. */
setSharedUnprotectedHeader(sharedUnprotectedHeader: t.JWEHeaderParameters): this;
/** Sets the JWE AAD, which is integrity protected but not encrypted. */
setAdditionalAuthenticatedData(aad: Uint8Array): this;
/** Encrypts the plaintext and returns the general JWE JSON Serialization. */
encrypt(): Promise<t.GeneralJWE>;
}