Skip to content

Commit

Permalink
webapp: new pages DiscordBotInfo and WebBluetoothTool & update Home
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioPinheiro committed Nov 9, 2023
1 parent a056d4b commit 56a342b
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 27 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,8 @@ Want to see your project here? [Submit a PR]
- support `from_prior`
- support `sub` `iss` on JWT https://datatracker.ietf.org/doc/html/rfc7519
- create module for protocols
- routing:
- implement utilities for DID Agents [WIP]
- [DONE] HTTP POST
- [WIP] push notification
- [WIP] websocket
- [WIP-stop] NFC
- [TODO] bluetooth
- maybe implement method `did:peer.3` (this is an extension)
- maybe implement method `did:peer.3` and `did:peer.4`
- [TODO] method `did:key`
- maybe implement method `did:jwk` https://github.com/quartzjer/did-jwk
- maybe implement methods ["KERI lite"](https://docs.google.com/presentation/d/1ksqVxeCAvqLjr67htWZ4JYaSnI8TUZIO7tDMF5npHTo/edit#slide=id.g1ca1fd90f33_0_0)
- be part of the Adopters in https://github.com/sbt/sbt-ci-release/
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/main/scala/fmgp/webapp/AgentMessages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ object AgentMessageStorage {
// job(ctx.owner)
()
},
// code("AgentMessageStorage"),
// p("Agent Message Storage of ", child <-- Global.agentVar.signal.map(_.map(_.id.string).getOrElse("NONE"))),
code("AgentMessageStorage"),
p("Agent Message Storage of ", child <-- Global.agentVar.signal.map(_.map(_.id.string).getOrElse("NONE"))),
// br(),
div( // container
padding := "12pt",
Expand Down
4 changes: 4 additions & 0 deletions webapp/src/main/scala/fmgp/webapp/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ object App {
.collectSignal[OOBPage](page => OutOfBandTool(page))
.collectStatic(QRcodeScannerPage)(QRcodeScannerTool())
.collectStatic(NFCScannerPage)(NFCScannerTool())
.collectStatic(WebBluetoothPage)(WebBluetoothTool())
.collectStatic(DiscordBotPage)(DiscordBotInfo())
.collectStatic(DocPage)(Doc())
.collectStatic(AgentManagementPage)(AgentManagement())
// .collectStatic(AgentDBPage)(AgentDB())
Expand All @@ -86,6 +88,8 @@ object App {
SettingsPage,
QRcodeScannerPage,
NFCScannerPage,
WebBluetoothPage,
DiscordBotPage,
OOBPage(oobExample),
ResolverPage(didExample),
AgentManagementPage,
Expand Down
36 changes: 36 additions & 0 deletions webapp/src/main/scala/fmgp/webapp/DiscordBotInfo.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package fmgp.webapp

import org.scalajs.dom
import org.scalajs.dom.HTMLElement
import com.raquo.laminar.api.L._
import com.raquo.laminar.nodes.ReactiveHtmlElement
import typings.std.stdStrings.text
import typings.mermaid

import fmgp.did._
object DiscordBotInfo {

def apply(): HtmlElement = // rootElement
div(
p("Discord Bot"),
p("The Discord bot is this a WIP (2023-11-05)"),
p(
"The Bot id is ",
code("1170442329883168788"),
". ",
a(
href := "https://discord.com/api/oauth2/authorize?client_id=1170442329883168788&permissions=8&scope=bot",
"Click here to add the Bot"
),
". The permission need to be refine (is Administrator for now)."
),
p("Capabilities:"),
ul(
li("[WIP] As a Discord user proved that you control the DID"),
li("[TODO] Setup Discord ROLEs based on DID Comm interactions"),
li("[TODO] As a DID get the Verifiable Credentials that you control a Discord user"),
li("[TODO] Setup Discord ROLEs based on Verifiable Credentials"),
)
)

}
52 changes: 37 additions & 15 deletions webapp/src/main/scala/fmgp/webapp/Home.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,53 @@ object Home {

def hack = mermaid.mod.default

def showPage(page: MyRouter.Page, message: String) =
p("Navigate to ", b(message), MyRouter.navigateTo(page), page.makeI)

def apply(): HtmlElement = // rootElement
div(
p("Sandbox for DID Comm v2.1"),
p("Navigate to ", b("Settings Page"), MyRouter.navigateTo(MyRouter.SettingsPage)),
p("Navigate to ", b("OOB Tool "), MyRouter.navigateTo(MyRouter.OOBPage(App.oobExample))),
p("Navigate to ", b("QRcode Scanner Tool "), MyRouter.navigateTo(MyRouter.QRcodeScannerPage)),
p("Navigate to ", b("NFC Scanner Tool "), MyRouter.navigateTo(MyRouter.NFCScannerPage)),
p("Navigate to ", b("DID Resolver Tool "), MyRouter.navigateTo(MyRouter.ResolverPage(App.didExample))),
p("Navigate to ", b("Encrypt Tool "), MyRouter.navigateTo(MyRouter.EncryptPage)),
p("Navigate to ", b("Decrypt Tool "), MyRouter.navigateTo(MyRouter.DecryptPage)),
p("Navigate to ", b("Basic Message "), MyRouter.navigateTo(MyRouter.BasicMessagePage)),
p("Navigate to ", b("Trust Ping "), MyRouter.navigateTo(MyRouter.TrustPingPage)),
p("Navigate to ", b("TapIntoStream Tool "), MyRouter.navigateTo(MyRouter.TapIntoStreamPage)),
showPage(MyRouter.SettingsPage, "Settings Page"),
showPage(MyRouter.AgentManagementPage, "Agent Management"),
showPage(MyRouter.AgentMessageStoragePage, "Agent Message Storage"),
showPage(MyRouter.OOBPage(App.oobExample), "OOB Tool"),
showPage(MyRouter.QRcodeScannerPage, "DIDComm over QRcode"),
showPage(MyRouter.NFCScannerPage, "DIDComm over NFC"),
showPage(MyRouter.ResolverPage(App.didExample), "DID Resolver Tool"),
showPage(MyRouter.EncryptPage, "Encrypt Tool"),
showPage(MyRouter.DecryptPage, "Decrypt Tool"),
// p(
// "Navigate to ",
// b("Message DB"),
// " (only works for alice, bob and charlie)",
// MyRouter.navigateTo(MyRouter.AgentDBPage)
// ),
// p("Navigate to ", b("Agent Message DB"), MyRouter.navigateTo(MyRouter.AgentDBPage)),
p("Navigate to ", b("Mediator (Alice)"), MyRouter.navigateTo(MyRouter.MediatorPage)),
p("Navigate to ", b("Agent Management"), MyRouter.navigateTo(MyRouter.AgentManagementPage)),
p("Navigate to ", b("Documentation for scala-did lib"), MyRouter.navigateTo(MyRouter.DocPage)),
// showPage(MyRouter.AgentDBPage, ge("Agent Message DB"),
br(),
p("In developing:"),
showPage(MyRouter.DiscordBotPage, "Discord Bot (with DIDComm capabilities)"),
showPage(MyRouter.WebBluetoothPage, "DIDComm over Web Bluetooth"),
br(),
p("Deprecated:"),
showPage(MyRouter.BasicMessagePage, "Basic Message"),
showPage(MyRouter.TrustPingPage, "Trust Ping"),
showPage(MyRouter.TapIntoStreamPage, "TapIntoStream Tool"),
showPage(MyRouter.MediatorPage, "Mediator (Alice)"),
showPage(MyRouter.DocPage, "Documentation for scala-did lib"),
br(),
p("Ideas for experiments and applications:"),
ul(
li("[Done] DID Comm over Websocket"),
li("[WIP] DID Comm over Push API"),
li("DID Comm Protocol to Bootstrap WebRTC"),
li("DID Comm over WebRTC: This would be indeed very interesting"),
li("DID Comm over Email (in top of a SMTP server): Prove the control/ownership of emails addresses"),
li("DID Comm over Power Line: Smart meters"),
li("DID Comm over Li-Fi: Vehicles communication, Broadcast news, Indoor positioning system"),
li("DID Comm over Audio Waves"),
),
br(),
p("DIDs: "),
p("DIDs:"),
div(child <-- statementVar.signal.map(e => getHtml(e)))
)
def getHtml(statement: Option[Statement], indent: Int = 0): ReactiveHtmlElement[HTMLElement] =
Expand Down
16 changes: 14 additions & 2 deletions webapp/src/main/scala/fmgp/webapp/MyRouter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ object MyRouter {
sealed abstract class Page(
val title: String,
val icon: String // https://fonts.google.com/icons?selected=Material+Icons+Outlined
)
) {
def makeI = i(
className("material-icons mdc-list-item__graphic"),
aria.hidden(true),
this.icon
)
}

case object HomePage extends Page("Home", "home")
case object SettingsPage extends Page("Settings", "settings")
case class OOBPage(query_oob: String) extends Page("OutOfBand", "app_shortcut")
object OOBPage { def apply(oob: OutOfBand) = new OOBPage(oob.data.urlBase64) }
case object QRcodeScannerPage extends Page("QRcodeScanner", "qr_code_scanner")
case object NFCScannerPage extends Page("NFCScanner", "nfc")
case object NFCScannerPage extends Page("NFCScanner", "nfc") // or "contactless"
case object WebBluetoothPage extends Page("WebBluetooth", "bluetooth")
case object DiscordBotPage extends Page("DIscordBot", "smart_toy")
case object DocPage extends Page("Doc", "menu_book")
case object AgentManagementPage extends Page("AgentManagement", "manage_accounts")
// case object DIDPage extends Page("DID", "visibility")
Expand All @@ -38,6 +46,8 @@ object MyRouter {
given oobPageRW: ReadWriter[OOBPage] = macroRW
given qrcodeScannerPageRW: ReadWriter[QRcodeScannerPage.type] = macroRW
given nfcScannerPageRW: ReadWriter[NFCScannerPage.type] = macroRW
given webBluetoothPageRW: ReadWriter[WebBluetoothPage.type] = macroRW
given discordBotPageRW: ReadWriter[DiscordBotPage.type] = macroRW
given docPageRW: ReadWriter[DocPage.type] = macroRW
given keysPageRW: ReadWriter[AgentManagementPage.type] = macroRW
// given agentDBPageRW: ReadWriter[AgentDBPage.type] = macroRW
Expand Down Expand Up @@ -72,6 +82,8 @@ object MyRouter {
Route.static(DocPage, root / "doc" / endOfSegments, Router.localFragmentBasePath),
Route.static(QRcodeScannerPage, root / "scanner" / endOfSegments, Router.localFragmentBasePath),
Route.static(NFCScannerPage, root / "nfc" / endOfSegments, Router.localFragmentBasePath),
Route.static(WebBluetoothPage, root / "bluetooth" / endOfSegments, Router.localFragmentBasePath),
Route.static(DiscordBotPage, root / "discord" / endOfSegments, Router.localFragmentBasePath),
Route.static(AgentManagementPage, root / "agentkeys" / endOfSegments, Router.localFragmentBasePath),
// Route.static(AgentDBPage, root / "db" / endOfSegments, Router.localFragmentBasePath),
Route.static(AgentMessageStoragePage, root / "agent" / endOfSegments, Router.localFragmentBasePath),
Expand Down
26 changes: 26 additions & 0 deletions webapp/src/main/scala/fmgp/webapp/WebBluetoothTool.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fmgp.webapp

import org.scalajs.dom
import org.scalajs.dom.HTMLElement
import com.raquo.laminar.api.L._
import com.raquo.laminar.nodes.ReactiveHtmlElement
import typings.std.stdStrings.text
import typings.mermaid

import fmgp.did._
object WebBluetoothTool {

def apply(): HtmlElement = // rootElement
div(
p("WebBluetoothTool"),
p("The Discord bot is this a WIP (2023-09-10)"),
p(
"Specs of ",
a(
href := "https://translate.google.pt/?sl=en&tl=pt&text=we%20did%20come%20capabilities&op=translate",
"Web Bluetooth API"
),
),
)

}

0 comments on commit 56a342b

Please sign in to comment.