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
fix: properly clear data from memory on logout
thecodrr2aa0fa592c57
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.jsindex 524adddae..783c6ea49 100644--- a/packages/core/api/vault.js+++ b/packages/core/api/vault.js@@ -15,6 +15,9 @@ export default class Vault {vaultLocked: "ERR_VAULT_LOCKED",wrongPassword: "ERR_WRONG_PASSWORD",};+ this._db.ev.subscribe("user:loggedOut", () => {+ this._password = "";+ });}/**diff --git a/packages/core/collections/collection.js b/packages/core/collections/collection.jsindex bf74ee8d0..6e08cf091 100644--- a/packages/core/collections/collection.js+++ b/packages/core/collections/collection.js@@ -8,7 +8,10 @@ class Collection {if (collection.init) await collection.init();if (collection._collection.clear)- db.ev.subscribe("user:loggedOut", () => collection._collection.clear());+ db.ev.subscribe(+ "user:loggedOut",+ async () => await collection._collection.clear()+ );return collection;}diff --git a/packages/core/database/cached-collection.js b/packages/core/database/cached-collection.jsindex 07492d78a..36092c1a0 100644--- a/packages/core/database/cached-collection.js+++ b/packages/core/database/cached-collection.js@@ -14,8 +14,9 @@ export default class CachedCollection {if (data.length > 0) this.map = new Map(data);}- clear() {+ async clear() {this.map.clear();+ await this.indexer.clear();}/**diff --git a/packages/core/database/indexed-collection.js b/packages/core/database/indexed-collection.jsindex 5ab0dfc16..6f3b06f8e 100644--- a/packages/core/database/indexed-collection.js+++ b/packages/core/database/indexed-collection.js@@ -5,6 +5,10 @@ export default class IndexedCollection {this.indexer = new Indexer(context, type);}+ clear() {+ return this.indexer.clear();+ }+async init() {await this.indexer.init();}@@ -34,7 +38,7 @@ export default class IndexedCollection {id,deleted: true,dateCreated: Date.now(),- dateEdited: Date.now()+ dateEdited: Date.now(),});}diff --git a/packages/core/database/indexer.js b/packages/core/database/indexer.jsindex 62bb84605..5623b4657 100644--- a/packages/core/database/indexer.js+++ b/packages/core/database/indexer.js@@ -28,4 +28,9 @@ export default class Indexer extends Storage {this.indices.splice(this.indices.indexOf(key), 1);await this.write(this.type, this.indices);}++ async clear() {+ this.indices = [];+ await super.clear();+ }}