devibe
Version:
Intelligent repository cleanup with auto mode, AI learning, markdown consolidation, auto-consolidate workflow, context-aware classification, and cost optimization
86 lines • 2.21 kB
TypeScript
/**
* AI API Key Manager
*
* Securely stores API keys in user's home directory (.devibe/keys.json)
* Never commits keys to git, encrypted at rest.
*/
export interface StoredKeys {
anthropic?: string;
openai?: string;
google?: string;
}
export declare class AIKeyManager {
private keysPath;
private encryptionKey;
constructor();
/**
* Get a pseudo-unique machine identifier
*/
private getMachineId;
/**
* Encrypt data
*/
private encrypt;
/**
* Decrypt data
*/
private decrypt;
/**
* Ensure config directory exists
*/
private ensureConfigDir;
/**
* Load all stored keys
*/
loadKeys(): Promise<StoredKeys>;
/**
* Save all keys
*/
private saveKeys;
/**
* Add or update an API key
*/
setKey(provider: 'anthropic' | 'openai' | 'google', apiKey: string): Promise<void>;
/**
* Get a specific API key
*/
getKey(provider: 'anthropic' | 'openai' | 'google'): Promise<string | undefined>;
/**
* Remove an API key
*/
removeKey(provider: 'anthropic' | 'openai' | 'google'): Promise<void>;
/**
* Check which providers have keys configured
*/
getConfiguredProviders(): Promise<Array<'anthropic' | 'openai' | 'google'>>;
/**
* Validate an API key format (basic check)
*/
validateKeyFormat(provider: 'anthropic' | 'openai' | 'google', key: string): boolean;
/**
* Mask API key for display (show first/last 4 chars)
*/
maskKey(key: string): string;
/**
* Get storage location (for user info)
*/
getStorageLocation(): string;
/**
* Check if keys file exists
*/
hasStoredKeys(): Promise<boolean>;
/**
* Clear all keys (for testing or user request)
*/
clearAllKeys(): Promise<void>;
/**
* Get key from environment or stored config
*/
getKeyWithFallback(provider: 'anthropic' | 'openai' | 'google'): Promise<string | undefined>;
/**
* Get key from environment variable
*/
private getKeyFromEnv;
}
export declare function getKeyManager(): AIKeyManager;
//# sourceMappingURL=ai-key-manager.d.ts.map