mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
feature/refactor did state (#10)
* feat(did): remove account types * feat: Refactor Property to Proof in zkprop.go * feat: add ZKP proof mechanism for verifications * fix: return bool and error from pinInitialVault * feat: implement KeyshareSet for managing user and validator keyshares * feat: Update Credential type in protobuf * feat: update credential schema with sign count * feat: migrate and modules to middleware * refactor: rename vault module to ORM * chore(dwn): add service worker registration to index template * feat: integrate service worker for offline functionality * refactor(did): use DIDNamespace enum for verification method in proto reflection * refactor: update protobuf definitions to support Keyshare * feat: expose did keeper in app keepers * Add Motr Web App * refactor: rename motr/handlers/discovery.go to motr/handlers/openid.go * refactor: move session related code to middleware * feat: add database operations for managing assets, chains, and credentials * feat: add htmx support for UI updates * refactor: extract common helper scripts * chore: remove unused storage GUI components * refactor: Move frontend rendering to dedicated handlers * refactor: rename to * refactor: move alert implementation to templ * feat: add alert component with icon, title, and message * feat: add new RequestHeaders struct to store request headers * Feature/create home view (#9) * refactor: move view logic to new htmx handler * refactor: remove unnecessary dependencies * refactor: remove unused dependencies * feat(devbox): integrate air for local development * feat: implement openid connect discovery document * refactor: rename to * refactor(did): update service handling to support DNS discovery * feat: add support for user and validator keyshares * refactor: move keyshare signing logic to signer
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package main
|
||||
|
||||
templ VaultIndex() {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Sonr Vault</title>
|
||||
<script>
|
||||
navigator.serviceWorker.register({ swPath });
|
||||
|
||||
// Skip installed stage and jump to activating stage
|
||||
addEventListener("install", (event) => {
|
||||
event.waitUntil(skipWaiting());
|
||||
});
|
||||
|
||||
// Start controlling clients as soon as the SW is activated
|
||||
addEventListener("activate", (event) => {
|
||||
event.waitUntil(clients.claim());
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Sonr Vault</h1>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
package main
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func VaultIndex() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Sonr Vault</title><script>\n navigator.serviceWorker.register({ swPath });\n\n // Skip installed stage and jump to activating stage\n addEventListener(\"install\", (event) => {\n event.waitUntil(skipWaiting());\n });\n\n // Start controlling clients as soon as the SW is activated\n addEventListener(\"activate\", (event) => {\n event.waitUntil(clients.claim());\n });\n </script></head><body><h1>Sonr Vault</h1></body></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
+90
-15
@@ -7,37 +7,112 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
wasmhttp "github.com/nlepage/go-wasm-http-server"
|
||||
"github.com/onsonr/sonr/internal/vfs/wasm"
|
||||
|
||||
"github.com/donseba/go-htmx"
|
||||
"github.com/onsonr/sonr/internal/db"
|
||||
)
|
||||
|
||||
var edb *db.DB
|
||||
var dwn *DWN
|
||||
|
||||
func main() {
|
||||
// Initialize the database
|
||||
initDB()
|
||||
|
||||
e := echo.New()
|
||||
e.POST("/api/insert/:account/:address", itemsHandler)
|
||||
wasmhttp.Serve(e)
|
||||
type DWN struct {
|
||||
*echo.Echo
|
||||
DB *db.DB
|
||||
Htmx *htmx.HTMX
|
||||
}
|
||||
|
||||
func initDB() {
|
||||
var err error
|
||||
edb, err = db.Open(db.New())
|
||||
func main() {
|
||||
dwn = initRails()
|
||||
|
||||
dwn.GET("/", htmxHandler)
|
||||
dwn.POST("/accounts", accountsHandler)
|
||||
|
||||
wasm.Serve(dwn.Echo)
|
||||
}
|
||||
|
||||
// initRails initializes the Rails application
|
||||
func initRails() *DWN {
|
||||
// Open the database
|
||||
cnfg := db.New()
|
||||
db, err := cnfg.Open()
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
// Initialize the htmx handler
|
||||
return &DWN{
|
||||
Echo: echo.New(),
|
||||
DB: db,
|
||||
Htmx: htmx.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func itemsHandler(e echo.Context) error {
|
||||
func accountsHandler(e echo.Context) error {
|
||||
switch e.Request().Method {
|
||||
case "GET":
|
||||
case "POST":
|
||||
edb.AddAccount(e.Param("account"), e.Param("address"))
|
||||
case "PUT":
|
||||
// dwn.DB.AddAccount(e.Param("account"), e.Param("address"))
|
||||
default:
|
||||
e.Error(errors.New("Method not allowed"))
|
||||
}
|
||||
return e.JSON(200, "OK")
|
||||
}
|
||||
|
||||
func htmxHandler(e echo.Context) error {
|
||||
// initiate a new htmx handler
|
||||
h := dwn.Htmx.NewHandler(e.Response(), e.Request())
|
||||
|
||||
// check if the request is a htmx request
|
||||
if h.IsHxRequest() {
|
||||
// do something
|
||||
}
|
||||
|
||||
// check if the request is boosted
|
||||
if h.IsHxBoosted() {
|
||||
// do something
|
||||
}
|
||||
|
||||
// check if the request is a history restore request
|
||||
if h.IsHxHistoryRestoreRequest() {
|
||||
// do something
|
||||
}
|
||||
|
||||
// check if the request is a prompt request
|
||||
if h.RenderPartial() {
|
||||
// do something
|
||||
}
|
||||
|
||||
// set the headers for the response, see docs for more options
|
||||
h.PushURL("http://push.url")
|
||||
h.ReTarget("#ReTarged")
|
||||
|
||||
// write the output like you normally do.
|
||||
// check the inspector tool in the browser to see that the headers are set.
|
||||
_, err := h.Write([]byte("OK"))
|
||||
return err
|
||||
}
|
||||
|
||||
//
|
||||
// func credentialsHandler(e echo.Context) error {
|
||||
// switch e.Request().Method {
|
||||
// case "GET":
|
||||
// dwn.DB.GetCredentials(e.Param("account"))
|
||||
// case "PUT":
|
||||
// dwn.DB.AddCredentials(e.Param("account"), e.Param("address"))
|
||||
// default:
|
||||
// e.Error(errors.New("Method not allowed"))
|
||||
// }
|
||||
// return e.JSON(200, "OK")
|
||||
// }
|
||||
//
|
||||
// func keysharesHandler(e echo.Context) error {
|
||||
// switch e.Request().Method {
|
||||
// case "GET":
|
||||
// dwn.DB.GetKeyshares(e.Param("account"))
|
||||
// case "PUT":
|
||||
// dwn.DB.AddKeyshares(e.Param("account"), e.Param("address"))
|
||||
// default:
|
||||
// e.Error(errors.New("Method not allowed"))
|
||||
// }
|
||||
// return e.JSON(200, "OK")
|
||||
// }
|
||||
|
||||
+2
-2
@@ -95,8 +95,8 @@ func NewRootCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
// Set the context chain ID and validator address
|
||||
app.SetLocalChainID(initClientCtx.ChainID)
|
||||
app.SetLocalValidatorAddress(initClientCtx.FromAddress.String())
|
||||
// app.SetLocalChainID(initClientCtx.ChainID)
|
||||
// app.SetLocalValidatorAddress(initClientCtx.FromAddress.String())
|
||||
|
||||
customAppTemplate, customAppConfig := initAppConfig()
|
||||
customCMTConfig := initCometBFTConfig()
|
||||
|
||||
Reference in New Issue
Block a user