(event: Event)
| 225 | } |
| 226 | |
| 227 | protected async isEventValid(event: Event): Promise<string | undefined> { |
| 228 | if (!(await isEventIdValid(event))) { |
| 229 | return 'invalid: event id does not match' |
| 230 | } |
| 231 | if (!(await isEventSignatureValid(event))) { |
| 232 | return 'invalid: event signature verification failed' |
| 233 | } |
| 234 | |
| 235 | if (event.kind === EventKinds.REQUEST_TO_VANISH && !isRequestToVanishEvent(event, this.settings().info.relay_url)) { |
| 236 | return 'invalid: request to vanish relay tag invalid' |
| 237 | } |
| 238 | |
| 239 | // NIP-17: kind 13 (Seal) and kind 14 (Direct Message) are inner events that |
| 240 | // must never be published directly to a relay. They are encrypted inside a |
| 241 | // kind 1059 Gift Wrap (NIP-59) before being sent here. |
| 242 | // Marmot MIP-02: kind 444 (Welcome rumor) is similarly an inner event that |
| 243 | // must only be delivered inside a kind 1059 gift wrap. |
| 244 | if (isSealEvent(event) || isDirectMessageEvent(event) || isFileMessageEvent(event) || isWelcomeRumorEvent(event)) { |
| 245 | return `blocked: kind ${event.kind} events must not be published directly; wrap them in a kind 1059 gift wrap` |
| 246 | } |
| 247 | |
| 248 | // NIP-42: auth events must use the AUTH message type |
| 249 | if (event.kind === EventKinds.AUTH) { |
| 250 | return 'invalid: auth events must be sent using the AUTH message type' |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | protected async isBlockedByRequestToVanish(event: Event): Promise<string | undefined> { |
| 255 | if (isRequestToVanishEvent(event)) { |
no test coverage detected