fix(coding-agent,ai): show env auth source in /login
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
import {
|
||||
getEnvApiKey,
|
||||
getEnvApiKeyInfo,
|
||||
type OAuthCredentials,
|
||||
type OAuthLoginCallbacks,
|
||||
type OAuthProviderId,
|
||||
@@ -32,6 +33,12 @@ export type AuthCredential = ApiKeyCredential | OAuthCredential;
|
||||
|
||||
export type AuthStorageData = Record<string, AuthCredential>;
|
||||
|
||||
export type AuthStatus = {
|
||||
configured: boolean;
|
||||
source?: "stored" | "runtime" | "environment" | "fallback";
|
||||
label?: string;
|
||||
};
|
||||
|
||||
type LockResult<T> = {
|
||||
result: T;
|
||||
next?: string;
|
||||
@@ -329,6 +336,30 @@ export class AuthStorage {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return auth status without exposing credential values or refreshing tokens.
|
||||
*/
|
||||
getAuthStatus(provider: string): AuthStatus {
|
||||
if (this.data[provider]) {
|
||||
return { configured: true, source: "stored" };
|
||||
}
|
||||
|
||||
if (this.runtimeOverrides.has(provider)) {
|
||||
return { configured: false, source: "runtime", label: "--api-key" };
|
||||
}
|
||||
|
||||
const envKey = getEnvApiKeyInfo(provider);
|
||||
if (envKey) {
|
||||
return { configured: false, source: "environment", label: envKey.label };
|
||||
}
|
||||
|
||||
if (this.fallbackResolver?.(provider)) {
|
||||
return { configured: false, source: "fallback", label: "custom provider config" };
|
||||
}
|
||||
|
||||
return { configured: false };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all credentials (for passing to getOAuthApiKey).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user