The server might always send a modified script that just uploads the plaintext private key.
Yeah, you'd need a way to validate the client code before it's executed to solve that issue
Section "2. Client application security" of MEGA's Security Whitepaper discusses this exact problem. Their best solution to that issue is to just cram the whole frontend in a signed web extension and not serve any code to the user when the extension is active, which is not very user friendly but works for those who want an extra layer of protection
I just can't find a good user-friendly implementation, sorry for not being of more help. The web just isn't E2EE-friendly ig :/
Damn already working on an app? That's so cool! Starting E2EE there is definitely a good idea then!
MeroChat is such a nice project, thank you for working on it <3