matrix-org / matrix-js-sdk

Matrix Client-Server SDK for JavaScript
Apache License 2.0
1.57k stars 583 forks source link

Element-R: wire up `encryptAndSendToDevices` #3304

Open richvdh opened 1 year ago

richvdh commented 1 year ago

This is used by element call, which could otherwise be an early adopter of the rustified crypto.

richvdh commented 1 year ago

Looks like we'll have to expose this functionality in the rust matrix-crypto-sdk as well

richvdh commented 1 year ago

Blocked on https://github.com/matrix-org/matrix-rust-sdk/issues/1816

richvdh commented 1 month ago

Given that MatrixClient.encryptAndSendToDevices takes a DeviceInfo, which is part of the legacy crypto stack, we won't be able to implement this directly.

I'd suggest adding a new api encryptToDeviceMessages to CryptoApi, which takes an array of (user_id, device_id) pairs. The application can then call MatrixClient.queueToDeviceon the results.

hughns commented 1 month ago

I'd suggest adding a new api encryptToDeviceMessages to CryptoApi, which takes an array of (user_id, device_id) pairs. The application can then call MatrixClient.queueToDeviceon the results.

This sounds perfect 👍

hughns commented 1 month ago

n.b. https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/issues/140 is a blocker.

hughns commented 1 month ago

@richvdh I have started an implementation at https://github.com/matrix-org/matrix-js-sdk/pull/4380. On the API shape, might you be able to take a look and see if this is going in the right direction?

The motivation behind leaving a MatrixClient.encryptAndSendToDevices function is that it then works nicely when using the js-sdk as a matryoshka client within the widget API.

hughns commented 1 month ago

Dealing with the breaking changes in matrix-sdk-crypto-wasm is now a blocker: https://github.com/matrix-org/matrix-js-sdk/pull/4396