ruma_identity_service_api/keys/
validate_ephemeral_key.rs

1//! `GET /_matrix/identity/*/pubkey/ephemeral/isvalid`
2//!
3//! Check whether a short-term public key is valid.
4
5pub mod v2 {
6    //! `/v2/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/identity-service-api/#get_matrixidentityv2pubkeyephemeralisvalid
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata,
13        third_party_invite::IdentityServerBase64PublicKey,
14    };
15
16    const METADATA: Metadata = metadata! {
17        method: GET,
18        rate_limited: false,
19        authentication: None,
20        history: {
21            1.0 => "/_matrix/identity/v2/pubkey/ephemeral/isvalid",
22        }
23    };
24
25    /// Request type for the `validate_ephemeral_key` endpoint.
26    #[request]
27    pub struct Request {
28        /// The unpadded base64-encoded short-term public key to check.
29        #[ruma_api(query)]
30        pub public_key: IdentityServerBase64PublicKey,
31    }
32
33    /// Response type for the `validate_ephemeral_key` endpoint.
34    #[response]
35    pub struct Response {
36        /// Whether the short-term public key is recognised and is currently valid.
37        pub valid: bool,
38    }
39
40    impl Request {
41        /// Create a `Request` with the given base64-encoded (unpadded) short-term public key.
42        pub fn new(public_key: IdentityServerBase64PublicKey) -> Self {
43            Self { public_key }
44        }
45    }
46
47    impl Response {
48        /// Create a `Response` with the given bool indicating the validity of the short-term public
49        /// key.
50        pub fn new(valid: bool) -> Self {
51            Self { valid }
52        }
53    }
54}