@@ -63,8 +63,6 @@ impl RequestContext {
6363
6464#[ derive( Debug ) ]
6565pub struct CredentialService < H : HybridHandler , U : UsbHandler , N : NfcHandler , UC : UiController > {
66- devices : Vec < Device > ,
67-
6866 /// Current request and channel to respond to caller.
6967 ctx : Arc < Mutex < Option < RequestContext > > > ,
7068
8886 nfc_handler : N ,
8987 ui_control_client : Arc < UC > ,
9088 ) -> Self {
91- let devices = vec ! [
92- Device {
93- id: String :: from( "0" ) ,
94- transport: Transport :: Usb ,
95- } ,
96- Device {
97- id: String :: from( "1" ) ,
98- transport: Transport :: HybridQr ,
99- } ,
100- Device {
101- id: String :: from( "2" ) ,
102- transport: Transport :: Nfc ,
103- } ,
104- ] ;
10589 Self {
106- devices,
107-
10890 ctx : Arc :: new ( Mutex :: new ( None ) ) ,
10991
11092 hybrid_handler,
@@ -184,7 +166,25 @@ impl<
184166 }
185167
186168 pub async fn get_available_public_key_devices ( & self ) -> Result < Vec < Device > , ( ) > {
187- Ok ( self . devices . to_owned ( ) )
169+ // We create the list new for each call, in case someone plugs in
170+ // an NFC-reader in the middle of an auth-flow
171+ let mut devices = vec ! [
172+ Device {
173+ id: String :: from( "0" ) ,
174+ transport: Transport :: Usb ,
175+ } ,
176+ Device {
177+ id: String :: from( "1" ) ,
178+ transport: Transport :: HybridQr ,
179+ } ,
180+ ] ;
181+ if libwebauthn:: transport:: nfc:: is_nfc_available ( ) {
182+ devices. push ( Device {
183+ id : String :: from ( "2" ) ,
184+ transport : Transport :: Nfc ,
185+ } ) ;
186+ }
187+ Ok ( devices)
188188 }
189189
190190 pub fn get_hybrid_credential (
0 commit comments