Unified OAuth authentication toolkit for modern JavaScript applications.
OAuth providers should not require different code paths.
OAuth made less painful.
Uniauth is a TypeScript-first OAuth wrapper library for social login providers.
It provides a unified provider interface so you can integrate multiple OAuth providers without rewriting authentication logic for every platform.
The goal is simple:
- unified OAuth flows
- reusable provider architecture
- PKCE-ready utilities
- scalable provider expansion
- developer-friendly API surface
Most OAuth libraries force developers into:
- provider-specific logic
- inconsistent APIs
- unnecessary boilerplate
- framework lock-in
Uniauth provides:
- a unified provider interface
- consistent OAuth flow handling
- TypeScript-first developer experience
- lightweight and flexible architecture
Write authentication logic once and switch providers easily.
- 🔐 Unified OAuth API
- ⚡ Lightweight architecture
- 🧠 TypeScript-first developer experience
- 🔄 Consistent provider flow handling
- 🛠 Framework agnostic
- 📦 Easy provider integration
- 🚀 Minimal setup
- 🔑 PKCE-ready utilities
- 🌱 Scalable provider system
| Feature | Uniauth | Passport.js |
|---|---|---|
| Unified provider API | ✅ | ❌ |
| TypeScript-first | ✅ | |
| Lightweight setup | ✅ | ❌ |
| Consistent flow handling | ✅ | ❌ |
| Minimal boilerplate | ✅ | ❌ |
| Framework agnostic | ✅ | |
| PKCE utilities included | ✅ | ❌ |
Package currently published under the
@deba_1307scope.
npm install @deba_1307/uniauthpnpm add @deba_1307/uniauthyarn add @deba_1307/uniauthBefore using Uniauth, make sure your environment meets the following requirements:
- Node.js >= 20
- npm, pnpm, or yarn
Check your current Node.js version:
node -vimport Uniauth from '@deba_1307/uniauth'
const auth = new Uniauth({
providers: {
Google: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
redirecturl: 'http://localhost:3000/auth/google/callback',
scope: ['openid', 'email', 'profile']
}
}
})
const google = auth.getProvider('Google')
const url = google.getAuthorizationUrl()Google provider uses the PKCE OAuth flow.
The overall provider usage remains identical to other providers, but there is one additional step.
You must extract and store the generated PKCE key and the Authurl from the authorization URL using the Extractkey() helper.
That extracted key is later required during token exchange.
import Uniauth from '@deba_1307/uniauth'
import { Extractkey } from '@deba_1307/uniauth'
const auth = new Uniauth({
providers: {
Google: {
clientId: '<YOUR_GOOGLE_CLIENT_ID>',
clientSecret: '<YOUR_GOOGLE_CLIENT_SECRET>',
redirecturl: 'https://yourapp.com/auth/google/callback',
scope: ['openid', 'email', 'profile']
}
}
})
const google = auth.getProvider('Google')
/* ⚠️Don't use ❌ this 'url' as you authorization url
it might return a invalid redirect_uri issue
⚠️ */
const url = google.getAuthorizationUrl()
/*
Extract the generated PKCE key.
Store this key securely because it will be
required later during token exchange.
*/
const { key, AuthUrl } = Extractkey(url)
// redirect user to AuthUrl
// after OAuth callback:
const token = await google.exchangeCodeForToken(code, key)
// fetch user profile
const profile = await google.getUserProfile(token.accessToken)import Uniauth from '@deba_1307/uniauth'
const auth = new Uniauth({
providers: {
Linkedin: {
clientId: '<YOUR_LINKEDIN_CLIENT_ID>',
clientSecret: '<YOUR_LINKEDIN_CLIENT_SECRET>',
redirecturl: 'https://yourapp.com/auth/linkedin/callback',
scope: ['r_liteprofile', 'r_emailaddress']
}
}
})
const linkedin = auth.getProvider('Linkedin')
const authorizationUrl = linkedin.getAuthorizationUrl()
// redirect user to authorizationUrl
// after callback, exchange the authorization code:
const token = await linkedin.exchangeCodeForToken(code)
// fetch the LinkedIn user profile:
const profile = await linkedin.getUserProfile(token.accessToken)Every OAuth provider accepts the following configuration:
clientId— provider application client IDclientSecret— provider application client secretredirecturl— OAuth callback redirect URIscope— array of OAuth scopes
Example:
{
clientId: 'abc123',
clientSecret: 'secret',
redirecturl: 'https://yourapp.com/auth/provider/callback',
scope: ['openid', 'profile']
}Your Application
↓
Uniauth
↓
OAuth Providers
(Google, LinkedIn, GitHub...)
Uniauth abstracts provider-specific OAuth logic into a unified developer-friendly API.
Uniauth is under active development and new providers/features are being added continuously.
- LinkedIn OAuth provider
- Google OAuth provider
- Authorization URL generation
- Access token exchange flow
- User profile fetching
- PKCE utility helpers
- ESM + CommonJS builds
- CI workflow integration
- GitHub OAuth
- Discord OAuth
- Spotify OAuth
- Twitter/X OAuth
- Facebook OAuth
- Session helpers
- Adapter ecosystem
- LinkedIn OAuth
- Google OAuth
- PKCE utilities
- ESM + CommonJS support
- GitHub OAuth
- Discord OAuth
- Spotify OAuth
- Session utilities
- Provider adapters
- Framework integrations
- Better developer tooling
Uniauthcurrently exposes a default classgetProvider(providerName)returns the provider instance- Providers expose:
getAuthorizationUrl()exchangeCodeForToken(code)getUserProfile(accessToken)
src/index.ts— library entrypointsrc/providers/core/Uniauth.ts— provider registry and configurationsrc/providers/linkedin/LinkedinProvider.ts— LinkedIn OAuth implementationsrc/providers/linkedin/Linkedin.types.ts— LinkedIn provider typessrc/providers/core/types/TokenResponse.types.ts— token response shapesrc/providers/core/types/UserProfile.types.ts— user profile shapesrc/pkce/*— PKCE helper utilities
- Automated tests and CI validation are included
- The provider system is designed for scalable expansion
- Additional providers can be added by extending the provider core architecture
Contributions are welcome.
If you want to add a provider:
- Create a provider class under
src/providers - Add the required provider types
- Register the provider inside
src/providers/core/Uniauth.ts
Issues, discussions, and pull requests are always appreciated.
MIT

