OAuthService
Main service for OAuth 2.1 and OpenID Connect authentication flows.
Overview
The OAuthService manages the complete OAuth 2.1 and OIDC authentication lifecycle with automatic PKCE, state validation, nonce handling, and token refresh. It wraps the industry-standard oidc-client-ts library with AuthSafe-specific configuration.
Basic Usage
import { OAuthService } from 'authsafe-ts';
const oauthService = new OAuthService({
clientId: 'your-client-id',
redirectUri: 'http://localhost:3000/callback',
scope: ['openid', 'profile', 'email', 'offline_access'],
env: 'production',
});
await oauthService.initialize();