Skip to main content

tuwunel_api/client/
versions.rs

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