tuwunel_api/client/versions.rs
1use std::iter::once;
2
3use axum::extract::State;
4use ruma::api::client::discovery::get_supported_versions::{self, Server};
5use tuwunel_core::{
6 Result,
7 info::rustc::version as rustc_version,
8 version::{name as package_name, version as package_version},
9};
10
11use crate::Ruma;
12
13/// # `GET /_matrix/client/versions`
14///
15/// Get the versions of the specification and unstable features supported by
16/// this server.
17///
18/// - Versions take the form MAJOR.MINOR.PATCH
19/// - Only the latest PATCH release will be reported for each MAJOR.MINOR value
20/// - Unstable features are namespaced and may include version information in
21/// their name
22///
23/// Note: Unstable features are used while developing new features. Clients
24/// should avoid using unstable features in their stable releases
25pub(crate) async fn get_supported_versions_route(
26 State(services): State<crate::State>,
27 _body: Ruma<get_supported_versions::Request>,
28) -> Result<get_supported_versions::Response> {
29 // MSC4383: client-side parity with /_matrix/federation/v1/version.
30 let server = Server {
31 compiler: rustc_version().map(Into::into),
32 ..Server::new(package_name().into(), package_version().into())
33 };
34
35 Ok(get_supported_versions::Response {
36 versions: VERSIONS.into_iter().map(Into::into).collect(),
37
38 unstable_features: UNSTABLE_FEATURES
39 .into_iter()
40 .chain(
41 services
42 .config
43 .rendezvous_enabled
44 .then_some("org.matrix.msc4108"),
45 )
46 .map(Into::into)
47 .zip(once(true).cycle())
48 .collect(),
49
50 server: Some(server),
51 })
52}
53
54static VERSIONS: [&str; 27] = [
55 "r0.0.1", /* Historical */
56 "r0.1.0", /* Historical */
57 "r0.2.0", /* Historical */
58 "r0.3.0", /* Historical */
59 "r0.4.0", /* Historical */
60 "r0.5.0", /* Historical */
61 "r0.6.0", /* Historical */
62 "r0.6.1", /* Historical */
63 "v1.1", /* Stable; Tested */
64 "v1.2", /* Stable; Tested */
65 "v1.3", /* Stable; Tested */
66 "v1.4", /* Tested; private read receipts, threads */
67 "v1.5", /* Stable; Tested */
68 "v1.6", /* jump to date (element-web labs gate) */
69 "v1.7", /* intentional mentions */
70 "v1.8", /* no action */
71 "v1.9", /* no action */
72 "v1.10", /* Tested; relations recursion */
73 "v1.11", /* Tested; authenticated media */
74 "v1.12", /* no action */
75 "v1.13", /* no action */
76 "v1.14", /* no action */
77 "v1.15", /* OIDC auth metadata */
78 "v1.16", /* extended profiles (MSC4133) */
79 "v1.17", /* no action */
80 "v1.18", /* policy servers (MSC4284) */
81 "v1.19", /* mutual rooms (MSC2666) */
82];
83
84static UNSTABLE_FEATURES: [&str; 38] = [
85 "org.matrix.e2e_cross_signing",
86 // private read receipts (https://github.com/matrix-org/matrix-spec-proposals/pull/2285)
87 "org.matrix.msc2285.stable",
88 // appservice ping https://github.com/matrix-org/matrix-spec-proposals/pull/2659)
89 "fi.mau.msc2659.stable",
90 // query mutual rooms (https://github.com/matrix-org/matrix-spec-proposals/pull/2666)
91 "uk.half-shot.msc2666.query_mutual_rooms",
92 "uk.half-shot.msc2666.query_mutual_rooms.stable",
93 // threading/threads (https://github.com/matrix-org/matrix-spec-proposals/pull/2836)
94 "org.matrix.msc2836",
95 // jump to date (https://github.com/matrix-org/matrix-spec-proposals/pull/3030)
96 "org.matrix.msc3030",
97 // spaces/hierarchy summaries (https://github.com/matrix-org/matrix-spec-proposals/pull/2946)
98 "org.matrix.msc2946",
99 // busy presence status (https://github.com/matrix-org/matrix-spec-proposals/pull/3026)
100 "org.matrix.msc3026.busy_presence",
101 // sliding sync (https://github.com/matrix-org/matrix-spec-proposals/pull/3575/files#r1588877046)
102 "org.matrix.msc3575",
103 // dehydrated devices
104 "org.matrix.msc3814",
105 // filtering of /publicRooms by room type (https://github.com/matrix-org/matrix-spec-proposals/pull/3827)
106 "org.matrix.msc3827",
107 "org.matrix.msc3827.stable",
108 // authenticated media (https://github.com/matrix-org/matrix-spec-proposals/pull/3916)
109 "org.matrix.msc3916.stable",
110 // intentional mentions (https://github.com/matrix-org/matrix-spec-proposals/pull/3952)
111 "org.matrix.msc3952_intentional_mentions",
112 // MatrixRTC transport discovery (https://github.com/matrix-org/matrix-spec-proposals/pull/4143)
113 "org.matrix.msc4143",
114 // MSC4133 (custom profile fields) and MSC4175 (m.tz) stabilized in
115 // Matrix 1.16; advertise the historical unstable prefixes alongside
116 // the post-merge `.stable` flags for clients that haven't migrated.
117 "uk.tcpip.msc4133",
118 "uk.tcpip.msc4133.stable",
119 "us.cloke.msc4175",
120 "us.cloke.msc4175.stable",
121 // stable flag for 3916 (https://github.com/matrix-org/matrix-spec-proposals/pull/4180)
122 "org.matrix.msc4180",
123 // Simplified Sliding sync (https://github.com/matrix-org/matrix-spec-proposals/pull/4186)
124 "org.matrix.simplified_msc3575",
125 // Allow room moderators to view redacted event content (https://github.com/matrix-org/matrix-spec-proposals/pull/2815)
126 "fi.mau.msc2815",
127 // OIDC-native auth umbrella (https://github.com/matrix-org/matrix-spec-proposals/pull/3861)
128 "org.matrix.msc3861",
129 // OIDC-native auth: authorization code grant (https://github.com/matrix-org/matrix-spec-proposals/pull/2964)
130 "org.matrix.msc2964",
131 // OIDC-native auth: auth issuer discovery (https://github.com/matrix-org/matrix-spec-proposals/pull/2965)
132 "org.matrix.msc2965",
133 // OIDC-native auth: dynamic client registration (https://github.com/matrix-org/matrix-spec-proposals/pull/2966)
134 "org.matrix.msc2966",
135 // OIDC-native auth: API scopes (https://github.com/matrix-org/matrix-spec-proposals/pull/2967)
136 "org.matrix.msc2967",
137 // OIDC delegation aware
138 "org.matrix.msc3824",
139 // Backwards-compatible redaction sending via /send (https://github.com/matrix-org/matrix-spec-proposals/pull/4169)
140 "com.beeper.msc4169",
141 // Invite blocking via m.invite_permission_config (https://github.com/matrix-org/matrix-spec-proposals/pull/4380)
142 "org.matrix.msc4380",
143 "org.matrix.msc4380.stable",
144 // Client-server discovery of server version (https://github.com/matrix-org/matrix-spec-proposals/pull/4383)
145 "net.zemos.msc4383",
146 // Policy servers (https://github.com/matrix-org/matrix-spec-proposals/pull/4284)
147 "org.matrix.msc4284",
148 // Read receipts for threads (https://github.com/matrix-org/matrix-spec-proposals/pull/3771)
149 "org.matrix.msc3771",
150 // Notifications for threads (https://github.com/matrix-org/matrix-spec-proposals/pull/3773)
151 "org.matrix.msc3773",
152 // Threading via m.thread relations, stable since Matrix 1.4 (https://github.com/matrix-org/matrix-spec-proposals/pull/3440)
153 "org.matrix.msc3440.stable",
154 // state_after on /sync (https://github.com/matrix-org/matrix-spec-proposals/pull/4222)
155 "org.matrix.msc4222",
156];