matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

[Meta] Be more explicit about/test for/document limitations of various runtimes

Open bradjones1 opened this issue 1 year ago • 8 comments

Following-on to https://github.com/matrix-org/matrix-js-sdk/issues/2788#issue-1419245094 but more broadly: I think it would be helpful to document more explicitly the SDK's compatibility with various runtimes, e.g. Node, browsers, and RN (e.g., Hermes engine.)

The linked issue relating to WebCrypto is a good example of this: the SDK now basically requires Node 16+ or a browser with WebCrypto API. Unsupported in React Native.

I'm certainly not advocating for any more or unplanned work on the part of the Matrix team, which is doing amazing work here. Rather I think it would be helpful to explicitly state these requirements and limitations, and perhaps provide some sort of support matrix for features based on their capabilities or versions.

bradjones1 avatar Oct 22 '22 11:10 bradjones1

I've written a more detailed blog post about my experience implementing the SDK 21.0 RC, which provides a bit of a broader usage report.

bradjones1 avatar Oct 22 '22 11:10 bradjones1

@bradjones1 thanks so much for this! My team has been trying to figure this out over the past couple days. Ultimately, were you able to get the SDK fully working in your RN app?

apguan avatar Nov 02 '22 19:11 apguan

@apguan I'd say, "yes," but not "fully working" in the sense that things like E2E encryption are dependent on runtime requirements that are difficult/impossible to manage reasonably in the RN environment. (Which is the genesis of this issue.)

There are also other considerations such as login, token refresh and the like that need special handling in a non-browser environment but they are not insurmountable. Token refresh in particular has been made a lot easier thanks to https://github.com/matrix-org/matrix-js-sdk/pull/2719 - I implemented a basic middleware but caveat emptor.

All that said, I'm very happy with the SDK and with Matrix as a chat solution - it lets me offload a lot of that complexity to a service I don't need to homebrew. There are things that I've had to postpone (such as selling access to read receipts) because the Matrix paradigm doesn't quite fit all my business domain needs. But life is all about trade-offs.

I'm far from an RN expert (I'm a back-end guy thrust into the front-end out of necessity) but you can email me at [email protected] if you want to chat more about it/want some consulting.

I will say that I started off early on working from https://gitlab.com/ditto-chat/ditto but the observer pattern she implemented just doesn't work for me. As I've learned more about Matrix (and honestly, RN/TypeScript) I've ripped a lot of that code out but it was a good reference implementation, especially for the chat screen.

Also, know any angels interested in a disruptive dating app? :-D

bradjones1 avatar Nov 02 '22 19:11 bradjones1

Let me ask around in my network. Thanks again 🙂

apguan avatar Nov 02 '22 19:11 apguan

@bradjones1 Hey, how's it going? It's five months later now, have you by any chance figured out a way to make e2e encryption work using the sdk in react native with all its kicks i.e backups and persisting cryoto storage etc.

AbdullahQureshi1080 avatar Apr 09 '23 23:04 AbdullahQureshi1080

@AbdullahQureshi1080 Sorry, I don't use E2E so I can't speak to this.

bradjones1 avatar Apr 09 '23 23:04 bradjones1

@bradjones1 That's a bummer, I thought maybe you've had some breakthrough on that.

Thanks for the comment and best of luck with your usecase.👍🏻

AbdullahQureshi1080 avatar Apr 09 '23 23:04 AbdullahQureshi1080

To follow

Neustradamus avatar Jun 13 '23 22:06 Neustradamus