Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>RubberDuckCrew/.github//configs/renovate/renovate-rubberduckcrew.json"
],
"extends": ["github>RubberDuckCrew/.github//configs/renovate/renovate-rubberduckcrew.json"],
"reviewers": ["team:cloudflare-worker-development"]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"**/Thumbs.db": false
},
"explorerExclude.backup": {}
}
}
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
# gitdone-cloudflare-worker
# gitdone-cloudflare-worker

Cloudflare Worker for the GitDone login flow. The worker accepts an OAuth callback POST request, validates the payload, rate-limits requests per IP, and exchanges the `code` for a GitHub access token.

## Required secrets

The worker expects these environment values:

- `CLIENT_ID`
- `CLIENT_SECRET`

## API

### Request

- **Method:** `POST`
- **Content-Type:** `application/json`

Example body:

```json
{
"code": "oauth_code_from_callback",
"code_verifier": "pkce_verifier"
}
```

### Responses

- `200 OK` – GitHub OAuth response returned as JSON
- `400 Bad Request` – invalid JSON or missing fields
- `405 Method Not Allowed` – when the request is not `POST`
- `429 Too Many Requests` – rate limit exceeded
- `500 Internal Server Error` – missing GitHub credentials

## Rate limiting

- Counted per IP address using `CF-Connecting-IP`
- Window: **10 minutes**
- Maximum: **10 requests** per IP per window
5 changes: 1 addition & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ import js from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';

export default defineConfig(
js.configs.recommended,
tseslint.configs.recommended,
);
export default defineConfig(js.configs.recommended, tseslint.configs.recommended);
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
const githubRes = await fetch('https://github.com/login/oauth/access_token', {
method: 'POST',
headers: {
'Accept': 'application/json',
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: params.toString(),
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ export type OAuthRequestBody = {
code: string;
code_verifier: string;
};

4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@

/* Skip type checking all .d.ts files. */
"skipLibCheck": true,
"types": [
"./worker-configuration.d.ts"
]
"types": ["./worker-configuration.d.ts"]
},
"exclude": ["test"],
"include": ["worker-configuration.d.ts", "src/**/*.ts"]
Expand Down
Loading