Add experimental tracker reconnect for paired devices
During a session authenticated by both device identities, one person proposes a WebTorrent tracker and the other confirms it. Both contribute a nonce over the data channel; HKDF binds both device keys, the session fingerprints and the tracker URL into a non-extractable base key stored with the connection. Forget device, a replaced paired device and Turn off reconnect clear it. Reconnect joins a daily swarm derived from that key. Offers, answers and codeless wakes travel as AES-GCM envelopes bound to the tracker routing fields. The lower device key offers; the other device wakes it when it arrives second. Retries are spaced and capped, one attempt per slot runs under a Web Lock, and fresh device proofs still authenticate the session. Checked against tracker.openwebtorrent.com and tracker.webtorrent.dev with the new opt-in browser check (--tracker=<url>). Signaling v5, midnight rollover, clock skew, CSP and real-network checks remain open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a5935a8324
commit
3659956967
17 files changed
+930
-28
No files matched your search
@@ -3,7 +3,7 @@ import { onActivated, onMounted, ref, shallowRef } from 'vue';
|
||||
import { clearIdentityStorage, createIdentity, loadIdentityState, saveIdentityState, type IdentityState } from '../lib/identity.ts';
|
||||
import type { ConnectionUpdate } from '../lib/connections.ts';
|
||||
import { asError } from '../lib/validation.ts';
|
||||
const props = defineProps<{ disabled: boolean; paired: string; remember: boolean }>();
|
||||
const props = defineProps<{ disabled: boolean; paired: string; remember: boolean; reconnect: string }>();
|
||||
const emit = defineEmits<{ update: [change: ConnectionUpdate] }>();
|
||||
const supported = (() => { try { return isSecureContext && !!crypto.subtle && !!window.indexedDB; } catch { return false; } })();
|
||||
const state = shallowRef<IdentityState>({ identity: null });
|
||||
@@ -37,6 +37,7 @@ function create() { void run(async () => { state.value = await saveIdentityState
|
||||
function reset() { void run(async () => { if (!confirmDelete.value) return; state.value = await saveIdentityState({ identity: null }, state.value.revision); confirmDelete.value = false; }); }
|
||||
function toggle(event: Event) { if (!props.disabled && event.target instanceof HTMLInputElement) emit('update', { rememberDevice: event.target.checked }); }
|
||||
function forget() { if (!props.disabled) emit('update', { peerKey: '' }); }
|
||||
function stopReconnect() { if (!props.disabled) emit('update', { reconnect: null }); }
|
||||
async function refreshIdentity() {
|
||||
if (working.value) throw new Error('Wait for the device settings operation to finish before connecting.');
|
||||
if (!supported) return null;
|
||||
@@ -62,6 +63,10 @@ defineExpose({ refreshIdentity });
|
||||
<template v-else>
|
||||
<template v-if="paired">
|
||||
<p class="status">Paired device <code>{{ paired.slice(-12) }}</code>. Later sessions verify it automatically.</p>
|
||||
<template v-if="reconnect">
|
||||
<p class="status">Reconnects without codes through <strong>{{ reconnect }}</strong>.</p>
|
||||
<button @click="stopReconnect">Turn off reconnect</button>
|
||||
</template>
|
||||
<button @click="forget">Forget device</button>
|
||||
</template>
|
||||
<label v-else><input id="remember-device" :checked="remember" type="checkbox" @change="toggle" /> Use my device identity on this connection</label>
|
||||
|
||||
Reference in new issue
Block a user