source dump of claude code
at main 19 lines 674 B view raw
1import { execa } from 'execa' 2import { getMacOsKeychainStorageServiceName } from 'src/utils/secureStorage/macOsKeychainHelpers.js' 3 4export async function maybeRemoveApiKeyFromMacOSKeychainThrows(): Promise<void> { 5 if (process.platform === 'darwin') { 6 const storageServiceName = getMacOsKeychainStorageServiceName() 7 const result = await execa( 8 `security delete-generic-password -a $USER -s "${storageServiceName}"`, 9 { shell: true, reject: false }, 10 ) 11 if (result.exitCode !== 0) { 12 throw new Error('Failed to delete keychain entry') 13 } 14 } 15} 16 17export function normalizeApiKeyForConfig(apiKey: string): string { 18 return apiKey.slice(-20) 19}