Skip to content

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

vault: convert delta to string

thecodrr07dd6c84db2b
diff --git a/packages/core/__mocks__/storage.mock.js b/packages/core/__mocks__/storage.mock.js
index bb37c3d96..a580a978e 100644
--- a/packages/core/__mocks__/storage.mock.js
+++ b/packages/core/__mocks__/storage.mock.js
@@ -25,7 +25,8 @@ function clear() {
}
function encrypt(password, data) {
- return new Promise((resolve) => {
+ return new Promise((resolve, reject) => {
+ if (typeof data === "object") reject("data cannot be object.");
resolve({
iv: "some iv",
cipher: data,
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.js
index c2e85e3eb..fa573ac91 100644
--- a/packages/core/api/vault.js
+++ b/packages/core/api/vault.js
@@ -109,7 +109,10 @@ export default class Vault {
if (text === textId) text = await this._db.text.get(textId);
text = await this._context.encrypt({ password: this._password }, text);
- delta = await this._context.encrypt({ password: this._password }, delta);
+ delta = await this._context.encrypt(
+ { password: this._password },
+ JSON.stringify(delta)
+ );
await this._db.text.add({ id: textId, data: text });
await this._db.delta.add({ id: deltaId, data: delta });