lmauth guide

Secret-isolated token collection architecture, lmconn broker integration, and invocation manifest handling for lmauth.

Overview

lmauth separates credential guidance and orchestration from secret possession. An LLM agent or automation script can request a token setup flow for specific repositories, while the human operator enters the token into a local interface that hands the secret directly to the encrypted lmconn store.

Secret-isolated authorization flow

Every authorization session moves through five explicit stages:

  1. Recipe planning (auth_plan or lmauth plan) generates human-readable instructions for creating a fine-grained GitHub personal access token scoped to the target owner and repositories with a seven-day expiry.
  2. Presentation (auth_present or lmauth present) launches either a loopback operator web page or a controlling-TTY hidden prompt (--terminal) when a real terminal session is attached.
  3. Collection (auth_collect) holds the entered token in memory inside the host process and assigns an internal opaque session reference.
  4. Verification (auth_verify) queries the provider identity endpoint and public repository metadata (or a local lmmock endpoint when --mock-api is supplied) to confirm the token authenticates as a valid user while marking permission grants as human-attested.
  5. Broker storage (auth_store) invokes lmconn over stdin in broker store mode, storing the token under a random lmauth:HANDLE key with reveal disabled.

lmconn store and encryption boundary

lmauth does not maintain its own credential database. Instead, it delegates persistence to lmconn, which encrypts credentials at rest. When --lmconn-key-file ABS is provided, lmauth validates that the key file resides in a private directory distinct from the database directory and forwards the path to lmconn as LMCONN_KEY_FILE without reading the key bytes or accepting raw keys in environment variables.

Invocation manifest and dry-mode guarantees

When invoked via --lmcode FILE, lmauth inspects LMCODE_INVOCATION_FILE before starting any server or terminal prompt. The manifest must be valid version-1 JSON with a boolean dry field; missing or non-boolean dry values fail immediately with exit code 2 before dispatch. In dry mode, domain callbacks are bypassed and the host emits a dry-no-auth return envelope so orchestration pipelines can verify wiring offline.

Publishing to npm

lmauth publish packs a package, publishes it through an npm login kept in the lmconn store, and can set the package's trusted publisher so that the repository's GitHub workflow publishes later versions with no token. You only click links; the npm token never reaches you, the agent or the page.

Use it when a package's trusted-publishing workflow fails with ENEEDAUTH (npm has no trusted publisher for the package yet), or for a new package, since npm accepts a trusted publisher only for a package that already exists.

export LMBRIDGE_APPKEY="$(node -p "require(process.env.HOME + '/.config/lmctl/appkey.json').appkey")"
lmauth publish --package /abs/path/to/package-dir --access public --tag latest \
  --credential lmauth:npm-NPMUSER --login --expect-user NPMUSER \
  --trust-repo OWNER/REPO --trust-file release.yml \
  --lmconn-node $T/node --lmconn-entry $T/lmconn/bin/lmconn.js --lmconn-db $D/creds.db

$T is a directory holding private copies of node and lmconn that only you can write, and $D is a 700 store directory directly under your home. lmconn must be at commit 4f5b14e or later, or a first login stops with login_check_failed.

lmauth prints each approval page on stderr as {"approve":"https://lmctl.ai/r/.../npm-approve-N.html"}. Open it signed in to lmctl.ai and click the npm link. A first run showed two pages: npm's web login (approve as NPMUSER), then the 2FA approval for the publish, which also covered the trusted publisher. The receipt on stdout reports outcome published_confirmed, trust configured and verified true; the exit code is 0 only when every package is confirmed.

The full procedure, including the one-time setup and the errors, is in docs/npm-publish.md.