mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 16:19:07 -05:00
actually verify signatures.
This commit is contained in:
parent
2f455ab225
commit
e17ec3d1f9
|
@ -135,7 +135,7 @@ object EventSignatures extends Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@nowarn("cat=other")
|
@nowarn("cat=other")
|
||||||
def itemSignatureValid(evtj: String): MaybeItem = Future {
|
def itemSignatureValid(evtj: String): MaybeItem = {
|
||||||
val event: js.Dynamic = js.JSON.parse(evtj)
|
val event: js.Dynamic = js.JSON.parse(evtj)
|
||||||
|
|
||||||
def render(result: Boolean) = Item.component(
|
def render(result: Boolean) = Item.component(
|
||||||
|
@ -148,11 +148,13 @@ object EventSignatures extends Handler {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
true match {
|
Nostr.verifySignature(event).toFuture map { result =>
|
||||||
|
result match {
|
||||||
case true => Right(render(true))
|
case true => Right(render(true))
|
||||||
case false => Left(render(false))
|
case false => Left(render(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val protoElements = List[(String) => MaybeItem](
|
val protoElements = List[(String) => MaybeItem](
|
||||||
itemWrongProperties,
|
itemWrongProperties,
|
||||||
|
@ -186,9 +188,7 @@ object EventSignatures extends Handler {
|
||||||
case Nil => Future { acc.reverse }
|
case Nil => Future { acc.reverse }
|
||||||
}
|
}
|
||||||
|
|
||||||
runAndUnwrapUntilFirstLeft(protoElements, List()) foreach { elements =>
|
runAndUnwrapUntilFirstLeft(protoElements, List()) foreach setElements
|
||||||
setElements(elements)
|
|
||||||
}
|
|
||||||
|
|
||||||
() => {}
|
() => {}
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,6 +9,6 @@ object Nostr extends js.Object {
|
||||||
def getPublicKey(text: String): String = js.native
|
def getPublicKey(text: String): String = js.native
|
||||||
def getEventHash(evt: js.Dynamic): String = js.native
|
def getEventHash(evt: js.Dynamic): String = js.native
|
||||||
def serializeEvent(evt: js.Dynamic): String = js.native
|
def serializeEvent(evt: js.Dynamic): String = js.native
|
||||||
def verifySignature(evt: js.Dynamic): Boolean = js.native
|
def verifySignature(evt: js.Dynamic): js.Promise[Boolean] = js.native
|
||||||
def signEvent(evt: js.Dynamic, privateKey: String): String = js.native
|
def signEvent(evt: js.Dynamic, privateKey: String): String = js.native
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user