Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2025-04-16 13:51:39 +01:00
parent 0298141e03
commit 0cdf4dfbec
No known key found for this signature in database
GPG Key ID: A2B008A5F49F5D0D
2 changed files with 19 additions and 9 deletions

View File

@ -464,8 +464,18 @@ app.on("ready", async () => {
console.log("No update_base_url is defined: auto update is disabled"); console.log("No update_base_url is defined: auto update is disabled");
} }
console.debug("Ensuring storage is ready"); // Set up i18n before loading storage as we need translations for dialogs
await store.safeStorageReady(); global.appLocalization = new AppLocalization({
components: [(): void => tray.initApplicationMenu(), (): void => Menu.setApplicationMenu(buildMenuTemplate())],
});
try {
console.debug("Ensuring storage is ready");
await store.safeStorageReady();
} catch (e) {
console.error(e);
app.exit(1);
}
// Load the previous window state with fallback to defaults // Load the previous window state with fallback to defaults
const mainWindowState = windowStateKeeper({ const mainWindowState = windowStateKeeper({
@ -561,10 +571,6 @@ app.on("ready", async () => {
webContentsHandler(global.mainWindow.webContents); webContentsHandler(global.mainWindow.webContents);
global.appLocalization = new AppLocalization({
components: [(): void => tray.initApplicationMenu(), (): void => Menu.setApplicationMenu(buildMenuTemplate())],
});
session.defaultSession.setDisplayMediaRequestHandler((_, callback) => { session.defaultSession.setDisplayMediaRequestHandler((_, callback) => {
global.mainWindow?.webContents.send("openDesktopCapturerSourcePicker"); global.mainWindow?.webContents.send("openDesktopCapturerSourcePicker");
setDisplayMediaCallback(callback); setDisplayMediaCallback(callback);

View File

@ -177,7 +177,7 @@ class Store extends ElectronStore<{
if (data) { if (data) {
for (const key in data) { for (const key in data) {
const plaintext = data[key]; const plaintext = data[key];
await this.setSecret(key, plaintext); await this.setSecretSafeStorage(key, plaintext);
} }
} }
} else if (safeStorageBackend in safeStorageBackendMap) { } else if (safeStorageBackend in safeStorageBackendMap) {
@ -239,7 +239,7 @@ class Store extends ElectronStore<{
]; ];
for (const cred of credentials) { for (const cred of credentials) {
console.info("Store migration: writing", cred); console.info("Store migration: writing", cred);
await this.setSecret(cred.account, cred.password); await this.setSecretSafeStorage(cred.account, cred.password);
console.info("Store migration: deleting", cred); console.info("Store migration: deleting", cred);
await this.deleteSecretKeytar(LEGACY_KEYTAR_SERVICE, cred.account); await this.deleteSecretKeytar(LEGACY_KEYTAR_SERVICE, cred.account);
} }
@ -290,9 +290,13 @@ class Store extends ElectronStore<{
throw new Error("safeStorage is not available"); throw new Error("safeStorage is not available");
} }
await this.setSecretSafeStorage(key, secret);
await keytar.setPassword(KEYTAR_SERVICE, key, secret);
}
private async setSecretSafeStorage(key: string, secret: string): Promise<void> {
const encryptedValue = safeStorage.encryptString(secret); const encryptedValue = safeStorage.encryptString(secret);
this.set(this.getSecretStorageKey(key), encryptedValue.toString("base64")); this.set(this.getSecretStorageKey(key), encryptedValue.toString("base64"));
await keytar.setPassword(KEYTAR_SERVICE, key, secret);
} }
/** /**