Confirm reconnect pairings and add connection discovery settings
Setup now waits for both IndexedDB writes: the acceptor acknowledges its write, a failure on either side is reported to both people, and the proposer removes its copy if the acceptor could not save. Every session that authenticates the paired device compares a check value derived from the stored pairing, so a one-sided pairing (interrupted setup, or Turn off reconnect on one device) is turned off on the other side too. The tracker is chosen under Network settings > Connection discovery (manual, default from VITE_TRACKER_URL, or custom), stored per browser and editable during a session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3659956967
commit
acba97a7e1
10 files changed
+309
-55
No files matched your search
@@ -600,16 +600,77 @@ try {
|
||||
assert.deepEqual(rememberedBytes, { length: 4096, valid: true });
|
||||
console.log('PASS: identities and paired connections persist across reload; fresh mutual proofs authenticate the paired device and transfer exact bytes without manual reconfirmation.');
|
||||
|
||||
if (trackerUrl) {
|
||||
const both = [identitySender, identityReceiver];
|
||||
await input(identitySender, '#tracker-url', trackerUrl);
|
||||
const both = [identitySender, identityReceiver];
|
||||
// Setup itself never contacts the tracker, so these checks run without one.
|
||||
assert.ok(await evaluate(identitySender, () => document.body.textContent?.includes('choose a tracker under Network settings')));
|
||||
await input(identitySender, '#discovery', 'custom');
|
||||
await wait(identitySender, () => !!document.querySelector('#tracker-url'));
|
||||
await input(identitySender, '#tracker-url', trackerUrl || 'wss://tracker.example/');
|
||||
await wait(identitySender, () => [...document.querySelectorAll('button')].some(button => button.textContent === 'Set up reconnect'));
|
||||
const hasPairing = (session: string) => evaluate(session, () => [...document.querySelectorAll('button')].some(button => button.textContent === 'Turn off reconnect'));
|
||||
const failStorage = (session: string) => evaluate(session, () => {
|
||||
const originalOpen = indexedDB.open;
|
||||
indexedDB.open = () => {
|
||||
indexedDB.open = originalOpen;
|
||||
throw new DOMException('Simulated connection storage failure', 'SecurityError');
|
||||
};
|
||||
});
|
||||
// A failed IndexedDB write on either side is reported to both people, and
|
||||
// the proposer, which stores first, removes its copy when the acceptor fails.
|
||||
for (const failing of both) {
|
||||
await failStorage(failing);
|
||||
await click(identitySender, 'Set up reconnect');
|
||||
await wait(identityReceiver, () => document.body.textContent?.includes('proposes reconnecting through'));
|
||||
await click(identityReceiver, 'Accept');
|
||||
for (const session of both) {
|
||||
await wait(session, () => !!document.querySelector('.reconnect-setup .error'));
|
||||
assert.equal(await evaluate(session, () => document.body.textContent?.includes('Reconnect is set up')), false);
|
||||
}
|
||||
for (const session of both) await wait(session, () => ![...document.querySelectorAll('button')].some(button => button.textContent === 'Turn off reconnect'));
|
||||
}
|
||||
console.log('PASS: failed reconnect storage on either side is reported to both peers, and the proposer rolls back its stored pairing.');
|
||||
|
||||
const setUpReconnect = async () => {
|
||||
await click(identitySender, 'Set up reconnect');
|
||||
await wait(identityReceiver, () => document.body.textContent?.includes('proposes reconnecting through'));
|
||||
await checkAccessibility(identityReceiver, 'reconnect proposal');
|
||||
if (screenshotDirectory) await evaluate(identityReceiver, () => window.__hellcon.element('.reconnect-setup').scrollIntoView({ block: 'center' }));
|
||||
await screenshot(identityReceiver, 'reconnect-proposal');
|
||||
await click(identityReceiver, 'Accept');
|
||||
for (const session of both) await wait(session, () => document.body.textContent?.includes('Reconnect is set up'));
|
||||
for (const session of both) await wait(session, () => document.body.textContent?.includes('Reconnect is set up on both devices'));
|
||||
for (const session of both) assert.ok(await hasPairing(session));
|
||||
};
|
||||
const exchangeCodes = async () => {
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(1024, 'manual.bin'));
|
||||
await click(identitySender, 'Create code'); await wait(identitySender, () => !!document.querySelector('#output-code'));
|
||||
await input(identityReceiver, '#offer-input', await evaluate(identitySender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value));
|
||||
await click(identityReceiver, 'Accept & create answer');
|
||||
await wait(identityReceiver, () => !!document.querySelector('#output-code'));
|
||||
await input(identitySender, '#answer-input', await evaluate(identityReceiver, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value));
|
||||
await click(identitySender, 'Connect');
|
||||
await wait(identityReceiver, () => !!document.querySelector('.incoming'));
|
||||
await click(identityReceiver, 'Accept file');
|
||||
await wait(identitySender, () => document.body.textContent?.includes('The receiver confirmed the complete file.'));
|
||||
};
|
||||
const disconnectBoth = async () => {
|
||||
await click(identitySender, 'Disconnect');
|
||||
await wait(identityReceiver, () => [...document.querySelectorAll('button')].some(button => button.textContent === 'Reset'));
|
||||
await click(identitySender, 'Reset'); await click(identityReceiver, 'Reset');
|
||||
};
|
||||
await setUpReconnect();
|
||||
// Turning reconnect off on one device is noticed by the other during the
|
||||
// next authenticated session, which then turns its own copy off as well.
|
||||
await disconnectBoth();
|
||||
await click(identityReceiver, 'Turn off reconnect');
|
||||
await wait(identityReceiver, () => ![...document.querySelectorAll('button')].some(button => button.textContent === 'Turn off reconnect'));
|
||||
assert.ok(await hasPairing(identitySender));
|
||||
await exchangeCodes();
|
||||
await wait(identitySender, () => document.body.textContent?.includes('no matching reconnect settings'));
|
||||
await wait(identitySender, () => ![...document.querySelectorAll('button')].some(button => button.textContent === 'Turn off reconnect'));
|
||||
console.log('PASS: confirmed reconnect setup; a pairing turned off on one device is removed from the other in the next authenticated session.');
|
||||
|
||||
if (trackerUrl) {
|
||||
await setUpReconnect();
|
||||
if (screenshotDirectory) await evaluate(identitySender, () => window.__hellcon.element('.reconnect-setup').scrollIntoView({ block: 'center' }));
|
||||
await screenshot(identitySender, 'reconnect-set-up');
|
||||
await click(identitySender, 'Disconnect');
|
||||
@@ -630,6 +691,7 @@ try {
|
||||
await screenshot(identitySender, 'reconnect-waiting');
|
||||
await click(identityReceiver, 'Reconnect');
|
||||
for (const session of both) await wait(session, () => document.body.textContent?.includes('Paired device authenticated'));
|
||||
for (const session of both) await wait(session, () => document.body.textContent?.includes('is set up on both devices'));
|
||||
assert.equal(await evaluate(identitySender, () => !!document.querySelector('#output-code')), false, 'No code is shown on reconnect');
|
||||
for (const [from, to, size] of [[identitySender, identityReceiver, 5000], [identityReceiver, identitySender, 6000]] as const) {
|
||||
await evaluate(from, (size: number) => window.__hellcon.chooseFile(size, 'reconnected.bin'), size);
|
||||
|
||||
Reference in new issue
Block a user