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: export errors
thecodrr766bc9ff51ab
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.jsindex 2c10fc0a9..a84a69cf6 100644--- a/packages/core/api/vault.js+++ b/packages/core/api/vault.js@@ -1,9 +1,5 @@import Database from "./index";-const ERRORS = {- noVault: "ERR_NO_VAULT",- vaultLocked: "ERR_VAULT_LOCKED"-};export default class Vault {/***@@ -16,6 +12,12 @@ export default class Vault {this._password = "";}+ ERRORS = {+ noVault: "ERR_NO_VAULT",+ vaultLocked: "ERR_VAULT_LOCKED",+ wrongPassword: "ERR_WRONG_PASSWORD"+ };+async create(password) {const lockKey = await this._context.read("lockKey");if (!lockKey || !lockKey.cipher || !lockKey.iv) {@@ -33,10 +35,10 @@ export default class Vault {try {data = await this._context.decrypt(password, lockKey);} catch (e) {- throw new Error("ERR_WRNG_PWD");+ throw new Error(this.ERRORS.wrongPassword);}if (data !== this._key) {- throw new Error("ERR_WRNG_PWD");+ throw new Error(this.ERRORS.wrongPassword);}this._password = password;return true;@@ -53,11 +55,11 @@ export default class Vault {async _check() {if (!(await this._exists())) {- throw new Error(ERRORS.noVault);+ throw new Error(this.ERRORS.noVault);}if (await this._locked()) {- throw new Error(ERRORS.vaultLocked);+ throw new Error(this.ERRORS.vaultLocked);}}