From a5935a8324f4086eb86f2fe4d5c98892e32603e2 Mon Sep 17 00:00:00 2001 From: Schluffe Date: Tue, 20 Oct 2026 19:47:07 +0200 Subject: [PATCH] Remove shareable invitation links Codes are exchanged by copy and paste again. The URL fragment intake, the invitation dialog, the BroadcastChannel answer relay and the Share link / Copy link controls are gone, along with their tests, browser check scenarios and design doc. Code fields no longer accept links. The compressed HC1 codes with typed offers/answers and echoed refs stay. An optional signaling backend is the intended way to simplify the exchange instead. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 11 +-- README.md | 29 ++---- docs/invitations.md | 128 ------------------------- docs/ux-roadmap.md | 20 ++-- scripts/browser-check.ts | 99 +------------------ src/App.vue | 33 +------ src/components/ConnectionWorkspace.vue | 15 +-- src/components/InvitationDialog.vue | 110 --------------------- src/components/TransferPanel.vue | 85 +++++----------- src/lib/codes.ts | 20 +--- src/lib/invitations.ts | 43 --------- src/lib/webrtc.ts | 6 +- src/main.ts | 4 +- src/style.css | 8 +- tests/codes.test.ts | 9 +- tests/invitations.test.ts | 39 -------- 16 files changed, 57 insertions(+), 602 deletions(-) delete mode 100644 docs/invitations.md delete mode 100644 src/components/InvitationDialog.vue delete mode 100644 src/lib/invitations.ts delete mode 100644 tests/invitations.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 6199f06..59ce178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,13 +21,6 @@ - **Disconnect**, which aborts unfinished writes, and Send/Receive navigation within a live session. The initial receiver can send files without reconnecting. -- Shareable invitation links. Codes travel in the URL fragment, which is never - sent to the host and is removed from the address bar on opening. An offer - link opens a preview that suggests an idle connection (the one paired with - the sender's device first) and fills in the code without answering. An answer - link opened in the same browser connects the waiting sender tab; elsewhere it - shows the answer to copy. **Share link** uses the Web Share API where - available; **Copy link** and the bare code always remain. - The hosted-first, serverless [UX roadmap](docs/ux-roadmap.md). ### Changed @@ -38,8 +31,8 @@ Base64url of deflated JSON). Each code states whether it is an offer or an answer and carries a reference shared by both, so a pasted offer in the answer field, or an answer to a different code, is rejected with a clear - message while the live offer stays valid. Codes may be pasted as part of a - link. Codes from earlier 0.0.5 drafts are rejected. + message while the live offer stays valid. Codes from earlier 0.0.5 drafts are + rejected. - Replace the receive-storage choice with a single **Accept file** button that treats every file size the same: stream to Downloads where supported, else use the native save picker, else buffer up to 64 MiB in memory and hand it diff --git a/README.md b/README.md index 32af641..6973102 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Current version: **0.0.5** (draft). See the [changelog](CHANGELOG.md) for releas notes and compatibility changes. Browser-to-browser file sharing with Vue 3 and WebRTC. There are no accounts, no -signaling backend, and no server-side file storage: you exchange invitation links -or connection codes yourself, through any messenger. Connections are direct by +signaling backend, and no server-side file storage: you exchange connection codes +yourself, through any messenger. Connections are direct by default. A TURN relay is used only when both people opt in. This is experimental software, not independently audited or battle-tested. @@ -40,16 +40,12 @@ so and temporary sessions still work. 1. **Create a code.** The person starting picks one or more files, chooses a STUN provider (PageQuit by default, Google, Cloudflare, custom, or None), and - clicks **Create code**. They send the link privately to the receiver through - an authenticated channel, with **Share link** where supported or **Copy - link**. The bare code is under **Show code instead**. -2. **Answer it.** The receiver opens the link or pastes the link or code. An - opened link shows a preview and lets them pick which connection receives it; - nothing is sent until they click **Accept & create answer**. They send the - answer link back. Opened in the browser that holds the sender's tab, it - connects that tab directly; elsewhere it shows the answer for the sender to - paste. Gathering waits up to 30 seconds and fails rather than exporting - incomplete connection information. + clicks **Create code**. They send the code privately to the receiver through + an authenticated channel. +2. **Answer it.** The receiver pastes the code and clicks **Accept & create + answer**, then sends the answer back for the sender to paste. Gathering waits + up to 30 seconds and fails rather than exporting incomplete connection + information. 3. **Compare fingerprints.** Both people compare **both full SHA-256 certificate fingerprints** over a channel they trust for authenticity, such as in person. Your fingerprint must equal their “Their fingerprint”, and vice versa. Compare @@ -141,7 +137,7 @@ malicious host. See [the identity protocol and storage](docs/device-identities.m ## Privacy and security -### Codes and links +### Connection codes Connection codes are **compressed and Base64url-encoded, not encrypted** (`HC1.` followed by deflated JSON). They contain SDP: candidate addresses, temporary ICE @@ -150,13 +146,6 @@ messaging service, may learn these details. Treat codes as private and do not publish them. The browser may obscure local addresses, but this app does not provide anonymity. -Invitation links carry the code after `#`. Browsers do not send this fragment to -the host, and the app removes it from the address bar on opening. Otherwise a -link is as sensitive as its code; browser history, including synced history, may -keep it. Opening an offer link never answers automatically. Answer links reach -the waiting tab over a same-origin `BroadcastChannel`. See [the invitation -design](docs/invitations.md). - File transfers use protocol **v3**; codes from older builds are rejected before connecting. diff --git a/docs/invitations.md b/docs/invitations.md deleted file mode 100644 index bd5d748..0000000 --- a/docs/invitations.md +++ /dev/null @@ -1,128 +0,0 @@ -# Shareable invitations - -Phase 4 of the [UX roadmap](ux-roadmap.md). 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`: `offer` or `answer`. 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. - -1. 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`, `ref` mismatch, old-format detection. -2. Switch signaling to the parsed structure; keep existing webrtc/session tests - green and add `ref` validation in `useAnswer`. -3. Fragment intake, import dialog and slot selection through `App` → - `ConnectionWorkspace` → `TransferPanel`. -4. Answer relay and fallback; Share/Copy link UI. -5. 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. -6. Manually verify on phones with at least two messengers: link length intact, - preview fetches without the fragment, in-app browser behaviour, Web Share. -7. Update README, CHANGELOG and the roadmap. - -The shorter encoding also reduces the payload the planned -[tracker reconnect](webtorrent-reconnect.md) carries. diff --git a/docs/ux-roadmap.md b/docs/ux-roadmap.md index 6ed9b43..c5b9cbf 100644 --- a/docs/ux-roadmap.md +++ b/docs/ux-roadmap.md @@ -86,23 +86,17 @@ storage denial/recovery, and protocol-version validation. Design and review note are in [the device identity protocol](device-identities.md); this is not an independent cryptographic audit. -## 4. Shareable invitations — implemented +## 4. Compressed connection codes — implemented -Detailed in [the invitation design](invitations.md). - -Offers and answers are shared as links with the compressed code in the URL -fragment, through **Share link** where supported or **Copy link**; the bare code -stays available. Opening a link clears the fragment. An offer opens an import -preview with slot selection and never answers automatically. An answer link -reaches the waiting sender tab in the same browser over `BroadcastChannel` and -otherwise falls back to copy and paste. An answer exchange remains necessary. - -Still open: manual checks of link length, previews and in-app browsers across -real messengers and phones. QR codes remain deferred. +Offers and answers are compressed `HC1.` codes that state their type and share a +reference, so mixed-up or stale codes are rejected with a specific message. +Shareable invitation links were built on top and removed again: they did not make +real-world connections more reliable. An optional signaling backend is the +intended way to simplify the exchange. ## 5. Guided connection flow -Present one primary next action across Choose files → Share invitation → Connect +Present one primary next action across Choose files → Share code → 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, diff --git a/scripts/browser-check.ts b/scripts/browser-check.ts index 0bb3a73..8bcaa2a 100644 --- a/scripts/browser-check.ts +++ b/scripts/browser-check.ts @@ -49,7 +49,6 @@ interface ProtocolResults { 'Browser.setDownloadBehavior': object; 'Target.createTarget': { targetId: string }; 'Target.attachToTarget': { sessionId: string }; - 'Target.closeTarget': object; 'Runtime.enable': object; 'Page.enable': object; 'Page.navigate': object; @@ -100,11 +99,9 @@ async function wait(session: string, check: () => unknown) { const result = await call('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }, session); if (result.exceptionDetails) throw new Error(JSON.stringify(result.exceptionDetails)); } -const targets = new Map(); async function page(url = origin) { const { targetId } = await call('Target.createTarget', { url: 'about:blank' }); const { sessionId } = await call('Target.attachToTarget', { targetId, flatten: true }); - targets.set(sessionId, targetId); await call('Runtime.enable', {}, sessionId); await call('Page.enable', {}, sessionId); // Background tabs otherwise skip focus/blur events, which the name editor relies on. @@ -117,8 +114,7 @@ async function page(url = origin) { if (turn) await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${forceRelay.toString()})(${JSON.stringify(transport)})` }, sessionId); await call('Page.navigate', { url }, sessionId); for (let n = 0; n < 100; n++) { - // The app removes invitation fragments from the address bar. - try { if (await evaluate(sessionId, (expected: string) => location.href.startsWith(expected) && document.readyState === 'complete', url.split('#')[0]!)) break; } + try { if (await evaluate(sessionId, (expected: string) => location.href.startsWith(expected) && document.readyState === 'complete', url)) break; } catch (err) { if (!(err instanceof Error) || !err.message.includes('context')) throw err; } await new Promise(resolve => setTimeout(resolve, 20)); } @@ -143,7 +139,6 @@ const screenshot = async (session: string, name: string) => { const { data } = await call('Page.captureScreenshot', { format: 'png', captureBeyondViewport: false }, session); await writeFile(join(screenshotDirectory, name + '.png'), Buffer.from(data, 'base64')); }; -const closePage = (session: string) => call('Target.closeTarget', { targetId: targets.get(session) }); const dialogText = (session: string) => evaluate(session, () => document.querySelector('dialog[open]')?.textContent ?? ''); const click = (session: string, label: string) => evaluate(session, (label: string) => window.__hellcon.click(label), label); const input = (session: string, selector: string, value: string) => evaluate(session, (selector: string, value: string) => window.__hellcon.input(selector, value), selector, value); @@ -151,30 +146,12 @@ const enableTurn = (session: string) => evaluate(session, () => { const checkbox = window.__hellcon.element('.checkbox input'); if (!checkbox.checked) checkbox.click(); }); -let checkedCodeLayout = false; async function connect(sender: string, receiver: string, size: number, changedIdentity = false) { await evaluate(sender, (size: number) => window.__hellcon.chooseFile(size, 'browser-test.bin'), size); await input(sender, '#stun-provider', provider); await input(receiver, '#stun-provider', provider); if (turn) { await enableTurn(sender); await enableTurn(receiver); } await click(sender, 'Create code'); await wait(sender, () => !!document.querySelector('#output-code')); - if (!checkedCodeLayout) { - const layout = await evaluate(sender, () => { - const details = window.__hellcon.element('.code-details'); - const closedByDefault = !details.open; - details.open = true; - const code = window.__hellcon.element('#output-code').getBoundingClientRect(); - const copy = window.__hellcon.element('.code-entry button').getBoundingClientRect(); - const answer = window.__hellcon.element('#answer-input').getBoundingClientRect(); - const connect = window.__hellcon.element('#answer-input + button').getBoundingClientRect(); - details.open = false; - return { closedByDefault, codeGap: copy.top - code.bottom, answerGap: connect.top - answer.bottom, codeWidth: code.width, answerWidth: answer.width }; - }); - assert.equal(layout.closedByDefault, true, 'Code alternative starts collapsed'); - assert.ok(Math.abs(layout.codeGap - layout.answerGap) < 1, 'Code and answer buttons have matching spacing'); - assert.ok(Math.abs(layout.codeWidth - layout.answerWidth) < 1, 'Code and answer fields have matching width'); - checkedCodeLayout = true; - } const offer = await evaluate(sender, () => window.__hellcon.element('#output-code').value); assert.ok(offer.startsWith(CODE_PREFIX)); await input(receiver, '#offer-input', 'invalid-code!'); @@ -564,62 +541,6 @@ try { await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file')); console.log('PASS: fresh code exchange after a failed transfer succeeds without reloading either page.'); if (!turn) { - // Invitation links: the offer opens a dialog in a fresh page, the answer link - // reaches the sender's tab, and other origins fall back to copy and paste. - const inviter = await page(); - await evaluate(inviter, () => window.__hellcon.chooseFile(3000, 'invited.bin')); - await input(inviter, '#stun-provider', provider); - await click(inviter, 'Create code'); await wait(inviter, () => !!document.querySelector('#output-link')); - const offerLink = await evaluate(inviter, () => window.__hellcon.element('#output-link').value); - const offerCode = await evaluate(inviter, () => window.__hellcon.element('#output-code').value); - assert.equal(offerLink, `${origin}/#${offerCode}`); - const invited = await page(offerLink); - await wait(invited, () => document.querySelector('dialog[open]')?.textContent?.includes('Invitation to receive files')); - assert.equal(await evaluate(invited, () => location.href), `${origin}/`); - assert.match(await dialogText(invited), /temporary identity/); - await checkAccessibility(invited, 'Invitation dialog'); - if (screenshotDirectory) await evaluate(inviter, () => window.__hellcon.element('#output-link').scrollIntoView({ block: 'center' })); - await screenshot(inviter, 'invitation-share'); - await screenshot(invited, 'invitation-offer'); - await call('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 1, mobile: false }, invited); - assert.equal(await evaluate(invited, () => document.documentElement.scrollWidth <= innerWidth), true, 'Invitation dialog must not overflow horizontally'); - await screenshot(invited, 'invitation-offer-mobile'); - await click(invited, 'Open'); await wait(invited, () => !document.querySelector('dialog[open]')); - await wait(invited, () => document.activeElement?.textContent === 'Accept & create answer'); - assert.equal(await evaluate(invited, () => window.__hellcon.element('#offer-input').value), offerCode); - assert.equal(await evaluate(invited, () => window.__hellcon.element('.tabs button[aria-pressed=true]').textContent), 'Receive'); - await input(invited, '#stun-provider', provider); - await click(invited, 'Accept & create answer'); await wait(invited, () => !!document.querySelector('#output-link')); - const answerLink = await evaluate(invited, () => window.__hellcon.element('#output-link').value); - const answerCode = await evaluate(invited, () => window.__hellcon.element('#output-code').value); - const elsewhere = await page(answerLink.replace('127.0.0.1', 'localhost')); - await wait(elsewhere, () => document.querySelector('dialog[open]')?.textContent?.includes('Paste this answer in the sender’s tab')); - assert.equal(await evaluate(elsewhere, () => window.__hellcon.element('#invitation-answer').value), answerCode); - await checkAccessibility(elsewhere, 'Answer fallback dialog'); - await screenshot(elsewhere, 'invitation-answer-fallback'); - assert.equal(await evaluate(inviter, () => !!document.querySelector('.fingerprint')), false); - const relay = await page(answerLink); - await wait(relay, () => document.querySelector('dialog[open]')?.textContent?.includes('Answer delivered')); - await wait(inviter, () => !!document.querySelector('.fingerprint')); - await evaluate(relay, (link: string) => { location.hash = link.split('#')[1]!; }, answerLink); - await wait(relay, () => document.querySelector('dialog[open]')?.textContent?.includes('Answer already used')); - assert.equal(await evaluate(relay, () => location.hash), ''); - await click(relay, 'Close'); - await evaluate(relay, () => { location.hash = 'HC1.not-a-code'; }); - await wait(relay, () => document.querySelector('dialog[open]')?.textContent?.includes('Link could not be opened')); - await click(inviter, 'Both fingerprints match — confirm'); await click(invited, 'Both fingerprints match — confirm'); - await wait(invited, () => !!document.querySelector('.incoming')); - await click(invited, 'Accept file'); - await wait(inviter, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file')); - const invitedBytes = await evaluate(invited, 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(invitedBytes, { name: 'invited.bin', length: 3000, valid: true }); - for (const session of [inviter, invited, elsewhere, relay]) await closePage(session); - console.log('PASS: offer links open a reviewed import with a clean URL; answer links connect the waiting tab once, fall back to copy and paste elsewhere, and transfer exact bytes.'); - const identitySender = await page(); const receiverOrigin = origin.replace('127.0.0.1', 'localhost'); const identityReceiver = await page(receiverOrigin); @@ -665,24 +586,6 @@ try { await click(identitySender, 'Create code'); await wait(identitySender, () => !!document.querySelector('#output-code')); const offer = await evaluate(identitySender, () => window.__hellcon.element('#output-code').value); assert.ok((await decodeCode(offer)).identity); - // Another receiver tab whose current slot is a new one: the invitation still - // suggests the slot paired with the sender's device, and Open hands it there. - const invitedPaired = await page(receiverOrigin); - await click(invitedPaired, 'Add connection'); - await wait(invitedPaired, () => document.querySelector('.main-pane h1')?.textContent === 'Con 2'); - await evaluate(invitedPaired, (code: string) => { location.hash = code; }, offer); - await wait(invitedPaired, () => document.querySelector('dialog[open]')?.textContent?.includes('Invitation to receive files')); - assert.match(await dialogText(invitedPaired), /matches the paired device of Con 1/); - assert.equal(await evaluate(invitedPaired, () => window.__hellcon.element('#invitation-target').selectedOptions[0]?.textContent?.trim()), 'Con 1 · paired device'); - await click(invitedPaired, 'Open'); await wait(invitedPaired, () => !document.querySelector('dialog[open]')); - assert.equal(await evaluate(invitedPaired, () => document.querySelector('.main-pane h1')?.textContent), 'Con 1'); - assert.equal(await evaluate(invitedPaired, () => window.__hellcon.element('#offer-input').value), offer); - await evaluate(invitedPaired, () => [...document.querySelectorAll('.connection-name')].find(item => item.textContent === 'Con 2')?.click()); - await wait(invitedPaired, () => document.querySelector('.main-pane h1')?.textContent === 'Con 2'); - await click(invitedPaired, 'Remove Con 2'); await click(invitedPaired, 'Remove connection'); - await wait(invitedPaired, () => document.querySelectorAll('.connection-link').length === 1); - await closePage(invitedPaired); - console.log('PASS: an invitation from a paired device suggests its slot over the current one and hands the code to it.'); await input(identityReceiver, '#offer-input', offer); await click(identityReceiver, 'Accept & create answer'); await wait(identityReceiver, () => !!document.querySelector('#output-code')); const answer = await evaluate(identityReceiver, () => window.__hellcon.element('#output-code').value); diff --git a/src/App.vue b/src/App.vue index 2747251..14faf8a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,14 +2,9 @@ import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'; import ConnectionWorkspace from './components/ConnectionWorkspace.vue'; import AppDialog from './components/AppDialog.vue'; -import InvitationDialog from './components/InvitationDialog.vue'; import { addConnection, CONNECTION_LIMIT, emptyConnection, loadConnections, removeConnection, saveConnection, updateConnection, type ConnectionUpdate, type SavedConnection } from './lib/connections.ts'; -import { takeFragment } from './lib/invitations.ts'; import { asError } from './lib/validation.ts'; -// A code from the link this page was opened with, already removed from the URL. -const props = defineProps<{ initialCode?: string }>(); - const logoUrl = `${import.meta.env.BASE_URL}HellNet_alt.png`; const giteaIconUrl = `${import.meta.env.BASE_URL}gitea.svg`; const connections = ref([]), selected = ref(''); @@ -22,10 +17,6 @@ let renameContainer: HTMLElement | null = null; const removalTarget = computed(() => connections.value.find(item => item.id === removalId.value)); const error = ref(''), removalError = ref(''); const heading = ref(null); -// An opened link awaiting review, and an accepted offer on its way to a slot. -const invitation = ref<{ code: string } | null>(null); -const handoff = ref<{ connection: string; code: string } | null>(null); -const canAdd = computed(() => !adding.value && !removing.value && connections.value.length < CONNECTION_LIMIT); let persistent = true, pending = 0, writes = Promise.resolve(), refreshRequested = false; let updates: BroadcastChannel | undefined; function select(id: string) { @@ -81,15 +72,8 @@ onMounted(async () => { updates.onmessage = () => { void refresh(); }; } window.addEventListener('focus', refresh); - window.addEventListener('hashchange', openLink); - if (props.initialCode) invitation.value = { code: props.initialCode }; }); -onBeforeUnmount(() => { updates?.close(); window.removeEventListener('focus', refresh); window.removeEventListener('hashchange', openLink); }); -// A link opened in an existing tab only changes the fragment. -function openLink() { - const code = takeFragment(); - if (code) invitation.value = { code }; -} +onBeforeUnmount(() => { updates?.close(); window.removeEventListener('focus', refresh); }); async function add() { if (adding.value || removing.value || connections.value.length >= CONNECTION_LIMIT) return; adding.value = true; @@ -97,18 +81,10 @@ async function add() { await writes; if (persistent) connections.value = await addConnection(); else connections.value.push(emptyConnection(Math.max(...connections.value.map(item => item.number)) + 1)); - const id = connections.value.at(-1)!.id; - select(id); updates?.postMessage('changed'); - return id; + select(connections.value.at(-1)!.id); updates?.postMessage('changed'); } catch (err) { error.value = asError(err).message; } finally { adding.value = false; } } -async function openInvitation(target: string, code: string) { - const id = target === 'new' ? await add() : target; - if (!id || !connections.value.some(item => item.id === id)) return; - if ((states.value[id] ?? 'ready') !== 'ready') { error.value = 'That connection is in use. Open the link again and choose another connection.'; return; } - select(id); handoff.value = { connection: id, code }; -} function update(id: string, change: ConnectionUpdate) { const index = connections.value.findIndex(item => item.id === id); if (index < 0) return; @@ -214,8 +190,8 @@ async function remove() {

Opening your connections…

@@ -231,5 +207,4 @@ async function remove() { - diff --git a/src/components/ConnectionWorkspace.vue b/src/components/ConnectionWorkspace.vue index bb1a51a..1982f40 100644 --- a/src/components/ConnectionWorkspace.vue +++ b/src/components/ConnectionWorkspace.vue @@ -1,12 +1,11 @@