Skip to content

Commit 7633ed1

Browse files
committed
fix(auth): complete refresh-service imports
1 parent 35046b1 commit 7633ed1

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

packages/agent-core-v2/src/app/auth/authService.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { join } from 'pathe';
99

1010
import { ScopeActivation, registerScopedService } from '#/_base/di/scope';
11+
import { Error2 } from '#/_base/errors/errors';
1112
import { type ILogger, ILogService } from '#/_base/log/log';
1213
import { IBootstrapService } from '#/app/bootstrap/bootstrap';
1314
import { IConfigService } from '#/app/config/config';
@@ -31,6 +32,7 @@ import {
3132
IAuthSummaryService,
3233
IOAuthTokenService,
3334
} from './auth';
35+
import { AuthErrors } from './errors';
3436

3537
const REFRESH_BUFFER_SECONDS = 5 * 60;
3638

@@ -88,8 +90,6 @@ export class OAuthTokenService implements IOAuthTokenService {
8890
const refreshed = await this.refreshSingleFlight(storageName, token);
8991
return refreshed.accessToken;
9092
} catch (error) {
91-
// A proactive refresh may fail transiently while the current token is still
92-
// valid. A forced refresh follows a 401 and must not replay the stale token.
9393
if (!force && token.expiresAt > nowSeconds) return token.accessToken;
9494
throw error;
9595
}
@@ -114,7 +114,9 @@ export class OAuthTokenService implements IOAuthTokenService {
114114
const provider = token.metadata?.['provider'];
115115
if (provider === 'kimi') {
116116
const deviceId = token.metadata?.['deviceId'];
117-
if (deviceId === undefined || deviceId.length === 0) throw new Error('Kimi OAuth credential is missing deviceId metadata.');
117+
if (deviceId === undefined || deviceId.length === 0) {
118+
throw new Error('Kimi OAuth credential is missing deviceId metadata.');
119+
}
118120
const refreshed = await refreshKimiOAuthToken(token.refreshToken, deviceId);
119121
return {
120122
accessToken: refreshed.accessToken,
@@ -128,7 +130,9 @@ export class OAuthTokenService implements IOAuthTokenService {
128130
}
129131
if (provider === 'minimax') {
130132
const region = token.metadata?.['region'];
131-
if (region !== 'global' && region !== 'cn') throw new Error('MiniMax OAuth credential has invalid region metadata.');
133+
if (region !== 'global' && region !== 'cn') {
134+
throw new Error('MiniMax OAuth credential has invalid region metadata.');
135+
}
132136
const refreshed = await refreshMiniMaxOAuthToken(region, token.refreshToken);
133137
return {
134138
accessToken: refreshed.accessToken,

0 commit comments

Comments
 (0)