fix: 移除闲置字段id/name,认证文件路径改为~/.costrict/share/auth.json
Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
This commit is contained in:
parent
ef151d84ba
commit
902b7d4ed5
|
|
@ -142,8 +142,6 @@ async function coStrictLogin(): Promise<void> {
|
|||
|
||||
const expiryDate = extractExpiryFromJWT(tokens.access_token)
|
||||
await saveCoStrictCredentials({
|
||||
id: 'csc',
|
||||
name: 'CSC Auth',
|
||||
access_token: tokens.access_token,
|
||||
refresh_token: tokens.refresh_token,
|
||||
state,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user