* Validate a postMessage event * * Checks if a message event is valid and from an expected source
(
event: MessageEvent,
expectedTypes: string[]
)
| 224 | * Checks if a message event is valid and from an expected source |
| 225 | */ |
| 226 | static validateMessage( |
| 227 | event: MessageEvent, |
| 228 | expectedTypes: string[] |
| 229 | ): boolean { |
| 230 | if (!event.data || typeof event.data !== 'object') { |
| 231 | return false; |
| 232 | } |
| 233 | |
| 234 | if (!event.data.type || typeof event.data.type !== 'string') { |
| 235 | return false; |
| 236 | } |
| 237 | |
| 238 | return expectedTypes.includes(event.data.type); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected