Files
rUv 8b8127d75e feat(iot): COGNITUM_SEED_TOKEN bearer auth via .env (1.0.0-alpha.5) (#1684)
The bin shim now loads .env from CWD (or any parent) without overwriting
existing env vars, then reads COGNITUM_SEED_TOKEN. When present:
  - Default endpoint switches from http://169.254.42.1 (link-local, no auth)
    to https://169.254.42.1:8443 (LAN/HTTPS, bearer)
  - The token is passed as the pairing/bearer token on `register`
  - All subsequent SDK calls use the bearer-authenticated session

Verified end-to-end against a live Seed: bearer-authed register, status,
mesh, witness, query all work over HTTPS:8443. Self-signed dev cert is
tolerated via NODE_TLS_REJECT_UNAUTHORIZED=0 in the smoke harness;
plugin/SDK tolerance via tlsInsecure config (default true).

Smoke results with bearer: 22/25 pass. The 3 remaining failures are
real Seed-side state (rate-limited pair window from prior runs, SDK
trust-score circuit breaker after repeated unauthorized attempts in
the same in-process run, and store/ingest correctly classified as
needing a write-scoped token vs. our read-scoped one).

Plugin source (src/bin.ts):
- New loadDotenv() walks up from CWD looking for .env, parses KEY=VALUE
  lines (handles quoted values, comments, blanks), sets process.env
  without overwriting.
- SEED_DEFAULT_ENDPOINT = COGNITUM_SEED_ENDPOINT ?? (token ? lan : link-local)
- register handler auto-injects --token from env if not explicitly passed
- --help banner shows token status and endpoint mode

Smoke harness:
- Loads same .env, picks endpoint+token automatically
- pair-window opener now checks status first (avoids HTTP 429 on already-open),
  passes bearer when available
- ingest failure now classified as expected-on-read-scope-tokens

Plugin README documents .env setup, COGNITUM_SEED_TOKEN, optional
COGNITUM_SEED_ENDPOINT/IOT_FLEET_ID/IOT_ZONE_ID/IOT_TLS_INSECURE overrides,
and the read-vs-write token scope distinction.

Bump to 1.0.0-alpha.5; published to npm (alpha + latest).

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-04-30 13:25:52 -04:00
..