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
- 81f10e4eident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- f51029abMerge branch 'sy-sync'mre
- eae6e8c7sync components.hybriel 4922f9c: comments like / Edit / Delete / 'edited' are 44 px targets; gate: 'edited' hit-area padding, thread targets check (SY)mre
- 0de4750btheme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
- 4eeb7bfeST2 report wordingmre
- 2558f56cst2-sec: keep the hlsid session cookie name (no one is signed out), Secure flag only; gate: a cookie issued by main stays signed in; ident stub serves selector.js; security.mjs in deploy GATESmre
- ea2e440esecurity audit (ST): JSON body cap, relation rights, login session rotation, __Host- Secure cookie, API security headers, CSP+referrer meta, /connect cap, one-line subjects, tests/security.mjs, reportmre
- 7c8c2282sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
- b6277497report MT-mobile, LOGmre
- 6709398blist paging: the newest rows come first (the sorted array was not used); filter rows hide their scrollbar; gate checks the ordermre
- 31736a80gate: member-name check fails on the old row layout toomre
- e03ae537gate: the phone checks run on without the Show more button (so old code reports every failed check)mre
- adf7f132gate: 390 px checks for the mobile audit fixes (row number, filters, field widths, Edit, member names, relation taps, paging)mre
- 28e9c938ticket list: draw the newest 50 rows and a Show more button (500 rows were a 2-4 s first paint, 740 KB, a 90 000 px phone page)mre
- ccebb0c7mobile: ticket number stays on one line, filter chips one scrolling row, fields full width under their caption, Edit/action buttons, member names whole, 44 px relation linksmre
- f2dc7741gate: the phone toolbar is two even rows (E2)mre
- 20f7c33async components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
- d74a5482sync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
- 9d02c540sync components.hybriel 6b0936a: the 'edited' foldable drops the theme's border and marginmre
- 22751914sync components.hybriel 8d79ff7: bubble hugs its content, quiet 'edited' label; gate checksmre