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