Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compass): display warning message to user when Compass cannot access credential storage COMPASS-7819 #6056

Merged
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
15 changes: 15 additions & 0 deletions packages/compass/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { globalAppRegistry } from 'hadron-app-registry';
import { defaultPreferencesInstance } from 'compass-preferences-model';
import semver from 'semver';
import { CompassElectron } from './components/entrypoint';
import { openToast } from '@mongodb-js/compass-components';

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

async function checkSecretStorageIsAvailable(): Promise<boolean> {
return await ipcRenderer?.call('compass:check-secret-storage-is-available');
}

/**
* The top-level application singleton that brings everything together!
*/
Expand Down Expand Up @@ -212,6 +217,7 @@ const Application = View.extend({
(): Promise<AutoConnectPreferences> => {
return Promise.resolve(initialAutoConnectPreferences);
};
const isSecretStorageAvailable = await checkSecretStorageIsAvailable();
const connectionStorage = new CompassRendererConnectionStorage(
ipcRenderer,
getInitialAutoConnectPreferences
Expand Down Expand Up @@ -253,6 +259,15 @@ const Application = View.extend({
this.queryByHook('layout-container')
);

if (!isSecretStorageAvailable) {
openToast('secret-storage-not-available', {
variant: 'warning',
title:
'Compass cannot access credential storage. You can still connect, but please note that passwords will not be saved.',
alenakhineika marked this conversation as resolved.
Show resolved Hide resolved
});
track('Secret Storage Not Available');
}

document.querySelector('#loading-placeholder')?.remove();
},
updateAppVersion: async function () {
Expand Down
9 changes: 9 additions & 0 deletions packages/compass/src/main/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class CompassApplication {
safeStorage.setUsePlainTextEncryption(true);
}

// Accessing isEncryptionAvailable is not allowed when app is not ready on Windows
// https://github.com/electron/electron/issues/33640
await app.whenReady();
log.info(
mongoLogId(1_001_000_307),
'Application',
Expand Down Expand Up @@ -230,6 +233,12 @@ class CompassApplication {
debug('Did not agree to license, quitting app.');
app.quit();
},
'compass:check-secret-storage-is-available': async function () {
// Accessing isEncryptionAvailable is not allowed when app is not ready on Windows
// https://github.com/electron/electron/issues/33640
await app.whenReady();
return safeStorage.isEncryptionAvailable();
alenakhineika marked this conversation as resolved.
Show resolved Hide resolved
alenakhineika marked this conversation as resolved.
Show resolved Hide resolved
},
});

ipcMain?.handle('coverage', () => {
Expand Down
Loading