Skylar-Tech / node-red-contrib-matrix-chat

Matrix chat server support for Node-RED
GNU General Public License v3.0
31 stars 10 forks source link

Send Images/Files (sending files to e2ee room doesn't currently encrypt them yet) #79

Open saket424 opened 1 year ago

saket424 commented 1 year ago

@skylord123

I have now successfully installed 0.7.0 and thinking aloud on how i'd like to use this cool and thoughtful nodered matrix bot integration that you have generously made available to us

Just trying to get a sense of how hard it is to get encryption of images and files working especially since decryption of images and files already is supposed to work in encrypted rooms.

I want to begin trying to use this feature to store and share content that only members of the room can make sense of and it is gibberish to anyone else who has access to the filesystem.

Please label it as an enhancement request that we can track progress on

saket424 commented 1 year ago

A related question. How are the files and images actually stored in the matrix hierarchy and can they be secured/encrypted so only members of the room can make sense of it

skylord123 commented 1 year ago

They are stored just like other uploaded files. Anyone with the link can technically download it. The thing is that in e2ee rooms the uploaded files is encrypted before uploading and the keys to decrypt are shared in the e2ee message so the client's in the room know how to decrypt it.

This is why if you receive an encrypted file you need to use the "Decrypt File" node to get the contents. If the file isn't encrypted you can just download it from the URL but if it is you need to download it and decrypt it.

We have the method to encrypt files, just need to implement it. It honestly doesn't look that difficult. Looking at matrix-react-sdk they already have a good example we can base it off of: https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/ContentMessages.ts#L277-L320

Basically we just need to check if the room is encrypted and if so encrypt the file before upload. I want to merge Send File and Send Image into one node for the next release so it would be a good time to also tackle this issue (I want just one node that can send any type of file to make things cleaner and would make it so this encrypt code doesn't have to be duplicated across each node, you would just configure on the node what type of file you are sending).

I'll see if I get some time to work on this over the weekend.

saket424 commented 1 year ago

@skylord123 That really would be super if you can combine file and image encryption into a single node. Then, this nodered matrix bot would become a fully capable member in the world of encrypted rooms just as any human who manually signs in.

saket424 commented 1 year ago

@skylord123 Any update on file encryption by the bot? Thanks in advance