diff --git a/apps/desktop/desktop_native/core/src/biometric/macos.rs b/apps/desktop/desktop_native/core/src/biometric/macos.rs index ec09d566e1..de5a8d1e02 100644 --- a/apps/desktop/desktop_native/core/src/biometric/macos.rs +++ b/apps/desktop/desktop_native/core/src/biometric/macos.rs @@ -14,7 +14,7 @@ impl super::BiometricTrait for Biometric { bail!("platform not supported"); } - fn derive_key_material(_iv_str: Option<&str>) -> Result { + async fn derive_key_material(_iv_str: Option<&str>) -> Result { bail!("platform not supported"); } diff --git a/apps/desktop/desktop_native/core/src/biometric/mod.rs b/apps/desktop/desktop_native/core/src/biometric/mod.rs index 79be43b1bf..f41a319385 100644 --- a/apps/desktop/desktop_native/core/src/biometric/mod.rs +++ b/apps/desktop/desktop_native/core/src/biometric/mod.rs @@ -31,7 +31,7 @@ pub struct OsDerivedKey { pub trait BiometricTrait { async fn prompt(hwnd: Vec, message: String) -> Result; async fn available() -> Result; - fn derive_key_material(secret: Option<&str>) -> Result; + async fn derive_key_material(secret: Option<&str>) -> Result; async fn set_biometric_secret( service: &str, account: &str, diff --git a/apps/desktop/desktop_native/core/src/biometric/unix.rs b/apps/desktop/desktop_native/core/src/biometric/unix.rs index e57b77515e..85bbd7b2ed 100644 --- a/apps/desktop/desktop_native/core/src/biometric/unix.rs +++ b/apps/desktop/desktop_native/core/src/biometric/unix.rs @@ -53,7 +53,7 @@ impl super::BiometricTrait for Biometric { Ok(false) } - fn derive_key_material(challenge_str: Option<&str>) -> Result { + async fn derive_key_material(challenge_str: Option<&str>) -> Result { let challenge: [u8; 16] = match challenge_str { Some(challenge_str) => base64_engine .decode(challenge_str)? diff --git a/apps/desktop/desktop_native/core/src/biometric/windows.rs b/apps/desktop/desktop_native/core/src/biometric/windows.rs index a2200ef998..a68ba397a3 100644 --- a/apps/desktop/desktop_native/core/src/biometric/windows.rs +++ b/apps/desktop/desktop_native/core/src/biometric/windows.rs @@ -73,7 +73,7 @@ impl super::BiometricTrait for Biometric { /// /// Windows will only sign the challenge if the user has successfully authenticated with Windows, /// ensuring user presence. - fn derive_key_material(challenge_str: Option<&str>) -> Result { + async fn derive_key_material(challenge_str: Option<&str>) -> Result { let challenge: [u8; 16] = match challenge_str { Some(challenge_str) => base64_engine .decode(challenge_str)? @@ -103,7 +103,7 @@ impl super::BiometricTrait for Biometric { let done = Arc::new(AtomicBool::new(false)); let done_clone = done.clone(); - let _ = tokio::task::spawn_blocking(move || loop { + let focus_future = tokio::task::spawn_blocking(move || loop { if !done_clone.load(std::sync::atomic::Ordering::Relaxed) { focus_security_prompt(); std::thread::sleep(std::time::Duration::from_millis(500)); @@ -114,6 +114,7 @@ impl super::BiometricTrait for Biometric { let signature = async_operation.get(); done.store(true, std::sync::atomic::Ordering::Relaxed); + focus_future.await?; let signature = signature?; if signature.Status()? != KeyCredentialStatus::Success { diff --git a/apps/desktop/desktop_native/napi/src/lib.rs b/apps/desktop/desktop_native/napi/src/lib.rs index 3ceef666d8..2d764631f2 100644 --- a/apps/desktop/desktop_native/napi/src/lib.rs +++ b/apps/desktop/desktop_native/napi/src/lib.rs @@ -106,6 +106,7 @@ pub mod biometrics { Biometric::derive_key_material(iv.as_deref()) .map(|k| k.into()) .map_err(|e| napi::Error::from_reason(e.to_string())) + .await } #[napi(object)]