use core::fmt;
#[derive(Clone, Eq, PartialEq)]
pub struct SupabaseAuth {
api_key: String,
bearer_token: String,
}
impl SupabaseAuth {
pub fn service_role(secret: impl Into<String>) -> Self {
let secret = secret.into();
Self {
api_key: secret.clone(),
bearer_token: secret,
}
}
pub fn new(api_key: impl Into<String>, bearer_token: impl Into<String>) -> Self {
Self {
api_key: api_key.into(),
bearer_token: bearer_token.into(),
}
}
pub fn api_key(&self) -> &str {
&self.api_key
}
pub fn bearer_token(&self) -> &str {
&self.bearer_token
}
}
impl fmt::Debug for SupabaseAuth {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("SupabaseAuth")
.field("api_key", &"<redacted>")
.field("bearer_token", &"<redacted>")
.finish()
}
}