cipherstash-client 0.34.1-alpha.8

The official CipherStash SDK
Documentation
use serde::{Deserialize, Serialize};

/// A pre-obtained service token that callers can pass into ZeroKMS / EQL to
/// short-circuit token acquisition — the client uses this token directly
/// instead of invoking a `stack_auth::AuthStrategy`. The JSON shape
/// (`{accessToken, expiry}`) is part of the wire contract with JS callers
/// (e.g. protect-ffi); change with care.
#[derive(Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ServiceToken {
    #[serde(rename = "accessToken")]
    pub(crate) token: String,
    pub(crate) expiry: u64,
}

opaque_debug::implement!(ServiceToken);

impl ServiceToken {
    pub fn new(token: impl Into<String>, expiry: u64) -> Self {
        Self {
            token: token.into(),
            expiry,
        }
    }

    pub(crate) fn token(&self) -> &str {
        &self.token
    }
}