Skip to content

Commit fc42691

Browse files
aspiersAdam Spiers
authored and
Adam Spiers
committed
Mention caveat in README about IndexedDB outside browser
If using the SDK outside the browser with end-to-end encryption, IndexedDB usage needs to be disabled otherwise it will cause the Rust code to panic. See also: - matrix-org#4570 - matrix-org/matrix-rust-sdk-crypto-wasm#168 - matrix-org/matrix-rust-sdk-crypto-wasm#195 (comment) Signed-off-by: Adam Spiers <[email protected]>
1 parent a1a0463 commit fc42691

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ const matrixClient = sdk.createClient({
321321
await matrixClient.initRustCrypto();
322322
```
323323

324+
Note that by default it will attempt to use the Indexed DB provided by the browser as a crypto store. If running outside the browser, you will need to pass [an options object](https://matrix-org.github.io/matrix-js-sdk/classes/matrix.MatrixClient.html#initrustcrypto) which includes `useIndexedDB: false`, to use an ephemeral in-memory store instead. Note that without a persistent store, you'll need to create a new device on the server side (with [`MatrixClient.loginRequest`](https://matrix-org.github.io/matrix-js-sdk/classes/matrix.MatrixClient.html#loginrequest)) each time your application starts.
325+
324326
After calling `initRustCrypto`, you can obtain a reference to the [`CryptoApi`](https://matrix-org.github.io/matrix-js-sdk/interfaces/crypto_api.CryptoApi.html) interface, which is the main entry point for end-to-end encryption, by calling [`MatrixClient.getCrypto`](https://matrix-org.github.io/matrix-js-sdk/classes/matrix.MatrixClient.html#getCrypto).
325327

326328
**WARNING**: the cryptography stack is not thread-safe. Having multiple `MatrixClient` instances connected to the same Indexed DB will cause data corruption and decryption failures. The application layer is responsible for ensuring that only one `MatrixClient` issue is instantiated at a time.

0 commit comments

Comments
 (0)