Skip to main content

spoolframe_protocol/
lib.rs

1//! The `spoolframe/client/1` wire protocol: messages, framing and ALPN
2//! names.
3//!
4//! Permissively licensed (MIT OR Apache-2.0); it is the boundary that
5//! proprietary clients talk across, so it never depends on an AGPL crate.
6//!
7//! One connection carries many QUIC streams ([`streams`]). Every message
8//! is a length-prefixed CBOR frame ([`codec`]); the messages are in
9//! [`messages`].
10
11pub mod artwork;
12pub mod codec;
13pub mod device_sign_in;
14pub mod downloads;
15pub mod experimental;
16pub mod federation;
17pub mod fingerprint;
18pub mod invite;
19pub mod invite_admin;
20pub mod lan;
21pub mod media;
22pub mod messages;
23pub mod pairing;
24pub mod passkeys;
25pub mod playback;
26pub mod playlists;
27pub mod plex;
28pub mod policy;
29pub mod portable;
30pub mod previews;
31pub mod relay_access;
32pub mod resource;
33pub mod rpc;
34pub mod search;
35pub mod server_id;
36pub mod streams;
37
38pub use artwork::{ArtworkReply, ArtworkRequest, ArtworkResponse, ArtworkSize};
39pub use media::{MAX_READ, MediaRead, MediaReadReply, MediaReadResponse, PlaybackHandle};
40pub use messages::{
41    AddressNetwork, AuthMethod, ChangePassword, ConfirmPassword, DeviceAddress, DeviceInfo,
42    DeviceSignInRequest, Error, Event, Hello, HomeScreen, InviteLookupOutcome, LoginPassword,
43    LookupInvite, MAX_HELLO_TEXT, ManifestKind, PROTOCOL_VERSION, PinProof, PinState,
44    PortableSignIn, PortableTie, RedeemInvite, RedeemPortableInvite, Reply, Request,
45    RequestEnvelope, Response, SUBTITLE_CHUNK, ServerInfo, ServerRow, SessionId, SessionInfo,
46    TrackPreferencesInfo, TrustedProfile, UserSummary, WhoAmIReply,
47};
48pub use passkeys::{
49    FinishPasskeyRegistration, FinishPasskeySignIn, LEGACY_APP_RP_ID, NONCE_LEN, PasskeyCreation,
50    PasskeyInfo, PasskeyRegistrationBegun, PasskeyRequest, PasskeySignInBegun,
51    app_passkey_challenge, is_app_rp_id,
52};
53pub use playback::{
54    AudioAction, BitmapSubtitles, ChosenTracks, ConvertedAudio, ConvertedSubtitle, ConvertedVideo,
55    PlannedAudio, PlannedSubtitle, PlaybackPlan, Quality, Rung, Selection, SubtitleAction,
56    SubtitleDelivery, TrackReason,
57};
58pub use plex::{PlexLink, PlexSyncSummary};
59pub use portable::{
60    CredentialError, DevicePublicKey, InvalidDevicePublicKey, InvalidPortableUserId,
61    PORTABLE_USER_ID_LEN, PortableIdentityState, PortableUserId, RevokedKey, StateError, TieProof,
62    TieProofError, UserDeviceCredential, tie_message,
63};
64pub use previews::{PreviewTile, Previews};
65pub use search::{
66    Copies, SearchCounts, SearchGroup, SearchHit, SearchRequest, SearchResults, TitleCopy,
67    TopResult,
68};
69pub use server_id::{APP_RP_DOMAIN, InvalidServerId, SERVER_ID_LEN, ServerId};
70
71/// Development ALPN. Breaking revisions currently retain `/1` and require
72/// a coordinated server/SDK update; [`PROTOCOL_VERSION`] identifies the revision.
73pub const CLIENT_ALPN: &[u8] = b"spoolframe/client/1";
74
75/// The ALPN of server-to-server federation, version 1:
76/// [`federation`]. Experimental: a server whose
77/// `experimental.federation` is off refuses it with
78/// [`close::UNSUPPORTED_PROTOCOL`].
79pub const FEDERATION_ALPN: &[u8] = b"spoolframe/federation/1";
80
81/// The ALPN a device pairs with a portable identity's phone on,
82/// directly, with no server: [`pairing`].
83pub use pairing::PAIR_ALPN;
84
85/// QUIC application close codes a Spoolframe peer sends, with a
86/// human-readable reason beside them.
87pub mod close {
88    /// The ALPN is known but this peer does not serve it.
89    pub const UNSUPPORTED_PROTOCOL: u32 = 1;
90    /// The server holds as many connections from devices with no session
91    /// as it takes. A device that is signed in is always let in;
92    /// one that is not tries again later.
93    pub const BUSY: u32 = 2;
94    /// The device's last live session on this server ended (signed out,
95    /// revoked, or its user disabled). It may connect again, as a device
96    /// that is not signed in.
97    pub const SIGNED_OUT: u32 = 3;
98    /// Federation: the dialling server's endpoint is paired under
99    /// another server id. Refused every time.
100    pub const SERVER_ID_CHANGED: u32 = 4;
101    /// Federation: the two servers no longer pair; the one closing
102    /// revoked its side.
103    pub const UNPAIRED: u32 = 5;
104}