xmtp / xmtp-js

XMTP client SDKs for JavaScript applications.

Home Page:https://xmtp.org/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Pluggable persistence engine

neekolas opened this issue · comments

Is your feature request related to a problem?

Developers should be able to define their own persistence implementations (compliant with the Persistence interface) and have them used as the base layer for persistence everywhere.

This is important for server-side contexts. For example, I should be able to build a filesystem persistence provider, or even a Postgres persistence provider.

Describe the solution to the problem

We should add a new Client option that allows the application to include a PersistenceFactory that allows the caller to provide the base layer of persistence (without the PrefixedPersistence wrapper, which should be handled by the SDK).

If none is provided, the default should be new LocalStoragePersistence() (the current base layer of persistence today).

Whether the base persistence is wrapped in an EncryptedPersistence should also be configurable, as some persistence providers may already include encryption and there is no need to encrypt twice.

Describe the uses cases for the feature

Any Node.js app using xmtp-js would benefit from the ability to persist conversation state onto the file system. Some might benefit from persisting to a database.

The actual implementations are out of scope for this feature, but it should be trivial to make this part of our SDK extensible.

Additional details

No response