From 0172a9a095821b39130976fd8611d974b87b132c Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Wed, 25 Oct 2023 01:38:33 +0100 Subject: [PATCH] Show "processing" status for BTLE and USB keys --- webauthn-authenticator-rs/src/bluetooth/mod.rs | 6 ++++-- webauthn-authenticator-rs/src/ui/cli.rs | 5 +++++ webauthn-authenticator-rs/src/ui/mod.rs | 3 +++ webauthn-authenticator-rs/src/usb/mod.rs | 6 ++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/webauthn-authenticator-rs/src/bluetooth/mod.rs b/webauthn-authenticator-rs/src/bluetooth/mod.rs index 7cd9e7d4..b75ed707 100644 --- a/webauthn-authenticator-rs/src/bluetooth/mod.rs +++ b/webauthn-authenticator-rs/src/bluetooth/mod.rs @@ -524,8 +524,10 @@ impl Token for BluetoothToken { if let Response::KeepAlive(r) = resp { trace!("waiting for {:?}", r); - if r == KeepAliveStatus::UserPresenceNeeded { - ui.request_touch(); + match r { + KeepAliveStatus::UserPresenceNeeded => ui.request_touch(), + KeepAliveStatus::Processing => ui.processing(), + _ => (), } // TODO: maybe time out at some point // thread::sleep(Duration::from_millis(100)); diff --git a/webauthn-authenticator-rs/src/ui/cli.rs b/webauthn-authenticator-rs/src/ui/cli.rs index ba708c22..fbecf082 100644 --- a/webauthn-authenticator-rs/src/ui/cli.rs +++ b/webauthn-authenticator-rs/src/ui/cli.rs @@ -25,6 +25,11 @@ impl UiCallback for Cli { writeln!(stderr, "Touch the authenticator").ok(); } + fn processing(&self) { + let mut stderr = stderr(); + writeln!(stderr, "Processing...").ok(); + } + fn fingerprint_enrollment_feedback( &self, remaining_samples: u32, diff --git a/webauthn-authenticator-rs/src/ui/mod.rs b/webauthn-authenticator-rs/src/ui/mod.rs index b02c0f6b..b00851a8 100644 --- a/webauthn-authenticator-rs/src/ui/mod.rs +++ b/webauthn-authenticator-rs/src/ui/mod.rs @@ -18,6 +18,9 @@ pub trait UiCallback: Sync + Send + Debug { /// This method will be called synchronously, and must not block. fn request_touch(&self); + /// Tell the user that the key is currently processing a request. + fn processing(&self); + /// Provide the user feedback when they are enrolling fingerprints. /// /// This method will be called synchronously, and must not block. diff --git a/webauthn-authenticator-rs/src/usb/mod.rs b/webauthn-authenticator-rs/src/usb/mod.rs index 4204c0fc..76f709dc 100644 --- a/webauthn-authenticator-rs/src/usb/mod.rs +++ b/webauthn-authenticator-rs/src/usb/mod.rs @@ -229,8 +229,10 @@ impl Token for USBToken { if let Response::KeepAlive(r) = resp { trace!("waiting for {:?}", r); - if r == KeepAliveStatus::UserPresenceNeeded { - ui.request_touch(); + match r { + KeepAliveStatus::UserPresenceNeeded => ui.request_touch(), + KeepAliveStatus::Processing => ui.processing(), + _ => (), } // TODO: maybe time out at some point tokio::time::sleep(Duration::from_millis(100)).await;