awslabs / mls-rs

An implementation of Messaging Layer Security (RFC 9420)
Apache License 2.0
99 stars 19 forks source link

Web storage-provider based on IndexedDB #194

Open nicdard opened 1 month ago

nicdard commented 1 month ago

Description of feature:

I think that the WASM build would greatly benefit from a storage provider based on IndexedDB. Basically something like the web-crypto-provider, where the storage is coded on top of IndexedDB web api, using the web-sys crate.

Currently, when working with the WASM code, the sqlLite storage provider cannot be used (at least easily, I made some explorations whether it is possible to compile slqLite in WASM, but didn't try anything).

Use case:

When running mls in a browser, store the state inside IndexedDB to be able to keep the session on multiple visits of the same page. This would be a step forward in making the library actually usable to develop a web application for example.

Implementation discussion (Optional)

I have been quickly looking at the code as I don't have currently much time. I would create a new crate in the library, and then implement the various traits for the Storage like GroupStateStorage in a similar fashion as it is done in the slqLite provider, but internally using the IndexedDB. IndexedDB seems a good option as it supports also any object not just strings, and the size of the data we write is not a problem like in the LocalStorage.