Ensure new passphrase is stored in keytar

This commit is contained in:
Germain Souquet 2021-04-23 15:35:09 +01:00
parent 1fa6671a17
commit b7dd4e53a3

View file

@ -98,12 +98,6 @@ if (argv["help"]) {
app.exit(); app.exit();
} }
function delay(timeout) {
return new Promise(res => {
setTimeout(() => res(), timeout);
});
}
// Electron creates the user data directory (with just an empty 'Dictionaries' directory...) // Electron creates the user data directory (with just an empty 'Dictionaries' directory...)
// as soon as the app path is set, so pick a random path in it that must exist if it's a // as soon as the app path is set, so pick a random path in it that must exist if it's a
// real user data directory. // real user data directory.
@ -508,7 +502,9 @@ async function getOrCreatePassphrase(key) {
if (storedPassphrase !== null) { if (storedPassphrase !== null) {
return storedPassphrase; return storedPassphrase;
} else { } else {
return await randomArray(32); const newPassphrase = await randomArray(32);
await keytar.setPassword("element.io", key, newPassphrase);
return newPassphrase;
} }
} catch (e) { } catch (e) {
console.log("Error getting the event index passphrase out of the secret store", e); console.log("Error getting the event index passphrase out of the secret store", e);