mod ops;
use systemprompt_identifiers::{ClientId, RefreshTokenId, UserId};
#[derive(Debug)]
pub struct RefreshTokenParams<'a> {
pub token_id: &'a RefreshTokenId,
pub client_id: &'a ClientId,
pub user_id: &'a UserId,
pub scope: &'a str,
pub expires_at: i64,
pub family_id: Option<&'a str>,
}
#[derive(Debug)]
pub struct RefreshTokenParamsBuilder<'a> {
token_id: &'a RefreshTokenId,
client_id: &'a ClientId,
user_id: &'a UserId,
scope: &'a str,
expires_at: i64,
family_id: Option<&'a str>,
}
impl<'a> RefreshTokenParamsBuilder<'a> {
pub const fn new(
token_id: &'a RefreshTokenId,
client_id: &'a ClientId,
user_id: &'a UserId,
scope: &'a str,
expires_at: i64,
) -> Self {
Self {
token_id,
client_id,
user_id,
scope,
expires_at,
family_id: None,
}
}
pub const fn with_family(mut self, family_id: &'a str) -> Self {
self.family_id = Some(family_id);
self
}
pub const fn build(self) -> RefreshTokenParams<'a> {
RefreshTokenParams {
token_id: self.token_id,
client_id: self.client_id,
user_id: self.user_id,
scope: self.scope,
expires_at: self.expires_at,
family_id: self.family_id,
}
}
}
impl<'a> RefreshTokenParams<'a> {
pub const fn builder(
token_id: &'a RefreshTokenId,
client_id: &'a ClientId,
user_id: &'a UserId,
scope: &'a str,
expires_at: i64,
) -> RefreshTokenParamsBuilder<'a> {
RefreshTokenParamsBuilder::new(token_id, client_id, user_id, scope, expires_at)
}
}
#[derive(Debug)]
pub struct ConsumedRefreshToken {
pub user_id: UserId,
pub scope: String,
pub family_id: String,
}