Add hosted service-worker streaming downloads
This commit is contained in:
1 parent
a53022d717
commit
7856725c72
8 files changed
+344
-17
No files matched your search
@@ -23,14 +23,21 @@ explicit opt-in by both people; no relay is configured automatically.
|
||||
Compare every byte. Cancel on any mismatch. Both people must explicitly
|
||||
confirm before the app sends the filename, size, MIME metadata, or contents.
|
||||
4. The receiver sees the filename and size and explicitly accepts the file.
|
||||
Supported browsers can stream directly to a chosen disk destination, up to
|
||||
64 GiB. Other browsers can receive files up to 64 MiB in memory and then offer
|
||||
a download. Larger files require direct-to-disk support. Even capped memory
|
||||
downloads may be too large on a memory-constrained device.
|
||||
On the hosted app (HTTPS or localhost), **Receive as download** streams up to
|
||||
64 GiB 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 memory
|
||||
transfers, after constructing the complete download. This does not prove a
|
||||
human saved the memory download, nor that a malicious receiver told the truth.
|
||||
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. The 64 GiB cap is not a tested size guarantee.
|
||||
|
||||
Cancel, reset, changing the selected file, or switching Send/Receive closes the
|
||||
connection and aborts unfinished disk writes. Keep the tab open until receipt is
|
||||
@@ -146,6 +153,15 @@ 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.
|
||||
@@ -159,8 +175,12 @@ 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. Direct-to-disk receiving depends on browser support and may be unavailable
|
||||
from a local file. The in-memory receive option remains available.
|
||||
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.
|
||||
@@ -260,6 +280,7 @@ 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
|
||||
@@ -270,6 +291,9 @@ publishing a build. Protocol regression tests cover verification gating, malform
|
||||
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.
|
||||
|
||||
Reference in new issue
Block a user