Pairing
How Console pairs with a daemon from a link or on the same machine, and what each side verifies.
Identities are keys. Console has one X25519 key pair (its peer_id, vpp_...). A daemon has its own
(daemon_id, vpd_...). A pairing is the daemon storing Console's key with a role, viewer or controller.
From a link
viewport-daemon pair prints a single-use link that carries the daemon's key, an offer id and secret, and its
targets. Console parses the link locally and shows both fingerprints in full, in groups of 4, before anything
touches the network:
const preview = await app.daemons.preview(offer.link); // parsed locally, no network
console.log("Name (from the link, unverified) ", preview.name);
console.log("Daemon fingerprint ", preview.daemon_fingerprint.join(" "));
console.log("This Console ", preview.console_fingerprint.join(" "));
console.log("Reach it via ", preview.targets.relay);Redeeming it runs the pair handshake against the daemon key from the link. Console tries direct first with a 3 second budget, aborts that attempt, then tries the relay. Two handshakes never race for one offer.
const paired = await app.daemons.pair(offer.link);
console.log("Paired over the", app.services.hub.state(paired.daemon.daemon_id));- Compare all 26 characters of both fingerprints when the daemon was started with
pair --confirm. A prefix match proves nothing: a key matching the first 8 characters can be ground. - A link is used once. If someone redeemed it first, Console says so and suggests
viewport-daemon peers lsto audit. - Console dials only
ws:andwss:targets, and never link-local, cloud metadata or unspecified addresses. Loopback and private ranges are allowed, because LAN pairing is the point. - A link carries the role the daemon grants.
viewport-daemon pair --role controllerlets Console start sessions and answer approvals; a link made without--rolepairs Console as a viewer, which can only watch. - The daemon CLI can put Console's address in the link with
viewport-daemon pair --console <url>. There is no QR code yet: copy the link.
The daemon on this machine
// A daemon with a home (its token and local socket live there) and a Direct endpoint on a free port.
const daemonHome = fs.mkdtempSync(path.join(os.tmpdir(), "vpd-"));
const workdir = fs.mkdtempSync(path.join(os.tmpdir(), "vpc-agent-"));
const supervisor = createTestSupervisor({ runners: [fakeRunner("agent", [say("hello from the agent"), exit(0)])] });
const daemon = await serve(supervisor, {
home: daemonHome,
direct: { host: "127.0.0.1", port: 0 },
name: "this-machine",
});Console reads <daemon home>/token and connects to <daemon home>/daemon.sock. The daemon home is daemon.home
in console.yaml, else VIEWPORT_HOME, else ~/.viewport/daemon. The token must be 0600 and owned by you.
Console asks for an offer, checks the offer's key against hello, redeems it over Direct, and keeps only the
controller pairing. A daemon started with --no-local-pairing refuses; Console then shows the
viewport-daemon pair command to run instead.
Staying connected and leaving
- Reconnects use full-jitter backoff from 1 s to 60 s, starting with the target that worked last.
rejectframes and close reasons are unauthenticated. Console reports them aschannel.rejectedwith the claimed code, shows the code as unverified, and never deletes a pairing because of one. After a claimeddaemon.peer_unknownit keeps retrying, with backoff capped at 10 minutes.- Removing a daemon sends
peer.leavewhen it is online. When it is offline, Console shows the command to run on the daemon:viewport-daemon peers revoke vpp_....