element-hq / element-hq/element-call
js-sdk voip architecture: Input validation & types
- Dominant language
- TypeScript
- Stars
- 996
- Forks
- 213
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 55
Description
### Your use case
https://github.com/matrix-org/matrix-js-sdk/blob/fc2671d8538a3339ca5925ef42e3ba6102f7e8f2/src/matrixrtc/CallMembership.ts#L40 takes a typed data structure and does further validation on it that should be unnecessary because of the types. This is a bit weird and confusing, but is because we are casting the raw content from the event into a CallMembershipData and then having the constructor take a typed interface, so we are technically lying about the type of the data between those points.
Now that I think about this more, I suspect the neatest solution would be to have a separate validator function that takes `unknown`, validates it and returns `CallMembershipData` or throws, then you can construct the CallMembership with a validated CallMembershipData.
Either way, we should do something less confusing, but still actually do explicit validation which we have often neglected in the past.
### Have you considered any alternatives?
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.