Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2025-04-11 09:19:46 +01:00
parent 3e68efc894
commit 26a30ce22b
No known key found for this signature in database
GPG Key ID: A2B008A5F49F5D0D

View File

@ -86,6 +86,7 @@ export class Store extends ElectronStore<{
/** /**
* Migrates keytar data to safeStorage, * Migrates keytar data to safeStorage,
* deletes data from legacy keytar but keeps it in the new keytar for downgrade compatibility. * deletes data from legacy keytar but keeps it in the new keytar for downgrade compatibility.
* @throws if safeStorage is not available.
*/ */
public async migrate(): Promise<void> { public async migrate(): Promise<void> {
if (this.has("safeStorage")) return; if (this.has("safeStorage")) return;
@ -157,12 +158,11 @@ export class Store extends ElectronStore<{
*/ */
public async deleteSecret(key: string): Promise<void> { public async deleteSecret(key: string): Promise<void> {
await this.safeStorageReady(); await this.safeStorageReady();
if (!safeStorage.isEncryptionAvailable()) {
throw new Error("SafeStorage is not available");
}
this.delete(this.getSecretStorageKey(key));
await keytar.deletePassword(LEGACY_KEYTAR_SERVICE, key); await keytar.deletePassword(LEGACY_KEYTAR_SERVICE, key);
await keytar.deletePassword(KEYTAR_SERVICE, key); await keytar.deletePassword(KEYTAR_SERVICE, key);
if (safeStorage.isEncryptionAvailable()) {
this.delete(this.getSecretStorageKey(key));
}
} }
} }