Validate events

This commit is contained in:
styppo 2023-01-20 18:40:29 +00:00
parent 285f27c3dd
commit aa8e844ecb
No known key found for this signature in database
GPG Key ID: 3AAA685C50724C28

View File

@ -1,5 +1,4 @@
import {getEventHash} from 'nostr-tools' import {getEventHash, validateEvent, verifySignature} from 'nostr-tools'
import DateUtils from 'src/utils/DateUtils'
export const EventKind = { export const EventKind = {
METADATA: 0, METADATA: 0,
@ -71,11 +70,6 @@ export default class Event {
return new Event(obj) return new Event(obj)
} }
static fresh(opts) {
opts.createdAt = opts.createdAt || DateUtils.now()
return new Event(opts)
}
static parseTags(tags) { static parseTags(tags) {
const res = [] const res = []
for (const tag of tags) { for (const tag of tags) {
@ -86,13 +80,16 @@ export default class Event {
return res return res
} }
get author() {
return this.pubkey
}
get createdAt() { get createdAt() {
return this.created_at return this.created_at
} }
validate() { validate() {
// TODO return validateEvent(this) && verifySignature(this)
return true
} }
hash() { hash() {