Session type `auth.api.getSession` is wrong

When I do
import { auth } from "@myworkspace/auth";

const { session, user } = (await auth.api.getSession({
  headers: fromNodeHeaders(req.headers),
})) ?? { session: null, user: null };


the session is typed without activeOrganizationId.

When I do
type Session = typeof auth.$Infer.Session;

in my auth package itself, it's typed properly. I'm already doing
export const auth = betterAuth({
  ...options,
  plugins: [
    ...(options.plugins ?? []),
    customSession(async ({ session, user }, ctx) => {
      return {
        session,
        user,
      };
    }, options),
  ],
});

where session is typed as
(parameter) session: {
    id: string;
    userId: string;
    expiresAt: Date;
    createdAt: Date;
    updatedAt: Date;
    token: string;
    ipAddress?: string | null | undefined;
    userAgent?: string | null | undefined;
} & {
    id: string;
    userId: string;
    expiresAt: Date;
    createdAt: Date;
    updatedAt: Date;
    token: string;
    ipAddress?: string | null | undefined;
    userAgent?: string | null | undefined;
    activeOrganizationId?: string | null | undefined;
}
Was this page helpful?