A production-ready, universal OAuth/OIDC SDK for Node.js with TypeScript support, comprehensive error handling, and pluggable token storage.
- π OAuth 2.0 & OIDC - Full support with PKCE
- π Automatic Token Refresh - Seamless token management
- πΎ Pluggable Storage - SQLite, Memory, or custom implementations
- π‘οΈ Type Safe - Full TypeScript support with strict types
- β Well Tested - 19 comprehensive tests with 100% pass rate
- π¨ Error Handling - Timeouts, validation, and detailed error messages
- π¦ Monorepo - Multiple packages for different use cases
- π― Provider Catalog - Pre-configured for Google, GitHub, and more
| Package | Description | Status |
|---|---|---|
@oauth-kit/sdk |
Core SDK with OAuth client | β Production Ready |
@oauth-kit/cli |
Developer CLI tool | β Production Ready |
@oauth-kit/provider-catalog |
Provider manifests | β Production Ready |
@oauth-kit/manifest-tools |
Manifest validator | β Production Ready |
pnpm add @oauth-kit/sdk
# or
npm install @oauth-kit/sdkimport { createClient, SQLiteStore } from "@oauth-kit/sdk";
// Create OAuth client
const client = createClient({
provider: "google",
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
redirectUri: "http://localhost:8787/callback",
store: new SQLiteStore("tokens.db")
});
// Initialize and authorize
await client.init();
await client.authorize();
// Make authenticated requests
const response = await client.request("https://www.googleapis.com/oauth2/v2/userinfo");
const user = await response.json();
console.log(user);- API Documentation - Complete API reference
- Usage Guide - Examples and best practices
- Progress Report - Current status and roadmap
- Node.js 18+ or 20+
- pnpm 9.0+ (or use
corepack enable) - Visual Studio Build Tools (for better-sqlite3)
# Clone the repository
git clone <repo-url>
cd universal-oauth-sdk
# Install dependencies
pnpm install
# Build all packages
pnpm -r build
# Run tests
pnpm testpnpm build # Build all packages
pnpm test # Run all tests
pnpm lint # Lint TypeScript files
pnpm lint:fix # Fix linting issues
pnpm format # Format code with Prettier
pnpm format:check # Check code formatting# Run all tests
pnpm test
# Run tests in watch mode
cd packages/sdk-node
pnpm test:watch
# Run tests with UI
pnpm test:uiTest Coverage:
- β 19 tests passing
- β MemoryStore (9 tests)
- β SQLiteStore (10 tests)
- β Token storage and retrieval
- β Database persistence
- β Prefix filtering
# For Google OAuth
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your-secret
# For GitHub OAuth
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-secretconst client = createClient({
provider: {
name: "custom",
displayName: "Custom Provider",
authorizationEndpoint: "https://provider.com/oauth/authorize",
tokenEndpoint: "https://provider.com/oauth/token",
scopes: ["read", "write"]
},
clientId: "your-client-id",
redirectUri: "http://localhost:8787/callback",
store: new SQLiteStore("tokens.db")
});- β PKCE - Proof Key for Code Exchange
- β State Validation - CSRF protection
- β Input Validation - All inputs validated
- β Timeout Protection - 5-minute authorization timeout
- β Error Handling - OAuth error responses handled
- β Secure Storage - SQLite with optional encryption
- All critical bugs fixed
- Comprehensive error handling
- 19 tests with 100% pass rate
- Type safety improvements
- ESLint and Prettier configured
- Complete API documentation
- Usage guide with examples
- Additional provider manifests
- CLI enhancements (list, revoke commands)
- Advanced OAuth flows (device code)
- Token encryption at rest
- Rate limiting
- More comprehensive integration tests
- CI/CD automation
Contributions are welcome! Please read our contributing guidelines and submit pull requests.
- Create a manifest in
packages/provider-catalog/manifests/ - Follow the JSON schema in
packages/provider-catalog/schema/ - Run the linter:
pnpm lint:manifests - Submit a pull request
- SDK & Tools: Apache-2.0
- Provider Catalog: MIT (to encourage contributions)
See individual package LICENSE files for details.
Built with:
- openid-client - OAuth/OIDC client
- better-sqlite3 - SQLite storage
- Vitest - Testing framework
- TypeScript - Type safety
- π Documentation
- π Issue Tracker
- π¬ Discussions
Made with β€οΈ for the OAuth community