From 600679c0f707ae4e46cec988256b077d74a791fd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 11 Apr 2025 16:45:58 +0100 Subject: [PATCH] Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- playwright/e2e/launch/launch.spec.ts | 10 ++++++++-- src/store.ts | 12 ++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/playwright/e2e/launch/launch.spec.ts b/playwright/e2e/launch/launch.spec.ts index f47ebcbc..2d3f21e2 100644 --- a/playwright/e2e/launch/launch.spec.ts +++ b/playwright/e2e/launch/launch.spec.ts @@ -57,7 +57,10 @@ test.describe("App launch", () => { test("should be supported", async ({ page }) => { await expect( - page.evaluate(() => window.mxPlatformPeg.get().createPickleKey(userId, deviceId)), + page.evaluate( + ([userId, deviceId]) => window.mxPlatformPeg.get().createPickleKey(userId, deviceId), + [userId, deviceId], + ), ).resolves.not.toBeNull(); }); @@ -70,7 +73,10 @@ test.describe("App launch", () => { test("should migrate successfully", async ({ page }) => { await expect( - page.evaluate(() => window.mxPlatformPeg.get().getPickleKey(userId, deviceId)), + page.evaluate( + ([userId, deviceId]) => window.mxPlatformPeg.get().getPickleKey(userId, deviceId), + [userId, deviceId], + ), ).resolves.toBe(pickleKey); }); }); diff --git a/src/store.ts b/src/store.ts index 272822c7..d9369f52 100644 --- a/src/store.ts +++ b/src/store.ts @@ -101,8 +101,8 @@ export class Store extends ElectronStore<{ ...(await keytar.findCredentials(KEYTAR_SERVICE)), ]; for (const cred of credentials) { - await this.deleteSecret(cred.account); // delete from keytar & keytar legacy - await this.setSecret(cred.account, cred.password); // write to safeStorage & keytar for downgrade compatibility + await this.deleteSecretKeytar(LEGACY_KEYTAR_SERVICE, cred.account); + await this.setSecret(cred.account, cred.password); } console.info(`Store migration done: found ${credentials.length} credentials`); } @@ -161,10 +161,14 @@ export class Store extends ElectronStore<{ public async deleteSecret(key: string): Promise { await this.safeStorageReady(); - await keytar.deletePassword(LEGACY_KEYTAR_SERVICE, key); - await keytar.deletePassword(KEYTAR_SERVICE, key); + await this.deleteSecretKeytar(LEGACY_KEYTAR_SERVICE, key); + await this.deleteSecretKeytar(KEYTAR_SERVICE, key); if (safeStorage.isEncryptionAvailable()) { this.delete(this.getSecretStorageKey(key)); } } + + private async deleteSecretKeytar(namespace: string, key: string): Promise { + await keytar.deletePassword(namespace, key); + } }