Skip to main content

host_sso/
state.rs

1/// Observed state of the SSO session manager.
2///
3/// Transitions flow: `Idle` → `AwaitingScan` → `Paired` (happy path),
4/// or any state → `Failed` on error. `unpair()` always returns to `Idle`.
5#[derive(Debug, Clone, PartialEq)]
6#[non_exhaustive]
7pub enum SsoState {
8    /// No active session; pairing has not been initiated.
9    Idle,
10    /// QR code is displayed; waiting for the mobile app to scan it.
11    AwaitingScan {
12        /// The QR URI to present to the user (e.g. `polkadotapp://pair?handshake=…`).
13        qr_uri: String,
14    },
15    /// A session is established with the mobile wallet.
16    Paired {
17        /// SS58 address of the paired mobile account.
18        address: String,
19        /// Human-readable name shown during pairing (e.g. device name).
20        display_name: String,
21        /// Whether the mobile app is currently reachable on the transport.
22        phone_online: bool,
23    },
24    /// The last operation failed; the manager returns to `Idle` on next `pair()`.
25    Failed {
26        /// Human-readable reason for the failure.
27        reason: String,
28    },
29}