Confirm reconnect pairings and add connection discovery settings

Setup now waits for both IndexedDB writes: the acceptor acknowledges its
write, a failure on either side is reported to both people, and the
proposer removes its copy if the acceptor could not save. Every session
that authenticates the paired device compares a check value derived from
the stored pairing, so a one-sided pairing (interrupted setup, or Turn off
reconnect on one device) is turned off on the other side too.

The tracker is chosen under Network settings > Connection discovery
(manual, default from VITE_TRACKER_URL, or custom), stored per browser and
editable during a session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-21 00:30:04 +02:00
1 parent 3659956967
commit acba97a7e1
10 files changed
+309 -55

No files matched your search

+31 -15
View File
@@ -280,9 +280,24 @@ sealed envelopes), `src/lib/tracker.ts` (WebSocket adapter and attempt logic) an
Either person proposes a tracker URL; the peer sees the host and accepts or
declines. Both contribute 32 random bytes; the HKDF context binds both device
keys, both fingerprints of that session and the tracker URL. The proposer
stores first, then the acceptor. The base key is a non-extractable CryptoKey
in the connection record, which Forget device, a replaced paired device and
**Turn off reconnect** clear. A changed local identity blocks the attempt.
stores first, then the acceptor; each waits for its IndexedDB write, and the
acceptor acknowledges its completed write before the proposer reports success.
A failed write on either side is reported to both people, and the proposer
removes its stored copy again if the acceptor's write failed. The base key is
a non-extractable CryptoKey in the connection record, which Forget device, a
replaced paired device and **Turn off reconnect** clear. A changed local
identity blocks the attempt.
- Every session that authenticates the paired device exchanges a 128-bit check
value derived from the stored pairing (or an empty value without one) over
the encrypted session. On a mismatch, the side holding a pairing turns it off
and says so. This repairs interrupted setups, and **Turn off reconnect** on
one device reaches the other at the next manual session. A match shows the
pairing as set up on both devices.
- **Connection discovery** in Network settings: Manual codes only, Default
tracker (only when `VITE_TRACKER_URL` is set) or Custom tracker. The choice is
a per-browser preference in `localStorage`, stays editable during a session,
and is resolved to a concrete URL when setup is proposed; existing pairings
keep their tracker.
- The discovery identifier is derived per UTC day; envelopes are AES-256-GCM with
a random IV, the role, info_hash, offer ID, source and destination peer IDs
as associated data, and a two-minute lifetime with five minutes' tolerance.
@@ -311,18 +326,19 @@ typical sealed codes are a few KB. Neither tracker is bundled.
Still open before this can ship:
- Signaling v5: pairing messages ride the v3 session protocol, so an older
peer rejects them as unexpected, and the device proof does not bind the
reconnect version.
- Joining adjacent day identifiers around UTC midnight, clock-skew detection,
and a frozen envelope encoding with published test vectors.
- The **Connection discovery** settings section: the tracker URL is entered in
the setup section (prefilled from `VITE_TRACKER_URL`), and changing it means
setting up again over a live session.
- Storage acknowledgement: each side stores without confirming the write to
the other, so a storage failure can leave one side configured.
- `connect-src` for the hosted CSP, Firefox and real separate-device networks,
tracker outage and cross-tab behavior (step 5), and the deployment checks.
- Firefox and real separate-device networks, tracker outage and cross-tab
behavior (step 5), `connect-src` for the hosted CSP, and the deployment checks.
- Clock-skew detection and a frozen envelope encoding with published test vectors.
Deliberately not planned for now:
- Signaling v5. Pairing messages ride the v3 session protocol, so an outdated
peer rejects them; reloading the page updates it.
- Joining adjacent day identifiers around UTC midnight. If one person presses
Reconnect just before UTC midnight and the other just after, they miss each
other until the first presses Reconnect again.
- An interrupted setup is not atomic across two browsers; the check in the
next authenticated session removes a one-sided pairing.
## References