use serde::{Deserialize, Serialize};
pub type AuthenticatorId = String;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AuthenticatorProtocol {
#[serde(rename = "u2f")]
U2f,
#[serde(rename = "ctap2")]
Ctap2,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Ctap2Version {
#[serde(rename = "ctap2_0")]
Ctap20,
#[serde(rename = "ctap2_1")]
Ctap21,
#[serde(rename = "ctap2_2")]
Ctap22,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AuthenticatorTransport {
#[serde(rename = "usb")]
Usb,
#[serde(rename = "nfc")]
Nfc,
#[serde(rename = "ble")]
Ble,
#[serde(rename = "cable")]
Cable,
#[serde(rename = "hybrid")]
Hybrid,
#[serde(rename = "smart-card")]
SmartCard,
#[serde(rename = "internal")]
Internal,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct VirtualAuthenticatorOptions {
pub protocol: AuthenticatorProtocol,
#[serde(
rename = "ctap2Version",
default,
skip_serializing_if = "Option::is_none"
)]
pub ctap2_version: Option<Ctap2Version>,
pub transport: AuthenticatorTransport,
#[serde(
rename = "hasResidentKey",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_resident_key: Option<bool>,
#[serde(
rename = "hasUserVerification",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_user_verification: Option<bool>,
#[serde(
rename = "hasLargeBlob",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_large_blob: Option<bool>,
#[serde(
rename = "hasCredBlob",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_cred_blob: Option<bool>,
#[serde(
rename = "hasMinPinLength",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_min_pin_length: Option<bool>,
#[serde(rename = "hasPrf", default, skip_serializing_if = "Option::is_none")]
pub has_prf: Option<bool>,
#[serde(
rename = "hasHmacSecret",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_hmac_secret: Option<bool>,
#[serde(
rename = "hasHmacSecretMc",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_hmac_secret_mc: Option<bool>,
#[serde(
rename = "hasCmtgKey",
default,
skip_serializing_if = "Option::is_none"
)]
pub has_cmtg_key: Option<bool>,
#[serde(
rename = "automaticPresenceSimulation",
default,
skip_serializing_if = "Option::is_none"
)]
pub automatic_presence_simulation: Option<bool>,
#[serde(
rename = "isUserVerified",
default,
skip_serializing_if = "Option::is_none"
)]
pub is_user_verified: Option<bool>,
#[serde(
rename = "defaultBackupEligibility",
default,
skip_serializing_if = "Option::is_none"
)]
pub default_backup_eligibility: Option<bool>,
#[serde(
rename = "defaultBackupState",
default,
skip_serializing_if = "Option::is_none"
)]
pub default_backup_state: Option<bool>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Credential {
#[serde(rename = "credentialId")]
pub credential_id: String,
#[serde(rename = "isResidentCredential")]
pub is_resident_credential: bool,
#[serde(rename = "rpId", default, skip_serializing_if = "Option::is_none")]
pub rp_id: Option<String>,
#[serde(rename = "privateKey")]
pub private_key: String,
#[serde(
rename = "userHandle",
default,
skip_serializing_if = "Option::is_none"
)]
pub user_handle: Option<String>,
#[serde(rename = "signCount")]
pub sign_count: f64,
#[serde(rename = "largeBlob", default, skip_serializing_if = "Option::is_none")]
pub large_blob: Option<String>,
#[serde(
rename = "backupEligibility",
default,
skip_serializing_if = "Option::is_none"
)]
pub backup_eligibility: Option<bool>,
#[serde(
rename = "backupState",
default,
skip_serializing_if = "Option::is_none"
)]
pub backup_state: Option<bool>,
#[serde(rename = "userName", default, skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
#[serde(
rename = "userDisplayName",
default,
skip_serializing_if = "Option::is_none"
)]
pub user_display_name: Option<String>,
#[serde(rename = "cmtgKeys", default, skip_serializing_if = "Option::is_none")]
pub cmtg_keys: Option<Vec<String>>,
#[serde(
rename = "activeCmtgKeyIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub active_cmtg_key_index: Option<i64>,
#[serde(
rename = "generateCmtgKeyOnNextOperation",
default,
skip_serializing_if = "Option::is_none"
)]
pub generate_cmtg_key_on_next_operation: Option<bool>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {
#[serde(rename = "enableUI", default, skip_serializing_if = "Option::is_none")]
pub enable_ui: Option<bool>,
}
impl crate::typed::Command for EnableParams {
const METHOD: &'static str = "WebAuthn.enable";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}
impl crate::typed::Command for DisableParams {
const METHOD: &'static str = "WebAuthn.disable";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AddVirtualAuthenticatorParams {
pub options: VirtualAuthenticatorOptions,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddVirtualAuthenticatorReturns {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
}
impl crate::typed::Command for AddVirtualAuthenticatorParams {
const METHOD: &'static str = "WebAuthn.addVirtualAuthenticator";
type Returns = AddVirtualAuthenticatorReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetResponseOverrideBitsParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
#[serde(
rename = "isBogusSignature",
default,
skip_serializing_if = "Option::is_none"
)]
pub is_bogus_signature: Option<bool>,
#[serde(rename = "isBadUV", default, skip_serializing_if = "Option::is_none")]
pub is_bad_uv: Option<bool>,
#[serde(rename = "isBadUP", default, skip_serializing_if = "Option::is_none")]
pub is_bad_up: Option<bool>,
}
impl crate::typed::Command for SetResponseOverrideBitsParams {
const METHOD: &'static str = "WebAuthn.setResponseOverrideBits";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RemoveVirtualAuthenticatorParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
}
impl crate::typed::Command for RemoveVirtualAuthenticatorParams {
const METHOD: &'static str = "WebAuthn.removeVirtualAuthenticator";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddCredentialParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
pub credential: Credential,
}
impl crate::typed::Command for AddCredentialParams {
const METHOD: &'static str = "WebAuthn.addCredential";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetCredentialParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
#[serde(rename = "credentialId")]
pub credential_id: String,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetCredentialReturns {
pub credential: Credential,
}
impl crate::typed::Command for GetCredentialParams {
const METHOD: &'static str = "WebAuthn.getCredential";
type Returns = GetCredentialReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetCredentialsParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetCredentialsReturns {
pub credentials: Vec<Credential>,
}
impl crate::typed::Command for GetCredentialsParams {
const METHOD: &'static str = "WebAuthn.getCredentials";
type Returns = GetCredentialsReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RemoveCredentialParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
#[serde(rename = "credentialId")]
pub credential_id: String,
}
impl crate::typed::Command for RemoveCredentialParams {
const METHOD: &'static str = "WebAuthn.removeCredential";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ClearCredentialsParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
}
impl crate::typed::Command for ClearCredentialsParams {
const METHOD: &'static str = "WebAuthn.clearCredentials";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetUserVerifiedParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
#[serde(rename = "isUserVerified")]
pub is_user_verified: bool,
}
impl crate::typed::Command for SetUserVerifiedParams {
const METHOD: &'static str = "WebAuthn.setUserVerified";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetAutomaticPresenceSimulationParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
pub enabled: bool,
}
impl crate::typed::Command for SetAutomaticPresenceSimulationParams {
const METHOD: &'static str = "WebAuthn.setAutomaticPresenceSimulation";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetCredentialPropertiesParams {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
#[serde(rename = "credentialId")]
pub credential_id: String,
#[serde(
rename = "backupEligibility",
default,
skip_serializing_if = "Option::is_none"
)]
pub backup_eligibility: Option<bool>,
#[serde(
rename = "backupState",
default,
skip_serializing_if = "Option::is_none"
)]
pub backup_state: Option<bool>,
#[serde(
rename = "activeCmtgKeyIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub active_cmtg_key_index: Option<i64>,
#[serde(
rename = "generateCmtgKeyOnNextOperation",
default,
skip_serializing_if = "Option::is_none"
)]
pub generate_cmtg_key_on_next_operation: Option<bool>,
#[serde(rename = "signCount", default, skip_serializing_if = "Option::is_none")]
pub sign_count: Option<f64>,
}
impl crate::typed::Command for SetCredentialPropertiesParams {
const METHOD: &'static str = "WebAuthn.setCredentialProperties";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CredentialAddedEvent {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
pub credential: Credential,
}
impl crate::typed::Event for CredentialAddedEvent {
const METHOD: &'static str = "WebAuthn.credentialAdded";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CredentialDeletedEvent {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
#[serde(rename = "credentialId")]
pub credential_id: String,
}
impl crate::typed::Event for CredentialDeletedEvent {
const METHOD: &'static str = "WebAuthn.credentialDeleted";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CredentialUpdatedEvent {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
pub credential: Credential,
}
impl crate::typed::Event for CredentialUpdatedEvent {
const METHOD: &'static str = "WebAuthn.credentialUpdated";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CredentialAssertedEvent {
#[serde(rename = "authenticatorId")]
pub authenticator_id: AuthenticatorId,
pub credential: Credential,
}
impl crate::typed::Event for CredentialAssertedEvent {
const METHOD: &'static str = "WebAuthn.credentialAsserted";
}