feat(companion): npub-first pairing — node self-anchor + guaranteed public anchor in the QR

The pairing QR was effectively IP-first: the phone dialed the scanned LAN
host and went dark when the LAN renumbered or it left home. FIPS peers on
npubs; IPs are only dial hints. fanchors now leads with the paired node
ITSELF (fnpub @ current host, npub-keyed so LAN contact is direct p2p over
FIPS and survives DHCP), and fips.pair-info always includes the Archipelago
vps2 public anchor (pairing hint only — the node's own anchor file is not
modified) so the phone can rendezvous through the public mesh when away.
Contract doc updated with the REQUIRED app-side changes (built on the Mac).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
archipelago
2026-07-23 15:30:40 -04:00
co-authored by Claude Fable 5
parent e59ea1da69
commit c58f84c6e9
3 changed files with 53 additions and 6 deletions
@@ -348,9 +348,19 @@ async function buildPairingUrl(): Promise<string> {
if (info.udp_port) params.set('fudp', String(info.udp_port))
if (info.tcp_port) params.set('ftcp', String(info.tcp_port))
// Rendezvous anchors (compact: npub@addr/transport, comma-joined).
// Cap keeps the QR at a camera-friendly density; the node lists its
// most reachable anchors first.
const anchors = (info.anchors || []).slice(0, 4)
// FIRST entry is the paired node ITSELF: the phone peers with it by
// npub (the fhost addr is only a dial hint), so LAN contact is direct
// p2p over FIPS and survives DHCP renumbering; the node's public
// anchors follow for reaching it away from home. Cap keeps the QR at a
// camera-friendly density; the node lists its most reachable anchors
// first.
const selfAnchor = info.tcp_port
? [{ npub: info.npub, addr: `${params.get('fhost')}:${info.tcp_port}`, transport: 'tcp' }]
: []
const anchors = [
...selfAnchor,
...(info.anchors || []).filter((a) => a.npub !== info.npub),
].slice(0, 4)
if (anchors.length) {
params.set(
'fanchors',