chore: enforce pubkey whitelist/blacklist

This commit is contained in:
Ricardo Arturo Cabral Mejia
2022-09-22 21:36:33 +00:00
parent 45fe91ae66
commit 68678a5ad8

View File

@@ -70,7 +70,7 @@ export class EventMessageHandler implements IMessageHandler {
if (limits.eventId.minLeadingZeroBits > 0) { if (limits.eventId.minLeadingZeroBits > 0) {
if (getEventProofOfWork(event) < limits.eventId.minLeadingZeroBits) { if (getEventProofOfWork(event) < limits.eventId.minLeadingZeroBits) {
return `insufficient proof of work: eventId has less than ${limits.eventId.minLeadingZeroBits} leading zero bits` return `insufficient proof of work: event Id has less than ${limits.eventId.minLeadingZeroBits} leading zero bits`
} }
} }
@@ -80,6 +80,18 @@ export class EventMessageHandler implements IMessageHandler {
} }
} }
if (limits.pubkey.blacklist.length > 0) {
if (limits.pubkey.blacklist.includes(event.pubkey)) {
return `pubkey ${event.pubkey} is not allowed`
}
}
if (limits.pubkey.whitelist.length > 0) {
if (!limits.pubkey.whitelist.includes(event.pubkey)) {
return `pubkey ${event.pubkey} is not allowed`
}
}
if (limits.kind.blacklist.length > 0) { if (limits.kind.blacklist.length > 0) {
if (limits.kind.blacklist.includes(event.kind)) { if (limits.kind.blacklist.includes(event.kind)) {
return `event kind ${event.kind} is not allowed` return `event kind ${event.kind} is not allowed`