fine grained validation

This commit is contained in:
Daniel Lugo 2020-01-29 14:54:14 -04:00
parent 11fd373301
commit d898506a28

View file

@ -150,13 +150,29 @@ const onIncoming = cb => {
return return
} }
if (!Schema.isOutgoing(data)) { if (typeof data !== 'object') {
return return
} }
if (typeof data.with !== 'string') {
return
}
if (typeof data.messages !== 'object') {
return
}
if (data.messages === null) {
return
}
const msgs = /** @type {[string, Schema.Message][]} */ (Object.entries(
data.messages
).filter(([_, msg]) => Schema.isMessage(msg)))
// eslint-disable-next-line require-atomic-updates // eslint-disable-next-line require-atomic-updates
pubToIncoming[pub] = await Utils.asyncMap( pubToIncoming[pub] = await Utils.asyncMap(
Object.entries(data.messages), msgs,
async ([msgid, msg]) => { async ([msgid, msg]) => {
let decryptedBody = '' let decryptedBody = ''