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

feat: migrate to v4 #40

Merged
merged 30 commits into from
Dec 1, 2021
Merged

feat: migrate to v4 #40

merged 30 commits into from
Dec 1, 2021

Conversation

ndom91
Copy link
Member

@ndom91 ndom91 commented Aug 11, 2021

Migrated everything that needs changed so far.

I did, however, run into one console error regarding jwt that I wasn't sure about. Maybe I forgot to migrate something?

For example, on the "API" page of the example app, which is supposed to print the current session and jwt info, I get the following in my node console:

event - build page: /api/examples/jwt
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of SecretKeyObject, ArrayBuffer, TypedArray, DataView, or Buffer. Received undefined
    at Object.hkdfSync (node:internal/crypto/hkdf:134:7)
    at hkdf (/opt/ndomino/next-auth-typescript-example/node_modules/next-auth/dist/lib/jwt.js:127:40)
    at getDerivedSigningKey (/opt/ndomino/next-auth-typescript-example/node_modules/next-auth/dist/lib/jwt.js:143:18)
    at decode (/opt/ndomino/next-auth-typescript-example/node_modules/next-auth/dist/lib/jwt.js:81:96)
    at getToken (/opt/ndomino/next-auth-typescript-example/node_modules/next-auth/dist/lib/jwt.js:109:12)
    at jwt (webpack-internal:///./pages/api/examples/jwt.ts:11:78)
    at Object.apiResolver (/opt/ndomino/next-auth-typescript-example/node_modules/next/dist/server/api-utils.js:101:15)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async DevServer.handleApiRequest (/opt/ndomino/next-auth-typescript-example/node_modules/next/dist/server/next-server.js:760:9)
    at async Object.fn (/opt/ndomino/next-auth-typescript-example/node_modules/next/dist/server/next-server.js:651:37) {
  code: 'ERR_INVALID_ARG_TYPE'
}

On both the normal and typescript example apps btw.

Any idea whats going on there? Did I miss something in terms of the migration?

Obviously there will probably be a few more small things to change before this is really up to snuff for v4.0.0 (final), but hopefully this takes care of most of the work and then we can merge this PR whenever the day comes tada

@ndom91 ndom91 requested a review from balazsorban44 August 11, 2021 20:43
@vercel
Copy link

vercel bot commented Aug 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

next-auth-example – ./

🔍 Inspect: https://vercel.com/nextauthjs/next-auth-example/BX7KU5aofL8TLpuskCuYZKJM3ETZ
✅ Preview: https://next-auth-example-git-ndom91-update-v4-nextauthjs.vercel.app

@ndom91
Copy link
Member Author

ndom91 commented Aug 27, 2021

Same deal here, I updated next-auth in this PR to 4.0.0-next.24. Also the jwt error seemed to be resolved once I explicitly set the same secret in the config under both config.secret and config.jwt.secret.

Also in this example in /pages/api/examples/jwt.js it was having trouble with getToken from next-auth/jwt. It needed to be explicitly imported as a named import apparently.

@ndom91 ndom91 changed the title feat: migrate to v4.0.0-next.20 feat: migrate to v4.0.0-next.24 Aug 27, 2021
@ndom91 ndom91 changed the title feat: migrate to v4.0.0-next.24 feat: migrate to v4.0.0-beta.1 Sep 5, 2021
@balazsorban44 balazsorban44 changed the title feat: migrate to v4.0.0-beta.1 feat: migrate to v4 Sep 7, 2021
@motleydev
Copy link

motleydev commented Sep 20, 2021

I attempted to use this PR and defining an email provider as well as installing nodemailer throws an "adapter undefined" error.

Error: [next-auth][error][EMAIL_REQUIRES_ADAPTER_ERROR]

Deps:

"dependencies": {
    "next": "11.1.2",
    "next-auth": "^4.0.0-beta.2",
    "nodemailer": "^6.6.3",
    "pg": "^8.7.1",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },

Provider Config:

providers: [
    EmailProvider({
      server: process.env.EMAIL_SERVER,
      from: process.env.EMAIL_FROM,
    }),
  ],

I'm using a mailtrap smtp connection string. FWIW.

@balazsorban44
Copy link
Member

as the message says, you'll need an adapter. 😅

https://next-auth.js.org/adapters/overview

@ndom91 we could explain it a bit better in:
https://next-auth.js.org/errors#email_requires_adapter_error

@motleydev
Copy link

as the message says, you'll need an adapter. 😅

https://next-auth.js.org/adapters/overview

@ndom91 we could explain it a bit better in:
https://next-auth.js.org/errors#email_requires_adapter_error

Hah, I did get THAT far. 😂 I installed nodemailer like mentioned above, which is what the docs indicated as the only required "adapter" needed - am I missing something additional to that? Sorry for the noob Q - hopefully this will help clarify some extra points for those that come after. :)

@balazsorban44
Copy link
Member

balazsorban44 commented Sep 20, 2021

nodemailer is not an adapter, it is a library that helps you sending emails. an adapter is a way for us to save data in a database. which is a requirement for the Email provider. see the docs link in my previous reply

Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

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

Could you update this to use beta.7 To be ready for merge?

@ndom91
Copy link
Member Author

ndom91 commented Nov 23, 2021

@balazsorban44 updated the PR to beta.7 👍

@ndom91
Copy link
Member Author

ndom91 commented Nov 23, 2021

@balazsorban44 since updating to beta.7 this is seemingly having those typescript issues resolving next-auth/react again at build time on vercel (https://vercel.com/nextauthjs/next-auth-example/3PyFJEmnfyyF5eMZyjjG93jCUHXj)

package.json Outdated Show resolved Hide resolved
@balazsorban44 balazsorban44 mentioned this pull request Nov 24, 2021
@balazsorban44
Copy link
Member

image
we will need to comment out the email adapter

@ndom91
Copy link
Member Author

ndom91 commented Dec 1, 2021

image we will need to comment out the email adapter

Okay, done 👍

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.

6 participants