Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion bindings/matrix-sdk-ffi/src/qr_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ impl From<qrcode::QRCodeLoginError> for HumanQrLoginError {
| SecureChannelError::RendezvousChannel(_) => HumanQrLoginError::Unknown,
SecureChannelError::SecureChannelMessage { .. }
| SecureChannelError::Ecies(_)
| SecureChannelError::InvalidCheckCode => HumanQrLoginError::ConnectionInsecure,
| SecureChannelError::InvalidCheckCode
| SecureChannelError::CannotReceiveCheckCode => {
HumanQrLoginError::ConnectionInsecure
}
SecureChannelError::InvalidIntent => HumanQrLoginError::OtherDeviceNotSignedIn,
},

Expand Down
3 changes: 3 additions & 0 deletions crates/matrix-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ All notable changes to this project will be documented in this file.
begins ([#5678](https://github.com/matrix-org/matrix-rust-sdk/pull/5678).
- Make `PaginationTokens` `pub`, as well as its `previous` and `next` tokens so they can be assigned from other files
([#5678](https://github.com/matrix-org/matrix-rust-sdk/pull/5678).
- Add `OAuth::login_with_generated_qr_code` for generating a QR code on a new device
and logging it in with the help of an existing device scanning the code.
([#5711](https://github.com/matrix-org/matrix-rust-sdk/pull/5711))
Comment on lines +82 to +84
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not the only change, some error types got new variants as well. Extending the error types is a breaking change.


### Refactor

Expand Down
27 changes: 26 additions & 1 deletion crates/matrix-sdk/src/authentication/oauth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ mod tests;
#[cfg(feature = "e2e-encryption")]
use self::cross_process::{CrossProcessRefreshLockGuard, CrossProcessRefreshManager};
#[cfg(feature = "e2e-encryption")]
use self::qrcode::LoginWithQrCode;
use self::qrcode::{LoginWithGeneratedQrCode, LoginWithQrCode};
pub use self::{
account_management_url::{AccountManagementActionFull, AccountManagementUrlBuilder},
auth_code_builder::{OAuthAuthCodeUrlBuilder, OAuthAuthorizationData},
Expand Down Expand Up @@ -459,6 +459,31 @@ impl OAuth {
LoginWithQrCode::new(&self.client, data, registration_data)
}

/// Log in using a generated QR code.
///
/// This method allows you to log in with a QR code, this device
/// needs to display the QR code by calling this method so the existing
/// device can scan it and grant the log in.
///
/// A successful login using this method will automatically mark the device
/// as verified and transfer all end-to-end encryption related secrets, like
/// the private cross-signing keys and the backup key from the existing
/// device to the new device.
///
/// # Arguments
///
/// * `registration_data` - The data to restore or register the client with
/// the server. If this is not provided, an error will occur unless
/// [`OAuth::register_client()`] or [`OAuth::restore_registered_client()`]
/// was called previously.
#[cfg(feature = "e2e-encryption")]
pub fn login_with_generated_qr_code<'a>(
&'a self,
registration_data: Option<&'a ClientRegistrationData>,
) -> LoginWithGeneratedQrCode<'a> {
LoginWithGeneratedQrCode::new(&self.client, registration_data)
}

/// Restore or register the OAuth 2.0 client for the server with the given
/// metadata, with the given optional [`ClientRegistrationData`].
///
Expand Down
Loading
Loading