Skip to content

feat: Add AuthClient and LeaderboardClient to TypeScript SDK (Closes #863)#1257

Open
sepulchralvoid666 wants to merge 1 commit into
SolFoundry:mainfrom
sepulchralvoid666:feat/bounty-863-typescript-sdk
Open

feat: Add AuthClient and LeaderboardClient to TypeScript SDK (Closes #863)#1257
sepulchralvoid666 wants to merge 1 commit into
SolFoundry:mainfrom
sepulchralvoid666:feat/bounty-863-typescript-sdk

Conversation

@sepulchralvoid666
Copy link
Copy Markdown

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 users
  • exchangeGitHubCode(code, state?) — Exchange OAuth callback code for JWT tokens + user profile
  • refreshTokens(refreshToken) — Refresh expired access tokens without re-auth
  • getMe() — Fetch current authenticated user profile

All methods include full JSDoc with @throws annotations and @example blocks.

New: LeaderboardClient (sdk/src/leaderboard.ts)

Platform rankings and statistics:

  • getLeaderboard(period?) — Fetch contributor leaderboard for 7d/30d/90d/all time periods
  • getStats() — Platform-wide statistics with field name normalization (handles both open_bounties and active_bounties field shapes)

Updated: SolFoundry Facade

The main SolFoundry class now exposes:

  • client.auth — AuthClient instance
  • client.leaderboard — LeaderboardClient instance

Updated 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, AuthClientConfig
  • LeaderboardClient, TimePeriod, LeaderboardEntry, PlatformStats

New: Test Suite

  • sdk/src/__tests__/auth.test.ts — 6 tests covering all AuthClient methods, error propagation, and optional params
  • sdk/src/__tests__/leaderboard.test.ts — 6 tests covering leaderboard fetch, paginated response handling, stats normalization, and zero-defaults

New: Example

  • sdk/examples/03-github-auth.ts — Full OAuth walkthrough: authorize URL → code exchange → token refresh → leaderboard + stats

How to test

  1. Review sdk/src/auth.ts and sdk/src/leaderboard.ts for API coverage completeness
  2. Review test files in sdk/src/__tests__/
  3. Run cd sdk && npm install && npm test to execute all tests
  4. Review examples/03-github-auth.ts for usage patterns
  5. Verify the SolFoundry facade now includes auth and leaderboard properties

SDK API Coverage Summary

Client Methods Status
BountyClient list, get, create, update, delete, search, autocomplete, submit Existing
EscrowClient fund, release, refund, getStatus, getLedger Existing
ContributorClient create, get, update, list, getStats Existing
AuthClient getGitHubAuthorizeUrl, exchangeGitHubCode, refreshTokens, getMe New
LeaderboardClient getLeaderboard, getStats New
GitHubClient listBounties, checkClaim, verifyCompletion Existing
EventSubscriber connect, subscribe, on, disconnect Existing

Closes #863

Wallet: 2JHa4QQWNV7AGSGsVeX1cwjZtFcmTTomb1TrJmQthoh3

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🏭 Bounty T3: SolFoundry TypeScript SDK

1 participant