@kyperauth/oauth2-client
v0.1.1
Published
Thin OAuth2 Authorization Code + PKCE client for KyperAuth. Zero dependencies, browser-only.
Downloads
201
Readme
@kyperauth/oauth2-client
Thin OAuth2 Authorization Code + PKCE client for KyperAuth. Zero dependencies, browser-only.
Usage
import { KyperAuthOAuth2Client } from '@kyperauth/oauth2-client';
const client = new KyperAuthOAuth2Client({
authorizeUrl: 'https://auth.example.com/oauth2/authorize',
tokenUrl: 'https://api.example.com/oauth2/token',
clientId: 'your-client-id',
redirectUri: 'https://app.example.com/callback',
tenantSlug: 'my-tenant',
// baseUrl: 'https://api.example.com', // optional, derived from tokenUrl
});
// Login or register
await client.login();
await client.register();
// Handle callback
const tokens = await client.handleCallback(window.location.href);
// Verify email
const result = await client.verifyEmail('verification-token-from-email');
// Refresh
const newTokens = await client.refreshToken(tokens.refreshToken);