@@ -8,11 +8,12 @@ use libwebauthn::{
88 proto:: CtapError ,
99 transport:: {
1010 hid:: { channel:: HidChannelHandle , HidDevice } ,
11- Device ,
11+ Channel , Device ,
1212 } ,
1313 webauthn:: { Error as WebAuthnError , WebAuthn } ,
14- UxUpdate ,
14+ UvUpdate ,
1515} ;
16+ use tokio:: sync:: broadcast;
1617use tokio:: sync:: mpsc:: { self , Receiver , Sender , WeakSender } ;
1718use tracing:: { debug, warn} ;
1819
@@ -84,7 +85,7 @@ impl InProcessUsbHandler {
8485 let dev = device. clone ( ) ;
8586
8687 let res = match device. channel ( ) . await {
87- Ok ( ( ref mut channel, _ ) ) => {
88+ Ok ( ref mut channel) => {
8889 let cancel_handle = channel. get_handle ( ) ;
8990 stx. send ( ( idx, dev, cancel_handle) ) . await . unwrap ( ) ;
9091 drop ( stx) ;
@@ -292,10 +293,11 @@ async fn handle_events(
292293 Err ( err) => {
293294 tracing:: error!( "Failed to open channel to USB authenticator, cannot receive user verification events: {:?}" , err) ;
294295 }
295- Ok ( ( mut channel, state_rx ) ) => {
296+ Ok ( mut channel) => {
296297 let signal_tx2 = signal_tx. clone ( ) . downgrade ( ) ;
298+ let ux_updates_rx = channel. get_ux_update_receiver ( ) ;
297299 tokio:: spawn ( async move {
298- handle_usb_updates ( & signal_tx2, state_rx ) . await ;
300+ handle_usb_updates ( & signal_tx2, ux_updates_rx ) . await ;
299301 debug ! ( "Reached end of USB update task" ) ;
300302 } ) ;
301303 tracing:: debug!(
@@ -527,23 +529,23 @@ impl From<UsbStateInternal> for UsbState {
527529
528530async fn handle_usb_updates (
529531 signal_tx : & WeakSender < Result < UsbUvMessage , Error > > ,
530- mut state_rx : Receiver < UxUpdate > ,
532+ mut state_rx : broadcast :: Receiver < UvUpdate > ,
531533) {
532- while let Some ( msg) = state_rx. recv ( ) . await {
534+ while let Ok ( msg) = state_rx. recv ( ) . await {
533535 let signal_tx = match signal_tx. upgrade ( ) {
534536 Some ( tx) => tx,
535537 None => break ,
536538 } ;
537539 match msg {
538- UxUpdate :: UvRetry { attempts_left } => {
540+ UvUpdate :: UvRetry { attempts_left } => {
539541 if let Err ( err) = signal_tx
540542 . send ( Ok ( UsbUvMessage :: NeedsUserVerification { attempts_left } ) )
541543 . await
542544 {
543545 tracing:: error!( "Authenticator requested user verficiation, but we cannot relay the message to credential service: {:?}" , err) ;
544546 }
545547 }
546- UxUpdate :: PinRequired ( pin_update) => {
548+ UvUpdate :: PinRequired ( pin_update) => {
547549 let ( pin_tx, mut pin_rx) = mpsc:: channel ( 1 ) ;
548550 if let Err ( err) = signal_tx
549551 . send ( Ok ( UsbUvMessage :: NeedsPin {
@@ -562,7 +564,7 @@ async fn handle_usb_updates(
562564 None => tracing:: debug!( "Pin channel closed before receiving pin from client." ) ,
563565 }
564566 }
565- UxUpdate :: PresenceRequired => {
567+ UvUpdate :: PresenceRequired => {
566568 if let Err ( err) = signal_tx. send ( Ok ( UsbUvMessage :: NeedsUserPresence ) ) . await {
567569 tracing:: error!( "Authenticator requested user presence, but we cannot relay the message to the credential service: {:?}" , err) ;
568570 }
0 commit comments