Well, I see 2 main use cases for encryption support:
1. Provide encrypt/decrypt routines for explicit encryption/decryption.
2. Allow to to enter master password once and then implicitly decrypt data on read and encrypt them on write.
First use case is simple. We just need to add encryption support based on proven standards (WebCrypto?) to allow application developers to call
RemoteStorage.encrypt(data, secret) and
RemoteStorage.decrypt(data, secret). To use it developer will only need to implement an UI callback that will ask for password.
Second use case will need some way to detect should an object be encrypted/ decrypted? I agree that extension isn't good idea and probably better idea is to use
RemoteStorage.defineModule. For example if an module defines
preSave and 'postRead' in own
exports RemoteStorage can call these functions immediately after read and before save to the underlying datastorte. Encryption/decryption (and any other pre- and post-processing) can be done inside these functions. Functions accepts raw objects, analyse it, change if required and return original or modified copy. What do you think about this approach?
We also will need a default way to ask user for master password (it can be just trivial
window.prompt. Application developer can customize this prompt also on module level defining in
exports callback with name like
passwordPrompt. Once we obtain master password from user, we can derive real password with a standard function like
PKDF2 and use it for actual encryption/decryption with
AES256 as chipper. So user will enter master password only once and we will use it until session expire or an timeout. We can discard master password immediately after generating of derived password and keep it private in memory only.
We even can have option to use own master password for each module, this
will lead to better security but weaker UX probably.
Yeah, I'm interested in it. If we all agree desired solution and requirements to it, I can implement it.