calvinmetcalf / crypto-pouch

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

Add the possibility to temporarily disable encryption and to re-use `.crypto()` #86

Closed mytdragon closed 1 year ago

mytdragon commented 2 years ago

Hey there,

thank you for this plugin that is really helpfull for my project. However I had to do a few changes to make it work as I needed. It's the first time I use the pull-request feature so excuse me if I didn't do the stuff properly 🙏

I noticed that I couldn't use db.crypto(...) twice after using db.removeCrypto() because the transform-pouch was still set after removing _crypt so I had an encoding problem on the 2nd run. The work around I did check if the crypto was set up once so it won't add again the transform stuff.

Also, we can remove encryption on the database and forgets the password but we couldn't temporarily disable the encryption and re-enable it back in the same db.crypto(...), so I just added it.

I'm creating this pull-request just in case someone need this stuff, the tests ran properly. If you don't need it, feel free to refuse it. Cheers

garbados commented 2 years ago

Hi! Thanks for this PR. Before I do a bigger review, can you write tests that assert the correct behavior of your desired features?