Chores: fix chutes oauth build

This commit is contained in:
Friederike Seiler
2026-01-11 16:01:53 +01:00
committed by Peter Steinberger
parent 0aba911912
commit 0efcfc0864
6 changed files with 113 additions and 95 deletions

View File

@@ -61,7 +61,9 @@ export function parseOAuthCallbackInput(
function coerceExpiresAt(expiresInSeconds: number, now: number): number {
const value =
now + Math.max(0, Math.floor(expiresInSeconds)) * 1000 - DEFAULT_EXPIRES_BUFFER_MS;
now +
Math.max(0, Math.floor(expiresInSeconds)) * 1000 -
DEFAULT_EXPIRES_BUFFER_MS;
return Math.max(value, now + 30_000);
}
@@ -121,7 +123,8 @@ export async function exchangeChutesCodeForTokens(params: {
const refresh = data.refresh_token?.trim();
const expiresIn = data.expires_in ?? 0;
if (!access) throw new Error("Chutes token exchange returned no access_token");
if (!access)
throw new Error("Chutes token exchange returned no access_token");
if (!refresh) {
throw new Error("Chutes token exchange returned no refresh_token");
}
@@ -201,4 +204,3 @@ export async function refreshChutesTokens(params: {
clientSecret,
} as unknown as ChutesStoredOAuth;
}