Expand description
The desktop side of AgentMux Cloud’s GitHub broker (/github/v1/*).
The broker holds the AgentMux App’s client secret, so a connect, a refresh and a disconnect all go through it. Every call carries two proofs:
- the account’s AgentMux Cloud sign-in, as a bearer token;
- an install signature (the Ed25519 instance key of this install, the one the WAN jekts use) over the request, so a stolen sign-in alone can’t call the broker from another machine.
The signature covers, joined by U+0001: amx-github-broker-v1, the HTTP
method in upper case, the path and query as sent, the timestamp header’s
value (epoch milliseconds), and the lower-case hex SHA-256 of the exact body
bytes (of the empty string when there is none). It travels as
x-amx-instance, x-amx-ts and x-amx-sig (standard base64). The golden
vectors in the tests are the broker’s own (generated independently of this
code), so a drift on either side fails a test.
Structs§
- AppBot
- The App’s bot: what its commits are attributed to.
- Caller
- Who is calling, and as what: everything a call needs besides its request.
- Connection
GET /github/v1/connection.- Github
User - Install
State - A state for an install trip (
POST /github/v1/installations/state): single use, bound to the account, valid for a few minutes.install_urlis GitHub’s install page for the App, carrying it. - Installation
Account - The GitHub account an installation is on.
- Installation
Request - What
POST /github/v1/installation-tokenasks for: a token for one installation, narrowed to the repositories (bare names under the installation’s account) and the permissions. - Installation
Token - A minted installation token.
- Linked
Installation - One of the account’s links to an installation, from
GET /github/v1/installations. - Revalidated
- What a revalidation did.
- Revoked
- What a disconnect did.
- Token
Grant POST /github/v1/tokenfor a code exchange or a refresh.
Enums§
- Broker
Error - Why a broker call gave no answer. The variants are what the desktop does next, not what the broker said.
Constants§
- NO_
VALID_ SIGN_ IN - What
callersays when there is no valid AgentMux Cloud sign-in: the oneNotSignedInthat signing in fixes. - SIGNATURE_
DOMAIN - The signature’s domain separator.
Functions§
- caller
- The caller for this install: the cloud sign-in and the instance key.
- code_
body - The body of an authorization-code exchange.
- connection
- Whether the account has a live GitHub grant, and as whom.
- error_
for - Maps a failed answer to what the desktop does about it.
- exchange_
code - Trade an authorization code (with its PKCE verifier) for the user’s grant.
- exchange_
trip_ code - Trade the code an install trip came back with (and the trip’s
state) for the user’s grant. - installation_
state - A state for an install trip.
- installation_
token - A token narrowed to the repositories and permissions asked for, on one linked installation.
- installations
- The installations this account has linked.
- link_
installation - Link the account to an installation. The broker checks, with the person’s own GitHub token, that the installation is one that person can see, and records which of its repositories they can.
- refresh
- Trade a refresh token for a new grant. GitHub’s refresh tokens are single use: the answer’s replaces the one sent.
- revalidate
- Present a fresh user token so the broker re-reads what this account can see; it keeps nothing of the token.
- revoke
- End the grant on GitHub and at the broker. Both of the install’s tokens are sent, so a dead access token can fall back to the refresh token.
- sign
- The base64 signature of
materialunder the instance’s 32-byte seed. - signature_
material - What the install signs for one request.
- trip_
code_ body - The body of an install trip’s code exchange (the one-trip first connect): no PKCE verifier, since GitHub’s
install page starts none; the install
statethe broker issued to this account is what binds the code. - unlink_
installation - End the account’s link to an installation. The installation stays on GitHub.