1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! The HTTPS endpoint an S2 Connect node exposes.
//!
//! As with [`client`](super::client), almost nothing is decided here. The router turns a
//! request into a call on [`proto::PairingServer`](crate::connect::proto::PairingServer)
//! or [`proto::SessionInitServer`](crate::connect::proto::SessionInitServer), and turns
//! that call's result back into a status code. [`SessionService`] builds its
//! `SessionInitServer` per request from the [`Store`], which works because everything that
//! must survive a restart is in the store — the grant waiting to be confirmed included.
//!
//! The status-code mapping is the interesting part, because the specification
//! distinguishes codes that are easy to collapse:
//!
//! | Outcome | Code | Why it matters |
//! |---|---|---|
//! | the attempt id is unknown | `401` | the client may **restart** the pairing |
//! | the challenge response is wrong | `403` | the attempt is **dead**; restarting is the only option |
//! | another attempt for this node is in flight | `503` | "try again soon" — not a failure |
//! | the roles or versions do not fit | `400` + body | a named reason the user can act on |
//!
//! A server that answers `400` to all four tells a client nothing, and the client's
//! recovery logic — which the specification spells out — cannot run.
//!
//! # What the host still owns
//!
//! Storage. This module keeps pairings in memory because a library cannot know where a
//! device puts its state; [`Store`] is the seam, and an implementation that writes to
//! SQLite or a flash partition drops straight in. Nothing else about the endpoint is
//! pluggable, because nothing else about it is a choice.
pub use WaitingNode;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Error;
pub use ;
/// Fill a buffer from the operating system's CSPRNG.
///
/// Every secret this endpoint mints — attempt ids, challenges, access tokens,
/// communication tokens — comes from here. A failure means the system has no entropy
/// source, which is not something to paper over with a weaker generator.
pub