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