@@ -72,7 +72,7 @@ import { reqWithEnvURL, setEnvDefaults } from "./lib/env.js"
72
72
import { initAuth } from "./lib/index.js"
73
73
import { signIn , signOut , update } from "./lib/actions.js"
74
74
75
- import type { Session } from "@auth/core/types"
75
+ import type { Awaitable , Session } from "@auth/core/types"
76
76
import type { BuiltInProviderType } from "@auth/core/providers"
77
77
import type {
78
78
GetServerSidePropsContext ,
@@ -358,7 +358,7 @@ export interface NextAuthResult {
358
358
* import NextAuth from "next-auth"
359
359
* import GitHub from "@auth/core/providers/github"
360
360
*
361
- * export const { handlers, auth } = NextAuth((req) => {
361
+ * export const { handlers, auth } = NextAuth(async (req) => {
362
362
* console.log(req) // do something with the request
363
363
* return {
364
364
* providers: [GitHub],
@@ -369,11 +369,11 @@ export interface NextAuthResult {
369
369
export default function NextAuth (
370
370
config :
371
371
| NextAuthConfig
372
- | ( ( request : NextRequest | undefined ) => NextAuthConfig )
372
+ | ( ( request : NextRequest | undefined ) => Awaitable < NextAuthConfig > )
373
373
) : NextAuthResult {
374
374
if ( typeof config === "function" ) {
375
- const httpHandler = ( req : NextRequest ) => {
376
- const _config = config ( req )
375
+ const httpHandler = async ( req : NextRequest ) => {
376
+ const _config = await config ( req )
377
377
setEnvDefaults ( _config )
378
378
return Auth ( reqWithEnvURL ( req ) , _config )
379
379
}
@@ -383,18 +383,18 @@ export default function NextAuth(
383
383
// @ts -expect-error
384
384
auth : initAuth ( config , ( c ) => setEnvDefaults ( c ) ) ,
385
385
386
- signIn : ( provider , options , authorizationParams ) => {
387
- const _config = config ( undefined )
386
+ signIn : async ( provider , options , authorizationParams ) => {
387
+ const _config = await config ( undefined )
388
388
setEnvDefaults ( _config )
389
389
return signIn ( provider , options , authorizationParams , _config )
390
390
} ,
391
- signOut : ( options ) => {
392
- const _config = config ( undefined )
391
+ signOut : async ( options ) => {
392
+ const _config = await config ( undefined )
393
393
setEnvDefaults ( _config )
394
394
return signOut ( options , _config )
395
395
} ,
396
- unstable_update : ( data ) => {
397
- const _config = config ( undefined )
396
+ unstable_update : async ( data ) => {
397
+ const _config = await config ( undefined )
398
398
setEnvDefaults ( _config )
399
399
return update ( data , _config )
400
400
} ,
0 commit comments