pub struct Client<S, U, P>where
S: CredentialStore + Sync,
U: UserValidationMethod + Sync,
P: EffectiveTLDProvider + Sync + 'static,{ /* private fields */ }
Expand description
A Client
represents a Webauthn client. Users of this struct should supply a
CredentialStore
, a UserValidationMethod
and, optionally, an implementation of
public_suffix::EffectiveTLDProvider
.
The tld_provider
is used to verify effective Top-Level Domains for request origins presented
to the client. Most applications can use the new()
function, which creates a Client
with a
default provider implementation. Use new_with_custom_tld_provider()
to provide a custom
EffectiveTLDProvider
if your application needs to interpret eTLDs differently from the Mozilla
Public Suffix List.
Implementations§
Source§impl<S, U> Client<S, U, PublicSuffixList>where
S: CredentialStore + Sync,
U: UserValidationMethod + Sync,
Passkey: TryFrom<<S as CredentialStore>::PasskeyItem>,
impl<S, U> Client<S, U, PublicSuffixList>where
S: CredentialStore + Sync,
U: UserValidationMethod + Sync,
Passkey: TryFrom<<S as CredentialStore>::PasskeyItem>,
Sourcepub fn new(authenticator: Authenticator<S, U>) -> Self
pub fn new(authenticator: Authenticator<S, U>) -> Self
Create a Client
with a given Authenticator
that uses the default
TLD verifier provided by [public_suffix]
.
Source§impl<S, U, P> Client<S, U, P>where
S: CredentialStore + Sync,
U: UserValidationMethod<PasskeyItem = <S as CredentialStore>::PasskeyItem> + Sync,
P: EffectiveTLDProvider + Sync + 'static,
impl<S, U, P> Client<S, U, P>where
S: CredentialStore + Sync,
U: UserValidationMethod<PasskeyItem = <S as CredentialStore>::PasskeyItem> + Sync,
P: EffectiveTLDProvider + Sync + 'static,
Sourcepub fn new_with_custom_tld_provider(
authenticator: Authenticator<S, U>,
custom_provider: P,
) -> Self
pub fn new_with_custom_tld_provider( authenticator: Authenticator<S, U>, custom_provider: P, ) -> Self
Create a Client
with a given Authenticator
and a custom TLD provider
that implements [public_suffix::EffectiveTLDProvider]
.
Sourcepub fn allows_insecure_localhost(self, is_allowed: bool) -> Self
pub fn allows_insecure_localhost(self, is_allowed: bool) -> Self
Allows the internal RpIdVerifier to pass through localhost requests.
Sourcepub fn authenticator(&self) -> &Authenticator<S, U>
pub fn authenticator(&self) -> &Authenticator<S, U>
Read access to the Client’s Authenticator
.
Sourcepub fn authenticator_mut(&mut self) -> &mut Authenticator<S, U>
pub fn authenticator_mut(&mut self) -> &mut Authenticator<S, U>
Write access to the Client’s Authenticator
.
Sourcepub async fn register<D: ClientData<E>, E: Serialize + Clone>(
&mut self,
origin: impl Into<Origin<'_>>,
request: CredentialCreationOptions,
client_data: D,
) -> Result<CreatedPublicKeyCredential, WebauthnError>
pub async fn register<D: ClientData<E>, E: Serialize + Clone>( &mut self, origin: impl Into<Origin<'_>>, request: CredentialCreationOptions, client_data: D, ) -> Result<CreatedPublicKeyCredential, WebauthnError>
Register a webauthn request
from the given origin
.
Returns either a webauthn::CreatedPublicKeyCredential
on success or some WebauthnError
Sourcepub async fn authenticate<D: ClientData<E>, E: Serialize + Clone>(
&mut self,
origin: impl Into<Origin<'_>>,
request: CredentialRequestOptions,
client_data: D,
) -> Result<AuthenticatedPublicKeyCredential, WebauthnError>
pub async fn authenticate<D: ClientData<E>, E: Serialize + Clone>( &mut self, origin: impl Into<Origin<'_>>, request: CredentialRequestOptions, client_data: D, ) -> Result<AuthenticatedPublicKeyCredential, WebauthnError>
Authenticate a Webauthn request.
Returns either an webauthn::AuthenticatedPublicKeyCredential
on success or some WebauthnError
.