360 lines
21 KiB
Markdown
360 lines
21 KiB
Markdown
# HellCon
|
||
|
||
Current version: **0.0.4**. See the [changelog](CHANGELOG.md) for release notes
|
||
and compatibility changes.
|
||
|
||
Browser-to-browser file sharing with Vue 3 and WebRTC. No accounts, signaling
|
||
backend, or server-side file storage. You exchange connection codes manually.
|
||
Direct connections are the default. TURN relaying is optional and requires
|
||
explicit opt-in by both people; no relay is configured automatically.
|
||
|
||
## How it works
|
||
|
||
1. The person starting the connection selects one or more files and configures STUN (PageQuit by default, Google,
|
||
Cloudflare, a custom provider, or None). They create a code and send it
|
||
privately to the intended receiver through an authenticated channel. Normal
|
||
messenger copy/paste is supported; there is no need to transcribe codes.
|
||
2. The receiver pastes the code, creates an answer, and sends it back. The sender
|
||
pastes the answer. Gathering waits for completion, up to 30 seconds; a timeout
|
||
fails rather than quietly exporting incomplete connection information.
|
||
3. **Both people compare both full SHA-256 certificate fingerprints** over a
|
||
channel whose authenticity and integrity they trust, such as in person.
|
||
Your fingerprint must equal their “Their fingerprint”, and vice versa.
|
||
Compare every byte. Cancel on any mismatch. Both people must explicitly
|
||
confirm before the app sends the filename, size, MIME metadata, or contents.
|
||
On later connections, a remembered device’s fresh proof can replace manual
|
||
comparison (see Remembered devices below).
|
||
4. The receiver sees the filename and size and explicitly accepts the file.
|
||
On the hosted app (HTTPS or localhost), **Receive as download** shows the incoming file size and streams into the browser's download manager using a same-origin service worker.
|
||
It requires transferable streams and service-worker support; Chromium and
|
||
Brave have been tested with 120 MiB files. Allow the download and keep the
|
||
receiving tab open. File contents are not uploaded to the web host.
|
||
**Choose destination & receive to disk** remains available with a supported
|
||
native file picker. **Receive in memory** retains its 64 MiB cap. Even capped
|
||
memory downloads may be too large on a memory-constrained device.
|
||
5. The sender waits for a receipt acknowledgment. For disk transfers, the receiver
|
||
sends this only after its writable stream closes successfully; for streaming
|
||
downloads, after handing all bytes to the browser; for memory transfers,
|
||
after constructing the complete download. A streaming receipt does not prove
|
||
the download manager successfully saved the file: check its final status in
|
||
Downloads. This also does not prove a human saved a memory download, nor that
|
||
a malicious receiver told the truth. Streamed transfers have no app-defined size cap; browser, filesystem, and
|
||
available storage limits apply. Byte counts must remain safe JavaScript integers
|
||
(at most 2^53 − 1 bytes). Files above 120 MiB have not been tested end to end.
|
||
|
||
Once both people verify, either person can add files without new codes or another
|
||
fingerprint comparison. Each side can queue up to 32 files (including its active
|
||
outgoing file). Each direction transfers one file at a time; sending and receiving
|
||
can happen simultaneously. Each file has its own progress, receipt and explicit
|
||
receiver acceptance. **Remove** drops a waiting local queue item; **Decline file**
|
||
rejects an incoming offer and lets the sender's queue continue.
|
||
|
||
**Disconnect** ends the entire session, drops waiting files and aborts unfinished
|
||
disk writes. To cancel an already active transfer, disconnect; cancelling only an
|
||
active file is not supported. Completed memory downloads remain available after
|
||
disconnect. Save a previous memory download before accepting another file;
|
||
acceptance replaces it. **Reset** discards the memory download and returns to
|
||
setup. Before connecting, Send/Receive chooses who starts the connection. Once
|
||
verified, these controls navigate to the sending and receiving sections without
|
||
reconnecting. The initial receiver can click **Send**, then **Add files to send**.
|
||
|
||
Keep both tabs open. Switching browser tabs or apps does not explicitly cancel
|
||
the session, although browsers and mobile operating systems can suspend pages.
|
||
Pending verification/acceptance expires after five minutes; stalled transfers
|
||
expire after one minute. Idle verified sessions stay open. Lost connections need
|
||
fresh codes. File transfers use protocol **v3**; pre-v3 connection codes are
|
||
rejected before connecting. The local HTML supports the same manual flow.
|
||
|
||
If an answer is rejected as invalid, correct the pasted answer and click Connect
|
||
again; the sender keeps its existing offer while it is still awaiting an answer.
|
||
After a connection actually closes or fails, use Reset and exchange a **new offer
|
||
and new answer**. Old codes refer to the closed connection and cannot reopen it.
|
||
Reset returns the page to its initial ready state. For a local test, open two
|
||
separate browser tabs or windows; use Disconnect before changing the setup role. Use the specific error shown in red to diagnose
|
||
failures; if a configured STUN server is unreachable, try None for a local test.
|
||
|
||
### Connection diagnostics and first-version comparison
|
||
|
||
Expand **Connection diagnostics** to copy the last 80 timed events. The log
|
||
retains local/remote candidate type counts, candidate-pair states, selected
|
||
route types, DTLS transport states, and ICE check request/response counters after failure.
|
||
Four snapshots during ICE checking preserve evidence before failed pairs disappear. Final stats
|
||
are requested before closing the peer, with a 300 ms cleanup bound. A `?` means
|
||
the browser did not supply a counter; it does not mean zero. Addresses, raw SDP,
|
||
candidate IDs, credentials, server URLs and filenames are excluded.
|
||
|
||
Same-machine success does not establish cross-device connectivity. Error 701
|
||
alone does not establish the cause of a failed connection. A receiver shutdown
|
||
after both sides report completion can be normal sender cleanup.
|
||
|
||
The comparison with the first commit and controlled test results are recorded in
|
||
[the investigation notes](docs/connection-investigation.md). Run the isolated
|
||
ICE experiment with `node scripts/compare-ice.mjs firefox` or replace `firefox`
|
||
with `chromium`. This uses local browser peers and deliberately unusable offer
|
||
ports plus a 20-second answer delay; it is **not a cross-device test**. Add
|
||
`--normal-candidates` to preserve the real candidate ports. No firewall changes,
|
||
TURN credentials or public STUN service are required.
|
||
|
||
## Remembered devices
|
||
|
||
On the hosted app, expand **Remembered devices** and choose **Create device
|
||
identity** on both browsers. Enable **Use my device identity for this connection**,
|
||
exchange codes, and compare both full fingerprints for the first pairing. Once
|
||
connected, give the peer a local nickname and choose **Remember device**.
|
||
|
||
For later connections, enable your identity and select the **Expected device**
|
||
on each side before exchanging fresh codes. HellCon checks fresh signed proofs
|
||
bound to both device keys and both connection fingerprints. A matching saved key
|
||
can replace manual fingerprint comparison; file acceptance is still required.
|
||
A changed or missing identity requires manual comparison and never overwrites a
|
||
saved contact. Nicknames stay local. Public identities in codes can link sessions.
|
||
|
||
Use **Forget** to remove a contact, or explicitly delete your identity and contacts.
|
||
Encrypted backup/restore includes both, protected by a password of at least 12
|
||
characters. Keep that password separately. Clearing site data loses saved trust;
|
||
restoring a backup on another browser gives it the same identity. Browser-stored
|
||
keys remain accessible to trusted app code and are not protection against a
|
||
malicious host. Identity use defaults off after reload. Storage failure leaves
|
||
temporary connections available; downloaded local HTML stays manual.
|
||
|
||
Identity-enabled codes use signaling version **4** and require the new build.
|
||
Temporary codes retain version **3**. If only one peer enables identity, the
|
||
current build uses manual comparison without remembering that connection.
|
||
See [the identity protocol and backup format](docs/device-identities.md).
|
||
|
||
## Network privacy and optional TURN
|
||
|
||
STUN discovers externally reachable addresses. Its operator can see your public
|
||
IP address and request metadata, but STUN does not relay file contents. Lookups,
|
||
retries and connectivity checks may involve multiple packets. Choosing None
|
||
avoids contacting a configured STUN provider; direct connectivity depends on
|
||
addresses, routing, browser policy and firewalls, not simply whether peers share
|
||
one network. A VPN is not automatically a guarantee against address disclosure.
|
||
|
||
Connection codes are **Base64-encoded, not encrypted**. They contain SDP,
|
||
including candidate addresses, temporary ICE credentials and certificate
|
||
fingerprints. Peers and anyone who sees these codes (including the messaging
|
||
service used to exchange them) may learn connection details. Local addresses may
|
||
be obscured by the browser, but this app does not provide anonymity. Treat codes
|
||
as private session information; do not publish them.
|
||
|
||
Restrictive NATs or firewalls can prevent direct connections. There is no silent
|
||
TURN retry. To permit a relay, both people must explicitly check **Allow a TURN
|
||
relay**, supply their authorized TURN URL, username and password, and generate
|
||
new codes. Otherwise TURN URLs are rejected in the STUN field and codes with
|
||
relay candidates are rejected. Enabling TURN allows the browser to contact that
|
||
relay during gathering and select a relay route when needed. This does not force
|
||
relay-only routing or hide your IP from the peer. A remote peer can independently
|
||
proxy their own traffic; the opt-in controls this app's configuration and the
|
||
relay candidates it accepts, not arbitrary software run by the other person.
|
||
|
||
When a credential endpoint is configured (including the local development setup
|
||
below), **Use the configured relay with temporary credentials** replaces manual
|
||
credential entry. The app fetches fresh credentials for each new connection,
|
||
only after TURN opt-in. The issued relay address, username and masked password
|
||
appear in read-only fields while the connection is active. Uncheck it to use a
|
||
different relay manually.
|
||
|
||
TURN credentials stay in the current component's memory; the app does not persist
|
||
them or include them in codes. The relay receives its authentication exchange and
|
||
can observe addresses, timing and traffic volume, and may charge for bandwidth.
|
||
Resetting, cancelling or ending a connection clears TURN consent;
|
||
check the option again before creating another relayed connection.
|
||
File traffic remains DTLS encrypted through the relay. The web host, DNS resolver,
|
||
and code-exchange service are also relevant third parties.
|
||
|
||
## Security model and limits
|
||
|
||
Data channels use **SCTP over DTLS**, which provides transport confidentiality and
|
||
integrity. This is not DTLS-SRTP (the media transport). DTLS authenticates the
|
||
certificate in the connection description; an independently authenticated full
|
||
fingerprint comparison binds that certificate to the intended peer. Comparing
|
||
fingerprints through a channel an attacker can rewrite provides no such assurance.
|
||
|
||
You must trust your browser, device, and **the JavaScript you load**. A compromised
|
||
host or build can steal plaintext or falsify the verification display. Serve the
|
||
production build over HTTPS, or run a verified build you control on localhost.
|
||
HTTPS protects delivery against network tampering, not against a malicious host.
|
||
The app does not upload files to its web host in this implementation; that is a
|
||
property of this code, not a guarantee against a host serving different code.
|
||
|
||
The protocol accepts one ordered, reliable data channel, bounded metadata and
|
||
messages, exact declared byte counts, and at most one accepted file per direction.
|
||
Monotonic per-direction file IDs bind offers, data, and receipts to their files. It rejects unexpected
|
||
states, excess data and duplicate metadata. An acknowledged 1 MiB send window per transfer
|
||
and a bounded receive queue limit buffering during disk writes. Files are treated
|
||
as opaque downloads; metadata is not rendered as HTML. Encryption does not make
|
||
a file safe to open. These limits reduce denial-of-service exposure but do not
|
||
eliminate browser, device, network, or malicious-peer risks.
|
||
|
||
For deployment, serve `dist/` as static files over HTTPS. Do not expose the Vite
|
||
dev or preview server as the production service. Configure hosting headers such
|
||
as `Content-Security-Policy` (including `frame-ancestors 'none'`),
|
||
`X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer`. A baseline
|
||
CSP for this build is `default-src 'self'; script-src 'self'; style-src 'self'
|
||
'unsafe-inline'; img-src 'self'; connect-src 'self'; object-src 'none'; base-uri
|
||
'none'; frame-ancestors 'none'`. Inline styles are currently used for progress and
|
||
Vue visibility. Test headers on the actual host; CSP is defense in depth and is
|
||
not a substitute for trusting the host or a portable WebRTC egress filter.
|
||
`robots.txt` and indexing metadata are crawler requests, not access control.
|
||
|
||
Deploy the complete `dist/` directory, including `download/worker.js`, served
|
||
with a JavaScript MIME type. The download worker has scope `download/` only:
|
||
it does not control the app page, cache the app, or proxy normal web requests.
|
||
It serves single-use, randomly named download URLs from incoming browser
|
||
streams, with bounded buffering. The default CSP above permits this; custom
|
||
policies must permit same-origin workers and frames. No third-party helper,
|
||
download backend, or additional hosting service is required. Closing/resetting
|
||
an unfinished transfer aborts it; interrupted transfers must restart.
|
||
|
||
## Download and run locally
|
||
|
||
Run `bun run build`, then open `dist/hellcon-local.html` directly in a browser.
|
||
This single HTML file includes the app code, styles, and icon. A hosted production
|
||
build also offers **Download app for local use**. Download that file instead of
|
||
using the browser's **Save Page As** command, which may save only the hosted page
|
||
without its required assets. You can share the downloaded HTML file with the
|
||
other participant; both can open it from disk. No web server is needed to load
|
||
the app itself.
|
||
|
||
The app still needs network access to connect peers on different machines, and
|
||
the selected STUN or TURN servers must be reachable. A `file://` copy cannot use
|
||
the host's managed TURN credential endpoint; enter your own relay details when
|
||
needed. Service-worker downloads are **disabled for `file://` copies**; there is
|
||
no hosted helper dependency in the local version. For large local transfers,
|
||
use desktop Chrome with its native save picker and select **Choose destination
|
||
& receive to disk**. Brave may disable that API even though it is Chromium-based.
|
||
Native disk access still depends on browser settings and platform support.
|
||
The 64 MiB in-memory receive option remains available.
|
||
|
||
To self-host the regular multi-file build, serve the whole `dist/` directory,
|
||
including `assets/`. Serve it over HTTPS for access from other machines.
|
||
|
||
## Development
|
||
|
||
### Local STUN/TURN environment (Linux)
|
||
|
||
Keep Vite on the host for hot reload; only coturn runs in Docker. Both bind to
|
||
loopback, so use two browser tabs on this machine. No DNS, certificates, firewall
|
||
changes or production services are needed. Nothing is enabled at boot, and the
|
||
container has no automatic restart policy.
|
||
|
||
```sh
|
||
# Start Docker only when needed (if it isn't already running).
|
||
sudo systemctl start docker.service
|
||
# If you just joined the docker group, log in again or run: newgrp docker
|
||
bun install --frozen-lockfile
|
||
bun run dev:setup # creates ignored .env.development, without overwriting it
|
||
bun run turn:up
|
||
bun run dev # open the printed localhost URL in two tabs
|
||
```
|
||
|
||
Pick a file in the sender tab, choose Receive in the other, and check **Allow a
|
||
TURN relay** in both tabs. Leave **Use the configured relay with temporary
|
||
credentials** checked. Exchange codes and compare fingerprints as usual. Reset,
|
||
failure or disconnect clears consent, so check it again for each connection.
|
||
STUN defaults to the local server; TURN remains opt-in, with direct routes preferred.
|
||
|
||
```sh
|
||
bun run test # protocol and temporary-credential unit tests
|
||
bun run test:turn # real Chromium file transfer, forced TURN/UDP
|
||
bun run test:turn --tcp # same test, TURN/TCP only
|
||
bun run build
|
||
bun run test:browser # direct-path browser regressions and axe accessibility checks
|
||
docker compose --env-file .env.development logs --tail=50 coturn
|
||
```
|
||
|
||
The TURN checks start and stop their own Vite server and isolated browser profiles;
|
||
coturn must already be running. They obtain real temporary credentials, force
|
||
relay-only routing, assert selected relay candidates on both ends, verify exact
|
||
received bytes and receipts, and exercise cancellation and reconnection. TCP here
|
||
means browser-to-TURN transport; relay-to-peer traffic is UDP. These same-machine
|
||
checks do not test Internet NATs or a remote server's firewall.
|
||
|
||
Stop Vite with Ctrl-C, then:
|
||
|
||
```sh
|
||
bun run turn:down
|
||
# Optional: stop Docker too, after finishing any other containers.
|
||
sudo systemctl stop docker.service docker.socket containerd.service
|
||
```
|
||
|
||
`.env.development` contains the private shared `TURN_SECRET`, server-side
|
||
`TURN_HOST`/`TURN_PORT`, and public `VITE_ICE_ENDPOINT`/`VITE_STUN_URL` settings.
|
||
See [.env.example](.env.example). The secret never enters the client bundle.
|
||
Compose passes it directly to coturn; no config-file environment substitution is
|
||
assumed. If changing the port, update both `TURN_PORT` and `VITE_STUN_URL`, then
|
||
rerun `turn:up` and restart Vite. The image is pinned to a concrete release;
|
||
loopback listeners and UDP relay ports 49160–49200 are defined in [compose.yaml](compose.yaml).
|
||
Loopback peer access is explicitly allowed for these local tests.
|
||
|
||
The credential endpoint is **development-only**, implemented as Vite middleware.
|
||
It isn't included in `dist/` or `vite preview`. Production builds ignore
|
||
`.env.development` and retain the existing static/manual configuration. To reuse
|
||
the client integration later, set `VITE_ICE_ENDPOINT` and `VITE_STUN_URL` when
|
||
building and implement the same JSON endpoint behind your production access
|
||
policy. [dev/ice-server.ts](dev/ice-server.ts) contains the HMAC issuance logic.
|
||
There are no accounts or room sessions in this app to authorize production
|
||
credential issuance automatically. Don't expose this development endpoint or
|
||
reuse the loopback-permitting Compose configuration as a public relay.
|
||
|
||
Credentials expire after one hour; each new code exchange fetches fresh ones.
|
||
Automatic renewal during long transfers is not implemented because this app
|
||
uses manual signaling. Keep development transfers below that duration; expired
|
||
or failed sessions need fresh codes.
|
||
|
||
Configuration references: [coturn Docker usage](https://github.com/coturn/coturn/blob/master/docker/coturn/README.md)
|
||
and [coturn configuration](https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf).
|
||
|
||
### Existing checks and static build
|
||
|
||
Use Bun for dependency installation and Node.js 22.18+ for the scripts and tests.
|
||
All application code, Vue scripts, development middleware, and checks use strict
|
||
TypeScript. `vue-tsc` checks both TypeScript and Vue templates, and runs before
|
||
every production build. TypeScript stays on 5.9 until Vue's checker supports the
|
||
TypeScript 7 compiler.
|
||
|
||
Vite 8 supplies VoidZero's Rolldown bundler and Oxc transforms. The only added
|
||
development dependencies are TypeScript, `vue-tsc`, and Node types. Node runs
|
||
the TypeScript tests directly; no separate test framework or TS loader is needed.
|
||
|
||
```sh
|
||
bun install --frozen-lockfile
|
||
bun run dev
|
||
bun run typecheck
|
||
bun run test
|
||
bun run build
|
||
bun run test:browser # local Chromium integration checks against dist/
|
||
bun run test:download # real hosted downloads, including 120 MiB, with native picker disabled
|
||
bun run test:cross-browser # Brave sender → Firefox receiver
|
||
bun run preview # local build inspection only
|
||
bun audit
|
||
```
|
||
|
||
The lockfile pins dependencies. Review dependency updates and advisories before
|
||
publishing a build. Protocol regression tests cover verification gating, malformed
|
||
messages, size limits, cancellation, receipt acknowledgment, and relay opt-in.
|
||
The browser check requires Chromium at `/usr/bin/chromium` (override with
|
||
`CHROMIUM_PATH`); it uses an isolated temporary profile and a loopback server.
|
||
Run `CHROMIUM_PATH=/usr/bin/brave bun run test:download` for the streaming
|
||
download check in Brave. Worker tests cover byte counts, backpressure, single-use
|
||
URLs, and browser/app cancellation; integration checks verify the actual saved bytes.
|
||
The cross-browser check uses Brave and Firefox at `/usr/bin/brave` and
|
||
`/usr/bin/firefox` (override with `BRAVE_PATH` and `FIREFOX_PATH`). It checks
|
||
that the received file remains downloadable after the sender disconnects.
|
||
Pass `--reverse` to test Firefox → Brave, or `--default-network` to use PageQuit
|
||
STUN instead of the local test's default None. These checks use temporary
|
||
browser profiles and do not modify your normal browser settings.
|
||
|
||
This is experimental software, not independently audited or battle-tested.
|
||
Browser compatibility, network connectivity and storage availability vary.
|
||
|
||
## License
|
||
|
||
MIT — see `LICENSE`.
|
||
|
||
## UX roadmap
|
||
|
||
See [the hosted-first UX roadmap](docs/ux-roadmap.md) for repeat transfers, file
|
||
queues and bidirectional sessions, remembered devices, invitations, and guided setup.
|