mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
feat(copilot): add GitHub Enterprise Server support (#2175)
* feat(copilot): add GitHub Enterprise Server support * fix(copilot): address GHES PR review findings (P1 + 2×P2) - P1: Use composite account ID (domain:user_id) for GHES to prevent cross-instance ID collisions; github.com keeps plain numeric ID for backward compatibilit - P2-a: Use get_api_endpoint() for model list URL with automatic fallback to static URL when dynamic endpoint resolution fails - P2-b: Add normalize_github_domain() as backend SSOT for domain normalization (lowercase, strip protocol/path/query, reject userinfo) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ export interface ManagedAuthAccount {
|
||||
avatar_url: string | null;
|
||||
authenticated_at: number;
|
||||
is_default: boolean;
|
||||
github_domain: string;
|
||||
}
|
||||
|
||||
export interface ManagedAuthStatus {
|
||||
@@ -30,19 +31,23 @@ export interface ManagedAuthDeviceCodeResponse {
|
||||
|
||||
export async function authStartLogin(
|
||||
authProvider: ManagedAuthProvider,
|
||||
githubDomain?: string,
|
||||
): Promise<ManagedAuthDeviceCodeResponse> {
|
||||
return invoke<ManagedAuthDeviceCodeResponse>("auth_start_login", {
|
||||
authProvider,
|
||||
githubDomain: githubDomain || null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function authPollForAccount(
|
||||
authProvider: ManagedAuthProvider,
|
||||
deviceCode: string,
|
||||
githubDomain?: string,
|
||||
): Promise<ManagedAuthAccount | null> {
|
||||
return invoke<ManagedAuthAccount | null>("auth_poll_for_account", {
|
||||
authProvider,
|
||||
deviceCode,
|
||||
githubDomain: githubDomain || null,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ export interface GitHubAccount {
|
||||
avatar_url: string | null;
|
||||
/** 认证时间戳(Unix 秒) */
|
||||
authenticated_at: number;
|
||||
/** GitHub 域名(github.com 或 GHES 域名) */
|
||||
github_domain: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user