UNPKG

editia-core

Version:

Core services and utilities for Editia applications - Authentication, Monetization, Video Generation Types, and Database Management

67 lines 2.65 kB
/** * Unified Clerk Authentication Service * Based on analysis of server-primary and server-analyzer patterns */ import { AuthResult, DatabaseUser, AuthConfig, JWTVerificationResult } from '../../types/auth'; export type { AuthResult, DatabaseUser, AuthConfig, JWTVerificationResult }; /** * Unified Clerk Authentication Service * Combines the best patterns from server-primary and server-analyzer */ export declare class ClerkAuthService { private static clerkClient; private static supabaseClient; private static config; /** * Initialize the authentication service * Must be called before using any authentication methods */ static initialize(config: AuthConfig): void; /** * Verify user from a Clerk JWT token and return both Clerk user and database user * @param authHeader The Authorization header value containing Clerk JWT * @returns Object containing Clerk user, database user, or error response */ static verifyUser(authHeader?: string | null): Promise<AuthResult>; /** * Helper method to get just the database user ID from a Clerk token * @param authHeader The Authorization header value containing Clerk JWT * @returns Database user ID or null */ static getDatabaseUserId(authHeader?: string | null): Promise<string | null>; /** * Check if user has Pro subscription (required for certain features) * @param authHeader The Authorization header value containing Clerk JWT * @returns True if user has Pro access */ static hasProAccess(authHeader?: string | null): Promise<boolean>; /** * Verify user and check Pro access in one call * @param authHeader The Authorization header value containing Clerk JWT * @returns AuthResult with Pro access verification */ static verifyProUser(authHeader?: string | null): Promise<AuthResult>; /** * Delete user from both Clerk and database * @param authHeader The Authorization header value containing Clerk JWT * @returns Success status and error if any */ static deleteUser(authHeader?: string | null): Promise<{ success: boolean; error?: string; }>; /** * Check if the service is properly initialized * @returns True if initialized, false otherwise */ private static isInitialized; /** * Create a standardized error response * @param error Error message * @param status HTTP status code * @param hint Optional hint for debugging * @returns AuthErrorResponse */ private static createErrorResponse; } //# sourceMappingURL=clerk-auth.d.ts.map