Skip to content

Commit 9e1e2dd

Browse files
committed
Include devices in initial request
1 parent 271ad16 commit 9e1e2dd

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

  • credentialsd-common/src
  • credentialsd-ui/src/gui/view_model
  • credentialsd/src/credential_service

credentialsd-common/src/server.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,19 @@ where
584584
#[derive(Serialize, Deserialize, Type)]
585585
pub struct ViewRequest {
586586
pub operation: Operation,
587+
588+
/// ID of the request.
587589
pub id: RequestId,
590+
591+
/// The RP ID
588592
pub rp_id: String,
593+
594+
/// Details about the application requesting credentials.
589595
pub requesting_app: RequestingApplication,
590596

597+
/// Initial list of device interfaces that may provide credentials.
598+
pub initial_devices: Vec<Device>,
599+
591600
/// Client window handle.
592601
pub window_handle: Optional<WindowHandle>,
593602
}

credentialsd-ui/src/gui/view_model/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl<F: FlowController + Send> ViewModel<F> {
6161
} = request.requesting_app;
6262

6363
let app_name: Option<String> = app_name.into();
64+
let devices = request.initial_devices;
6465
Self {
6566
flow_controller,
6667
rx_event,
@@ -72,7 +73,7 @@ impl<F: FlowController + Send> ViewModel<F> {
7273
app_pid: pid,
7374
title: String::default(),
7475
subtitle: String::default(),
75-
devices: Vec::new(),
76+
devices,
7677
selected_device: None,
7778
hybrid_qr_state: HybridState::default(),
7879
hybrid_qr_code_data: None,
@@ -125,14 +126,7 @@ impl<F: FlowController + Send> ViewModel<F> {
125126
.unwrap();
126127
}
127128

128-
async fn update_devices(&mut self) {
129-
let devices = self
130-
.flow_controller
131-
.lock()
132-
.await
133-
.get_available_public_key_devices()
134-
.await
135-
.unwrap();
129+
async fn update_devices(&mut self, devices: Vec<Device>) {
136130
self.devices = devices;
137131
self.tx_update
138132
.send(ViewUpdate::SetDevices(self.devices.to_owned()))
@@ -201,7 +195,7 @@ impl<F: FlowController + Send> ViewModel<F> {
201195
match event {
202196
Event::View(ViewEvent::Initiated) => {
203197
self.update_title().await;
204-
self.update_devices().await;
198+
self.update_devices(self.devices.clone()).await;
205199
}
206200
Event::View(ViewEvent::DeviceSelected(id)) => {
207201
self.select_device(&id).await;

credentialsd/src/credential_service/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,15 @@ impl<
131131
CredentialRequest::CreatePublicKeyCredentialRequest(r) => r.relying_party.id.clone(),
132132
CredentialRequest::GetPublicKeyCredentialRequest(r) => r.relying_party_id.clone(),
133133
};
134+
let initial_devices = self
135+
.get_available_public_key_devices()
136+
.await
137+
.unwrap_or_default();
134138
let view_request = ViewRequest {
135139
operation,
136140
id: request_id,
137141
rp_id,
142+
initial_devices,
138143
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
139144
window_handle: window_handle.into(),
140145
};

0 commit comments

Comments
 (0)