MCPcopy Create free account
hub / github.com/altic-dev/Pilot / validateMessage

Method validateMessage

src/lib/picker-injector.ts:226–239  ·  view source on GitHub ↗

* Validate a postMessage event * * Checks if a message event is valid and from an expected source

(
    event: MessageEvent,
    expectedTypes: string[]
  )

Source from the content-addressed store, hash-verified

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/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected