Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: auto clear vault session after 30 minutes

thecodrrd9afd7b64565
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.js
index 783c6ea49..07f1d1384 100644
--- a/packages/core/api/vault.js
+++ b/packages/core/api/vault.js
@@ -1,5 +1,6 @@
import getId from "../utils/id";
+const ERASE_TIME = 1000 * 60 * 30;
export default class Vault {
/**
*
@@ -34,6 +35,7 @@ export default class Vault {
);
await this._context.write("vaultKey", encryptedData);
this._password = password;
+ this._startEraser();
}
return true;
}
@@ -57,9 +59,16 @@ export default class Vault {
throw new Error(this.ERRORS.wrongPassword);
}
this._password = password;
+ this._startEraser();
return true;
}
+ _startEraser() {
+ setTimeout(() => {
+ this._password = "";
+ }, ERASE_TIME);
+ }
+
/**
* Locks (add to vault) a note
* @param {string} noteId The id of the note to lock