From 89f018508d934b446ffb454a0fce438d7becc0e0 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Thu, 26 Oct 2023 12:19:36 -0700 Subject: [PATCH] fix(nextjs): Drop `user`, `session`, `organization` from `auth()` --- .changeset/thin-phones-drop.md | 5 +++++ packages/nextjs/src/server/getAuth.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/thin-phones-drop.md diff --git a/.changeset/thin-phones-drop.md b/.changeset/thin-phones-drop.md new file mode 100644 index 00000000000..8aee5843997 --- /dev/null +++ b/.changeset/thin-phones-drop.md @@ -0,0 +1,5 @@ +--- +'@clerk/nextjs': patch +--- + +Drop `user`, `session`, and `organization` resouces from the returned value of `auth()`. diff --git a/packages/nextjs/src/server/getAuth.ts b/packages/nextjs/src/server/getAuth.ts index 21104a0483b..cf37b838973 100644 --- a/packages/nextjs/src/server/getAuth.ts +++ b/packages/nextjs/src/server/getAuth.ts @@ -1,4 +1,4 @@ -import type { Organization, Session, SignedInAuthObject, SignedOutAuthObject, User } from '@clerk/backend'; +import type { AuthObject, Organization, Session, SignedInAuthObject, SignedOutAuthObject, User } from '@clerk/backend'; import { AuthStatus, constants, @@ -18,6 +18,8 @@ import { getAuthKeyFromRequest, getCookie, getHeader, injectSSRStateIntoObject } type GetAuthOpts = Partial; +type AuthObjectWithoutResources = Omit; + export const createGetAuth = ({ debugLoggerName, noAuthStatusMessage, @@ -26,7 +28,10 @@ export const createGetAuth = ({ debugLoggerName: string; }) => withLogger(debugLoggerName, logger => { - return (req: RequestLike, opts?: GetAuthOpts): SignedInAuthObject | SignedOutAuthObject => { + return ( + req: RequestLike, + opts?: GetAuthOpts, + ): AuthObjectWithoutResources => { const debug = getHeader(req, constants.Headers.EnableDebug) === 'true'; if (debug) { logger.enable();