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 <noreply@anthropic.com>
This commit is contained in:
1 parent
f320bfb541
commit
a5935a8324
16 files changed
+57
-602
No files matched your search
+2
-7
@@ -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, MAX_INPUT_LENGTH, codeFromText, codeLink, createRef, decodeCode, encodeCode, type Signal } from '../src/lib/codes.ts';
|
||||
import { CODE_PREFIX, MAX_CODE_LENGTH, MAX_INPUT_LENGTH, 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) };
|
||||
@@ -24,14 +24,9 @@ test('codes round-trip both types, with and without identity', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('links, wrapped text and bare codes decode the same', async () => {
|
||||
test('wrapped text and bare codes decode the same', async () => {
|
||||
const code = await encodeCode(offer);
|
||||
const link = codeLink(code, 'https://example.com/apps/hellcon/?x=1#old');
|
||||
assert.equal(link, `https://example.com/apps/hellcon/?x=1#${code}`);
|
||||
assert.equal(codeFromText(link), code);
|
||||
assert.deepEqual(await decodeCode(link), offer);
|
||||
assert.deepEqual(await decodeCode(` ${code.slice(0, 20)}\n${code.slice(20)} `), offer);
|
||||
assert.deepEqual(await decodeCode('#' + code), offer);
|
||||
});
|
||||
|
||||
test('expected type and ref are enforced', async () => {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { deliverAnswer, listenForAnswers, takeFragment } from '../src/lib/invitations.ts';
|
||||
|
||||
test('answers reach the waiting offer once and report later deliveries as used', async () => {
|
||||
let waiting = true;
|
||||
const received: string[] = [];
|
||||
const stop = listenForAnswers('ref-a', code => {
|
||||
if (!waiting) return false;
|
||||
waiting = false; received.push(code);
|
||||
return true;
|
||||
});
|
||||
const other = listenForAnswers('ref-b', () => assert.fail('another offer must ignore this answer'));
|
||||
try {
|
||||
assert.equal(await deliverAnswer('ref-a', 'HC1.answer'), 'delivered');
|
||||
assert.equal(await deliverAnswer('ref-a', 'HC1.answer'), 'used');
|
||||
assert.deepEqual(received, ['HC1.answer']);
|
||||
} finally { stop(); other(); }
|
||||
});
|
||||
|
||||
test('answers without a waiting tab fall back to manual pasting', async () => {
|
||||
assert.equal(await deliverAnswer('nobody', 'HC1.answer', 50), null);
|
||||
const stop = listenForAnswers('ref-a', () => true);
|
||||
stop();
|
||||
assert.equal(await deliverAnswer('ref-a', 'HC1.answer', 50), null);
|
||||
});
|
||||
|
||||
test('only code fragments are taken from the URL', () => {
|
||||
const replaced: string[] = [];
|
||||
const url = { href: 'https://example.test/app/?x=1#HC1.abc', hash: '#HC1.abc' };
|
||||
Object.assign(globalThis, { location: url, history: { state: null, replaceState: (_: unknown, __: string, next: string) => replaced.push(next) } });
|
||||
try {
|
||||
assert.equal(takeFragment(), 'HC1.abc');
|
||||
assert.deepEqual(replaced, ['https://example.test/app/?x=1']);
|
||||
Object.assign(url, { href: 'https://example.test/app/#main-content', hash: '#main-content' });
|
||||
assert.equal(takeFragment(), '');
|
||||
assert.equal(replaced.length, 1);
|
||||
} finally { Reflect.deleteProperty(globalThis, 'location'); Reflect.deleteProperty(globalThis, 'history'); }
|
||||
});
|
||||
Reference in new issue
Block a user