From 1cad6f445198cb8e0da4e9cec04ec7378f0ee6f8 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:38:48 +0000 Subject: [PATCH] Add multiprocess health warnings to `initRustCrypto` (#4571) --- README.md | 2 ++ src/client.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 756b8c71ca9..5272706e432 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,8 @@ await matrixClient.initRustCrypto(); 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). +**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. + ## Secret storage You should normally set up [secret storage](https://spec.matrix.org/v1.12/client-server-api/#secret-storage) before using the end-to-end encryption. To do this, call [`CryptoApi.bootstrapSecretStorage`](https://matrix-org.github.io/matrix-js-sdk/interfaces/crypto_api.CryptoApi.html#bootstrapSecretStorage). diff --git a/src/client.ts b/src/client.ts index 478e2784e51..dbe1363942c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -2222,6 +2222,10 @@ export class MatrixClient extends TypedEventEmitter