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