You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3.**Homepage URL:** (Optional, your GitHub profile/repo URL).
60
-
4.**Callback URL:** If using a web-backend like Cloudflare Workers, use `https://<your-worker-url>.workers.dev/auth/github/callback`. For Chrome Extension direct flows, use `https://<extension-id>.chromiumapp.org/`.
60
+
4.**Callback URL:** If using a web-backend like Cloudflare Workers, use `https://<your-worker-url>.workers.dev/api/auth/github/callback`. For Chrome Extension direct flows, use `https://<extension-id>.chromiumapp.org/`.
61
61
5.**Webhook:** Disable Webhook (Active: false).
62
62
6.**Permissions:**
63
63
***Repository Permissions:**
@@ -76,7 +76,7 @@ sequenceDiagram
76
76
participant GitHub as GitHub OAuth API
77
77
78
78
User->>Extension: Clicks "Connect GitHub"
79
-
Extension->>CFWorker: Opens popup to /auth/github
79
+
Extension->>CFWorker: Opens popup to /api/auth/github
80
80
CFWorker->>GitHub: Redirects user to GitHub Authorize URI
81
81
GitHub-->>User: Prompts for permission (repo scope)
BG -->|GraphQL/REST| Git[GitHub API - Tree Commit]
@@ -41,7 +41,7 @@ sequenceDiagram
41
41
```
42
42
43
43
**Explanation:**
44
-
Upon installation or startup, the Service Worker initializes `BasePlatformHandler`, `BaseGitHandler`, and `BaseAIHandler` instances. This design means that adding a new platform (like HackerRank) only requires writing a single isolated class and registering it.
44
+
Upon installation or startup, the Service Worker initializes `BasePlatformHandler`, `BaseGitHandler`, and `BaseAIHandler` instances. This design means that adding a new platform (like HackerRank) only requires writing a single isolated class and registering it.
45
45
46
46
## 3. GitHub Secure OAuth Flow
47
47
@@ -51,11 +51,11 @@ Since MV3 service workers and cross-origin isolation make OAuth tricky without h
51
51
sequenceDiagram
52
52
participant User
53
53
participant Ext as CodeLedger
54
-
participant CF as Cloudflare Worker (/auth/github)
54
+
participant CF as Cloudflare Worker (/api/auth/github)
55
55
participant GH as GitHub OAuth
56
-
56
+
57
57
User->>Ext: Clicks Login
58
-
Ext->>CF: Popup window to /auth/github
58
+
Ext->>CF: Popup window to /api/auth/github
59
59
CF->>GH: Redirect to authorization UI
60
60
User->>GH: Approves
61
61
GH->>CF: Callback with ?code=XXX
@@ -76,16 +76,16 @@ CodeLedger uses the GitHub Git Data APIs (`/git/trees`, `/git/commits`, `/git/re
76
76
sequenceDiagram
77
77
participant BG as Background Worker
78
78
participant GH as GitHub API (Trees)
79
-
79
+
80
80
BG->>GH: GET /git/refs/heads/main
81
81
GH-->>BG: Return base commit SHA
82
-
82
+
83
83
BG->>GH: POST /git/trees (Files & prev SHA)
84
84
GH-->>BG: Return new tree SHA
85
-
85
+
86
86
BG->>GH: POST /git/commits (Tree SHA & Parent SHA)
87
87
GH-->>BG: Return new commit SHA
88
-
88
+
89
89
BG->>GH: PATCH /git/refs/heads/main (New commit SHA)
**Webhook secret**: generate a strong random secret and store it as an environment variable in your Cloudflare Worker (e.g. `GITHUB_APP_WEBHOOK_SECRET`).
14
14
@@ -49,8 +49,8 @@ Example GitHub App manifest (use via GitHub App creation flow):
2. In the Cloudflare dashboard, create a new Worker, choose "Upload a script" or use the online editor and paste `worker/src/index.js`.
88
88
3. In Worker settings, add the environment variables listed above under "Variables" (or "Secrets/Environment").
89
89
4. If your Worker serves static assets (worker/public), configure a KV or Pages deployment, or copy the static assets into the Worker script's `serveStatic` root.
90
-
5. Test the endpoints: `/auth/github` should redirect to GitHub, `/auth/github/callback` should return a small HTML page that posts the token back to the opener window.
90
+
5. Test the endpoints: `/api/auth/github` should redirect to GitHub, `/api/auth/github/callback` should return a small HTML page that posts the token back to the opener window.
91
91
92
92
Notes on the two auth modes:
93
93
@@ -97,21 +97,42 @@ Notes on the two auth modes:
97
97
98
98
Deploying the worker from this repository (recommended GitHub Actions flow):
-`CODELEDGER_GH_APP_CLIENT_ID` — (optional) OAuth client id if using OAuth flow.
109
+
-`CODELEDGER_GH_APP_CLIENT_SECRET` — (optional) OAuth client secret if using OAuth flow.
110
+
-`CODELEDGER_GH_APP_WEBHOOK_SECRET` — Webhook secret to validate GitHub webhooks.
102
111
103
-
Quick local steps to publish the worker (you must have `wrangler` installed):
112
+
> Note: GitHub Actions disallows repository secret names that begin with `GITHUB_`. That is why the CI and repo are configured to use the `CODELEDGER_GH_*` mapping instead of `GITHUB_*`.
113
+
114
+
- The included workflow (`.github/workflows/deploy-worker.yml`) will:
115
+
1. Generate a runtime `worker/wrangler.toml` using `CF_ACCOUNT_ID` and `CANONICAL_KV_ID`.
116
+
2. Upload the runtime secrets listed above to Cloudflare (via `wrangler secret put`).
117
+
3. Publish the Worker to the route `https://codeledger.vkrishna04.me/*` (landing + API).
118
+
119
+
Quick local steps to run a smoke test (no CI required):
104
120
105
121
```powershell
106
122
cd worker
107
-
wrangler login
108
-
wrangler publish
123
+
npm ci
124
+
# Start a local dev server for the Worker (requires Wrangler installed)
125
+
npx wrangler dev --local
109
126
```
110
127
128
+
Notes:
129
+
- If you prefer CI-based deployment, ensure `CF_API_TOKEN` and all required secrets are set in the repository before triggering the workflow — otherwise the workflow will fail early during validation.
130
+
- If you want me to trigger the workflow now, I can do that (I will check whether `CF_API_TOKEN` exists in repo secrets first). Alternatively I can run `wrangler dev` locally for a smoke test instead.
131
+
111
132
If you want, I can:
112
133
113
134
- Add a `docs` page with a sample `worker/.env.example` and the minimal `worker/src/index.js` auth routes wired to the App settings.
114
-
- Prepare a GitHub Actions workflow that deploys the worker using `CLOUDFLARE_API_TOKEN`.
135
+
- Prepare or run the GitHub Actions workflow that deploys the worker using `CF_API_TOKEN`.
constprompt=`Review this DSA solution for "${problemContext.title}". Language: ${problemContext.language}, Difficulty: ${problemContext.difficulty}. Code: \`${code}\`. Provide Time/Space complexity, optimizations, and key patterns.`;
0 commit comments