gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb487b05ab487b05aRecord verified direct push protocol handoffmreb487b05a/docs/connect-apps.md

3.0 KB

  1. # Connecting an app to a tickets project (for app workers, e.g. gitoria)
  2. Source of truth: `README.md` section "Connecting an app to a project" of tickets.worldapi.org. Base URL: `https://tickets.worldapi.org`.
  3. Always send a `user-agent` header (Cloudflare blocks default script agents).
  4. ## 1. Send the browser to tickets
  5. `GET /connect?app=<name>&label=<owner/repo>&return=<url>&state=<opaque>`
  6. - `app` required (≤ 60 chars); `label`, `state` optional (state ≤ 200 chars, comes back unchanged).
  7. - `return` = the app's page that receives the answer: https on `worldapi.org` or a subdomain (dev copies: an origin listed in the
  8. tickets env `TICKETS_CONNECT_ORIGINS`). Max 500 chars, URL-safe characters only, no `#`. Otherwise `400` with a reason.
  9. - 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.
  10. ## 2. The return redirect
  11. The browser comes back to `<return>?code=<one-time code>&state=<state>` (`?` becomes `&` if `return` already has a query).
  12. The code is valid 5 minutes and works once. The request itself is valid 1 hour.
  13. ## 3. Exchange (from the app's SERVER, never the browser)
  14. `POST /api/connect/exchange` with `Content-Type: application/json`, body `{"code": "<code>"}`
  15. → `200 {"key": "tktc_<48 hex>", "project": "<slug>", "title": "<title>", "api": "https://tickets.worldapi.org/api/projects/<slug>"}`.
  16. Wrong / used / expired code → `400 {error}`. GET → 405. The key is shown ONCE; store it like a secret.
  17. 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.
  18. ## 4. Using the key
  19. Every call: `Authorization: Bearer tktc_…` and, on every write, `X-Tickets-Identity: <ident public id of the person>`.
  20. 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.
  21. 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):
  22. | what | request | body |
  23. |---|---|---|
  24. | create ticket | `POST <api>/tickets` | `{"subject": "…", "summary"?: "…", "source"?: "…", "assignee"?: "…"}` |
  25. | event: comment | `POST <api>/tickets/<n>/comments` | `{"text": "…"}` (Markdown) |
  26. | event: state change | `POST <api>/tickets/<n>/state` | `{"state": "…", "text"?: "…"}` |
  27. `<api>` = the `api` value from the exchange (`/api/projects/<slug>`). Create answers `201 {ticket, existed}` (`200` if the same ticket exists).
  28. "Mentioned in PR" / "fixed by commit" = a comment, or a state change with a `text`. Any other endpoint with a key → 401.
  29. Reads need no key: `GET <api>/tickets`, `GET <api>/tickets/<n>` (add `Accept: text/markdown` for the Markdown view),
  30. `GET /api/projects/<slug>/connections` (who is connected).
  31. ```bash
  32. curl -s -A gitoria -H "Authorization: Bearer $KEY" -H "X-Tickets-Identity: $IDENT_ID" \
  33. -H 'content-type: application/json' -d '{"text":"Fixed by commit abc123"}' "$API/tickets/7/comments"
  34. ```

Branches

Latest commits

  • b487b05aRecord verified direct push protocol handoffmre
  • 74e34cc3Verify encrypted push secrets and direct push retry semanticsmre
  • a1ac5cd0Push subscription notices directly to signed HyperConductor chat endpointsmre
  • d662ad27Remove superseded waker service for direct chat push protocolmre
  • ff2e8701Finalize subscription build verification and handoff reportmre
  • 54bc5fe1Harden delta relevance, overflow caps and retry verificationmre
  • 8d8e2053Document subscription contract and exercise delta deliverymre
  • fd23726aAdd subscription delta API and signed wake bridgemre
  • c5d28fb5Tickets conductor: S51 startedmre
  • fd6ca1e6Tickets conductor: brief 027 waker design, push-test projectmre
  • e448e656Tickets conductor: STATUS #51mre
  • 1c10857bTickets conductor: P51 eval, brief 027mre
  • e725969dTickets conductor: #51 directionmre
  • 1b5c63ddTickets conductor: P51 startedmre
  • 9f13fbdaTickets conductor: brief 026 prioritymre
  • acc477d9Tickets conductor: brief 026 + Vinzenz recommendationsmre
  • 9233a734Tickets conductor: brief 026 completemre
  • 5da589fdTickets conductor: brief 026 + Gitoria's answermre
  • a3cd5329Tickets conductor: tickets#51 opened, brief 026 draftmre
  • 6f6e5797Tickets conductor: STATUS wordingmre