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 diagnostics;
15pub mod downloads;
16pub mod experimental;
17pub mod features;
18pub mod federation;
19pub mod fingerprint;
20mod home_view;
21pub mod invite;
22pub mod invite_admin;
23pub mod lan;
24pub mod media;
25pub mod messages;
26pub mod pairing;
27pub mod passkeys;
28pub mod phone_sign_in;
29mod plan_summary;
30pub mod playback;
31pub mod playlists;
32pub mod plex;
33pub mod policy;
34pub mod portable;
35pub mod previews;
36pub mod recently_played;
37pub mod relay_access;
38pub mod resource;
39pub mod rpc;
40pub mod search;
41pub mod search_rank;
42mod search_view;
43pub mod server_id;
44pub mod streams;
45pub mod well_known;
46
47#[cfg(feature = "uniffi")]
48uniffi::setup_scaffolding!();
49
50pub use artwork::{ArtworkFace, ArtworkReply, ArtworkRequest, ArtworkResponse, ArtworkSize};
51pub use features::{Feature, Features};
52pub use home_view::{Featured, FeaturedLimits, FeaturedRow};
53pub use media::{MAX_READ, MediaRead, MediaReadReply, MediaReadResponse, PlaybackHandle};
54pub use messages::{
55    AddressNetwork, AuthMethod, BeginInvitePasskey, ChangePassword, ConfirmPassword, DeviceAddress,
56    DeviceInfo, DeviceSignInRequest, Error, Event, Hello, HomeScreen, InviteLookupOutcome,
57    LoginPassword, LookupInvite, MAX_HELLO_TEXT, ManifestKind, NextMode, PROTOCOL_VERSION,
58    PinProof, PinState, PortableSignIn, PortableTie, RedeemInvite, RedeemInviteWithPasskey,
59    RedeemPortableInvite, Reply, Request, RequestEnvelope, Response, SUBTITLE_CHUNK, ServerInfo,
60    ServerRow, SessionId, SessionInfo, TrackPreferencesInfo, TrustedProfile, UserSummary,
61    WhoAmIReply, cut,
62};
63pub use passkeys::{
64    FinishPasskeyRegistration, FinishPasskeySignIn, LEGACY_APP_RP_ID, MAX_NAME_CHARS, NONCE_LEN,
65    PasskeyCreation, PasskeyInfo, PasskeyRegistrationBegun, PasskeyRequest, PasskeySignInBegun,
66    app_passkey_challenge, fit_name, is_app_rp_id,
67};
68pub use plan_summary::{
69    AudioSummary, PlanKind, PlanSummary, SubtitleHow, SubtitleSummary, VideoSummary,
70};
71pub use playback::{
72    AudioAction, BitmapSubtitles, ChosenTracks, ConvertedAudio, ConvertedSubtitle, ConvertedVideo,
73    PlannedAudio, PlannedSubtitle, PlaybackPlan, Quality, Rung, Selection, SubtitleAction,
74    SubtitleDelivery, TrackReason,
75};
76pub use plex::{PlexLink, PlexSyncSummary};
77pub use portable::{
78    CredentialError, DevicePublicKey, InvalidDevicePublicKey, InvalidPortableUserId,
79    PORTABLE_USER_ID_LEN, PortableIdentityState, PortableUserId, RevokedKey, StateError, TieProof,
80    TieProofError, UserDeviceCredential, tie_message,
81};
82pub use previews::{PreviewTile, Previews};
83pub use search::{
84    Copies, SearchCounts, SearchGroup, SearchHit, SearchRequest, SearchResult, SearchResults,
85    TitleCopy, TopResult,
86};
87pub use search_view::{HiddenUnder, PlayFromChoice};
88pub use server_id::{APP_RP_DOMAIN, InvalidServerId, SERVER_ID_LEN, ServerId};
89
90/// Development ALPN. Breaking revisions currently retain `/1` and require
91/// a coordinated server/SDK update; [`PROTOCOL_VERSION`] identifies the revision.
92pub const CLIENT_ALPN: &[u8] = b"spoolframe/client/1";
93
94/// The ALPN of server-to-server federation, version 1:
95/// [`federation`]. Experimental: a server whose
96/// `experimental.federation` is off refuses it with
97/// [`close::UNSUPPORTED_PROTOCOL`].
98pub const FEDERATION_ALPN: &[u8] = b"spoolframe/federation/1";
99
100/// The ALPN a device pairs with a portable identity's phone on,
101/// directly, with no server: [`pairing`].
102pub use pairing::PAIR_ALPN;
103
104/// The ALPN a TV takes a phone's sign-ins on, directly, with no
105/// server: [`phone_sign_in`].
106pub use phone_sign_in::SIGNIN_ALPN;
107
108/// QUIC application close codes a Spoolframe peer sends, with a
109/// human-readable reason beside them.
110pub mod close {
111    /// The ALPN is known but this peer does not serve it.
112    pub const UNSUPPORTED_PROTOCOL: u32 = 1;
113    /// The server holds as many connections from devices with no session
114    /// as it takes. A device that is signed in is always let in;
115    /// one that is not tries again later.
116    pub const BUSY: u32 = 2;
117    /// The device's last live session on this server ended (signed out,
118    /// revoked, or its user disabled). It may connect again, as a device
119    /// that is not signed in.
120    pub const SIGNED_OUT: u32 = 3;
121    /// Federation: the dialling server's endpoint is paired under
122    /// another server id. Refused every time.
123    pub const SERVER_ID_CHANGED: u32 = 4;
124    /// Federation: the two servers no longer pair; the one closing
125    /// revoked its side.
126    pub const UNPAIRED: u32 = 5;
127}