Pair a wall panel through the portal

A screen somewhere this installation is not reachable from asks the portal for
a code instead, and the portal mints its credential — because a token signed
here is one such a device could never present.

Where it was minted changes nothing about what it may do. The panel gate moved
off the branch that decodes a local panel token and onto whatever claims name
a panel, so the portal's and this installation's are bounded by the same check
against the same panel's dashboards. A token of that scope naming no panel is
refused rather than left holding the account it borrows.

The connector marks what arrives on its socket, since that is the only thing
that makes it true, and the approval screen now names what is holding a code —
approving adopts whatever answers, so it is worth a look first.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017F9RnYCJgASuBTcAjxmnsp
This commit is contained in:
2026-08-20 23:42:58 +02:00
co-authored by Claude Opus 5
parent dcd6716749
commit 1d6918d8df
17 changed files with 695 additions and 175 deletions
+19
View File
@@ -43,6 +43,25 @@ export function apiToken(): string {
return portalConfig()?.token ?? localStorage.getItem("access_token") ?? ""
}
/**
* Hand a freshly paired credential to the hub, which keeps it in its cookie.
*
* Under the portal the page is served with its token injected, so there is
* nowhere in this app to put one a device just collected — and a credential
* that lasts a year is exactly what must not ride in a query string, where
* access logs and browser history would keep it.
*/
export async function openPortalSession(token: string): Promise<void> {
const config = portalConfig()
if (!config) return
const response = await fetch(`${config.basePath}/session`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ token }),
})
if (!response.ok) throw new Error(`The portal refused the credential`)
}
/**
* A path in this app, spelled the way the browser has to spell it.
*