mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-13 04:13:25 +00:00
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
This commit is contained in:
@@ -548,6 +548,17 @@ export class Rondevu {
|
|||||||
async connectToService(options: ConnectToServiceOptions): Promise<ConnectionContext> {
|
async connectToService(options: ConnectToServiceOptions): Promise<ConnectionContext> {
|
||||||
const { serviceFqn, service, username, onConnection, rtcConfig } = options
|
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
|
// Determine the full service FQN
|
||||||
let fqn: string
|
let fqn: string
|
||||||
if (serviceFqn) {
|
if (serviceFqn) {
|
||||||
|
|||||||
Reference in New Issue
Block a user