chore(oauth-provider): correct optional typing for refreshToken sessionId field (#9324)

Co-authored-by: Taesu <bytaesu@gmail.com>
This commit is contained in:
Dylan Vanmali
2026-05-03 12:12:23 -07:00
committed by GitHub
parent 4b34df8bdc
commit 6b03a45a14
4 changed files with 11 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"@better-auth/oauth-provider": patch
---
Make `sessionId` optional in refresh token types to match the refresh token schema.

View File

@@ -288,14 +288,14 @@ async function validateRefreshToken(
};
}
let sessionId: string | undefined = refreshToken.sessionId ?? undefined;
let sessionId = refreshToken.sessionId ?? undefined;
if (sessionId) {
const session = await ctx.context.adapter.findOne<Session>({
model: "session",
where: [
{
field: "id",
value: refreshToken.sessionId,
value: sessionId,
},
],
});

View File

@@ -301,7 +301,9 @@ async function createRefreshToken(
}
// Issue new refresh token
const refreshToken = await ctx.context.adapter.create({
const refreshToken = await ctx.context.adapter.create<
OAuthRefreshToken<Scope[]> & { id: string }
>({
model: "oauthRefreshToken",
data: {
token: await storeToken(opts.storeTokens, token, "refresh_token"),

View File

@@ -1037,7 +1037,7 @@ export interface OAuthRefreshToken<
Scopes extends readonly Scope[] = InternallySupportedScopes[],
> {
token: string;
sessionId: string;
sessionId?: string;
userId: string;
referenceId?: string;
clientId?: string;