use crate::{authentication, object};
pub const DEFAULT_AUTHENTICATION_KEY_ID: object::Id = 1;
#[derive(Clone, Debug)]
pub struct Credentials {
pub authentication_key_id: object::Id,
pub authentication_key: authentication::Key,
}
impl Credentials {
pub fn new(authentication_key_id: object::Id, authentication_key: authentication::Key) -> Self {
Self {
authentication_key_id,
authentication_key,
}
}
#[cfg(feature = "passwords")]
pub fn from_password(authentication_key_id: object::Id, password: &[u8]) -> Self {
Self::new(
authentication_key_id,
authentication::Key::derive_from_password(password),
)
}
}
#[cfg(feature = "passwords")]
impl Default for Credentials {
fn default() -> Self {
Self::new(
DEFAULT_AUTHENTICATION_KEY_ID,
authentication::Key::default(),
)
}
}