@@ -74,6 +74,8 @@ use url::Url;
7474
7575#[ cfg( feature = "e2e-encryption" ) ]
7676use crate :: encryption:: Encryption ;
77+ #[ cfg( feature = "experimental-oidc" ) ]
78+ use crate :: oidc:: Oidc ;
7779use crate :: {
7880 authentication:: AuthData ,
7981 config:: RequestConfig ,
@@ -141,12 +143,12 @@ pub(crate) struct ClientInner {
141143 /// The URL of the homeserver to connect to.
142144 homeserver : RwLock < Url > ,
143145 /// The authentication server info discovered from the homeserver.
144- authentication_server_info : Option < AuthenticationServerInfo > ,
146+ pub ( crate ) authentication_server_info : Option < AuthenticationServerInfo > ,
145147 /// The sliding sync proxy that is trusted by the homeserver.
146148 #[ cfg( feature = "experimental-sliding-sync" ) ]
147149 sliding_sync_proxy : StdRwLock < Option < Url > > ,
148150 /// The underlying HTTP client.
149- http_client : HttpClient ,
151+ pub ( crate ) http_client : HttpClient ,
150152 /// User session data.
151153 base_client : BaseClient ,
152154 /// The Matrix versions the server supports (well-known ones only)
@@ -477,7 +479,7 @@ impl Client {
477479 ///
478480 /// Will be `None` if the client has not been logged in.
479481 pub fn access_token ( & self ) -> Option < String > {
480- Some ( self . inner . auth_data . get ( ) ?. access_token ( ) )
482+ self . inner . auth_data . get ( ) ?. access_token ( )
481483 }
482484
483485 /// Access the authentication API used to log in this client.
@@ -486,6 +488,8 @@ impl Client {
486488 pub fn auth_api ( & self ) -> Option < AuthApi > {
487489 match self . inner . auth_data . get ( ) ? {
488490 AuthData :: Matrix ( _) => Some ( AuthApi :: Matrix ( self . matrix_auth ( ) ) ) ,
491+ #[ cfg( feature = "experimental-oidc" ) ]
492+ AuthData :: Oidc ( _) => Some ( AuthApi :: Oidc ( self . oidc ( ) ) ) ,
489493 }
490494 }
491495
@@ -498,6 +502,8 @@ impl Client {
498502 pub fn session ( & self ) -> Option < AuthSession > {
499503 match self . auth_api ( ) ? {
500504 AuthApi :: Matrix ( api) => api. session ( ) . map ( Into :: into) ,
505+ #[ cfg( feature = "experimental-oidc" ) ]
506+ AuthApi :: Oidc ( api) => api. full_session ( ) . map ( Into :: into) ,
501507 }
502508 }
503509
@@ -527,6 +533,12 @@ impl Client {
527533 Media :: new ( self . clone ( ) )
528534 }
529535
536+ /// Access the OpenID Connect API of the client.
537+ #[ cfg( feature = "experimental-oidc" ) ]
538+ pub fn oidc ( & self ) -> Oidc {
539+ Oidc :: new ( self . clone ( ) )
540+ }
541+
530542 /// Register a handler for a specific event type.
531543 ///
532544 /// The handler is a function or closure with one or more arguments. The
@@ -942,6 +954,8 @@ impl Client {
942954 let session = session. into ( ) ;
943955 match session {
944956 AuthSession :: Matrix ( s) => self . matrix_auth ( ) . restore_session ( s) . await ,
957+ #[ cfg( feature = "experimental-oidc" ) ]
958+ AuthSession :: Oidc ( s) => self . oidc ( ) . restore_session ( s) . await ,
945959 }
946960 }
947961
@@ -959,6 +973,10 @@ impl Client {
959973 AuthApi :: Matrix ( a) => {
960974 a. refresh_access_token ( ) . await ?;
961975 }
976+ #[ cfg( feature = "experimental-oidc" ) ]
977+ AuthApi :: Oidc ( api) => {
978+ api. refresh_access_token ( ) . await ?;
979+ }
962980 }
963981
964982 Ok ( ( ) )
0 commit comments