diff --git a/packages/nextjs/src/middleware/types.ts b/packages/nextjs/src/middleware/types.ts index 9822d3c4bec..22ab21f72aa 100644 --- a/packages/nextjs/src/middleware/types.ts +++ b/packages/nextjs/src/middleware/types.ts @@ -1,5 +1,5 @@ import type { Session, User } from '@clerk/clerk-sdk-node'; -import { GetSessionTokenOptions } from '@clerk/types'; +import { ServerSideAuth } from '@clerk/types'; import { GetServerSidePropsContext } from 'next'; // TODO: Remove when we're using TS >=4.5 @@ -10,9 +10,7 @@ export type WithServerSideAuthOptions = { loadSession?: boolean; }; -export type WithServerSideAuthCallback = ( - context: ContextWithAuth, -) => Return; +export type WithServerSideAuthCallback = (context: ContextWithAuth) => Return; export type WithServerSideAuthResult = ( context: GetServerSidePropsContext, @@ -26,16 +24,7 @@ export type AuthData = { getToken: (...args: any) => Promise; }; -export type ContextWithAuth = - GetServerSidePropsContext & { - auth: ServerSideAuth; - } & (Options extends { loadSession: true } - ? { session: Session | null } - : {}) & - (Options extends { loadUser: true } ? { user: User | null } : {}); - -export type ServerSideAuth = { - sessionId: string | null; - userId: string | null; - getToken: (options?: GetSessionTokenOptions) => Promise; -}; +export type ContextWithAuth = GetServerSidePropsContext & { + auth: ServerSideAuth; +} & (Options extends { loadSession: true } ? { session: Session | null } : {}) & + (Options extends { loadUser: true } ? { user: User | null } : {}); diff --git a/packages/types/src/ssr.ts b/packages/types/src/ssr.ts index f4ad6567aef..b494b4486bd 100644 --- a/packages/types/src/ssr.ts +++ b/packages/types/src/ssr.ts @@ -1,7 +1,14 @@ import { SessionJSON, UserJSON } from './json'; import { SessionResource } from './session'; +import { GetSessionTokenOptions } from './token'; import { UserResource } from './user'; +export type ServerSideAuth = { + sessionId: string | null; + userId: string | null; + getToken: (options?: GetSessionTokenOptions) => Promise; +}; + type SsrSessionState = | { sessionId: null; @@ -22,10 +29,8 @@ type SsrUserState = user: UserType | undefined; }; -export type SsrAuthData = SsrSessionState & - SsrUserState; -export type ClerkSsrState = SsrSessionState & - SsrUserState; +export type SsrAuthData = SsrSessionState & SsrUserState; +export type ClerkSsrState = SsrSessionState & SsrUserState; export type InitialState = | { user: undefined;