koompi-oauth-sdk
v0.1.4
Published
Official Koompi OAuth helper library for JavaScript and TypeScript applications.
Readme
Koompi OAuth SDK
Developer-friendly helper library for integrating with Koompi’s Identity Provider. It wraps the authorization-code flow, PKCE helpers, token exchange, and user info retrieval for both browser and server environments.
Features
- Build authorization URLs with state and PKCE.
- Simple browser client with pluggable storage for state/PKCE.
- Node/server helper for exchanging codes and fetching user info.
- Fully typed (TypeScript) with ESM and CommonJS builds.
Installation
npm install koompi-oauth-sdk
# or
yarn add koompi-oauth-sdkQuick Start
import { createKoompiOAuthClient } from 'koompi-oauth-sdk';
const client = createKoompiOAuthClient({
clientId: process.env.NEXT_PUBLIC_KOOMPI_CLIENT_ID!,
redirectUri: `${window.location.origin}/callback`,
});
const authorizeUrl = await client.buildAuthorizeUrl();
window.location.href = authorizeUrl;In your callback route:
import { createKoompiOAuthServer } from 'koompi-oauth-sdk';
const oauth = createKoompiOAuthServer({
clientId: process.env.KOOMPI_CLIENT_ID!,
clientSecret: process.env.KOOMPI_CLIENT_SECRET!,
redirectUri: 'https://your-app.com/callback',
baseUrl: 'https://oauth.koompi.org',
});
const token = await oauth.exchangeCode({ code, state });
const user = await oauth.getUserInfo(token.access_token);Documentation
Scripts
npm run build– builds ESM + CJS bundles with type definitionsnpm run lint– runs ESLintnpm run typecheck– TypeScript type checking
License
MIT
