@koompi/oauth
v1.0.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
# or
yarn add @koompi/oauthQuick Start
import { KoompiAuth } from "@koompi/oauth";
const auth = new KoompiAuth({
clientId: process.env.NEXT_PUBLIC_KOOMPI_CLIENT_ID!,
redirectUri: "https://your-app.com/callback",
});
const authorizeUrl = await auth.createLoginUrl();
window.location.href = authorizeUrl;In your callback route:
import { KoompiAuth } from "@koompi/oauth";
const auth = new KoompiAuth({
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 auth.exchangeCode({ code, state });
const user = await auth.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
