Skip to main content

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
37/// Returned by [`EhppEP`].
38#[derive(Serialize, Deserialize, Debug, Clone)]
39#[serde(deny_unknown_fields)]
40#[serde(rename = "snake_case")]
41#[must_use]
42pub enum EhppResp {
43    RetryWithNewPpp,
44
45    /// The requested encrypted hub pseudonym package
46    Success(Sealed<sso::EncryptedHubPseudonymPackage>),
47}