diff --git a/fido-hid-rs/build.rs b/fido-hid-rs/build.rs index 9409c477..85da9242 100644 --- a/fido-hid-rs/build.rs +++ b/fido-hid-rs/build.rs @@ -1,6 +1,6 @@ use std::{env, path::PathBuf}; -const LINUX_WRAPPER_H: &'static str = "src/linux/wrapper.h"; +const LINUX_WRAPPER_H: &str = "src/linux/wrapper.h"; fn linux_headers() { println!("cargo:rerun-if-changed={LINUX_WRAPPER_H}"); diff --git a/webauthn-authenticator-rs/examples/authenticate.rs b/webauthn-authenticator-rs/examples/authenticate.rs index fe83dd51..21fa0ac3 100644 --- a/webauthn-authenticator-rs/examples/authenticate.rs +++ b/webauthn-authenticator-rs/examples/authenticate.rs @@ -64,7 +64,7 @@ impl From for UserVerificationPolicy { async fn select_transport(ui: &U) -> impl AuthenticatorBackend + '_ { use futures::StreamExt; - let mut reader = AnyTransport::new().await.unwrap(); + let reader = AnyTransport::new().await.unwrap(); info!("Using reader: {:?}", reader); match reader.watch().await { diff --git a/webauthn-authenticator-rs/src/ctap2/ctap20.rs b/webauthn-authenticator-rs/src/ctap2/ctap20.rs index 9085d91d..2a3ed655 100644 --- a/webauthn-authenticator-rs/src/ctap2/ctap20.rs +++ b/webauthn-authenticator-rs/src/ctap2/ctap20.rs @@ -552,7 +552,7 @@ impl<'a, T: Token, U: UiCallback> Ctap20Authenticator<'a, T, U> { } error!("got unexpected OK response from authenticator"); - return Err(WebauthnCError::Internal); + Err(WebauthnCError::Internal) } } diff --git a/webauthn-authenticator-rs/src/ctap2/ctap21.rs b/webauthn-authenticator-rs/src/ctap2/ctap21.rs index 3cadcf9a..35bb2819 100644 --- a/webauthn-authenticator-rs/src/ctap2/ctap21.rs +++ b/webauthn-authenticator-rs/src/ctap2/ctap21.rs @@ -6,10 +6,8 @@ use webauthn_rs_proto::UserVerificationPolicy; use crate::{error::WebauthnCError, transport::Token, ui::UiCallback}; use super::{ - commands::{GetInfoResponse, SelectionRequest}, - ctap21_bio::BiometricAuthenticatorInfo, - ctap21_cred::CredentialManagementAuthenticatorInfo, - internal::CtapAuthenticatorVersion, + commands::GetInfoResponse, ctap21_bio::BiometricAuthenticatorInfo, + ctap21_cred::CredentialManagementAuthenticatorInfo, internal::CtapAuthenticatorVersion, Ctap20Authenticator, }; diff --git a/webauthn-authenticator-rs/src/ctap2/mod.rs b/webauthn-authenticator-rs/src/ctap2/mod.rs index 335fc919..f194bda8 100644 --- a/webauthn-authenticator-rs/src/ctap2/mod.rs +++ b/webauthn-authenticator-rs/src/ctap2/mod.rs @@ -133,7 +133,7 @@ use std::ops::{Deref, DerefMut}; use std::pin::Pin; use futures::stream::{BoxStream, FuturesUnordered}; -use futures::{select, Future, Stream, StreamExt}; +use futures::{select, Future, StreamExt}; use crate::authenticator_hashed::AuthenticatorBackendHashedClientData; use crate::error::WebauthnCError; diff --git a/webauthn-authenticator-rs/src/nfc/mod.rs b/webauthn-authenticator-rs/src/nfc/mod.rs index cdf688e4..46e457b6 100644 --- a/webauthn-authenticator-rs/src/nfc/mod.rs +++ b/webauthn-authenticator-rs/src/nfc/mod.rs @@ -67,7 +67,7 @@ use async_trait::async_trait; use futures::executor::block_on; use futures::{stream::BoxStream, Stream}; use tokio::sync::mpsc; -use tokio::task::{spawn_blocking, JoinHandle}; +use tokio::task::spawn_blocking; use tokio_stream::wrappers::ReceiverStream; use pcsc::*; @@ -130,24 +130,20 @@ fn ignored_reader(reader_name: &CStr) -> bool { } struct NFCDeviceWatcher { - handle: JoinHandle>, stream: ReceiverStream>, } impl NFCDeviceWatcher { - fn new(ctx: Context) -> Result { + fn new(ctx: Context) -> Self { let (tx, rx) = mpsc::channel(16); let stream = ReceiverStream::from(rx); - let handle = spawn_blocking(move || { + spawn_blocking(move || { let mut enumeration_complete = false; let mut reader_states: Vec = vec![ReaderState::new(PNP_NOTIFICATION(), State::UNAWARE)]; - 'main: loop { - if tx.is_closed() { - break; - } + 'main: while !tx.is_closed() { // trace!( // "{} known reader(s), pruning ignored readers", // reader_states.len() @@ -282,6 +278,8 @@ impl NFCDeviceWatcher { // Channel lost! break 'main; } + } else { + // Unhandled state transition } } @@ -304,10 +302,10 @@ impl NFCDeviceWatcher { } } - Ok(()) + Ok::<(), WebauthnCError>(()) }); - Ok(Self { handle, stream }) + Self { stream } } } @@ -382,7 +380,7 @@ impl<'b> Transport<'b> for NFCTransport { type Token = NFCCard; async fn watch(&self) -> Result>, WebauthnCError> { - let watcher = NFCDeviceWatcher::new(self.ctx.clone())?; + let watcher = NFCDeviceWatcher::new(self.ctx.clone()); Ok(Box::pin(watcher)) } diff --git a/webauthn-authenticator-rs/src/stubs.rs b/webauthn-authenticator-rs/src/stubs.rs index 7ec771ad..68db60df 100644 --- a/webauthn-authenticator-rs/src/stubs.rs +++ b/webauthn-authenticator-rs/src/stubs.rs @@ -20,7 +20,7 @@ pub mod authenticator { pub mod fido_hid_rs { const HID_RPT_SIZE: usize = 64; const HID_RPT_SEND_SIZE: usize = HID_RPT_SIZE + 1; - + pub type HidReportBytes = [u8; HID_RPT_SIZE]; pub type HidSendReportBytes = [u8; HID_RPT_SEND_SIZE]; pub trait USBDevice {} @@ -30,7 +30,7 @@ pub mod fido_hid_rs { } pub struct USBDeviceInfoImpl {} impl USBDeviceInfo for USBDeviceInfoImpl { - type Id = String; + type Id = String; } pub trait USBDeviceManager {} pub struct USBDeviceManagerImpl {} diff --git a/webauthn-authenticator-rs/src/transport/any.rs b/webauthn-authenticator-rs/src/transport/any.rs index 32cf770a..fb0f36d5 100644 --- a/webauthn-authenticator-rs/src/transport/any.rs +++ b/webauthn-authenticator-rs/src/transport/any.rs @@ -150,41 +150,44 @@ impl<'b> Transport<'b> for AnyTransport { while !bluetooth.is_terminated() || !nfc.is_terminated() || !usb.is_terminated() { tokio::select! { Some(b) = bluetooth.next() => { - let a: TokenEvent = b.into(); - if matches!(a, TokenEvent::EnumerationComplete) { + #[cfg(feature = "bluetooth")] + let b: TokenEvent = b.into(); + if matches!(b, TokenEvent::EnumerationComplete) { if nfc_complete && usb_complete { trace!("Sending enumeration complete from Bluetooth"); yield TokenEvent::EnumerationComplete; } bluetooth_complete = true; } else { - yield a; + yield b; } } Some(n) = nfc.next() => { - let a: TokenEvent = n.into(); - if matches!(a, TokenEvent::EnumerationComplete) { + #[cfg(feature = "nfc")] + let n: TokenEvent = n.into(); + if matches!(n, TokenEvent::EnumerationComplete) { if bluetooth_complete && usb_complete { trace!("Sending enumeration complete from NFC"); yield TokenEvent::EnumerationComplete; } nfc_complete = true; } else { - yield a; + yield n; } } Some(u) = usb.next() => { - let a: TokenEvent = u.into(); - if matches!(a, TokenEvent::EnumerationComplete) { + #[cfg(feature = "usb")] + let u: TokenEvent = u.into(); + if matches!(u, TokenEvent::EnumerationComplete) { if bluetooth_complete && nfc_complete { trace!("Sending enumeration complete from USB"); yield TokenEvent::EnumerationComplete; } usb_complete = true; } else { - yield a; + yield u; } }