tickets
All repositories: gitoria
3.0 KB
# Connecting an app to a tickets project (for app workers, e.g. gitoria)Source of truth: `README.md` section "Connecting an app to a project" of tickets.worldapi.org. Base URL: `https://tickets.worldapi.org`.Always send a `user-agent` header (Cloudflare blocks default script agents).## 1. Send the browser to tickets`GET /connect?app=<name>&label=<owner/repo>&return=<url>&state=<opaque>`- `app` required (≤ 60 chars); `label`, `state` optional (state ≤ 200 chars, comes back unchanged).- `return` = the app's page that receives the answer: https on `worldapi.org` or a subdomain (dev copies: an origin listed in thetickets env `TICKETS_CONNECT_ORIGINS`). Max 500 chars, URL-safe characters only, no `#`. Otherwise `400` with a reason.- Answer: redirect to `/connect/<nonce>`. There the person logs in (ident), picks a project they are ADMIN of (or makes a new one) and confirms.## 2. The return redirectThe browser comes back to `<return>?code=<one-time code>&state=<state>` (`?` becomes `&` if `return` already has a query).The code is valid 5 minutes and works once. The request itself is valid 1 hour.## 3. Exchange (from the app's SERVER, never the browser)`POST /api/connect/exchange` with `Content-Type: application/json`, body `{"code": "<code>"}`→ `200 {"key": "tktc_<48 hex>", "project": "<slug>", "title": "<title>", "api": "https://tickets.worldapi.org/api/projects/<slug>"}`.Wrong / used / expired code → `400 {error}`. GET → 405. The key is shown ONCE; store it like a secret.A second connection of the same app + label to the same project replaces the first (old key dies). An admin can disconnect: key dies at once.## 4. Using the keyEvery call: `Authorization: Bearer tktc_…` and, on every write, `X-Tickets-Identity: <ident public id of the person>`.The person must have logged in to tickets once and chosen a display name; the project's roles apply to them. The person is the author.The key reaches ITS project only (other project → 403; no/unknown identity → 403 naming the header) and only these writes (JSON, strict — unknown fields → 400):| what | request | body ||---|---|---|| create ticket | `POST <api>/tickets` | `{"subject": "…", "summary"?: "…", "source"?: "…", "assignee"?: "…"}` || event: comment | `POST <api>/tickets/<n>/comments` | `{"text": "…"}` (Markdown) || event: state change | `POST <api>/tickets/<n>/state` | `{"state": "…", "text"?: "…"}` |`<api>` = the `api` value from the exchange (`/api/projects/<slug>`). Create answers `201 {ticket, existed}` (`200` if the same ticket exists)."Mentioned in PR" / "fixed by commit" = a comment, or a state change with a `text`. Any other endpoint with a key → 401.Reads need no key: `GET <api>/tickets`, `GET <api>/tickets/<n>` (add `Accept: text/markdown` for the Markdown view),`GET /api/projects/<slug>/connections` (who is connected).```bashcurl -s -A gitoria -H "Authorization: Bearer $KEY" -H "X-Tickets-Identity: $IDENT_ID" \-H 'content-type: application/json' -d '{"text":"Fixed by commit abc123"}' "$API/tickets/7/comments"```
Branches
Latest commits
- 18d2df60md-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- f6764bedreports/H1-hydrate.mdmre
- 1bbbf0edtests/browser.mjs: wait for hydration before clicking the login button on / (device B)mre
- 6f503cfctests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
- e17e2855re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- a6ddccd2re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- 81e036b7docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 5d8d2cf6deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- 58e8c02cmission 024: report, LOG, STATUS, e2e fixmre
- 50778073tests/e2e-route-marker.mjs: first paint marker, comments post/edit redrawmre
- c5203298mission 024: MainMenu marks the page from the route (layouts 0bcc629 main-menu.hl); browser-side marker removed; gate: marker in the server HTMLmre
- b1a4c270re-vendor Hybriel master f9614007: bin/ (git-ignored) and plugins wholemre
- 866397a0mission 023: theme from layouts 76f99f6 (current marker, menu count badge), components from 3794c59 (MdEditor keys); Inbox count as badge, current by address; gates and E2E; reportmre
- 7ed2e5e5deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail), as gitoria/layoutsmre
- bf9064a3mission 022: tickets on the layouts theme (step 1): shell, styles, gates, audit, E2E; reportmre
- f3d61711mission 022 WIP: tickets on the layouts theme (dbe3de7): AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst shell, styles reduced to the app's own, check-theme in the gates, 390 audit + real-Chrome walk scriptmre
- 31cabfccmission 021: E2E script, report, LOG, STATUSmre
- 6aea8683editor look: .empty rule only for p.empty, files off where tickets has no upload, state note one line, events test scrolls the editor into view; synced md-editor (components d702d76+6f27ad3); gate 377/0, events 52/0mre
- dce6ffa6Merge branch 'w28-deflake'mre
- 536092a1tickets (mission 019): de-flake the m016 comment clicks (B: unliked) — calmClick waits until the button stops moving; test only, no app changemre