Skip to main content
Module

x/jose/index.ts>GeneralEncrypt

"JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK, JWKS with no dependencies using runtime's native crypto in Node.js, Browser, Cloudflare Workers, Electron, and Deno.
Extremely Popular
Go to Latest
class GeneralEncrypt
import { GeneralEncrypt } from "https://deno.land/x/jose@v4.8.3/index.ts";

The GeneralEncrypt class is a utility for creating General JWE objects.

Examples

Usage

const jwe = await new jose.GeneralEncrypt(
  new TextEncoder().encode(
    'It’s a dangerous business, Frodo, going out your door.'
  )
)
  .setProtectedHeader({ enc: 'A256GCM' })
  .addRecipient(ecPublicKey)
  .setUnprotectedHeader({ alg: 'ECDH-ES+A256KW' })
  .addRecipient(rsaPublicKey)
  .setUnprotectedHeader({ alg: 'RSA-OAEP-384' })
  .encrypt()

console.log(jwe)

Constructors

new
GeneralEncrypt(plaintext: Uint8Array)

Properties

private
_aad: Uint8Array
private
_plaintext: Uint8Array
private
_protectedHeader: JWEHeaderParameters
private
_recipients: IndividualRecipient[]
private
_unprotectedHeader: JWEHeaderParameters

Methods

addRecipient(key: KeyLike | Uint8Array, options?: CritOption): Recipient

Adds an additional recipient for the General JWE object.

encrypt(options?: DeflateOption): Promise<GeneralJWE>

Encrypts and resolves the value of the General JWE object.

Sets the Additional Authenticated Data on the GeneralEncrypt object.

setProtectedHeader(protectedHeader: JWEHeaderParameters): this

Sets the JWE Protected Header on the GeneralEncrypt object.

setSharedUnprotectedHeader(sharedUnprotectedHeader: JWEHeaderParameters): this

Sets the JWE Shared Unprotected Header on the GeneralEncrypt object.