Session type `auth.api.getSession` is wrong
When I do
the session is typed without
When I do
in my auth package itself, it's typed properly. I'm already doing
where
import { auth } from "@myworkspace/auth";
const { session, user } = (await auth.api.getSession({
headers: fromNodeHeaders(req.headers),
})) ?? { session: null, user: null };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
activeOrganizationIdactiveOrganizationId. When I do
type Session = typeof auth.$Infer.Session;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),
],
});export const auth = betterAuth({
...options,
plugins: [
...(options.plugins ?? []),
customSession(async ({ session, user }, ctx) => {
return {
session,
user,
};
}, options),
],
});where
sessionsession 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;
}(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;
}