refactor(crypto): Create a MSC and intent specific accessor for the QR login data type
This patch adds a view into the MSC-specific and intent specific data fields of the QR login data type. MSC4108 and MSC4388 have subtle differences in the way the rendezvous URL and the server name are shared, this new getter allows us to access all of those fields in a consistent manner. MSC4108: https://github.com/matrix-org/matrix-spec-proposals/pull/4108 MSC4388: https://github.com/matrix-org/matrix-spec-proposals/pull/4388
This commit is contained in:
@@ -6,7 +6,7 @@ use futures_util::StreamExt;
|
||||
use matrix_sdk::{
|
||||
Client,
|
||||
authentication::oauth::{
|
||||
qrcode::{LoginProgress, QrCodeData, QrCodeIntentData, QrProgress},
|
||||
qrcode::{LoginProgress, Msc4108IntentData, QrCodeData, QrCodeIntentData, QrProgress},
|
||||
registration::{ApplicationType, ClientMetadata, Localized, OAuthGrantType},
|
||||
},
|
||||
ruma::serde::Raw,
|
||||
@@ -101,7 +101,9 @@ async fn login(proxy: Option<Url>) -> Result<()> {
|
||||
|
||||
let data = QrCodeData::from_base64(input).context("Couldn't parse the base64 QR code data")?;
|
||||
|
||||
let QrCoodeIntentData::Reciprocate { server_name } = &data.intent_data() else {
|
||||
let QrCodeIntentData::Msc4108 { data: Msc4108IntentData::Reciprocate { server_name }, .. } =
|
||||
&data.intent_data()
|
||||
else {
|
||||
bail!("The QR code is invalid, we did not receive a homeserver in the QR code.");
|
||||
};
|
||||
let mut client = Client::builder().server_name_or_homeserver_url(server_name);
|
||||
|
||||
Reference in New Issue
Block a user