Add shareable invitation links
Codes now travel as links with the code in the URL fragment, which the app reads and clears before mounting (and on hashchange). An offer link opens a preview that suggests an idle slot, preferring the one paired with the sender's device, and only fills in the code; the user still creates the answer. Answer links reach the waiting sender tab over a same-origin BroadcastChannel, are acknowledged once and reported as used afterwards, and fall back to copy and paste when no tab answers. The panel offers Share link where the Web Share API accepts URLs, Copy link, and the bare code under a disclosure. The browser check covers the offer dialog, clean URL, answer relay, reuse, fallback on another origin, an invalid fragment, axe on both dialogs and exact bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8bd37ac8b1
commit
43ee7f119f
14 files changed
+422
-59
No files matched your search
+5
-1
@@ -104,6 +104,10 @@ export function waitForIceComplete(pc: IcePeer, { signal, timeout = 30000 }: Wai
|
||||
});
|
||||
}
|
||||
|
||||
export function hasRelay(sdp: string) {
|
||||
return sdp.split(/\r?\n/).some(line => /^a=candidate:.*\styp\s+relay(?:\s|$)/i.test(line));
|
||||
}
|
||||
|
||||
export function validateDescription(sdp: unknown, { allowTurn = false }: Pick<IceOptions, 'allowTurn'> = {}) {
|
||||
if (typeof sdp !== 'string' || sdp.length > MAX_SIGNAL_LENGTH || /[^\x09\x0A\x0D\x20-\x7E]/.test(sdp)) {
|
||||
throw new Error('Invalid connection description.');
|
||||
@@ -118,7 +122,7 @@ export function validateDescription(sdp: unknown, { allowTurn = false }: Pick<Ic
|
||||
if (fingerprints.length !== 1 || !/^a=fingerprint:sha-256 (?:[\da-f]{2}:){31}[\da-f]{2}$/i.test(fingerprints[0])) {
|
||||
throw new Error('A single full SHA-256 fingerprint is required.');
|
||||
}
|
||||
if (!allowTurn && lines.some(line => /^a=candidate:.*\styp\s+relay(?:\s|$)/i.test(line))) {
|
||||
if (!allowTurn && hasRelay(sdp)) {
|
||||
throw new Error('This code contains a TURN relay. Both people must explicitly enable TURN and create new codes to use a relay.');
|
||||
}
|
||||
return fingerprints[0].slice('a=fingerprint:sha-256 '.length).toUpperCase().replaceAll(':', ' ');
|
||||
|
||||
Reference in new issue
Block a user