feat: refactor existing code, and add Erlang and JavaScript rsa implementation#12
Draft
brettkolodny wants to merge 4 commits intomainfrom
Draft
feat: refactor existing code, and add Erlang and JavaScript rsa implementation#12brettkolodny wants to merge 4 commits intomainfrom
brettkolodny wants to merge 4 commits intomainfrom
Conversation
Open
3422a49 to
6506573
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 adds support for RS256, RS384, and RS256 signed JWTs.
Erlang:
JavaScript:
Changes to the existing API
As described in the next section, it's become necessary to break out the signing and verifying functionality into their own modules. To keep consistency a new module
gwt/hmachas been created that handles the existingto_signed_stringandfrom_signed_stringfunctions. All other functionality around working with a JWT once it's decoded remains in thegwtmodule.New functionality
Because the JavaScript API is promise based and that is incompatible with Erlang the functionality is broken out the following modules:
gwt/erlang/rsagwt/javascript/rsaAll of the functions and types in any module within a
<runtime>folder is annotated with@target(<runtime>). This means that it's impossible to use the the incorrect implementation as they won't even be available at compile time. The docs will make this very clear both at the top level of the module and on every function and type.With this set up we are able to keep all the platform specific code separate from the cross platform utilities of the library. For example, once a JWT is verified/decoded you can use all of the existing functionality in the
gwtmodule without having to worry about platform differences.Notes on JavaScript
To be cross platform between server runtimes (Node, Deno, and Bun) I'm using the web
SubtleCryptoAPI. This seems to be working well, but the one draw back I found is that it doesn't support PKCS#1 formatted PEMs. But seeing as you can convert a PKCS#1 PEMs to a PKCS#8 this doesn't seem like a deal breaker.Closes #1