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:
1 parent
da2999ed5d
commit
8bd37ac8b1
10 files changed
+68
-89
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import { CODE_PREFIX, MAX_CODE_LENGTH, codeFromText, codeLink, createRef, decodeCode, encodeCode, type Signal } from '../src/lib/codes.ts';
|
||||
import { CODE_PREFIX, MAX_CODE_LENGTH, MAX_INPUT_LENGTH, codeFromText, codeLink, createRef, decodeCode, encodeCode, type Signal } from '../src/lib/codes.ts';
|
||||
const fingerprint = Array.from({ length: 32 }, (_, i) => i.toString(16).padStart(2, '0')).join(':');
|
||||
const sdp = `v=0\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\na=fingerprint:sha-256 ${fingerprint}\r\n`;
|
||||
const identity = { key: '04' + 'ab'.repeat(64), nonce: 'cd'.repeat(32) };
|
||||
@@ -67,7 +67,7 @@ test('malformed, old and unexpected payloads are rejected', async () => {
|
||||
|
||||
test('oversized codes and decompression bombs are rejected', async () => {
|
||||
await assert.rejects(decodeCode(CODE_PREFIX + 'A'.repeat(MAX_CODE_LENGTH)), /too large/);
|
||||
await assert.rejects(decodeCode('x'.repeat(MAX_CODE_LENGTH * 2 + 1)), /too large/);
|
||||
await assert.rejects(decodeCode('x'.repeat(MAX_INPUT_LENGTH + 1)), /too large/);
|
||||
// 32 MiB of zeros deflate to about 32 KiB, which fits the code length limit.
|
||||
const bomb = CODE_PREFIX + base64url(await deflate(new Uint8Array(32 * 1024 * 1024)));
|
||||
assert.ok(bomb.length < MAX_CODE_LENGTH);
|
||||
|
||||
Reference in new issue
Block a user