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

v3.14.0 bug: TypeError: [provider.protection].flat is not a function #1675

Closed
liamross opened this issue Apr 8, 2021 · 8 comments · Fixed by #1684 or #1691
Closed

v3.14.0 bug: TypeError: [provider.protection].flat is not a function #1675

liamross opened this issue Apr 8, 2021 · 8 comments · Fixed by #1684 or #1691
Assignees
Labels
bug Something isn't working good first issue Good issue to take for first time contributors

Comments

@liamross
Copy link

liamross commented Apr 8, 2021

Describe the bug

provider.protection is not a required property, and not providing it breaks the package since .flat() is called without first verifying it is an array.

Steps to reproduce

Add a custom provider without specifying protection property

Additional context

Here are all the places this is done:
https://github.com/nextauthjs/next-auth/search?q=%5Bprovider.protection%5D.flat%28%29

@liamross liamross added the bug Something isn't working label Apr 8, 2021
@balazsorban44 balazsorban44 self-assigned this Apr 8, 2021
@balazsorban44
Copy link
Member

thanks, I think you are right! A PR is very welcome for this as it should be an easy fix, but if no one volunteers, I'll just do it myself. 🙂

@balazsorban44 balazsorban44 added the good first issue Good issue to take for first time contributors label Apr 8, 2021
@liamross
Copy link
Author

liamross commented Apr 8, 2021

@balazsorban44 I can, but what about this case where provider.protection is assigned a string?

provider.protection = 'state' // Default to state, as we did in 3.1 REVIEW: should we use "pkce" or "none" as default?

Should that be an array? The documentation is not super clear on what types provider.protection is allowed to be.

@balazsorban44
Copy link
Member

balazsorban44 commented Apr 8, 2021

Originally it was supposed to be a string, but later I was told it would be great if it did support different methods of protection, like PKCE AND state for example (there is also nonce, which isn't implemented right now). For that not to be a breaking change, we still support both a string and an array of strings.

I guess it would be nice if in the core, we just used an array everywhere, so changing that line to ["state"] would be fine.

@fxamauri
Copy link
Contributor

A provisional solution until we wait for the pull request, use node 11 or higher for Array.prototype.flat to be available 😜

@fxamauri
Copy link
Contributor

see if this can be fixed in this version #1684

@github-actions
Copy link

🎉 This issue has been resolved in version 3.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This issue has been resolved in version 3.14.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good issue to take for first time contributors
Projects
None yet
3 participants