Add candidate validation to addIceCandidates()

Validation: Add basic candidate validation
- Validate each candidate is an object
- Don't enforce specific structure (per CLAUDE.md guidelines)
- Provides clear error messages with index

Impact: Prevents runtime errors from null/primitive values
Note: Intentionally keeps candidate structure flexible per design
This commit is contained in:
2025-12-12 22:53:29 +01:00
parent 7e2e8c703e
commit 53a576670e

View File

@@ -600,6 +600,13 @@ const handlers: Record<string, RpcHandler> = {
throw new Error('Missing or invalid required parameter: candidates');
}
// Validate each candidate is an object (don't enforce structure per CLAUDE.md)
candidates.forEach((candidate, index) => {
if (!candidate || typeof candidate !== 'object') {
throw new Error(`Invalid candidate at index ${index}: must be an object`);
}
});
const offer = await storage.getOfferById(offerId);
if (!offer) {
throw new Error('Offer not found');