Skip to main content

Module github_broker

Module github_broker 

Source
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.
GithubUser
InstallState
A state for an install trip (POST /github/v1/installations/state): single use, bound to the account, valid for a few minutes. install_url is GitHub’s install page for the App, carrying it.
InstallationAccount
The GitHub account an installation is on.
InstallationRequest
What POST /github/v1/installation-token asks for: a token for one installation, narrowed to the repositories (bare names under the installation’s account) and the permissions.
InstallationToken
A minted installation token.
LinkedInstallation
One of the account’s links to an installation, from GET /github/v1/installations.
Revalidated
What a revalidation did.
Revoked
What a disconnect did.
TokenGrant
POST /github/v1/token for a code exchange or a refresh.

Enums§

BrokerError
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 caller says when there is no valid AgentMux Cloud sign-in: the one NotSignedIn that 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 material under 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 state the 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.