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:
13
tests/__mocks__/electron.ts
Normal file
13
tests/__mocks__/electron.ts
Normal 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:', '');
|
||||
})
|
||||
};
|
||||
Reference in New Issue
Block a user