calvinmetcalf / crypto-pouch

plugin for encrypted pouchdb/couchdb databases
MIT License
243 stars 43 forks source link

fix: preserve ignored fields on read #79

Closed garbados closed 3 years ago

garbados commented 3 years ago

This PR fixes https://github.com/calvinmetcalf/crypto-pouch/issues/44 by restoring ignored fields to the decrypted document upon read. Previously these fields were attached to the encrypted document but otherwise discarded, as the system assumed the decrypted document would already possess them. This broke replication for documents that were assigned a first revision value during write, as that revision value would only be assigned to the encrypted version. This PR assigns ignored fields like _rev from the encrypted document to its decrypted version so that such documents always have a revision value.