diff --git a/internal/gateway/handlers/index/handlers.go b/internal/gateway/handlers/index/handlers.go new file mode 100644 index 000000000..1a56d8aa0 --- /dev/null +++ b/internal/gateway/handlers/index/handlers.go @@ -0,0 +1,13 @@ +package index + +import ( + "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/pkg/common/response" +) + +func Handler(c echo.Context) error { + if isExpired(c) { + return response.TemplEcho(c, ReturningView()) + } + return response.TemplEcho(c, InitialView()) +} diff --git a/internal/gateway/handlers/index_handler.go b/internal/gateway/handlers/index/model.go similarity index 54% rename from internal/gateway/handlers/index_handler.go rename to internal/gateway/handlers/index/model.go index 6b62a0c9b..10d691bc3 100644 --- a/internal/gateway/handlers/index_handler.go +++ b/internal/gateway/handlers/index/model.go @@ -1,23 +1,10 @@ -package handlers +package index import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/gateway/pages/index" "github.com/onsonr/sonr/internal/gateway/session" - "github.com/onsonr/sonr/pkg/common/response" ) -func HandleIndex(c echo.Context) error { - if isExpired(c) { - return response.TemplEcho(c, index.ReturningView()) - } - return response.TemplEcho(c, index.InitialView()) -} - -// ╭─────────────────────────────────────────────────────────╮ -// │ Utility Functions │ -// ╰─────────────────────────────────────────────────────────╯ - // Initial users have no authorization, user handle, or vault address func isInitial(c echo.Context) bool { sess, err := session.Get(c) diff --git a/internal/gateway/pages/index/page.templ b/internal/gateway/handlers/index/views.templ similarity index 100% rename from internal/gateway/pages/index/page.templ rename to internal/gateway/handlers/index/views.templ diff --git a/internal/gateway/pages/index/page_templ.go b/internal/gateway/handlers/index/views_templ.go similarity index 100% rename from internal/gateway/pages/index/page_templ.go rename to internal/gateway/handlers/index/views_templ.go diff --git a/internal/gateway/handlers/register/forms.templ b/internal/gateway/handlers/register/forms.templ new file mode 100644 index 000000000..c7a320fb3 --- /dev/null +++ b/internal/gateway/handlers/register/forms.templ @@ -0,0 +1,189 @@ +package register + +import "github.com/onsonr/sonr/pkg/common/styles/layout" + +templ formCreateProfile(action string, method string, data CreateProfileData) { +
+ +
+
+ +
+
+ @layout.Rows() { + + + } + @layout.Spacer() + +
+ +
+
+ @layout.Spacer() + +
+ + + Cancel + + + Next + + +
+ +
+
+} + +templ formRegisterPasskey(action, method string, data RegisterPasskeyData) { +
+ + +
+
+ @sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock) +
+
+ + @cryptoWalletOption("SNR", "Sonr", true) + @cryptoWalletOption("BTC", "Bitcoin", true) + @cryptoWalletOption("ETH", "Ethereum", true) + @cryptoWalletOption("SOL", "Solana", false) + @cryptoWalletOption("LTC", "Litecoin", false) + @cryptoWalletOption("DOGE", "Dogecoin", false) + @cryptoWalletOption("XRP", "Ripple", false) + @cryptoWalletOption("OSMO", "Osmosis", false) + @cryptoWalletOption("ATOM", "Cosmos", false) + @cryptoWalletOption("STARZ", "Stargaze", false) + @cryptoWalletOption("AKT", "Akash", false) + @cryptoWalletOption("EVMOS", "Evmos", false) + @cryptoWalletOption("FIL", "Filecoin", false) + @cryptoWalletOption("AXL", "Axelar", false) + + +
+ @passkeyDropzone(data.Address, data.Handle, data.Challenge) + + + Cancel + +
+ +
+
+} + +templ formRegisterPasskey(action, method string, data RegisterPasskeyData) { +
+ + +
+
+ @sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock) +
+
+ + @cryptoWalletOption("SNR", "Sonr", true) + @cryptoWalletOption("BTC", "Bitcoin", true) + @cryptoWalletOption("ETH", "Ethereum", true) + @cryptoWalletOption("SOL", "Solana", false) + @cryptoWalletOption("LTC", "Litecoin", false) + @cryptoWalletOption("DOGE", "Dogecoin", false) + @cryptoWalletOption("XRP", "Ripple", false) + @cryptoWalletOption("OSMO", "Osmosis", false) + @cryptoWalletOption("ATOM", "Cosmos", false) + @cryptoWalletOption("STARZ", "Stargaze", false) + @cryptoWalletOption("AKT", "Akash", false) + @cryptoWalletOption("EVMOS", "Evmos", false) + @cryptoWalletOption("FIL", "Filecoin", false) + @cryptoWalletOption("AXL", "Axelar", false) + + +
+ @passkeyDropzone(data.Address, data.Handle, data.Challenge) + + + Cancel + +
+ +
+
+} diff --git a/internal/gateway/handlers/register/forms_templ.go b/internal/gateway/handlers/register/forms_templ.go new file mode 100644 index 000000000..d3611269d --- /dev/null +++ b/internal/gateway/handlers/register/forms_templ.go @@ -0,0 +1,369 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package register + +//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" + +import "github.com/onsonr/sonr/pkg/common/styles/layout" + +func formCreateProfile(action string, method string, data CreateProfileData) 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 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + 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("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Var4 := 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_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = layout.Rows().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = layout.Spacer().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = layout.Spacer().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Cancel Next
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func formRegisterPasskey(action, method string, data RegisterPasskeyData) 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 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + 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_Var6 := templ.GetChildren(ctx) + if templ_7745c5c3_Var6 == nil { + templ_7745c5c3_Var6 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("SNR", "Sonr", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("BTC", "Bitcoin", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("ETH", "Ethereum", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("SOL", "Solana", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("LTC", "Litecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("DOGE", "Dogecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("XRP", "Ripple", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("OSMO", "Osmosis", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("ATOM", "Cosmos", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("STARZ", "Stargaze", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("AKT", "Akash", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("EVMOS", "Evmos", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("FIL", "Filecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("AXL", "Axelar", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = passkeyDropzone(data.Address, data.Handle, data.Challenge).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" Cancel
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func formRegisterPasskey(action, method string, data RegisterPasskeyData) 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 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + 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_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("SNR", "Sonr", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("BTC", "Bitcoin", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("ETH", "Ethereum", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("SOL", "Solana", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("LTC", "Litecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("DOGE", "Dogecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("XRP", "Ripple", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("OSMO", "Osmosis", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("ATOM", "Cosmos", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("STARZ", "Stargaze", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("AKT", "Akash", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("EVMOS", "Evmos", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("FIL", "Filecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("AXL", "Axelar", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = passkeyDropzone(data.Address, data.Handle, data.Challenge).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" Cancel
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/handlers.go b/internal/gateway/handlers/register/handlers.go new file mode 100644 index 000000000..4592c414a --- /dev/null +++ b/internal/gateway/handlers/register/handlers.go @@ -0,0 +1,52 @@ +package register + +import ( + "fmt" + "net/http" + + "github.com/go-webauthn/webauthn/protocol" + "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/crypto/mpc" + "github.com/onsonr/sonr/pkg/common/response" +) + +func HandleCreateProfile(c echo.Context) error { + dat := CreateProfileData{ + FirstNumber: 1, + LastNumber: 2, + } + return response.TemplEcho(c, ProfileFormView(dat)) +} + +func HandlePasskeyStart(c echo.Context) error { + challenge, _ := protocol.CreateChallenge() + handle := c.FormValue("handle") + firstName := c.FormValue("first_name") + lastName := c.FormValue("last_name") + + ks, err := mpc.NewKeyset() + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + dat := RegisterPasskeyData{ + Address: ks.Address(), + Handle: handle, + Name: fmt.Sprintf("%s %s", firstName, lastName), + Challenge: challenge.String(), + CreationBlock: "00001", + } + return response.TemplEcho(c, LinkCredentialView(dat)) +} + +func HandlePasskeyFinish(c echo.Context) error { + // Get the raw credential JSON string + credentialJSON := c.FormValue("credential") + if credentialJSON == "" { + return echo.NewHTTPError(http.StatusBadRequest, "missing credential data") + } + _, err := extractCredentialDescriptor(credentialJSON) + if err != nil { + return err + } + return response.TemplEcho(c, LoadingVaultView()) +} diff --git a/internal/gateway/pages/register/creds.templ b/internal/gateway/handlers/register/inputs.templ similarity index 62% rename from internal/gateway/pages/register/creds.templ rename to internal/gateway/handlers/register/inputs.templ index 03f868385..e5bc0f8b3 100644 --- a/internal/gateway/pages/register/creds.templ +++ b/internal/gateway/handlers/register/inputs.templ @@ -1,76 +1,5 @@ package register -type RegisterPasskeyData struct { - Address string - Handle string - Name string - Challenge string - CreationBlock string -} - -templ formRegisterPasskey(action, method string, data RegisterPasskeyData) { -
- - -
-
- @sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock) -
-
- - @cryptoWalletOption("SNR", "Sonr", true) - @cryptoWalletOption("BTC", "Bitcoin", true) - @cryptoWalletOption("ETH", "Ethereum", true) - @cryptoWalletOption("SOL", "Solana", false) - @cryptoWalletOption("LTC", "Litecoin", false) - @cryptoWalletOption("DOGE", "Dogecoin", false) - @cryptoWalletOption("XRP", "Ripple", false) - @cryptoWalletOption("OSMO", "Osmosis", false) - @cryptoWalletOption("ATOM", "Cosmos", false) - @cryptoWalletOption("STARZ", "Stargaze", false) - @cryptoWalletOption("AKT", "Akash", false) - @cryptoWalletOption("EVMOS", "Evmos", false) - @cryptoWalletOption("FIL", "Filecoin", false) - @cryptoWalletOption("AXL", "Axelar", false) - - -
- @passkeyDropzone(data.Address, data.Handle, data.Challenge) - - - Cancel - -
- -
-
-} templ passkeyDropzone(addr string, userHandle string, challenge string) { @@ -208,11 +137,3 @@ templ cryptoWalletOption(ticker string, name string, isDefault bool) { } } - -// Helper function to shorten address -func shortenAddress(address string) string { - if len(address) <= 20 { - return address - } - return address[:16] + "..." + address[len(address)-4:] -} diff --git a/internal/gateway/pages/register/creds_templ.go b/internal/gateway/handlers/register/inputs_templ.go similarity index 59% rename from internal/gateway/pages/register/creds_templ.go rename to internal/gateway/handlers/register/inputs_templ.go index 9e21af634..47fb549bd 100644 --- a/internal/gateway/pages/register/creds_templ.go +++ b/internal/gateway/handlers/register/inputs_templ.go @@ -8,15 +8,7 @@ package register import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -type RegisterPasskeyData struct { - Address string - Handle string - Name string - Challenge string - CreationBlock string -} - -func formRegisterPasskey(action, method string, data RegisterPasskeyData) templ.Component { +func passkeyDropzone(addr string, userHandle string, challenge string) 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 if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -37,133 +29,6 @@ func formRegisterPasskey(action, method string, data RegisterPasskeyData) templ. templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("SNR", "Sonr", true).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("BTC", "Bitcoin", true).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("ETH", "Ethereum", true).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("SOL", "Solana", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("LTC", "Litecoin", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("DOGE", "Dogecoin", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("XRP", "Ripple", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("OSMO", "Osmosis", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("ATOM", "Cosmos", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("STARZ", "Stargaze", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("AKT", "Akash", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("EVMOS", "Evmos", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("FIL", "Filecoin", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = cryptoWalletOption("AXL", "Axelar", false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = passkeyDropzone(data.Address, data.Handle, data.Challenge).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" Cancel
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func passkeyDropzone(addr string, userHandle string, challenge string) 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 - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - 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_Var4 := templ.GetChildren(ctx) - if templ_7745c5c3_Var4 == nil { - templ_7745c5c3_Var4 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, createPasskey(addr, userHandle, challenge)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -172,8 +37,8 @@ func passkeyDropzone(addr string, userHandle string, challenge string) templ.Com if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var5 templ.ComponentScript = createPasskey(addr, userHandle, challenge) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5.Call) + var templ_7745c5c3_Var2 templ.ComponentScript = createPasskey(addr, userHandle, challenge) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2.Call) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -292,21 +157,21 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var6 := templ.GetChildren(ctx) - if templ_7745c5c3_Var6 == nil { - templ_7745c5c3_Var6 = templ.NopComponent + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

sonr-testnet-1

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(handle) + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(handle) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 173, Col: 43} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 102, Col: 43} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -314,12 +179,12 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var8 string - templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(shortenAddress(addr)) + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(shortenAddress(addr)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 180, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 109, Col: 58} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -327,12 +192,12 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var9 string - templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(creationBlock) + var templ_7745c5c3_Var6 string + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(creationBlock) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 185, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 114, Col: 55} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -340,12 +205,12 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var10 string - templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(name) + var templ_7745c5c3_Var7 string + templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 189, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 118, Col: 32} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -373,9 +238,9 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var11 := templ.GetChildren(ctx) - if templ_7745c5c3_Var11 == nil { - templ_7745c5c3_Var11 = templ.NopComponent + templ_7745c5c3_Var8 := templ.GetChildren(ctx) + if templ_7745c5c3_Var8 == nil { + templ_7745c5c3_Var8 = templ.NopComponent } ctx = templ.ClearChildren(ctx) if isDefault { @@ -383,12 +248,12 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var12 string - templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) + var templ_7745c5c3_Var9 string + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 198, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 127, Col: 27} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -396,12 +261,12 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var13 string - templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 199, Col: 39} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 128, Col: 39} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -409,12 +274,12 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var14 string - templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(name) + var templ_7745c5c3_Var11 string + templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 200, Col: 9} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 129, Col: 9} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -427,12 +292,12 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var15 string - templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) + var templ_7745c5c3_Var12 string + templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 204, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 133, Col: 27} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -440,12 +305,12 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) + var templ_7745c5c3_Var13 string + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 205, Col: 39} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 134, Col: 39} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -453,12 +318,12 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var17 string - templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(name) + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/pages/register/creds.templ`, Line: 206, Col: 9} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/inputs.templ`, Line: 135, Col: 9} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -471,12 +336,4 @@ func cryptoWalletOption(ticker string, name string, isDefault bool) templ.Compon }) } -// Helper function to shorten address -func shortenAddress(address string) string { - if len(address) <= 20 { - return address - } - return address[:16] + "..." + address[len(address)-4:] -} - var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/model.go b/internal/gateway/handlers/register/model.go new file mode 100644 index 000000000..8172118b1 --- /dev/null +++ b/internal/gateway/handlers/register/model.go @@ -0,0 +1,72 @@ +package register + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/internal/gateway/database" +) + +type CreateProfileData struct { + TurnstileSiteKey string + FirstNumber int + LastNumber int +} + +type RegisterPasskeyData struct { + Address string + Handle string + Name string + Challenge string + CreationBlock string +} + +// Helper function to shorten address +func shortenAddress(address string) string { + if len(address) <= 20 { + return address + } + return address[:16] + "..." + address[len(address)-4:] +} + +func (d CreateProfileData) IsHumanLabel() string { + return fmt.Sprintf("What is %d + %d?", d.FirstNumber, d.LastNumber) +} + +func extractCredentialDescriptor(jsonString string) (*database.Credential, error) { + cred := &database.Credential{} + // Unmarshal the credential JSON + if err := json.Unmarshal([]byte(jsonString), cred); err != nil { + return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid credential format: %v", err)) + } + + // Validate required fields + if cred.ID == "" || cred.RawID == "" { + return nil, echo.NewHTTPError(http.StatusBadRequest, "missing credential ID") + } + if cred.Type != "public-key" { + return nil, echo.NewHTTPError(http.StatusBadRequest, "invalid credential type") + } + if cred.Response.AttestationObject == "" || cred.Response.ClientDataJSON == "" { + return nil, echo.NewHTTPError(http.StatusBadRequest, "missing attestation data") + } + + // Log detailed credential information + fmt.Printf("Credential Details:\n"+ + "ID: %s\n"+ + "Raw ID: %s\n"+ + "Type: %s\n"+ + "Authenticator Attachment: %s\n"+ + "Transports: %v\n"+ + "Attestation Object Size: %d bytes\n"+ + "Client Data Size: %d bytes\n", + cred.ID, + cred.RawID, + cred.Type, + cred.AuthenticatorAttachment, + cred.Transports, + ) + return cred, nil +} diff --git a/internal/gateway/pages/register/page.templ b/internal/gateway/handlers/register/views.templ similarity index 100% rename from internal/gateway/pages/register/page.templ rename to internal/gateway/handlers/register/views.templ diff --git a/internal/gateway/pages/register/page_templ.go b/internal/gateway/handlers/register/views_templ.go similarity index 100% rename from internal/gateway/pages/register/page_templ.go rename to internal/gateway/handlers/register/views_templ.go diff --git a/internal/gateway/handlers/register_handler.go b/internal/gateway/handlers/register_handler.go deleted file mode 100644 index c398121c8..000000000 --- a/internal/gateway/handlers/register_handler.go +++ /dev/null @@ -1,97 +0,0 @@ -package handlers - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "net/http" - - "github.com/go-webauthn/webauthn/protocol" - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/crypto/mpc" - "github.com/onsonr/sonr/internal/gateway/database" - "github.com/onsonr/sonr/internal/gateway/pages/register" - "github.com/onsonr/sonr/pkg/common/response" -) - -func HandleRegisterView(c echo.Context) error { - dat := register.CreateProfileData{ - FirstNumber: 1, - LastNumber: 2, - } - return response.TemplEcho(c, register.ProfileFormView(dat)) -} - -func HandleRegisterStart(c echo.Context) error { - challenge, _ := protocol.CreateChallenge() - handle := c.FormValue("handle") - firstName := c.FormValue("first_name") - lastName := c.FormValue("last_name") - - ks, err := mpc.NewKeyset() - if err != nil { - return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) - } - dat := register.RegisterPasskeyData{ - Address: ks.Address(), - Handle: handle, - Name: fmt.Sprintf("%s %s", firstName, lastName), - Challenge: challenge.String(), - CreationBlock: "00001", - } - return response.TemplEcho(c, register.LinkCredentialView(dat)) -} - -func HandleRegisterFinish(c echo.Context) error { - // Get the raw credential JSON string - credentialJSON := c.FormValue("credential") - if credentialJSON == "" { - return echo.NewHTTPError(http.StatusBadRequest, "missing credential data") - } - cred := database.Credential{} - // Unmarshal the credential JSON - if err := json.Unmarshal([]byte(credentialJSON), &cred); err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid credential format: %v", err)) - } - - // Validate required fields - if cred.ID == "" || cred.RawID == "" { - return echo.NewHTTPError(http.StatusBadRequest, "missing credential ID") - } - if cred.Type != "public-key" { - return echo.NewHTTPError(http.StatusBadRequest, "invalid credential type") - } - if cred.Response.AttestationObject == "" || cred.Response.ClientDataJSON == "" { - return echo.NewHTTPError(http.StatusBadRequest, "missing attestation data") - } - - // Decode attestation object and client data - attestationObj, err := base64.RawURLEncoding.DecodeString(cred.Response.AttestationObject) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, "invalid attestation object encoding") - } - - clientData, err := base64.RawURLEncoding.DecodeString(cred.Response.ClientDataJSON) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, "invalid client data encoding") - } - - // Log detailed credential information - fmt.Printf("Credential Details:\n"+ - "ID: %s\n"+ - "Raw ID: %s\n"+ - "Type: %s\n"+ - "Authenticator Attachment: %s\n"+ - "Transports: %v\n"+ - "Attestation Object Size: %d bytes\n"+ - "Client Data Size: %d bytes\n", - cred.ID, - cred.RawID, - cred.Type, - cred.AuthenticatorAttachment, - cred.Transports, - len(attestationObj), - len(clientData)) - - return response.TemplEcho(c, register.LoadingVaultView()) -} diff --git a/internal/gateway/handlers/spawn_handler.go b/internal/gateway/handlers/spawn_handler.go deleted file mode 100644 index 4da1905aa..000000000 --- a/internal/gateway/handlers/spawn_handler.go +++ /dev/null @@ -1,33 +0,0 @@ -package handlers - -// -// type SpawnVaultRequest struct { -// Name string `json:"name"` -// } -// -// func SpawnVault(c echo.Context) error { -// ks, err := mpc.NewKeyset() -// if err != nil { -// return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) -// } -// src, err := mpc.NewSource(ks) -// if err != nil { -// return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) -// } -// tk, err := src.OriginToken() -// if err != nil { -// return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) -// } -// // Create the vault keyshare auth token -// kscid, err := tk.CID() -// if err != nil { -// return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) -// } -// // Create the vault config -// dir, err := config.NewFS(config.GetVaultConfig(src.Address(), kscid.String())) -// path, err := clients.IPFSAdd(c, dir) -// if err != nil { -// return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) -// } -// return c.Redirect(http.StatusFound, path) -// } diff --git a/internal/gateway/pages/index/error.templ b/internal/gateway/pages/index/error.templ deleted file mode 100644 index cdaaabf87..000000000 --- a/internal/gateway/pages/index/error.templ +++ /dev/null @@ -1,29 +0,0 @@ -package index - -import "github.com/onsonr/sonr/pkg/common/styles/layout" - -templ NoWebauthnErrorView() { - @layout.Root("Error | Sonr.ID") { -

-
-
-
-
-

- No WebAuthn Devices -

-

- You don't have any WebAuthn devices connected to your computer. -

-
-
- -
-
-
-
-
- } -} diff --git a/internal/gateway/pages/index/error_templ.go b/internal/gateway/pages/index/error_templ.go deleted file mode 100644 index ef0cf3330..000000000 --- a/internal/gateway/pages/index/error_templ.go +++ /dev/null @@ -1,60 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package index - -//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" - -import "github.com/onsonr/sonr/pkg/common/styles/layout" - -func NoWebauthnErrorView() 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 - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - 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_Var2 := 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_Err = templ_7745c5c3_Buffer.WriteString("

No WebAuthn Devices

You don't have any WebAuthn devices connected to your computer.

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = layout.Root("Error | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/pages/login/model.go b/internal/gateway/pages/login/model.go deleted file mode 100644 index 9b8ed2abe..000000000 --- a/internal/gateway/pages/login/model.go +++ /dev/null @@ -1,24 +0,0 @@ -package login - -type LoginRequest struct { - Subject string - Action string - Origin string - Status string - Ping string - BlockSpeed string - BlockHeight string -} - -type PublicKeyCredentialRequestOptions struct { - Challenge string `json:"challenge"` - RpID string `json:"rpId"` - Timeout int `json:"timeout,omitempty"` - UserVerification string `json:"userVerification,omitempty"` - AllowCredentials []CredentialDescriptor `json:"allowCredentials,omitempty"` -} - -type CredentialDescriptor struct { - Type string `json:"type"` - ID string `json:"id"` -} diff --git a/internal/gateway/pages/register/model.go b/internal/gateway/pages/register/model.go deleted file mode 100644 index dcd6b7caf..000000000 --- a/internal/gateway/pages/register/model.go +++ /dev/null @@ -1,20 +0,0 @@ -package register - -import ( - "github.com/a-h/templ" - "github.com/go-webauthn/webauthn/protocol" -) - -type LinkCredentialRequest struct { - Platform string `json:"platform"` - Handle string `json:"handle"` - DeviceModel string `json:"deviceModel"` - Architecture string `json:"architecture"` - Address string `json:"address"` - RegisterOptions protocol.PublicKeyCredentialCreationOptions `json:"registerOptions"` -} - -func (r LinkCredentialRequest) GetCredentialOptions() string { - opts, _ := templ.JSONString(r.RegisterOptions) - return opts -} diff --git a/internal/gateway/pages/register/profile.templ b/internal/gateway/pages/register/profile.templ deleted file mode 100644 index ace683b7c..000000000 --- a/internal/gateway/pages/register/profile.templ +++ /dev/null @@ -1,78 +0,0 @@ -package register - -import ( - "fmt" - "github.com/onsonr/sonr/pkg/common/styles/layout" -) - -type CreateProfileData struct { - TurnstileSiteKey string - FirstNumber int - LastNumber int -} - -func (d CreateProfileData) IsHumanLabel() string { - return fmt.Sprintf("What is %d + %d?", d.FirstNumber, d.LastNumber) -} - -templ formCreateProfile(action string, method string, data CreateProfileData) { -
- -
-
- -
-
- @layout.Rows() { - - - } - @layout.Spacer() - -
- -
-
- @layout.Spacer() - -
- - - Cancel - - - Next - - -
- -
-
-} - -// ╭──────────────────────────────────────────────────────╮ -// │ Passkey Components │ -// ╰──────────────────────────────────────────────────────╯ diff --git a/internal/gateway/pages/register/profile_templ.go b/internal/gateway/pages/register/profile_templ.go deleted file mode 100644 index f233b4795..000000000 --- a/internal/gateway/pages/register/profile_templ.go +++ /dev/null @@ -1,131 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package register - -//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" - -import ( - "fmt" - "github.com/onsonr/sonr/pkg/common/styles/layout" -) - -type CreateProfileData struct { - TurnstileSiteKey string - FirstNumber int - LastNumber int -} - -func (d CreateProfileData) IsHumanLabel() string { - return fmt.Sprintf("What is %d + %d?", d.FirstNumber, d.LastNumber) -} - -func formCreateProfile(action string, method string, data CreateProfileData) 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 - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - 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("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Var4 := 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_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = layout.Rows().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = layout.Spacer().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = layout.Spacer().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Cancel Next
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -// ╭──────────────────────────────────────────────────────╮ -// │ Passkey Components │ -// ╰──────────────────────────────────────────────────────╯ -var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/routes.go b/internal/gateway/routes.go index 66fd62688..6155d24bf 100644 --- a/internal/gateway/routes.go +++ b/internal/gateway/routes.go @@ -5,7 +5,8 @@ import ( "github.com/labstack/echo/v4" "github.com/onsonr/sonr/internal/gateway/config" "github.com/onsonr/sonr/internal/gateway/database" - "github.com/onsonr/sonr/internal/gateway/handlers" + "github.com/onsonr/sonr/internal/gateway/handlers/index" + "github.com/onsonr/sonr/internal/gateway/handlers/register" "github.com/onsonr/sonr/internal/gateway/session" "github.com/onsonr/sonr/pkg/common/response" ) @@ -24,9 +25,9 @@ func RegisterRoutes(e *echo.Echo, env config.Env) error { e.Use(session.Middleware(db, env)) // Register routes - e.GET("/", handlers.HandleIndex) - e.GET("/register", handlers.HandleRegisterView) - e.POST("/register/start", handlers.HandleRegisterStart) - e.POST("/register/finish", handlers.HandleRegisterFinish) + e.GET("/", index.Handler) + e.GET("/register", register.HandleCreateProfile) + e.POST("/register/start", register.HandlePasskeyStart) + e.POST("/register/finish", register.HandlePasskeyFinish) return nil } diff --git a/internal/vault/handlers/connect_handler.go b/internal/vault/handlers/auth/connect_handler.go similarity index 100% rename from internal/vault/handlers/connect_handler.go rename to internal/vault/handlers/auth/connect_handler.go diff --git a/internal/vault/handlers/authorization_handler.go b/internal/vault/handlers/authz/authorization_handler.go similarity index 100% rename from internal/vault/handlers/authorization_handler.go rename to internal/vault/handlers/authz/authorization_handler.go diff --git a/internal/vault/handlers/credentials_handler.go b/internal/vault/handlers/credentials_handler.go deleted file mode 100644 index 3b6b47daa..000000000 --- a/internal/vault/handlers/credentials_handler.go +++ /dev/null @@ -1,72 +0,0 @@ -package handlers - -import ( - "github.com/go-webauthn/webauthn/protocol" - "github.com/labstack/echo/v4" -) - -// ╭───────────────────────────────────────────────────────────╮ -// │ Login Handlers │ -// ╰───────────────────────────────────────────────────────────╯ - -// LoginSubjectCheck handles the login subject check. -func LoginSubjectCheck(e echo.Context) error { - return e.JSON(200, "HandleCredentialAssertion") -} - -// LoginSubjectStart handles the login subject start. -func LoginSubjectStart(e echo.Context) error { - opts := &protocol.PublicKeyCredentialRequestOptions{ - UserVerification: "preferred", - Challenge: []byte("challenge"), - } - return e.JSON(200, opts) -} - -// LoginSubjectFinish handles the login subject finish. -func LoginSubjectFinish(e echo.Context) error { - var crr protocol.CredentialAssertionResponse - if err := e.Bind(&crr); err != nil { - return err - } - return e.JSON(200, crr) -} - -// ╭───────────────────────────────────────────────────────────╮ -// │ Register Handlers │ -// ╰───────────────────────────────────────────────────────────╯ - -// RegisterSubjectCheck handles the register subject check. -func RegisterSubjectCheck(e echo.Context) error { - subject := e.FormValue("subject") - return e.JSON(200, subject) -} - -// RegisterSubjectStart handles the register subject start. -func RegisterSubjectStart(e echo.Context) error { - // Get subject and address - // subject := e.FormValue("subject") - - // Get challenge - - return nil -} - -// RegisterSubjectFinish handles the register subject finish. -func RegisterSubjectFinish(e echo.Context) error { - // Deserialize the JSON into a temporary struct - var ccr protocol.CredentialCreationResponse - if err := e.Bind(&ccr); err != nil { - return err - } - // - // // Parse the CredentialCreationResponse - // parsedData, err := ccr.Parse() - // if err != nil { - // return e.JSON(500, err.Error()) - // } - // - // // Create the Credential - // // credential := orm.NewCredential(parsedData, e.Request().Host, "") - return e.JSON(201, ccr) -} diff --git a/internal/vault/handlers/dash_handler.go b/internal/vault/handlers/feeds/dash_handler.go similarity index 100% rename from internal/vault/handlers/dash_handler.go rename to internal/vault/handlers/feeds/dash_handler.go diff --git a/internal/vault/handlers/index_handler.go b/internal/vault/handlers/index/index_handler.go similarity index 100% rename from internal/vault/handlers/index_handler.go rename to internal/vault/handlers/index/index_handler.go diff --git a/internal/vault/handlers/accounts_handler.go b/internal/vault/handlers/profile/accounts_handler.go similarity index 100% rename from internal/vault/handlers/accounts_handler.go rename to internal/vault/handlers/profile/accounts_handler.go diff --git a/internal/vault/handlers/resolver_handler.go b/internal/vault/handlers/search/resolver_handler.go similarity index 100% rename from internal/vault/handlers/resolver_handler.go rename to internal/vault/handlers/search/resolver_handler.go diff --git a/internal/vault/handlers/transaction_handler.go b/internal/vault/handlers/wallet/transaction_handler.go similarity index 100% rename from internal/vault/handlers/transaction_handler.go rename to internal/vault/handlers/wallet/transaction_handler.go diff --git a/internal/vault/handlers/wallet_handler.go b/internal/vault/handlers/wallet/wallet_handler.go similarity index 100% rename from internal/vault/handlers/wallet_handler.go rename to internal/vault/handlers/wallet/wallet_handler.go diff --git a/internal/vault/pages/authenticate/model.go b/internal/vault/pages/authenticate/model.go deleted file mode 100644 index a6e5cf0ef..000000000 --- a/internal/vault/pages/authenticate/model.go +++ /dev/null @@ -1,7 +0,0 @@ -package authorize - -type AuthorizeRequest struct { - Subject string - Action string - Origin string -} diff --git a/internal/vault/pages/authorize/model.go b/internal/vault/pages/authorize/model.go deleted file mode 100644 index a6e5cf0ef..000000000 --- a/internal/vault/pages/authorize/model.go +++ /dev/null @@ -1,7 +0,0 @@ -package authorize - -type AuthorizeRequest struct { - Subject string - Action string - Origin string -} diff --git a/internal/vault/pages/dashboard/page.templ b/internal/vault/pages/dashboard/page.templ deleted file mode 100644 index b1560f2d2..000000000 --- a/internal/vault/pages/dashboard/page.templ +++ /dev/null @@ -1,57 +0,0 @@ -package dash - -import "github.com/onsonr/sonr/pkg/common/styles/layout" - -templ ProfileView() { - @layout.Root("Sonr.ID") { -
-
-
-
-
-

- Sonr.ID -

-

- The decentralized identity layer for the web. -

-
-
- -
-
- { children... } -
-
-
- } -} - -templ FeedView() { - @layout.Root("Sonr.ID") { -
-
-
-
-
-

- Welcome Back! -

-

- Continue with your existing Sonr.ID. -

-
-
- -
-
- { children... } -
-
-
- } -} diff --git a/internal/vault/pages/dashboard/page_templ.go b/internal/vault/pages/dashboard/page_templ.go deleted file mode 100644 index d711f4337..000000000 --- a/internal/vault/pages/dashboard/page_templ.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package dash - -//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" - -import "github.com/onsonr/sonr/pkg/common/styles/layout" - -func ProfileView() 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 - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - 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_Var2 := 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_Err = templ_7745c5c3_Buffer.WriteString("

Sonr.ID

The decentralized identity layer for the web.

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = layout.Root("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func FeedView() 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 - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - 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_Var3 := templ.GetChildren(ctx) - if templ_7745c5c3_Var3 == nil { - templ_7745c5c3_Var3 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var4 := 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_Err = templ_7745c5c3_Buffer.WriteString("

Welcome Back!

Continue with your existing Sonr.ID.

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = layout.Root("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/vault/routes.go b/internal/vault/routes.go index 28f842706..bc3759ea5 100644 --- a/internal/vault/routes.go +++ b/internal/vault/routes.go @@ -7,7 +7,6 @@ package vault import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/vault/handlers" session "github.com/onsonr/sonr/internal/vault/session" "github.com/onsonr/sonr/internal/vault/types" ) @@ -15,14 +14,4 @@ import ( // RegisterRoutes registers the Decentralized Web Node API routes. func RegisterRoutes(e *echo.Echo, config *types.Config) { e.Use(session.Middleware(config)) - - e.GET("/register/:subject/start", handlers.RegisterSubjectStart) - e.POST("/register/:subject/finish", handlers.RegisterSubjectFinish) - - e.GET("/login/:subject/start", handlers.LoginSubjectStart) - e.POST("/login/:subject/finish", handlers.LoginSubjectFinish) - - e.GET("/authz/jwks", handlers.GetJWKS) - e.GET("/authz/token", handlers.GetToken) - e.POST("/:origin/grant/:subject", handlers.GrantAuthorization) }