recoder-shared
Version:
Shared types, utilities, and configurations for Recoder
106 lines • 2.6 kB
TypeScript
/**
* Web OAuth Implementation
* Handles OAuth flows for web platforms (React/Next.js)
*/
import { AuthClient } from './auth-client';
export interface WebOAuthConfig {
popupMode?: boolean;
redirectMode?: boolean;
popupOptions?: {
width?: number;
height?: number;
centerScreen?: boolean;
};
}
export interface WebOAuthResult {
success: boolean;
user?: any;
tokens?: any;
error?: string;
}
export declare class WebOAuthHandler {
private oauthHandler;
private authClient;
private config;
constructor(authClient: AuthClient, config?: WebOAuthConfig);
private setupEventHandlers;
/**
* Start OAuth flow with popup
*/
loginWithPopup(provider: string): Promise<WebOAuthResult>;
/**
* Start OAuth flow with redirect
*/
loginWithRedirect(provider: string): void;
/**
* Handle OAuth callback (for redirect flow)
*/
handleCallback(provider: string): Promise<WebOAuthResult>;
/**
* Login with Google (popup)
*/
loginWithGoogle(): Promise<WebOAuthResult>;
/**
* Login with GitHub (popup)
*/
loginWithGitHub(): Promise<WebOAuthResult>;
/**
* Login with Microsoft (popup)
*/
loginWithMicrosoft(): Promise<WebOAuthResult>;
/**
* Login with Google (redirect)
*/
loginWithGoogleRedirect(): void;
/**
* Login with GitHub (redirect)
*/
loginWithGitHubRedirect(): void;
/**
* Login with Microsoft (redirect)
*/
loginWithMicrosoftRedirect(): void;
/**
* Open OAuth popup window
*/
private openPopup;
/**
* Get the OAuth callback script for popup
* This should be included in the OAuth callback page
*/
static getCallbackScript(): string;
/**
* React Hook for OAuth
*/
static createUseAuth(): () => {
isAuthenticated: boolean;
user: null;
loading: boolean;
login: (provider: string) => Promise<void>;
logout: () => Promise<void>;
};
/**
* Next.js API route handler
*/
static createNextAuthHandler(authClient: AuthClient): {
GET(request: Request): Promise<Response>;
};
/**
* Get available OAuth providers
*/
getAvailableProviders(): string[];
/**
* Check if user is authenticated
*/
isAuthenticated(): boolean;
/**
* Get current user
*/
getCurrentUser(): any;
/**
* Logout
*/
logout(): Promise<void>;
}
export default WebOAuthHandler;
//# sourceMappingURL=oauth-web.d.ts.map