mirror of
https://github.com/styppo/hamstr.git
synced 2024-10-18 05:23:28 +00:00
Validate events
This commit is contained in:
parent
285f27c3dd
commit
aa8e844ecb
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user