Skip to content

Commit 59d5590

Browse files
committed
examples: Implement Nfc in Hid tests
u2f_hid webauthn_hid webauthn_preflight_hid:
1 parent f5fbced commit 59d5590

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

libwebauthn/examples/u2f_hid.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use tokio::sync::broadcast::Receiver;
66
use tracing_subscriber::{self, EnvFilter};
77

88
use libwebauthn::ops::u2f::{RegisterRequest, SignRequest};
9+
#[cfg(not(feature = "nfc"))]
910
use libwebauthn::transport::hid::list_devices;
11+
#[cfg(feature = "nfc")]
12+
use libwebauthn::transport::nfc::list_devices;
1013
use libwebauthn::transport::{Channel as _, Device};
1114
use libwebauthn::u2f::U2F;
1215

libwebauthn/examples/webauthn_hid.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ use libwebauthn::proto::ctap2::{
1717
Ctap2CredentialType, Ctap2PublicKeyCredentialDescriptor, Ctap2PublicKeyCredentialRpEntity,
1818
Ctap2PublicKeyCredentialUserEntity,
1919
};
20+
#[cfg(not(feature = "nfc"))]
2021
use libwebauthn::transport::hid::list_devices;
22+
#[cfg(feature = "nfc")]
23+
use libwebauthn::transport::nfc::list_devices;
2124
use libwebauthn::transport::{Channel as _, Device};
2225
use libwebauthn::webauthn::{Error as WebAuthnError, WebAuthn};
2326

libwebauthn/examples/webauthn_preflight_hid.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ use libwebauthn::proto::ctap2::{
2020
Ctap2CredentialType, Ctap2PublicKeyCredentialDescriptor, Ctap2PublicKeyCredentialRpEntity,
2121
Ctap2PublicKeyCredentialType, Ctap2PublicKeyCredentialUserEntity,
2222
};
23+
#[cfg(not(feature = "nfc"))]
2324
use libwebauthn::transport::hid::list_devices;
25+
#[cfg(feature = "nfc")]
26+
use libwebauthn::transport::nfc::list_devices;
2427
use libwebauthn::transport::{Channel as _, Device};
2528
use libwebauthn::webauthn::{CtapError, Error as WebAuthnError, WebAuthn};
2629

@@ -156,7 +159,7 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
156159
}
157160

158161
async fn make_credential_call(
159-
channel: &mut HidChannel<'_>,
162+
channel: &mut impl Channel,
160163
user_id: &[u8],
161164
exclude_list: Option<Vec<Ctap2PublicKeyCredentialDescriptor>>,
162165
) -> Result<Ctap2PublicKeyCredentialDescriptor, WebAuthnError> {
@@ -194,7 +197,7 @@ async fn make_credential_call(
194197
}
195198

196199
async fn get_assertion_call(
197-
channel: &mut HidChannel<'_>,
200+
channel: &mut impl Channel,
198201
allow_list: Vec<Ctap2PublicKeyCredentialDescriptor>,
199202
) -> Result<GetAssertionResponse, WebAuthnError> {
200203
let challenge: [u8; 32] = thread_rng().gen();

0 commit comments

Comments
 (0)