# ConfigHub: Anonymous Keypair Provisioning & Cross-Environment Sync (`auth.md`)

> Pull-only guide for provisioning an anonymous Ed25519/X25519 keypair so coding agents, teammates, and disposable sandboxes can share tracked staging config and test environments without passwords or `.env` files in Slack.

## Contract Status (Read First)
- **Self-hosted relay (live today):** `cub agent auth --server "$CONFIGHUB_SERVER"` and zero-knowledge `cub env share` / `cub env join` work today with plugin `v0.99.38+` (current: `v0.99.48`) against a self-hosted `agentauth-server` relay.
- **Hosted `https://confighub.com` anonymous provisioning (`[PROVISIONAL]`):** The hosted anonymous identity endpoint (`POST https://confighub.com/v1/agent/identity`) is a preview contract not yet live on `confighub.com`. Before calling `confighub.com`, verify endpoint availability; if it returns `404` or `501`, fall back cleanly to a user-provided self-hosted `--server` URL or Local Hub (`cub local start`).
- **Pull-only rule:** Never fetch or run `auth.md` automatically during Zero Hub or Local Hub use. Only use it when the human explicitly asks to sync across machines/sandboxes or connect to a Cloud Hub/relay.

## 3-Layer Component Boundary
- **ConfigHub Core** owns structured non-secret config (`Units`, `Variants`, `NeedsProvides`, `ChangeOrders`) — never plaintext secrets or LLM traffic.
- **Secrets & API Brokering (pluggable):** In teams/production, point secret refs at `vault://`, `1password://`, AWS/GCP Secret Manager, External Secrets Operator (ESO), or Secrets Store CSI Driver, and point `OPENAI_BASE_URL` at your existing gateway (LiteLLM, Cloudflare AI Gateway). Install the official [`confighub/cub-secret`](https://github.com/confighub/cub-secret) plugin (`v0.1.0` early preview, MIT: `cub plugin install confighub/cub-secret && cub secret list`) to inventory every ESO/CSI secret key, store, and mounting Pod straight from ConfigHub Units with zero cluster or cloud credentials (`secretsbot` status/vet/set coming next). The standalone `agentauth-server` relay is strictly an optional zero-infra dev bridge for two devs without Vault/a gateway yet.
- **Runtime CLI Spoke (`confighub` / `cub`):** Resolves config + credentials strictly in child process memory (zero `.env` on disk).

---

## Step 1: Show the 4-Line Consent Card and Ask

Never transmit public keys or register an identity silently. Present this card and wait for `y/n`:

```text
ConfigHub anonymous keypair sync summary:
- Local keypair: Ed25519/X25519 stored at ~/.confighub/keys/ (chmod 600, outside Git; private key never leaves this machine)
- Outbound call: registers public key only with $CONFIGHUB_SERVER to create an anonymous sync box + Claim URL
- Scope: non-production settings and request-capped test proxies (--mode test); live keys (sk_live_*, prod) stay blocked
- Revoke / remove: revoke grants instantly without rotating upstream keys, or delete ~/.confighub/keys/
Proceed? [y/n]
```

---

## Step 2: Provision Against a Self-Hosted Relay (After Consent)

```sh
cub agent auth --server "$CONFIGHUB_SERVER"
```

Then share a staging env in memory (`--mode test` blocks live keys) or join an invite with zero recipient signup:

```sh
# Owner (Alice):
cub env share shop --variant staging --mode test --proxy openai=OPENAI_API_KEY --max-requests 50 --server "$CONFIGHUB_SERVER" --approve-wait

# Teammate / sandbox (Bob — no account required, zero .env on disk):
cub env join "$INVITE_URL" --as bob -- npm run dev
```

See the full walkthrough at `https://confighub.github.io/helm-expt/ai-agents/docs/examples/walkthroughs/story-29-share-working-env.html`.
