Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions examples/ctap2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,9 @@ fn main() {
Ok(StatusUpdate::InteractiveManagement(..)) => {
panic!("STATUS: This can't happen when doing non-interactive usage");
}
Ok(StatusUpdate::DeviceAvailable { dev_info }) => {
println!("STATUS: device available: {dev_info}")
}
Ok(StatusUpdate::DeviceUnavailable { dev_info }) => {
println!("STATUS: device unavailable: {dev_info}")
}
Ok(StatusUpdate::Success { dev_info }) => {
println!("STATUS: success using device: {dev_info}");
}
Ok(StatusUpdate::SelectDeviceNotice) => {
println!("STATUS: Please select a device by touching one of them.");
}
Ok(StatusUpdate::DeviceSelected(dev_info)) => {
println!("STATUS: Continuing with device: {dev_info}");
}
Ok(StatusUpdate::PresenceRequired) => {
println!("STATUS: waiting for user presence");
}
Expand Down
24 changes: 0 additions & 24 deletions examples/ctap2_discoverable_creds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,9 @@ fn register_user(manager: &mut AuthenticatorService, username: &str, timeout_ms:
Ok(StatusUpdate::InteractiveManagement(..)) => {
panic!("STATUS: This can't happen when doing non-interactive usage");
}
Ok(StatusUpdate::DeviceAvailable { dev_info }) => {
println!("STATUS: device available: {dev_info}")
}
Ok(StatusUpdate::DeviceUnavailable { dev_info }) => {
println!("STATUS: device unavailable: {dev_info}")
}
Ok(StatusUpdate::Success { dev_info }) => {
println!("STATUS: success using device: {dev_info}");
}
Ok(StatusUpdate::SelectDeviceNotice) => {
println!("STATUS: Please select a device by touching one of them.");
}
Ok(StatusUpdate::DeviceSelected(dev_info)) => {
println!("STATUS: Continuing with device: {dev_info}");
}
Ok(StatusUpdate::PresenceRequired) => {
println!("STATUS: waiting for user presence");
}
Expand Down Expand Up @@ -246,21 +234,9 @@ fn main() {
Ok(StatusUpdate::InteractiveManagement(..)) => {
panic!("STATUS: This can't happen when doing non-interactive usage");
}
Ok(StatusUpdate::DeviceAvailable { dev_info }) => {
println!("STATUS: device available: {dev_info}")
}
Ok(StatusUpdate::DeviceUnavailable { dev_info }) => {
println!("STATUS: device unavailable: {dev_info}")
}
Ok(StatusUpdate::Success { dev_info }) => {
println!("STATUS: success using device: {dev_info}");
}
Ok(StatusUpdate::SelectDeviceNotice) => {
println!("STATUS: Please select a device by touching one of them.");
}
Ok(StatusUpdate::DeviceSelected(dev_info)) => {
println!("STATUS: Continuing with device: {dev_info}");
}
Ok(StatusUpdate::PresenceRequired) => {
println!("STATUS: waiting for user presence");
}
Expand Down
27 changes: 2 additions & 25 deletions examples/interactive_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ fn print_usage(program: &str, opts: Options) {
}

fn interactive_status_callback(status_rx: Receiver<StatusUpdate>) {
let mut num_of_devices = 0;
loop {
match status_rx.recv() {
Ok(StatusUpdate::InteractiveManagement((tx, dev_info, auth_info))) => {
debug!(
"STATUS: interactive management: {:#}, {:#?}",
dev_info, auth_info
);
println!("Device info {:#}", dev_info);
Ok(StatusUpdate::InteractiveManagement((tx, auth_info))) => {
debug!("STATUS: interactive management: {:#?}", auth_info);
let mut change_pin = false;
if let Some(info) = auth_info {
println!("Authenticator Info {:#?}", info);
Expand Down Expand Up @@ -98,27 +93,9 @@ fn interactive_status_callback(status_rx: Receiver<StatusUpdate>) {
println!("Device only supports CTAP1 and can't be managed.");
}
}
Ok(StatusUpdate::DeviceAvailable { dev_info }) => {
num_of_devices += 1;
debug!(
"STATUS: New device #{} available: {}",
num_of_devices, dev_info
);
}
Ok(StatusUpdate::DeviceUnavailable { dev_info }) => {
num_of_devices -= 1;
if num_of_devices <= 0 {
println!("No more devices left. Please plug in a device!");
}
debug!("STATUS: Device became unavailable: {}", dev_info)
}
Ok(StatusUpdate::Success { dev_info }) => {
println!("STATUS: success using device: {}", dev_info);
}
Ok(StatusUpdate::SelectDeviceNotice) => {
println!("STATUS: Please select a device by touching one of them.");
}
Ok(StatusUpdate::DeviceSelected(_dev_info)) => {}
Ok(StatusUpdate::PresenceRequired) => {
println!("STATUS: waiting for user presence");
}
Expand Down
3 changes: 0 additions & 3 deletions examples/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ fn main() {
manager.cancel().unwrap();
return;
}
Ok(StatusUpdate::DeviceSelected(dev_info)) => {
println!("STATUS: Continuing with device: {dev_info}");
}
Ok(StatusUpdate::PresenceRequired) => {
println!("STATUS: waiting for user presence");
break;
Expand Down
12 changes: 0 additions & 12 deletions examples/set_pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,9 @@ fn main() {
Ok(StatusUpdate::InteractiveManagement(..)) => {
panic!("STATUS: This can't happen when doing non-interactive usage");
}
Ok(StatusUpdate::DeviceAvailable { dev_info }) => {
println!("STATUS: device available: {dev_info}")
}
Ok(StatusUpdate::DeviceUnavailable { dev_info }) => {
println!("STATUS: device unavailable: {dev_info}")
}
Ok(StatusUpdate::Success { dev_info }) => {
println!("STATUS: success using device: {dev_info}");
}
Ok(StatusUpdate::SelectDeviceNotice) => {
println!("STATUS: Please select a device by touching one of them.");
}
Ok(StatusUpdate::DeviceSelected(dev_info)) => {
println!("STATUS: Continuing with device: {dev_info}");
}
Ok(StatusUpdate::PresenceRequired) => {
println!("STATUS: waiting for user presence");
}
Expand Down
12 changes: 0 additions & 12 deletions examples/test_exclude_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,9 @@ fn main() {
Ok(StatusUpdate::InteractiveManagement(..)) => {
panic!("STATUS: This can't happen when doing non-interactive usage");
}
Ok(StatusUpdate::DeviceAvailable { dev_info }) => {
println!("STATUS: device available: {dev_info}")
}
Ok(StatusUpdate::DeviceUnavailable { dev_info }) => {
println!("STATUS: device unavailable: {dev_info}")
}
Ok(StatusUpdate::Success { dev_info }) => {
println!("STATUS: success using device: {dev_info}");
}
Ok(StatusUpdate::SelectDeviceNotice) => {
println!("STATUS: Please select a device by touching one of them.");
}
Ok(StatusUpdate::DeviceSelected(dev_info)) => {
println!("STATUS: Continuing with device: {dev_info}");
}
Ok(StatusUpdate::PresenceRequired) => {
println!("STATUS: waiting for user presence");
}
Expand Down
18 changes: 0 additions & 18 deletions src/ctap2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,6 @@ pub fn register<Dev: FidoDevice>(
let resp = dev.send_msg_cancellable(&makecred, alive);
match resp {
Ok(MakeCredentialsResult(attestation)) => {
send_status(
&status,
crate::StatusUpdate::Success {
dev_info: dev.get_device_info(),
},
);
callback.call(Ok(RegisterResult::CTAP2(attestation)));
return true;
}
Expand Down Expand Up @@ -625,12 +619,6 @@ pub fn sign<Dev: FidoDevice>(
}
match resp {
Ok(assertions) => {
send_status(
&status,
crate::StatusUpdate::Success {
dev_info: dev.get_device_info(),
},
);
callback.call(Ok(SignResult::CTAP2(assertions)));
return true;
}
Expand Down Expand Up @@ -696,12 +684,6 @@ pub fn reset_helper(
send_status(&status, crate::StatusUpdate::PresenceRequired);
let resp = dev.send_cbor_cancellable(&reset, keep_alive);
if resp.is_ok() {
send_status(
&status,
crate::StatusUpdate::Success {
dev_info: dev.get_device_info(),
},
);
// The DeviceSelector could already be dead, but it might also wait
// for us to respond, in order to cancel all other tokens in case
// we skipped the "blinking"-action and went straight for the actual
Expand Down
54 changes: 0 additions & 54 deletions src/statemachine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ impl StateMachine {
selector
.send(DeviceSelectorEvent::ImAToken((dev.id(), tx)))
.ok()?;
send_status(
status,
crate::StatusUpdate::DeviceAvailable {
dev_info: dev.get_device_info(),
},
);

// We can be cancelled from the user (through keep_alive()) or from the device selector
// (through a DeviceCommand::Cancel on rx). We'll combine those signals into a single
Expand All @@ -130,11 +124,6 @@ impl StateMachine {
selector
.send(DeviceSelectorEvent::SelectedToken(dev.id()))
.ok()?;

send_status(
status,
crate::StatusUpdate::DeviceSelected(dev.get_device_info()),
);
}
BlinkResult::Cancelled => {
info!("Device {:?} was not selected", dev.id());
Expand All @@ -148,20 +137,10 @@ impl StateMachine {
}
Ok(DeviceCommand::Removed) => {
info!("Device {:?} was removed", dev.id());
send_status(
status,
crate::StatusUpdate::DeviceUnavailable {
dev_info: dev.get_device_info(),
},
);
return None;
}
Ok(DeviceCommand::Continue) => {
// Just continue
send_status(
status,
crate::StatusUpdate::DeviceSelected(dev.get_device_info()),
);
}
Err(_) => {
warn!("Error when trying to receive messages from DeviceSelector! Exiting.");
Expand Down Expand Up @@ -432,13 +411,6 @@ impl StateMachine {
return;
}

send_status(
&status,
crate::StatusUpdate::DeviceAvailable {
dev_info: dev.get_device_info(),
},
);

// Iterate the exclude list and see if there are any matches.
// If so, we'll keep polling the device anyway to test for user
// consent, to be consistent with CTAP2 device behavior.
Expand Down Expand Up @@ -476,22 +448,13 @@ impl StateMachine {
break;
}
};
let dev_info = dev.get_device_info();
send_status(&status, crate::StatusUpdate::Success { dev_info });
callback.call(Ok(RegisterResult::CTAP2(result)));
break;
}

// Sleep a bit before trying again.
thread::sleep(Duration::from_millis(100));
}

send_status(
&status,
crate::StatusUpdate::DeviceUnavailable {
dev_info: dev.get_device_info(),
},
);
},
);

Expand Down Expand Up @@ -566,13 +529,6 @@ impl StateMachine {
return;
}

send_status(
&status,
crate::StatusUpdate::DeviceAvailable {
dev_info: dev.get_device_info(),
},
);

send_status(&status, crate::StatusUpdate::PresenceRequired);

'outer: while alive() {
Expand Down Expand Up @@ -611,8 +567,6 @@ impl StateMachine {
break 'outer;
}
};
let dev_info = dev.get_device_info();
send_status(&status, crate::StatusUpdate::Success { dev_info });
callback.call(Ok(SignResult::CTAP2(result)));
break 'outer;
}
Expand All @@ -622,13 +576,6 @@ impl StateMachine {
// Sleep a bit before trying again.
thread::sleep(Duration::from_millis(100));
}

send_status(
&status,
crate::StatusUpdate::DeviceUnavailable {
dev_info: dev.get_device_info(),
},
);
},
);

Expand Down Expand Up @@ -673,7 +620,6 @@ impl StateMachine {
&status,
crate::StatusUpdate::InteractiveManagement((
tx,
dev.get_device_info(),
dev.get_authenticator_info().cloned(),
)),
);
Expand Down
12 changes: 1 addition & 11 deletions src/status_update.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{u2ftypes, Pin};
use super::Pin;
use crate::ctap2::commands::get_info::AuthenticatorInfo;
use serde::{Deserialize, Serialize as DeriveSer, Serializer};
use std::sync::mpsc::Sender;
Expand Down Expand Up @@ -55,27 +55,17 @@ pub enum StatusPinUv {

#[derive(Debug)]
pub enum StatusUpdate {
/// Device found
DeviceAvailable { dev_info: u2ftypes::U2FDeviceInfo },
/// Device got removed
DeviceUnavailable { dev_info: u2ftypes::U2FDeviceInfo },
/// We're waiting for the user to touch their token
PresenceRequired,
/// We successfully finished the register or sign request
Success { dev_info: u2ftypes::U2FDeviceInfo },
/// Sent if a PIN is needed (or was wrong), or some other kind of PIN-related
/// error occurred. The Sender is for sending back a PIN (if needed).
PinUvError(StatusPinUv),
/// Sent, if multiple devices are found and the user has to select one
SelectDeviceNotice,
/// Sent, once a device was selected (either automatically or by user-interaction)
/// and the register or signing process continues with this device
DeviceSelected(u2ftypes::U2FDeviceInfo),
/// Sent when a token was selected for interactive management
InteractiveManagement(
(
Sender<InteractiveRequest>,
u2ftypes::U2FDeviceInfo,
Option<AuthenticatorInfo>,
),
),
Expand Down
Loading