diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b9fb78..ecd8931 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,26 @@ # Changelog -## Unreleased +## [0.0.4] - 2026-10-16 + +### Added - Added streaming downloads for the hosted app using a same-origin service - worker, with a 64 GiB cap and bounded buffering. Verified real 120 MiB downloads - in Chromium and Brave without the native file picker. -- Kept `file://` copies independent of hosted helpers; they continue to use the - native save picker or the 64 MiB in-memory option. -- Distinguished handing a file to the browser's download manager from confirming - that it was saved to disk. Added worker tests and a real-download browser check. + worker with bounded buffering. Verified real 120 MiB downloads in Chromium + and Brave without the native file picker. +- Worker tests for byte counts, backpressure, cancellation, and single-use URLs, + plus a browser check that verifies actual downloaded file contents. +- Guidance to use desktop Chrome for large files in the downloaded local version. + +### Changed + +- Removed the app-defined 64 GiB file-size cap for streamed and native disk + transfers. Browser, filesystem, available storage, and exact byte-count limits + still apply. The 64 MiB in-memory safety cap remains in place. +- Download receive buttons now show the incoming file size instead of a size cap. +- Streaming completion reports that bytes were handed to the browser; users + should check Downloads for the final save result. +- Local `file://` copies remain independent of hosted helpers and use the native + save picker or the in-memory option. Service-worker downloads are hosted-only. ## [0.0.3] - 2026-10-09 diff --git a/README.md b/README.md index 76a9615..1a34063 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HellCon -Current version: **0.0.3**. See the [changelog](CHANGELOG.md) for release notes +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 @@ -23,8 +23,7 @@ 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. - 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. + 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. @@ -37,7 +36,9 @@ explicit opt-in by both people; no relay is configured automatically. 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. + 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. 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 diff --git a/package.json b/package.json index b8de4df..d5c4ce0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hellcon", "private": true, - "version": "0.0.3", + "version": "0.0.4", "license": "MIT", "type": "module", "scripts": { diff --git a/public/download/worker.js b/public/download/worker.js index 8f67319..14a6757 100644 --- a/public/download/worker.js +++ b/public/download/worker.js @@ -7,7 +7,7 @@ self.addEventListener('message', event => { const port = event.ports[0]; if (type !== 'download' || !port || !/^[a-f0-9]{32}$/.test(id) || typeof name !== 'string' || name.length > 255 || /[\r\n/\\]/.test(name) || - !Number.isSafeInteger(size) || size < 0 || size > 64 * 1024 ** 3 || + !Number.isSafeInteger(size) || size < 0 || !(stream instanceof ReadableStream) || downloads.has(id)) return; const reader = stream.getReader(); let controller, finished = false, received = 0; diff --git a/scripts/browser-check.ts b/scripts/browser-check.ts index bca6375..691c9fe 100644 --- a/scripts/browser-check.ts +++ b/scripts/browser-check.ts @@ -173,7 +173,7 @@ try { await click(receiver, 'Receive'); await connect(sender, receiver, size); assert.equal(await evaluate(receiver, () => typeof window.showSaveFilePicker), 'undefined'); - await click(receiver, 'Receive as download (up to 64 GiB)'); + await click(receiver, `Receive as download (${size === 0 ? '0 B' : (size / 1024 ** 2).toFixed(1) + ' MiB'})`); await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file')); assert.match(await evaluate(receiver, () => window.__hellcon.element('[role=status]').textContent), /Check Downloads/); const destination = join(downloads, 'browser-test.bin'); diff --git a/src/App.vue b/src/App.vue index 71999a0..6c6afc1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,7 +4,8 @@ import SendPanel from './components/SendPanel.vue'; import ReceivePanel from './components/ReceivePanel.vue'; const mode = ref<'send' | 'receive'>('send'); -const canDownloadApp = import.meta.env.PROD && location.protocol !== 'file:'; +const isLocal = location.protocol === 'file:'; +const canDownloadApp = import.meta.env.PROD && !isLocal; @@ -17,6 +18,8 @@ const canDownloadApp = import.meta.env.PROD && location.protocol !== 'file:';
Download app for local use +For large files in the downloaded local version, use desktop Chrome on the receiving machine and choose “Choose destination & receive to disk”.
+Drop a file here or choose one below. Choosing a new file cancels the current connection.
@@ -300,7 +300,7 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); }){{ incoming.name }} — {{ formatBytes(incoming.size) }}
Only accept files you expect. Encryption does not make their contents safe to open.
- +Allow the browser download and keep this page open until the transfer finishes. Check Downloads for the final save result.
diff --git a/src/lib/transfer.ts b/src/lib/transfer.ts index 189c76c..baa3699 100644 --- a/src/lib/transfer.ts +++ b/src/lib/transfer.ts @@ -32,16 +32,15 @@ export interface TransferOptions { type ControlType = 'ready' | 'meta' | 'accept' | 'ack' | 'end' | 'complete'; export const MEMORY_LIMIT = 64 * 1024 * 1024; -export const FILE_LIMIT = 64 * 1024 * 1024 * 1024; const CONTROL_LIMIT = 2048; const WINDOW = MAX_BUFFERED; export function validateMetadata(meta: unknown): FileMetadata { if (!isRecord(meta) || typeof meta.name !== 'string' || !meta.name.length || meta.name.length > 255 || /[\x00-\x1f\x7f/\\\u202a-\u202e\u2066-\u2069]/.test(meta.name) || - typeof meta.size !== 'number' || !Number.isSafeInteger(meta.size) || meta.size < 0 || meta.size > FILE_LIMIT || + typeof meta.size !== 'number' || !Number.isSafeInteger(meta.size) || meta.size < 0 || typeof meta.mime !== 'string' || meta.mime.length > 128 || /[^\x20-\x7e]/.test(meta.mime)) { - throw new Error('Invalid file metadata or file exceeds the 64 GiB limit.'); + throw new Error('Invalid file metadata. File size must be a nonnegative safe integer.'); } return { name: meta.name, size: meta.size, mime: meta.mime }; } diff --git a/tests/download.test.ts b/tests/download.test.ts index d433eb3..48aaad2 100644 --- a/tests/download.test.ts +++ b/tests/download.test.ts @@ -84,3 +84,12 @@ test('app cancellation errors the browser response and cancels pending source re assert.equal(canceled, true); assert.equal(w.messages.at(-1)?.type, 'error'); }); + +test('download worker accepts sizes above 64 GiB without allocating the file', async () => { + const w = worker(); + const size = 64 * 1024 ** 3 + 1; + w.start(new ReadableStream(), size); + const response = await w.fetch(); + assert.equal(response.headers.get('Content-Length'), String(size)); + await response.body!.cancel(); +}); diff --git a/tests/transfer.test.ts b/tests/transfer.test.ts index 1edda1a..69e0a15 100644 --- a/tests/transfer.test.ts +++ b/tests/transfer.test.ts @@ -1,7 +1,7 @@ import test, { type TestContext } from 'node:test'; import type { TransferChannel, TransferOptions, TransferResult } from '../src/lib/transfer.ts'; import assert from 'node:assert/strict'; -import { Transfer, MEMORY_LIMIT, FILE_LIMIT, validateMetadata } from '../src/lib/transfer.ts'; +import { Transfer, MEMORY_LIMIT, validateMetadata } from '../src/lib/transfer.ts'; import { CHUNK_SIZE, MAX_BUFFERED } from '../src/lib/webrtc.ts'; class Channel extends EventTarget implements TransferChannel { @@ -167,7 +167,7 @@ test('memory limit requires an explicit disk destination for larger files', asyn }); test('metadata rejects invalid sizes, misleading names and invalid types', () => { - for (const size of [-1, 0.5, '10', NaN, Infinity, FILE_LIMIT + 1]) assert.throws(() => validateMetadata({ ...meta(), size })); + for (const size of [-1, 0.5, '10', NaN, Infinity, Number.MAX_SAFE_INTEGER + 1]) assert.throws(() => validateMetadata({ ...meta(), size })); for (const name of ['', '../secret', 'a\\b', 'bad\u202efile.exe', 'a'.repeat(256)]) assert.throws(() => validateMetadata({ ...meta(), name })); assert.throws(() => validateMetadata({ ...meta(), mime: {} })); }); @@ -225,3 +225,9 @@ test('forged completion or invalid byte acknowledgments cannot report success', message(second.sender, 'ack', { bytes: 1 }); await second.sender.queue; assert.equal(second.sender.state, 'closed'); }); + +test('metadata accepts files above 64 GiB while preserving exact byte counts', () => { + for (const size of [64 * 1024 ** 3 + 1, 1024 ** 4, Number.MAX_SAFE_INTEGER]) { + assert.equal(validateMetadata({ ...meta(), size }).size, size); + } +});