Skip to content

Commit 700e262

Browse files
fix(cable): propagate post-handshake errors from protocol::connection (#217)
- Add EncryptionFailed transport error variant - Surface decode/encrypt failures out of the cable connection task instead of swallowing them - Forward tunnel-connection errors via send_error so callers see the real cause - Hoist CableTunnelMessage::from_slice and CableKnownDeviceInfo::new to return TransportError directly
1 parent 0734067 commit 700e262

4 files changed

Lines changed: 118 additions & 82 deletions

File tree

libwebauthn/src/transport/cable/known_devices.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,27 @@ impl From<&CableLinkingInfo> for CableKnownDeviceId {
9898
}
9999

100100
impl CableKnownDeviceInfo {
101-
pub(crate) fn new(tunnel_domain: &str, linking_info: &CableLinkingInfo) -> Result<Self, Error> {
101+
pub(crate) fn new(
102+
tunnel_domain: &str,
103+
linking_info: &CableLinkingInfo,
104+
) -> Result<Self, TransportError> {
102105
let info = Self {
103106
contact_id: linking_info.contact_id.to_vec(),
104107
link_id: linking_info
105108
.link_id
106109
.clone()
107110
.try_into()
108-
.map_err(|_| Error::Transport(TransportError::InvalidFraming))?,
111+
.map_err(|_| TransportError::InvalidFraming)?,
109112
link_secret: linking_info
110113
.link_secret
111114
.clone()
112115
.try_into()
113-
.map_err(|_| Error::Transport(TransportError::InvalidFraming))?,
116+
.map_err(|_| TransportError::InvalidFraming)?,
114117
public_key: linking_info
115118
.authenticator_public_key
116119
.clone()
117120
.try_into()
118-
.map_err(|_| Error::Transport(TransportError::InvalidFraming))?,
121+
.map_err(|_| TransportError::InvalidFraming)?,
119122
name: linking_info.authenticator_name.clone(),
120123
tunnel_domain: tunnel_domain.to_string(),
121124
};
@@ -223,10 +226,17 @@ impl<'d> Device<'d, Cable, CableChannel> for CableKnownDevice {
223226
cbor_rx_send,
224227
);
225228

226-
protocol::connection(tunnel_input).await;
227-
ux_sender
228-
.set_connection_state(ConnectionState::Terminated)
229-
.await;
229+
match protocol::connection(tunnel_input).await {
230+
Ok(()) => {
231+
ux_sender
232+
.set_connection_state(ConnectionState::Terminated)
233+
.await;
234+
}
235+
Err(e) => {
236+
// send_error already transitions to Terminated.
237+
ux_sender.send_error(e).await;
238+
}
239+
}
230240
});
231241

232242
Ok(CableChannel {

0 commit comments

Comments
 (0)