1
1
import type { AuthObject } from '@clerk/backend' ;
2
2
import { constants , createClerkRequest , createRedirect , type RedirectFun } from '@clerk/backend/internal' ;
3
+ import type { PendingSessionOptions } from '@clerk/types' ;
3
4
import { notFound , redirect } from 'next/navigation' ;
4
5
5
6
import { PUBLISHABLE_KEY , SIGN_IN_URL , SIGN_UP_URL } from '../../server/constants' ;
@@ -38,7 +39,7 @@ type Auth = AuthObject & {
38
39
} ;
39
40
40
41
export interface AuthFn {
41
- ( ) : Promise < Auth > ;
42
+ ( options ?: PendingSessionOptions ) : Promise < Auth > ;
42
43
43
44
/**
44
45
* `auth` includes a single property, the `protect()` method, which you can use in two ways:
@@ -68,7 +69,7 @@ export interface AuthFn {
68
69
* - Only works on the server-side, such as in Server Components, Route Handlers, and Server Actions.
69
70
* - Requires [`clerkMiddleware()`](https://clerk.com/docs/references/nextjs/clerk-middleware) to be configured.
70
71
*/
71
- export const auth : AuthFn = async ( ) => {
72
+ export const auth : AuthFn = async ( { treatPendingAsSignedOut } = { } ) => {
72
73
// eslint-disable-next-line @typescript-eslint/no-require-imports
73
74
require ( 'server-only' ) ;
74
75
@@ -89,7 +90,7 @@ export const auth: AuthFn = async () => {
89
90
const authObject = await createAsyncGetAuth ( {
90
91
debugLoggerName : 'auth()' ,
91
92
noAuthStatusMessage : authAuthHeaderMissing ( 'auth' , await stepsBasedOnSrcDirectory ( ) ) ,
92
- } ) ( request ) ;
93
+ } ) ( request , { treatPendingAsSignedOut } ) ;
93
94
94
95
const clerkUrl = getAuthKeyFromRequest ( request , 'ClerkUrl' ) ;
95
96
0 commit comments