feat: Add AuthClient and LeaderboardClient to TypeScript SDK (Closes #863)#1257
Open
sepulchralvoid666 wants to merge 1 commit into
Open
feat: Add AuthClient and LeaderboardClient to TypeScript SDK (Closes #863)#1257sepulchralvoid666 wants to merge 1 commit into
sepulchralvoid666 wants to merge 1 commit into
Conversation
- New AuthClient (sdk/src/auth.ts): - getGitHubAuthorizeUrl() — get OAuth authorize URL - exchangeGitHubCode() — exchange code for JWT tokens + user - refreshTokens() — refresh expired access tokens - getMe() — fetch current authenticated user profile - Full JSDoc documentation with examples - Comprehensive test suite (sdk/src/__tests__/auth.test.ts) - New LeaderboardClient (sdk/src/leaderboard.ts): - getLeaderboard(period?) — fetch contributor rankings - getStats() — platform-wide statistics with field normalization - Full JSDoc documentation with examples - Comprehensive test suite (sdk/src/__tests__/leaderboard.test.ts) - Updated SolFoundry facade class: - Added auth and leaderboard properties - Updated JSDoc examples to show new clients - Imported and wired both new clients in constructor - New barrel exports in index.ts for all new types and classes - New example: examples/03-github-auth.ts - Full OAuth flow walkthrough - Token lifecycle demonstration - Leaderboard and stats integration Closes SolFoundry#863 **Wallet:** 2JHa4QQWNV7AGSGsVeX1cwjZtFcmTTomb1TrJmQthoh3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Completes the SolFoundry TypeScript SDK by adding two missing API clients and full test coverage.
New: AuthClient (
sdk/src/auth.ts)Full GitHub OAuth 2.0 authentication lifecycle:
getGitHubAuthorizeUrl()— Fetch GitHub OAuth authorize URL for redirecting usersexchangeGitHubCode(code, state?)— Exchange OAuth callback code for JWT tokens + user profilerefreshTokens(refreshToken)— Refresh expired access tokens without re-authgetMe()— Fetch current authenticated user profileAll methods include full JSDoc with
@throwsannotations and@exampleblocks.New: LeaderboardClient (
sdk/src/leaderboard.ts)Platform rankings and statistics:
getLeaderboard(period?)— Fetch contributor leaderboard for 7d/30d/90d/all time periodsgetStats()— Platform-wide statistics with field name normalization (handles bothopen_bountiesandactive_bountiesfield shapes)Updated: SolFoundry Facade
The main
SolFoundryclass now exposes:client.auth— AuthClient instanceclient.leaderboard— LeaderboardClient instanceUpdated JSDoc examples show both new clients in action.
New: Barrel Exports
All new types and classes exported from
sdk/src/index.ts:AuthClient,AuthTokens,GitHubAuthResponse,AuthUser,AuthClientConfigLeaderboardClient,TimePeriod,LeaderboardEntry,PlatformStatsNew: Test Suite
sdk/src/__tests__/auth.test.ts— 6 tests covering all AuthClient methods, error propagation, and optional paramssdk/src/__tests__/leaderboard.test.ts— 6 tests covering leaderboard fetch, paginated response handling, stats normalization, and zero-defaultsNew: Example
sdk/examples/03-github-auth.ts— Full OAuth walkthrough: authorize URL → code exchange → token refresh → leaderboard + statsHow to test
sdk/src/auth.tsandsdk/src/leaderboard.tsfor API coverage completenesssdk/src/__tests__/cd sdk && npm install && npm testto execute all testsexamples/03-github-auth.tsfor usage patternsSolFoundryfacade now includesauthandleaderboardpropertiesSDK API Coverage Summary
Closes #863
Wallet: 2JHa4QQWNV7AGSGsVeX1cwjZtFcmTTomb1TrJmQthoh3