Skip to content

Commit 667b32b

Browse files
committed
fido: Make user verification availability synchronous
This function is intended to signal whether user verification may potentially be available for the authenticator, not whether user verification will be available for a particular request. Since this can be known ahead of time for our clients, there is no need for this function to be async. Making this async also aligns us closer with upstream. Per-request availability checks should be done in the caller's implementation of check_user().
1 parent 2171a0c commit 667b32b

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

crates/bitwarden-fido/src/authenticator.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl<'a> Fido2Authenticator<'a> {
163163
options: passkey::types::ctap2::make_credential::Options {
164164
rk: request.options.rk,
165165
up: true,
166-
uv: self.convert_requested_uv(request.options.uv).await,
166+
uv: self.convert_requested_uv(request.options.uv),
167167
},
168168
pin_auth: None,
169169
pin_protocol: None,
@@ -222,7 +222,7 @@ impl<'a> Fido2Authenticator<'a> {
222222
options: passkey::types::ctap2::make_credential::Options {
223223
rk: request.options.rk,
224224
up: true,
225-
uv: self.convert_requested_uv(request.options.uv).await,
225+
uv: self.convert_requested_uv(request.options.uv),
226226
},
227227
pin_auth: None,
228228
pin_protocol: None,
@@ -305,8 +305,8 @@ impl<'a> Fido2Authenticator<'a> {
305305
)
306306
}
307307

308-
async fn convert_requested_uv(&self, uv: UV) -> bool {
309-
let verification_enabled = self.user_interface.is_verification_enabled().await;
308+
fn convert_requested_uv(&self, uv: UV) -> bool {
309+
let verification_enabled = self.user_interface.is_verification_enabled();
310310
match (uv, verification_enabled) {
311311
(UV::Preferred, true) => true,
312312
(UV::Preferred, false) => false,
@@ -656,17 +656,12 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<'
656656
})
657657
}
658658

659-
async fn is_presence_enabled(&self) -> bool {
659+
fn is_presence_enabled(&self) -> bool {
660660
true
661661
}
662662

663-
async fn is_verification_enabled(&self) -> Option<bool> {
664-
Some(
665-
self.authenticator
666-
.user_interface
667-
.is_verification_enabled()
668-
.await,
669-
)
663+
fn is_verification_enabled(&self) -> Option<bool> {
664+
Some(self.authenticator.user_interface.is_verification_enabled())
670665
}
671666
}
672667

crates/bitwarden-fido/src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub trait Fido2UserInterface: Send + Sync {
3232
options: CheckUserOptions,
3333
new_credential: Fido2CredentialNewView,
3434
) -> Result<(CipherView, CheckUserResult), Fido2CallbackError>;
35-
async fn is_verification_enabled(&self) -> bool;
35+
fn is_verification_enabled(&self) -> bool;
3636
}
3737

3838
#[allow(missing_docs)]

crates/bitwarden-uniffi/src/platform/fido2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub trait Fido2UserInterface: Send + Sync {
231231
options: CheckUserOptions,
232232
new_credential: Fido2CredentialNewView,
233233
) -> Result<CheckUserAndPickCredentialForCreationResult, Fido2CallbackError>;
234-
async fn is_verification_enabled(&self) -> bool;
234+
fn is_verification_enabled(&self) -> bool;
235235
}
236236

237237
#[uniffi::export(with_foreign)]
@@ -353,7 +353,7 @@ impl bitwarden_fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInte
353353
.map(|v| (v.cipher.cipher, v.check_user_result.into()))
354354
.map_err(Into::into)
355355
}
356-
async fn is_verification_enabled(&self) -> bool {
357-
self.0.is_verification_enabled().await
356+
fn is_verification_enabled(&self) -> bool {
357+
self.0.is_verification_enabled()
358358
}
359359
}

crates/bitwarden-uniffi/swift/iOS/App/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ class Fido2UserInterfaceImpl: Fido2UserInterface {
408408
return CheckUserResult(userPresent: true, userVerified: true)
409409
}
410410

411-
func isVerificationEnabled() async -> Bool {
411+
func isVerificationEnabled() -> Bool {
412412
true
413413
}
414414
}

0 commit comments

Comments
 (0)