Use compressed connection codes in the transfer panel

Offers and answers now go through the HC1 codec: the sender creates a
ref per session and the answer must echo it, so pasting an offer as the
answer or an answer for another code is rejected with a specific message
while the live offer stays usable. Pasted input may be a full link.

webrtc.ts drops its Base64 JSON signaling and exchanges validated SDP
only; identity hellos travel in the code envelope. Tests, the browser
check, compare-ice and the docs follow the new format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-19 22:35:44 +02:00
1 parent da2999ed5d
commit 8bd37ac8b1
10 files changed
+68 -89

No files matched your search

+6 -4
View File
@@ -1,6 +1,7 @@
// Dependency-free Chromium integration check. Run after `bun run build`.
import { Readable, Writable } from 'node:stream';
import { installBrowserContext, forceRelay, relayCandidateTypes, simulateSlowDisk } from './browser-context.ts';
import { CODE_PREFIX, decodeCode } from '../src/lib/codes.ts';
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
import { createServer } from 'node:http';
@@ -144,6 +145,7 @@ async function connect(sender: string, receiver: string, size: number, changedId
if (turn) { await enableTurn(sender); await enableTurn(receiver); }
await click(sender, 'Create code'); await wait(sender, () => !!document.querySelector('#output-code'));
const offer = await evaluate(sender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
assert.ok(offer.startsWith(CODE_PREFIX));
await input(receiver, '#offer-input', 'invalid-code!');
await click(receiver, 'Accept & create answer');
await wait(receiver, () => !!document.querySelector('[role=alert]'));
@@ -152,8 +154,8 @@ async function connect(sender: string, receiver: string, size: number, changedId
await input(receiver, '#offer-input', offer); await click(receiver, 'Accept & create answer');
await wait(receiver, () => !!document.querySelector('#output-code'));
const answer = await evaluate(receiver, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
await input(sender, '#answer-input', 'invalid-answer!'); await click(sender, 'Connect');
await wait(sender, () => !!document.querySelector('[role=alert]'));
await input(sender, '#answer-input', offer); await click(sender, 'Connect');
await wait(sender, () => document.querySelector('[role=alert]')?.textContent?.includes('not an answer'));
assert.equal(await evaluate(sender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code')?.value), offer);
assert.equal(await evaluate(sender, () => window.__hellcon.element<HTMLTextAreaElement>('#answer-input').disabled), false);
await input(sender, '#answer-input', answer); await click(sender, 'Connect');
@@ -517,7 +519,7 @@ try {
await evaluate(identitySender, () => window.__hellcon.chooseFile(4096, 'remembered.bin'));
await click(identitySender, 'Create code'); await wait(identitySender, () => !!document.querySelector('#output-code'));
const offer = await evaluate(identitySender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
assert.equal(JSON.parse(atob(offer)).version, 4);
assert.ok((await decodeCode(offer)).identity);
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<HTMLTextAreaElement>('#output-code').value);
@@ -621,7 +623,7 @@ try {
await input(denied, '#stun-provider', 'none'); await click(denied, 'Create code');
await wait(denied, () => !!document.querySelector('#output-code'));
const temporary = await evaluate(denied, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
assert.equal(JSON.parse(atob(temporary)).version, 3);
assert.equal((await decodeCode(temporary)).identity, undefined);
await click(denied, 'Cancel connection');
console.log('PASS: denied identity storage still allows temporary v3 connection setup.');