client-api: Stabilize MSC2918

This commit is contained in:
Kévin Commaille 2022-06-20 17:00:51 +02:00 committed by Kévin Commaille
parent 05a28c8097
commit 0d71ce17da
7 changed files with 22 additions and 32 deletions

View File

@ -8,12 +8,9 @@ Breaking changes:
Improvements:
* Add unstable support for refresh tokens (MSC2918)
* Add support for refresh tokens (MSC2918)
* Add `ErrorKind::{UnableToAuthorizeJoin, UnableToGrantJoin}` encountered for restricted rooms
* Add unstable support for timestamp massaging (MSC3316)
Improvements:
* Add unstable support for querying relating events (MSC2675)
* Move `filter::RelationType` to `ruma_common::events::relations`
* Add unstable support for discovering an OpenID Connect server (MSC2965)

View File

@ -25,7 +25,6 @@ unstable-msc2654 = []
unstable-msc2675 = []
unstable-msc2676 = []
unstable-msc2677 = []
unstable-msc2918 = []
unstable-msc2965 = []
unstable-msc3316 = []
unstable-msc3440 = []

View File

@ -7,7 +7,6 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3register
#[cfg(feature = "unstable-msc2918")]
use std::time::Duration;
use ruma_common::{api::ruma_api, DeviceId, OwnedDeviceId, OwnedUserId};
@ -85,8 +84,9 @@ pub mod v3 {
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub login_type: Option<&'a LoginType>,
/// If set to `true`, the client supports refresh tokens.
#[cfg(feature = "unstable-msc2918")]
/// If set to `true`, the client supports [refresh tokens].
///
/// [refresh tokens]: https://spec.matrix.org/v1.3/client-server-api/#refreshing-access-tokens
#[serde(
default,
skip_serializing_if = "ruma_common::serde::is_default",
@ -115,13 +115,15 @@ pub mod v3 {
/// Required if the request's `inhibit_login` was set to `false`.
pub device_id: Option<OwnedDeviceId>,
/// A refresh token for the account.
/// A [refresh token] for the account.
///
/// This token can be used to obtain a new access token when it expires by calling the
/// `/refresh` endpoint.
/// [`refresh_token`] endpoint.
///
/// Omitted if the request's `inhibit_login` was set to `true`.
#[cfg(feature = "unstable-msc2918")]
///
/// [refresh token]: https://spec.matrix.org/v1.3/client-server-api/#refreshing-access-tokens
/// [`refresh_token`]: crate::session::refresh_token
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<String>,
@ -134,7 +136,6 @@ pub mod v3 {
/// If this is `None`, the client can assume that the access token will not expire.
///
/// Omitted if the request's `inhibit_login` was set to `true`.
#[cfg(feature = "unstable-msc2918")]
#[serde(
with = "ruma_common::serde::duration::opt_ms",
default,
@ -161,9 +162,7 @@ pub mod v3 {
access_token: None,
user_id,
device_id: None,
#[cfg(feature = "unstable-msc2918")]
refresh_token: None,
#[cfg(feature = "unstable-msc2918")]
expires_in: None,
}
}

View File

@ -5,7 +5,6 @@ pub mod login;
pub mod login_fallback;
pub mod logout;
pub mod logout_all;
#[cfg(feature = "unstable-msc2918")]
pub mod refresh_token;
pub mod sso_login;
pub mod sso_login_with_provider;

View File

@ -5,7 +5,6 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3login
#[cfg(feature = "unstable-msc2918")]
use std::time::Duration;
use ruma_common::{
@ -48,8 +47,9 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
pub initial_device_display_name: Option<&'a str>,
/// If set to `true`, the client supports refresh tokens.
#[cfg(feature = "unstable-msc2918")]
/// If set to `true`, the client supports [refresh tokens].
///
/// [refresh tokens]: https://spec.matrix.org/v1.3/client-server-api/#refreshing-access-tokens
#[serde(
default,
skip_serializing_if = "ruma_common::serde::is_default",
@ -85,11 +85,13 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
pub well_known: Option<DiscoveryInfo>,
/// A refresh token for the account.
/// A [refresh token] for the account.
///
/// This token can be used to obtain a new access token when it expires by calling the
/// `/refresh` endpoint.
#[cfg(feature = "unstable-msc2918")]
/// [`refresh_token`] endpoint.
///
/// [refresh token]: https://spec.matrix.org/v1.3/client-server-api/#refreshing-access-tokens
/// [`refresh_token`]: crate::session::refresh_token
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<String>,
@ -100,7 +102,6 @@ pub mod v3 {
/// re-login to obtain a new access token.
///
/// If this is `None`, the client can assume that the access token will not expire.
#[cfg(feature = "unstable-msc2918")]
#[serde(
with = "ruma_common::serde::duration::opt_ms",
default,
@ -120,7 +121,6 @@ pub mod v3 {
login_info,
device_id: None,
initial_device_display_name: None,
#[cfg(feature = "unstable-msc2918")]
refresh_token: false,
}
}
@ -135,9 +135,7 @@ pub mod v3 {
home_server: None,
device_id,
well_known: None,
#[cfg(feature = "unstable-msc2918")]
refresh_token: None,
#[cfg(feature = "unstable-msc2918")]
expires_in: None,
}
}
@ -424,7 +422,6 @@ pub mod v3 {
login_info: LoginInfo::Token(Token { token: "0xdeadbeef" }),
device_id: None,
initial_device_display_name: Some("test"),
#[cfg(feature = "unstable-msc2918")]
refresh_token: false,
}
.try_into_http_request(
@ -451,7 +448,6 @@ pub mod v3 {
}),
device_id: None,
initial_device_display_name: Some("test"),
#[cfg(feature = "unstable-msc2918")]
refresh_token: false,
}
.try_into_http_request(

View File

@ -20,10 +20,10 @@
//!
//! Application Service identity assertion is disabled for this endpoint.
pub mod unstable {
//! `/unstable/` (MSC2918)
pub mod v3 {
//! `/v3/` ([spec])
//!
//! [MSC2918]: https://github.com/matrix-org/matrix-spec-proposals/pull/2918
//! [spec]: https://spec.matrix.org/v1.3/client-server-api/#post_matrixclientv3refresh
use std::time::Duration;
@ -35,8 +35,10 @@ pub mod unstable {
method: POST,
name: "refresh",
unstable_path: "/_matrix/client/unstable/org.matrix.msc2918/refresh",
stable_path: "/_matrix/client/v3/refresh",
rate_limited: true,
authentication: None,
added: 1.3,
}
request: {

View File

@ -139,7 +139,6 @@ unstable-msc2677 = [
]
unstable-msc2746 = ["ruma-common/unstable-msc2746"]
unstable-msc2870 = ["ruma-signatures?/unstable-msc2870"]
unstable-msc2918 = ["ruma-client-api?/unstable-msc2918"]
unstable-msc3245 = ["ruma-common/unstable-msc3245"]
unstable-msc3246 = ["ruma-common/unstable-msc3246"]
unstable-msc3316 = ["ruma-client-api?/unstable-msc3316"]
@ -172,7 +171,6 @@ __ci = [
"unstable-msc2677",
"unstable-msc2746",
"unstable-msc2870",
"unstable-msc2918",
"unstable-msc3245",
"unstable-msc3246",
"unstable-msc3316",