1
1
use std:: { fs, num:: NonZeroUsize , path:: Path , sync:: Arc , time:: Duration } ;
2
2
3
- use futures_util:: StreamExt ;
4
3
#[ cfg( not( target_family = "wasm" ) ) ]
5
4
use matrix_sdk:: reqwest:: Certificate ;
6
5
use matrix_sdk:: {
7
- crypto:: {
8
- types:: qr_login:: QrCodeModeData , CollectStrategy , DecryptionSettings , TrustRequirement ,
9
- } ,
6
+ crypto:: { CollectStrategy , DecryptionSettings , TrustRequirement } ,
10
7
encryption:: { BackupDownloadStrategy , EncryptionSettings } ,
11
8
event_cache:: EventCacheError ,
12
9
ruma:: { ServerName , UserId } ,
@@ -22,15 +19,7 @@ use tracing::{debug, error};
22
19
use zeroize:: Zeroizing ;
23
20
24
21
use super :: client:: Client ;
25
- use crate :: {
26
- authentication:: OidcConfiguration ,
27
- client:: ClientSessionDelegate ,
28
- error:: ClientError ,
29
- helpers:: unwrap_or_clone_arc,
30
- qr_code:: { HumanQrLoginError , QrCodeData , QrLoginProgressListener } ,
31
- runtime:: get_runtime_handle,
32
- task_handle:: TaskHandle ,
33
- } ;
22
+ use crate :: { client:: ClientSessionDelegate , error:: ClientError , helpers:: unwrap_or_clone_arc} ;
34
23
35
24
/// A list of bytes containing a certificate in DER or PEM form.
36
25
pub type CertificateBytes = Vec < u8 > ;
@@ -582,60 +571,6 @@ impl ClientBuilder {
582
571
. await ?,
583
572
) )
584
573
}
585
-
586
- /// Finish the building of the client and attempt to log in using the
587
- /// provided [`QrCodeData`].
588
- ///
589
- /// This method will build the client and immediately attempt to log the
590
- /// client in using the provided [`QrCodeData`] using the login
591
- /// mechanism described in [MSC4108]. As such this methods requires OAuth
592
- /// 2.0 support as well as sliding sync support.
593
- ///
594
- /// The usage of the progress_listener is required to transfer the
595
- /// [`CheckCode`] to the existing client.
596
- ///
597
- /// [MSC4108]: https://github.com/matrix-org/matrix-spec-proposals/pull/4108
598
- pub async fn build_with_qr_code (
599
- self : Arc < Self > ,
600
- qr_code_data : & QrCodeData ,
601
- oidc_configuration : & OidcConfiguration ,
602
- progress_listener : Box < dyn QrLoginProgressListener > ,
603
- ) -> Result < Arc < Client > , HumanQrLoginError > {
604
- let QrCodeModeData :: Reciprocate { server_name } = & qr_code_data. inner . mode_data else {
605
- return Err ( HumanQrLoginError :: OtherDeviceNotSignedIn ) ;
606
- } ;
607
-
608
- let builder = self . server_name_or_homeserver_url ( server_name. to_owned ( ) ) ;
609
-
610
- let client = builder. build ( ) . await . map_err ( |e| match e {
611
- ClientBuildError :: SlidingSync ( _) => HumanQrLoginError :: SlidingSyncNotAvailable ,
612
- _ => {
613
- error ! ( "Couldn't build the client {e:?}" ) ;
614
- HumanQrLoginError :: Unknown
615
- }
616
- } ) ?;
617
-
618
- let registration_data = oidc_configuration
619
- . registration_data ( )
620
- . map_err ( |_| HumanQrLoginError :: OidcMetadataInvalid ) ?;
621
-
622
- let oauth = client. inner . oauth ( ) ;
623
- let login = oauth. login_with_qr_code ( & qr_code_data. inner , Some ( & registration_data) ) ;
624
-
625
- let mut progress = login. subscribe_to_progress ( ) ;
626
-
627
- // We create this task, which will get cancelled once it's dropped, just in case
628
- // the progress stream doesn't end.
629
- let _progress_task = TaskHandle :: new ( get_runtime_handle ( ) . spawn ( async move {
630
- while let Some ( state) = progress. next ( ) . await {
631
- progress_listener. on_update ( state. into ( ) ) ;
632
- }
633
- } ) ) ;
634
-
635
- login. await ?;
636
-
637
- Ok ( client)
638
- }
639
574
}
640
575
641
576
#[ cfg( not( target_family = "wasm" ) ) ]
0 commit comments