MCPcopy Create free account
hub / github.com/EvoMap/evolver / hubValidate

Function hubValidate

test/proxyEnvelope.test.js:97–106  ·  view source on GitHub ↗
(msg, allowedTypes)

Source from the content-addressed store, hash-verified

95// Mirrors the hub's isValidProtocolMessage (src/lib/a2aProtocol.js in
96// evomap-hub) plus the validateProtocol message_type check.
97function 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
108function readBody(req) {
109 return new Promise((resolve) => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected