obscura-server 0.8.0

A server for relaying secure messages using the Signal Protocol
Documentation
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
pub(crate) struct Claims {
    pub sub: Uuid,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub device_id: Option<Uuid>,
    pub exp: usize,
}
impl Claims {
    #[must_use]
    pub(crate) const fn new(user_id: Uuid, device_id: Option<Uuid>, exp: usize) -> Self {
        Self { sub: user_id, device_id, exp }
    }
}

#[derive(Clone, PartialEq, Eq)]
pub struct Jwt(pub String);
impl Jwt {
    #[must_use]
    pub const fn new(token: String) -> Self {
        Self(token)
    }

    #[must_use]
    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl std::fmt::Debug for Jwt {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "Jwt(***)")
    }
}

impl std::fmt::Display for Jwt {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "***")
    }
}

#[derive(Debug)]
pub struct Password;
#[derive(Debug)]
pub struct OpaqueToken;