Skip to content

Universal OAuth Connector SDK is the open-source developer toolkit that lets any app or AI agent connect to hundreds of OAuth 2.0 providers through one unified API. It standardizes auth flows, manages token lifecycles, and offers an optional managed Vault for secure storage and compliance.

License

Notifications You must be signed in to change notification settings

topcoder1/universal-oauth-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Universal OAuth SDK

Tests TypeScript License

A production-ready, universal OAuth/OIDC SDK for Node.js with TypeScript support, comprehensive error handling, and pluggable token storage.

✨ Features

  • πŸ” 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

πŸ“¦ Packages

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

πŸš€ Quick Start

Installation

pnpm add @oauth-kit/sdk
# or
npm install @oauth-kit/sdk

Basic Usage

import { 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);

πŸ“š Documentation

πŸ—οΈ Development

Prerequisites

  • Node.js 18+ or 20+
  • pnpm 9.0+ (or use corepack enable)
  • Visual Studio Build Tools (for better-sqlite3)

Setup

# Clone the repository
git clone <repo-url>
cd universal-oauth-sdk

# Install dependencies
pnpm install

# Build all packages
pnpm -r build

# Run tests
pnpm test

Available Scripts

pnpm 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

πŸ§ͺ Testing

# Run all tests
pnpm test

# Run tests in watch mode
cd packages/sdk-node
pnpm test:watch

# Run tests with UI
pnpm test:ui

Test Coverage:

  • βœ… 19 tests passing
  • βœ… MemoryStore (9 tests)
  • βœ… SQLiteStore (10 tests)
  • βœ… Token storage and retrieval
  • βœ… Database persistence
  • βœ… Prefix filtering

πŸ”§ Configuration

Environment Variables

# 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-secret

Custom Provider

const 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")
});

πŸ›‘οΈ Security Features

  • βœ… 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

πŸ“Š Project Status

Completed βœ…

  • 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

In Progress 🚧

  • Additional provider manifests
  • CLI enhancements (list, revoke commands)
  • Advanced OAuth flows (device code)

Planned πŸ“‹

  • Token encryption at rest
  • Rate limiting
  • More comprehensive integration tests
  • CI/CD automation

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests.

Adding a Provider

  1. Create a manifest in packages/provider-catalog/manifests/
  2. Follow the JSON schema in packages/provider-catalog/schema/
  3. Run the linter: pnpm lint:manifests
  4. Submit a pull request

πŸ“„ License

  • SDK & Tools: Apache-2.0
  • Provider Catalog: MIT (to encourage contributions)

See individual package LICENSE files for details.

πŸ™ Acknowledgments

Built with:

πŸ“ž Support


Made with ❀️ for the OAuth community

About

Universal OAuth Connector SDK is the open-source developer toolkit that lets any app or AI agent connect to hundreds of OAuth 2.0 providers through one unified API. It standardizes auth flows, manages token lifecycles, and offers an optional managed Vault for secure storage and compliance.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published