-
-
Notifications
You must be signed in to change notification settings - Fork 652
Description
Hey!
I'm currently trying to create a Matrix client inside WorkAventure.
So far, I managed to set up Rust crypto and everything seems to run fine. I can log into my application using my "john.doe" user and the connection to Synapse is successful.
However, if I log out, and log in with another used ("jane.doe"), I'm getting the following error during the call to await client.initRustCrypto();:
the account in the store doesn't match the account in the constructor: expected @john.doe:matrix.workadventure.localhost:ULlGg2Bzxv, got @jane.doe:matrix.workadventure.localhost:aUM4pNrpuo
I'm quite new to Matrix so I don't know if I stumbled on a bug or if there is something I don't understand.
My expectation was that a store could contain several accounts.
Am I supposed to purge the store when someone logs out?
When I look at the code, I see that the name of the indexedDb we use to store the crypto keys is always the same (it is RUST_SDK_STORE_PREFIX):
Lines 2320 to 2329 in 48d4f1b
| const rustCrypto = await RustCrypto.initRustCrypto( | |
| this.logger, | |
| this.http, | |
| userId, | |
| deviceId, | |
| this.secretStorage, | |
| this.cryptoCallbacks, | |
| useIndexedDB ? RUST_SDK_STORE_PREFIX : null, | |
| this.pickleKey, | |
| ); |
If the store can only contain one user, wouldn't it make sense to create one store per user?
Something like:
const rustCrypto = await RustCrypto.initRustCrypto(
this.logger,
this.http,
userId,
deviceId,
this.secretStorage,
this.cryptoCallbacks,
- useIndexedDB ? RUST_SDK_STORE_PREFIX : null,
+ useIndexedDB ? RUST_SDK_STORE_PREFIX + userId : null,
this.pickleKey,
);Or is there something I don't understand?
Note: I will happily contribute a PR if this is something that needs fixing.