diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd8931..ea80b92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## Unreleased + +- Keep verified sessions open for “Send another file”, with separate acceptance + and storage for each file. +- Preserve the previous memory download until the next file is accepted. +- Add bounded queues (32 files per side), sending in both directions, per-file + progress and results, queue removal, and incoming-file decline. +- Add explicit Disconnect; setup roles stay locked while connected. Disconnect + aborts unfinished writes while preserving the last completed memory download. +- Upgrade connection/session framing to v3 with per-file identifiers. Both peers + must update; v2 codes are rejected before connection setup. +- Document the hosted-first, serverless UX roadmap. + ## [0.0.4] - 2026-10-16 ### Added diff --git a/README.md b/README.md index 1a34063..af75259 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ explicit opt-in by both people; no relay is configured automatically. ## How it works -1. The sender picks one file and configures STUN (PageQuit by default, Google, +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. @@ -40,22 +40,34 @@ explicit opt-in by both people; no relay is configured automatically. 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 -confirmed. A completed memory download is discarded when you reset or switch. -Switching browser tabs or apps to copy/paste does not explicitly cancel the -session, although a browser or mobile OS can suspend a background page. +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. Send/Receive chooses who starts the connection and is locked during the +session. Both people can send using the session's file picker. + +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. The two peers must use this protocol version (v2); -legacy connection codes are rejected. +expire after one minute. Idle verified sessions stay open. Lost connections need +fresh codes. Both peers must use protocol **v3**; older 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; switching Send/Receive inside one page cancels -that page's previous connection. Use the specific error shown in red to diagnose +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 @@ -115,7 +127,7 @@ 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, completing or failing a connection clears TURN consent; +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. @@ -136,8 +148,9 @@ 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, an exact declared byte count, and a single file. It rejects unexpected -states, excess data and duplicate metadata. An acknowledged 1 MiB send window +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 @@ -208,7 +221,7 @@ 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 completion clears consent, so check it again for each connection. +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 @@ -308,3 +321,8 @@ 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. diff --git a/docs/ux-roadmap.md b/docs/ux-roadmap.md new file mode 100644 index 0000000..a252045 --- /dev/null +++ b/docs/ux-roadmap.md @@ -0,0 +1,101 @@ +# Serverless UX roadmap + +The hosted HTTPS app is the primary experience. The downloadable HTML must keep +working for basic manual connection and file transfer; it need not match hosted +conveniences. No signaling backend, peer presence service, automatic offline-peer +reconnection, or silent TURN fallback is in scope. + +## 1. Send another file on a verified connection — implemented first + +Keep the reliable data channel open after a successful receipt. The sender can +choose or drop another file without exchanging codes or confirming fingerprints +again. Require explicit receiver acceptance for each file. Reset counters, +metadata, and storage per file while retaining connection verification. Preserve +a completed memory download until the receiver accepts its replacement or resets. +Keep network settings fixed for the session; relay consent applies to that +connection until disconnect. Reset, disconnect, errors, and tab closure end +the session. Idle completed sessions remain open while both tabs remain available; +a lost connection requires fresh codes. + +The first implementation negotiated repeat support within v2. Phase 2 supersedes +that compatibility path with protocol v3; both peers now need the current build. + +## 2. Multiple files and transfers in either direction — implemented + +Session ownership is independent of the initial Send/Receive setup choice. Setup +tabs stay locked while a session exists. Both people can select or drop multiple +files and add more while transferring. Each local queue is capped at 32 including +its active outgoing file; a rolling list retains the last 50 results. + +The arbitration decision is one sequential queue per direction, permitting two +active files total. Simultaneous offers therefore never compete for one global +slot. Monotonic odd/even IDs identify files by originating peer; control frames +and binary chunks carry these IDs. Each file uses the existing bounded window, +receive queue, receipt validation, and storage limits. The receiver accepts or +declines every file separately. Only one incoming memory file is retained. + +Remove affects only a waiting local item. Decline rejects an incoming offer before +acceptance and advances the peer's queue. Disconnect cancels the whole session, +clears queues, and aborts unfinished writes in either direction. Cancellation of +an individual active file is intentionally not provided. Completed memory downloads +survive disconnect until Reset or the next acceptance. + +Protocol v3 rejects old connection codes before setup. Tests cover simultaneous +queues, empty files, separate acceptance, removal, decline, stale IDs/receipts, +queue caps, storage cancellation, and verification gates. Browser checks exercise +both directions, real bytes, accessibility, streaming downloads, and the local HTML. + +## 3. Remember trusted devices + +Add opt-in local device identity and a contact list on the hosted app, backed by +browser storage. After authenticated first pairing, offer “Remember this device” +and a local nickname. Store public identities for contacts and protect the local +private identity using available browser cryptographic storage; this does not +protect against compromised app JavaScript. Temporary sessions remain available. + +Specify and review mutual proof of identity bound to fresh session information, +both DTLS fingerprints, participant roles, and replay protection before building +automatic verification. Never infer trust from a nickname or saved connection +code. Changed identities require explicit re-verification. Continue requiring +file acceptance. Add contact removal, identity reset, storage-unavailable behavior, +and password-encrypted identity export/import with a reviewed backup format. + +Test impersonation, replay, identity changes, wrong backup passwords, storage +loss, and mixed-version peers. Local HTML may remain temporary/manual; do not +block delivery on persistent identity support for file URLs. + +## 4. Shareable invitations + +For HTTPS, encode fresh offers in URL fragments with an explicit Share/Copy link +action and an import preview. Keep connection details out of query strings and +server paths. Fragments still expose their contents to link recipients and any +service carrying the full link; explain that invitations are private. Clear the +fragment after import. Provide a similarly convenient answer handoff; an answer +exchange remains necessary. Keep pasteable codes as the universal fallback. + +Bound and validate payloads, handle stale/incompatible links, and test practical +URL limits across messengers and mobile browsers. Do not promise a short link +without a storage service. Consider compressed payloads and QR only after checking +real payload sizes and decoding limits. Local HTML only needs manual codes. + +## 5. Guided connection flow + +Present one primary next action across Choose files → Share invitation → 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, +and disconnected. Provide recovery actions tailored to the actual failure. + +Prefer the hosted streaming-download path when supported, retain native disk and +bounded memory fallbacks, and explain browser download completion accurately. +Use accessible focus management, keyboard controls, live status announcements, +and mobile layouts. Validate both first-time and remembered-peer paths, denied +permissions, clipboard/share fallback, browser suspension, and reconnect guidance. + +## Delivery order and gates + +Deliver in the order above, with a build and relevant protocol/browser checks per +phase. Small contextual UI improvements can accompany each phase. Treat identity +authentication and bidirectional framing as explicit design/review milestones. +No new persistent data or backend is needed for phase 1. Deployments are separate +from implementation; this document is the plan for the remaining phases. diff --git a/scripts/browser-check.ts b/scripts/browser-check.ts index 691c9fe..e74f04b 100644 --- a/scripts/browser-check.ts +++ b/scripts/browser-check.ts @@ -167,11 +167,14 @@ try { const downloads = join(profile, 'downloads'); await mkdir(downloads); await call('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: downloads }); - const sender = await page(); + const sender = await page(), receiver = await page(); + await click(receiver, 'Receive'); for (const size of [0, 1024 * 1024 + 7, 120 * 1024 * 1024]) { - const receiver = await page(); - await click(receiver, 'Receive'); - await connect(sender, receiver, size); + if (size === 0) await connect(sender, receiver, size); + else { + await evaluate(sender, (size: number) => window.__hellcon.chooseFile(size, 'browser-test.bin'), size); + await wait(receiver, () => !!document.querySelector('.incoming')); + } assert.equal(await evaluate(receiver, () => typeof window.showSaveFilePicker), 'undefined'); 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')); @@ -190,7 +193,6 @@ try { } assert.equal(bytes, size); await rm(destination); - await click(sender, 'Reset'); console.log(`PASS: hosted app streams ${size} bytes to a real browser download without the native save picker; exact file bytes verified.`); } assert.deepEqual(browserErrors, []); @@ -246,6 +248,53 @@ try { assert.doesNotMatch(diagnostics, /browser-test\.bin|a=candidate:|a=ice-pwd:|a=fingerprint:|\.local\b/); console.log('PASS: real two-page WebRTC flow; full fingerprints; no metadata before both confirmations; exact file and receipt.'); console.log('PASS: invalid offers can be replaced; invalid answers can be corrected without losing the live offer.'); + const originalFingerprints = await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent)); + for (const size of [0, 4097]) { + const previousDownload = await evaluate(receiver, () => window.__hellcon.element('a.download').href); + await evaluate(sender, (size: number) => window.__hellcon.chooseFile(size, 'another.bin'), size); + await wait(receiver, () => !!document.querySelector('.incoming')); + assert.equal(await evaluate(receiver, () => window.__hellcon.element('a.download').href), previousDownload); + assert.equal(await evaluate(sender, () => window.__hellcon.element('[role=status]').textContent), 'Waiting for the receiver to accept the file…'); + assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent)), originalFingerprints); + await click(receiver, 'Receive in memory (up to 64 MiB)'); + await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file')); + const next = await evaluate(receiver, async () => { + const link = window.__hellcon.element('a.download'); + const bytes = new Uint8Array(await (await fetch(link.href)).arrayBuffer()); + return { name: link.download, length: bytes.length, valid: bytes.every(byte => byte === 123) }; + }); + assert.deepEqual(next, { name: 'another.bin', length: size, valid: true }); + } + console.log('PASS: consecutive files including an empty file reuse fingerprints, require acceptance, and preserve the previous download until acceptance.'); + // Queue two files and send back simultaneously, on the same peer connection. + await evaluate(sender, () => { + const input = window.__hellcon.element('#file-input'); + const files = new DataTransfer(); + for (const name of ['decline-me.bin', 'queued.bin', 'remove-me.bin']) files.items.add(new File([new Uint8Array(1024).fill(123)], name)); + input.files = files.files; input.dispatchEvent(new Event('change', { bubbles: true })); + }); + await evaluate(sender, () => window.__hellcon.element('button[aria-label="Remove remove-me.bin"]').click()); + await evaluate(receiver, () => window.__hellcon.chooseFile(8193, 'return.bin')); + await wait(sender, () => !!document.querySelector('.incoming')); + await wait(receiver, () => !!document.querySelector('.incoming')); + await click(receiver, 'Decline file'); + await wait(receiver, () => document.querySelector('.incoming')?.textContent?.includes('queued.bin')); + await click(sender, 'Receive in memory (up to 64 MiB)'); + await click(receiver, 'Receive in memory (up to 64 MiB)'); + await wait(sender, () => document.querySelector('a.download')?.download === 'return.bin'); + await wait(receiver, () => document.querySelector('a.download')?.download === 'queued.bin'); + for (const [session, size] of [[sender, 8193], [receiver, 1024]] as const) { + const received = await evaluate(session, async () => { + const bytes = new Uint8Array(await (await fetch(window.__hellcon.element('a.download').href)).arrayBuffer()); + return { length: bytes.length, valid: bytes.every(byte => byte === 123) }; + }); + assert.deepEqual(received, { length: size, valid: true }); + await checkAccessibility(session, 'Bidirectional session'); + } + assert.equal(await evaluate(sender, () => [...document.querySelectorAll('.tabs button')].every(button => (button as HTMLButtonElement).disabled)), true); + assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent)), originalFingerprints); + console.log('PASS: simultaneous bidirectional transfers, multiple-file queue, removal, decline, exact bytes, and locked setup tabs.'); + await click(sender, 'Reset'); await click(receiver, 'Reset'); assert.equal(await evaluate(sender, () => window.__hellcon.element('[role=status]').textContent), 'Choose a file to start.'); assert.equal(await evaluate(receiver, () => window.__hellcon.element('[role=status]').textContent), 'Paste the sender’s connection code to start.'); @@ -254,14 +303,17 @@ try { await connect(sender, receiver, 2 * 1024 * 1024); await click(receiver, 'Choose destination & receive to disk'); await wait(receiver, () => !!window.__hellcon.releaseWrite); - await click(sender, 'Receive'); + await evaluate(sender, () => window.__hellcon.chooseFile(1024, 'pending-at-disconnect.bin')); + assert.equal(await evaluate(sender, () => !!document.querySelector('ul[aria-label="Files waiting to send"]')), true); + await click(sender, 'Disconnect'); + assert.equal(await evaluate(sender, () => !!document.querySelector('ul[aria-label="Files waiting to send"]')), false); await wait(receiver, () => window.__hellcon.aborted); assert.equal(await evaluate(receiver, () => !!document.querySelector('a.download')), false); await wait(receiver, () => window.__hellcon.element('#connection-diagnostics').value.includes('pairs=')); assert.match(await evaluate(receiver, () => window.__hellcon.element('#connection-diagnostics').value), /session failed/); console.log('PASS: privacy-safe candidate/check diagnostics remain available after completion and failure.'); - console.log('PASS: switching away from Send closes the connection and aborts the receiver’s pending disk write.'); - await click(sender, 'Send'); await click(receiver, 'Reset'); + console.log('PASS: Disconnect closes the connection and aborts the receiver’s pending disk write.'); + await click(sender, 'Reset'); await click(receiver, 'Reset'); await connect(sender, receiver, 2048); await click(receiver, 'Receive in memory (up to 64 MiB)'); await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file')); diff --git a/scripts/cross-browser-driver.ts b/scripts/cross-browser-driver.ts index bd7fbcd..8ffb983 100644 --- a/scripts/cross-browser-driver.ts +++ b/scripts/cross-browser-driver.ts @@ -53,6 +53,7 @@ try { if(bytes.length!==2*1024*1024+7||!bytes.every(b=>b===123))throw new Error('File content mismatch'); }else{ await stage('waiting for receipt');await wait(()=>element('[role=status]').textContent?.includes('confirmed the complete file')); + click('Disconnect'); } await post(role+'Result',{ok:true}); }catch(error){ diff --git a/src/App.vue b/src/App.vue index 6c6afc1..24746ab 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,9 +1,9 @@ @@ -21,12 +21,11 @@ const canDownloadApp = import.meta.env.PROD && !isLocal;

For large files in the downloaded local version, use desktop Chrome on the receiving machine and choose “Choose destination & receive to disk”.

- - + +
- - +