open-index/open-npm huggingface dataset:
npm package: @kyperauth/oauth2-client
Description: Thin OAuth2 Authorization Code + PKCE client for KyperAuth. Zero dependencies, browser-only.
Latest version: 0.1.1

# @kyperauth/oauth2-client

Thin OAuth2 Authorization Code + PKCE client for KyperAuth. Zero dependencies, browser-only.

## Usage

```ts
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);
```