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
feat: no need for integrity check for encrypted backups
thecodrr7473f630069c
diff --git a/packages/core/database/backup.js b/packages/core/database/backup.jsindex a2bf0824b..32193d1d8 100644--- a/packages/core/database/backup.js+++ b/packages/core/database/backup.js@@ -39,22 +39,23 @@ export default class Backup {);let data = Object.fromEntries(await this._db.context.readMulti(keys));+ let hash = {};if (encrypt) {const key = await this._db.user.getEncryptionKey();data = await this._db.context.encrypt(key, JSON.stringify(data));+ } else {+ hash = { hash: SparkMD5.hash(JSON.stringify(data)), hash_type: "md5" };}// save backup timeawait this._db.context.write("lastBackupTime", Date.now());-return JSON.stringify({version: CURRENT_DATABASE_VERSION,type,date: Date.now(),data,- hash: SparkMD5.hash(JSON.stringify(data)),- hash_type: "md5",+ ...hash,});}@@ -71,15 +72,13 @@ export default class Backup {backup = this._migrateBackup(backup);- if (!this._verify(backup))- throw new Error("Backup file has been tempered, aborting...");-let db = backup.data;//check if we have encrypted dataif (db.salt && db.iv) {if (!key) key = await this._db.user.getEncryptionKey();backup.data = JSON.parse(await this._db.context.decrypt(key, db));- }+ } else if (!this._verify(backup))+ throw new Error("Backup file has been tempered, aborting...");await this._migrateData(backup);}