Skip to content

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

feat: disable at rest encryption

thecodrr32545d432038
diff --git a/packages/core/api/sync/collector.js b/packages/core/api/sync/collector.js
index 9b1d88ac7..995a1fb98 100644
--- a/packages/core/api/sync/collector.js
+++ b/packages/core/api/sync/collector.js
@@ -16,10 +16,15 @@ class Collector {
this._lastSyncedTimestamp = lastSyncedTimestamp;
this.key = await this._db.user.getEncryptionKey();
return {
- notes: this._collect(await this._db.notes.encrypted()),
- notebooks: this._collect(await this._db.notebooks.encrypted()),
- content: this._collect(await this._db.content.encrypted()),
- attachments: this._collect(this._collect(this._db.attachments.syncable)),
+ // notes: this._collect(await this._db.notes.encrypted()),
+ // notebooks: this._collect(await this._db.notebooks.encrypted()),
+ // content: this._collect(await this._db.content.encrypted()),
+ notes: await this._encrypt(this._collect(this._db.notes.raw)),
+ notebooks: await this._encrypt(this._collect(this._db.notebooks.raw)),
+ content: await this._encrypt(this._collect(await this._db.content.all())),
+ attachments: await this._encrypt(
+ this._collect(this._collect(this._db.attachments.syncable))
+ ),
settings: await this._encrypt(this._collect([this._db.settings.raw])),
vaultKey: await this._serialize(await this._db.vault._getKey()),
};
diff --git a/packages/core/database/cached-collection.js b/packages/core/database/cached-collection.js
index 102c7d23d..60d71ee4a 100644
--- a/packages/core/database/cached-collection.js
+++ b/packages/core/database/cached-collection.js
@@ -15,17 +15,17 @@ export default class CachedCollection extends IndexedCollection {
let data = await this.indexer.readMulti(this.indexer.indices);
if (this.map && this.map.dispose) this.map.dispose();
- const encryptionKey =
- this.encryptionKeyFactory && (await this.encryptionKeyFactory());
- if (encryptionKey) {
- for (let item of data) {
- const [_key, value] = item;
- const decryptedValue = JSON.parse(
- await this.indexer.decrypt(encryptionKey, value)
- );
- item[1] = decryptedValue;
- }
- }
+ // const encryptionKey =
+ // this.encryptionKeyFactory && (await this.encryptionKeyFactory());
+ // if (encryptionKey) {
+ // for (let item of data) {
+ // const [_key, value] = item;
+ // const decryptedValue = JSON.parse(
+ // await this.indexer.decrypt(encryptionKey, value)
+ // );
+ // item[1] = decryptedValue;
+ // }
+ // }
this.map = new MapStub.Map(data, this.type);
}
diff --git a/packages/core/database/indexed-collection.js b/packages/core/database/indexed-collection.js
index 5ea96bdaa..5cbd1e03a 100644
--- a/packages/core/database/indexed-collection.js
+++ b/packages/core/database/indexed-collection.js
@@ -37,17 +37,19 @@ export default class IndexedCollection {
delete item.remote;
delete item.migrated;
- if (await this.getEncryptionKey()) {
- const encrypted = await this.indexer.encrypt(
- await this.getEncryptionKey(),
- JSON.stringify(item)
- );
- encrypted.dateModified = item.dateModified;
- encrypted.localOnly = item.localOnly;
- encrypted.migrated = item.migrated;
- encrypted.id = item.id;
- await this.indexer.write(item.id, encrypted);
- } else await this.indexer.write(item.id, item);
+ // if (await this.getEncryptionKey()) {
+ // const encrypted = await this.indexer.encrypt(
+ // await this.getEncryptionKey(),
+ // JSON.stringify(item)
+ // );
+ // encrypted.dateModified = item.dateModified;
+ // encrypted.localOnly = item.localOnly;
+ // encrypted.migrated = item.migrated;
+ // encrypted.id = item.id;
+ // await this.indexer.write(item.id, encrypted);
+ // } else
+
+ await this.indexer.write(item.id, item);
}
removeItem(id) {
@@ -72,11 +74,12 @@ export default class IndexedCollection {
const item = await this.indexer.read(id);
if (!item) return;
- if ((await this.getEncryptionKey()) && item.iv && item.cipher) {
- return JSON.parse(
- await this.indexer.decrypt(await this.getEncryptionKey(), item)
- );
- } else return item;
+ // if ((await this.getEncryptionKey()) && item.iv && item.cipher) {
+ // return JSON.parse(
+ // await this.indexer.decrypt(await this.getEncryptionKey(), item)
+ // );
+ // } else
+ return item;
}
async getItems(indices) {