Remove shareable invitation links

Codes are exchanged by copy and paste again. The URL fragment intake,
the invitation dialog, the BroadcastChannel answer relay and the Share
link / Copy link controls are gone, along with their tests, browser
check scenarios and design doc. Code fields no longer accept links.

The compressed HC1 codes with typed offers/answers and echoed refs stay.
An optional signaling backend is the intended way to simplify the
exchange instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-20 19:47:07 +02:00
1 parent f320bfb541
commit a5935a8324
16 files changed
+57 -602

No files matched your search

-128
View File
@@ -1,128 +0,0 @@
# Shareable invitations
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
Steps 1–5 and 7 are implemented (`src/lib/codes.ts`, `src/lib/invitations.ts`,
`InvitationDialog.vue`, and the invitation flow in `scripts/browser-check.ts`,
which opens the fallback on a second origin instead of a separate browser
context). Step 6 still needs manual verification.
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.
+7 -13
View File
@@ -86,23 +86,17 @@ storage denial/recovery, and protocol-version validation. Design and review note
are in [the device identity protocol](device-identities.md); this is not an
independent cryptographic audit.
## 4. Shareable invitations — implemented
## 4. Compressed connection codes — implemented
Detailed in [the invitation design](invitations.md).
Offers and answers are shared as links with the compressed code in the URL
fragment, through **Share link** where supported or **Copy link**; the bare code
stays available. Opening a link clears the fragment. An offer opens an import
preview with slot selection and never answers automatically. An answer link
reaches the waiting sender tab in the same browser over `BroadcastChannel` and
otherwise falls back to copy and paste. An answer exchange remains necessary.
Still open: manual checks of link length, previews and in-app browsers across
real messengers and phones. QR codes remain deferred.
Offers and answers are compressed `HC1.` codes that state their type and share a
reference, so mixed-up or stale codes are rejected with a specific message.
Shareable invitation links were built on top and removed again: they did not make
real-world connections more reliable. An optional signaling backend is the
intended way to simplify the exchange.
## 5. Guided connection flow
Present one primary next action across Choose files → Share invitation → Connect
Present one primary next action across Choose files → Share code → Connect
→ Verify → Transfer. Collapse completed setup steps, expose advanced network
settings on demand, and keep relay consent explicit. Show session state separately
from file progress. Distinguish connected, awaiting acceptance, saving, completed,