Refactor SSE Endpoint with Enhanced Token Validation and Client Management
- Replaced direct token comparison with TokenManager validation - Implemented robust SSE client connection and event subscription workflow - Added detailed client authentication and connection status reporting - Improved SSE endpoint with flexible event, entity, and domain subscription - Enhanced error handling and client disconnect management
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { HassEntity, HassEvent, StateChangedEvent } from '../types/hass.js';
|
||||
import { TokenManager } from '../security/index.js';
|
||||
|
||||
interface RateLimit {
|
||||
count: number;
|
||||
@@ -264,8 +265,7 @@ export class SSEManager extends EventEmitter {
|
||||
|
||||
private validateToken(token?: string): boolean {
|
||||
if (!token) return false;
|
||||
// Compare with HASS_TOKEN from environment
|
||||
return token === process.env.HASS_TOKEN;
|
||||
return TokenManager.validateToken(token);
|
||||
}
|
||||
|
||||
// Utility methods
|
||||
|
||||
Reference in New Issue
Block a user