Skip to main content

silicon_browser_shared/
delivery.rs

1//! Public state of backend-owned recording authorization. No credentials cross this boundary.
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
5pub struct DeliveryAuthorization {
6    pub configured: bool,
7    pub enabled: bool,
8    pub state: DeliveryAuthorizationState,
9    pub actor_id: String,
10}
11
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
13#[serde(rename_all = "snake_case")]
14pub enum DeliveryAuthorizationState {
15    Unavailable,
16    Pending,
17    Active,
18    Refreshing,
19    NeedsAuth,
20    Revoking,
21    Disabled,
22}
23
24#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
25#[serde(deny_unknown_fields)]
26pub struct DeliveryAuthorizationRequest {
27    pub short_lived_token: String,
28}
29impl std::fmt::Debug for DeliveryAuthorizationRequest {
30    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31        f.debug_struct("DeliveryAuthorizationRequest").field("short_lived_token", &"[REDACTED]").finish()
32    }
33}
34impl crate::Validate for DeliveryAuthorizationRequest {
35    fn validate(&self) -> Result<(), crate::ValidationError> {
36        crate::AuthExchangeRequest { short_lived_token: self.short_lived_token.clone(), org_id: "delivery".into() }
37            .validate()
38    }
39}