diff --git a/crates/ruma-client-api/src/r0/session.rs b/crates/ruma-client-api/src/r0/session.rs index 905a28d2..cec74580 100644 --- a/crates/ruma-client-api/src/r0/session.rs +++ b/crates/ruma-client-api/src/r0/session.rs @@ -1,5 +1,6 @@ //! Endpoints for user session management. +pub mod fallback; pub mod get_login_types; pub mod login; pub mod logout; diff --git a/crates/ruma-client-api/src/r0/session/fallback.rs b/crates/ruma-client-api/src/r0/session/fallback.rs new file mode 100644 index 00000000..de82441d --- /dev/null +++ b/crates/ruma-client-api/src/r0/session/fallback.rs @@ -0,0 +1,53 @@ +//! [GET /_matrix/static/client/login/](https://spec.matrix.org/unstable/client-server-api/#login-fallback) + +use ruma_api::ruma_api; +use ruma_identifiers::DeviceId; + +ruma_api! { + metadata: { + description: "Get login fallback web page.", + method: GET, + name: "login_fallback", + path: "/_matrix/static/client/login/", + rate_limited: false, + authentication: None, + } + + #[derive(Default)] + request: { + /// ID of the client device. + #[ruma_api(query)] + #[serde(skip_serializing_if = "Option::is_none")] + pub device_id: Option<&'a DeviceId>, + + /// A display name to assign to the newly-created device. + /// + /// Ignored if `device_id` corresponds to a known device. + #[ruma_api(query)] + #[serde(skip_serializing_if = "Option::is_none")] + pub initial_device_display_name: Option<&'a str>, + } + + response: { + /// HTML to return to client. + #[ruma_api(raw_body)] + pub body: Vec, + } +} + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given auth type and session ID. + pub fn new( + device_id: Option<&'a DeviceId>, + initial_device_display_name: Option<&'a str>, + ) -> Self { + Self { device_id, initial_device_display_name } + } +} + +impl Response { + /// Creates a new `Response` with the given HTML body. + pub fn new(body: Vec) -> Self { + Self { body } + } +} diff --git a/crates/ruma-client-api/src/r0/uiaa.rs b/crates/ruma-client-api/src/r0/uiaa.rs index 68956b81..d051b002 100644 --- a/crates/ruma-client-api/src/r0/uiaa.rs +++ b/crates/ruma-client-api/src/r0/uiaa.rs @@ -17,6 +17,8 @@ use serde_json::{ use crate::error::{Error as MatrixError, ErrorBody}; +pub mod fallback; + /// Additional authentication information for the user-interactive authentication API. #[derive(Clone, Debug, Outgoing, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] diff --git a/crates/ruma-client-api/src/r0/uiaa/fallback.rs b/crates/ruma-client-api/src/r0/uiaa/fallback.rs new file mode 100644 index 00000000..b22bc80f --- /dev/null +++ b/crates/ruma-client-api/src/r0/uiaa/fallback.rs @@ -0,0 +1,51 @@ +//! [GET /_matrix/client/r0/auth/{auth_type}/fallback/web?session={session_id}](https://matrix.org/docs/spec/client_server/r0.6.1#fallback) + +use ruma_api::ruma_api; + +ruma_api! { + metadata: { + description: "Get UIAA fallback web page.", + method: GET, + name: "uiaa_fallback", + path: "/_matrix/client/r0/auth/:auth_type/fallback/web", + rate_limited: false, + authentication: None, + } + + request: { + /// The type name ("m.login.dummy", etc.) of the uiaa stage to get a fallback page for. + #[ruma_api(path)] + pub auth_type: String, + + /// The ID of the session given by the homeserver. + #[ruma_api(query)] + pub session: String, + } + + #[derive(Default)] + response: { + /// Optional URI to redirect to. + #[ruma_api(header = LOCATION)] + pub redirect_url: Option, + + /// HTML to return to client. + #[ruma_api(raw_body)] + pub body: Vec, + } + + error: crate::Error +} + +impl Request { + /// Creates a new `Request` with the given auth type and session ID. + pub fn new(auth_type: String, session: String) -> Self { + Self { auth_type, session } + } +} + +impl Response { + /// Creates a new `Response` with the given redirect URL and HTML body. + pub fn new(redirect_url: Option, body: Vec) -> Self { + Self { redirect_url, body } + } +}