What it does
Hub is the one front door for every product in the ecosystem: the suite's data API, the owner portal, the inspection, field-service and property-management products on the web, the five mobile apps, and the internal administration dashboard. A user signs in once at Hub and is signed in everywhere. No product has its own login; Hub is the first piece of infrastructure deployed, before any product that depends on it.
The screens and routes
- Register and log in. Public pages for creating an account and signing in, with a password-strength meter.
- Onboarding. A guided wizard for a new user's first steps.
- Select product. After sign-in, the user chooses which product to open, and Hub sends them there already signed in.
- Five server routes handle login, registration, token refresh, and setting and clearing the refresh cookie.
- A health endpoint that reports whether the suite's API is reachable by actually calling it, returning a 503 when it is not.
How the tokens are kept safe
- Access tokens in memory only. The short-lived access token lives in browser memory and nowhere else: never in cookies, local storage, session storage or IndexedDB. Closing the tab discards it on purpose.
- Refresh tokens in HttpOnly cookies. The long-lived refresh token is set by Hub's own server route as an HttpOnly, Secure, SameSite=Strict cookie shared across the ecosystem's domain, so page scripts can never read it and every product shares one sign-in.
- No token checks in the browser. JSON Web Token verification happens only on the server; the browser receives the user's claims through a
useAuthhook. - Fail closed. Any authentication error signs the user out instead of guessing.
Multi-tab leader election
Refresh tokens are single-use. If a user has five tabs open and all five try to refresh at once, four of them would spend an already-used token and sign the user out. Hub elects one leader tab using BroadcastChannel and Atomics; the leader makes exactly one refresh call and shares the new token with the other tabs. Cross-origin isolation headers are set so the shared memory this needs is available.
The open-redirect firewall
After sign-in Hub returns the user to where they came from. Every return_to address is validated against the ecosystem's allowed destinations, so a crafted link cannot use Hub's sign-in page to send a user to an attacker's site.
Sign-in providers
Email and password, and Google through the suite's API's redirect flow. Apple and Microsoft sign-in are designed into the same flow, with Apple using the API's mobile endpoint and Microsoft using its own client-side library.
The shared packages
auth: the auth provider, the in-memory token store, the token manager, the broadcast coordinator for leader election, and theuseAuth,useLoginanduseRegisterhooks every product uses.api-client: a typed client for the suite's API's auth and profile endpoints, which turns every API failure into a typed error so the interface never shows a raw fetch error.ui: the shared buttons, inputs, spinner and password-strength components.
What Hub consumes
Hub is mapped to 45 of the suite's API endpoints: authentication (8), OAuth (4), profile (6), company (8), membership (5), party (4), app (7) and session (3).
What it achieved
- One sign-in for twelve products. Every product in the ecosystem authenticates through Hub.
- 189 test cases in 3,702 lines of tests across 15 files, plus consumer contract tests and browser journey tests.
- Sixteen invariants and ten structural rules that govern every change.
- The tab-refresh race removed: exactly one refresh call per refresh event, however many tabs are open.
The problem it solves
An ecosystem of twelve products cannot have twelve logins. Users expect to sign in once, and every separate login is another place for a security mistake. Single sign-on in the browser has well-known traps: tokens stored where scripts can steal them, sign-in pages that can be turned into redirect attacks, and single-use refresh tokens that log users out when several tabs refresh at once. Hub solves all three in one place, so no product team has to solve them again.
How he built it
Maxwell wrote Hub's constitution before any code: sixteen invariants covering token storage, package naming, no local authentication, leader election, cross-origin isolation headers, snake_case API fields, server-only token verification, return-address validation, a contract test for every API call, typed errors, UUIDv7 identifiers, fail-closed errors, the quality gate, test-first development, Hub's place as the first infrastructure deployed, and local HTTPS in development. Every agent working in the repository must list the invariants that apply to its task before writing a line. He directed AI agents to build it test-first, with every the suite's API call covered by a Pact consumer contract test and agents required to confirm each endpoint, field and permission level through the ecosystem's contract server and the database schema itself, never from documentation. pnpm gate (type checks, lint, unit tests, contract tests and bundle-size limits) is the only accepted checkpoint, and after two failed agents on one task the work stops, is reverted, and the task description is fixed before another agent is sent in.