Expand description
Pairing a device with a portable identity (P7-03, ARCHITECTURE §47):
the link a device shows as a QR code, and the frames the identity’s
phone and the device then exchange over a direct Iroh connection on
PAIR_ALPN. No Spoolframe server takes part.
A TV has no camera, so the QR code goes one way, device to phone:
spoolframe://pair?e=<endpoint id>&c=<code>&n=<name>&a=<ip:port>&r=<relay url>
e, the device’sEndpointIdas 64 hex digits, andc, the one-timePairingCodeas 43 base64url characters (no padding), are required. The phone dialseand nothing else, and Iroh’s TLS proves the key, so the phone pairs with the device that showed the code or with nothing.nis the device’s name, for “Pairing with …” while the phone dials; cut toMAX_NAMEcharacters.a(repeated, at mostMAX_ADDRS) andr(repeated, at mostMAX_RELAYS) are where the device may be reached. Hints: the key is still proved whatever path is taken.
Values are percent-encoded as in an invite link (crate::invite).
A parameter this build does not know is ignored; a second e or c
is not (the link is refused), nor is one that cannot be read.
Then, on one bidirectional stream, each frame a crate::codec frame
(big-endian u32 length, CBOR) of at most MAX_FRAME bytes:
- phone → device:
PhoneFrame::Hello, the code and the identity the phone wants this device to act as; - device → phone:
DeviceFrame::Key, the device’s key for that identity and its name, orDeviceFrame::Refused; - phone → device:
PhoneFrame::Credential, the root’s credential for that key, the identity’s newest state and the servers it signs in to (P7-06), orPhoneFrame::Declined; - device → phone:
DeviceFrame::Done, orDeviceFrame::Refused.
Structs§
- Paired
Server - A server the paired identity signs in to, as the phone has it saved (P7-06): enough for the device to pin and reach it. The phone vouches for it as the invite that brought it there did; the device dials the key and nothing else, and Iroh proves it.
- Pairing
Answer - The root terminal’s answer to a
PairingOffer: whatPhoneFrame::Credentialcarries on a direct pairing. The server only carries it: the device checks the credential names its own key and shows whose identity it is before it keeps it. - Pairing
Code - A one-time pairing code: 32 random bytes the device made, shown only in
its QR code. Compared in constant time;
fmt::Debugdoes not show it. - Pairing
Link - What a pairing link holds.
- Pairing
Offer - A device’s pairing request, held on a server under a
RelayCodefor a root terminal to fetch (P7-08): the key the root is to vouch for and the device’s name. Public data: whoever has the code may read it. - Relay
Code - The short code a device shows beside its QR code, for a root terminal with no camera to pair it through a server both reach (P7-08): 10 characters of Crockford’s base32, written in two groups of five.
Enums§
- Device
Frame - What the device sends.
- Link
Error - Why a text is not a pairing link.
- Phone
Frame - What the phone sends.
- Refusal
- Why a device refused a pairing. The device’s pairing ends with each of them: it shows a new code to try again.
Constants§
- CODE_
LEN - Bytes in a
PairingCode: 256 bits, out of reach of guessing within its five minutes whatever the rate. - CODE_
TTL_ SECS - How long a code is good for, from when the device shows it.
- MAX_
ADDRS - The most
ahints a link is written or read with. - MAX_
FRAME - The largest pairing frame either side reads: room for an identity state at its limit of revoked keys, 1024 of about 90 bytes each.
- MAX_
LINK - The longest link read, in bytes. A link this build writes fits with every hint at its limit, the name in characters of three bytes each; a usual one (a LAN address or two, a short name) is under 250, a QR code of version 10 or so.
- MAX_
NAME - The most characters of the device’s name a link carries.
- MAX_
PAIRED_ SERVERS - The most servers a
PhoneFrame::Credentialcarries; a device reads no more. - MAX_
RELAYS - The most
rhints a link is written or read with. - PAIR_
ALPN - The ALPN of pairing, version 1. A device accepts it only while it shows a pairing code; at any other time a connection on it fails its handshake.
- RELAY_
CODE_ LEN - Characters in a
RelayCode: 10 of Crockford’s base32, 50 bits. Typed by a person, so short; guessed only at the rate the server lets a stranger try, against a code that livesRELAY_TTL_SECS. - RELAY_
TTL_ SECS - How long a server holds a relayed pairing (P7-08), from its offer.
Functions§
- parse_
link - The pairing link
textholds.