ruma_identity_service_api/lookup/get_hash_parameters.rs
1//! `GET /_matrix/identity/*/hash_details`
2//!
3//! Gets parameters for hashing identifiers from the server. This can include any of the algorithms
4//! defined in the spec.
5
6pub mod v2 {
7 //! `/v2/` ([spec])
8 //!
9 //! [spec]: https://spec.matrix.org/latest/identity-service-api/#get_matrixidentityv2hash_details
10
11 use ruma_common::{
12 api::{request, response, Metadata},
13 metadata,
14 };
15
16 use crate::lookup::IdentifierHashingAlgorithm;
17
18 const METADATA: Metadata = metadata! {
19 method: GET,
20 rate_limited: false,
21 authentication: AccessToken,
22 history: {
23 1.0 => "/_matrix/identity/v2/hash_details",
24 }
25 };
26
27 /// Request type for the `get_hash_parameters` endpoint.
28 #[request]
29 #[derive(Default)]
30 pub struct Request {}
31
32 /// Response type for the `get_hash_parameters` endpoint.
33 #[response]
34 pub struct Response {
35 /// The pepper the client MUST use in hashing identifiers, and MUST supply to the /lookup
36 /// endpoint when performing lookups.
37 ///
38 /// Servers SHOULD rotate this string often.
39 pub lookup_pepper: String,
40
41 /// The algorithms the server supports.
42 ///
43 /// Must contain at least `sha256`.
44 pub algorithms: Vec<IdentifierHashingAlgorithm>,
45 }
46
47 impl Request {
48 /// Creates an empty `Request`.
49 pub fn new() -> Self {
50 Self {}
51 }
52 }
53
54 impl Response {
55 /// Create a new `Response` using the given pepper and `Vec` of algorithms.
56 pub fn new(lookup_pepper: String, algorithms: Vec<IdentifierHashingAlgorithm>) -> Self {
57 Self { lookup_pepper, algorithms }
58 }
59 }
60}