diff --git a/packages/tm-core/src/auth/auth-manager.ts b/packages/tm-core/src/auth/auth-manager.ts index cd590d98..b5842160 100644 --- a/packages/tm-core/src/auth/auth-manager.ts +++ b/packages/tm-core/src/auth/auth-manager.ts @@ -167,7 +167,8 @@ export class AuthManager { } /** - * Check if authenticated + * Check if authenticated (credentials exist, regardless of expiration) + * @returns true if credentials are stored, including expired credentials */ isAuthenticated(): boolean { return this.credentialStore.hasCredentials(); diff --git a/packages/tm-core/src/auth/credential-store.ts b/packages/tm-core/src/auth/credential-store.ts index fd1983c3..1d4b2776 100644 --- a/packages/tm-core/src/auth/credential-store.ts +++ b/packages/tm-core/src/auth/credential-store.ts @@ -54,9 +54,12 @@ export class CredentialStore { /** * Get stored authentication credentials + * @param options.allowExpired - Whether to return expired credentials (default: true) * @returns AuthCredentials with expiresAt as number (milliseconds) for runtime use */ - getCredentials(options?: { allowExpired?: boolean }): AuthCredentials | null { + getCredentials({ + allowExpired = true + }: { allowExpired?: boolean } = {}): AuthCredentials | null { try { if (!fs.existsSync(this.config.configFile)) { return null; @@ -89,9 +92,7 @@ export class CredentialStore { authData.expiresAt = expiresAtMs; // Check if the token has expired (with clock skew tolerance) - // Default to allowExpired=true to enable refresh flows const now = Date.now(); - const allowExpired = options?.allowExpired ?? true; if (now >= expiresAtMs - this.CLOCK_SKEW_MS && !allowExpired) { this.logger.warn( 'Authentication token has expired or is about to expire', @@ -201,6 +202,7 @@ export class CredentialStore { /** * Check if credentials exist (regardless of expiration status) + * @returns true if credentials are stored, including expired credentials */ hasCredentials(): boolean { const credentials = this.getCredentials({ allowExpired: true });