NHI-as-Code
Documentation & Quickstart

CLI, GitHub Action, MCP Server & Control-Plane API

Everything runs zero-dependency on Node 22+ and Cloudflare Workers.

1. Zero-Secret Local CLI (@nhiascode/cli)

# Instant interactive GhostAction blast-radius demo (zero credentials needed)
npx @nhiascode/cli demo

# Scan local workflows, Terraform OIDC policies, and Dockerfiles
npx @nhiascode/cli scan . --format json

# Generate confused-deputy-proof AWS OIDC Terraform + SHA-pinned workflow
npx @nhiascode/cli fix-preview \
  --org acme-saas --repo-name api --branch main \
  --aws-account 123456789012 --aws-region us-east-1 --aws-role github-actions-deploy

# Verify an Ed25519-signed SOC 2 / ISO 27001 evidence bundle offline
npx @nhiascode/cli verify evidence.json --pubkey jwks.json

2. GitHub Action (SARIF + Optional Metadata-Only Upload)

- name: NHI-as-Code GhostAction & OIDC Audit
  uses: theperipetycompany/nhi-as-code-action@<40-char-commit-sha>
  with:
    repo-path: .
    fail-on: critical
    sarif-output: nhi-results.sarif

3. Read-Only MCP Server (@nhiascode/mcp-server)

Expose deterministic NHI auditing and OIDC remediation generation to AI coding assistants with strict workspace containment and zero shell execution:

{
  "mcpServers": {
    "nhi-as-code": {
      "command": "node",
      "args": ["--experimental-strip-types", "packages/mcp/src/index.ts"]
    }
  }
}

4. Control-Plane HTTP API & GitHub App Installation Binding

To bind a GitHub App installation securely to your tenant without slug-squatting, mint a short-lived setup state token via POST /api/v1/orgs/:org/github/setup-state and pass it as ?state=... when installing the GitHub App.

Method & RouteAuthDescription
GET /api/healthPublicD1 liveness, signing key readiness, latest canary status.
GET /.well-known/nhi-jwks.jsonPublicEd25519 public verification JWK (OKP / Ed25519).
POST /api/v1/scan/workflowPublic (Rate-Limited)Stateless workflow scanner + Terraform OIDC preview (422 on raw secrets).
POST /api/v1/ingests/digestBearer API KeyMetadata-only snapshot ingestion (422 raw-secret firewall, 403 cross-tenant guard).
GET /api/v1/orgs/:org/inventoryBearer API KeyLatest tenant-isolated NHI inventory, findings, and blast-radius posture.
GET /api/v1/orgs/:org/evidenceBearer API KeyEd25519-signed SOC 2 & ISO 27001 bundle + Vanta & Drata custom evidence JSON (plan-gated).
POST /api/v1/orgs/:org/remediateBearer API KeyCreates SHA-pinned OIDC, GitHub App, or action-pinning PR for a verified opted-in installation.
POST /api/v1/orgs/:org/offboardBearer API KeyGenerates prioritized, human-reviewed employee offboarding revocation playbook (HMAC-only owner hashing).
POST /api/v1/orgs/:org/github/setup-stateBearer API Key (Team+)Issues a 15-minute single-use setup state token + GitHub App install URL bound to your tenant.
GET /api/v1/github/setup-callbackState + OAuth CodeExchanges GitHub OAuth code, verifies user ownership & org admin role, and binds the installation to your tenant.
POST /api/v1/orgs/:org/billing/checkoutBearer API KeyCreates a signed Polar checkout session embedding an HMAC-SHA256 org_binding_token for your tenant.

5. Authenticated Polar Billing Checkout

Paid plans (Team $249/mo, Growth $599/mo, Scale $1,299/mo) are initiated exclusively via POST /api/v1/orgs/:org/billing/checkout with a valid organization API key so every Polar subscription carries a server-signed HMAC-SHA256 org_binding_token verified on webhook delivery.

curl -X POST https://nhiascode.dev/api/v1/orgs/YOUR_ORG/billing/checkout \
  -H "Authorization: Bearer $NHI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"planTier":"team"}'