Sample code for 30+ languages & platforms
JavaScript

Get the Entire Loaded JWE Structure

See more JSON Web Encryption (JWE) Examples

Demonstrates Jwe.GetHeader, which copies the entire currently loaded JWE structure into a JsonObject.

Background. This is the full JWE representation, not a decoded or merged JOSE header. It can contain the protected, unprotected, and per-recipient header material.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

var jwe = new CkJwe();

//  Load the JWE.
var jweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>";
success = jwe.LoadJwe(jweCompact);
if (success == false) {
    console.log(jwe.LastErrorText);
    return;
}

//  Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
//  decoded or merged JOSE header.
var json = new CkJsonObject();
success = jwe.GetHeader(json);
if (success == false) {
    console.log(jwe.LastErrorText);
    return;
}

json.EmitCompact = false;
console.log(json.Emit());