Commit graph

27 commits

Author SHA1 Message Date
Stefan Hausotte
1ad2ee2607 fix: report security-key-blocked Basic auth instead of invalid credentials
Forgejo rejects username/password (Basic auth) for accounts with a
security key / passkey (WebAuthn) enrolled, responding 401 with
"Basic authorization is not allowed while having security keys enrolled".
This was misclassified as .invalidCredentials, showing "Invalid username
or password" and sending users in circles. Add a dedicated
.basicAuthBlockedBySecurityKey case that tells the user to use a token.

Also extract AuthenticationError into its own file.
2026-06-15 18:43:55 +02:00
Stefan Hausotte
485c147e7f release 0.8.0 2026-06-15 12:06:48 +02:00
Stefan Hausotte
81c74f6dc3 chore: formatting and function names 2026-06-15 12:06:27 +02:00
Stefan Hausotte
b78c57ffd9 feat: add Attachment model and image upload support
- Add Attachment model with isImage computed property
- Add assets field to Issue, IssueComment, and PullRequest
- Add multipart/form-data upload support to ForgejoClient
- Add uploadIssueAttachment and uploadCommentAttachment to IssueService
2026-06-15 09:48:47 +02:00
Stefan Hausotte
4d1dfc1305 release 0.7.0 2026-06-04 11:29:39 +02:00
Stefan Hausotte
167d61bc06 chore: improved formatting and linting 2026-06-04 11:29:23 +02:00
systemblue
551e1d01ea feat: add .bearer credential for OAuth access tokens (#4) 2026-06-04 11:15:25 +02:00
Stefan Hausotte
7352bc4b1f release 0.6.1 2026-05-17 21:26:30 +02:00
Stefan Hausotte
03829084c8 refactor: small code refactoring 2026-05-17 21:26:19 +02:00
pdurlej
81d8bc5b4a fix: preserve merge error context (#3)
Problem
- Merge failures currently collapse 405 and 409 responses to generic ServiceError cases, even when Forgejo returns a useful response body.

Change
- Keeps the existing notMergeable and mergeConflict fallbacks for empty responses.
- Preserves non-empty Forgejo response bodies as ServiceError.httpError for merge failures.
- Extracts the common JSON message field for clearer LocalizedError descriptions.

Tests
- DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test

Co-authored-by: Piotr Durlej <pdurlej@users.noreply.github.com>
Reviewed-on: https://codeberg.org/secana/ForgejoKit/pulls/3
2026-05-17 21:19:39 +02:00
Stefan Hausotte
2ab5808c34 release 0.6.0 2026-05-12 17:42:44 +02:00
pdurlej
8a5e513c50 feat: classify auth and service errors (#2)
Problem
- Callers currently need to inspect raw status codes to distinguish authentication, permission, not-found, and server failures.

Change
- Adds a small HTTPErrorCategory for 401, 403, 404, and 5xx responses.
- Exposes httpStatusCode and httpErrorCategory on ServiceError and AuthenticationError.
- Keeps the existing AuthenticationError cases intact and centralizes status-to-auth-error mapping.

Tests
- DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test

Co-authored-by: Piotr Durlej <pdurlej@users.noreply.github.com>
Reviewed-on: https://codeberg.org/secana/ForgejoKit/pulls/2
Reviewed-by: secana <secana@noreply.codeberg.org>
2026-05-12 17:41:24 +02:00
Stefan Hausotte
b87e4980a0 release 0.5.0 2026-05-07 18:56:59 +02:00
Stefan Hausotte
21149d4b45 feat: add "hasActions" flag to repo 2026-05-07 18:56:46 +02:00
Stefan Hausotte
3030629b36 release 0.4.0 2026-05-07 16:45:14 +02:00
Voislav Vasiljevski
3967a1ba79 feat: add Forgejo Actions runs API (#1)
New model:
  - WorkflowRun — mirrors Forgejo's ActionRun schema (id, title, status,
    event, indexInRepo, commitSha, prettyRef, workflowId, created, updated,
    started, stopped, durationNanos, htmlUrl, triggerUser, repository).

New service:
  - WorkflowService
      - fetchRuns(owner:repo:status:event:ref:workflowId:runNumber:headSha:page:limit:)
        backed by GET /repos/{owner}/{repo}/actions/runs.
      - fetchRun(owner:repo:runId:) backed by
        GET /repos/{owner}/{repo}/actions/runs/{run_id}.

Experimental:
  - fetchRunView(owner:repo:runIndex:jobIndex:logCursors:) backed by
    Forgejo's web-UI route POST
    /{owner}/{repo}/actions/runs/{runIndex}/jobs/{jobIndex}/attempt/{N}.
    This is not part of /api/v1 and may change between Forgejo releases;
    it lets clients render jobs, steps, and step logs (via WorkflowRunView,
    WorkflowRunViewJob, WorkflowRunViewStep, WorkflowLogCursor types).
  - ForgejoClient.discoverRedirectLocation(url:) helper that resolves
    Forgejo's RedirectToLatestAttempt without consuming the redirect
    target — used to find the latest attempt number before POSTing.

Co-authored-by: Voislav Vasiljevski <voislav@voioo.cz>
Reviewed-on: https://codeberg.org/secana/ForgejoKit/pulls/1
Reviewed-by: secana <secana@noreply.codeberg.org>
2026-05-07 16:42:16 +02:00
Stefan Hausotte
c31ce0d267 release 0.3.2 2026-03-22 11:49:58 +01:00
Stefan Hausotte
4c786f4f73 fix: pascal case needed for merge message an titel 2026-03-22 11:49:42 +01:00
Stefan Hausotte
954d5b5064 release 0.3.1 2026-03-22 11:29:07 +01:00
Stefan Hausotte
7da2d2ce0d fix: missing merge titel in PRs 2026-03-22 11:29:01 +01:00
Stefan Hausotte
373b29a21b release 0.3.0 2026-03-22 11:15:21 +01:00
Stefan Hausotte
271839d21b feat: add fetchRepository function 2026-03-22 11:15:10 +01:00
Stefan Hausotte
a73f044623 release 0.2.0 2026-03-11 22:17:50 +01:00
Stefan Hausotte
f576906931 fix: lint errors 2026-03-11 22:17:20 +01:00
Stefan Hausotte
0c2fc12ded feat: add new models and services
New model:
  - Token — id, name, sha1, tokenLastEight

New services:
  - AdminService — createUser()
  - UserService — createToken()

RepositoryService additions:
  - createRepository()
  - editRepository()
  - createLabel()
  - createMilestone()
  - addCollaborator()
  - createFile()

remove MARKS
2026-03-11 21:57:40 +01:00
Stefan Hausotte
42c5ec0ea6 fix: failing release command 2026-02-28 20:33:38 +01:00
Stefan Hausotte
897a8ebedd feat: initial commit
Intitial commit for ForgejoKit, a native Swift library to interact with
the Frogejo API
2026-02-28 20:25:57 +01:00