← Back to index
class EncryptJWT
extends ProduceJWT

The EncryptJWT class is used to build and encrypt Compact JWE formatted JSON Web Tokens.

Properties

🔗
_cek: Uint8Array
🔗
_iv: Uint8Array
🔗
_keyManagementParameters: JWEKeyManagementHeaderParameters
🔗
_replicateAudienceAsHeader: boolean
🔗
_replicateIssuerAsHeader: boolean
🔗
_replicateSubjectAsHeader: boolean

Methods

🔗
encrypt(key: KeyLike | Uint8Array, options?: EncryptOptions): Promise<string>

Encrypts and returns the JWT.

🔗
replicateAudienceAsHeader()

Replicates the "aud" (Audience) Claim as a JWE Protected Header Parameter.

🔗
replicateIssuerAsHeader()

Replicates the "iss" (Issuer) Claim as a JWE Protected Header Parameter.

🔗
replicateSubjectAsHeader()

Replicates the "sub" (Subject) Claim as a JWE Protected Header Parameter.

🔗
setContentEncryptionKey(cek: Uint8Array)

Sets a content encryption key to use, by default a random suitable one is generated for the JWE enc" (Encryption Algorithm) Header Parameter.

🔗
setInitializationVector(iv: Uint8Array)

Sets the JWE Initialization Vector to use for content encryption, by default a random suitable one is generated for the JWE enc" (Encryption Algorithm) Header Parameter.

🔗
setKeyManagementParameters(parameters: JWEKeyManagementHeaderParameters)

Sets the JWE Key Management parameters to be used when encrypting. Use of this is method is really only needed for ECDH based algorithms when utilizing the Agreement PartyUInfo or Agreement PartyVInfo parameters. Other parameters will always be randomly generated when needed and missing.

🔗
setProtectedHeader(protectedHeader: CompactJWEHeaderParameters)

Sets the JWE Protected Header on the EncryptJWT object.