Plan shareable invitation links

Codes move into the URL fragment, which browsers never send to the host.
A compressed, versioned encoding with offer/answer type and an echoed ref
serves both links and pasted codes. Offers open an import dialog with slot
selection; answer links reach the waiting tab over BroadcastChannel, with
copy/paste as fallback. Includes measured code sizes and acceptance checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-19 22:26:22 +02:00
1 parent 1b76c7ce01
commit 4cf2ff5211
2 files changed
+125

No files matched your search

+123
View File
@@ -0,0 +1,123 @@
# Shareable invitations (planned, not implemented)
Phase 4 of the [UX roadmap](ux-roadmap.md). The sender shares a link instead of
a pasted code; the receiver opens it, previews it and creates an answer, which
returns as a link as well. Pasteable codes remain the universal fallback. No
server, storage service or new dependency is involved; Vue remains the only
runtime dependency.
## Why the fragment
The code travels after `#`. Browsers never send the fragment in HTTP requests or
`Referer` headers, so the app host, its service worker, proxies and network
observers do not receive it. Over HTTPS, an observer sees the hostname and IP
addresses only, as today.
Everyone the link is shared with sees it: the recipient, the messenger and, for
messengers without end-to-end encryption, their servers. That is the same
exposure as a pasted code. Browser history, including synced history, may keep
the full URL even after the app clears it; this is the one addition compared with
pasting. Codes are not secrets and stop working when the session ends, but they
contain IP addresses. Fingerprint comparison and device proofs, not code secrecy,
prevent a leaked or substituted code from being used for interception.
## Code format
Measured in headless Chromium (2 host candidates, 1 with STUN): current codes are
1.0–1.5 KB; deflated and base64url-encoded they are 650–780 characters, including
a v4 identity. More interfaces and TURN candidates grow both; a code stays well
below 2 KB in typical cases.
One encoding serves codes and links: a versioned prefix followed by base64url of
`deflate-raw`-compressed JSON (native `CompressionStream`). The JSON keeps the
existing session versions (3 temporary, 4 with identity) and adds:
- `type`: `offer` or `answer`. Pasting an offer into the answer field, or the
reverse, fails with a clear message instead of an SDP error.
- `ref`: 16 random bytes chosen by the offerer and echoed by the answerer. An
answer for a different offer is rejected before it reaches the peer connection.
It also addresses answer links to the waiting tab (see below).
Decoding bounds the compressed input and stops decompression once the output
exceeds `MAX_SIGNAL_LENGTH`, so a small hostile link cannot expand without limit.
Decoding becomes asynchronous: parse once into a validated structure
(`type`, `ref`, `sdp`, `identity`) and pass that around instead of re-decoding
text in `TransferPanel`. 0.0.5 is unreleased and already incompatible with 0.0.4,
so no legacy encoding is accepted; a recognizable old code reports that both
people need the current version.
A link is the current app URL (from `location`, so any self-hosted path works)
with the code as its fragment. Every code field accepts either a bare code or a
full link and uses the part after `#`. A link from another HellCon host can be
pasted into one's own instance; opening it directly would use that host's
origin, without one's saved connections and identity.
## Receiving an invitation
`main.ts` reads the fragment before mounting, removes it with
`history.replaceState`, and hands it to the app; `hashchange` covers a link
pasted into an already open tab. Invalid fragments show an error and are
discarded the same way.
An offer opens an import dialog. It never creates an answer automatically,
because answering reveals the receiver's addresses to whoever made the link.
The dialog shows:
- that this is an invitation to receive files and that it only works while the
sender's page is waiting (setup times out after 5 minutes);
- the device status: no identity, a new device, or a key matching a slot's paired
device. A match is a suggestion; the fresh device proof still decides;
- whether the code contains a TURN relay, which requires the receiver's explicit
TURN opt-in as today;
- a slot selector: the matching paired slot if idle, otherwise the current slot
if idle, otherwise **New connection**. Busy slots are unavailable.
**Open** selects the slot, switches it to Receive, fills the code and focuses
**Accept & create answer**. Network settings and identity behave as for a pasted
code.
## Returning the answer
The answer is shared as a link too. Opened from a messenger it lands in a new tab,
but the sender's offer lives only in memory in the original tab. The new tab
posts `{ ref, code }` on a `BroadcastChannel`. A panel waiting in `offer-ready`
with that `ref` acknowledges and applies the answer as if Connect had been
pressed; fingerprint comparison or the device proof follows as usual. A second
delivery of the same answer is acknowledged as already used.
After an acknowledgement the new tab says the answer was delivered and the user
can switch back; pages cannot focus another tab. Without an acknowledgement
within about a second, for example in a messenger's in-app browser with separate
storage or in another browser, it shows the answer with **Copy** and explains
where to paste it. The channel is same-origin; other sites cannot post to it.
## Sharing UI
Where `navigator.share` accepts a URL, offer **Share link**; always offer
**Copy link**, with the bare code in a collapsed section. The privacy note says
that a link is as sensitive as a code, may remain in browser history, and should
be sent privately. Status texts name the 5-minute limit while waiting.
QR codes stay deferred. Measured sizes fit a QR code, but generating one needs a
hand-written encoder or a dependency, and scanning adds camera handling.
## Implementation steps and acceptance checks
1. Codec module with Node tests: round trips for both types and versions, bare
code vs. link, whitespace, invalid base64url, oversized input, decompression
bomb, wrong `type`, `ref` mismatch, old-format detection.
2. Switch signaling to the parsed structure; keep existing webrtc/session tests
green and add `ref` validation in `useAnswer`.
3. Fragment intake, import dialog and slot selection through `App` →
`ConnectionWorkspace` → `TransferPanel`.
4. Answer relay and fallback; Share/Copy link UI.
5. Browser check: offer link in a second page shows the dialog and a clean URL;
accepting it and opening the answer link in a third page connects the sender's
tab; exact bytes transfer. Repeat the answer link in a separate browser context
for the fallback. Run axe on the dialog.
6. Manually verify on phones with at least two messengers: link length intact,
preview fetches without the fragment, in-app browser behaviour, Web Share.
7. Update README, CHANGELOG and the roadmap.
The shorter encoding also reduces the payload the planned
[tracker reconnect](webtorrent-reconnect.md) carries.
+2
View File
@@ -90,6 +90,8 @@ independent cryptographic audit.
## 4. Shareable invitations
Detailed in [the invitation plan](invitations.md).
For HTTPS, encode fresh offers in URL fragments with an explicit Share/Copy link
action and an import preview. Keep connection details out of query strings and
server paths. Fragments still expose their contents to link recipients and any