A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
refactor: use _getKey & _setKey functions for db access
thecodrr2943e91f2d95
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.jsindex 03e308a34..df1e4d5e9 100644--- a/packages/core/api/vault.js+++ b/packages/core/api/vault.js@@ -50,13 +50,13 @@ export default class Vault {async create(password) {if (!(await checkIsUserPremium(CHECK_IDS.vaultAdd))) return;- const vaultKey = await this._storage.read("vaultKey");+ const vaultKey = await this._getKey();if (!vaultKey || !vaultKey.cipher || !vaultKey.iv) {const encryptedData = await this._storage.encrypt({ password },this._key);- await this._storage.write("vaultKey", encryptedData);+ await this._setKey(encryptedData);this._password = password;}return true;@@ -69,7 +69,7 @@ export default class Vault {* @returns {Promise<Boolean>}*/async unlock(password) {- const vaultKey = await this._storage.read("vaultKey");+ const vaultKey = await this._getKey();if (!(await this.exists(vaultKey))) throw new Error(this.ERRORS.noVault);try {await this._storage.decrypt({ password }, vaultKey);@@ -186,7 +186,7 @@ export default class Vault {}async exists(vaultKey) {- if (!vaultKey) vaultKey = await this._storage.read("vaultKey");+ if (!vaultKey) vaultKey = await this._getKey();return vaultKey && vaultKey.cipher && vaultKey.iv;}@@ -309,7 +309,7 @@ export default class Vault {/** @inner */async _getKey() {- if (await this.exists()) return await this._storage.read("vaultKey");+ return await this._storage.read("vaultKey");}/** @inner */