Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/core/src/services/keychainService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ vi.mock('../utils/events.js', () => ({
}));

vi.mock('../utils/debugLogger.js', () => ({
debugLogger: { log: vi.fn() },
debugLogger: { debug: vi.fn() },
}));

vi.mock('node:os', async (importOriginal) => {
Expand Down Expand Up @@ -153,14 +153,14 @@ describe('KeychainService', () => {

// Because it falls back to FileKeychain, it is always available.
expect(available).toBe(true);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('encountered an error'),
'locked',
);
expect(coreEvents.emitTelemetryKeychainAvailability).toHaveBeenCalledWith(
expect.objectContaining({ available: false }),
);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('Using FileKeychain fallback'),
);
expect(FileKeychain).toHaveBeenCalled();
Expand All @@ -173,7 +173,7 @@ describe('KeychainService', () => {
const available = await service.isAvailable();

expect(available).toBe(true);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('failed structural validation'),
expect.objectContaining({ getPassword: expect.any(Array) }),
);
Expand All @@ -191,7 +191,7 @@ describe('KeychainService', () => {
const available = await service.isAvailable();

expect(available).toBe(true);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('functional verification failed'),
);
expect(FileKeychain).toHaveBeenCalled();
Expand Down Expand Up @@ -243,7 +243,7 @@ describe('KeychainService', () => {
);
expect(mockKeytar.setPassword).not.toHaveBeenCalled();
expect(FileKeychain).toHaveBeenCalled();
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('MacOS default keychain not found'),
);
});
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/services/keychainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class KeychainService {
}

// If native failed or was skipped, return the secure file fallback.
debugLogger.log('Using FileKeychain fallback for secure storage.');
debugLogger.debug('Using FileKeychain fallback for secure storage.');
return new FileKeychain();
}

Expand All @@ -130,7 +130,7 @@ export class KeychainService {

// Probing macOS prevents process-blocking popups when no keychain exists.
if (os.platform() === 'darwin' && !this.isMacOSKeychainAvailable()) {
debugLogger.log(
debugLogger.debug(
'MacOS default keychain not found; skipping functional verification.',
);
return null;
Expand All @@ -140,12 +140,15 @@ export class KeychainService {
return keychainModule;
}

debugLogger.log('Keychain functional verification failed');
debugLogger.debug('Keychain functional verification failed');
return null;
} catch (error) {
// Avoid logging full error objects to prevent PII exposure.
const message = error instanceof Error ? error.message : String(error);
debugLogger.log('Keychain initialization encountered an error:', message);
debugLogger.debug(
'Keychain initialization encountered an error:',
message,
);
return null;
}
}
Expand All @@ -162,7 +165,7 @@ export class KeychainService {
return potential as Keychain;
}

debugLogger.log(
debugLogger.debug(
'Keychain module failed structural validation:',
result.error.flatten().fieldErrors,
);
Expand Down
Loading