mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-25 08:31:37 -05:00
chore(oauth-provider): correct optional typing for refreshToken sessionId field (#9324)
Co-authored-by: Taesu <bytaesu@gmail.com>
This commit is contained in:
5
.changeset/yellow-shirts-heal.md
Normal file
5
.changeset/yellow-shirts-heal.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@better-auth/oauth-provider": patch
|
||||
---
|
||||
|
||||
Make `sessionId` optional in refresh token types to match the refresh token schema.
|
||||
@@ -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,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -1037,7 +1037,7 @@ export interface OAuthRefreshToken<
|
||||
Scopes extends readonly Scope[] = InternallySupportedScopes[],
|
||||
> {
|
||||
token: string;
|
||||
sessionId: string;
|
||||
sessionId?: string;
|
||||
userId: string;
|
||||
referenceId?: string;
|
||||
clientId?: string;
|
||||
|
||||
Reference in New Issue
Block a user