mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-13 20:33:25 +00:00
Add SDP validation to publishService()
Validation: Add comprehensive offer validation - Validate each offer is an object - Validate each offer has sdp property - Validate sdp is a string - Validate sdp is not empty/whitespace Impact: Prevents runtime errors from malformed offers Improves error messages with specific index information
This commit is contained in:
13
src/rpc.ts
13
src/rpc.ts
@@ -336,6 +336,19 @@ const handlers: Record<string, RpcHandler> = {
|
||||
);
|
||||
}
|
||||
|
||||
// Validate each offer has valid SDP
|
||||
offers.forEach((offer, index) => {
|
||||
if (!offer || typeof offer !== 'object') {
|
||||
throw new Error(`Invalid offer at index ${index}: must be an object`);
|
||||
}
|
||||
if (!offer.sdp || typeof offer.sdp !== 'string') {
|
||||
throw new Error(`Invalid offer at index ${index}: missing or invalid SDP`);
|
||||
}
|
||||
if (!offer.sdp.trim()) {
|
||||
throw new Error(`Invalid offer at index ${index}: SDP cannot be empty`);
|
||||
}
|
||||
});
|
||||
|
||||
// Create service with offers
|
||||
const now = Date.now();
|
||||
const offerTtl =
|
||||
|
||||
Reference in New Issue
Block a user