-
Web OAuth Flow (~120 lines)
/oauth/authorizeendpoint/oauth/callbackendpoint- Associated handler functions
-
CORS Handling (~25 lines)
- CORS headers
- Preflight handling
ALLOWED_ORIGINSconfiguration
-
Security Headers (~10 lines)
- CSP headers
- X-Frame-Options
- X-Content-Type-Options
-
Unused Helper Functions (~75 lines)
base64UrlEncode()base64UrlDecode()pemToArrayBuffer()githubRequest()createAppJWT()verifyGitHubToken()checkRepositoryAccess()getAppInstallationPermissions()validatePermissions()getInstallationId()
-
Installation Token Support (~115 lines)
/tokenendpoint (entire function)- All authentication/validation logic
-
Tests (~160 lines)
- OAuth endpoint tests
- CORS tests
- JWT tests
- Authentication tests
- Code reduction: ~50% fewer lines of code
- Complexity: Significantly simpler architecture
- Dependencies: No JWT signing, no complex auth
- Testing: From 7 tests to 2 essential tests
- Device Flow endpoints (the only thing ai-aligned-gh needs)
- Minimal configuration (just GITHUB_CLIENT_ID)
- Simple error handling
- Health check endpoint (optional, could be removed)
Since ai-aligned-gh is a CLI tool that:
- Only needs device flow (not web OAuth)
- Doesn't need CORS (not a browser)
- Doesn't need complex security headers (API-only)
- Doesn't need installation tokens (wants user attribution)
The simplified version is perfect for its use case while being much easier to maintain.