@@ -14,7 +14,7 @@ use qrcode::render::unicode;
1414use qrcode:: QrCode ;
1515use rand:: { thread_rng, Rng } ;
1616use text_io:: read;
17- use tokio:: sync:: mpsc :: Receiver ;
17+ use tokio:: sync:: broadcast :: Receiver ;
1818use tokio:: time:: sleep;
1919use tracing_subscriber:: { self , EnvFilter } ;
2020
@@ -25,7 +25,7 @@ use libwebauthn::proto::ctap2::{
2525 Ctap2CredentialType , Ctap2PublicKeyCredentialDescriptor , Ctap2PublicKeyCredentialRpEntity ,
2626 Ctap2PublicKeyCredentialUserEntity ,
2727} ;
28- use libwebauthn:: transport:: Device ;
28+ use libwebauthn:: transport:: { Channel as _ , Device } ;
2929use libwebauthn:: webauthn:: { Error as WebAuthnError , WebAuthn } ;
3030
3131const TIMEOUT : Duration = Duration :: from_secs ( 120 ) ;
@@ -38,7 +38,7 @@ fn setup_logging() {
3838}
3939
4040async fn handle_updates ( mut state_recv : Receiver < CableUxUpdate > ) {
41- while let Some ( update) = state_recv. recv ( ) . await {
41+ while let Ok ( update) = state_recv. recv ( ) . await {
4242 match update {
4343 CableUxUpdate :: UvUpdate ( uv_update) => match uv_update {
4444 UvUpdate :: PresenceRequired => println ! ( "Please touch your device!" ) ,
@@ -111,9 +111,10 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
111111 println ! ( "{}" , image) ;
112112
113113 // Connect to a known device
114- let ( mut channel, state_recv ) = device. channel ( ) . await . unwrap ( ) ;
114+ let mut channel = device. channel ( ) . await . unwrap ( ) ;
115115 println ! ( "Tunnel established {:?}" , channel) ;
116116
117+ let state_recv = channel. get_ux_update_receiver ( ) ;
117118 tokio:: spawn ( handle_updates ( state_recv) ) ;
118119
119120 // Make Credentials ceremony
@@ -177,9 +178,10 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
177178 . unwrap ( ) ;
178179
179180 // Connect to a known device
180- let ( mut channel, state_recv ) = known_device. channel ( ) . await . unwrap ( ) ;
181+ let mut channel = known_device. channel ( ) . await . unwrap ( ) ;
181182 println ! ( "Tunnel established {:?}" , channel) ;
182183
184+ let state_recv = channel. get_ux_update_receiver ( ) ;
183185 tokio:: spawn ( handle_updates ( state_recv) ) ;
184186
185187 let response = loop {
0 commit comments