Skip to content

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

feat: expose method to check if vault exists

thecodrrd002c445a48d
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.js
index 599b55a43..d24e2f15d 100644
--- a/packages/core/api/vault.js
+++ b/packages/core/api/vault.js
@@ -49,7 +49,7 @@ export default class Vault {
*/
async unlock(password) {
const vaultKey = await this._context.read("vaultKey");
- if (!(await this._exists(vaultKey))) throw new Error(this.ERRORS.noVault);
+ if (!(await this.exists(vaultKey))) throw new Error(this.ERRORS.noVault);
var data;
try {
data = await this._context.decrypt({ password }, vaultKey);
@@ -116,14 +116,13 @@ export default class Vault {
return await this._lockNote(note);
}
- // Private & internal methods
-
- /** @private */
- async _exists(vaultKey) {
+ async exists(vaultKey) {
if (!vaultKey) vaultKey = await this._context.read("vaultKey");
return vaultKey && vaultKey.cipher && vaultKey.iv;
}
+ // Private & internal methods
+
/** @private */
_locked() {
return !this._password || !this._password.length;
@@ -131,7 +130,7 @@ export default class Vault {
/** @private */
async _check() {
- if (!(await this._exists())) {
+ if (!(await this.exists())) {
throw new Error(this.ERRORS.noVault);
}
@@ -208,7 +207,7 @@ export default class Vault {
/** @inner */
async _getKey() {
- if (await this._exists()) return await this._context.read("vaultKey");
+ if (await this.exists()) return await this._context.read("vaultKey");
}
/** @inner */