From 902b7d4ed5cc04d5219a5a4fcf05adbff1d5950d Mon Sep 17 00:00:00 2001 From: Askhz <1361267452@qq.com> Date: Wed, 13 May 2026 09:54:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E9=97=B2=E7=BD=AE?= =?UTF-8?q?=E5=AD=97=E6=AE=B5id/name=EF=BC=8C=E8=AE=A4=E8=AF=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E6=94=B9=E4=B8=BA~/.costrict/share/?= =?UTF-8?q?auth.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: CoStrict-DeepSeek-V4-Pro --- src/cli/handlers/auth.ts | 2 -- src/commands/model/model.tsx | 2 -- src/components/ConsoleOAuthFlow.tsx | 2 -- src/costrict/provider/auth.ts | 2 -- src/costrict/provider/credentials.ts | 14 +++++++------- 5 files changed, 7 insertions(+), 15 deletions(-) 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,