diff --git a/credentialsd-common/src/server.rs b/credentialsd-common/src/server.rs index 8096634..7eb656e 100644 --- a/credentialsd-common/src/server.rs +++ b/credentialsd-common/src/server.rs @@ -584,10 +584,19 @@ where #[derive(Serialize, Deserialize, Type)] pub struct ViewRequest { pub operation: Operation, + + /// ID of the request. pub id: RequestId, + + /// The RP ID pub rp_id: String, + + /// Details about the application requesting credentials. pub requesting_app: RequestingApplication, + /// Initial list of device interfaces that may provide credentials. + pub initial_devices: Vec, + /// Client window handle. pub window_handle: Optional, } diff --git a/credentialsd-ui/src/gui/view_model/mod.rs b/credentialsd-ui/src/gui/view_model/mod.rs index d3113ef..4472afa 100644 --- a/credentialsd-ui/src/gui/view_model/mod.rs +++ b/credentialsd-ui/src/gui/view_model/mod.rs @@ -61,6 +61,7 @@ impl ViewModel { } = request.requesting_app; let app_name: Option = app_name.into(); + let devices = request.initial_devices; Self { flow_controller, rx_event, @@ -72,7 +73,7 @@ impl ViewModel { app_pid: pid, title: String::default(), subtitle: String::default(), - devices: Vec::new(), + devices, selected_device: None, hybrid_qr_state: HybridState::default(), hybrid_qr_code_data: None, @@ -125,14 +126,7 @@ impl ViewModel { .unwrap(); } - async fn update_devices(&mut self) { - let devices = self - .flow_controller - .lock() - .await - .get_available_public_key_devices() - .await - .unwrap(); + async fn update_devices(&mut self, devices: Vec) { self.devices = devices; self.tx_update .send(ViewUpdate::SetDevices(self.devices.to_owned())) @@ -201,7 +195,7 @@ impl ViewModel { match event { Event::View(ViewEvent::Initiated) => { self.update_title().await; - self.update_devices().await; + self.update_devices(self.devices.clone()).await; } Event::View(ViewEvent::DeviceSelected(id)) => { self.select_device(&id).await; diff --git a/credentialsd/src/credential_service/mod.rs b/credentialsd/src/credential_service/mod.rs index 09b593b..1ab7979 100644 --- a/credentialsd/src/credential_service/mod.rs +++ b/credentialsd/src/credential_service/mod.rs @@ -131,10 +131,15 @@ impl< CredentialRequest::CreatePublicKeyCredentialRequest(r) => r.relying_party.id.clone(), CredentialRequest::GetPublicKeyCredentialRequest(r) => r.relying_party_id.clone(), }; + let initial_devices = self + .get_available_public_key_devices() + .await + .unwrap_or_default(); let view_request = ViewRequest { operation, id: request_id, rp_id, + initial_devices, requesting_app: requesting_app.unwrap_or_default(), // We can't send Options, so we send an empty string instead, if we don't know the peer window_handle: window_handle.into(), };