Squash merge develop into master

This commit is contained in:
Prad Nukala
2024-09-14 14:27:45 -04:00
parent a929e61d01
commit 05bda3d1b2
227 changed files with 56902 additions and 10178 deletions
+40
View File
@@ -0,0 +1,40 @@
//go:build js && wasm
// +build js,wasm
package main
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/internal/vfs/wasm"
"github.com/onsonr/sonr/internal/db"
)
var dwn *DWN
type DWN struct {
*echo.Echo
DB *db.DB
}
func main() {
dwn = initRails()
wasm.Serve(dwn.Echo)
}
// initRails initializes the Rails application
func initRails() *DWN {
// Open the database
e := echo.New()
db, err := db.New()
if err != nil {
panic(err.Error())
}
db.ServeEcho(e.Group("/dwn"))
// Initialize the htmx handler
return &DWN{
Echo: e,
DB: db,
}
}
+61
View File
@@ -0,0 +1,61 @@
//go:build wasm
package main
import (
"github.com/labstack/echo/v4"
"github.com/syumai/workers"
"github.com/onsonr/sonr/internal/db"
"github.com/onsonr/sonr/internal/gui/views"
"github.com/onsonr/sonr/internal/mdw"
"github.com/onsonr/sonr/internal/svc"
)
func main() {
// Configure the server
e := echo.New()
// Use Middlewares
e.Use(mdw.UseSession)
// Setup routes
registerFrontend(e)
registerOpenID(e.Group("/authorize"))
registerVault(e.Group("/vault"))
// Serve Worker
workers.Serve(e)
}
func registerFrontend(e *echo.Echo) {
// Add Public Pages
e.GET("/", views.HomeView)
e.GET("/login", views.LoginView)
e.POST("/login/:identifier", svc.HandleCredentialAssertion)
e.GET("/register", views.RegisterView)
e.POST("/register/:subject", svc.HandleCredentialCreation)
e.POST("/register/:subject/check", svc.CheckSubjectIsValid)
e.GET("/profile", views.ProfileView)
}
func registerOpenID(g *echo.Group) {
// Add Authenticated Pages
g.Use(mdw.MacaroonMiddleware("test", "test"))
g.GET("/", views.AuthorizeView)
g.GET("/discovery", svc.GetDiscovery)
g.GET("/jwks", svc.GetJWKS)
g.GET("/token", svc.GetToken)
g.POST("/:origin/grant/:subject", svc.GrantAuthorization)
}
func registerVault(g *echo.Group) {
// Add Authenticated Pages
g.Use(mdw.MacaroonMiddleware("test", "test"))
vault, err := db.New(db.WitDir("vault"))
if err != nil {
// panic(err)
}
vault.ServeEcho(g)
}
+10
View File
@@ -0,0 +1,10 @@
name = "sonr-id"
main = "./build/worker.mjs"
compatibility_date = "2024-07-26"
[dev]
ip = "localhost"
port = 4202
[build]
command = "devbox run build:motr"
+1 -1
View File
@@ -7,7 +7,7 @@ import (
cmtcfg "github.com/cometbft/cometbft/config"
dbm "github.com/cosmos/cosmos-db"
"github.com/onsonr/hway/app"
"github.com/onsonr/sonr/app"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/viper"
+4 -1
View File
@@ -6,11 +6,14 @@ import (
"cosmossdk.io/log"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
_ "github.com/joho/godotenv/autoload"
"github.com/onsonr/hway/app"
"github.com/onsonr/sonr/app"
"github.com/onsonr/sonr/internal/tui"
)
func main() {
rootCmd := NewRootCmd()
tui.AddTUICmds(rootCmd)
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err)
+13 -17
View File
@@ -3,11 +3,8 @@ package main
import (
"os"
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cobra"
"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
@@ -19,11 +16,10 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/tx"
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/spf13/cobra"
"github.com/onsonr/hway/app"
"github.com/onsonr/hway/app/params"
// NewRootCmd creates a new root command for chain app. It is called once in the
// main function.
"github.com/onsonr/sonr/app"
"github.com/onsonr/sonr/app/params"
)
func NewRootCmd() *cobra.Command {
@@ -34,14 +30,14 @@ func NewRootCmd() *cobra.Command {
cfg.Seal()
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
// note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go)
tempApp := app.NewChainApp(
preApp := app.NewChainApp(
log.NewNopLogger(), dbm.NewMemDB(), nil, false, simtestutil.NewAppOptionsWithFlagHome(tempDir()),
)
encodingConfig := params.EncodingConfig{
InterfaceRegistry: tempApp.InterfaceRegistry(),
Codec: tempApp.AppCodec(),
TxConfig: tempApp.TxConfig(),
Amino: tempApp.LegacyAmino(),
InterfaceRegistry: preApp.InterfaceRegistry(),
Codec: preApp.AppCodec(),
TxConfig: preApp.TxConfig(),
Amino: preApp.LegacyAmino(),
}
initClientCtx := client.Context{}.
@@ -99,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()
@@ -109,10 +105,10 @@ func NewRootCmd() *cobra.Command {
},
}
initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, tempApp.BasicModuleManager)
initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, preApp.BasicModuleManager)
// add keyring to autocli opts
autoCliOpts := tempApp.AutoCliOpts()
autoCliOpts := preApp.AutoCliOpts()
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx = initClientCtx
+1 -1
View File
@@ -39,7 +39,7 @@ import (
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/onsonr/hway/app"
"github.com/onsonr/sonr/app"
)
var (