diff --git a/src/main/scala/app/handlers/EventSignatures.scala b/src/main/scala/app/handlers/EventSignatures.scala index 49caf21..76c0cbe 100644 --- a/src/main/scala/app/handlers/EventSignatures.scala +++ b/src/main/scala/app/handlers/EventSignatures.scala @@ -135,7 +135,7 @@ object EventSignatures extends Handler { } @nowarn("cat=other") - def itemSignatureValid(evtj: String): MaybeItem = Future { + def itemSignatureValid(evtj: String): MaybeItem = { val event: js.Dynamic = js.JSON.parse(evtj) def render(result: Boolean) = Item.component( @@ -148,9 +148,11 @@ object EventSignatures extends Handler { ) ) - true match { - case true => Right(render(true)) - case false => Left(render(false)) + Nostr.verifySignature(event).toFuture map { result => + result match { + case true => Right(render(true)) + case false => Left(render(false)) + } } } @@ -186,9 +188,7 @@ object EventSignatures extends Handler { case Nil => Future { acc.reverse } } - runAndUnwrapUntilFirstLeft(protoElements, List()) foreach { elements => - setElements(elements) - } + runAndUnwrapUntilFirstLeft(protoElements, List()) foreach setElements () => {} }, diff --git a/src/main/scala/app/modules/Nostr.scala b/src/main/scala/app/modules/Nostr.scala index bfb83c0..b6954b4 100644 --- a/src/main/scala/app/modules/Nostr.scala +++ b/src/main/scala/app/modules/Nostr.scala @@ -9,6 +9,6 @@ object Nostr extends js.Object { def getPublicKey(text: String): String = js.native def getEventHash(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 }