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

+4 -4
View File
@@ -40,8 +40,8 @@ async function run(mode) {
dc.onopen = () => { log('sender channel open'); dc.send('exact-file-bytes'); };
b.ondatachannel = e => { e.channel.onmessage = e => { received = e.data === 'exact-file-bytes'; log('receiver bytes '+received); }; };
try {
const offer = await api.createOfferCode(a);
let sdp = api.decodeSignal(offer);
// The original helpers exchange encoded codes; current helpers exchange SDP.
let sdp = mode === 'original' ? api.decodeSignal(await api.createOfferCode(a)) : await api.createOffer(a);
// Deliberately unusable advertised ports: only sender-initiated checks
// after the answer can discover the real sender. No host firewall changes.
if(rewritePorts) sdp = sdp.split('\r\n').filter(l=>!/^a=candidate:.* tcp /i.test(l)).map(l=>{
@@ -49,11 +49,11 @@ async function run(mode) {
const fields=l.split(' '); fields[5]='9'; return fields.join(' ');
}).join('\r\n');
log('offer ready; end-of-candidates='+sdp.includes('a=end-of-candidates'));
const answer = await api.createAnswerCode(b, api.encodeSignal(sdp));
const answer = mode === 'original' ? await api.createAnswerCode(b, api.encodeSignal(sdp)) : await api.createAnswer(b, sdp);
log('answer ready');
await new Promise(r=>setTimeout(r,20000));
log('apply answer');
await api.acceptAnswerCode(a,answer);
await (mode === 'original' ? api.acceptAnswerCode(a,answer) : api.acceptAnswer(a,answer));
await new Promise(r=>setTimeout(r,12000));
return {mode,received,events};
} catch { return {mode,received,events,error:'Signaling failed; raw browser error omitted'}; }