Skip to content

Commit 5d039d3

Browse files
feat(compass): display warning message to user when Compass cannot access cred… (#6056)
* feat: display warning message to user when Compass cannot access credential storage COMPASS-7819 * feat: track secret storage not available * fix: await for app be ready before sending telemetry
1 parent 3d110bd commit 5d039d3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/compass/src/app/index.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { globalAppRegistry } from 'hadron-app-registry';
99
import { defaultPreferencesInstance } from 'compass-preferences-model';
1010
import semver from 'semver';
1111
import { CompassElectron } from './components/entrypoint';
12+
import { openToast } from '@mongodb-js/compass-components';
1213

1314
// https://github.com/nodejs/node/issues/40537
1415
dns.setDefaultResultOrder('ipv4first');
@@ -114,6 +115,10 @@ async function getWindowAutoConnectPreferences(): Promise<AutoConnectPreferences
114115
return await ipcRenderer?.call('compass:get-window-auto-connect-preferences');
115116
}
116117

118+
async function checkSecretStorageIsAvailable(): Promise<boolean> {
119+
return await ipcRenderer?.call('compass:check-secret-storage-is-available');
120+
}
121+
117122
/**
118123
* The top-level application singleton that brings everything together!
119124
*/
@@ -212,6 +217,7 @@ const Application = View.extend({
212217
(): Promise<AutoConnectPreferences> => {
213218
return Promise.resolve(initialAutoConnectPreferences);
214219
};
220+
const isSecretStorageAvailable = await checkSecretStorageIsAvailable();
215221
const connectionStorage = new CompassRendererConnectionStorage(
216222
ipcRenderer,
217223
getInitialAutoConnectPreferences
@@ -253,6 +259,15 @@ const Application = View.extend({
253259
this.queryByHook('layout-container')
254260
);
255261

262+
if (!isSecretStorageAvailable) {
263+
openToast('secret-storage-not-available', {
264+
variant: 'warning',
265+
title:
266+
'Compass cannot access credential storage. You can still connect, but please note that passwords will not be saved.',
267+
});
268+
track('Secret Storage Not Available');
269+
}
270+
256271
document.querySelector('#loading-placeholder')?.remove();
257272
},
258273
updateAppVersion: async function () {

packages/compass/src/main/application.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class CompassApplication {
101101
safeStorage.setUsePlainTextEncryption(true);
102102
}
103103

104+
// Accessing isEncryptionAvailable is not allowed when app is not ready on Windows
105+
// https://github.com/electron/electron/issues/33640
106+
await app.whenReady();
104107
log.info(
105108
mongoLogId(1_001_000_307),
106109
'Application',
@@ -230,6 +233,12 @@ class CompassApplication {
230233
debug('Did not agree to license, quitting app.');
231234
app.quit();
232235
},
236+
'compass:check-secret-storage-is-available': async function () {
237+
// Accessing isEncryptionAvailable is not allowed when app is not ready on Windows
238+
// https://github.com/electron/electron/issues/33640
239+
await app.whenReady();
240+
return safeStorage.isEncryptionAvailable();
241+
},
233242
});
234243

235244
ipcMain?.handle('coverage', () => {

0 commit comments

Comments
 (0)