gitoria
All repositories: gitoria
6.0 KB
# W41 report — gitoria#41 repo owners can connect an app (branch w41-apps-connect, worktree W41/wt, base 06d622d)## BuiltOne commit `9af07ec` "gitoria#41: connect an app to a repo …" (not pushed, not deployed, no ticket written).- `lib/apps.hl`: table `apps.db` keyed by the repo's id (`repo`), rows {repo, name, hookUrl, keyHash (sha256 of gak_+40 hex), secret (64 hex, server only), createdBy, created, lastDelivery, lastStatus}; one row per (repo, name, case-insensitive), re-connect keeps the app id and replaces key + secret; `appOfKey(key)`; `removeApp` (row gone = key dead); `rotateSecret`; `addApp` (manual way B); `makeCode`/`exchangeCode` (table `appcodes.db`, only sha256 of the 48-hex code, deleted on first use, 5 minutes, only on the address of its own repo). Max 20 apps per repo.- `lib/apps-helpers.hl`: URL allow-list, `GITORIA_APP_HOSTS` config (default empty), key shape, `apiOf(slug)`, form parsing.- `lib/api.hl` (thin wrappers) + `lib/api-helpers.hl` `apiError` (contract §6 shape) + `project.hl` routes: `GET /settings/apps/connect` (and `/:orepo/…`), `POST /settings/apps/confirm`, `POST /api/apps/exchange`, `/api/:orepo/apps/exchange`, `/:orepo/api/apps/exchange`.- `components/settings.hl`: "Apps" section (owner: list with name, receiver host, added, last delivery status; Rotate secret; Remove; Add form; key/secret shown once in the page state of that click; the confirm card "Connect X to repo?" with Yes/No). Styles nested, one declaration per line, id rules.- Hook point: `pingAfterConnect(app, repo)` in `lib/apps.hl`, called after an exchange and after a manual Add; sends nothing (for gitoria#43).- README: env var `GITORIA_APP_HOSTS`, section "Apps". `tests/apps.mjs` (95 checks) added to GATES in deploy.sh.## Connect flow as builtApp sends browser → `/settings/apps/connect?app&hook&return&state`: hook/return checked (400 `invalid_url`), name/state checked (422 `invalid`), request parked in the session with a nonce (a session is minted if none) → redirect to the repo's `/settings` → signed out: "Sign in with the selector at the top"; the login callback keeps the same session so the card appears after sign-in; non-owner: "Only the owner…"; owner: Yes/No as a plain HTML form POST with the nonce (no hand-written JS) → `return?code&state` (No: `return?error=denied&state`). The owner check (`ownsRepo`) and the nonce are repeated at the POST; a wrong try does not use up the parked request. Exchange answers the §1 step 3 JSON.Allow-list: https + host `worldapi.org`/subdomain (no port, no user info, no IP, plain ASCII, ≤500 chars, lower-case `https` only), or url == base or starts with base + "/" from `GITORIA_APP_HOSTS` (plain http included, per Apollo's correction and contract v1.1). Tested: `http://100.77.141.84:8100.evil`, `:81000`, other ports, `worldapi.org.evil.com`, `evilworldapi.org`, `x.worldapi.org\@evil.com`, spaces, ftp, javascript:, empty all refused for both hook and return.## Tests (LC_ALL=C, ports 8730–8739, all free before and after)- `node tests/apps.mjs` 95 passed, 0 failed (new gate; flow, allow-list incl. 38 refusal checks, owner-only, re-connect, add/rotate/remove, org repo `acme/rev` with both exchange spellings, no key/secret/code in any page or the server log).- `node theme/check-theme.mjs .` 0 problems (58 files).- `node tests/browser.mjs` 265 passed, 0 failed (rerun with Chrome ports 8733-8738; the first run crashed with "no bindable port in 8735-8738" because I gave it only 4 Chrome ports, not a test failure).- signin-return 3/0, security 82/0, private 158/0, ident-access-gitoria 30/0 (these four are deploy.sh GATES).- Logs: W41/gates.log, W41/apps1.log.## Contract pointsCovered: §0 key/secret/api-base shapes; §1 flow A steps 1–3 and manual B, re-connect replaces, remove, rotate, allowed URLs (v1.1), §6 error shape for the routes I added.Not covered (by scope): step 4 ping (hook point only), tokens gat_ (#42), events/deliveries (#43), rate limits/413 (#47). `lastDelivery`/`lastStatus` stay empty ("no delivery yet").Deviations/choices to confirm: (1) an unknown, used, expired or wrong-repo code is `404 not_found` (the contract has no `invalid_code`). (2) The org exchange route: contract says `{repo address}/api/apps/exchange` (= `<org>/<repo>/api/apps/exchange`) but the API base for org is `<org>/api/<repo>`; I serve both. (3) The confirm card lives on `/settings` (not a separate page), because the login `next` keeps only the path. (4) Uppercase `HTTPS://` is refused (strict).## DOCS/GAP- GAP-1: `JSON.parse` of broken JSON ends the request with 500 (located error), no safe parse, no `req.json()`. Repro: `curl -XPOST -d '{broken' http://host/api/apps/exchange` → 500. Only a body not shaped like `{…}` gets the contract's 400 `invalid_json`; `{broken}` still 500. No workaround added.- GAP-2: a page component cannot read the query string and `route.path` has no query, so `?next=` of the login loses it; solved by parking in the session (fine, but a framework way would be shorter).- DOCS: a View `if` refuses `x != ''` ("declare it at the root"): needed `hasShownKey`.## Open risks / not done- NOT proven in his Chrome on lisbeth :9223 (WORKER-RULES "proof in his Chrome", multi-resolution screenshots). Only the headless gate (real HTTP, plus browser.mjs for existing pages) ran; no screenshot of the new Apps section was taken or looked at. The Add/Rotate/Remove face handlers are tested through the face endpoint, not by clicks in a browser. A follow-up must click Add/Rotate/Remove and the Yes form at 390 px and 1280 px.- The expiry of the 5-minute code is coded (`codeLifeMs`) but not tested (no clock control).- `appOfKey` has no caller yet (#42).- `secret` is stored plain in `apps.db` (server must sign); the face of Add/Rotate sends it to the owner's page once, by design.- The worktree's `bin` is a symlink to the main checkout's bin (not committed; `git status` clean).- Stopped: nothing left running (gates stop their own servers; `ss` shows no 873x listener, no Chrome with a W41 cwd). I started no background processes.- Requests used: about 40.
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 4a3f557eImport layouts theme ebd00b6 for W61 (startup blocked)mre
- 53ca42b2log: W60 merged, W61 W62 startedmre
- 80870a33mission W61: style passmre
- 560fd208Merge W60: helpers, bound forms, login in topics, two form fixes (gitoria#28 #32 #33)mre
- ac5ba6a4log: W60, #25 measuredmre
- 220f6342W60: record corrected form proof, full AE and remaining gapsmre
- 7e31cac5gitoria#28: restrict reply form layout to reply formsmre
- ae373cfdgitoria#28: keep each reply draft in its thread componentmre
- eeeebd5agitoria: insert a newly created organization oncemre
- 34d2d5cagitoria: clear the bound public-key textarea after creationmre
- 119e54c0W60: restore conductor-owned tracking filesmre
- 24b479e7W60: record final gates, Chrome failures and AE evidencemre
- 5e11184cW60: record partial validation, framework gaps and cleanupmre
- 20fe13fagitoria#33: centralize login and tickets connection statemre
- 859754c0gitoria#29: retain the offline note and record the framework gapmre
- d140bc04gitoria#30: reproduce the upsert ordering constraintmre
- 6960e8f8gitoria#28: keep form values in bound component membersmre
- 0db27200gitoria#32: share character checks and environment lookupmre
- 452f6a1amission W60: logic clean-upsmre
- 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre