nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
23.86k stars 3.29k forks source link

When trying HTTP-based Email Provider I get Type "email"; sendVerificationRequest is not assignable to type 'Provider'. #8871

Closed kjetilge closed 7 months ago

kjetilge commented 10 months ago

Provider type

Custom provider

Environment

System: OS: macOS 14.0 CPU: (10) arm64 Apple M1 Max Memory: 26.67 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node Yarn: 1.22.17 - ~/.yarn/bin/yarn npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm pnpm: 8.6.7 - ~/.nvm/versions/node/v19.9.0/bin/pnpm Browsers: Chrome: 118.0.5993.70 Safari: 17.0

Reproduction URL

https://github.com/kjetilge/Fagfilm-2023/tree/dev

Describe the issue

I'm trying to implement HTTP-based Email Provider as described here.

How to reproduce

In a nexjs app add file api/auth/[...nextauth]/authOptions.ts that looks like this:

import NextAuth, { NextAuthOptions } from "next-auth"
import { PrismaAdapter } from "@auth/prisma-adapter"
import prisma from "@/lib/prisma"; // a global client for dev use

export const authOptions: NextAuthOptions = {
  adapter: PrismaAdapter(prisma),
  providers: [
    {
      id: 'sendgrid',
      type: 'email',
      async sendVerificationRequest({identifier: email, url}) {
      }
    }
  ],
}

In VS Code observe that you get a type error for the type:'email' on the sendgrid provider. If you change the type to ''oauth" the error goes away. I've tried using the experimental version where the error goes away, but then I see that middleware is not supported, and it's the nodemailer error I get when doing stuff there that make me try http based email.

Also sendVerificationRequest seems to not be recognised.

Expected behavior

I expect email type and sendVerificationRequest to be supported

basememara commented 10 months ago

Yes the EmailProvider seems regressed since 4.22.1. Related discussions:

Anyone looking into this for v5, please make id and name on the EmailProvider optional.