diff --git a/internal/gateway/handlers/register/data.go b/internal/gateway/handlers/register/data.go index 6317f6d54..0063025e5 100644 --- a/internal/gateway/handlers/register/data.go +++ b/internal/gateway/handlers/register/data.go @@ -37,14 +37,6 @@ type RegisterPasskeyData struct { 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) } diff --git a/internal/gateway/handlers/register/forms.templ b/internal/gateway/handlers/register/forms.templ index db6ce900d..0d084a08c 100644 --- a/internal/gateway/handlers/register/forms.templ +++ b/internal/gateway/handlers/register/forms.templ @@ -1,6 +1,9 @@ package register -import "github.com/onsonr/sonr/pkg/common/styles/layout" +import ( + "github.com/onsonr/sonr/internal/gateway/handlers/register/ui" + "github.com/onsonr/sonr/pkg/common/styles/layout" +) templ formCreateProfile(action string, method string, data CreateProfileData) {
@@ -66,49 +69,11 @@ templ formRegisterPasskey(action, method string, data RegisterPasskeyData) {
- @sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock) + @ui.ProfileCard(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) + @ui.CreatePasskey(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 index c0695896e..7c533f5e0 100644 --- a/internal/gateway/handlers/register/forms_templ.go +++ b/internal/gateway/handlers/register/forms_templ.go @@ -8,7 +8,10 @@ package register import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import "github.com/onsonr/sonr/pkg/common/styles/layout" +import ( + "github.com/onsonr/sonr/internal/gateway/handlers/register/ui" + "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) { @@ -47,7 +50,7 @@ func formCreateProfile(action string, method string, data CreateProfileData) tem var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(method) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/forms.templ`, Line: 6, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/forms.templ`, Line: 9, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -76,7 +79,7 @@ func formCreateProfile(action string, method string, data CreateProfileData) tem var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.IsHumanLabel()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/forms.templ`, Line: 24, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/forms.templ`, Line: 27, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -127,7 +130,7 @@ func formRegisterPasskey(action, method string, data RegisterPasskeyData) templ. var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(method) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/forms.templ`, Line: 64, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/forms.templ`, Line: 67, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -137,75 +140,15 @@ func formRegisterPasskey(action, method string, data RegisterPasskeyData) templ. 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) + templ_7745c5c3_Err = ui.ProfileCard(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("
") + _, 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) + templ_7745c5c3_Err = ui.CreatePasskey(data.Address, data.Handle, data.Challenge).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/gateway/handlers/register/inputs.templ b/internal/gateway/handlers/register/inputs.templ index e5bc0f8b3..f0f4024c8 100644 --- a/internal/gateway/handlers/register/inputs.templ +++ b/internal/gateway/handlers/register/inputs.templ @@ -1,6 +1,5 @@ package register - templ passkeyDropzone(addr string, userHandle string, challenge string) { @@ -9,49 +8,50 @@ templ passkeyDropzone(addr string, userHandle string, challenge string) { } script createPasskey(userId string, userHandle string, challenge string) { -const publicKey = { - challenge: Uint8Array.from(challenge, (c) => c.charCodeAt(0)), - rp: { - name: "Sonr.ID", - }, - user: { - // Assuming that userId is ASCII-only - id: Uint8Array.from(userId, (c) => c.charCodeAt(0)), - name: userId, - displayName: userHandle, - }, - pubKeyCredParams: [ - { - type: "public-key", - alg: -7, // "ES256" + const publicKey = { + challenge: Uint8Array.from(challenge, (c) => c.charCodeAt(0)), + rp: { + name: "Sonr.ID", }, - { - type: "public-key", - alg: -257, // "RS256" + user: { + // Assuming that userId is ASCII-only + id: Uint8Array.from(userId, (c) => c.charCodeAt(0)), + name: userId, + displayName: userHandle, }, - ], - authenticatorSelection: { - userVerification: "required", - residentKey: "required", - authenticatorAttachment: "platform", - }, - timeout: 60000, // 1 minute - extensions: { - payment: { - isPayment: true, + pubKeyCredParams: [ + { + type: "public-key", + alg: -7, // "ES256" + }, + { + type: "public-key", + alg: -257, // "RS256" + }, + ], + authenticatorSelection: { + userVerification: "required", + residentKey: "required", + authenticatorAttachment: "platform", }, - }, -}; -// Helper function to convert ArrayBuffer to Base64URL string -function arrayBufferToBase64URL(buffer) { - const bytes = new Uint8Array(buffer); - let str = ''; - bytes.forEach(byte => { str += String.fromCharCode(byte) }); - return btoa(str) - .replace(/\+/g, '-') - .replace(/\//g, '_') - .replace(/=/g, ''); -} + timeout: 60000, // 1 minute + extensions: { + payment: { + isPayment: true, + }, + }, + }; + + // Helper function to convert ArrayBuffer to Base64URL string + function arrayBufferToBase64URL(buffer) { + const bytes = new Uint8Array(buffer); + let str = ''; + bytes.forEach(byte => { str += String.fromCharCode(byte) }); + return btoa(str) + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=/g, ''); + } navigator.credentials .create({ publicKey }) @@ -92,48 +92,3 @@ navigator.credentials alert(`Failed to create passkey: ${err.message || 'Unknown error'}`); }); } - -templ sonrProfile(addr string, name string, handle string, creationBlock string) { -
-
-
-
-

sonr-testnet-1

-

{ handle }

-
-
- -
-
-
- { shortenAddress(addr) } -
-
-
-

Block Created

-

#{ creationBlock }

-
-
-

Issued to

-

{ name }

-
-
-
-
-} - -templ cryptoWalletOption(ticker string, name string, isDefault bool) { - if isDefault { - - - { name } - - - } else { - - - { name } - - - } -} diff --git a/internal/gateway/handlers/register/inputs_templ.go b/internal/gateway/handlers/register/inputs_templ.go index 47fb549bd..2c370eee7 100644 --- a/internal/gateway/handlers/register/inputs_templ.go +++ b/internal/gateway/handlers/register/inputs_templ.go @@ -52,50 +52,51 @@ func passkeyDropzone(addr string, userHandle string, challenge string) templ.Com func createPasskey(userId string, userHandle string, challenge string) templ.ComponentScript { return templ.ComponentScript{ - Name: `__templ_createPasskey_fc87`, - Function: `function __templ_createPasskey_fc87(userId, userHandle, challenge){const publicKey = { - challenge: Uint8Array.from(challenge, (c) => c.charCodeAt(0)), - rp: { - name: "Sonr.ID", - }, - user: { - // Assuming that userId is ASCII-only - id: Uint8Array.from(userId, (c) => c.charCodeAt(0)), - name: userId, - displayName: userHandle, - }, - pubKeyCredParams: [ - { - type: "public-key", - alg: -7, // "ES256" + Name: `__templ_createPasskey_18a8`, + Function: `function __templ_createPasskey_18a8(userId, userHandle, challenge){const publicKey = { + challenge: Uint8Array.from(challenge, (c) => c.charCodeAt(0)), + rp: { + name: "Sonr.ID", }, - { - type: "public-key", - alg: -257, // "RS256" + user: { + // Assuming that userId is ASCII-only + id: Uint8Array.from(userId, (c) => c.charCodeAt(0)), + name: userId, + displayName: userHandle, }, - ], - authenticatorSelection: { - userVerification: "required", - residentKey: "required", - authenticatorAttachment: "platform", - }, - timeout: 60000, // 1 minute - extensions: { - payment: { - isPayment: true, + pubKeyCredParams: [ + { + type: "public-key", + alg: -7, // "ES256" + }, + { + type: "public-key", + alg: -257, // "RS256" + }, + ], + authenticatorSelection: { + userVerification: "required", + residentKey: "required", + authenticatorAttachment: "platform", }, - }, -}; -// Helper function to convert ArrayBuffer to Base64URL string -function arrayBufferToBase64URL(buffer) { - const bytes = new Uint8Array(buffer); - let str = ''; - bytes.forEach(byte => { str += String.fromCharCode(byte) }); - return btoa(str) - .replace(/\+/g, '-') - .replace(/\//g, '_') - .replace(/=/g, ''); -} + timeout: 60000, // 1 minute + extensions: { + payment: { + isPayment: true, + }, + }, + }; + + // Helper function to convert ArrayBuffer to Base64URL string + function arrayBufferToBase64URL(buffer) { + const bytes = new Uint8Array(buffer); + let str = ''; + bytes.forEach(byte => { str += String.fromCharCode(byte) }); + return btoa(str) + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=/g, ''); + } navigator.credentials .create({ publicKey }) @@ -136,204 +137,9 @@ navigator.credentials alert(` + "`" + `Failed to create passkey: ${err.message || 'Unknown error'}` + "`" + `); }); }`, - Call: templ.SafeScript(`__templ_createPasskey_fc87`, userId, userHandle, challenge), - CallInline: templ.SafeScriptInline(`__templ_createPasskey_fc87`, userId, userHandle, challenge), + Call: templ.SafeScript(`__templ_createPasskey_18a8`, userId, userHandle, challenge), + CallInline: templ.SafeScriptInline(`__templ_createPasskey_18a8`, userId, userHandle, challenge), } } -func sonrProfile(addr string, name string, handle string, creationBlock 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_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_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/handlers/register/inputs.templ`, Line: 102, Col: 43} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) - 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 - } - 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/handlers/register/inputs.templ`, Line: 109, Col: 58} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Block Created

#") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - 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/handlers/register/inputs.templ`, Line: 114, Col: 55} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Issued to

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - 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/handlers/register/inputs.templ`, Line: 118, Col: 32} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) - 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 - }) -} - -func cryptoWalletOption(ticker string, name string, isDefault bool) 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_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - if isDefault { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - 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/handlers/register/inputs.templ`, Line: 129, Col: 9} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) - 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 - } - } else { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - 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/handlers/register/inputs.templ`, Line: 135, Col: 9} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) - 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 - }) -} - var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/card_profile.templ b/internal/gateway/handlers/register/ui/card_profile.templ new file mode 100644 index 000000000..340ffc097 --- /dev/null +++ b/internal/gateway/handlers/register/ui/card_profile.templ @@ -0,0 +1,30 @@ +package ui + +templ ProfileCard(addr, name, handle, creationBlock string) { +
+
+
+
+

sonr-testnet-1

+

{ handle }

+
+
+ +
+
+
+ { shortenAddress(addr) } +
+
+
+

Block Created

+

#{ creationBlock }

+
+
+

Issued to

+

{ name }

+
+
+
+
+} diff --git a/internal/gateway/handlers/register/ui/card_profile_templ.go b/internal/gateway/handlers/register/ui/card_profile_templ.go new file mode 100644 index 000000000..49a132b26 --- /dev/null +++ b/internal/gateway/handlers/register/ui/card_profile_templ.go @@ -0,0 +1,92 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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 ProfileCard(addr, name, handle, creationBlock 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_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("

sonr-testnet-1

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(handle) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/ui/card_profile.templ`, Line: 9, Col: 43} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + 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 + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(shortenAddress(addr)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/ui/card_profile.templ`, Line: 16, Col: 58} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Block Created

#") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(creationBlock) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/ui/card_profile.templ`, Line: 21, Col: 55} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Issued to

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/ui/card_profile.templ`, Line: 25, Col: 32} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + 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 + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/form_card.templ b/internal/gateway/handlers/register/ui/form_card.templ new file mode 100644 index 000000000..7a8993205 --- /dev/null +++ b/internal/gateway/handlers/register/ui/form_card.templ @@ -0,0 +1,46 @@ +package ui + +templ FormCard(action string, method string) { + + +
+
+
+
+ + + Cancel + + + Next + + + +
+ +
+ +} diff --git a/internal/gateway/handlers/register/ui/form_card_templ.go b/internal/gateway/handlers/register/ui/form_card_templ.go new file mode 100644 index 000000000..03e404e95 --- /dev/null +++ b/internal/gateway/handlers/register/ui/form_card_templ.go @@ -0,0 +1,62 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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 FormCard(action string, method 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_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("
Cancel Next
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/input_handle.templ b/internal/gateway/handlers/register/ui/input_handle.templ new file mode 100644 index 000000000..96dc5a04d --- /dev/null +++ b/internal/gateway/handlers/register/ui/input_handle.templ @@ -0,0 +1,21 @@ +package ui + +type InputHandleState string + +const ( + InputHandleStateInitial InputHandleState = "inital" + InputHandleStateValid InputHandleState = "valid" + InputHandleStateInvalid InputHandleState = "invalid" +) + +func (s InputHandleState) string() string { + return string(s) +} + +templ InputHandle(handle string) { + +
+ +
+
+} diff --git a/internal/gateway/handlers/register/ui/input_handle_templ.go b/internal/gateway/handlers/register/ui/input_handle_templ.go new file mode 100644 index 000000000..39af2cbbc --- /dev/null +++ b/internal/gateway/handlers/register/ui/input_handle_templ.go @@ -0,0 +1,52 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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" + +type InputHandleState string + +const ( + InputHandleStateInitial InputHandleState = "inital" + InputHandleStateValid InputHandleState = "valid" + InputHandleStateInvalid InputHandleState = "invalid" +) + +func (s InputHandleState) string() string { + return string(s) +} + +func InputHandle(handle 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_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 + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/input_passkey.templ b/internal/gateway/handlers/register/ui/input_passkey.templ new file mode 100644 index 000000000..c0b60d221 --- /dev/null +++ b/internal/gateway/handlers/register/ui/input_passkey.templ @@ -0,0 +1,94 @@ +package ui + +templ InputPasskey(addr string, userHandle string, challenge string) { + + + Register Passkey + +} + +script navigatorCredentialsCreate(userId string, userHandle string, challenge string) { + const publicKey = { + challenge: Uint8Array.from(challenge, (c) => c.charCodeAt(0)), + rp: { + name: "Sonr.ID", + }, + user: { + // Assuming that userId is ASCII-only + id: Uint8Array.from(userId, (c) => c.charCodeAt(0)), + name: userId, + displayName: userHandle, + }, + pubKeyCredParams: [ + { + type: "public-key", + alg: -7, // "ES256" + }, + { + type: "public-key", + alg: -257, // "RS256" + }, + ], + authenticatorSelection: { + userVerification: "required", + residentKey: "required", + authenticatorAttachment: "platform", + }, + timeout: 60000, // 1 minute + extensions: { + payment: { + isPayment: true, + }, + }, + }; + + // Helper function to convert ArrayBuffer to Base64URL string + function arrayBufferToBase64URL(buffer) { + const bytes = new Uint8Array(buffer); + let str = ''; + bytes.forEach(byte => { str += String.fromCharCode(byte) }); + return btoa(str) + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=/g, ''); + } + +navigator.credentials + .create({ publicKey }) + .then((newCredentialInfo) => { + if (!(newCredentialInfo instanceof PublicKeyCredential)) { + throw new Error('Received credential is not a PublicKeyCredential'); + } + + const response = newCredentialInfo.response; + if (!(response instanceof AuthenticatorAttestationResponse)) { + throw new Error('Response is not an AuthenticatorAttestationResponse'); + } + + // Convert the credential data to a cross-platform compatible format + const credentialJSON = { + id: newCredentialInfo.id, + rawId: arrayBufferToBase64URL(newCredentialInfo.rawId), + type: newCredentialInfo.type, + authenticatorAttachment: newCredentialInfo.authenticatorAttachment || null, + transports: Array.isArray(response.getTransports) ? response.getTransports() : [], + clientExtensionResults: newCredentialInfo.getClientExtensionResults(), + response: { + attestationObject: arrayBufferToBase64URL(response.attestationObject), + clientDataJSON: arrayBufferToBase64URL(response.clientDataJSON) + } + }; + + // Set the form value with the stringified credential data + const credentialInput = document.getElementById('credential-data'); + credentialInput.value = JSON.stringify(credentialJSON); + + // Submit the form + const form = document.getElementById('passkey-form'); + form.submit(); + }) + .catch((err) => { + console.error('Passkey creation failed:', err); + alert(`Failed to create passkey: ${err.message || 'Unknown error'}`); + }); +} diff --git a/internal/gateway/handlers/register/ui/input_passkey_templ.go b/internal/gateway/handlers/register/ui/input_passkey_templ.go new file mode 100644 index 000000000..b69c40f4e --- /dev/null +++ b/internal/gateway/handlers/register/ui/input_passkey_templ.go @@ -0,0 +1,145 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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 InputPasskey(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_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, navigatorCredentialsCreate(addr, userHandle, challenge)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" Register Passkey") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func navigatorCredentialsCreate(userId string, userHandle string, challenge string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_navigatorCredentialsCreate_18a8`, + Function: `function __templ_navigatorCredentialsCreate_18a8(userId, userHandle, challenge){const publicKey = { + challenge: Uint8Array.from(challenge, (c) => c.charCodeAt(0)), + rp: { + name: "Sonr.ID", + }, + user: { + // Assuming that userId is ASCII-only + id: Uint8Array.from(userId, (c) => c.charCodeAt(0)), + name: userId, + displayName: userHandle, + }, + pubKeyCredParams: [ + { + type: "public-key", + alg: -7, // "ES256" + }, + { + type: "public-key", + alg: -257, // "RS256" + }, + ], + authenticatorSelection: { + userVerification: "required", + residentKey: "required", + authenticatorAttachment: "platform", + }, + timeout: 60000, // 1 minute + extensions: { + payment: { + isPayment: true, + }, + }, + }; + + // Helper function to convert ArrayBuffer to Base64URL string + function arrayBufferToBase64URL(buffer) { + const bytes = new Uint8Array(buffer); + let str = ''; + bytes.forEach(byte => { str += String.fromCharCode(byte) }); + return btoa(str) + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=/g, ''); + } + +navigator.credentials + .create({ publicKey }) + .then((newCredentialInfo) => { + if (!(newCredentialInfo instanceof PublicKeyCredential)) { + throw new Error('Received credential is not a PublicKeyCredential'); + } + + const response = newCredentialInfo.response; + if (!(response instanceof AuthenticatorAttestationResponse)) { + throw new Error('Response is not an AuthenticatorAttestationResponse'); + } + + // Convert the credential data to a cross-platform compatible format + const credentialJSON = { + id: newCredentialInfo.id, + rawId: arrayBufferToBase64URL(newCredentialInfo.rawId), + type: newCredentialInfo.type, + authenticatorAttachment: newCredentialInfo.authenticatorAttachment || null, + transports: Array.isArray(response.getTransports) ? response.getTransports() : [], + clientExtensionResults: newCredentialInfo.getClientExtensionResults(), + response: { + attestationObject: arrayBufferToBase64URL(response.attestationObject), + clientDataJSON: arrayBufferToBase64URL(response.clientDataJSON) + } + }; + + // Set the form value with the stringified credential data + const credentialInput = document.getElementById('credential-data'); + credentialInput.value = JSON.stringify(credentialJSON); + + // Submit the form + const form = document.getElementById('passkey-form'); + form.submit(); + }) + .catch((err) => { + console.error('Passkey creation failed:', err); + alert(` + "`" + `Failed to create passkey: ${err.message || 'Unknown error'}` + "`" + `); + }); +}`, + Call: templ.SafeScript(`__templ_navigatorCredentialsCreate_18a8`, userId, userHandle, challenge), + CallInline: templ.SafeScriptInline(`__templ_navigatorCredentialsCreate_18a8`, userId, userHandle, challenge), + } +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/name_input.templ b/internal/gateway/handlers/register/ui/name_input.templ new file mode 100644 index 000000000..d84071e28 --- /dev/null +++ b/internal/gateway/handlers/register/ui/name_input.templ @@ -0,0 +1,8 @@ +package ui + +templ NameInput(name string) { +
+ + +
+} diff --git a/internal/gateway/handlers/register/ui/name_input_templ.go b/internal/gateway/handlers/register/ui/name_input_templ.go new file mode 100644 index 000000000..cd08a2587 --- /dev/null +++ b/internal/gateway/handlers/register/ui/name_input_templ.go @@ -0,0 +1,40 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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 NameInput(name 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_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 + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/select_coins.templ b/internal/gateway/handlers/register/ui/select_coins.templ new file mode 100644 index 000000000..d3536c263 --- /dev/null +++ b/internal/gateway/handlers/register/ui/select_coins.templ @@ -0,0 +1,69 @@ +package ui + +type Coin struct { + Ticker string + Name string + IsDefault bool +} + +var defaultCoins = []Coin{ + {Ticker: "SNR", Name: "Sonr", IsDefault: true}, + {Ticker: "BTC", Name: "Bitcoin", IsDefault: true}, + {Ticker: "ETH", Name: "Ethereum", IsDefault: true}, + {Ticker: "SOL", Name: "Solana", IsDefault: false}, + {Ticker: "LTC", Name: "Litecoin", IsDefault: false}, + {Ticker: "DOGE", Name: "Dogecoin", IsDefault: false}, + {Ticker: "XRP", Name: "Ripple", IsDefault: false}, + {Ticker: "OSMO", Name: "Osmosis", IsDefault: false}, + {Ticker: "ATOM", Name: "Cosmos", IsDefault: false}, + {Ticker: "STARZ", Name: "Stargaze", IsDefault: false}, + {Ticker: "AKT", Name: "Akash", IsDefault: false}, + {Ticker: "EVMOS", Name: "Evmos", IsDefault: false}, + {Ticker: "FIL", Name: "Filecoin", IsDefault: false}, + {Ticker: "AXL", Name: "Axelar", IsDefault: false}, +} + +templ SelectCoins() { + + for _, a := range defaultCoins { + @CoinOption(a) + } + + +} + +templ CoinOption(a Coin) { + if a.IsDefault { + + + { a.Name } + + + } else { + + + { a.Name } + + + } +} diff --git a/internal/gateway/handlers/register/ui/select_coins_templ.go b/internal/gateway/handlers/register/ui/select_coins_templ.go new file mode 100644 index 000000000..da353cbd2 --- /dev/null +++ b/internal/gateway/handlers/register/ui/select_coins_templ.go @@ -0,0 +1,187 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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" + +type Coin struct { + Ticker string + Name string + IsDefault bool +} + +var defaultCoins = []Coin{ + {Ticker: "SNR", Name: "Sonr", IsDefault: true}, + {Ticker: "BTC", Name: "Bitcoin", IsDefault: true}, + {Ticker: "ETH", Name: "Ethereum", IsDefault: true}, + {Ticker: "SOL", Name: "Solana", IsDefault: false}, + {Ticker: "LTC", Name: "Litecoin", IsDefault: false}, + {Ticker: "DOGE", Name: "Dogecoin", IsDefault: false}, + {Ticker: "XRP", Name: "Ripple", IsDefault: false}, + {Ticker: "OSMO", Name: "Osmosis", IsDefault: false}, + {Ticker: "ATOM", Name: "Cosmos", IsDefault: false}, + {Ticker: "STARZ", Name: "Stargaze", IsDefault: false}, + {Ticker: "AKT", Name: "Akash", IsDefault: false}, + {Ticker: "EVMOS", Name: "Evmos", IsDefault: false}, + {Ticker: "FIL", Name: "Filecoin", IsDefault: false}, + {Ticker: "AXL", Name: "Axelar", IsDefault: false}, +} + +func SelectCoins() 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 + } + for _, a := range defaultCoins { + templ_7745c5c3_Err = CoinOption(a).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 + }) +} + +func CoinOption(a Coin) 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_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + if a.IsDefault { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(a.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/ui/select_coins.templ`, Line: 59, Col: 11} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + 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 + } + } else { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(a.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gateway/handlers/register/ui/select_coins.templ`, Line: 65, Col: 11} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + 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 + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/slider_ishuman.templ b/internal/gateway/handlers/register/ui/slider_ishuman.templ new file mode 100644 index 000000000..9ed34fda3 --- /dev/null +++ b/internal/gateway/handlers/register/ui/slider_ishuman.templ @@ -0,0 +1,11 @@ +package ui + +import "fmt" + +templ HumanSlider(firstNumber int, lastNumber int) { + +} + +func formatHumanSliderLabel(firstNumber int, lastNumber int) string { + return fmt.Sprintf("What is %d + %d?", firstNumber, lastNumber) +} diff --git a/internal/gateway/handlers/register/ui/slider_ishuman_templ.go b/internal/gateway/handlers/register/ui/slider_ishuman_templ.go new file mode 100644 index 000000000..895172e18 --- /dev/null +++ b/internal/gateway/handlers/register/ui/slider_ishuman_templ.go @@ -0,0 +1,59 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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" + +func HumanSlider(firstNumber int, lastNumber int) 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 + } + return templ_7745c5c3_Err + }) +} + +func formatHumanSliderLabel(firstNumber int, lastNumber int) string { + return fmt.Sprintf("What is %d + %d?", firstNumber, lastNumber) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/styles.templ b/internal/gateway/handlers/register/ui/styles.templ new file mode 100644 index 000000000..dbeb89c1b --- /dev/null +++ b/internal/gateway/handlers/register/ui/styles.templ @@ -0,0 +1,30 @@ +package ui + +// Styles for form controls +templ LabelOnLeft() { + +} diff --git a/internal/gateway/handlers/register/ui/styles_templ.go b/internal/gateway/handlers/register/ui/styles_templ.go new file mode 100644 index 000000000..1b56b3c62 --- /dev/null +++ b/internal/gateway/handlers/register/ui/styles_templ.go @@ -0,0 +1,41 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package ui + +//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" + +// Styles for form controls +func LabelOnLeft() 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 + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/ui/utils.go b/internal/gateway/handlers/register/ui/utils.go new file mode 100644 index 000000000..0b010a774 --- /dev/null +++ b/internal/gateway/handlers/register/ui/utils.go @@ -0,0 +1,9 @@ +package ui + +// 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/handlers/register/views/form_credential.templ b/internal/gateway/handlers/register/views/form_credential.templ new file mode 100644 index 000000000..42e054388 --- /dev/null +++ b/internal/gateway/handlers/register/views/form_credential.templ @@ -0,0 +1,30 @@ + +package views + + +templ formRegisterPasskey(action, method string, data RegisterPasskeyData) { +
+ + +
+
+ @ui.ProfileCard(data.Address, data.Name, data.Handle, data.CreationBlock) +
+
+
+ @ui.CreatePasskey(data.Address, data.Handle, data.Challenge) + + + Cancel + +
+ +
+
+} + diff --git a/internal/gateway/handlers/register/views/form_credential_templ.go b/internal/gateway/handlers/register/views/form_credential_templ.go new file mode 100644 index 000000000..e1f95b7c0 --- /dev/null +++ b/internal/gateway/handlers/register/views/form_credential_templ.go @@ -0,0 +1,79 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 + +package views + +//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 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_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_Err = ui.ProfileCard(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 = ui.CreatePasskey(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/views/form_profile.templ b/internal/gateway/handlers/register/views/form_profile.templ new file mode 100644 index 000000000..d3e556c94 --- /dev/null +++ b/internal/gateway/handlers/register/views/form_profile.templ @@ -0,0 +1,56 @@ + +package views + +import ( + "math/rand" + "time" + "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/internal/gateway/handlers/register/ui" +) + +func HandleProfileFormView(c echo.Context) error { + dat := CreateProfileData{ + FirstNumber: 1, + LastNumber: 2, + } + return response.TemplEcho(c, ProfileFormView(dat)) +} + + +templ FormRegisterPasskey(action, method string) { +
+ + +
+
+ @ui.ProfileCard(data.Address, data.Name, data.Handle, data.CreationBlock) +
+
+
+ @ui.CreatePasskey(data.Address, data.Handle, data.Challenge) + + + Cancel + +
+ +
+
+} + + +// randomNumbers returns two random numbers whose sum is less than or equal to 10 +func randomNumbers() (int, int) { + rand.Seed(time.Now().UnixNano()) + firstNumber := rand.Intn(10) + lastNumber := rand.Intn(10) + for firstNumber+lastNumber > 10 { + lastNumber = rand.Intn(10) + } + return firstNumber, lastNumber +} diff --git a/internal/gateway/handlers/register/views/form_profile_templ.go b/internal/gateway/handlers/register/views/form_profile_templ.go new file mode 100644 index 000000000..91f600b25 --- /dev/null +++ b/internal/gateway/handlers/register/views/form_profile_templ.go @@ -0,0 +1,105 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 + +package views + +//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/labstack/echo/v4" + "github.com/onsonr/sonr/internal/gateway/handlers/register/ui" + "math/rand" + "time" +) + +func HandleProfileFormView(c echo.Context) error { + dat := CreateProfileData{ + FirstNumber: 1, + LastNumber: 2, + } + return response.TemplEcho(c, ProfileFormView(dat)) +} + +func FormRegisterPasskey(action, method 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_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_Err = ui.ProfileCard(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 = ui.CreatePasskey(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 + }) +} + +// randomNumbers returns two random numbers whose sum is less than or equal to 10 +func randomNumbers() (int, int) { + rand.Seed(time.Now().UnixNano()) + firstNumber := rand.Intn(10) + lastNumber := rand.Intn(10) + for firstNumber+lastNumber > 10 { + lastNumber = rand.Intn(10) + } + return firstNumber, lastNumber +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/handlers/register/views/loading.templ b/internal/gateway/handlers/register/views/loading.templ new file mode 100644 index 000000000..980d3d41a --- /dev/null +++ b/internal/gateway/handlers/register/views/loading.templ @@ -0,0 +1,2 @@ +package views + diff --git a/internal/gateway/handlers/register/views/loading_templ.go b/internal/gateway/handlers/register/views/loading_templ.go new file mode 100644 index 000000000..fcc6a1a57 --- /dev/null +++ b/internal/gateway/handlers/register/views/loading_templ.go @@ -0,0 +1,11 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.793 +package views + +//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" + +var _ = templruntime.GeneratedTemplate diff --git a/internal/gateway/types/Config.pkl.go b/internal/gateway/types/Config.pkl.go deleted file mode 100644 index eb894f474..000000000 --- a/internal/gateway/types/Config.pkl.go +++ /dev/null @@ -1,16 +0,0 @@ -// Code generated from Pkl module `sonr.hway.Gate`. DO NOT EDIT. -package types - -type Config struct { - ChainId string `pkl:"chainId" json:"chainId,omitempty"` - - IpfsGatewayUrl string `pkl:"ipfsGatewayUrl" json:"ipfsGatewayUrl,omitempty"` - - LandingUrl string `pkl:"landingUrl" json:"landingUrl,omitempty"` - - AuthProxyUrl string `pkl:"authProxyUrl" json:"authProxyUrl,omitempty"` - - SonrApiUrl string `pkl:"sonrApiUrl" json:"sonrApiUrl,omitempty"` - - SonrRpcUrl string `pkl:"sonrRpcUrl" json:"sonrRpcUrl,omitempty"` -} diff --git a/internal/gateway/types/Ctx.pkl.go b/internal/gateway/types/Ctx.pkl.go deleted file mode 100644 index 6ad8de08d..000000000 --- a/internal/gateway/types/Ctx.pkl.go +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated from Pkl module `sonr.hway.Ctx`. DO NOT EDIT. -package types - -type Ctx struct { -} diff --git a/internal/gateway/types/init.pkl.go b/internal/gateway/types/init.pkl.go deleted file mode 100644 index 1d947b8b8..000000000 --- a/internal/gateway/types/init.pkl.go +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated from Pkl module `sonr.hway.Gate`. DO NOT EDIT. -package types - -import "github.com/apple/pkl-go/pkl" - -func init() { - pkl.RegisterMapping("sonr.hway.Gate#Config", Config{}) -}