feat: add API key encryption utilities using Electron safeStorage

Implement encryption utilities for securely storing API keys:
- encryptApiKey(): encrypts keys using Electron safeStorage with base64 encoding
- decryptApiKey(): decrypts stored keys
- isEncryptionAvailable(): checks platform support

Encryption falls back to plaintext on platforms without keyring support.
Includes comprehensive test coverage with Electron mock.
This commit is contained in:
2025-10-25 21:02:15 -04:00
parent fb959338c3
commit cb21681dd0
3 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/**
* Mock Electron API for testing
* This provides minimal mocks for the Electron types used in tests
*/
export const safeStorage = {
isEncryptionAvailable: jest.fn(() => true),
encryptString: jest.fn((data: string) => Buffer.from(`encrypted:${data}`)),
decryptString: jest.fn((buffer: Buffer) => {
const str = buffer.toString();
return str.replace('encrypted:', '');
})
};