mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-15 19:45:34 -04:00
Merge pull request #2258 from matrix-org/matrix-sdk-crypto-js-0.1.3
Fix `receiveSyncChanges` js bindings, and release 0.1.3
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
# v0.1.3
|
||||
|
||||
## Changes in the Javascript bindings
|
||||
|
||||
- Fix bug introduced in v0.1.2 which caused an undocumented change to the results of `OlmMachine.receiveSyncChanges`.
|
||||
|
||||
## Changes in the underlying Rust crate
|
||||
|
||||
- Fix a bug which could cause generated one-time-keys not to be persisted.
|
||||
|
||||
# v0.1.2
|
||||
|
||||
**WARNING**: this version had a breaking change in the result type of `OlmMachine.receiveSyncChanges`.
|
||||
This is corrected in v0.1.3.
|
||||
|
||||
## Changes in the Javascript bindings
|
||||
|
||||
- Add `Qr.state()` method to inspect the current state of QR code
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@matrix-org/matrix-sdk-crypto-js",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"homepage": "https://github.com/matrix-org/matrix-rust-sdk",
|
||||
"description": "Matrix encryption library, for JavaScript",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -216,6 +216,9 @@ impl OlmMachine {
|
||||
///
|
||||
/// To decrypt an event from the room timeline call
|
||||
/// `decrypt_room_event`.
|
||||
///
|
||||
/// Returns a list of JSON strings, containing the decrypted to-device
|
||||
/// events.
|
||||
#[wasm_bindgen(js_name = "receiveSyncChanges")]
|
||||
pub fn receive_sync_changes(
|
||||
&self,
|
||||
@@ -255,15 +258,19 @@ impl OlmMachine {
|
||||
let me = self.inner.clone();
|
||||
|
||||
Ok(future_to_promise(async move {
|
||||
Ok(serde_json::to_string(
|
||||
&me.receive_sync_changes(
|
||||
// we discard the list of updated room keys in the result; JS applications are
|
||||
// expected to use register_room_key_updated_callback to receive updated room
|
||||
// keys.
|
||||
let (decrypted_to_device_events, _) = me
|
||||
.receive_sync_changes(
|
||||
to_device_events,
|
||||
&changed_devices,
|
||||
&one_time_key_counts,
|
||||
unused_fallback_keys.as_deref(),
|
||||
)
|
||||
.await?,
|
||||
)?)
|
||||
.await?;
|
||||
|
||||
Ok(serde_json::to_string(&decrypted_to_device_events)?)
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ async function addMachineToMachine(machineToAdd, machine) {
|
||||
await machineToAdd.receiveSyncChanges(toDeviceEvents, changedDevices, oneTimeKeyCounts, unusedFallbackKeys),
|
||||
);
|
||||
|
||||
expect(receiveSyncChanges).toEqual([[], []]);
|
||||
expect(receiveSyncChanges).toEqual([]);
|
||||
|
||||
const outgoingRequests = await machineToAdd.outgoingRequests();
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ describe(OlmMachine.name, () => {
|
||||
await m.receiveSyncChanges(toDeviceEvents, changedDevices, oneTimeKeyCounts, unusedFallbackKeys),
|
||||
);
|
||||
|
||||
expect(receiveSyncChanges).toEqual([[], []]);
|
||||
expect(receiveSyncChanges).toEqual([]);
|
||||
});
|
||||
|
||||
test("can receive sync changes with unusedFallbackKeys as undefined", async () => {
|
||||
@@ -230,7 +230,7 @@ describe(OlmMachine.name, () => {
|
||||
await m.receiveSyncChanges(toDeviceEvents, changedDevices, oneTimeKeyCounts, undefined),
|
||||
);
|
||||
|
||||
expect(receiveSyncChanges).toEqual([[], []]);
|
||||
expect(receiveSyncChanges).toEqual([]);
|
||||
});
|
||||
|
||||
test("can get the outgoing requests that need to be send out", async () => {
|
||||
@@ -244,7 +244,7 @@ describe(OlmMachine.name, () => {
|
||||
await m.receiveSyncChanges(toDeviceEvents, changedDevices, oneTimeKeyCounts, unusedFallbackKeys),
|
||||
);
|
||||
|
||||
expect(receiveSyncChanges).toEqual([[], []]);
|
||||
expect(receiveSyncChanges).toEqual([]);
|
||||
|
||||
const outgoingRequests = await m.outgoingRequests();
|
||||
|
||||
|
||||
@@ -38,3 +38,5 @@
|
||||
"Airplane", for consistency with the Matrix spec.
|
||||
|
||||
- Fix handling of SAS verification start events once we have shown a QR code.
|
||||
|
||||
- Fix a bug which could cause generated one-time-keys not to be persisted.
|
||||
|
||||
@@ -1105,7 +1105,9 @@ impl OlmMachine {
|
||||
///
|
||||
/// [`decrypt_room_event`]: #method.decrypt_room_event
|
||||
///
|
||||
/// Returns a tuple of (pending verification events, updated room keys)
|
||||
/// # Returns
|
||||
///
|
||||
/// A tuple of (decrypted to-device events, updated room keys).
|
||||
#[instrument(skip_all)]
|
||||
pub async fn receive_sync_changes(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user