Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2025-04-11 16:45:58 +01:00
parent bb314423bf
commit 600679c0f7
No known key found for this signature in database
GPG Key ID: A2B008A5F49F5D0D
2 changed files with 16 additions and 6 deletions

View File

@ -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);
});
});

View File

@ -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<void> {
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<void> {
await keytar.deletePassword(namespace, key);
}
}