pubhubs/api/tr.rs
1//! Additional endpoints provided by the Transcryptor
2
3use crate::api::*;
4
5use actix_web::http;
6use serde::{Deserialize, Serialize};
7
8use crate::id;
9
10/// Requests an [`sso::EncryptedHubPseudonymPackage`].
11pub struct EhppEP {}
12impl EndpointDetails for EhppEP {
13 type RequestType = EhppReq;
14 type ResponseType = Result<EhppResp>;
15
16 const METHOD: http::Method = http::Method::POST;
17 const PATH: &'static str = ".ph/ehpp";
18}
19
20/// Request type of [`EhppEP`].
21#[derive(Serialize, Deserialize, Debug, Clone)]
22#[serde(deny_unknown_fields)]
23#[serde(rename = "snake_case")]
24pub struct EhppReq {
25 /// What [`sso::EncryptedHubPseudonymPackage::hub_nonce`] to use.
26 pub hub_nonce: hub::EnterNonce,
27
28 /// Requests a pseudonym for this hub.
29 /// (Hub ids can be obtained via [`phc::user::WelcomeEP`].)
30 pub hub: id::Id,
31
32 /// The polymorphic pseudonym from which to create the hub pseudonym.
33 /// Can be obtained from [`phc::user::PppEP`].
34 pub ppp: Sealed<sso::PolymorphicPseudonymPackage>,
35
36 /// Per-session key from [`hub::EnterStartResp::hub_mac_key`], relayed by the global client; when
37 /// present the transcryptor returns [`sso::EncryptedHubPseudonymPackage::hub_id_mac`] binding
38 /// [`Self::hub`]. `None` for hubs predating the check.
39 ///
40 /// TODO: remove once all hubs are >3.4.0.
41 #[serde(default, skip_serializing_if = "Option::is_none")]
42 pub hub_mac_key: Option<hub::HubMacKey>,
43}
44
45/// Returned by [`EhppEP`].
46#[derive(Serialize, Deserialize, Debug, Clone)]
47#[serde(deny_unknown_fields)]
48#[serde(rename = "snake_case")]
49#[must_use]
50pub enum EhppResp {
51 RetryWithNewPpp,
52
53 /// The requested encrypted hub pseudonym package
54 Success(Sealed<sso::EncryptedHubPseudonymPackage>),
55}