1use actix_web::http;
3use serde::{Deserialize, Serialize};
4
5use crate::api::*;
6use crate::misc::serde_ext::bytes_wrapper::B64UU;
7
8pub struct InfoEP {}
10impl EndpointDetails for InfoEP {
11 type RequestType = NoPayload;
12 type ResponseType = Result<InfoResp>;
13
14 const METHOD: http::Method = http::Method::GET;
15 const PATH: &'static str = ".ph/info";
16}
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
19#[serde(deny_unknown_fields)]
20#[must_use]
21pub struct InfoResp {
22 #[serde(default)]
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub verifying_key: Option<VerifyingKey>,
28
29 pub hub_version: String,
31
32 pub hub_client_url: url::Url,
34
35 #[serde(default)]
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub dynamic: Option<DynamicHubInfo>,
39}
40
41#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
43#[serde(deny_unknown_fields)]
44#[must_use]
45pub struct DynamicHubInfo {
46 pub last_reload: NumericDate,
48
49 pub settings: serde_json::Value,
51}
52
53pub struct EnterStartEP {}
55impl EndpointDetails for EnterStartEP {
56 type RequestType = NoPayload;
57 type ResponseType = Result<EnterStartResp>;
58
59 const METHOD: http::Method = http::Method::POST; const PATH: &'static str = ".ph/enter-start";
61}
62
63#[derive(Serialize, Deserialize, Debug, Clone)]
65#[serde(deny_unknown_fields)]
66#[must_use]
67pub struct EnterStartResp {
68 pub state: EnterState,
70
71 pub nonce: EnterNonce,
73}
74
75#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
77#[serde(transparent)]
78pub struct EnterState {
79 pub(crate) inner: B64UU,
80}
81
82impl From<B64UU> for EnterState {
83 fn from(inner: B64UU) -> Self {
84 Self { inner }
85 }
86}
87
88#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
90#[serde(transparent)]
91pub struct EnterNonce {
92 pub(crate) inner: B64UU,
93}
94impl From<B64UU> for EnterNonce {
95 fn from(inner: B64UU) -> Self {
96 Self { inner }
97 }
98}
99
100pub struct EnterCompleteEP {}
102impl EndpointDetails for EnterCompleteEP {
103 type RequestType = EnterCompleteReq;
104 type ResponseType = Result<EnterCompleteResp>;
105
106 const METHOD: http::Method = http::Method::POST; const PATH: &'static str = ".ph/enter-complete";
108}
109
110#[derive(Serialize, Deserialize, Debug, Clone)]
112#[serde(deny_unknown_fields)]
113pub struct EnterCompleteReq {
114 pub state: EnterState,
116
117 pub hhpp: Signed<sso::HashedHubPseudonymPackage>,
120}
121
122#[derive(Serialize, Deserialize, Debug, Clone)]
124#[serde(deny_unknown_fields)]
125#[must_use]
126pub enum EnterCompleteResp {
127 RetryFromStart,
129
130 Entered {
131 access_token: String,
133
134 device_id: String,
136
137 new_user: bool,
139
140 mxid: String,
142 },
143}