This document explains how the GitHub Sponsors authentication feature works in Demo Time.
Demo Time now supports GitHub OAuth authentication to verify sponsor status and unlock Pro features for sponsors who contribute €10 or more per month.
-
Authentication Flow
- Users run the command
Demo Time: Authenticate with GitHub (Unlock Pro Features) - VS Code's authentication provider prompts for GitHub OAuth
- Required scopes:
read:userandread:org - Access token is stored securely by VS Code
- Users run the command
-
Sponsor Verification
- On extension activation, the sponsor status is checked silently
- If authenticated, the extension calls the sponsor verification API
- The API response determines if Pro features are unlocked
- Status is stored in workspace state and exposed via context key
-
State Management
StateKeys.sponsor: Stores boolean sponsor status in workspace stateContextKeys.isSponsor: VS Code context key for conditional UI/features
The sponsor verification API is hosted at https://demotime.show/api/sponsor
Request:
POST /api/sponsor
Content-Type: application/json
{
"token": "<github-access-token>"
}Response:
{
"isSponsor": true
}Logic:
- Accepts GitHub access token
- Queries GitHub GraphQL API for:
- Authenticated user's login (viewer.login)
- Active sponsorships for @eliostruyf
- Checks if user is sponsor with ≥€10/month tier
- Returns boolean result
apps/vscode-extension/src/services/SponsorService.ts- Main serviceapps/vscode-extension/src/constants/General.ts- API URL and tier configapps/vscode-extension/src/constants/StateKeys.ts- State keyapps/vscode-extension/src/constants/ContextKeys.ts- Context keyapps/vscode-extension/package.json- Authentication commanddocs/src/pages/api/sponsor.ts- API endpoint
- No Secrets in Extension: GitHub access token is never stored permanently
- API-Based Verification: Sponsor check happens server-side
- Minimal Scopes: Only necessary GitHub permissions requested
- Error Handling: Graceful fallback if API is unavailable
- Type Safety: Proper TypeScript interfaces for all API responses
Run tests with:
npm run testTest coverage includes:
- Constant values verification
- Type checking for all interfaces
- Cache sponsor status for a period (e.g., 24 hours)
- Add UI indicator showing sponsor status
- Implement Pro features gated by
ContextKeys.isSponsor - Add telemetry for authentication success/failure rates
- Support for organization sponsors
Authentication fails:
- Check internet connection
- Verify GitHub is accessible
- Try signing out and back in to GitHub in VS Code
Sponsor status not recognized:
- Ensure sponsorship is active on GitHub
- Verify tier is ≥€10/month
- Re-run authentication command
- Check extension logs for errors
API errors:
- The API endpoint must be deployed to production
- Check browser console for CORS or network issues
- Verify demotime.show is accessible