From aa8e844ecb59edd27601e5000cd6b9deade9162c Mon Sep 17 00:00:00 2001 From: styppo Date: Fri, 20 Jan 2023 18:40:29 +0000 Subject: [PATCH] Validate events --- src/nostr/model/Event.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/nostr/model/Event.js b/src/nostr/model/Event.js index 302c1eb..02e1a36 100644 --- a/src/nostr/model/Event.js +++ b/src/nostr/model/Event.js @@ -1,5 +1,4 @@ -import {getEventHash} from 'nostr-tools' -import DateUtils from 'src/utils/DateUtils' +import {getEventHash, validateEvent, verifySignature} from 'nostr-tools' export const EventKind = { METADATA: 0, @@ -71,11 +70,6 @@ export default class Event { return new Event(obj) } - static fresh(opts) { - opts.createdAt = opts.createdAt || DateUtils.now() - return new Event(opts) - } - static parseTags(tags) { const res = [] for (const tag of tags) { @@ -86,13 +80,16 @@ export default class Event { return res } + get author() { + return this.pubkey + } + get createdAt() { return this.created_at } validate() { - // TODO - return true + return validateEvent(this) && verifySignature(this) } hash() {