fix: OAuth tokens secure storage for Windows & Linux (#215)
* fix: OAuth tokens secure storage for Windows & Linux * fix: OAuth tokens secure storage for Windows & Linux #215 * fix: OAuth tokens secure storage for Windows & Linux #215 * fix: OAuth tokens secure storage for Windows & Linux #215
This commit is contained in:
@@ -18,7 +18,7 @@ import { createHash } from 'crypto'
|
||||
import { userInfo } from 'os'
|
||||
import { getOauthConfig } from 'src/constants/oauth.js'
|
||||
import { getClaudeConfigHomeDir } from '../envUtils.js'
|
||||
import type { SecureStorageData } from './types.js'
|
||||
import type { SecureStorageData } from './index.js'
|
||||
|
||||
// Suffix distinguishing the OAuth credentials keychain entry from the legacy
|
||||
// API key entry (which uses no suffix). Both share the service name base.
|
||||
@@ -26,7 +26,11 @@ import type { SecureStorageData } from './types.js'
|
||||
// orphan existing stored credentials.
|
||||
export const CREDENTIALS_SERVICE_SUFFIX = '-credentials'
|
||||
|
||||
export function getMacOsKeychainStorageServiceName(
|
||||
/**
|
||||
* Get the service/resource name for secure storage, scoped by CLAUDE_CONFIG_DIR
|
||||
* if it's set to a non-default location.
|
||||
*/
|
||||
export function getSecureStorageServiceName(
|
||||
serviceSuffix: string = '',
|
||||
): string {
|
||||
const configDir = getClaudeConfigHomeDir()
|
||||
@@ -40,6 +44,12 @@ export function getMacOsKeychainStorageServiceName(
|
||||
return `Claude Code${getOauthConfig().OAUTH_FILE_SUFFIX}${serviceSuffix}${dirHash}`
|
||||
}
|
||||
|
||||
export function getMacOsKeychainStorageServiceName(
|
||||
serviceSuffix: string = '',
|
||||
): string {
|
||||
return getSecureStorageServiceName(serviceSuffix)
|
||||
}
|
||||
|
||||
export function getUsername(): string {
|
||||
try {
|
||||
return process.env.USER || userInfo().username
|
||||
|
||||
Reference in New Issue
Block a user