Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support edge runtime compatibility (#1) #172

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kaaloo
Copy link

@kaaloo kaaloo commented Jun 18, 2023

When attempting to use the current 3.0.1 verify-apple-id-token package in the Vercel Edge Runtime an error appears at build time related to the use of dynamic evaluation:

https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

This PR provides a solution to this issue by replacing the jsonwebtoken and jwks-rsa libraries by jose which provides the same functionality in a single well supported package with albeit a slightly different API.

In this context, jose has the important characteristic of being compatible with various edge runtimes including Vercel's.

https://github.com/panva/jose#supported-runtimes

Fixes #171

* Use jose instead of jwks-rsa.  Still need to verify nonce.

* Verify nonce manually since there is no built-in support in jose

* Replace jsonwebtoken by jose too

* Mark as 3.0.1-jose version

* Reset to previous package version

* Ignore vscode settings

* Use jose's decodeProjectedHeader for alg and kid

* Fix tests
@kaaloo kaaloo marked this pull request as ready for review June 18, 2023 18:47
@kaaloo
Copy link
Author

kaaloo commented Jun 18, 2023

@stefanprokopdev please review this PR when you have a moment. I can get by for my needs for the moment by using my fork.

@stefanprokopdev
Copy link
Owner

Hey @kaaloo 👋 Thanks for the PR, it looks good to me!

Could you please run the npm run format script? I think some of the code parts should be reformatted an there is also a missing EOL whitespace (in package.json). Would you be so nice and take a look at this stuff? We can merge it then 🎉

kaaloo added a commit to upskyld/verify-apple-id-token that referenced this pull request Jun 19, 2023
@kaaloo
Copy link
Author

kaaloo commented Jun 19, 2023

Hi @stefanprokopdev , thanks for your quick review! I updated my PR accordingly.

@stefanprokopdev
Copy link
Owner

Thanks @kaaloo ! Are there any breaking changes? For example camelCase changed to snake_case or whatever? Just asking if are 100 % backward compatible or we need more changes or improvements (case sensitivity for example). I am not able to test it now because I dont have an active project 😞

@kaaloo
Copy link
Author

kaaloo commented Jun 19, 2023

Hi, good question 😅 I unfortunately am not going with this in our project because I discovered an experimental supabase auth API that covers the full scope of my use case. Have you had issues with this type of breakage in the past?

Copy link
Owner

@stefanprokopdev stefanprokopdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are just some minor request changes we can discuss.

@kaaloo
Copy link
Author

kaaloo commented Jun 27, 2023

Hi @stefanprokopdev sorry I've been travelling and had not had a moment to code. Will look at this shortly. Thanks for your careful review!

kaaloo and others added 3 commits June 27, 2023 11:39
Should be undefined but sound good to make sure

Co-authored-by: Štefan Prokop <[email protected]>
Best practice not to log nonce values

Co-authored-by: Štefan Prokop <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Edge Runtimes
2 participants