← Commit history
Publish 1.1.10
7 files changed
+111−15
README.md+4@@ -45,3 +45,7 @@ adom-molecule create --source fusion --name "Enclosure" --owner john \ - Binary: ~3.3 MB (Linux x86_64) ++## Private pages++`adom-molecule import <owner>/<slug> --owner <you>` works on **private** wiki pages since 1.1.10: the wiki reads carry the container credential (`Authorization: Bearer`) and the owner-qualified `wikiRef` lets Hydrogen re-read the page with the same credential. A page you cannot see 404s (by the wiki's design); nothing has to be made public.
adom-molecule⋯ 1 unchanged line ⋯
docs/switch-to-x-api-key.mdadded+90@@ -0,0 +1,90 @@+# Switch `adom-molecule` CLI auth from `Authorization: Bearer` to `X-Api-Key`++## Background++The molecule CLI talks to Hydrogen's molecule API (`/api/molecules/*`). Hydrogen+was just updated (Hydrogen repo) to authenticate and **authorize** those+endpoints using the same convention as the editor/panels API:++- **Browser users** → `session_token` cookie+- **AI / containers / CLI** → `X-Api-Key` header (a Carbon `c_`-prefixed token)++Hydrogen resolves the caller's identity from Carbon `GET /user`, their org+membership from `GET /user/orgs`, and **enforces that the target `owner`/+`username` is the caller's own username, an org they belong to, or that the+caller is an admin**. S3 itself is unauthenticated; Carbon is the identity+authority; Hydrogen enforces ownership.++The CLI currently sends `Authorization: Bearer <token>`. Hydrogen does **not**+read that header for the molecule endpoints — it reads `X-Api-Key`. So the CLI+must switch headers.++> Note: the token *value* is unchanged. Carbon accepts the same `c_…` token; only+> the header name on the request to Hydrogen changes.++## Scope of this issue (CLI repo only)++`src/client.rs`:++1. In `apply_auth()` (or wherever the auth header is attached), send the token as+ the `X-Api-Key` header instead of `Authorization: Bearer <token>`.+ - Apply it to every authenticated call: `get_json`, `post_json`, `delete`,+ `post_multipart`.+ - `head_ok` (health) stays unauthenticated.+2. Keep the existing 3-tier token resolution unchanged+ (`~/.config/adom-cli/config.json` `api_token` → `ADOM_API_TOKEN` env →+ `/var/run/adom/api-key`).++Example (ureq):++```rust+fn apply_auth(req: ureq::Request) -> ureq::Request {+ match resolve_token() {+ Some(token) => req.set("X-Api-Key", &token),+ None => req,+ }+}+```++That's the whole code change. No new dependencies.++## Why no Hydrogen-side change is needed for the internal S3 hop++For info only: `create`/`delete`/`generate-json` internally call+`/api/curium/get-s3-api-key` to fetch the shared S3 key. SvelteKit does not+auto-forward custom headers like `X-Api-Key` to internal `fetch`es, so Hydrogen+now threads the token explicitly into `CuriumClientTs.create(fetch, token)`.+That is already handled in Hydrogen — the CLI just needs to send `X-Api-Key`.++## Test plan++Against a CLI build pointed at prod Hydrogen (`ADOM_HYDROGEN_URL`,+default `https://hydrogen.adom.inc`):++1. **Own user:** `adom-molecule create --owner <your-username> ...` → succeeds.+2. **Member org:** `--owner <an-org-you-belong-to>` → succeeds.+3. **Forbidden owner:** `--owner <an-owner-you-do-NOT-belong-to>` →+ Hydrogen returns **403** (`Forbidden - <you> cannot act on behalf of '<owner>'`).+4. **No / bad token:** unset all token sources → **401**.+5. `delete`, `optimize` (queue), and `create` all exercise the same auth path —+ smoke-test each.++Quick header sanity check (token belongs to `kcknox`):++```sh+curl -sk -H "X-Api-Key: c_…" https://carbon.adom.inc/user # 200 + identity+curl -sk -H "X-Api-Key: c_…" https://carbon.adom.inc/user/orgs # 200 + org list+```++## Out of scope (separate follow-ups)++- **Unify resolvers:** Hydrogen now has two near-identical token resolvers —+ `src/lib/server/editorAuth.ts` (`resolveCallerIdentity`) and the new+ `src/lib/server/apiAuth.ts` (`resolveCaller`). Collapse to one shared helper.+- **`/api/workspaces/repo/[owner]/[repo]/current`** (the non-`editor` workspace+ endpoints) authenticate by forwarding the browser cookie to Carbon with+ `credentials: 'include'`; they have no `X-Api-Key` path and won't work for+ containers. Decide whether containers ever need them and gate accordingly.+- Consider adding `X-Api-Key` support to any other non-editor mutating routes+ surfaced during review.+```
install.sh−12@@ -20,18 +20,6 @@ if [ -w "$(dirname "$DEST")" ]; then install -m 0755 "$TMP_BIN" "$DEST"; else su rm -f "$TMP_BIN" echo "Installed adom-molecule ${VER} → $DEST" -# A stale copy/symlink in ~/.local/bin wins on PATH and shadows this install —-# the user then keeps running the OLD binary after every update (field report:-# adom/molecule-pipeline #190, rule 5). Clear any shadow that isn't $DEST.-SHADOW_USER="${SUDO_USER:-$(id -un)}"-SHADOW_HOME="$(getent passwd "$SHADOW_USER" | cut -d: -f6)"-for shadow in "$SHADOW_HOME/.local/bin/adom-molecule" "$HOME/.local/bin/adom-molecule"; do- if { [ -e "$shadow" ] || [ -L "$shadow" ]; } && [ "$shadow" != "$DEST" ]; then- echo "Removing stale shadow install: $shadow (was masking $DEST)" >&2- rm -f "$shadow"- fi-done- # Skills: root SKILL.md = the adom-molecule skill; sub-skills under skills/<name>/. # Copy real files (no symlinks), clearing any prior dir or symlink from an old install. # Under sudo, $HOME is /root — resolve the REAL user's home via SUDO_USER so the
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "adom-molecule",- "version": "1.1.9",+ "version": "1.1.10", "type": "app", "description": "Adom Molecule CLI \u2014 import a wiki molecule into Hydrogen (reuses the published GLB, no re-optimization), plus create/optimize/list/delete from KiCad, Fusion 360, and EasyEDA files.", "needs_sudo": true,
page.json+1−1@@ -1,6 +1,6 @@ { "slug": "adom-molecule",- "version": "1.1.9",+ "version": "1.1.10", "type": "app", "description": "Adom Molecule CLI — import a wiki molecule into Hydrogen (reuses the published GLB, no re-optimization), plus create/optimize/list/delete from KiCad, Fusion 360, and EasyEDA files.", "needs_sudo": true,
skills/adom-molecule-import/SKILL.md+15−1@@ -90,6 +90,20 @@ Print the result URL: `hydrogen.adom.inc/<owner>/molecules/<name>`. - **Don't re-optimize.** Reuse the GLB. If there's no GLB, surface the gap — don't fall into the silkscreen trap. - The clean long-term fix (so the no-GLB branch disappears) is upstream: have molecule publishing push the optimized GLB to the wiki for Fusion molecules too. Flag it when you hit a no-GLB molecule. +## The one-command path (adom-molecule >= 1.1.10) — use this first++```bash+adom-molecule import <owner>/<slug> --owner <your-owner> [--name <name>]+```++The native verb does everything above in one step, **including private pages**:+its wiki reads carry the container credential (`Authorization: Bearer`), and it+passes an owner-qualified `wikiRef` to Hydrogen's `/api/molecules/import`, which+re-reads the page with the same credential. Nothing has to be made public, and+the manual clone → `create --no-optimize` chain below is only the fallback for+containers pinned to an older CLI. Always pass `<owner>/<slug>` — a bare slug is+resolved through the wiki but errors if the slug exists under several owners.+ ## Related-- `adom-molecule` — the underlying CLI (`create`, `list`, `health`). A native `import <slug>` verb may exist in newer versions; prefer it if present (`adom-molecule import --help`).+- `adom-molecule` — the underlying CLI (`import`, `create`, `list`, `health`). - `adom-molecules` / `adom-molecules-catalog` — what molecules exist / SKUs.