Skip to main content
Module

x/jose/index.ts>generalDecrypt

"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
function generalDecrypt
import { generalDecrypt } from "https://deno.land/x/jose@v4.8.3/index.ts";

Decrypts a General JWE.

Examples

Usage

const jwe = {
  ciphertext: '9EzjFISUyoG-ifC2mSihfP0DPC80yeyrxhTzKt1C_VJBkxeBG0MI4Te61Pk45RAGubUvBpU9jm4',
  iv: '8Fy7A_IuoX5VXG9s',
  tag: 'W76IYV6arGRuDSaSyWrQNg',
  aad: 'VGhlIEZlbGxvd3NoaXAgb2YgdGhlIFJpbmc',
  protected: 'eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0',
  recipients: [
    {
      encrypted_key: 'Z6eD4UK_yFb5ZoKvKkGAdqywEG_m0e4IYo0x8Vf30LAMJcsc-_zSgIeiF82teZyYi2YYduHKoqImk7MRnoPZOlEs0Q5BNK1OgBmSOhCE8DFyqh9Zh48TCTP6lmBQ52naqoUJFMtHzu-0LwZH26hxos0GP3Dt19O379MJB837TdKKa87skq0zHaVLAquRHOBF77GI54Bc7O49d8aOrSu1VEFGMThlW2caspPRiTSePDMDPq7_WGk50izRhB3Asl9wmP9wEeaTrkJKRnQj5ips1SAZ1hDBsqEQKKukxP1HtdcopHV5_qgwU8Hjm5EwSLMluMQuiE6hwlkXGOujZLVizA'
    }
  ]
}

const {
  plaintext,
  protectedHeader,
  additionalAuthenticatedData
} = await jose.generalDecrypt(jwe, privateKey)

console.log(protectedHeader)
const decoder = new TextDecoder()
console.log(decoder.decode(plaintext))
console.log(decoder.decode(additionalAuthenticatedData))

Parameters

jwe: GeneralJWE

General JWE.

key: KeyLike | Uint8Array

Private Key or Secret to decrypt the JWE with.

optional
options: DecryptOptions

JWE Decryption options.

Returns

Promise<GeneralDecryptResult>

Parameters

jwe: GeneralJWE

General JWE.

getKey: GeneralDecryptGetKey

Function resolving Private Key or Secret to decrypt the JWE with.

optional
options: DecryptOptions

JWE Decryption options.

Returns

Promise<GeneralDecryptResult & ResolvedKey>