import { Request, Response } from 'express'; import { DyNTS_SingletonService } from '../../../_services/base/singleton.service'; /** * OAuth2 Control Service implementation * * This service handles OAuth2 specific business logic and token management * * @example * const oauth2Service = DyNTS_OAuth2_ControlService.getInstance(); * await oauth2Service.handleAuthorizationRequest(req, res); */ export declare class DyNTS_OAuth2_ControlService extends DyNTS_SingletonService { static getInstance(): DyNTS_OAuth2_ControlService; readonly serviceName: string; private readonly authService; private readonly authorizationCodes; private readonly accessTokens; private readonly refreshTokens; private readonly clients; private readonly users; /** * Handles the OAuth2 authorization request * @param req Express Request object * @param res Express Response object */ handleAuthorizationRequest(req: Request, res: Response): Promise; /** * Validates if the client is registered and active * @param clientId The client ID to validate * @returns true if the client is valid */ private isValidClient; /** * Validates if the redirect URI is registered for the client * @param clientId The client ID * @param redirectUri The redirect URI to validate * @returns true if the redirect URI is valid */ private isValidRedirectUri; /** * Validates if the scope is allowed for the client * @param clientId The client ID * @param scope The scope to validate * @returns true if the scope is valid */ private isValidScope; /** * Handles the OAuth2 token request * @param req Express Request object * @param res Express Response object */ handleTokenRequest(req: Request, res: Response): Promise; /** * Validates client credentials * @param clientId The client ID * @param clientSecret The client secret * @returns true if the credentials are valid */ private validateClientCredentials; /** * Handles the OAuth2 userinfo request * @param req Express Request object * @param res Express Response object */ handleUserInfoRequest(req: Request, res: Response): Promise; /** * Gets user information from the token * @param token The access token * @returns The user information object */ private getUserInfoFromToken; /** * Handles the OAuth2 token revocation request * @param req Express Request object * @param res Express Response object */ handleTokenRevocation(req: Request, res: Response): Promise; /** * Generates an authorization code * @param clientId The client ID * @param scope The requested scope * @returns The generated authorization code */ private generateAuthorizationCode; /** * Generates an access token * @param clientId The client ID * @param scope The requested scope * @returns The generated access token */ private generateAccessToken; /** * Generates a refresh token * @param clientId The client ID * @returns The generated refresh token */ private generateRefreshToken; /** * Gets the access token data * @param token The access token * @returns The access token data or undefined if not found */ getAccessTokenData(token: string): { clientId: string; scope: string; expiresAt: number; } | undefined; /** * Registers a new OAuth2 client * @param clientId The client ID * @param clientSecret The client secret * @param redirectUris The allowed redirect URIs * @param allowedScopes The allowed scopes * @returns true if the client was registered successfully */ registerClient(clientId: string, clientSecret: string, redirectUris: string[], allowedScopes: string[]): boolean; /** * Authenticates a user with username and password * @param username The username * @param password The password * @returns The user's scopes if authentication is successful, undefined otherwise */ private authenticateUser; /** * Registers a new user * @param username The username * @param password The password * @param scopes The user's scopes * @returns true if the user was registered successfully */ registerUser(username: string, password: string, scopes: string[]): boolean; } //# sourceMappingURL=oauth2.control-service.d.ts.map