| 95 | // Mirrors the hub's isValidProtocolMessage (src/lib/a2aProtocol.js in |
| 96 | // evomap-hub) plus the validateProtocol message_type check. |
| 97 | function hubValidate(msg, allowedTypes) { |
| 98 | if (!msg || typeof msg !== 'object') return 'invalid_protocol_message'; |
| 99 | if (msg.protocol !== 'gep-a2a') return 'invalid_protocol_message'; |
| 100 | if (!msg.message_type) return 'invalid_protocol_message'; |
| 101 | if (!msg.message_id || typeof msg.message_id !== 'string') return 'invalid_protocol_message'; |
| 102 | if (!msg.timestamp || typeof msg.timestamp !== 'string') return 'invalid_protocol_message'; |
| 103 | if (!allowedTypes.includes(msg.message_type)) return 'message_type_mismatch'; |
| 104 | if (!msg.sender_id) return 'sender_id_required'; |
| 105 | return null; |
| 106 | } |
| 107 | |
| 108 | function readBody(req) { |
| 109 | return new Promise((resolve) => { |