Codes now travel as links with the code in the URL fragment, which the app reads and clears before mounting (and on hashchange). An offer link opens a preview that suggests an idle slot, preferring the one paired with the sender's device, and only fills in the code; the user still creates the answer. Answer links reach the waiting sender tab over a same-origin BroadcastChannel, are acknowledged once and reported as used afterwards, and fall back to copy and paste when no tab answers. The panel offers Share link where the Web Share API accepts URLs, Copy link, and the bare code under a disclosure. The browser check covers the offer dialog, clean URL, answer relay, reuse, fallback on another origin, an invalid fragment, axe on both dialogs and exact bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6.7 KiB
Shareable invitations
Phase 4 of the UX roadmap. 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:offeroranswer. 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.
- 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,refmismatch, old-format detection. - Switch signaling to the parsed structure; keep existing webrtc/session tests
green and add
refvalidation inuseAnswer. - Fragment intake, import dialog and slot selection through
App→ConnectionWorkspace→TransferPanel. - Answer relay and fallback; Share/Copy link UI.
- 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.
- Manually verify on phones with at least two messengers: link length intact, preview fetches without the fragment, in-app browser behaviour, Web Share.
- Update README, CHANGELOG and the roadmap.
The shorter encoding also reduces the payload the planned tracker reconnect carries.