Skip to content

Commit

Permalink
fix: properly extend NodemailerConfig by EmailConfig (#9890)
Browse files Browse the repository at this point in the history
balazsorban44 authored Feb 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ea7b737 commit 54d8983
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/providers/email.ts
Original file line number Diff line number Diff line change
@@ -43,8 +43,10 @@ export interface EmailConfig extends CommonProviderOptions {
}) => Awaitable<void>
/** Used to hash the verification token. */
secret?: string
/** Used with HTTP-based email providers */
/** Used with HTTP-based email providers. */
apiKey?: string
/** Used with SMTP-based email providers. */
server?: NodemailerConfig["server"]
generateVerificationToken?: () => Awaitable<string>
normalizeIdentifier?: (identifier: string) => string
options: EmailUserConfig
13 changes: 8 additions & 5 deletions packages/core/src/providers/nodemailer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createTransport } from "nodemailer"
import { EmailConfig, html, text } from "./email"
import { EmailConfig, html, text } from "./email.js"
import { AuthError } from "../errors.js"

import type { Transport, TransportOptions } from "nodemailer"
import * as JSONTransport from "nodemailer/lib/json-transport/index.js"
@@ -8,7 +9,7 @@ import * as SESTransport from "nodemailer/lib/ses-transport/index.js"
import * as SMTPTransport from "nodemailer/lib/smtp-transport/index.js"
import * as SMTPPool from "nodemailer/lib/smtp-pool/index.js"
import * as StreamTransport from "nodemailer/lib/stream-transport/index.js"
import type { Awaitable, Theme } from "../types"
import type { Awaitable, Theme } from "../types.js"

type AllTransportOptions =
| string
@@ -27,9 +28,8 @@ type AllTransportOptions =
| Transport<any>
| TransportOptions

export interface NodemailerConfig
extends Omit<EmailConfig, "sendVerificationRequest" | "options"> {
server: AllTransportOptions
export interface NodemailerConfig extends EmailConfig {
server?: AllTransportOptions
sendVerificationRequest: (params: {
identifier: string
url: string
@@ -50,6 +50,9 @@ export type NodemailerUserConfig = Omit<
export default function Nodemailer(
config: NodemailerUserConfig
): NodemailerConfig {
if (!config.server)
throw new AuthError("Nodemailer requires a `server` configuration")

return {
id: "nodemailer",
type: "email",

0 comments on commit 54d8983

Please sign in to comment.