use anyhow::Result;
use tangled_api::lexicon::com::atproto::server;
use super::auth::PdsAuth;
pub async fn mint(
pds_base: &str,
auth: &PdsAuth,
service_base: &str,
lxm: &str,
) -> Result<String> {
let trimmed = service_base.trim_end_matches('/');
let host = trimmed
.strip_prefix("https://")
.or_else(|| trimmed.strip_prefix("http://"))
.unwrap_or(trimmed);
let params = server::get_service_auth::Params {
aud: format!("did:web:{host}"),
exp: Some(chrono::Utc::now().timestamp() + 60),
lxm: Some(lxm.to_string()),
};
let rb = server::get_service_auth(super::http(), pds_base, ¶ms);
let out: server::get_service_auth::Output = auth.send(rb).await?;
Ok(out.token)
}