From c662161cd9596519b627f8618ac201602afb7752 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 12 Dec 2025 22:51:58 +0100 Subject: [PATCH] Add input validation to connectToService() Validation: Add checks for empty strings in connectToService() - Validates serviceFqn is not empty string - Validates service is not empty string - Validates username is not empty string - Prevents silent failures from whitespace-only inputs Impact: Better error messages for invalid inputs --- src/rondevu.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rondevu.ts b/src/rondevu.ts index f55eba2..438e825 100644 --- a/src/rondevu.ts +++ b/src/rondevu.ts @@ -548,6 +548,17 @@ export class Rondevu { async connectToService(options: ConnectToServiceOptions): Promise { const { serviceFqn, service, username, onConnection, rtcConfig } = options + // Validate inputs + if (serviceFqn !== undefined && typeof serviceFqn === 'string' && !serviceFqn.trim()) { + throw new Error('serviceFqn cannot be empty') + } + if (service !== undefined && typeof service === 'string' && !service.trim()) { + throw new Error('service cannot be empty') + } + if (username !== undefined && typeof username === 'string' && !username.trim()) { + throw new Error('username cannot be empty') + } + // Determine the full service FQN let fqn: string if (serviceFqn) {