Skip to content

Conversation

@AlfioEmanueleFresta
Copy link
Member

@AlfioEmanueleFresta AlfioEmanueleFresta commented Jul 19, 2025

Requires #127.

Changes:

  • Refactors Hybrid (caBLE) connection stages into 3 reusable components
  • Move all 3 connection stages to the channel handle, in addition to existing connection handler
  • Operations first wait for a connection to be established, then perform the operation with the operation timeout

Next steps:

  • Surface errors

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors caBLE (Hybrid) connections to improve error handling and UX by making Channels async and breaking connection establishment into 3 reusable stages. The changes move connection logic to channel handles and implement proper timeout separation - operations first wait for connection establishment without timeout, then apply operation timeouts.

Key changes:

  • Refactored caBLE connection flow into proximity check, connection, and handshake stages
  • Made Channel trait generic over UX update types with async operations
  • Separated connection establishment from operation timeouts in caBLE channels

Reviewed Changes

Copilot reviewed 32 out of 34 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
libwebauthn/src/lib.rs Renamed UxUpdate to UvUpdate for user verification updates
libwebauthn/src/transport/channel.rs Made Channel trait generic with UxUpdate associated type and async send methods
libwebauthn/src/transport/cable/connection_stages.rs New module implementing 3-stage connection process for caBLE
libwebauthn/src/transport/cable/channel.rs Added connection state management and timeout separation logic
libwebauthn/src/transport/cable/tunnel.rs Refactored connection logic and added rustls initialization
Multiple example files Updated to use UvUpdate instead of UxUpdate
Comments suppressed due to low confidence (1)

libwebauthn/src/transport/cable/advertisement.rs:34

  • [nitpick] The field name _nonce suggests it's unused, but if it needs to be stored for potential future use, consider a more descriptive name like unused_nonce or remove it entirely if truly unnecessary.
            _nonce: nonce,

@AlfioEmanueleFresta AlfioEmanueleFresta changed the base branch from master to hybrid-fix July 19, 2025 22:34
@linux-credentials linux-credentials deleted a comment from Copilot AI Jul 19, 2025
Base automatically changed from hybrid-fix to master July 21, 2025 07:09
.await;

ux_sender
.set_connection_state(ConnectionState::Connected)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to set the state, before sending out the update of the changed state? I'm not fully sure what intricacies there are in terms of race condition possibilities.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR - I think this will be fine as the ConnectionState is only consumed internally, whilst UX updates are only consumed externally.

For each connection state transition:

  • The Connected state is only used to allow enqueuing CBOR operations, and starting the operation timeout timer. No behaviour that depends on the UX state.
  • The Terminated state is only used to fail operations early. If a new operation is queued after disconnection actually occurs, but before the state is transitioned to Terminated: the CBOR request will never be dequeued leading to a timeout.

Copy link
Collaborator

@msirringhaus msirringhaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good from what I can tell. Added one question.

@AlfioEmanueleFresta
Copy link
Member Author

Rebased.

@AlfioEmanueleFresta AlfioEmanueleFresta merged commit 38d6975 into master Jul 21, 2025
4 checks passed
AlfioEmanueleFresta added a commit that referenced this pull request Jul 21, 2025
Requires #126.

Changes:
* Moves UX updates to `Channel`, so that `Device::channel()` no longer
needs to return a tuple (Channel, Channel::UxUpdate)
* Changes updates channel implementation from multi-producer,
single-consumer `mpsc` to `broadcast`, allowing subscribing more than
once. This allows subscribing to events without borrowing the channel
mutably
* Wraps PIN entry callback with `Arc`, and makes all `UxUpdate`s
`Clone`, as `broadcast` requires the message to be `Clone`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants