Support encryption & decryption for jwts #111
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR proposes an implementation of jose's 'EncryptJWT' class and 'jwtDecrypt()' function in 'encrypt()' and 'decrypt()' methods on the '@elysiajs/jwt' plugin. Below I've listed the key changes:
Transparently, this is pushing into territory where I want someone to double-check my work, and this proposal doesn't yet include supporting test code.
Lastly, because this implementation is based closely on jose's, it has the same limitation of supporting only signing OR encrypting JWTs, not signing THEN encrypting. To solve for that, I'm prototyping a separate '@elysiajs/jwe' plugin that implements jose's 'CompactEncrypt' class and 'compactDecrypt()' function with dedicated publicKey, privateKey, or secret properties for encryption/decryption.