dexie-encrypted
Advanced tools
Comparing version 2.0.0-beta.2 to 2.0.0-beta.3
@@ -61,3 +61,15 @@ "use strict"; | ||
const { __encryptedData } = entity, unencryptedFields = tslib_1.__rest(entity, ["__encryptedData"]); | ||
const decrypted = performDecryption(encryptionKey, __encryptedData); | ||
let decrypted = performDecryption(encryptionKey, __encryptedData); | ||
// There is a bug that causes double encryption. I am not sure what causes it, | ||
// it is very rare and I have no repro steps. I believe the hook is running twice | ||
// in very rare circumstances, but I have no evidence of it. | ||
// This decrypts until all decryption is done. The only circumstance where it will | ||
// create an undesireable result is if your data has an __encryptedData key, and | ||
// that data can be decrypted by the performDecryption function. | ||
while (decrypted.__encryptedData) { | ||
const decryptionAttempt = performDecryption(encryptionKey, decrypted.__encryptedData); | ||
if (decryptionAttempt) { | ||
decrypted = decryptionAttempt; | ||
} | ||
} | ||
return Object.assign(Object.assign({}, unencryptedFields), decrypted); | ||
@@ -64,0 +76,0 @@ } |
{ | ||
"name": "dexie-encrypted", | ||
"version": "2.0.0-beta.2", | ||
"version": "2.0.0-beta.3", | ||
"description": "Encryption middleware for Dexie", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
Sorry, the diff of this file is not supported yet
53205
572