diff --git a/build.js b/build.js
index 1c59117..fab54b5 100755
--- a/build.js
+++ b/build.js
@@ -1,7 +1,23 @@
#!/usr/bin/env node
-require('esbuild').buildSync({
- entryPoints: ['globals.js'],
- outfile: 'globals.bundle.js',
- bundle: true
+const esbuild = require('esbuild')
+const alias = require('esbuild-plugin-alias')
+const nodeGlobals = require('@esbuild-plugins/node-globals-polyfill').default
+
+esbuild
+ .build({
+ entryPoints: ['globals.js'],
+ outfile: 'globals.bundle.js',
+ bundle: true,
+ plugins: [
+ alias({
+ stream: require.resolve('readable-stream')
+ }),
+ nodeGlobals({buffer: true})
+ ],
+ define: {
+ window: 'self',
+ global: 'self'
+ }
})
+ .then(() => console.log('build success.'))
diff --git a/globals.js b/globals.js
index 1d80bad..8b549f1 100644
--- a/globals.js
+++ b/globals.js
@@ -1,2 +1,3 @@
window.React = require('react')
window.ReactDOM = require('react-dom')
+window.Nostr = require('nostr-tools')
diff --git a/index.html b/index.html
index 68eae10..8613978 100644
--- a/index.html
+++ b/index.html
@@ -1,5 +1,5 @@
-
title
+nostr army knife - nak
diff --git a/package.json b/package.json
index add86a3..ed9964a 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,11 @@
"start": "./build.js && sbt ~fastLinkJS"
},
"dependencies": {
+ "@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"esbuild": "^0.14.23",
+ "esbuild-plugin-alias": "^0.2.1",
+ "events": "^3.3.0",
+ "nostr-tools": "^0.22.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
diff --git a/src/main/scala/app/handlers/KeyHandling.scala b/src/main/scala/app/handlers/KeyHandling.scala
index 98fa0df..ffa322c 100644
--- a/src/main/scala/app/handlers/KeyHandling.scala
+++ b/src/main/scala/app/handlers/KeyHandling.scala
@@ -7,6 +7,7 @@ import slinky.web.html._
import slinky.core.facade.Hooks._
import slinky.core.facade.Fragment
+import app.modules.Nostr
import app.handlers.{Handler}
import app.components.{Item}
@@ -19,7 +20,9 @@ object KeyHandling extends Handler {
override val component = FunctionalComponent[String] { props =>
Fragment(
Item.component(Item.props("private key", "", props)),
- Item.component(Item.props("public key", "", "soon to be shown here"))
+ Item.component(
+ Item.props("public key", "", Nostr.getPublicKey(props))
+ )
)
}
}
diff --git a/src/main/scala/app/modules/Nostr.scala b/src/main/scala/app/modules/Nostr.scala
new file mode 100644
index 0000000..63483f4
--- /dev/null
+++ b/src/main/scala/app/modules/Nostr.scala
@@ -0,0 +1,10 @@
+package app.modules
+
+import scala.scalajs.js.annotation._
+import scala.scalajs.js
+
+@js.native
+@JSGlobal
+object Nostr extends js.Object {
+ def getPublicKey(text: String): String = js.native
+}