#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct WebauthnCredential {
pub credential_id: String,
pub public_key_cose: Vec<u8>,
pub sign_count: u32,
pub device_name: String,
pub registered_at: i64,
pub last_used_at: i64,
pub attestation_format: String,
pub user_verified: bool,
pub backup_eligible: bool,
pub backup_state: bool,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct RegistrationOptions {
pub challenge: String,
pub rp: RelyingParty,
pub user: WebauthnUser,
#[cfg_attr(feature = "serde", serde(rename = "pubKeyCredParams"))]
pub pub_key_cred_params: Vec<PubKeyCredParam>,
pub timeout: u64,
#[cfg_attr(feature = "serde", serde(rename = "excludeCredentials"))]
pub exclude_credentials: Vec<ExcludeCredential>,
pub attestation: String,
#[cfg_attr(feature = "serde", serde(rename = "authenticatorSelection"))]
pub authenticator_selection: AuthenticatorSelection,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct RelyingParty {
pub id: String,
pub name: String,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct WebauthnUser {
pub id: String,
pub name: String,
#[cfg_attr(feature = "serde", serde(rename = "displayName"))]
pub display_name: String,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PubKeyCredParam {
pub alg: i32,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub type_: String,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ExcludeCredential {
pub id: String,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub type_: String,
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub transports: Option<Vec<String>>,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AuthenticatorSelection {
#[cfg_attr(feature = "serde", serde(rename = "residentKey"))]
pub resident_key: String,
#[cfg_attr(feature = "serde", serde(rename = "userVerification"))]
pub user_verification: String,
#[cfg_attr(feature = "serde", serde(rename = "requireResidentKey", default))]
pub require_resident_key: bool,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct RegistrationResponse {
pub client_data_json: String,
pub attestation_object: String,
#[cfg_attr(feature = "serde", serde(default))]
pub transports: Vec<String>,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AuthenticationOptions {
pub challenge: String,
#[cfg_attr(feature = "serde", serde(rename = "rpId"))]
pub rp_id: String,
#[cfg_attr(feature = "serde", serde(rename = "allowCredentials"))]
pub allow_credentials: Vec<AllowCredential>,
pub timeout: u64,
#[cfg_attr(feature = "serde", serde(rename = "userVerification"))]
pub user_verification: String,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AllowCredential {
pub id: String,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub type_: String,
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub transports: Option<Vec<String>>,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct AuthenticationResponse {
pub id: String,
pub client_data_json: String,
pub authenticator_data: String,
pub signature: String,
pub user_handle: Option<String>,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct RegistrationResult {
pub credential_id: String,
pub device_name: String,
pub attestation_format: String,
pub attestation: crate::attestation::AttestationResult,
pub user_verified: bool,
pub backup_eligible: bool,
pub backup_state: bool,
}
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct AuthenticationResult {
pub credential_id: String,
pub new_sign_count: u32,
pub user_verified: bool,
pub backup_state: bool,
pub backup_eligible: bool,
}