diff --git a/src/cli/handlers/auth.ts b/src/cli/handlers/auth.ts index 66d2eaa15..21a2cd2e2 100644 --- a/src/cli/handlers/auth.ts +++ b/src/cli/handlers/auth.ts @@ -142,8 +142,6 @@ async function coStrictLogin(): Promise { const expiryDate = extractExpiryFromJWT(tokens.access_token) await saveCoStrictCredentials({ - id: 'csc', - name: 'CSC Auth', access_token: tokens.access_token, refresh_token: tokens.refresh_token, state, diff --git a/src/commands/model/model.tsx b/src/commands/model/model.tsx index 942f62533..636075dc5 100644 --- a/src/commands/model/model.tsx +++ b/src/commands/model/model.tsx @@ -92,8 +92,6 @@ function ModelPickerWrapper({ // 保存凭证 const expiryDate = extractExpiryFromJWT(tokens.access_token) await saveCoStrictCredentials({ - id: 'csc', - name: 'CSC Auth', access_token: tokens.access_token, refresh_token: tokens.refresh_token, state, diff --git a/src/components/ConsoleOAuthFlow.tsx b/src/components/ConsoleOAuthFlow.tsx index 0d914873e..ca6ebc0a2 100644 --- a/src/components/ConsoleOAuthFlow.tsx +++ b/src/components/ConsoleOAuthFlow.tsx @@ -540,8 +540,6 @@ function OAuthStatusMessage({ // 保存凭证 const expiryDate = extractExpiryFromJWT(tokens.access_token) await saveCoStrictCredentials({ - id: 'csc', - name: 'CSC Auth', access_token: tokens.access_token, refresh_token: tokens.refresh_token, state, diff --git a/src/costrict/provider/auth.ts b/src/costrict/provider/auth.ts index 9344db0b4..53bcb8b23 100644 --- a/src/costrict/provider/auth.ts +++ b/src/costrict/provider/auth.ts @@ -174,8 +174,6 @@ export async function loginCoStrict( const expiryDate = extractExpiryFromJWT(tokens.access_token) const credentials: CoStrictCredentials = { - id: 'csc', - name: 'CSC Auth', access_token: tokens.access_token, refresh_token: tokens.refresh_token, state, diff --git a/src/costrict/provider/credentials.ts b/src/costrict/provider/credentials.ts index 88e4793e3..6a8544793 100644 --- a/src/costrict/provider/credentials.ts +++ b/src/costrict/provider/credentials.ts @@ -6,14 +6,12 @@ import { promises as fs } from 'node:fs' import { join } from 'node:path' import { createHash } from 'node:crypto' -import { getClaudeConfigHomeDir } from '../../utils/envUtils.js' +import { homedir } from 'node:os' /** - * CoStrict 凭证格式 (与 IDE 插件兼容) + * CoStrict 凭证格式 */ export interface CoStrictCredentials { - id: string // 标识符 - name: string // 显示名称 access_token: string // OAuth 访问令牌 refresh_token?: string // OAuth 刷新令牌 (可选) state?: string // OAuth 状态标识 (可选) @@ -24,11 +22,13 @@ export interface CoStrictCredentials { expired_at?: string // Token 过期时间 (ISO 8601) } +const COSTRICT_CONFIG_DIR = join(homedir(), '.costrict', 'share') + /** - * 获取 ~/.claude/csc-auth.json 路径 + * 获取 ~/.costrict/share/auth.json 路径 */ export function getCoStrictCredentialsPath(): string { - return join(getClaudeConfigHomeDir(), 'csc-auth.json') + return join(COSTRICT_CONFIG_DIR, 'auth.json') } /** @@ -68,7 +68,7 @@ export async function saveCoStrictCredentials( credentials: CoStrictCredentials, ): Promise { const filepath = getCoStrictCredentialsPath() - await fs.mkdir(getClaudeConfigHomeDir(), { recursive: true }) + await fs.mkdir(COSTRICT_CONFIG_DIR, { recursive: true }) await fs.writeFile(filepath, JSON.stringify(credentials, null, 2) + '\n', { encoding: 'utf-8', mode: 0o600,