mirror of
https://github.com/element-hq/element-desktop
synced 2025-04-21 17:13:57 +02:00
Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
bc4b6d3949
commit
c956c87337
16
src/store.ts
16
src/store.ts
@ -89,20 +89,22 @@ export class Store extends ElectronStore<{
|
|||||||
* @throws if safeStorage is not available.
|
* @throws if safeStorage is not available.
|
||||||
*/
|
*/
|
||||||
public async migrate(): Promise<void> {
|
public async migrate(): Promise<void> {
|
||||||
|
console.log("Store migration: started");
|
||||||
if (this.has("safeStorage")) return;
|
if (this.has("safeStorage")) return;
|
||||||
await app.whenReady();
|
|
||||||
if (!safeStorage.isEncryptionAvailable()) {
|
if (!safeStorage.isEncryptionAvailable()) {
|
||||||
throw new Error("SafeStorage is not available");
|
console.log("Store migration: safeStorage is not available");
|
||||||
|
throw new Error("safeStorage is not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
const credentials = [
|
const credentials = [
|
||||||
...(await keytar.findCredentials(LEGACY_KEYTAR_SERVICE)),
|
...(await keytar.findCredentials(LEGACY_KEYTAR_SERVICE)),
|
||||||
...(await keytar.findCredentials(KEYTAR_SERVICE)),
|
...(await keytar.findCredentials(KEYTAR_SERVICE)),
|
||||||
];
|
];
|
||||||
credentials.forEach((cred) => {
|
console.log("Store migration:", credentials);
|
||||||
this.deleteSecret(cred.account); // delete from keytar & keytar legacy
|
for (const cred of credentials) {
|
||||||
this.setSecret(cred.account, cred.password); // write to safeStorage & keytar for downgrade compatibility
|
await this.deleteSecret(cred.account); // delete from keytar & keytar legacy
|
||||||
});
|
await this.setSecret(cred.account, cred.password); // write to safeStorage & keytar for downgrade compatibility
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +144,7 @@ export class Store extends ElectronStore<{
|
|||||||
public async setSecret(key: string, secret: string): Promise<void> {
|
public async setSecret(key: string, secret: string): Promise<void> {
|
||||||
await this.safeStorageReady();
|
await this.safeStorageReady();
|
||||||
if (!safeStorage.isEncryptionAvailable()) {
|
if (!safeStorage.isEncryptionAvailable()) {
|
||||||
throw new Error("SafeStorage is not available");
|
throw new Error("safeStorage is not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptedValue = safeStorage.encryptString(secret);
|
const encryptedValue = safeStorage.encryptString(secret);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user