Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the matrix-sdk crates to 9b05d0d822 #124

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# UNRELEASED

**BREAKING CHANGES**

- Update matrix-rust-sdk to `9b05d0d82`, which includes:

- `Device.requestVerification`, `UserIdentities.requestVerification`, and
`UserIdentities.verificationRequestContent` is not async anymore.
([#3513](https://github.com/matrix-org/matrix-rust-sdk/pull/3513))
Comment on lines +7 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth mentioning that converting an async function to not-async is not normally a breaking change in JS (though typescript might complain at you about the redundant await).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's unexpected, thanks for letting me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth mentioning that converting an async function to not-async is not normally a breaking change in JS (though typescript might complain at you about the redundant await).

I disagree, as the method return value loses .then and .catch properties for non-async-await envs.


- Use the server name in the `QrCodeData` instead of the homeserver URL.
([#3537](https://github.com/matrix-org/matrix-rust-sdk/pull/3537))
Comment on lines +11 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a breaking change either?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we did rename the field, and the type of the field, thus the getter in the bindings was also renamed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it might be good to call out that rename then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# matrix-sdk-crypto-wasm v5.0.0

**BREAKING CHANGES**
Expand Down
34 changes: 15 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 14 additions & 16 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,24 @@ impl Device {
pub fn request_verification(
&self,
methods: Option<Vec<verification::VerificationMethod>>,
) -> Result<Promise, JsError> {
) -> Result<Array, JsError> {
let me = self.inner.clone();
let methods = methods.map(|methods| methods.iter().map(Into::into).collect());

Ok(future_to_promise(async move {
let tuple = Array::new();
let (verification_request, outgoing_verification_request) = match methods {
Some(methods) => me.request_verification_with_methods(methods).await,
None => me.request_verification().await,
};

tuple.set(0, verification::VerificationRequest::from(verification_request).into());
tuple.set(
1,
verification::OutgoingVerificationRequest::from(outgoing_verification_request)
.try_into()?,
);
let tuple = Array::new();
let (verification_request, outgoing_verification_request) = match methods {
Some(methods) => me.request_verification_with_methods(methods),
None => me.request_verification(),
};

tuple.set(0, verification::VerificationRequest::from(verification_request).into());
tuple.set(
1,
verification::OutgoingVerificationRequest::from(outgoing_verification_request)
.try_into()?,
);

Ok(tuple)
}))
Ok(tuple)
}

/// Is this device considered to be verified.
Expand Down
21 changes: 9 additions & 12 deletions src/identities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
use js_sys::{Array, Promise};
use wasm_bindgen::prelude::*;

use crate::{future::future_to_promise, identifiers, impl_from_to_inner, requests, verification};
use crate::{
future::future_to_promise,
identifiers, impl_from_to_inner, requests,
verification::{self, VerificationRequest},
};

pub(crate) struct UserIdentities {
inner: matrix_sdk_crypto::UserIdentities,
Expand Down Expand Up @@ -164,18 +168,13 @@ impl UserIdentity {
room_id: &identifiers::RoomId,
request_event_id: &identifiers::EventId,
methods: Option<Vec<verification::VerificationMethod>>,
) -> Result<Promise, JsError> {
) -> Result<VerificationRequest, JsError> {
let me = self.inner.clone();
let room_id = room_id.inner.clone();
let request_event_id = request_event_id.inner.clone();
let methods = methods.map(|methods| methods.iter().map(Into::into).collect());

Ok(future_to_promise::<_, verification::VerificationRequest>(async move {
Ok(me
.request_verification(room_id.as_ref(), request_event_id.as_ref(), methods)
.await
.into())
}))
Ok(me.request_verification(room_id.as_ref(), request_event_id.as_ref(), methods).into())
}

/// Send a verification request to the given user.
Expand All @@ -189,13 +188,11 @@ impl UserIdentity {
pub fn verification_request_content(
&self,
methods: Option<Vec<verification::VerificationMethod>>,
) -> Result<Promise, JsError> {
) -> Result<String, JsError> {
let me = self.inner.clone();
let methods = methods.map(|methods| methods.iter().map(Into::into).collect());

Ok(future_to_promise(async move {
Ok(serde_json::to_string(&me.verification_request_content(methods).await)?)
}))
Ok(serde_json::to_string(&me.verification_request_content(methods))?)
}

/// Get the master key of the identity.
Expand Down
1 change: 1 addition & 0 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl OlmMachine {
user_id.as_ref(),
device_id.as_ref(),
store_handle,
None,
)
.await
.map_err(JsError::from)?,
Expand Down
21 changes: 11 additions & 10 deletions src/qr_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ pub struct QrCodeData {
#[wasm_bindgen]
impl QrCodeData {
/// Create new [`QrCodeData`] from a given public key, a rendezvous URL and,
/// optionally, a homeserver URL.
/// optionally, a server name for the homeserver.
///
/// If a homeserver URL is given, then the [`QrCodeData`] mode will be
/// If a server name is given, then the [`QrCodeData`] mode will be
/// [`QrCodeMode::Reciprocate`], i.e. the QR code will contain data for the
/// existing device to display the QR code.
///
/// If no homeserver is given, the [`QrCodeData`] mode will be
/// If no server name is given, the [`QrCodeData`] mode will be
/// [`QrCodeMode::Login`], i.e. the QR code will contain data for the
/// new device to display the QR code.
#[wasm_bindgen(constructor)]
pub fn new(
public_key: Curve25519PublicKey,
rendezvous_url: &str,
homeserver_url: Option<String>,
server_name: Option<String>,
) -> Result<QrCodeData, JsError> {
let public_key = public_key.inner;
let rendezvous_url = Url::parse(rendezvous_url)?;

let mode_data = if let Some(homeserver_url) = homeserver_url {
qr_login::QrCodeModeData::Reciprocate { homeserver_url: Url::parse(&homeserver_url)? }
let mode_data = if let Some(server_name) = server_name {
qr_login::QrCodeModeData::Reciprocate { server_name }
} else {
qr_login::QrCodeModeData::Login
};
Expand Down Expand Up @@ -120,14 +120,15 @@ impl QrCodeData {
self.inner.rendezvous_url.as_str().to_owned()
}

/// Get the homeserver URL which the new device will be logged in to.
/// Get the server name of the homeserver which the new device will be
/// logged in to.
///
/// This will be only available if the existing device has generated the QR
/// code and the new device is the one scanning the QR code.
#[wasm_bindgen(getter)]
pub fn homeserver_url(&self) -> Option<String> {
if let qr_login::QrCodeModeData::Reciprocate { homeserver_url } = &self.inner.mode_data {
Some(homeserver_url.as_str().to_owned())
pub fn server_name(&self) -> Option<String> {
if let qr_login::QrCodeModeData::Reciprocate { server_name } = &self.inner.mode_data {
Some(server_name.to_owned())
} else {
None
}
Expand Down
Loading