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
9 changes: 9 additions & 0 deletions credentialsd-common/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Device>,

/// Client window handle.
pub window_handle: Optional<WindowHandle>,
}
Expand Down
14 changes: 4 additions & 10 deletions credentialsd-ui/src/gui/view_model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl<F: FlowController + Send> ViewModel<F> {
} = request.requesting_app;

let app_name: Option<String> = app_name.into();
let devices = request.initial_devices;
Self {
flow_controller,
rx_event,
Expand All @@ -72,7 +73,7 @@ impl<F: FlowController + Send> ViewModel<F> {
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,
Expand Down Expand Up @@ -125,14 +126,7 @@ impl<F: FlowController + Send> ViewModel<F> {
.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<Device>) {
self.devices = devices;
self.tx_update
.send(ViewUpdate::SetDevices(self.devices.to_owned()))
Expand Down Expand Up @@ -201,7 +195,7 @@ impl<F: FlowController + Send> ViewModel<F> {
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;
Expand Down
5 changes: 5 additions & 0 deletions credentialsd/src/credential_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
Loading