From d69c2a9d53a7e89810399851cd1bf77caf22adbe Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Sun, 22 Dec 2024 17:01:11 -0500 Subject: [PATCH] feature/refactor ui (#1205) * fix: correct HTTP error handling in gateway * refactor: migrate database and ORM to internal modules * feat: introduce taskfile build system for improved workflow management * refactor: update taskfiles to use relative paths * feat: add profile status field * refactor: move rendering logic to context package * fix: improve error handling in credentials retrieval * refactor: optimize HTTP request handling in Wasm environment * refactor: refactor config loading in motr command * chore: add process-compose for service management * chore: remove default task and update gum format command * fix: update project dependencies * refactor: improve code readability and maintainability * refactor: consolidate error handling components * refactor: update index handler to use new context package * refactor: consolidate database scripts and move to deploy directory * feat: Update flake.nix with development tools and environment configuration * fix: ignore flake.lock file * refactor: migrate build process to use taskfiles for improved modularity and maintainability * refactor: improve GatewayContext and reorganize handlers * refactor: Remove unused profile creation functions * (chore): templ generation * test: add test file for vaults.go * maintenance: remove defunct Discord server link * docs: update checks workflow documentation * test: remove obsolete vaults test file * refactor: move version bumping logic to release workflow --- .github/workflows/checks.yml | 19 - .github/workflows/publish.yml | 5 +- .github/workflows/release.yml | 21 + .gitignore | 3 +- .taskfiles/Hway.yml | 25 + .taskfiles/IPFS.yml | 37 ++ .taskfiles/Postgres.yml | 23 + .taskfiles/Sonrd.yml | 48 ++ .taskfiles/Synapse.yml | 23 + .taskfiles/TigerBeetle.yml | 12 + Dockerfile | 37 -- Makefile | 74 +-- README.md | 1 - Taskfile.yml | 146 ++--- app/gateway/context/credentials.go | 19 + app/gateway/context/middleware.go | 64 ++ app/gateway/context/profiles.go | 53 ++ .../gateway/context}/renderer.go | 4 +- app/gateway/context/resolver.go | 105 ++++ .../gateway/context}/sessions.go | 77 +-- app/gateway/context/types.go | 102 ++++ app/gateway/context/vaults.go | 45 ++ {pkg => app}/gateway/gateway.go | 31 +- app/gateway/handlers/errors.go | 14 + app/gateway/handlers/index.go | 14 + .../gateway/handlers/login.go | 0 app/gateway/handlers/register.go | 111 ++++ .../gateway/islands/card_account.templ | 4 +- .../gateway/islands/card_account_templ.go | 12 +- .../gateway/islands}/coin_select.templ | 2 +- .../gateway/islands}/coin_select_templ.go | 14 +- .../gateway/islands/human_slider.templ | 2 +- .../gateway/islands/human_slider_templ.go | 6 +- .../gateway/islands}/input_handle.templ | 10 +- .../gateway/islands}/input_handle_templ.go | 16 +- .../gateway/islands}/input_passkey.templ | 4 +- .../gateway/islands}/input_passkey_templ.go | 4 +- app/gateway/views/base_form.templ | 58 ++ app/gateway/views/base_form_templ.go | 265 ++++++++ .../gateway/views/base_head.templ | 2 +- .../gateway/views/base_head_templ.go | 30 +- app/gateway/views/base_hero.templ | 36 ++ .../gateway/views/base_hero_templ.go | 64 +- app/gateway/views/base_layout.templ | 59 ++ app/gateway/views/base_layout_templ.go | 222 +++++++ app/gateway/views/view_errors.templ | 14 + .../gateway/views/view_errors_templ.go | 13 +- app/gateway/views/view_home.templ | 26 + .../gateway/views/view_home_templ.go | 21 +- app/gateway/views/view_loading.templ | 9 + .../gateway/views/view_loading_templ.go | 11 +- app/gateway/views/view_register.templ | 47 ++ .../gateway/views/view_register_templ.go | 62 +- {cmd/motr/wasm => app/vault/context}/wasm.go | 4 +- .../vault/handlers/authorize.go | 0 .../vault/handlers/errors.go | 0 .../current.go => app/vault/handlers/index.go | 0 .../search.go => app/vault/handlers/login.go | 0 app/vault/handlers/profile.go | 1 + app/vault/handlers/search.go | 1 + .../vault/handlers/wallet.go | 0 app/vault/vault.go | 41 ++ .../vault/views/base_form.templ | 14 +- .../vault/views/base_form_templ.go | 18 +- app/vault/views/base_head.templ | 135 +++++ app/vault/views/base_head_templ.go | 573 ++++++++++++++++++ app/vault/views/base_hero.templ | 36 ++ .../vault/views/base_hero_templ.go | 71 +-- app/vault/views/base_layout.templ | 59 ++ app/vault/views/base_layout_templ.go | 222 +++++++ app/vault/views/initial.templ | 14 + {pkg => app}/vault/views/initial_templ.go | 15 +- cmd/hway/cmds.go | 2 +- cmd/hway/main.go | 2 +- cmd/motr/main.go | 264 ++++++-- cmd/motr/wasm/fetch.go | 211 ------- configs/logs.json | 1 + deploy/README.md | 42 -- .../chainindex/reset.sql} | 0 .../chainindex/schema.sql} | 0 .../db_seed.sql => apps/chainindex/seed.sql} | 0 deploy/devbox.json | 18 + deploy/devbox.lock | 232 +++++++ deploy/process-compose.yaml | 30 +- devbox.lock | 130 ++++ internal/config/hway/Hway.pkl.go | 8 + internal/config/motr/init.pkl.go | 1 - .../orm => internal/database/hwayorm}/db.go | 2 +- .../database/hwayorm}/models.go | 3 +- .../database/hwayorm}/query_highway.sql.go | 17 +- .../orm => internal/database/motrorm}/db.go | 2 +- .../database/motrorm}/models.go | 2 +- .../database/motrorm}/query_vault.sql.go | 2 +- .../database}/sink/query_highway.sql | 0 .../database}/sink/query_vault.sql | 0 .../database}/sink/schema_highway.sql | 3 + .../database}/sink/schema_vault.sql | 0 {deploy => internal/database}/sink/sink.go | 0 {deploy => internal/database}/sqlc.yaml | 8 +- {pkg/vault => internal}/embed/codec.go | 0 {pkg/vault => internal}/embed/index.html | 0 {pkg/vault => internal}/embed/main.js | 0 {pkg/vault => internal}/embed/sw.js | 0 {pkg/vault => internal}/embed/utils.go | 0 {pkg/vault => internal}/embed/webworker.go | 0 internal/nebula/hero/social_buttons.templ | 15 - internal/nebula/hero/social_buttons_templ.go | 40 -- internal/nebula/hero/start_button.templ | 11 - internal/nebula/hero/start_button_templ.go | 40 -- internal/nebula/hero/titles.templ | 12 - internal/nebula/hero/titles_templ.go | 66 -- internal/nebula/input/input_name.templ | 37 -- internal/nebula/layout/container.templ | 13 - internal/nebula/layout/container_templ.go | 48 -- internal/nebula/layout/grid.templ | 24 - internal/nebula/layout/layout.templ | 66 -- internal/nebula/layout/layout_templ.go | 127 ---- internal/nebula/nav/footer.templ | 10 - internal/nebula/nav/footer_templ.go | 40 -- internal/nebula/nav/header.templ | 35 -- internal/nebula/nav/header_templ.go | 69 --- .../cookies.go => pkg/common/http_cookies.go | 2 +- .../headers.go => pkg/common/http_headers.go | 2 +- pkg/gateway/handlers/check_handler.go | 36 -- pkg/gateway/handlers/initial_handler.go | 28 - pkg/gateway/handlers/register_handler.go | 24 - pkg/gateway/handlers/vault_handler.go | 28 - pkg/gateway/middleware/credentials.go | 83 --- pkg/gateway/middleware/middleware.go | 38 -- pkg/gateway/middleware/profiles.go | 125 ---- pkg/gateway/middleware/resolver.go | 113 ---- pkg/gateway/middleware/vaults.go | 80 --- pkg/gateway/routes/routes.go | 21 - pkg/gateway/views/error.templ | 19 - pkg/gateway/views/initial.templ | 31 - pkg/gateway/views/loading.templ | 14 - pkg/gateway/views/register.templ | 55 -- pkg/vault/handlers/payment.go | 93 --- pkg/vault/routes/routes.go | 15 - pkg/vault/vault.go | 1 - pkg/vault/views/initial.templ | 16 - pkl/matrix.net/Homeserver.pkl | 11 +- .../sonr.app.pkl => pkl/sonr.net/App.pkl | 2 + .../sonr.net/Config.pkl | 2 + pkl/sonr.net/Hway.pkl | 3 +- pkl/sonr.net/Motr.pkl | 17 - pkl/sonr.net/PklProject | 2 +- pkl/{sonr.orm => sonr.net}/UCAN.pkl | 8 +- pkl/sonr.orm/PklProject | 22 - pkl/sonr.orm/PklProject.deps.json | 4 - scripts/init_env.sh | 57 -- scripts/ipfs_config.sh | 26 - scripts/test_dop_node.sh | 2 +- 153 files changed, 3515 insertions(+), 2428 deletions(-) create mode 100644 .taskfiles/Hway.yml create mode 100644 .taskfiles/IPFS.yml create mode 100644 .taskfiles/Postgres.yml create mode 100644 .taskfiles/Sonrd.yml create mode 100644 .taskfiles/Synapse.yml create mode 100644 .taskfiles/TigerBeetle.yml create mode 100644 app/gateway/context/credentials.go create mode 100644 app/gateway/context/middleware.go create mode 100644 app/gateway/context/profiles.go rename {pkg/gateway/middleware => app/gateway/context}/renderer.go (93%) create mode 100644 app/gateway/context/resolver.go rename {pkg/gateway/middleware => app/gateway/context}/sessions.go (52%) create mode 100644 app/gateway/context/types.go create mode 100644 app/gateway/context/vaults.go rename {pkg => app}/gateway/gateway.go (54%) create mode 100644 app/gateway/handlers/errors.go create mode 100644 app/gateway/handlers/index.go rename pkg/vault/handlers/profile.go => app/gateway/handlers/login.go (100%) create mode 100644 app/gateway/handlers/register.go rename internal/nebula/card/sonr_profile.templ => app/gateway/islands/card_account.templ (93%) rename internal/nebula/card/sonr_profile_templ.go => app/gateway/islands/card_account_templ.go (87%) rename {internal/nebula/input => app/gateway/islands}/coin_select.templ (99%) rename {internal/nebula/input => app/gateway/islands}/coin_select_templ.go (91%) rename internal/nebula/input/input_ishuman.templ => app/gateway/islands/human_slider.templ (98%) rename internal/nebula/input/input_ishuman_templ.go => app/gateway/islands/human_slider_templ.go (95%) rename {internal/nebula/input => app/gateway/islands}/input_handle.templ (85%) rename {internal/nebula/input => app/gateway/islands}/input_handle_templ.go (89%) rename {internal/nebula/input => app/gateway/islands}/input_passkey.templ (97%) rename {internal/nebula/input => app/gateway/islands}/input_passkey_templ.go (98%) create mode 100644 app/gateway/views/base_form.templ create mode 100644 app/gateway/views/base_form_templ.go rename internal/nebula/layout/head.templ => app/gateway/views/base_head.templ (99%) rename internal/nebula/layout/head_templ.go => app/gateway/views/base_head_templ.go (93%) create mode 100644 app/gateway/views/base_hero.templ rename internal/nebula/input/input_name_templ.go => app/gateway/views/base_hero_templ.go (54%) create mode 100644 app/gateway/views/base_layout.templ create mode 100644 app/gateway/views/base_layout_templ.go create mode 100644 app/gateway/views/view_errors.templ rename pkg/gateway/views/error_templ.go => app/gateway/views/view_errors_templ.go (85%) create mode 100644 app/gateway/views/view_home.templ rename pkg/gateway/views/initial_templ.go => app/gateway/views/view_home_templ.go (85%) create mode 100644 app/gateway/views/view_loading.templ rename pkg/gateway/views/loading_templ.go => app/gateway/views/view_loading_templ.go (84%) create mode 100644 app/gateway/views/view_register.templ rename pkg/gateway/views/register_templ.go => app/gateway/views/view_register_templ.go (81%) rename {cmd/motr/wasm => app/vault/context}/wasm.go (90%) rename pkg/vault/handlers/authz.go => app/vault/handlers/authorize.go (100%) rename pkg/vault/handlers/redirect.go => app/vault/handlers/errors.go (100%) rename pkg/vault/handlers/current.go => app/vault/handlers/index.go (100%) rename pkg/vault/handlers/search.go => app/vault/handlers/login.go (100%) create mode 100644 app/vault/handlers/profile.go create mode 100644 app/vault/handlers/search.go rename pkg/vault/handlers/controller.go => app/vault/handlers/wallet.go (100%) create mode 100644 app/vault/vault.go rename internal/nebula/form/base.templ => app/vault/views/base_form.templ (84%) rename internal/nebula/form/base_templ.go => app/vault/views/base_form_templ.go (95%) create mode 100644 app/vault/views/base_head.templ create mode 100644 app/vault/views/base_head_templ.go create mode 100644 app/vault/views/base_hero.templ rename internal/nebula/layout/grid_templ.go => app/vault/views/base_hero_templ.go (61%) create mode 100644 app/vault/views/base_layout.templ create mode 100644 app/vault/views/base_layout_templ.go create mode 100644 app/vault/views/initial.templ rename {pkg => app}/vault/views/initial_templ.go (82%) delete mode 100644 cmd/motr/wasm/fetch.go create mode 100644 configs/logs.json delete mode 100644 deploy/README.md rename deploy/{sink/reset_chainindex.sql => apps/chainindex/reset.sql} (100%) rename deploy/{sink/schema_indexer.sql => apps/chainindex/schema.sql} (100%) rename deploy/{sink/db_seed.sql => apps/chainindex/seed.sql} (100%) create mode 100644 deploy/devbox.json create mode 100644 deploy/devbox.lock create mode 100644 devbox.lock rename {pkg/gateway/orm => internal/database/hwayorm}/db.go (97%) rename {pkg/gateway/orm => internal/database/hwayorm}/models.go (98%) rename {pkg/gateway/orm => internal/database/hwayorm}/query_highway.sql.go (98%) rename {pkg/vault/orm => internal/database/motrorm}/db.go (97%) rename {pkg/vault/orm => internal/database/motrorm}/models.go (99%) rename {pkg/vault/orm => internal/database/motrorm}/query_vault.sql.go (99%) rename {deploy => internal/database}/sink/query_highway.sql (100%) rename {deploy => internal/database}/sink/query_vault.sql (100%) rename {deploy => internal/database}/sink/schema_highway.sql (96%) rename {deploy => internal/database}/sink/schema_vault.sql (100%) rename {deploy => internal/database}/sink/sink.go (100%) rename {deploy => internal/database}/sqlc.yaml (72%) rename {pkg/vault => internal}/embed/codec.go (100%) rename {pkg/vault => internal}/embed/index.html (100%) rename {pkg/vault => internal}/embed/main.js (100%) rename {pkg/vault => internal}/embed/sw.js (100%) rename {pkg/vault => internal}/embed/utils.go (100%) rename {pkg/vault => internal}/embed/webworker.go (100%) delete mode 100644 internal/nebula/hero/social_buttons.templ delete mode 100644 internal/nebula/hero/social_buttons_templ.go delete mode 100644 internal/nebula/hero/start_button.templ delete mode 100644 internal/nebula/hero/start_button_templ.go delete mode 100644 internal/nebula/hero/titles.templ delete mode 100644 internal/nebula/hero/titles_templ.go delete mode 100644 internal/nebula/input/input_name.templ delete mode 100644 internal/nebula/layout/container.templ delete mode 100644 internal/nebula/layout/container_templ.go delete mode 100644 internal/nebula/layout/grid.templ delete mode 100644 internal/nebula/layout/layout.templ delete mode 100644 internal/nebula/layout/layout_templ.go delete mode 100644 internal/nebula/nav/footer.templ delete mode 100644 internal/nebula/nav/footer_templ.go delete mode 100644 internal/nebula/nav/header.templ delete mode 100644 internal/nebula/nav/header_templ.go rename internal/context/cookies.go => pkg/common/http_cookies.go (99%) rename internal/context/headers.go => pkg/common/http_headers.go (99%) delete mode 100644 pkg/gateway/handlers/check_handler.go delete mode 100644 pkg/gateway/handlers/initial_handler.go delete mode 100644 pkg/gateway/handlers/register_handler.go delete mode 100644 pkg/gateway/handlers/vault_handler.go delete mode 100644 pkg/gateway/middleware/credentials.go delete mode 100644 pkg/gateway/middleware/middleware.go delete mode 100644 pkg/gateway/middleware/profiles.go delete mode 100644 pkg/gateway/middleware/resolver.go delete mode 100644 pkg/gateway/middleware/vaults.go delete mode 100644 pkg/gateway/routes/routes.go delete mode 100644 pkg/gateway/views/error.templ delete mode 100644 pkg/gateway/views/initial.templ delete mode 100644 pkg/gateway/views/loading.templ delete mode 100644 pkg/gateway/views/register.templ delete mode 100644 pkg/vault/handlers/payment.go delete mode 100644 pkg/vault/routes/routes.go delete mode 100644 pkg/vault/vault.go delete mode 100644 pkg/vault/views/initial.templ rename deploy/config/sonr.app.pkl => pkl/sonr.net/App.pkl (98%) rename deploy/config/sonr.config.pkl => pkl/sonr.net/Config.pkl (99%) rename pkl/{sonr.orm => sonr.net}/UCAN.pkl (90%) delete mode 100644 pkl/sonr.orm/PklProject delete mode 100644 pkl/sonr.orm/PklProject.deps.json delete mode 100755 scripts/init_env.sh delete mode 100755 scripts/ipfs_config.sh diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f35d81afd..c20ed7757 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -2,7 +2,6 @@ name: Run All Checks on: pull_request: - types: [opened, edited] merge_group: jobs: @@ -132,21 +131,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - bump-version: - if: github.event_name == 'merge_group' - runs-on: ubuntu-latest - name: Bump Current Version - needs: [validate-release, test-cover, test-race] - outputs: - new_tag: ${{ steps.bump.outputs.new_tag }} - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 - - name: Create bump and changelog - id: bump - uses: commitizen-tools/commitizen-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - increment: "PATCH" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e2773b63f..5b282d05a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,8 @@ name: Publish Versioned Assets on: push: - branches: - - develop - - main + tags: + - v* paths: - "docs/**" - "proto/**" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af8ff1126..4770e11c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,8 @@ name: Versioned Release on: + pull_request: + types: [closed] push: tags: - v* @@ -9,6 +11,25 @@ permissions: contents: write jobs: + bump-version: + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' + runs-on: ubuntu-latest + name: Bump Current Version + needs: [validate-release, test-cover, test-race] + outputs: + new_tag: ${{ steps.bump.outputs.new_tag }} + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + - name: Create bump and changelog + id: bump + uses: commitizen-tools/commitizen-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + increment: "PATCH" + new-release: name: Run GoReleaser on New Tag if: startsWith(github.ref, 'refs/tags/') diff --git a/.gitignore b/.gitignore index 2ca144993..f018cdc0e 100644 --- a/.gitignore +++ b/.gitignore @@ -61,7 +61,7 @@ override.tf.json .terraformrc terraform.rc - +flake.lock # Misc .DS_Store @@ -100,6 +100,7 @@ mprocs.yaml mprocs.log tools-stamp sonr.log +deploy/conf interchaintest-downloader .haptic diff --git a/.taskfiles/Hway.yml b/.taskfiles/Hway.yml new file mode 100644 index 000000000..864547aba --- /dev/null +++ b/.taskfiles/Hway.yml @@ -0,0 +1,25 @@ +version: "3" + +vars: + GOPATH: + sh: go env GOPATH + BIN_DIR: "{{.GOPATH}}/bin" + BINARY: "{{.BIN_DIR}}/hway" + OS: + sh: uname -s + ARCH: + sh: uname -m + +tasks: + build: + desc: Build the hway binary + silent: true + cmds: + - gum spin --spinner dot --title "Build Hway Single Target ({{.OS}}/{{.ARCH}})..." -- goreleaser build --snapshot --clean --single-target --id hway -o {{.BIN_DIR}}/hway + + start: + desc: Start the hway daemon + silent: true + deps: [build] + cmds: + - "{{.BINARY}}" diff --git a/.taskfiles/IPFS.yml b/.taskfiles/IPFS.yml new file mode 100644 index 000000000..48c8c3e76 --- /dev/null +++ b/.taskfiles/IPFS.yml @@ -0,0 +1,37 @@ +version: "3" + +vars: + ROOT: + sh: git rev-parse --show-toplevel +tasks: + init: + desc: Setup ipfs with Cloudflare + silent: true + vars: + PEERS: | + '[ + {"ID": "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE", "Addrs": ["/dnsaddr/node-1.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z", "Addrs": ["/dnsaddr/node-2.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa", "Addrs": ["/dnsaddr/node-3.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx", "Addrs": ["/dnsaddr/node-4.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ", "Addrs": ["/dnsaddr/node-5.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G", "Addrs": ["/dnsaddr/node-6.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3", "Addrs": ["/dnsaddr/node-7.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP", "Addrs": ["/dnsaddr/node-8.ingress.cloudflare-ipfs.com"]}, + {"ID": "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi", "Addrs": ["/dnsaddr/node-9.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx", "Addrs": ["/dnsaddr/node-10.ingress.cloudflare-ipfs.com"]}, + {"ID": "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5", "Addrs": ["/dnsaddr/node-11.ingress.cloudflare-ipfs.com"]}, + {"ID": "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev", "Addrs": ["/dnsaddr/node-12.ingress.cloudflare-ipfs.com"]} + ]' + cmds: + - rm -rf ~/.ipfs + - ipfs init + - ipfs config --json Peering.Peers {{.PEERS}} + - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' + +start: + desc: Start the ipfs daemon + silent: true + deps: [init] + cmds: + - ipfs daemon diff --git a/.taskfiles/Postgres.yml b/.taskfiles/Postgres.yml new file mode 100644 index 000000000..61517e17f --- /dev/null +++ b/.taskfiles/Postgres.yml @@ -0,0 +1,23 @@ +version: "3" + +vars: + GOPATH: + sh: go env GOPATH + BIN_DIR: "{{.GOPATH}}/bin" + OS: + sh: uname -s + ARCH: + sh: uname -m + +tasks: + init: + desc: Initialize postgresql + silent: true + dir: deploy + cmds: + - cmd: sudo -u postgres psql -f deploy/apps/chainindex/seed.sql + platforms: + - linux + - cmd: sudo -u postgres psql -d chainindex -f deploy/apps/chainindex/schema.sql + platforms: + - linux diff --git a/.taskfiles/Sonrd.yml b/.taskfiles/Sonrd.yml new file mode 100644 index 000000000..cd98a0feb --- /dev/null +++ b/.taskfiles/Sonrd.yml @@ -0,0 +1,48 @@ +version: "3" + +vars: + BINARY: sonrd + BUILD_FLAGS: -mod=readonly -trimpath + BUILD_TAGS: netgo,ledger + COMMIT: + sh: git rev-parse HEAD + VERSION: + sh: git describe --tags --always + DOPPLER_TOKEN: + sh: skate get DOPPLER_NETWORK + +tasks: + build: + desc: Build the sonrd binary + cmds: + - > + go build + {{.BUILD_FLAGS}} + -tags "{{.BUILD_TAGS}}" + -ldflags " + -X github.com/cosmos/cosmos-sdk/version.Name=sonr + -X github.com/cosmos/cosmos-sdk/version.AppName=sonrd + -X github.com/cosmos/cosmos-sdk/version.Version={{.VERSION}} + -X github.com/cosmos/cosmos-sdk/version.Commit={{.COMMIT}} + -X github.com/cosmos/cosmos-sdk/version.BuildTags={{.BUILD_TAGS}} + " + -o ./build/{{.BINARY}} + ./cmd/sonrd + env: + CGO_ENABLED: 1 + GOARCH: + sh: go env GOARCH + GOOS: + sh: go env GOOS + + install: + desc: Install sonrd + silent: true + cmds: + - gum spin --spinner dot --title "Installing sonr daemon..." -- make install + + start: + desc: Start the sonr node + cmds: + - sh scripts/test_dop_node.sh + diff --git a/.taskfiles/Synapse.yml b/.taskfiles/Synapse.yml new file mode 100644 index 000000000..3652d0d8e --- /dev/null +++ b/.taskfiles/Synapse.yml @@ -0,0 +1,23 @@ +version: "3" + +vars: + ROOT: + sh: git rev-parse --show-toplevel + +tasks: + init: + desc: Configure synapse homeserver with PKL + silent: true + cmds: + - pkl eval pkl/matrix.net/Homeserver.pkl -f yaml -o deploy/conf/synapse/homeserver.yaml + env: + MATRIX_CLIENT_NAME: sonr.id + MATRIX_SERVER_NAME: sonr.id + MATRIX_SERVER_URL: http://localhost:8008 + MATRIX_SLIDING_SYNC_PROXY: http://localhost:8008 + MATRIX_PSQL_CONN: postgresql://matrixhs_user:matrixhs_password123@localhost:5432/sonr + MATRIX_REGISTRATION_SHARED_SECRET: secret + MATRIX_ENABLE_RECATCHA: false + MATRIX_RECATCHA_PUBLIC_KEY: "" + MATRIX_RECATCHA_PRIVATE_KEY: "" + MATRIX_RECATCHA_BYPASS_SECRET: "" diff --git a/.taskfiles/TigerBeetle.yml b/.taskfiles/TigerBeetle.yml new file mode 100644 index 000000000..0b9114d19 --- /dev/null +++ b/.taskfiles/TigerBeetle.yml @@ -0,0 +1,12 @@ +version: "3" + +vars: + ROOT: + sh: git rev-parse --show-toplevel + +tasks: + init: + desc: Configure tigerbeetle database + silent: true + cmds: + - pkl eval pkl/matrix.net/Homeserver.pkl -f yaml -o deploy/conf/synapse/homeserver.yaml diff --git a/Dockerfile b/Dockerfile index 69daa6b83..6d9b351b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,3 @@ -FROM jetpackio/devbox:latest AS sonrvm - -# Installing your devbox project -WORKDIR /code -USER root:root - -RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code - -USER ${DEVBOX_USER}:${DEVBOX_USER} - -COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json -COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} process-compose.yaml process-compose.yaml - -RUN devbox run -- echo "Installed Packages." - -ENTRYPOINT ["devbox", "run"] - -# -------------------------------------------------------- -FROM jetpackio/devbox:latest AS sonr-runner - -WORKDIR /code -USER root:root - -RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code - -USER ${DEVBOX_USER}:${DEVBOX_USER} - -COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json -COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} process-compose.yaml process-compose.yaml -COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . . - -RUN devbox run -- echo "Installed Packages." - -RUN git config --global --add safe.directory /code -ENTRYPOINT ["devbox", "run", "testnet"] - -# -------------------------------------------------------- FROM golang:1.22-alpine AS go-builder SHELL ["/bin/sh", "-ecuxo", "pipefail"] diff --git a/Makefile b/Makefile index c4b7f7d0f..ffe87aa07 100644 --- a/Makefile +++ b/Makefile @@ -87,6 +87,12 @@ else go build -mod=readonly $(BUILD_FLAGS) -o build/sonrd ./cmd/sonrd endif +build-motr: go.sum + GOOS=js GOARCH=wasm go build -o static/wasm/app.wasm ./cmd/motr/main.go + +build-hway: go.sum + go build -o build/hway ./cmd/hway + build-windows-client: go.sum GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/sonrd.exe ./cmd/sonrd @@ -100,6 +106,9 @@ endif install: go.sum go install -mod=readonly $(BUILD_FLAGS) ./cmd/sonrd +install-hway: go.sum + go install -mod=readonly ./cmd/hway + ######################################## ### Tools & dependencies @@ -301,75 +310,12 @@ testnet-basic: setup-testnet sh-testnet: mod-tidy CHAIN_ID="sonr-testnet-1" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh -dop-testnet: mod-tidy - sh scripts/test_dop_node.sh - .PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet dop-testnet -############################################################################### -### generation ### -############################################################################### -.PHONY: gen-pkl gen-templ gen-sqlc - -gen-pkl: init-env - pkl-gen-go pkl/sonr.orm/UCAN.pkl - pkl-gen-go pkl/sonr.net/Hway.pkl - pkl-gen-go pkl/sonr.net/Motr.pkl - -gen-sqlc: init-env - @sqlc generate -f deploy/sqlc.yaml - -gen-templ: init-env - @templ generate - -############################################################################### -### custom builds ### -############################################################################### -.PHONY: build-motr build-hway logs-hway logs-sonr - -build-motr: - GOOS=js GOARCH=wasm go build -o static/wasm/app.wasm ./cmd/motr/main.go - -build-hway: gen-templ - go build -o build/hway ./cmd/hway - -logs-hway: init-env - bin/process-compose process logs hway --port $(PC_PORT_NUM) --follow - -logs-sonr: init-env - bin/process-compose process logs sonr --port $(PC_PORT_NUM) --follow - -############################################################################### -### Network Start/Stop ### -############################################################################### - -.PHONY: deploy start start-tui start-uds stop stop-uds restart status - -start: build-hway init-env - bin/process-compose up --port $(PC_PORT_NUM) --log-file $(PC_LOG_FILE) -f deploy/process-compose.yaml - -start-uds: build-hway init-env - bin/process-compose up --use-uds --unix-socket $(PC_SOCKET_PATH) --log-file $(PC_LOG_FILE) --detached -f deploy/process-compose.yaml - -stop: init-env - bin/process-compose down --port $(PC_PORT_NUM) - -stop-uds: init-env - bin/process-compose down --use-uds --unix-socket $(PC_SOCKET_PATH) - -status: init-env - bin/process-compose project state --port $(PC_PORT_NUM) - -status-uds: init-env - bin/process-compose project state --use-uds --unix-socket $(PC_SOCKET_PATH) ############################################################################### ### help ### ############################################################################### -deploy: - cd ./proto && bunx buf dep update && bunx buf build && bunx buf push - sh ./.github/scripts/upload_cdn.sh - help: @echo "Usage: make " @echo "" @@ -381,7 +327,5 @@ help: @echo " sh-testnet : Shell local devnet" @echo " ictest-basic : Basic end-to-end test" @echo " ictest-ibc : IBC end-to-end test" - @echo " templ : Generate templ files" - @echo " vault : Build vault.wasm" .PHONY: help diff --git a/README.md b/README.md index aca1f39a4..eb0ef3e49 100644 --- a/README.md +++ b/README.md @@ -37,4 +37,3 @@ Sonr would not have been possible without the direct and indirect support of the - [Forum](https://github.com/onsonr/sonr/discussions) - [Issues](https://github.com/onsonr/sonr/issues) - [Twitter](https://sonr.io/twitter) -- [Dev Chat](https://sonr.io/discord) diff --git a/Taskfile.yml b/Taskfile.yml index 0c3309c4f..fd7828816 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -5,7 +5,7 @@ vars: sh: git describe --tags --abbrev=0 COMMIT: sh: git rev-parse --short HEAD - ROOT_DIR: + ROOT: sh: git rev-parse --show-toplevel OS: sh: uname -s @@ -13,110 +13,60 @@ vars: sh: task -l DOPPLER_TOKEN: sh: skate get DOPPLER_NETWORK + +includes: + hway: + taskfile: .taskfiles/Hway.yml + ipfs: + taskfile: .taskfiles/IPFS.yml + postgres: + taskfile: .taskfiles/Postgres.yml + sonrd: + taskfile: .taskfiles/Sonrd.yml + synapse: + taskfile: .taskfiles/Synapse.yml + tigerbeetle: + taskfile: .taskfiles/TigerBeetle.yml + tasks: default: cmds: - gh run ls -L 3 - - gum format -- "# Sonr ({{.OS}}-{{.VERSION}})" "({{.COMMIT}}) {{.ROOT_DIR}}" "### {{ .TASKS }}" + - gum format -- "# Sonr ({{.OS}}-{{.VERSION}})" " - ({{.COMMIT}}) {{.ROOT}}" + - task -l -j | jq -r '.tasks[].name' | fzf --height=16 | xargs task silent: true - build: - desc: Build all binaries + deps: + desc: Install go dependencies + silent: true + vars: + DEPS: ["github.com/apple/pkl-go/cmd/pkl-gen-go@latest", "github.com/sqlc-dev/sqlc/cmd/sqlc@latest", "github.com/goreleaser/goreleaser/v2@latest","github.com/a-h/templ/cmd/templ@latest"] + cmds: + - for: { var: DEPS } + cmd: gum spin --spinner dot --title "Installing go dependencies..." -- go install {{.ITEM}} + + pkl-gen: + desc: Generate PKL files + silent: true + dir: "pkl/sonr.net" + vars: + FILES: ["Hway.pkl", "Motr.pkl", "UCAN.pkl"] + cmds: + - for: { var: FILES } + cmd: gum spin --spinner dot --title "Generating PKL in Go..." -- pkl-gen-go {{.ITEM}} + + proto-gen: + desc: Generate proto files + silent: true + cmd: gum spin --spinner dot --title "Generating Protobufs..." -- make proto-gen + + sqlc-gen: + desc: Generate SQLC files silent: true cmds: - - task: clean - - mkdir -p ./build - - mkdir -p ./static/wasm - - task: build:motr - - task: build:sonr - - task: build:hway + - gum spin --spinner dot --title "Generating SQLC..." -- sqlc generate -f internal/database/sqlc.yaml - start: - desc: Start the node + templ-gen: + desc: Generate templ files silent: true - cmds: - - task: build:hway - - task: start:darwin - - task: start:linux - - stop: - desc: Stop the node - silent: true - cmds: - - task: stop:darwin - - task: stop:linux - - build:motr: - internal: true - silent: true - cmd: goreleaser build --snapshot --id motr --clean -o ./static/wasm/app.wasm - - build:sonr: - internal: true - silent: true - cmd: goreleaser build --snapshot --id sonr --single-target --clean -o ./build/sonrd - - build:hway: - internal: true - silent: true - cmd: goreleaser build --snapshot --id hway --single-target --clean -o ./build/hway - - init:db: - desc: Initialize the database - silent: true - platforms: - - linux - cmds: - - sudo -u postgres psql -f ./deploy/sink/db_seed.sql - - sudo -u postgres psql -d chainindex -f ./deploy/sink/schema_indexer.sql - - init:ipfs: - desc: Initialize the ipfs node - silent: true - cmds: - - sh ./scripts/ipfs_config.sh - - start:darwin: - internal: true - silent: true - platforms: - - darwin - cmd: make start - - start:linux: - internal: true - silent: true - platforms: - - linux - cmd: make start-uds - - stop:darwin: - internal: true - silent: true - platforms: - - darwin - cmd: make stop - - stop:linux: - internal: true - silent: true - platforms: - - linux - cmds: - - make stop-uds - - task: reset:chainindex - - clean: - internal: true - cmds: - - sh ./scripts/init_env.sh - - rm -rf ./build - - rm -rf ./dist - - rm -rf ./static - silent: true - - reset:chainindex: - internal: true - platforms: - - linux - cmd: sudo -u postgres psql -f ./deploy/sink/reset_chainindex.sql + cmd: gum spin --spinner dot --title "Generating Templ..." -- templ generate diff --git a/app/gateway/context/credentials.go b/app/gateway/context/credentials.go new file mode 100644 index 000000000..1eff7d8fe --- /dev/null +++ b/app/gateway/context/credentials.go @@ -0,0 +1,19 @@ +package context + +import ( + "github.com/go-webauthn/webauthn/protocol" +) + +func (c *GatewayContext) NewChallenge() string { + chal, _ := protocol.CreateChallenge() + chalStr := chal.String() + return chalStr +} + +func (cc *GatewayContext) ListCredentials(handle string) ([]*CredentialDescriptor, error) { + creds, err := cc.GetCredentialsByHandle(bgCtx(), handle) + if err != nil { + return nil, err + } + return CredentialArrayToDescriptors(creds), nil +} diff --git a/app/gateway/context/middleware.go b/app/gateway/context/middleware.go new file mode 100644 index 000000000..0a621b64d --- /dev/null +++ b/app/gateway/context/middleware.go @@ -0,0 +1,64 @@ +package context + +import ( + gocontext "context" + "net/http" + + "github.com/labstack/echo/v4" + "github.com/medama-io/go-useragent" + "github.com/onsonr/sonr/crypto/mpc" + "github.com/onsonr/sonr/internal/config/hway" + hwayorm "github.com/onsonr/sonr/internal/database/hwayorm" + "github.com/onsonr/sonr/pkg/common" +) + +type GatewayContext struct { + echo.Context + *hwayorm.Queries + agent useragent.UserAgent + id string + ipfsClient common.IPFS + tokenStore common.IPFSTokenStore + stagedEnclaves map[string]mpc.Enclave + grpcAddr string + turnstileSiteKey string +} + +func GetGateway(c echo.Context) (*GatewayContext, error) { + cc, ok := c.(*GatewayContext) + if !ok { + return nil, echo.NewHTTPError(http.StatusInternalServerError, "Gateway Context not found") + } + return cc, nil +} + +func UseGateway(env hway.Hway, ipc common.IPFS, db *hwayorm.Queries) echo.MiddlewareFunc { + return func(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + ua := useragent.NewParser() + ctx := &GatewayContext{ + Context: c, + turnstileSiteKey: env.GetTurnstileSiteKey(), + agent: ua.Parse(c.Request().UserAgent()), + Queries: db, + ipfsClient: ipc, + grpcAddr: env.GetSonrGrpcUrl(), + tokenStore: common.NewUCANStore(ipc), + } + return next(ctx) + } + } +} + +func BG() gocontext.Context { + ctx := gocontext.Background() + return ctx +} + +func (cc *GatewayContext) ReadCookie(k common.CookieKey) string { + return common.ReadCookieUnsafe(cc.Context, k) +} + +func (cc *GatewayContext) WriteCookie(k common.CookieKey, v string) { + common.WriteCookie(cc.Context, k, v) +} diff --git a/app/gateway/context/profiles.go b/app/gateway/context/profiles.go new file mode 100644 index 000000000..59a9032ff --- /dev/null +++ b/app/gateway/context/profiles.go @@ -0,0 +1,53 @@ +package context + +import ( + "net/http" + + "github.com/labstack/echo/v4" + hwayorm "github.com/onsonr/sonr/internal/database/hwayorm" +) + +func UpdateProfile(c echo.Context) (*hwayorm.Profile, error) { + ctx, ok := c.(*GatewayContext) + if !ok { + return nil, echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found") + } + address := c.FormValue("address") + handle := c.FormValue("handle") + name := c.FormValue("name") + profile, err := ctx.UpdateProfile(bgCtx(), hwayorm.UpdateProfileParams{ + Address: address, + Handle: handle, + Name: name, + }) + if err != nil { + return nil, err + } + return &profile, nil +} + +func ReadProfile(c echo.Context) (*hwayorm.Profile, error) { + ctx, ok := c.(*GatewayContext) + if !ok { + return nil, echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found") + } + handle := c.Param("handle") + profile, err := ctx.GetProfileByHandle(bgCtx(), handle) + if err != nil { + return nil, err + } + return &profile, nil +} + +func DeleteProfile(c echo.Context) error { + ctx, ok := c.(*GatewayContext) + if !ok { + return echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found") + } + address := c.Param("address") + err := ctx.SoftDeleteProfile(bgCtx(), address) + if err != nil { + return err + } + return nil +} diff --git a/pkg/gateway/middleware/renderer.go b/app/gateway/context/renderer.go similarity index 93% rename from pkg/gateway/middleware/renderer.go rename to app/gateway/context/renderer.go index c0759c614..5ed31517d 100644 --- a/pkg/gateway/middleware/renderer.go +++ b/app/gateway/context/renderer.go @@ -1,11 +1,11 @@ -package middleware +package context import ( "bytes" "github.com/a-h/templ" "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/gateway/views" + "github.com/onsonr/sonr/app/gateway/views" ) func Render(c echo.Context, cmp templ.Component) error { diff --git a/app/gateway/context/resolver.go b/app/gateway/context/resolver.go new file mode 100644 index 000000000..2fb2aeb31 --- /dev/null +++ b/app/gateway/context/resolver.go @@ -0,0 +1,105 @@ +package context + +import ( + "fmt" + + "github.com/onsonr/sonr/pkg/common" +) + +// ParamsBank returns the bank params +func (cc *GatewayContext) ParamsBank() (*common.BankParamsResponse, error) { + cl, err := common.NewBankClient(cc.grpcAddr) + if err != nil { + return nil, err + } + resp, err := cl.Params(bgCtx(), &common.BankParamsRequest{}) + if err != nil { + return nil, err + } + return resp, nil +} + +// ParamsDID returns the DID params +func (cc *GatewayContext) ParamsDID() (*common.DIDParamsResponse, error) { + cl, err := common.NewDIDClient(cc.grpcAddr) + if err != nil { + return nil, err + } + resp, err := cl.Params(bgCtx(), &common.DIDParamsRequest{}) + if err != nil { + return nil, err + } + return resp, nil +} + +// ParamsDWN returns the DWN params +func (cc *GatewayContext) ParamsDWN() (*common.DWNParamsResponse, error) { + cl, err := common.NewDWNClient(cc.grpcAddr) + if err != nil { + return nil, err + } + resp, err := cl.Params(bgCtx(), &common.DWNParamsRequest{}) + if err != nil { + return nil, err + } + return resp, nil +} + +// ParamsSVC returns the SVC params +func (cc *GatewayContext) ParamsSVC() (*common.SVCParamsResponse, error) { + cl, err := common.NewSVCClient(cc.grpcAddr) + if err != nil { + return nil, err + } + resp, err := cl.Params(bgCtx(), &common.SVCParamsRequest{}) + if err != nil { + return nil, err + } + return resp, nil +} + +// StatusBlock returns the current block +func (cc *GatewayContext) StatusBlock() string { + qc, err := common.NewNodeClient(cc.grpcAddr) + if err != nil { + return "-1" + } + resp, err := qc.Status(bgCtx(), &common.StatusRequest{}) + if err != nil { + return "-1" + } + return fmt.Sprintf("%d", resp.GetHeight()) +} + +// StatusNode returns the node status +func (cc *GatewayContext) StatusNode() (*common.StatusResponse, error) { + cl, err := common.NewNodeClient(cc.grpcAddr) + if err != nil { + return nil, err + } + resp, err := cl.Status(bgCtx(), &common.StatusRequest{}) + if err != nil { + return nil, err + } + return resp, nil +} + +// TxBroadcast broadcasts a transaction to the network +func (cc *GatewayContext) TxBroadcast() error { + return nil +} + +// TxEncode encodes a transaction +func (cc *GatewayContext) TxEncode() error { + return nil +} + +// TxDecode decodes a transaction +func (cc *GatewayContext) TxDecode() error { + return nil +} + +// TxSimulate simulates a transaction on the network +func (cc *GatewayContext) TxSimulate() error { + return nil +} diff --git a/pkg/gateway/middleware/sessions.go b/app/gateway/context/sessions.go similarity index 52% rename from pkg/gateway/middleware/sessions.go rename to app/gateway/context/sessions.go index ed9be0c2c..f42557d9a 100644 --- a/pkg/gateway/middleware/sessions.go +++ b/app/gateway/context/sessions.go @@ -1,14 +1,12 @@ -package middleware +package context import ( gocontext "context" - "github.com/go-webauthn/webauthn/protocol" "github.com/labstack/echo/v4" - "github.com/medama-io/go-useragent" - ctx "github.com/onsonr/sonr/internal/context" - hwayorm "github.com/onsonr/sonr/pkg/gateway/orm" + "github.com/onsonr/sonr/pkg/common" "github.com/segmentio/ksuid" + "lukechampine.com/blake3" ) func NewSession(c echo.Context) error { @@ -18,16 +16,32 @@ func NewSession(c echo.Context) error { } baseSessionCreateParams := BaseSessionCreateParams(cc) cc.id = baseSessionCreateParams.ID - if _, err := cc.dbq.CreateSession(bgCtx(), baseSessionCreateParams); err != nil { + if _, err := cc.CreateSession(bgCtx(), baseSessionCreateParams); err != nil { return err } // Set Cookie - if err := ctx.WriteCookie(c, ctx.SessionID, cc.id); err != nil { + if err := common.WriteCookie(c, common.SessionID, cc.id); err != nil { return err } return nil } +// Uses blake3 to hash the sessionID to generate a nonce of length 12 bytes +func GetNonce(sessionID string) ([]byte, error) { + hash := blake3.New(32, nil) + _, err := hash.Write([]byte(sessionID)) + if err != nil { + return nil, err + } + // Read the hash into a byte slice + nonce := make([]byte, 12) + _, err = hash.Write(nonce) + if err != nil { + return nil, err + } + return nonce, nil +} + // ForbiddenDevice returns true if the device is unavailable func ForbiddenDevice(c echo.Context) bool { cc, ok := c.(*GatewayContext) @@ -49,29 +63,29 @@ func GetSessionID(c echo.Context) string { } // check from cookie if cc.id == "" { - if ok := ctx.CookieExists(c, ctx.SessionID); !ok { + if ok := common.CookieExists(c, common.SessionID); !ok { return "" } - cc.id = ctx.ReadCookieUnsafe(c, ctx.SessionID) + cc.id = common.ReadCookieUnsafe(c, common.SessionID) } return cc.id } -func GetSessionChallenge(c echo.Context) string { +func GetAuthChallenge(c echo.Context) string { cc, ok := c.(*GatewayContext) if !ok { return "" } - s, err := cc.dbq.GetChallengeBySessionID(bgCtx(), cc.id) + s, err := cc.GetChallengeBySessionID(bgCtx(), cc.id) if err != nil { return "" } return s } -func GetHandle(c echo.Context) string { +func GetProfileHandle(c echo.Context) string { // First check for the cookie - handle := ctx.ReadCookieUnsafe(c, ctx.UserHandle) + handle := common.ReadCookieUnsafe(c, common.UserHandle) if handle != "" { return handle } @@ -81,11 +95,11 @@ func GetHandle(c echo.Context) string { if !ok { return "" } - s, err := cc.dbq.GetSessionByID(bgCtx(), cc.id) + s, err := cc.GetSessionByID(bgCtx(), cc.id) if err != nil { return "" } - profile, err := cc.dbq.GetProfileByID(bgCtx(), s.ProfileID) + profile, err := cc.GetProfileByID(bgCtx(), s.ProfileID) if err != nil { return "" } @@ -111,42 +125,17 @@ func bgCtx() gocontext.Context { return ctx } -func BaseSessionCreateParams(e echo.Context) hwayorm.CreateSessionParams { - // f := rand.Intn(5) + 1 - // l := rand.Intn(4) + 1 - challenge, _ := protocol.CreateChallenge() - id := getOrCreateSessionID(e) - ua := useragent.NewParser() - s := ua.Parse(e.Request().UserAgent()) - - return hwayorm.CreateSessionParams{ - ID: id, - BrowserName: s.GetBrowser(), - BrowserVersion: s.GetMajorVersion(), - ClientIpaddr: e.RealIP(), - Platform: s.GetOS(), - IsMobile: s.IsMobile(), - IsTablet: s.IsTablet(), - IsDesktop: s.IsDesktop(), - IsBot: s.IsBot(), - IsTv: s.IsTV(), - // IsHumanFirst: int64(f), - // IsHumanLast: int64(l), - Challenge: challenge.String(), - } -} - func getOrCreateSessionID(c echo.Context) string { - if ok := ctx.CookieExists(c, ctx.SessionID); !ok { + if ok := common.CookieExists(c, common.SessionID); !ok { sessionID := ksuid.New().String() - ctx.WriteCookie(c, ctx.SessionID, sessionID) + common.WriteCookie(c, common.SessionID, sessionID) return sessionID } - sessionID, err := ctx.ReadCookie(c, ctx.SessionID) + sessionID, err := common.ReadCookie(c, common.SessionID) if err != nil { sessionID = ksuid.New().String() - ctx.WriteCookie(c, ctx.SessionID, sessionID) + common.WriteCookie(c, common.SessionID, sessionID) } return sessionID } diff --git a/app/gateway/context/types.go b/app/gateway/context/types.go new file mode 100644 index 000000000..72ccea7e1 --- /dev/null +++ b/app/gateway/context/types.go @@ -0,0 +1,102 @@ +package context + +import ( + "github.com/go-webauthn/webauthn/protocol" + "github.com/labstack/echo/v4" + "github.com/medama-io/go-useragent" + hwayorm "github.com/onsonr/sonr/internal/database/hwayorm" +) + +// Define the credential structure matching our frontend data +type CredentialDescriptor struct { + ID string `json:"id"` + RawID string `json:"rawId"` + Type string `json:"type"` + AuthenticatorAttachment string `json:"authenticatorAttachment"` + Transports string `json:"transports"` + ClientExtensionResults map[string]string `json:"clientExtensionResults"` + Response struct { + AttestationObject string `json:"attestationObject"` + ClientDataJSON string `json:"clientDataJSON"` + } `json:"response"` +} + +func (c *CredentialDescriptor) ToModel(handle, origin string) *hwayorm.Credential { + return &hwayorm.Credential{ + Handle: handle, + Origin: origin, + CredentialID: c.ID, + Type: c.Type, + Transports: c.Transports, + AuthenticatorAttachment: c.AuthenticatorAttachment, + } +} + +func CredentialArrayToDescriptors(credentials []hwayorm.Credential) []*CredentialDescriptor { + var descriptors []*CredentialDescriptor + for _, cred := range credentials { + cd := &CredentialDescriptor{ + ID: cred.CredentialID, + RawID: cred.CredentialID, + Type: cred.Type, + AuthenticatorAttachment: cred.AuthenticatorAttachment, + Transports: cred.Transports, + } + descriptors = append(descriptors, cd) + } + return descriptors +} + +func BaseSessionCreateParams(e echo.Context) hwayorm.CreateSessionParams { + // f := rand.Intn(5) + 1 + // l := rand.Intn(4) + 1 + challenge, _ := protocol.CreateChallenge() + id := getOrCreateSessionID(e) + ua := useragent.NewParser() + s := ua.Parse(e.Request().UserAgent()) + + return hwayorm.CreateSessionParams{ + ID: id, + BrowserName: s.GetBrowser(), + BrowserVersion: s.GetMajorVersion(), + ClientIpaddr: e.RealIP(), + Platform: s.GetOS(), + IsMobile: s.IsMobile(), + IsTablet: s.IsTablet(), + IsDesktop: s.IsDesktop(), + IsBot: s.IsBot(), + IsTv: s.IsTV(), + // IsHumanFirst: int64(f), + // IsHumanLast: int64(l), + Challenge: challenge.String(), + } +} + +// ╭───────────────────────────────────────────────────────────╮ +// │ Create Passkey (/register/passkey) │ +// ╰───────────────────────────────────────────────────────────╯ + +// CreatePasskeyParams represents the parameters for creating a passkey +type CreatePasskeyParams struct { + Address string + Handle string + Name string + Challenge string + CreationBlock string +} + +// ╭───────────────────────────────────────────────────────────╮ +// │ Create Profile (/register/profile) │ +// ╰───────────────────────────────────────────────────────────╯ + +// CreateProfileParams represents the parameters for creating a profile +type CreateProfileParams struct { + TurnstileSiteKey string + FirstNumber int + LastNumber int +} + +// Sum returns the sum of the first and last number +func (d CreateProfileParams) Sum() int { + return d.FirstNumber + d.LastNumber +} diff --git a/app/gateway/context/vaults.go b/app/gateway/context/vaults.go new file mode 100644 index 000000000..203728f69 --- /dev/null +++ b/app/gateway/context/vaults.go @@ -0,0 +1,45 @@ +package context + +import ( + "github.com/onsonr/sonr/crypto/mpc" + "github.com/onsonr/sonr/pkg/common" + "lukechampine.com/blake3" +) + +func (cc *GatewayContext) Spawn(handle, origin string) (*CreatePasskeyParams, error) { + challenge := GetAuthChallenge(cc) + sid := GetSessionID(cc) + nonce, err := calcNonce(sid) + if err != nil { + return nil, err + } + encl, err := mpc.GenEnclave(nonce) + if err != nil { + return nil, err + } + cc.stagedEnclaves[sid] = encl + common.WriteCookie(cc, common.SonrAddress, encl.Address()) + return &CreatePasskeyParams{ + Address: encl.Address(), + Handle: handle, + Name: origin, + Challenge: challenge, + CreationBlock: cc.StatusBlock(), + }, nil +} + +// Uses blake3 to hash the sessionID to generate a nonce of length 12 bytes +func calcNonce(sessionID string) ([]byte, error) { + hash := blake3.New(32, nil) + _, err := hash.Write([]byte(sessionID)) + if err != nil { + return nil, err + } + // Read the hash into a byte slice + nonce := make([]byte, 12) + _, err = hash.Write(nonce) + if err != nil { + return nil, err + } + return nonce, nil +} diff --git a/pkg/gateway/gateway.go b/app/gateway/gateway.go similarity index 54% rename from pkg/gateway/gateway.go rename to app/gateway/gateway.go index ce5351685..c7ff95839 100644 --- a/pkg/gateway/gateway.go +++ b/app/gateway/gateway.go @@ -5,38 +5,29 @@ import ( "github.com/labstack/echo-contrib/echoprometheus" "github.com/labstack/echo/v4" echomiddleware "github.com/labstack/echo/v4/middleware" + "github.com/onsonr/sonr/app/gateway/context" + "github.com/onsonr/sonr/app/gateway/handlers" config "github.com/onsonr/sonr/internal/config/hway" - hwayorm "github.com/onsonr/sonr/pkg/gateway/orm" + hwayorm "github.com/onsonr/sonr/internal/database/hwayorm" "github.com/onsonr/sonr/pkg/common" - "github.com/onsonr/sonr/pkg/gateway/middleware" - "github.com/onsonr/sonr/pkg/gateway/routes" ) type Gateway = *echo.Echo // New returns a new Gateway instance func New(env config.Hway, ipc common.IPFS, dbq *hwayorm.Queries) (Gateway, error) { - e := echo.New() - // Override default behaviors - e.IPExtractor = echo.ExtractIPDirect() - e.HTTPErrorHandler = redirectOnError("http://localhost:3000") // Built-in middleware - e.Use(echoprometheus.NewMiddleware("hway")) e.Use(echomiddleware.Logger()) e.Use(echomiddleware.Recover()) - e.Use(middleware.UseGateway(env, ipc, dbq)) - routes.Register(e) + e.IPExtractor = echo.ExtractIPDirect() + e.Use(echoprometheus.NewMiddleware("hway")) + e.Use(context.UseGateway(env, ipc, dbq)) + + // Register View Handlers + e.HTTPErrorHandler = handlers.ErrorHandler + e.GET("/", handlers.IndexHandler) + handlers.RegisterHandler(e.Group("/register")) return e, nil } - -func redirectOnError(target string) echo.HTTPErrorHandler { - return func(err error, c echo.Context) { - if he, ok := err.(*echo.HTTPError); ok { - // Log the error if needed - c.Logger().Errorf("Error: %v", he.Message) - middleware.RenderError(c, he) - } - } -} diff --git a/app/gateway/handlers/errors.go b/app/gateway/handlers/errors.go new file mode 100644 index 000000000..ec69d8835 --- /dev/null +++ b/app/gateway/handlers/errors.go @@ -0,0 +1,14 @@ +package handlers + +import ( + "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/app/gateway/context" +) + +func ErrorHandler(err error, c echo.Context) { + if he, ok := err.(*echo.HTTPError); ok { + // Log the error if needed + c.Logger().Errorf("Error: %v", he.Message) + context.RenderError(c, he) + } +} diff --git a/app/gateway/handlers/index.go b/app/gateway/handlers/index.go new file mode 100644 index 000000000..e8869fb8c --- /dev/null +++ b/app/gateway/handlers/index.go @@ -0,0 +1,14 @@ +package handlers + +import ( + "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/app/gateway/context" +) + +func IndexHandler(c echo.Context) error { + id := context.GetSessionID(c) + if id == "" { + context.NewSession(c) + } + return context.RenderInitial(c) +} diff --git a/pkg/vault/handlers/profile.go b/app/gateway/handlers/login.go similarity index 100% rename from pkg/vault/handlers/profile.go rename to app/gateway/handlers/login.go diff --git a/app/gateway/handlers/register.go b/app/gateway/handlers/register.go new file mode 100644 index 000000000..f5b9450ec --- /dev/null +++ b/app/gateway/handlers/register.go @@ -0,0 +1,111 @@ +package handlers + +import ( + "encoding/json" + + "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/app/gateway/context" + "github.com/onsonr/sonr/app/gateway/islands" + "github.com/onsonr/sonr/app/gateway/views" + hwayorm "github.com/onsonr/sonr/internal/database/hwayorm" + "github.com/onsonr/sonr/pkg/common" +) + +func RegisterHandler(g *echo.Group) { + g.GET("/", renderProfileForm) + g.POST("/profile", validateProfileForm) + g.GET("/passkey", renderPasskeyForm) + g.POST("/passkey", validatePasskeyForm) + g.GET("/vault", renderVaultStatus) +} + +// ╭──────────────────────────────────────────────────────╮ +// │ Registration Views │ +// ╰────────────────────────────────────────────────────── + +func renderProfileForm(c echo.Context) error { + params := context.CreateProfileParams{ + FirstNumber: 6, + LastNumber: 3, + } + return context.Render(c, views.RegisterProfileView(params.FirstNumber, params.LastNumber)) +} + +func renderPasskeyForm(c echo.Context) error { + cc, err := context.GetGateway(c) + if err != nil { + return err + } + handle := c.FormValue("handle") + origin := c.FormValue("origin") + name := c.FormValue("name") + cc.InsertProfile(context.BG(), hwayorm.InsertProfileParams{ + Handle: handle, + Origin: origin, + Name: name, + }) + + params, err := cc.Spawn(handle, origin) + if err != nil { + return context.RenderError(c, err) + } + return context.Render(c, views.RegisterPasskeyView(params.Address, params.Handle, params.Name, params.Challenge, params.CreationBlock)) +} + +func renderVaultStatus(c echo.Context) error { + return context.Render(c, views.LoadingView()) +} + +// ╭─────────────────────────────────────────────────────────╮ +// │ Validation Components │ +// ╰─────────────────────────────────────────────────────────╯ + +func validateProfileForm(c echo.Context) error { + cc, err := context.GetGateway(c) + if err != nil { + return context.RenderError(c, err) + } + handle := c.FormValue("handle") + if handle == "" { + return context.Render(c, islands.InputHandleError(handle, "Please enter a 4-16 character handle")) + } + notok, err := cc.CheckHandleExists(context.BG(), handle) + if err != nil { + return err + } + if notok { + return context.Render(c, islands.InputHandleError(handle, "Handle is already taken")) + } + cc.WriteCookie(common.UserHandle, handle) + return context.Render(c, islands.InputHandleSuccess(handle)) +} + +func validatePasskeyForm(c echo.Context) error { + cc, err := context.GetGateway(c) + if err != nil { + return context.RenderError(c, err) + } + handle := context.GetProfileHandle(c) + origin := c.Request().Host + credentialJSON := c.FormValue("credential") + cred := &context.CredentialDescriptor{} + + // Unmarshal the credential JSON + err = json.Unmarshal([]byte(credentialJSON), cred) + if err != nil { + return context.RenderError(c, err) + } + + md := cred.ToModel(handle, origin) + _, err = cc.InsertCredential(context.BG(), hwayorm.InsertCredentialParams{ + Handle: md.Handle, + CredentialID: md.CredentialID, + Origin: md.Origin, + Type: md.Type, + Transports: md.Transports, + }) + if err != nil { + return context.RenderError(c, err) + } + return context.Render(c, views.LoadingView()) +} diff --git a/internal/nebula/card/sonr_profile.templ b/app/gateway/islands/card_account.templ similarity index 93% rename from internal/nebula/card/sonr_profile.templ rename to app/gateway/islands/card_account.templ index bfe943505..76e7b8cb5 100644 --- a/internal/nebula/card/sonr_profile.templ +++ b/app/gateway/islands/card_account.templ @@ -1,6 +1,6 @@ -package card +package islands -templ SonrProfile(addr, name, handle, creationBlock string) { +templ CardAccount(addr, name, handle, creationBlock string) {
diff --git a/internal/nebula/card/sonr_profile_templ.go b/app/gateway/islands/card_account_templ.go similarity index 87% rename from internal/nebula/card/sonr_profile_templ.go rename to app/gateway/islands/card_account_templ.go index 2dfcb8f61..9d48770ca 100644 --- a/internal/nebula/card/sonr_profile_templ.go +++ b/app/gateway/islands/card_account_templ.go @@ -1,14 +1,14 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package card +package islands //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 SonrProfile(addr, name, handle, creationBlock string) templ.Component { +func CardAccount(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 { @@ -36,7 +36,7 @@ func SonrProfile(addr, name, handle, creationBlock string) templ.Component { 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/nebula/card/sonr_profile.templ`, Line: 9, Col: 43} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/card_account.templ`, Line: 9, Col: 43} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -49,7 +49,7 @@ func SonrProfile(addr, name, handle, creationBlock string) templ.Component { 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/nebula/card/sonr_profile.templ`, Line: 16, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/card_account.templ`, Line: 16, Col: 58} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -62,7 +62,7 @@ func SonrProfile(addr, name, handle, creationBlock string) templ.Component { 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/nebula/card/sonr_profile.templ`, Line: 21, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/card_account.templ`, Line: 21, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -75,7 +75,7 @@ func SonrProfile(addr, name, handle, creationBlock string) templ.Component { 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/nebula/card/sonr_profile.templ`, Line: 25, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/card_account.templ`, Line: 25, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { diff --git a/internal/nebula/input/coin_select.templ b/app/gateway/islands/coin_select.templ similarity index 99% rename from internal/nebula/input/coin_select.templ rename to app/gateway/islands/coin_select.templ index aa26e6036..e16e7fbf7 100644 --- a/internal/nebula/input/coin_select.templ +++ b/app/gateway/islands/coin_select.templ @@ -1,4 +1,4 @@ -package input +package islands type Coin struct { Ticker string diff --git a/internal/nebula/input/coin_select_templ.go b/app/gateway/islands/coin_select_templ.go similarity index 91% rename from internal/nebula/input/coin_select_templ.go rename to app/gateway/islands/coin_select_templ.go index 855da64fb..cd524a80b 100644 --- a/internal/nebula/input/coin_select_templ.go +++ b/app/gateway/islands/coin_select_templ.go @@ -1,7 +1,7 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package input +package islands //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -99,7 +99,7 @@ func CoinOption(a Coin) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(a.Ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/coin_select.templ`, Line: 58, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/coin_select.templ`, Line: 58, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -112,7 +112,7 @@ func CoinOption(a Coin) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(a.Ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/coin_select.templ`, Line: 59, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/coin_select.templ`, Line: 59, Col: 41} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -125,7 +125,7 @@ func CoinOption(a Coin) templ.Component { 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/nebula/input/coin_select.templ`, Line: 60, Col: 11} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/coin_select.templ`, Line: 60, Col: 11} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -143,7 +143,7 @@ func CoinOption(a Coin) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(a.Ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/coin_select.templ`, Line: 64, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/coin_select.templ`, Line: 64, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -156,7 +156,7 @@ func CoinOption(a Coin) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(a.Ticker) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/coin_select.templ`, Line: 65, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/coin_select.templ`, Line: 65, Col: 41} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -169,7 +169,7 @@ func CoinOption(a Coin) templ.Component { 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/nebula/input/coin_select.templ`, Line: 66, Col: 11} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/coin_select.templ`, Line: 66, Col: 11} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { diff --git a/internal/nebula/input/input_ishuman.templ b/app/gateway/islands/human_slider.templ similarity index 98% rename from internal/nebula/input/input_ishuman.templ rename to app/gateway/islands/human_slider.templ index 2b0ef1437..ba5677c49 100644 --- a/internal/nebula/input/input_ishuman.templ +++ b/app/gateway/islands/human_slider.templ @@ -1,4 +1,4 @@ -package input +package islands import "fmt" diff --git a/internal/nebula/input/input_ishuman_templ.go b/app/gateway/islands/human_slider_templ.go similarity index 95% rename from internal/nebula/input/input_ishuman_templ.go rename to app/gateway/islands/human_slider_templ.go index b7f71d3b9..16d1a75ee 100644 --- a/internal/nebula/input/input_ishuman_templ.go +++ b/app/gateway/islands/human_slider_templ.go @@ -1,7 +1,7 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package input +package islands //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -38,7 +38,7 @@ func HumanSlider(firstNumber int, lastNumber int) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(humanLabel(firstNumber, lastNumber)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/input_ishuman.templ`, Line: 7, Col: 71} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/human_slider.templ`, Line: 7, Col: 71} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -80,7 +80,7 @@ func HumanSliderError(firstNumber int, lastNumber int) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(humanLabel(firstNumber, lastNumber)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/input_ishuman.templ`, Line: 12, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/human_slider.templ`, Line: 12, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { diff --git a/internal/nebula/input/input_handle.templ b/app/gateway/islands/input_handle.templ similarity index 85% rename from internal/nebula/input/input_handle.templ rename to app/gateway/islands/input_handle.templ index 805b7c403..12aa6459c 100644 --- a/internal/nebula/input/input_handle.templ +++ b/app/gateway/islands/input_handle.templ @@ -1,4 +1,4 @@ -package input +package islands type HandleState string @@ -12,9 +12,9 @@ func (s HandleState) string() string { return string(s) } -templ Handle() { +templ InputHandle() {
- +
@@ -23,7 +23,7 @@ templ Handle() {
} -templ HandleError(value string, helpText string) { +templ InputHandleError(value string, helpText string) {
@@ -35,7 +35,7 @@ templ HandleError(value string, helpText string) {
} -templ HandleSuccess(value string) { +templ InputHandleSuccess(value string) {
diff --git a/internal/nebula/input/input_handle_templ.go b/app/gateway/islands/input_handle_templ.go similarity index 89% rename from internal/nebula/input/input_handle_templ.go rename to app/gateway/islands/input_handle_templ.go index db2f5121b..dc8943cf4 100644 --- a/internal/nebula/input/input_handle_templ.go +++ b/app/gateway/islands/input_handle_templ.go @@ -1,7 +1,7 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package input +package islands //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -20,7 +20,7 @@ func (s HandleState) string() string { return string(s) } -func Handle() templ.Component { +func InputHandle() 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 { @@ -41,7 +41,7 @@ func Handle() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -49,7 +49,7 @@ func Handle() templ.Component { }) } -func HandleError(value string, helpText string) templ.Component { +func InputHandleError(value string, helpText 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 { @@ -77,7 +77,7 @@ func HandleError(value string, helpText string) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(value) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/input_handle.templ`, Line: 27, Col: 152} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/input_handle.templ`, Line: 27, Col: 152} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -90,7 +90,7 @@ func HandleError(value string, helpText string) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(helpText) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/input_handle.templ`, Line: 27, Col: 175} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/input_handle.templ`, Line: 27, Col: 175} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -104,7 +104,7 @@ func HandleError(value string, helpText string) templ.Component { }) } -func HandleSuccess(value string) templ.Component { +func InputHandleSuccess(value 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 { @@ -132,7 +132,7 @@ func HandleSuccess(value string) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(value) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/input/input_handle.templ`, Line: 39, Col: 154} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/islands/input_handle.templ`, Line: 39, Col: 154} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { diff --git a/internal/nebula/input/input_passkey.templ b/app/gateway/islands/input_passkey.templ similarity index 97% rename from internal/nebula/input/input_passkey.templ rename to app/gateway/islands/input_passkey.templ index e2236289e..094a13b0c 100644 --- a/internal/nebula/input/input_passkey.templ +++ b/app/gateway/islands/input_passkey.templ @@ -1,6 +1,6 @@ -package input +package islands -templ Passkey(addr string, userHandle string, challenge string) { +templ InputPasskey(addr string, userHandle string, challenge string) { Register Passkey diff --git a/internal/nebula/input/input_passkey_templ.go b/app/gateway/islands/input_passkey_templ.go similarity index 98% rename from internal/nebula/input/input_passkey_templ.go rename to app/gateway/islands/input_passkey_templ.go index 239116850..24a6734ae 100644 --- a/internal/nebula/input/input_passkey_templ.go +++ b/app/gateway/islands/input_passkey_templ.go @@ -1,14 +1,14 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package input +package islands //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 Passkey(addr string, userHandle string, challenge string) templ.Component { +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 { diff --git a/app/gateway/views/base_form.templ b/app/gateway/views/base_form.templ new file mode 100644 index 000000000..df0040b6d --- /dev/null +++ b/app/gateway/views/base_form.templ @@ -0,0 +1,58 @@ +package views + +templ Form(action, id string) { +
+ { children... } +
+} + +templ FormHeader() { +
+
+ { children... } +
+
+} + +templ FormBody() { + + { children... } + + +} + +templ FormFooter() { +
+ { children... } +
+} + +templ FormCancel() { + + + Cancel + +} + +templ FormSubmit(text string) { + + { text } + + +} diff --git a/app/gateway/views/base_form_templ.go b/app/gateway/views/base_form_templ.go new file mode 100644 index 000000000..b32b16dbd --- /dev/null +++ b/app/gateway/views/base_form_templ.go @@ -0,0 +1,265 @@ +// 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 Form(action, id 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 = 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 + }) +} + +func FormHeader() 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_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = 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 = templ_7745c5c3_Var5.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 FormBody() 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 = templ_7745c5c3_Var6.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 FormFooter() 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_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = 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 = templ_7745c5c3_Var7.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 FormCancel() 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) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" Cancel") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func FormSubmit(text 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_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 + } + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(text) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_form.templ`, Line: 55, Col: 8} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) + 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/nebula/layout/head.templ b/app/gateway/views/base_head.templ similarity index 99% rename from internal/nebula/layout/head.templ rename to app/gateway/views/base_head.templ index d2643c111..ab385ce2b 100644 --- a/internal/nebula/layout/head.templ +++ b/app/gateway/views/base_head.templ @@ -1,4 +1,4 @@ -package layout +package views import "fmt" diff --git a/internal/nebula/layout/head_templ.go b/app/gateway/views/base_head_templ.go similarity index 93% rename from internal/nebula/layout/head_templ.go rename to app/gateway/views/base_head_templ.go index d14958299..5609dd82b 100644 --- a/internal/nebula/layout/head_templ.go +++ b/app/gateway/views/base_head_templ.go @@ -1,7 +1,7 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package layout +package views //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -75,7 +75,7 @@ func Head(title string, nebulaVersion string) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 25, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 25, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -238,7 +238,7 @@ func Alpine() templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("alpinejs", "3.14.6", "dist/cdn.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 86, Col: 68} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 86, Col: 68} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -251,7 +251,7 @@ func Alpine() templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@alpinejs/focus", "3.14.6", "dist/cdn.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 87, Col: 75} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 87, Col: 75} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -312,7 +312,7 @@ func Dexie() templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie", "4.0.10", "dist/dexie.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 94, Col: 67} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 94, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -325,7 +325,7 @@ func Dexie() templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie-export-import", "4.1.4", "dist/dexie-export-import.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 95, Col: 94} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 95, Col: 94} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -386,7 +386,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx.org", "1.9.12", "dist/htmx.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 102, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 102, Col: 69} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -399,7 +399,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-include-vals", "2.0.0", "include-vals.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 103, Col: 84} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 103, Col: 84} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -412,7 +412,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-path-params", "2.0.0", "path-params.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 104, Col: 82} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 104, Col: 82} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -425,7 +425,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var20 string templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-alpine-morph", "2.0.0", "alpine-morph.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 105, Col: 84} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 105, Col: 84} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) if templ_7745c5c3_Err != nil { @@ -438,7 +438,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var21 string templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-sse", "2.2.2", "sse.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 106, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 106, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { @@ -451,7 +451,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var22 string templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-ws", "2.0.2", "ws.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 107, Col: 64} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 107, Col: 64} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { @@ -500,7 +500,7 @@ func Nebula(version string) templ.Component { var templ_7745c5c3_Var24 string templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/light.css")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 116, Col: 71} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 116, Col: 71} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) if templ_7745c5c3_Err != nil { @@ -513,7 +513,7 @@ func Nebula(version string) templ.Component { var templ_7745c5c3_Var25 string templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/dark.css")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 121, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 121, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) if templ_7745c5c3_Err != nil { @@ -542,7 +542,7 @@ func Nebula(version string) templ.Component { var templ_7745c5c3_Var27 string templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/shoelace-autoloader.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/head.templ`, Line: 125, Col: 98} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 125, Col: 98} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) if templ_7745c5c3_Err != nil { diff --git a/app/gateway/views/base_hero.templ b/app/gateway/views/base_hero.templ new file mode 100644 index 000000000..cf124e0cc --- /dev/null +++ b/app/gateway/views/base_hero.templ @@ -0,0 +1,36 @@ +package views + +templ HeroTitle(title string, subtitle string) { +
+

+ { title } +

+

+ { subtitle } +

+
+} + +templ HeroStart() { +
+ + + Create Vault + + +
+} + +templ HeroSocials() { +
+ + + + + + + + + +
+} diff --git a/internal/nebula/input/input_name_templ.go b/app/gateway/views/base_hero_templ.go similarity index 54% rename from internal/nebula/input/input_name_templ.go rename to app/gateway/views/base_hero_templ.go index cc2845d6d..a59208dba 100644 --- a/internal/nebula/input/input_name_templ.go +++ b/app/gateway/views/base_hero_templ.go @@ -1,26 +1,14 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package input +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" -type NameState string - -const ( - NameStateInitial NameState = "inital" - NameStateValid NameState = "valid" - NameStateInvalid NameState = "invalid" -) - -func (s NameState) string() string { - return string(s) -} - -func Name() templ.Component { +func HeroTitle(title string, subtitle 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 { @@ -41,7 +29,33 @@ func Name() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_hero.templ`, Line: 6, Col: 10} + } + _, 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(subtitle) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_hero.templ`, Line: 9, Col: 13} + } + _, 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("

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -49,7 +63,7 @@ func Name() templ.Component { }) } -func NameError() templ.Component { +func HeroStart() 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 { @@ -65,12 +79,12 @@ func NameError() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var2 := templ.GetChildren(ctx) - if templ_7745c5c3_Var2 == nil { - templ_7745c5c3_Var2 = templ.NopComponent + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Create Vault
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -78,7 +92,7 @@ func NameError() templ.Component { }) } -func NameValid() templ.Component { +func HeroSocials() 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 { @@ -94,12 +108,12 @@ func NameValid() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var3 := templ.GetChildren(ctx) - if templ_7745c5c3_Var3 == nil { - templ_7745c5c3_Var3 = templ.NopComponent + templ_7745c5c3_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/app/gateway/views/base_layout.templ b/app/gateway/views/base_layout.templ new file mode 100644 index 000000000..17cadae96 --- /dev/null +++ b/app/gateway/views/base_layout.templ @@ -0,0 +1,59 @@ +package views + +templ LayoutContainer() { +
+
+
+
+ { children... } +
+
+
+
+} + +// Columns is a component that renders a responsive flex container that stacks on mobile +templ LayoutColumns() { +
+ { children... } +
+} + +// Rows is a component that renders a responsive flex container that wraps on mobile +templ LayoutRows() { +
+ { children... } +
+} + +templ LayoutSeparator(text string) { +
+
+
+ { text } +
+
+} + +// Layout is a component that renders the general layout of the application +templ LayoutView(title string) { + + + @Head(title, "0.0.11") + +
+ { children... } +
+ + +} + +func Clsx(attrs ...templ.Attributes) templ.Attributes { + merged := templ.Attributes{} + for _, attr := range attrs { + for k, v := range attr { + merged[k] = v + } + } + return merged +} diff --git a/app/gateway/views/base_layout_templ.go b/app/gateway/views/base_layout_templ.go new file mode 100644 index 000000000..55c20af1f --- /dev/null +++ b/app/gateway/views/base_layout_templ.go @@ -0,0 +1,222 @@ +// 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 LayoutContainer() 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 = 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 + }) +} + +// Columns is a component that renders a responsive flex container that stacks on mobile +func LayoutColumns() 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) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ_7745c5c3_Var2.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 + }) +} + +// Rows is a component that renders a responsive flex container that wraps on mobile +func LayoutRows() 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("
") + 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 + }) +} + +func LayoutSeparator(text 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_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(text) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_layout.templ`, Line: 33, Col: 45} + } + _, 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 + }) +} + +// Layout is a component that renders the general layout of the application +func LayoutView(title 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_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 = Head(title, "0.0.11").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 = templ_7745c5c3_Var6.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 Clsx(attrs ...templ.Attributes) templ.Attributes { + merged := templ.Attributes{} + for _, attr := range attrs { + for k, v := range attr { + merged[k] = v + } + } + return merged +} + +var _ = templruntime.GeneratedTemplate diff --git a/app/gateway/views/view_errors.templ b/app/gateway/views/view_errors.templ new file mode 100644 index 000000000..269b7ec0f --- /dev/null +++ b/app/gateway/views/view_errors.templ @@ -0,0 +1,14 @@ +package views + +templ ErrorView(err string) { + @LayoutView("Error | Sonr.ID") { + @LayoutContainer() { + @HeroTitle("Uh oh!", "Something went wrong.") +
+

+ { err } +

+
+ } + } +} diff --git a/pkg/gateway/views/error_templ.go b/app/gateway/views/view_errors_templ.go similarity index 85% rename from pkg/gateway/views/error_templ.go rename to app/gateway/views/view_errors_templ.go index 5ccc817d4..daa4eeb53 100644 --- a/pkg/gateway/views/error_templ.go +++ b/app/gateway/views/view_errors_templ.go @@ -8,11 +8,6 @@ package views import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) - func ErrorView(err 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 @@ -58,7 +53,7 @@ func ErrorView(err string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = hero.TitleDesc("Uh oh!", "Something went wrong.").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroTitle("Uh oh!", "Something went wrong.").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -69,7 +64,7 @@ func ErrorView(err string) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(err) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/gateway/views/error.templ`, Line: 14, Col: 10} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/view_errors.templ`, Line: 9, Col: 10} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -81,13 +76,13 @@ func ErrorView(err string) templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.Container().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.View("Error | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutView("Error | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/app/gateway/views/view_home.templ b/app/gateway/views/view_home.templ new file mode 100644 index 000000000..df2ec47b1 --- /dev/null +++ b/app/gateway/views/view_home.templ @@ -0,0 +1,26 @@ +package views + +templ InitialView() { + @LayoutView("Sonr.ID") { + @LayoutContainer() { + @HeroTitle("Sonr.ID", "The decentralized identity layer for the web.") + @HeroStart() + @HeroSocials() + } + } +} + +templ ReturningView() { + @LayoutView("Login | Sonr.ID") { + @LayoutContainer() { + @HeroTitle("Welcome Back!", "Continue with your existing Sonr.ID.") +
+ + + Log back in + + +
+ } + } +} diff --git a/pkg/gateway/views/initial_templ.go b/app/gateway/views/view_home_templ.go similarity index 85% rename from pkg/gateway/views/initial_templ.go rename to app/gateway/views/view_home_templ.go index 693178bf4..94a5c2e3f 100644 --- a/pkg/gateway/views/initial_templ.go +++ b/app/gateway/views/view_home_templ.go @@ -8,11 +8,6 @@ package views import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) - func InitialView() 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 @@ -58,7 +53,7 @@ func InitialView() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = hero.TitleDesc("Sonr.ID", "The decentralized identity layer for the web.").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroTitle("Sonr.ID", "The decentralized identity layer for the web.").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -66,7 +61,7 @@ func InitialView() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = hero.StartButton().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroStart().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -74,19 +69,19 @@ func InitialView() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = hero.SocialButtonsRow().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroSocials().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.Container().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.View("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutView("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -139,7 +134,7 @@ func ReturningView() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = hero.TitleDesc("Welcome Back!", "Continue with your existing Sonr.ID.").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroTitle("Welcome Back!", "Continue with your existing Sonr.ID.").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -149,13 +144,13 @@ func ReturningView() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.Container().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.View("Login | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutView("Login | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/app/gateway/views/view_loading.templ b/app/gateway/views/view_loading.templ new file mode 100644 index 000000000..9418b23bb --- /dev/null +++ b/app/gateway/views/view_loading.templ @@ -0,0 +1,9 @@ +package views + +templ LoadingView() { + @LayoutView("Loading... | Sonr.ID") { + @LayoutContainer() { + @HeroTitle("Loading Vault", "This will be used to login to your vault.") + } + } +} diff --git a/pkg/gateway/views/loading_templ.go b/app/gateway/views/view_loading_templ.go similarity index 84% rename from pkg/gateway/views/loading_templ.go rename to app/gateway/views/view_loading_templ.go index 60a68b096..f1d88c510 100644 --- a/pkg/gateway/views/loading_templ.go +++ b/app/gateway/views/view_loading_templ.go @@ -8,11 +8,6 @@ package views import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) - func LoadingView() 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 @@ -58,19 +53,19 @@ func LoadingView() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = hero.TitleDesc("Loading Vault", "This will be used to login to your vault.").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroTitle("Loading Vault", "This will be used to login to your vault.").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.Container().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.View("Loading... | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutView("Loading... | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/app/gateway/views/view_register.templ b/app/gateway/views/view_register.templ new file mode 100644 index 000000000..890fb294e --- /dev/null +++ b/app/gateway/views/view_register.templ @@ -0,0 +1,47 @@ +package views + +import "github.com/onsonr/sonr/app/gateway/islands" + +templ RegisterProfileView(firstNumber int, lastNumber int) { + @LayoutView("New Profile | Sonr.ID") { + @LayoutContainer() { + @HeroTitle("Basic Info", "Tell us a little about yourself.") + @Form("/register/passkey", "create-profile") { + @FormBody() { + @FormHeader() { +
+ +
+ } + @islands.InputHandle() + @islands.HumanSlider(firstNumber, lastNumber) + @FormFooter() { + @FormCancel() + @FormSubmit("Next") + } + } + } + } + } +} + +templ RegisterPasskeyView(address string, handle string, name string, challenge string, creationBlock string) { + @LayoutView("Register | Sonr.ID") { + @LayoutContainer() { + @HeroTitle("Link a PassKey", "This will be used to login to your vault.") + @Form("/register/finish", "passkey-form") { + + @FormBody() { + @FormHeader() { + @islands.CardAccount(address, name, handle, creationBlock) + } + @islands.CoinSelect() + @FormFooter() { + @islands.InputPasskey(address, handle, challenge) + @FormCancel() + } + } + } + } + } +} diff --git a/pkg/gateway/views/register_templ.go b/app/gateway/views/view_register_templ.go similarity index 81% rename from pkg/gateway/views/register_templ.go rename to app/gateway/views/view_register_templ.go index b2c771138..1f77f86f1 100644 --- a/pkg/gateway/views/register_templ.go +++ b/app/gateway/views/view_register_templ.go @@ -8,13 +8,7 @@ package views import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import ( - "github.com/onsonr/sonr/internal/nebula/card" - "github.com/onsonr/sonr/internal/nebula/form" - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/input" - "github.com/onsonr/sonr/internal/nebula/layout" -) +import "github.com/onsonr/sonr/app/gateway/islands" func RegisterProfileView(firstNumber int, lastNumber int) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { @@ -61,7 +55,7 @@ func RegisterProfileView(firstNumber int, lastNumber int) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = hero.TitleDesc("Basic Info", "Tell us a little about yourself.").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroTitle("Basic Info", "Tell us a little about yourself.").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -105,13 +99,13 @@ func RegisterProfileView(firstNumber int, lastNumber int) templ.Component { }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Header().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormHeader().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -119,7 +113,7 @@ func RegisterProfileView(firstNumber int, lastNumber int) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = input.Handle().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = islands.InputHandle().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -127,15 +121,7 @@ func RegisterProfileView(firstNumber int, lastNumber int) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = input.Name().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 = input.HumanSlider(firstNumber, lastNumber).Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = islands.HumanSlider(firstNumber, lastNumber).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -155,7 +141,7 @@ func RegisterProfileView(firstNumber int, lastNumber int) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = form.CancelButton().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormCancel().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -163,37 +149,37 @@ func RegisterProfileView(firstNumber int, lastNumber int) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = form.SubmitButton("Next").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormSubmit("Next").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Footer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormFooter().Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Body().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormBody().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Root("/register/passkey", "create-profile").Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = Form("/register/passkey", "create-profile").Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.Container().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.View("New Profile | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutView("New Profile | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -246,7 +232,7 @@ func RegisterPasskeyView(address string, handle string, name string, challenge s }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = hero.TitleDesc("Link a PassKey", "This will be used to login to your vault.").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroTitle("Link a PassKey", "This will be used to login to your vault.").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -294,13 +280,13 @@ func RegisterPasskeyView(address string, handle string, name string, challenge s }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = card.SonrProfile(address, name, handle, creationBlock).Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = islands.CardAccount(address, name, handle, creationBlock).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Header().Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormHeader().Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -308,7 +294,7 @@ func RegisterPasskeyView(address string, handle string, name string, challenge s if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = input.CoinSelect().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = islands.CoinSelect().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -328,7 +314,7 @@ func RegisterPasskeyView(address string, handle string, name string, challenge s }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = input.Passkey(address, handle, challenge).Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = islands.InputPasskey(address, handle, challenge).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -336,37 +322,37 @@ func RegisterPasskeyView(address string, handle string, name string, challenge s if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = form.CancelButton().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormCancel().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Footer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormFooter().Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Body().Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FormBody().Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = form.Root("/register/finish", "passkey-form").Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = Form("/register/finish", "passkey-form").Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.Container().Render(templ.WithChildren(ctx, templ_7745c5c3_Var10), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var10), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.View("Register | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutView("Register | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/cmd/motr/wasm/wasm.go b/app/vault/context/wasm.go similarity index 90% rename from cmd/motr/wasm/wasm.go rename to app/vault/context/wasm.go index 6ef8f91a1..4d0d9bfc7 100644 --- a/cmd/motr/wasm/wasm.go +++ b/app/vault/context/wasm.go @@ -1,7 +1,7 @@ //go:build js && wasm // +build js,wasm -package wasm +package context import ( "encoding/base64" @@ -10,7 +10,7 @@ import ( "github.com/labstack/echo/v4" ) -func ContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc { +func WASMMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { // Extract WASM context from headers if wasmCtx := c.Request().Header.Get("X-Wasm-Context"); wasmCtx != "" { diff --git a/pkg/vault/handlers/authz.go b/app/vault/handlers/authorize.go similarity index 100% rename from pkg/vault/handlers/authz.go rename to app/vault/handlers/authorize.go diff --git a/pkg/vault/handlers/redirect.go b/app/vault/handlers/errors.go similarity index 100% rename from pkg/vault/handlers/redirect.go rename to app/vault/handlers/errors.go diff --git a/pkg/vault/handlers/current.go b/app/vault/handlers/index.go similarity index 100% rename from pkg/vault/handlers/current.go rename to app/vault/handlers/index.go diff --git a/pkg/vault/handlers/search.go b/app/vault/handlers/login.go similarity index 100% rename from pkg/vault/handlers/search.go rename to app/vault/handlers/login.go diff --git a/app/vault/handlers/profile.go b/app/vault/handlers/profile.go new file mode 100644 index 000000000..5ac8282f4 --- /dev/null +++ b/app/vault/handlers/profile.go @@ -0,0 +1 @@ +package handlers diff --git a/app/vault/handlers/search.go b/app/vault/handlers/search.go new file mode 100644 index 000000000..5ac8282f4 --- /dev/null +++ b/app/vault/handlers/search.go @@ -0,0 +1 @@ +package handlers diff --git a/pkg/vault/handlers/controller.go b/app/vault/handlers/wallet.go similarity index 100% rename from pkg/vault/handlers/controller.go rename to app/vault/handlers/wallet.go diff --git a/app/vault/vault.go b/app/vault/vault.go new file mode 100644 index 000000000..17146c1fb --- /dev/null +++ b/app/vault/vault.go @@ -0,0 +1,41 @@ +//go:build js && wasm + +package vault + +import ( + "github.com/labstack/echo/v4" + echomiddleware "github.com/labstack/echo/v4/middleware" + "github.com/onsonr/sonr/app/vault/context" + "github.com/onsonr/sonr/internal/config/motr" + "github.com/onsonr/sonr/internal/database/motrorm" +) + +type Vault = *echo.Echo + +// New returns a new Vault instance +func New(config *motr.Config, dbq *motrorm.Queries) (Vault, error) { + e := echo.New() + // Override default behaviors + e.IPExtractor = echo.ExtractIPDirect() + e.HTTPErrorHandler = handleError() + + // Built-in middleware + e.Use(echomiddleware.Logger()) + e.Use(echomiddleware.Recover()) + e.Use(context.WASMMiddleware) + registerRoutes(e) + return e, nil +} + +func handleError() echo.HTTPErrorHandler { + return func(err error, c echo.Context) { + if he, ok := err.(*echo.HTTPError); ok { + // Log the error if needed + c.Logger().Errorf("Error: %v", he.Message) + } + } +} + +// RegisterRoutes registers the Decentralized Web Node API routes. +func registerRoutes(e *echo.Echo) { +} diff --git a/internal/nebula/form/base.templ b/app/vault/views/base_form.templ similarity index 84% rename from internal/nebula/form/base.templ rename to app/vault/views/base_form.templ index 8601ea94f..70bf47bfe 100644 --- a/internal/nebula/form/base.templ +++ b/app/vault/views/base_form.templ @@ -1,12 +1,12 @@ -package form +package views -templ Root(action, id string) { +templ Form(action, id string) {
{ children... }
} -templ Header() { +templ FormHeader() {
{ children... } @@ -14,7 +14,7 @@ templ Header() {
} -templ Body() { +templ FormBody() { { children... } + { children... } + +} + +// ╭──────────────────────────────────────────────────────────╮ +// │ 3rd Party Libraries │ +// ╰──────────────────────────────────────────────────────────╯ + +// Tailwind css dependencies +templ Tailwind() { + @tailwindHandle.Once() { + + + } +} + +// Turnstile is used for cloudflare challenges +templ Turnstile() { + @turnstileHandle.Once() { + + } +} + +// Alpine is a component that renders the Alpine.js library +templ Alpine() { + @alpineHandle.Once() { + + + } +} + +// Dexie is a component that renders the Dexie.js library +templ Dexie() { + @dexieHandle.Once() { + + + } +} + +// Htmx is a component that renders the Htmx.js library +templ Htmx() { + @htmxHandle.Once() { + + + + + + + } +} + +// Nebula is a component that renders the Nebula.js library +templ Nebula(version string) { + + + @nebulaHandle.Once() { + + } +} + +// ╭───────────────────────────────────────────────────────────╮ +// │ Helper Functions │ +// ╰───────────────────────────────────────────────────────────╯ + +func jsDelivrURL(pkg string, version string, path string) string { + return fmt.Sprintf("https://cdn.jsdelivr.net/npm/%s@%s/%s", pkg, version, path) +} diff --git a/app/vault/views/base_head_templ.go b/app/vault/views/base_head_templ.go new file mode 100644 index 000000000..76c518bb9 --- /dev/null +++ b/app/vault/views/base_head_templ.go @@ -0,0 +1,573 @@ +// 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 "fmt" + +var ( + nebulaHandle = templ.NewOnceHandle() + tailwindHandle = templ.NewOnceHandle() + alpineHandle = templ.NewOnceHandle() + dexieHandle = templ.NewOnceHandle() + htmxHandle = templ.NewOnceHandle() + turnstileHandle = templ.NewOnceHandle() +) + +func Head(title string, nebulaVersion 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 = Turnstile().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = Tailwind().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = Alpine().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = Htmx().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = Dexie().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = Nebula(nebulaVersion).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 + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/vault/views/base_head.templ`, Line: 25, Col: 16} + } + _, 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 + } + 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 + }) +} + +// ╭──────────────────────────────────────────────────────────╮ +// │ 3rd Party Libraries │ +// ╰──────────────────────────────────────────────────────────╯ + +// Tailwind css dependencies +func Tailwind() 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(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = tailwindHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +// Turnstile is used for cloudflare challenges +func Turnstile() 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_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var6 := 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 = turnstileHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +// Alpine is a component that renders the Alpine.js library +func Alpine() 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_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var8 := 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 = alpineHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +// Dexie is a component that renders the Dexie.js library +func Dexie() 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_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var12 := 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 = dexieHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +// Htmx is a component that renders the Htmx.js library +func Htmx() 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_Var15 := templ.GetChildren(ctx) + if templ_7745c5c3_Var15 == nil { + templ_7745c5c3_Var15 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var16 := 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 = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +// Nebula is a component that renders the Nebula.js library +func Nebula(version 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_Var23 := templ.GetChildren(ctx) + if templ_7745c5c3_Var23 == nil { + templ_7745c5c3_Var23 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Var26 := 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 = nebulaHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var26), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +// ╭───────────────────────────────────────────────────────────╮ +// │ Helper Functions │ +// ╰───────────────────────────────────────────────────────────╯ + +func jsDelivrURL(pkg string, version string, path string) string { + return fmt.Sprintf("https://cdn.jsdelivr.net/npm/%s@%s/%s", pkg, version, path) +} + +var _ = templruntime.GeneratedTemplate diff --git a/app/vault/views/base_hero.templ b/app/vault/views/base_hero.templ new file mode 100644 index 000000000..cf124e0cc --- /dev/null +++ b/app/vault/views/base_hero.templ @@ -0,0 +1,36 @@ +package views + +templ HeroTitle(title string, subtitle string) { +
+

+ { title } +

+

+ { subtitle } +

+
+} + +templ HeroStart() { +
+ + + Create Vault + + +
+} + +templ HeroSocials() { +
+ + + + + + + + + +
+} diff --git a/internal/nebula/layout/grid_templ.go b/app/vault/views/base_hero_templ.go similarity index 61% rename from internal/nebula/layout/grid_templ.go rename to app/vault/views/base_hero_templ.go index 4db78d318..f686aa465 100644 --- a/internal/nebula/layout/grid_templ.go +++ b/app/vault/views/base_hero_templ.go @@ -1,15 +1,14 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.2.793 -package layout +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" -// Columns is a component that renders a responsive flex container that stacks on mobile -func Columns() templ.Component { +func HeroTitle(title string, subtitle 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 { @@ -30,15 +29,33 @@ func Columns() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, 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 = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/vault/views/base_hero.templ`, Line: 6, Col: 10} + } + _, 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("

") + _, 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(subtitle) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/vault/views/base_hero.templ`, Line: 9, Col: 13} + } + _, 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("

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -46,8 +63,7 @@ func Columns() templ.Component { }) } -// Rows is a component that renders a responsive flex container that wraps on mobile -func Rows() templ.Component { +func HeroStart() 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 { @@ -63,20 +79,12 @@ func Rows() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var2 := templ.GetChildren(ctx) - if templ_7745c5c3_Var2 == nil { - templ_7745c5c3_Var2 = templ.NopComponent + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = 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 = templ_7745c5c3_Var2.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("
Create Vault
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -84,7 +92,7 @@ func Rows() templ.Component { }) } -func Separator(text string) templ.Component { +func HeroSocials() 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 { @@ -100,25 +108,12 @@ func Separator(text string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var3 := templ.GetChildren(ctx) - if templ_7745c5c3_Var3 == nil { - templ_7745c5c3_Var3 = templ.NopComponent + templ_7745c5c3_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(text) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/layout/grid.templ`, Line: 21, Col: 45} - } - _, 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("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/app/vault/views/base_layout.templ b/app/vault/views/base_layout.templ new file mode 100644 index 000000000..17cadae96 --- /dev/null +++ b/app/vault/views/base_layout.templ @@ -0,0 +1,59 @@ +package views + +templ LayoutContainer() { +
+
+
+
+ { children... } +
+
+
+
+} + +// Columns is a component that renders a responsive flex container that stacks on mobile +templ LayoutColumns() { +
+ { children... } +
+} + +// Rows is a component that renders a responsive flex container that wraps on mobile +templ LayoutRows() { +
+ { children... } +
+} + +templ LayoutSeparator(text string) { +
+
+
+ { text } +
+
+} + +// Layout is a component that renders the general layout of the application +templ LayoutView(title string) { + + + @Head(title, "0.0.11") + +
+ { children... } +
+ + +} + +func Clsx(attrs ...templ.Attributes) templ.Attributes { + merged := templ.Attributes{} + for _, attr := range attrs { + for k, v := range attr { + merged[k] = v + } + } + return merged +} diff --git a/app/vault/views/base_layout_templ.go b/app/vault/views/base_layout_templ.go new file mode 100644 index 000000000..39e8cef34 --- /dev/null +++ b/app/vault/views/base_layout_templ.go @@ -0,0 +1,222 @@ +// 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 LayoutContainer() 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 = 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 + }) +} + +// Columns is a component that renders a responsive flex container that stacks on mobile +func LayoutColumns() 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) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ_7745c5c3_Var2.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 + }) +} + +// Rows is a component that renders a responsive flex container that wraps on mobile +func LayoutRows() 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("
") + 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 + }) +} + +func LayoutSeparator(text 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_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(text) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/vault/views/base_layout.templ`, Line: 33, Col: 45} + } + _, 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 + }) +} + +// Layout is a component that renders the general layout of the application +func LayoutView(title 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_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 = Head(title, "0.0.11").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 = templ_7745c5c3_Var6.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 Clsx(attrs ...templ.Attributes) templ.Attributes { + merged := templ.Attributes{} + for _, attr := range attrs { + for k, v := range attr { + merged[k] = v + } + } + return merged +} + +var _ = templruntime.GeneratedTemplate diff --git a/app/vault/views/initial.templ b/app/vault/views/initial.templ new file mode 100644 index 000000000..2f457692b --- /dev/null +++ b/app/vault/views/initial.templ @@ -0,0 +1,14 @@ +package views + +import ( +) + +templ InitialView() { + @LayoutView("Sonr.ID") { + @LayoutContainer() { + @HeroTitle("Sonr.ID", "The decentralized identity layer for the web.") + @HeroStart() + @HeroSocials() + } + } +} diff --git a/pkg/vault/views/initial_templ.go b/app/vault/views/initial_templ.go similarity index 82% rename from pkg/vault/views/initial_templ.go rename to app/vault/views/initial_templ.go index 654167ee4..e29570ccc 100644 --- a/pkg/vault/views/initial_templ.go +++ b/app/vault/views/initial_templ.go @@ -8,10 +8,7 @@ package views import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) +import () func InitialView() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { @@ -58,7 +55,7 @@ func InitialView() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = hero.TitleDesc("Sonr.ID", "The decentralized identity layer for the web.").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroTitle("Sonr.ID", "The decentralized identity layer for the web.").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -66,7 +63,7 @@ func InitialView() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = hero.StartButton().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroStart().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -74,19 +71,19 @@ func InitialView() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = hero.SocialButtonsRow().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = HeroSocials().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.Container().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.View("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LayoutView("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/cmd/hway/cmds.go b/cmd/hway/cmds.go index 082433064..9890dc388 100644 --- a/cmd/hway/cmds.go +++ b/cmd/hway/cmds.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/onsonr/sonr/pkg/common" - "github.com/onsonr/sonr/pkg/gateway" + "github.com/onsonr/sonr/app/gateway" "github.com/spf13/cobra" ) diff --git a/cmd/hway/main.go b/cmd/hway/main.go index 0e540971b..5040bbdf7 100644 --- a/cmd/hway/main.go +++ b/cmd/hway/main.go @@ -8,7 +8,7 @@ import ( "github.com/jackc/pgx/v5" config "github.com/onsonr/sonr/internal/config/hway" - hwayorm "github.com/onsonr/sonr/pkg/gateway/orm" + hwayorm "github.com/onsonr/sonr/internal/database/hwayorm" ) // main is the entry point for the application diff --git a/cmd/motr/main.go b/cmd/motr/main.go index 2b88503ec..3318a0115 100644 --- a/cmd/motr/main.go +++ b/cmd/motr/main.go @@ -4,62 +4,68 @@ package main import ( + "bytes" "context" "database/sql" "encoding/json" + "fmt" + "io" + "log" + "net/http" + "net/http/httptest" + "strings" + "sync" "syscall/js" - "github.com/labstack/echo/v4" _ "github.com/ncruces/go-sqlite3/driver" _ "github.com/ncruces/go-sqlite3/embed" - "github.com/onsonr/sonr/cmd/motr/wasm" - sink "github.com/onsonr/sonr/deploy/sink" + vault "github.com/onsonr/sonr/app/vault" "github.com/onsonr/sonr/internal/config/motr" - vault "github.com/onsonr/sonr/pkg/vault/routes" + "github.com/onsonr/sonr/internal/database/motrorm" + sink "github.com/onsonr/sonr/internal/database/sink" ) var ( - env *motr.Environment - config *motr.Config - err error + // Global buffer pool to reduce allocations + bufferPool = sync.Pool{ + New: func() interface{} { + return new(bytes.Buffer) + }, + } + + // Cached JS globals + jsGlobal = js.Global() + jsUint8Array = jsGlobal.Get("Uint8Array") + jsResponse = jsGlobal.Get("Response") + jsPromise = jsGlobal.Get("Promise") + jsWasmHTTP = jsGlobal.Get("wasmhttp") ) -func broadcastTx(this js.Value, args []js.Value) interface{} { - return nil -} - -func simulateTx(this js.Value, args []js.Value) interface{} { - return nil -} - -func syncData(this js.Value, args []js.Value) interface{} { - if len(args) < 1 { - return nil - } - - configString := args[0].String() - if err := json.Unmarshal([]byte(configString), &config); err != nil { - println("Error parsing config:", err.Error()) - return nil - } - return nil -} - func main() { - // Load dwn config - js.Global().Set("broadcastTx", js.FuncOf(broadcastTx)) - js.Global().Set("simulateTx", js.FuncOf(simulateTx)) - js.Global().Set("syncData", js.FuncOf(syncData)) + configString := "TODO" + config, _ := loadConfig(configString) + dbq, err := createDB() + if err != nil { + log.Fatal(err) + return + } + e, err := vault.New(config, dbq) + if err != nil { + log.Fatal(err) + return + } + serveFetch(e) +} - e := echo.New() - e.Use(wasm.ContextMiddleware) - // e.Use(controller.Middleware(nil)) - vault.RegisterRoutes(e, config) - wasm.ServeFetch(e) +// loadConfig loads the config from the given JSON string +func loadConfig(configString string) (*motr.Config, error) { + var config motr.Config + err := json.Unmarshal([]byte(configString), &config) + return &config, err } // createDB initializes and returns a configured database connection -func createDB() (*sql.DB, error) { +func createDB() (*motrorm.Queries, error) { db, err := sql.Open("sqlite3", ":memory:") if err != nil { return nil, err @@ -69,5 +75,185 @@ func createDB() (*sql.DB, error) { if _, err := db.ExecContext(context.Background(), sink.SchemaVaultSQL); err != nil { return nil, err } - return db, nil + return motrorm.New(db), nil +} + +// serveFetch serves HTTP requests with optimized handler management +func serveFetch(handler http.Handler) func() { + h := handler + if h == nil { + h = http.DefaultServeMux + } + + // Optimize prefix handling + prefix := strings.TrimRight(jsWasmHTTP.Get("path").String(), "/") + if prefix != "" { + mux := http.NewServeMux() + mux.Handle(prefix+"/", http.StripPrefix(prefix, h)) + h = mux + } + + // Create request handler function + cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + promise, resolve, reject := newPromiseOptimized() + + go handleRequest(h, args[1], resolve, reject) + + return promise + }) + + jsWasmHTTP.Call("setHandler", cb) + return cb.Release +} + +// handleRequest processes the request with panic recovery +func handleRequest(h http.Handler, jsReq js.Value, resolve, reject func(interface{})) { + defer func() { + if r := recover(); r != nil { + var errMsg string + if err, ok := r.(error); ok { + errMsg = fmt.Sprintf("wasmhttp: panic: %+v", err) + } else { + errMsg = fmt.Sprintf("wasmhttp: panic: %v", r) + } + reject(errMsg) + } + }() + + recorder := newResponseRecorder() + h.ServeHTTP(recorder, buildRequest(jsReq)) + resolve(recorder.jsResponse()) +} + +// buildRequest creates an http.Request from JS Request +func buildRequest(jsReq js.Value) *http.Request { + // Get request body + arrayBuffer, err := awaitPromiseOptimized(jsReq.Call("arrayBuffer")) + if err != nil { + panic(err) + } + + // Create body buffer + jsBody := jsUint8Array.New(arrayBuffer) + bodyLen := jsBody.Get("length").Int() + body := make([]byte, bodyLen) + js.CopyBytesToGo(body, jsBody) + + // Create request + req := httptest.NewRequest( + jsReq.Get("method").String(), + jsReq.Get("url").String(), + bytes.NewReader(body), + ) + + // Set headers efficiently + headers := jsReq.Get("headers") + headersIt := headers.Call("entries") + for { + entry := headersIt.Call("next") + if entry.Get("done").Bool() { + break + } + pair := entry.Get("value") + req.Header.Set(pair.Index(0).String(), pair.Index(1).String()) + } + + return req +} + +// ResponseRecorder with optimized buffer handling +type ResponseRecorder struct { + *httptest.ResponseRecorder + buffer *bytes.Buffer +} + +func newResponseRecorder() *ResponseRecorder { + return &ResponseRecorder{ + ResponseRecorder: httptest.NewRecorder(), + buffer: bufferPool.Get().(*bytes.Buffer), + } +} + +// jsResponse creates a JS Response with optimized memory usage +func (rr *ResponseRecorder) jsResponse() js.Value { + defer func() { + rr.buffer.Reset() + bufferPool.Put(rr.buffer) + }() + + res := rr.Result() + defer res.Body.Close() + + // Prepare response body + body := js.Undefined() + if res.ContentLength != 0 { + if _, err := io.Copy(rr.buffer, res.Body); err != nil { + panic(err) + } + bodyBytes := rr.buffer.Bytes() + body = jsUint8Array.New(len(bodyBytes)) + js.CopyBytesToJS(body, bodyBytes) + } + + // Prepare response init object + init := make(map[string]interface{}, 3) + if res.StatusCode != 0 { + init["status"] = res.StatusCode + } + + if len(res.Header) > 0 { + headers := make(map[string]interface{}, len(res.Header)) + for k, v := range res.Header { + if len(v) > 0 { + headers[k] = v[0] + } + } + init["headers"] = headers + } + + return jsResponse.New(body, init) +} + +// newPromiseOptimized creates a new JavaScript Promise with optimized callback handling +func newPromiseOptimized() (js.Value, func(interface{}), func(interface{})) { + var ( + resolve func(interface{}) + reject func(interface{}) + promiseFunc = js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve = func(v interface{}) { args[0].Invoke(v) } + reject = func(v interface{}) { args[1].Invoke(v) } + return js.Undefined() + }) + ) + defer promiseFunc.Release() + + return jsPromise.New(promiseFunc), resolve, reject +} + +// awaitPromiseOptimized waits for Promise resolution with optimized channel handling +func awaitPromiseOptimized(promise js.Value) (js.Value, error) { + done := make(chan struct{}) + var ( + result js.Value + err error + ) + + thenFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + result = args[0] + close(done) + return nil + }) + defer thenFunc.Release() + + catchFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + err = js.Error{Value: args[0]} + close(done) + return nil + }) + defer catchFunc.Release() + + promise.Call("then", thenFunc).Call("catch", catchFunc) + <-done + + return result, err } diff --git a/cmd/motr/wasm/fetch.go b/cmd/motr/wasm/fetch.go deleted file mode 100644 index ff6af6833..000000000 --- a/cmd/motr/wasm/fetch.go +++ /dev/null @@ -1,211 +0,0 @@ -//go:build js && wasm -// +build js,wasm - -package wasm - -import ( - "bytes" - "fmt" - "io" - "net/http" - "net/http/httptest" - "strings" - "sync" - "syscall/js" -) - -var ( - // Global buffer pool to reduce allocations - bufferPool = sync.Pool{ - New: func() interface{} { - return new(bytes.Buffer) - }, - } - - // Cached JS globals - jsGlobal = js.Global() - jsUint8Array = jsGlobal.Get("Uint8Array") - jsResponse = jsGlobal.Get("Response") - jsPromise = jsGlobal.Get("Promise") - jsWasmHTTP = jsGlobal.Get("wasmhttp") -) - -// ServeFetch serves HTTP requests with optimized handler management -func ServeFetch(handler http.Handler) func() { - h := handler - if h == nil { - h = http.DefaultServeMux - } - - // Optimize prefix handling - prefix := strings.TrimRight(jsWasmHTTP.Get("path").String(), "/") - if prefix != "" { - mux := http.NewServeMux() - mux.Handle(prefix+"/", http.StripPrefix(prefix, h)) - h = mux - } - - // Create request handler function - cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - promise, resolve, reject := newPromiseOptimized() - - go handleRequest(h, args[1], resolve, reject) - - return promise - }) - - jsWasmHTTP.Call("setHandler", cb) - return cb.Release -} - -// handleRequest processes the request with panic recovery -func handleRequest(h http.Handler, jsReq js.Value, resolve, reject func(interface{})) { - defer func() { - if r := recover(); r != nil { - var errMsg string - if err, ok := r.(error); ok { - errMsg = fmt.Sprintf("wasmhttp: panic: %+v", err) - } else { - errMsg = fmt.Sprintf("wasmhttp: panic: %v", r) - } - reject(errMsg) - } - }() - - recorder := newResponseRecorder() - h.ServeHTTP(recorder, buildRequest(jsReq)) - resolve(recorder.jsResponse()) -} - -// buildRequest creates an http.Request from JS Request -func buildRequest(jsReq js.Value) *http.Request { - // Get request body - arrayBuffer, err := awaitPromiseOptimized(jsReq.Call("arrayBuffer")) - if err != nil { - panic(err) - } - - // Create body buffer - jsBody := jsUint8Array.New(arrayBuffer) - bodyLen := jsBody.Get("length").Int() - body := make([]byte, bodyLen) - js.CopyBytesToGo(body, jsBody) - - // Create request - req := httptest.NewRequest( - jsReq.Get("method").String(), - jsReq.Get("url").String(), - bytes.NewReader(body), - ) - - // Set headers efficiently - headers := jsReq.Get("headers") - headersIt := headers.Call("entries") - for { - entry := headersIt.Call("next") - if entry.Get("done").Bool() { - break - } - pair := entry.Get("value") - req.Header.Set(pair.Index(0).String(), pair.Index(1).String()) - } - - return req -} - -// ResponseRecorder with optimized buffer handling -type ResponseRecorder struct { - *httptest.ResponseRecorder - buffer *bytes.Buffer -} - -func newResponseRecorder() *ResponseRecorder { - return &ResponseRecorder{ - ResponseRecorder: httptest.NewRecorder(), - buffer: bufferPool.Get().(*bytes.Buffer), - } -} - -// jsResponse creates a JS Response with optimized memory usage -func (rr *ResponseRecorder) jsResponse() js.Value { - defer func() { - rr.buffer.Reset() - bufferPool.Put(rr.buffer) - }() - - res := rr.Result() - defer res.Body.Close() - - // Prepare response body - body := js.Undefined() - if res.ContentLength != 0 { - if _, err := io.Copy(rr.buffer, res.Body); err != nil { - panic(err) - } - bodyBytes := rr.buffer.Bytes() - body = jsUint8Array.New(len(bodyBytes)) - js.CopyBytesToJS(body, bodyBytes) - } - - // Prepare response init object - init := make(map[string]interface{}, 3) - if res.StatusCode != 0 { - init["status"] = res.StatusCode - } - - if len(res.Header) > 0 { - headers := make(map[string]interface{}, len(res.Header)) - for k, v := range res.Header { - if len(v) > 0 { - headers[k] = v[0] - } - } - init["headers"] = headers - } - - return jsResponse.New(body, init) -} - -// newPromiseOptimized creates a new JavaScript Promise with optimized callback handling -func newPromiseOptimized() (js.Value, func(interface{}), func(interface{})) { - var ( - resolve func(interface{}) - reject func(interface{}) - promiseFunc = js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - resolve = func(v interface{}) { args[0].Invoke(v) } - reject = func(v interface{}) { args[1].Invoke(v) } - return js.Undefined() - }) - ) - defer promiseFunc.Release() - - return jsPromise.New(promiseFunc), resolve, reject -} - -// awaitPromiseOptimized waits for Promise resolution with optimized channel handling -func awaitPromiseOptimized(promise js.Value) (js.Value, error) { - done := make(chan struct{}) - var ( - result js.Value - err error - ) - - thenFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - result = args[0] - close(done) - return nil - }) - defer thenFunc.Release() - - catchFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - err = js.Error{Value: args[0]} - close(done) - return nil - }) - defer catchFunc.Release() - - promise.Call("then", thenFunc).Call("catch", catchFunc) - <-done - - return result, err -} diff --git a/configs/logs.json b/configs/logs.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/configs/logs.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/deploy/README.md b/deploy/README.md deleted file mode 100644 index 427b81111..000000000 --- a/deploy/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Deployment - -This directory contains the configuration files for deploying the Sonr blockchain. - -## Contents - -- `devnet`: Configuration for deploying the Sonr blockchain on the devnet (local development). -- `testnet`: Configuration for deploying the Sonr blockchain on the testnet (current prod setup) - -## Usage - -Configuration is automatically loaded from the `PKL` files in the root of the repository. These templates are generated during deployment initialization. - -To deploy the total network, run the following command: - -```bash -devbox run -``` - -Replace `` with either `devnet` or `testnet` from the root of the repository. - -## Components - -### Sonr - -The Sonr blockchain is deployed using the `sonrd` binary. This binary is built using the `Makefile` in the root of the repository. - -### IPFS - -IPFS is deployed using the `ipfs` binary. This binary is built using the `Makefile` in the root of the repository. - -### Hway - -Hway is deployed using the `hway` binary. This binary is built using the `Makefile` in the root of the repository. - -### Synapse - -Synapse is deployed using the `matrix-synapse` binary. This binary is built using the `Makefile` in the root of the repository. - -### Tigerbeetle - -Tigerbeetle is deployed using the `tigerbeetle` binary. This binary is built using the `Makefile` in the root of the repository. diff --git a/deploy/sink/reset_chainindex.sql b/deploy/apps/chainindex/reset.sql similarity index 100% rename from deploy/sink/reset_chainindex.sql rename to deploy/apps/chainindex/reset.sql diff --git a/deploy/sink/schema_indexer.sql b/deploy/apps/chainindex/schema.sql similarity index 100% rename from deploy/sink/schema_indexer.sql rename to deploy/apps/chainindex/schema.sql diff --git a/deploy/sink/db_seed.sql b/deploy/apps/chainindex/seed.sql similarity index 100% rename from deploy/sink/db_seed.sql rename to deploy/apps/chainindex/seed.sql diff --git a/deploy/devbox.json b/deploy/devbox.json new file mode 100644 index 000000000..7d37ab03e --- /dev/null +++ b/deploy/devbox.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.7/.schema/devbox.schema.json", + "packages": [ + "tigerbeetle@latest", + "ipfs@latest" + ], + "shell": { + "scripts": { + "init": [], + "start": [ + "devbox services up" + ], + "stop": [ + "devbox services down" + ] + } + } +} diff --git a/deploy/devbox.lock b/deploy/devbox.lock new file mode 100644 index 000000000..9bc801d92 --- /dev/null +++ b/deploy/devbox.lock @@ -0,0 +1,232 @@ +{ + "lockfile_version": "1", + "packages": { + "ipfs@latest": { + "last_modified": "2023-02-24T09:01:09Z", + "resolved": "github:NixOS/nixpkgs/7d0ed7f2e5aea07ab22ccb338d27fbe347ed2f11#ipfs", + "source": "devbox-search", + "version": "0.17.0" + }, + "postgresql@latest": { + "last_modified": "2024-12-08T19:40:50Z", + "plugin_version": "0.0.2", + "resolved": "github:NixOS/nixpkgs/dd51f52372a20a93c219e8216fe528a648ffcbf4#postgresql", + "source": "devbox-search", + "version": "16.5", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/6l498xrh9z690js5zmd3p2ps0r00ri9p-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/5yiw867cz810zi0z2yg5y794w2sy8kzq-postgresql-16.5-man", + "default": true + }, + { + "name": "dev", + "path": "/nix/store/9mc2nq9m18x0l7c1gyasp064cf2894vx-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/lxqw2xsh0vm11rcz5wayhskb8w9wjlih-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/c3a1ij8vyxv5fyg7qp6la2mn54jn84sn-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/6l498xrh9z690js5zmd3p2ps0r00ri9p-postgresql-16.5" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/vjcavy1l0s1l0frjag900239cpmvj17f-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/4l4a2044a6mb79sm46679ifappmj8vgc-postgresql-16.5-man", + "default": true + }, + { + "name": "debug", + "path": "/nix/store/zlw8cxkzf9a43mmplsp88dbjy8adbjkx-postgresql-16.5-debug" + }, + { + "name": "dev", + "path": "/nix/store/8mbabq6zp86a1gm2nf109pa1dvgp8s02-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/1sa3z90r6hrcfsd4hy4rxbwzbw6aa4p6-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/gr06jpjpxzqkpyyhg1f7v9mmy1f9qzgp-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/vjcavy1l0s1l0frjag900239cpmvj17f-postgresql-16.5" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/808d9axcd5q934lsi3l5v3x8phks9wc4-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/8njx7dcc3gj9j46cn5lfc8knd52hvl7k-postgresql-16.5-man", + "default": true + }, + { + "name": "dev", + "path": "/nix/store/pn22i14qpv3yxmaacd5yfcqxpqm3grlq-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/kd05cfbhaiiihdx6kkrjdyrywgjzfnqj-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/1gnp8q95nfjna56sllv66jbf6hshi6bd-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/808d9axcd5q934lsi3l5v3x8phks9wc4-postgresql-16.5" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/0z5iwcvalafm3j2c5pfhllsfbxrbyzf4-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/0q9yki1d9czy7i7mly8gy3ffjvc3hkqv-postgresql-16.5-man", + "default": true + }, + { + "name": "debug", + "path": "/nix/store/zvysixjns32iz6qlkr8s5b70cw50l0qy-postgresql-16.5-debug" + }, + { + "name": "dev", + "path": "/nix/store/207n898zbi7mb5scjaf532v78c3rll9f-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/7ip3havx020h3527y7cqdl8l39p3g67b-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/qi2zbhdnzdci7i0a6g64mbkk8wnzznlh-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/0z5iwcvalafm3j2c5pfhllsfbxrbyzf4-postgresql-16.5" + } + } + }, + "process-compose@latest": { + "last_modified": "2024-12-04T16:45:45Z", + "resolved": "github:NixOS/nixpkgs/2f9d395f057a50f8076f633c10519035fce8d773#process-compose", + "source": "devbox-search", + "version": "1.40.1", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/iz6ckcr1s8vy71b3wqvs680g2mwpf9jk-process-compose-1.40.1", + "default": true + } + ], + "store_path": "/nix/store/iz6ckcr1s8vy71b3wqvs680g2mwpf9jk-process-compose-1.40.1" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/7jw864z6wlzcirsz8fgaj2bw0f22izch-process-compose-1.40.1", + "default": true + } + ], + "store_path": "/nix/store/7jw864z6wlzcirsz8fgaj2bw0f22izch-process-compose-1.40.1" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/mrdrciqg6zjrblgjaya6bxqd57knf09r-process-compose-1.40.1", + "default": true + } + ], + "store_path": "/nix/store/mrdrciqg6zjrblgjaya6bxqd57knf09r-process-compose-1.40.1" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/0vq97wmm879440n8plsk1yjc1g28ai85-process-compose-1.40.1", + "default": true + } + ], + "store_path": "/nix/store/0vq97wmm879440n8plsk1yjc1g28ai85-process-compose-1.40.1" + } + } + }, + "tigerbeetle@latest": { + "last_modified": "2024-12-17T11:43:56Z", + "resolved": "github:NixOS/nixpkgs/4989a246d7a390a859852baddb1013f825435cee#tigerbeetle", + "source": "devbox-search", + "version": "0.16.17", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/89c3g9b3sscjv6nk01zq4h901gm15l7v-tigerbeetle-0.16.17", + "default": true + } + ], + "store_path": "/nix/store/89c3g9b3sscjv6nk01zq4h901gm15l7v-tigerbeetle-0.16.17" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/16l13g01n0vxim291x79apxdhxfg66rh-tigerbeetle-0.16.17", + "default": true + } + ], + "store_path": "/nix/store/16l13g01n0vxim291x79apxdhxfg66rh-tigerbeetle-0.16.17" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/8di9nxpw06kcvzfyhpbwc46y16qjp9gr-tigerbeetle-0.16.17", + "default": true + } + ], + "store_path": "/nix/store/8di9nxpw06kcvzfyhpbwc46y16qjp9gr-tigerbeetle-0.16.17" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/4kldrqg1wm877p4kx4n2ddifq5klxhix-tigerbeetle-0.16.17", + "default": true + } + ], + "store_path": "/nix/store/4kldrqg1wm877p4kx4n2ddifq5klxhix-tigerbeetle-0.16.17" + } + } + } + } +} diff --git a/deploy/process-compose.yaml b/deploy/process-compose.yaml index 7339b9e35..ca5bfb5ff 100644 --- a/deploy/process-compose.yaml +++ b/deploy/process-compose.yaml @@ -1,10 +1,30 @@ -version: "0.6" +version: "0.5" + +environment: + - "PC_DISABLE_TUI=true" +log_location: "./tmp/logs" +log_level: "debug" processes: - sonr: + IPFS: namespace: testnet - command: "make dop-testnet" + command: "task ipfs:start" + availability: + restart: "always" - hway: + Sonr: namespace: testnet - command: "./build/hway" + command: "task sonrd:start" + depends_on: + ipfs: + condition: process_completed + environment: + - "SONR_NETWORK=testnet" + + Hway: + namespace: testnet + command: "hway" + depends_on: + sonr: + condition: process_completed_successfully + diff --git a/devbox.lock b/devbox.lock new file mode 100644 index 000000000..6651f7e38 --- /dev/null +++ b/devbox.lock @@ -0,0 +1,130 @@ +{ + "lockfile_version": "1", + "packages": { + "postgresql@latest": { + "last_modified": "2024-12-08T19:40:50Z", + "plugin_version": "0.0.2", + "resolved": "github:NixOS/nixpkgs/dd51f52372a20a93c219e8216fe528a648ffcbf4#postgresql", + "source": "devbox-search", + "version": "16.5", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/6l498xrh9z690js5zmd3p2ps0r00ri9p-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/5yiw867cz810zi0z2yg5y794w2sy8kzq-postgresql-16.5-man", + "default": true + }, + { + "name": "dev", + "path": "/nix/store/9mc2nq9m18x0l7c1gyasp064cf2894vx-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/lxqw2xsh0vm11rcz5wayhskb8w9wjlih-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/c3a1ij8vyxv5fyg7qp6la2mn54jn84sn-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/6l498xrh9z690js5zmd3p2ps0r00ri9p-postgresql-16.5" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/vjcavy1l0s1l0frjag900239cpmvj17f-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/4l4a2044a6mb79sm46679ifappmj8vgc-postgresql-16.5-man", + "default": true + }, + { + "name": "debug", + "path": "/nix/store/zlw8cxkzf9a43mmplsp88dbjy8adbjkx-postgresql-16.5-debug" + }, + { + "name": "dev", + "path": "/nix/store/8mbabq6zp86a1gm2nf109pa1dvgp8s02-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/1sa3z90r6hrcfsd4hy4rxbwzbw6aa4p6-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/gr06jpjpxzqkpyyhg1f7v9mmy1f9qzgp-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/vjcavy1l0s1l0frjag900239cpmvj17f-postgresql-16.5" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/808d9axcd5q934lsi3l5v3x8phks9wc4-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/8njx7dcc3gj9j46cn5lfc8knd52hvl7k-postgresql-16.5-man", + "default": true + }, + { + "name": "dev", + "path": "/nix/store/pn22i14qpv3yxmaacd5yfcqxpqm3grlq-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/kd05cfbhaiiihdx6kkrjdyrywgjzfnqj-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/1gnp8q95nfjna56sllv66jbf6hshi6bd-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/808d9axcd5q934lsi3l5v3x8phks9wc4-postgresql-16.5" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/0z5iwcvalafm3j2c5pfhllsfbxrbyzf4-postgresql-16.5", + "default": true + }, + { + "name": "man", + "path": "/nix/store/0q9yki1d9czy7i7mly8gy3ffjvc3hkqv-postgresql-16.5-man", + "default": true + }, + { + "name": "debug", + "path": "/nix/store/zvysixjns32iz6qlkr8s5b70cw50l0qy-postgresql-16.5-debug" + }, + { + "name": "dev", + "path": "/nix/store/207n898zbi7mb5scjaf532v78c3rll9f-postgresql-16.5-dev" + }, + { + "name": "doc", + "path": "/nix/store/7ip3havx020h3527y7cqdl8l39p3g67b-postgresql-16.5-doc" + }, + { + "name": "lib", + "path": "/nix/store/qi2zbhdnzdci7i0a6g64mbkk8wnzznlh-postgresql-16.5-lib" + } + ], + "store_path": "/nix/store/0z5iwcvalafm3j2c5pfhllsfbxrbyzf4-postgresql-16.5" + } + } + } + } +} diff --git a/internal/config/hway/Hway.pkl.go b/internal/config/hway/Hway.pkl.go index 09c88ce2a..c3e46fa37 100644 --- a/internal/config/hway/Hway.pkl.go +++ b/internal/config/hway/Hway.pkl.go @@ -23,6 +23,8 @@ type Hway interface { GetSonrRpcUrl() string GetPsqlDSN() string + + GetTurnstileSiteKey() string } var _ Hway = (*HwayImpl)(nil) @@ -43,6 +45,8 @@ type HwayImpl struct { SonrRpcUrl string `pkl:"sonrRpcUrl"` PsqlDSN string `pkl:"psqlDSN"` + + TurnstileSiteKey string `pkl:"turnstileSiteKey"` } func (rcv *HwayImpl) GetServePort() int { @@ -77,6 +81,10 @@ func (rcv *HwayImpl) GetPsqlDSN() string { return rcv.PsqlDSN } +func (rcv *HwayImpl) GetTurnstileSiteKey() string { + return rcv.TurnstileSiteKey +} + // LoadFromPath loads the pkl module at the given path and evaluates it into a Hway func LoadFromPath(ctx context.Context, path string) (ret Hway, err error) { evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions) diff --git a/internal/config/motr/init.pkl.go b/internal/config/motr/init.pkl.go index 90029837f..9c55d885e 100644 --- a/internal/config/motr/init.pkl.go +++ b/internal/config/motr/init.pkl.go @@ -6,5 +6,4 @@ import "github.com/apple/pkl-go/pkl" func init() { pkl.RegisterMapping("sonr.net.Motr", Motr{}) pkl.RegisterMapping("sonr.net.Motr#Config", Config{}) - pkl.RegisterMapping("sonr.net.Motr#Environment", Environment{}) } diff --git a/pkg/gateway/orm/db.go b/internal/database/hwayorm/db.go similarity index 97% rename from pkg/gateway/orm/db.go rename to internal/database/hwayorm/db.go index 044d80730..976fb26f7 100644 --- a/pkg/gateway/orm/db.go +++ b/internal/database/hwayorm/db.go @@ -2,7 +2,7 @@ // versions: // sqlc v1.27.0 -package orm +package hwayorm import ( "context" diff --git a/pkg/gateway/orm/models.go b/internal/database/hwayorm/models.go similarity index 98% rename from pkg/gateway/orm/models.go rename to internal/database/hwayorm/models.go index bf07a5967..f7ea1a602 100644 --- a/pkg/gateway/orm/models.go +++ b/internal/database/hwayorm/models.go @@ -2,7 +2,7 @@ // versions: // sqlc v1.27.0 -package orm +package hwayorm import ( "github.com/jackc/pgx/v5/pgtype" @@ -61,6 +61,7 @@ type Profile struct { Handle string Origin string Name string + Status string } type Session struct { diff --git a/pkg/gateway/orm/query_highway.sql.go b/internal/database/hwayorm/query_highway.sql.go similarity index 98% rename from pkg/gateway/orm/query_highway.sql.go rename to internal/database/hwayorm/query_highway.sql.go index 7cda7c3f0..c006b500b 100644 --- a/pkg/gateway/orm/query_highway.sql.go +++ b/internal/database/hwayorm/query_highway.sql.go @@ -3,7 +3,7 @@ // sqlc v1.27.0 // source: query_highway.sql -package orm +package hwayorm import ( "context" @@ -193,7 +193,7 @@ func (q *Queries) GetHumanVerificationNumbers(ctx context.Context, id string) (G } const getProfileByAddress = `-- name: GetProfileByAddress :one -SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles +SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name, status FROM profiles WHERE address = $1 AND deleted_at IS NULL LIMIT 1 ` @@ -210,12 +210,13 @@ func (q *Queries) GetProfileByAddress(ctx context.Context, address string) (Prof &i.Handle, &i.Origin, &i.Name, + &i.Status, ) return i, err } const getProfileByHandle = `-- name: GetProfileByHandle :one -SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles +SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name, status FROM profiles WHERE handle = $1 AND deleted_at IS NULL LIMIT 1 @@ -233,12 +234,13 @@ func (q *Queries) GetProfileByHandle(ctx context.Context, handle string) (Profil &i.Handle, &i.Origin, &i.Name, + &i.Status, ) return i, err } const getProfileByID = `-- name: GetProfileByID :one -SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles +SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name, status FROM profiles WHERE id = $1 AND deleted_at IS NULL LIMIT 1 ` @@ -255,6 +257,7 @@ func (q *Queries) GetProfileByID(ctx context.Context, id string) (Profile, error &i.Handle, &i.Origin, &i.Name, + &i.Status, ) return i, err } @@ -411,7 +414,7 @@ INSERT INTO profiles ( origin, name ) VALUES ($1, $2, $3, $4) -RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name +RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name, status ` type InsertProfileParams struct { @@ -438,6 +441,7 @@ func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (P &i.Handle, &i.Origin, &i.Name, + &i.Status, ) return i, err } @@ -472,7 +476,7 @@ SET updated_at = CURRENT_TIMESTAMP WHERE address = $3 AND deleted_at IS NULL -RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name +RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name, status ` type UpdateProfileParams struct { @@ -493,6 +497,7 @@ func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (P &i.Handle, &i.Origin, &i.Name, + &i.Status, ) return i, err } diff --git a/pkg/vault/orm/db.go b/internal/database/motrorm/db.go similarity index 97% rename from pkg/vault/orm/db.go rename to internal/database/motrorm/db.go index fe1e9908e..93a2528e3 100644 --- a/pkg/vault/orm/db.go +++ b/internal/database/motrorm/db.go @@ -2,7 +2,7 @@ // versions: // sqlc v1.27.0 -package orm +package motrorm import ( "context" diff --git a/pkg/vault/orm/models.go b/internal/database/motrorm/models.go similarity index 99% rename from pkg/vault/orm/models.go rename to internal/database/motrorm/models.go index 470618d79..f8ca9c617 100644 --- a/pkg/vault/orm/models.go +++ b/internal/database/motrorm/models.go @@ -2,7 +2,7 @@ // versions: // sqlc v1.27.0 -package orm +package motrorm import ( "database/sql" diff --git a/pkg/vault/orm/query_vault.sql.go b/internal/database/motrorm/query_vault.sql.go similarity index 99% rename from pkg/vault/orm/query_vault.sql.go rename to internal/database/motrorm/query_vault.sql.go index fb7d80f16..0fed95a8e 100644 --- a/pkg/vault/orm/query_vault.sql.go +++ b/internal/database/motrorm/query_vault.sql.go @@ -3,7 +3,7 @@ // sqlc v1.27.0 // source: query_vault.sql -package orm +package motrorm import ( "context" diff --git a/deploy/sink/query_highway.sql b/internal/database/sink/query_highway.sql similarity index 100% rename from deploy/sink/query_highway.sql rename to internal/database/sink/query_highway.sql diff --git a/deploy/sink/query_vault.sql b/internal/database/sink/query_vault.sql similarity index 100% rename from deploy/sink/query_vault.sql rename to internal/database/sink/query_vault.sql diff --git a/deploy/sink/schema_highway.sql b/internal/database/sink/schema_highway.sql similarity index 96% rename from deploy/sink/schema_highway.sql rename to internal/database/sink/schema_highway.sql index 64d571eb5..2bda180ad 100644 --- a/deploy/sink/schema_highway.sql +++ b/internal/database/sink/schema_highway.sql @@ -8,6 +8,7 @@ CREATE TABLE profiles ( handle TEXT NOT NULL UNIQUE, origin TEXT NOT NULL, name TEXT NOT NULL, + status TEXT NOT NULL, UNIQUE(address, origin) ); @@ -102,6 +103,8 @@ CREATE TABLE vaults ( -- Indexes for common queries CREATE INDEX idx_profiles_handle ON profiles(handle); CREATE INDEX idx_profiles_address ON profiles(address); +CREATE INDEX idx_profiles_origin ON profiles(origin); +CREATE INDEX idx_profiles_status ON profiles(status); CREATE INDEX idx_profiles_deleted_at ON profiles(deleted_at); CREATE INDEX idx_accounts_address ON accounts(address); diff --git a/deploy/sink/schema_vault.sql b/internal/database/sink/schema_vault.sql similarity index 100% rename from deploy/sink/schema_vault.sql rename to internal/database/sink/schema_vault.sql diff --git a/deploy/sink/sink.go b/internal/database/sink/sink.go similarity index 100% rename from deploy/sink/sink.go rename to internal/database/sink/sink.go diff --git a/deploy/sqlc.yaml b/internal/database/sqlc.yaml similarity index 72% rename from deploy/sqlc.yaml rename to internal/database/sqlc.yaml index c6de5a430..c70a6f014 100644 --- a/deploy/sqlc.yaml +++ b/internal/database/sqlc.yaml @@ -5,15 +5,15 @@ sql: schema: "./sink/schema_vault.sql" gen: go: - package: "orm" - out: "../pkg/vault/orm" + package: "motrorm" + out: "motrorm" - engine: "postgresql" queries: "./sink/query_highway.sql" schema: "./sink/schema_highway.sql" gen: go: - package: "orm" - out: "../pkg/gateway/orm" + package: "hwayorm" + out: "hwayorm" sql_package: "pgx/v5" diff --git a/pkg/vault/embed/codec.go b/internal/embed/codec.go similarity index 100% rename from pkg/vault/embed/codec.go rename to internal/embed/codec.go diff --git a/pkg/vault/embed/index.html b/internal/embed/index.html similarity index 100% rename from pkg/vault/embed/index.html rename to internal/embed/index.html diff --git a/pkg/vault/embed/main.js b/internal/embed/main.js similarity index 100% rename from pkg/vault/embed/main.js rename to internal/embed/main.js diff --git a/pkg/vault/embed/sw.js b/internal/embed/sw.js similarity index 100% rename from pkg/vault/embed/sw.js rename to internal/embed/sw.js diff --git a/pkg/vault/embed/utils.go b/internal/embed/utils.go similarity index 100% rename from pkg/vault/embed/utils.go rename to internal/embed/utils.go diff --git a/pkg/vault/embed/webworker.go b/internal/embed/webworker.go similarity index 100% rename from pkg/vault/embed/webworker.go rename to internal/embed/webworker.go diff --git a/internal/nebula/hero/social_buttons.templ b/internal/nebula/hero/social_buttons.templ deleted file mode 100644 index 1802b4484..000000000 --- a/internal/nebula/hero/social_buttons.templ +++ /dev/null @@ -1,15 +0,0 @@ -package hero - -templ SocialButtonsRow() { -
- - - - - - - - - -
-} diff --git a/internal/nebula/hero/social_buttons_templ.go b/internal/nebula/hero/social_buttons_templ.go deleted file mode 100644 index bdb0fe6ce..000000000 --- a/internal/nebula/hero/social_buttons_templ.go +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package hero - -//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 SocialButtonsRow() 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/nebula/hero/start_button.templ b/internal/nebula/hero/start_button.templ deleted file mode 100644 index 64783b8df..000000000 --- a/internal/nebula/hero/start_button.templ +++ /dev/null @@ -1,11 +0,0 @@ -package hero - -templ StartButton() { -
- - - Create Vault - - -
-} diff --git a/internal/nebula/hero/start_button_templ.go b/internal/nebula/hero/start_button_templ.go deleted file mode 100644 index ceaf6e6b2..000000000 --- a/internal/nebula/hero/start_button_templ.go +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package hero - -//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 StartButton() 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("
Create Vault
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/nebula/hero/titles.templ b/internal/nebula/hero/titles.templ deleted file mode 100644 index 19a16a6b8..000000000 --- a/internal/nebula/hero/titles.templ +++ /dev/null @@ -1,12 +0,0 @@ -package hero - -templ TitleDesc(title string, subtitle string) { -
-

- { title } -

-

- { subtitle } -

-
-} diff --git a/internal/nebula/hero/titles_templ.go b/internal/nebula/hero/titles_templ.go deleted file mode 100644 index be11d0507..000000000 --- a/internal/nebula/hero/titles_templ.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package hero - -//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 TitleDesc(title string, subtitle 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 - } - var templ_7745c5c3_Var2 string - templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/hero/titles.templ`, Line: 6, Col: 10} - } - _, 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(subtitle) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/nebula/hero/titles.templ`, Line: 9, Col: 13} - } - _, 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("

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/nebula/input/input_name.templ b/internal/nebula/input/input_name.templ deleted file mode 100644 index 10caae91c..000000000 --- a/internal/nebula/input/input_name.templ +++ /dev/null @@ -1,37 +0,0 @@ -package input - -type NameState string - -const ( - NameStateInitial NameState = "inital" - NameStateValid NameState = "valid" - NameStateInvalid NameState = "invalid" -) - -func (s NameState) string() string { - return string(s) -} - -templ Name() { -
- - -
-
-} - -templ NameError() { -
- - -
-
-} - -templ NameValid() { -
- - -
-
-} diff --git a/internal/nebula/layout/container.templ b/internal/nebula/layout/container.templ deleted file mode 100644 index 58f616aa6..000000000 --- a/internal/nebula/layout/container.templ +++ /dev/null @@ -1,13 +0,0 @@ -package layout - -templ Container() { -
-
-
-
- { children... } -
-
-
-
-} diff --git a/internal/nebula/layout/container_templ.go b/internal/nebula/layout/container_templ.go deleted file mode 100644 index c02d5ed6d..000000000 --- a/internal/nebula/layout/container_templ.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package layout - -//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 Container() 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 = 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 - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/nebula/layout/grid.templ b/internal/nebula/layout/grid.templ deleted file mode 100644 index 4b2ef729b..000000000 --- a/internal/nebula/layout/grid.templ +++ /dev/null @@ -1,24 +0,0 @@ -package layout - -// Columns is a component that renders a responsive flex container that stacks on mobile -templ Columns() { -
- { children... } -
-} - -// Rows is a component that renders a responsive flex container that wraps on mobile -templ Rows() { -
- { children... } -
-} - -templ Separator(text string) { -
-
-
- { text } -
-
-} diff --git a/internal/nebula/layout/layout.templ b/internal/nebula/layout/layout.templ deleted file mode 100644 index 9d7e68aec..000000000 --- a/internal/nebula/layout/layout.templ +++ /dev/null @@ -1,66 +0,0 @@ -package layout - -type ( - Alignment templ.Attributes - ScreenWidth templ.Attributes -) - -var ( - AlignCenter = Alignment{ - "class": "flex items-center justify-center", - } - AlignEnd = Alignment{ - "class": "flex items-end justify-center", - } - MaxWidthSmall = ScreenWidth{ - "class": "max-w-screen-sm", - } - MaxWidthMedium = ScreenWidth{ - "class": "max-w-screen-md", - } - MaxWidthFull = ScreenWidth{ - "class": "w-full", - } -) - -// Layout is a component that renders the general layout of the application -templ View(title string) { - - - @Head(title, "0.0.11") - -
- { children... } -
- - -} - -templ Body(align Alignment, screenWidth ScreenWidth) { - - -
- { children... } -
- -} - -func Clsx(attrs ...templ.Attributes) templ.Attributes { - merged := templ.Attributes{} - for _, attr := range attrs { - for k, v := range attr { - merged[k] = v - } - } - return merged -} diff --git a/internal/nebula/layout/layout_templ.go b/internal/nebula/layout/layout_templ.go deleted file mode 100644 index ece9735c3..000000000 --- a/internal/nebula/layout/layout_templ.go +++ /dev/null @@ -1,127 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package layout - -//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 ( - Alignment templ.Attributes - ScreenWidth templ.Attributes -) - -var ( - AlignCenter = Alignment{ - "class": "flex items-center justify-center", - } - AlignEnd = Alignment{ - "class": "flex items-end justify-center", - } - MaxWidthSmall = ScreenWidth{ - "class": "max-w-screen-sm", - } - MaxWidthMedium = ScreenWidth{ - "class": "max-w-screen-md", - } - MaxWidthFull = ScreenWidth{ - "class": "w-full", - } -) - -// Layout is a component that renders the general layout of the application -func View(title 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 = Head(title, "0.0.11").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 = 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 - }) -} - -func Body(align Alignment, screenWidth ScreenWidth) 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) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templ_7745c5c3_Var2.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 Clsx(attrs ...templ.Attributes) templ.Attributes { - merged := templ.Attributes{} - for _, attr := range attrs { - for k, v := range attr { - merged[k] = v - } - } - return merged -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/nebula/nav/footer.templ b/internal/nebula/nav/footer.templ deleted file mode 100644 index a7fddc9eb..000000000 --- a/internal/nebula/nav/footer.templ +++ /dev/null @@ -1,10 +0,0 @@ -package nav - -templ Footer() { -
-
- -

Sonr.ID

-
-
-} diff --git a/internal/nebula/nav/footer_templ.go b/internal/nebula/nav/footer_templ.go deleted file mode 100644 index 45efa7b52..000000000 --- a/internal/nebula/nav/footer_templ.go +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package nav - -//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 Footer() 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.ID

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/nebula/nav/header.templ b/internal/nebula/nav/header.templ deleted file mode 100644 index 0b74facff..000000000 --- a/internal/nebula/nav/header.templ +++ /dev/null @@ -1,35 +0,0 @@ -package nav - -templ Header() { -
- -
-} - -templ NavFooter() { -
-
- -

Sonr.ID

-
-
-} diff --git a/internal/nebula/nav/header_templ.go b/internal/nebula/nav/header_templ.go deleted file mode 100644 index c31b6c624..000000000 --- a/internal/nebula/nav/header_templ.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package nav - -//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 Header() 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 NavFooter() 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) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Sonr.ID

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/context/cookies.go b/pkg/common/http_cookies.go similarity index 99% rename from internal/context/cookies.go rename to pkg/common/http_cookies.go index 5178e4fd7..ad7e419eb 100644 --- a/internal/context/cookies.go +++ b/pkg/common/http_cookies.go @@ -1,4 +1,4 @@ -package context +package common import ( "encoding/base64" diff --git a/internal/context/headers.go b/pkg/common/http_headers.go similarity index 99% rename from internal/context/headers.go rename to pkg/common/http_headers.go index 692cd0e0d..68de391be 100644 --- a/internal/context/headers.go +++ b/pkg/common/http_headers.go @@ -1,4 +1,4 @@ -package context +package common import "github.com/labstack/echo/v4" diff --git a/pkg/gateway/handlers/check_handler.go b/pkg/gateway/handlers/check_handler.go deleted file mode 100644 index 0095f9696..000000000 --- a/pkg/gateway/handlers/check_handler.go +++ /dev/null @@ -1,36 +0,0 @@ -package handlers - -import ( - "github.com/labstack/echo/v4" - - "github.com/onsonr/sonr/internal/nebula/input" - "github.com/onsonr/sonr/pkg/gateway/middleware" -) - -// CheckProfileHandle finds the chosen handle and verifies it is unique -func CheckProfileHandle(c echo.Context) error { - handle := c.FormValue("handle") - if handle == "" { - return middleware.Render(c, input.HandleError(handle, "Please enter a valid handle")) - } - // - // if ok { - // return middleware.Render(c, input.HandleError(handle)) - // } - // - return middleware.Render(c, input.HandleSuccess(handle)) -} - -// ValidateProfileHandle finds the chosen handle and verifies it is unique -func CheckIsHumanSum(c echo.Context) error { - // data := context.GetCreateProfileData(c) - // value := c.FormValue("is_human") - // intValue, err := strconv.Atoi(value) - // if err != nil { - // return middleware.Render(c, input.HumanSliderError(data.FirstNumber, data.LastNumber)) - // } - // if intValue != data.Sum() { - // return middleware.Render(c, input.HumanSliderError(data.FirstNumber, data.LastNumber)) - // } - return middleware.Render(c, input.HumanSliderSuccess()) -} diff --git a/pkg/gateway/handlers/initial_handler.go b/pkg/gateway/handlers/initial_handler.go deleted file mode 100644 index 081dcecd6..000000000 --- a/pkg/gateway/handlers/initial_handler.go +++ /dev/null @@ -1,28 +0,0 @@ -package handlers - -import ( - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/gateway/middleware" -) - -func HandleIndex(c echo.Context) error { - id := middleware.GetSessionID(c) - if id == "" { - return startNewSession(c) - } - return middleware.RenderInitial(c) -} - -func startNewSession(c echo.Context) error { - // Initialize the session - err := middleware.NewSession(c) - if err != nil { - return middleware.RenderError(c, err) - } - return middleware.RenderInitial(c) -} - -func continueExistingSession(c echo.Context, id string) error { - // Do some auth checks here - return middleware.RenderInitial(c) -} diff --git a/pkg/gateway/handlers/register_handler.go b/pkg/gateway/handlers/register_handler.go deleted file mode 100644 index 2a639bacc..000000000 --- a/pkg/gateway/handlers/register_handler.go +++ /dev/null @@ -1,24 +0,0 @@ -package handlers - -import ( - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/gateway/middleware" - "github.com/onsonr/sonr/pkg/gateway/views" -) - -func RenderProfileCreate(c echo.Context) error { - // numF, numL := middleware.GetHumanVerificationNumbers(c) - params := middleware.CreateProfileParams{ - FirstNumber: int(middleware.CurrentBlock(c)), - LastNumber: int(middleware.CurrentBlock(c)), - } - return middleware.Render(c, views.RegisterProfileView(params.FirstNumber, params.LastNumber)) -} - -func RenderPasskeyCreate(c echo.Context) error { - return middleware.Render(c, views.RegisterPasskeyView("", "", "", "", "")) -} - -func RenderVaultLoading(c echo.Context) error { - return middleware.Render(c, views.LoadingView()) -} diff --git a/pkg/gateway/handlers/vault_handler.go b/pkg/gateway/handlers/vault_handler.go deleted file mode 100644 index f37828ae8..000000000 --- a/pkg/gateway/handlers/vault_handler.go +++ /dev/null @@ -1,28 +0,0 @@ -package handlers - -import ( - "encoding/json" - - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/gateway/middleware" -) - -// SubmitProfileHandle submits a profile handle -func SubmitProfileHandle(c echo.Context) error { - return nil -} - -// SubmitPublicKeyCredential submits a public key credential -func SubmitPublicKeyCredential(c echo.Context) error { - credentialJSON := c.FormValue("credential") - cred := &middleware.CredentialDescriptor{} - // Unmarshal the credential JSON - if err := json.Unmarshal([]byte(credentialJSON), cred); err != nil { - return middleware.RenderError(c, err) - } - err := middleware.SubmitCredential(c, cred) - if err != nil { - return middleware.RenderError(c, err) - } - return nil -} diff --git a/pkg/gateway/middleware/credentials.go b/pkg/gateway/middleware/credentials.go deleted file mode 100644 index a253ce2ea..000000000 --- a/pkg/gateway/middleware/credentials.go +++ /dev/null @@ -1,83 +0,0 @@ -package middleware - -import ( - "net/http" - - "github.com/labstack/echo/v4" - hwayorm "github.com/onsonr/sonr/pkg/gateway/orm" -) - -func ListCredentials(c echo.Context, handle string) ([]*CredentialDescriptor, error) { - cc, ok := c.(*GatewayContext) - if !ok { - return nil, echo.NewHTTPError(http.StatusInternalServerError, "Credentials Context not found") - } - creds, err := cc.dbq.GetCredentialsByHandle(bgCtx(), handle) - if err != nil { - return nil, err - } - return CredentialArrayToDescriptors(creds), nil -} - -func SubmitCredential(c echo.Context, cred *CredentialDescriptor) error { - origin := GetOrigin(c) - handle := GetHandle(c) - md := cred.ToModel(handle, origin) - - cc, ok := c.(*GatewayContext) - if !ok { - return echo.NewHTTPError(http.StatusInternalServerError, "Credentials Context not found") - } - - _, err := cc.dbq.InsertCredential(bgCtx(), hwayorm.InsertCredentialParams{ - Handle: handle, - CredentialID: md.CredentialID, - Origin: origin, - Type: md.Type, - Transports: md.Transports, - }) - if err != nil { - return err - } - return nil -} - -// Define the credential structure matching our frontend data -type CredentialDescriptor struct { - ID string `json:"id"` - RawID string `json:"rawId"` - Type string `json:"type"` - AuthenticatorAttachment string `json:"authenticatorAttachment"` - Transports string `json:"transports"` - ClientExtensionResults map[string]string `json:"clientExtensionResults"` - Response struct { - AttestationObject string `json:"attestationObject"` - ClientDataJSON string `json:"clientDataJSON"` - } `json:"response"` -} - -func (c *CredentialDescriptor) ToModel(handle, origin string) *hwayorm.Credential { - return &hwayorm.Credential{ - Handle: handle, - Origin: origin, - CredentialID: c.ID, - Type: c.Type, - Transports: c.Transports, - AuthenticatorAttachment: c.AuthenticatorAttachment, - } -} - -func CredentialArrayToDescriptors(credentials []hwayorm.Credential) []*CredentialDescriptor { - var descriptors []*CredentialDescriptor - for _, cred := range credentials { - cd := &CredentialDescriptor{ - ID: cred.CredentialID, - RawID: cred.CredentialID, - Type: cred.Type, - AuthenticatorAttachment: cred.AuthenticatorAttachment, - Transports: cred.Transports, - } - descriptors = append(descriptors, cd) - } - return descriptors -} diff --git a/pkg/gateway/middleware/middleware.go b/pkg/gateway/middleware/middleware.go deleted file mode 100644 index d50b2343a..000000000 --- a/pkg/gateway/middleware/middleware.go +++ /dev/null @@ -1,38 +0,0 @@ -package middleware - -import ( - "github.com/labstack/echo/v4" - "github.com/medama-io/go-useragent" - "github.com/onsonr/sonr/crypto/mpc" - "github.com/onsonr/sonr/internal/config/hway" - "github.com/onsonr/sonr/pkg/common" - hwayorm "github.com/onsonr/sonr/pkg/gateway/orm" -) - -type GatewayContext struct { - echo.Context - agent useragent.UserAgent - id string - dbq *hwayorm.Queries - ipfsClient common.IPFS - tokenStore common.IPFSTokenStore - stagedEnclaves map[string]mpc.Enclave - grpcAddr string -} - -func UseGateway(env hway.Hway, ipc common.IPFS, db *hwayorm.Queries) echo.MiddlewareFunc { - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - ua := useragent.NewParser() - ctx := &GatewayContext{ - agent: ua.Parse(c.Request().UserAgent()), - Context: c, - dbq: db, - ipfsClient: ipc, - grpcAddr: env.GetSonrGrpcUrl(), - tokenStore: common.NewUCANStore(ipc), - } - return next(ctx) - } - } -} diff --git a/pkg/gateway/middleware/profiles.go b/pkg/gateway/middleware/profiles.go deleted file mode 100644 index de8ffbfd1..000000000 --- a/pkg/gateway/middleware/profiles.go +++ /dev/null @@ -1,125 +0,0 @@ -package middleware - -import ( - "net/http" - - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/context" - hwayorm "github.com/onsonr/sonr/pkg/gateway/orm" -) - -func CheckHandleUnique(c echo.Context, handle string) bool { - ctx, ok := c.(*GatewayContext) - if !ok { - return false - } - ok, err := ctx.dbq.CheckHandleExists(bgCtx(), handle) - if err != nil { - return false - } - if ok { - return false - } - context.WriteCookie(c, context.UserHandle, handle) - return true -} - -func CreateProfile(c echo.Context) (*hwayorm.Profile, error) { - ctx, ok := c.(*GatewayContext) - if !ok { - return nil, echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found") - } - address := c.FormValue("address") - handle := c.FormValue("handle") - origin := c.FormValue("origin") - name := c.FormValue("name") - profile, err := ctx.dbq.InsertProfile(bgCtx(), hwayorm.InsertProfileParams{ - Address: address, - Handle: handle, - Origin: origin, - Name: name, - }) - if err != nil { - return nil, err - } - // Update session with profile id - sid := GetSessionID(c) - _, err = ctx.dbq.UpdateSessionWithProfileID(bgCtx(), hwayorm.UpdateSessionWithProfileIDParams{ - ProfileID: profile.ID, - ID: sid, - }) - if err != nil { - return nil, err - } - return &profile, nil -} - -func UpdateProfile(c echo.Context) (*hwayorm.Profile, error) { - ctx, ok := c.(*GatewayContext) - if !ok { - return nil, echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found") - } - address := c.FormValue("address") - handle := c.FormValue("handle") - name := c.FormValue("name") - profile, err := ctx.dbq.UpdateProfile(bgCtx(), hwayorm.UpdateProfileParams{ - Address: address, - Handle: handle, - Name: name, - }) - if err != nil { - return nil, err - } - return &profile, nil -} - -func ReadProfile(c echo.Context) (*hwayorm.Profile, error) { - ctx, ok := c.(*GatewayContext) - if !ok { - return nil, echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found") - } - handle := c.Param("handle") - profile, err := ctx.dbq.GetProfileByHandle(bgCtx(), handle) - if err != nil { - return nil, err - } - return &profile, nil -} - -func DeleteProfile(c echo.Context) error { - ctx, ok := c.(*GatewayContext) - if !ok { - return echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found") - } - address := c.Param("address") - err := ctx.dbq.SoftDeleteProfile(bgCtx(), address) - if err != nil { - return err - } - return nil -} - -// ╭───────────────────────────────────────────────────────────╮ -// │ Create Profile (/register/profile) │ -// ╰───────────────────────────────────────────────────────────╯ - -// DefaultCreateProfileParams returns a default CreateProfileParams -func DefaultCreateProfileParams() CreateProfileParams { - return CreateProfileParams{ - TurnstileSiteKey: "", - FirstNumber: 0, - LastNumber: 0, - } -} - -// CreateProfileParams represents the parameters for creating a profile -type CreateProfileParams struct { - TurnstileSiteKey string - FirstNumber int - LastNumber int -} - -// Sum returns the sum of the first and last number -func (d CreateProfileParams) Sum() int { - return d.FirstNumber + d.LastNumber -} diff --git a/pkg/gateway/middleware/resolver.go b/pkg/gateway/middleware/resolver.go deleted file mode 100644 index 83b5a931a..000000000 --- a/pkg/gateway/middleware/resolver.go +++ /dev/null @@ -1,113 +0,0 @@ -package middleware - -import ( - "errors" - - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/common" -) - -// CurrentBlock returns the current block -func CurrentBlock(c echo.Context) uint64 { - cc, ok := c.(*GatewayContext) - if !ok { - return 0 - } - qc, err := common.NewNodeClient(cc.grpcAddr) - if err != nil { - return 0 - } - resp, err := qc.Status(bgCtx(), &common.StatusRequest{}) - if err != nil { - return 0 - } - return resp.GetHeight() -} - -// GetBankParams returns the bank params -func GetBankParams(c echo.Context) (*common.BankParamsResponse, error) { - cc, ok := c.(*GatewayContext) - if !ok { - return nil, errors.New("gateway context not found") - } - cl, err := common.NewBankClient(cc.grpcAddr) - if err != nil { - return nil, err - } - resp, err := cl.Params(bgCtx(), &common.BankParamsRequest{}) - if err != nil { - return nil, err - } - return resp, nil -} - -// GetDIDParams returns the DID params -func GetDIDParams(c echo.Context) (*common.DIDParamsResponse, error) { - cc, ok := c.(*GatewayContext) - if !ok { - return nil, errors.New("gateway context not found") - } - cl, err := common.NewDIDClient(cc.grpcAddr) - if err != nil { - return nil, err - } - resp, err := cl.Params(bgCtx(), &common.DIDParamsRequest{}) - if err != nil { - return nil, err - } - return resp, nil -} - -// GetDWNParams returns the DWN params -func GetDWNParams(c echo.Context) (*common.DWNParamsResponse, error) { - cc, ok := c.(*GatewayContext) - if !ok { - return nil, errors.New("gateway context not found") - } - - cl, err := common.NewDWNClient(cc.grpcAddr) - if err != nil { - return nil, err - } - resp, err := cl.Params(bgCtx(), &common.DWNParamsRequest{}) - if err != nil { - return nil, err - } - return resp, nil -} - -// GetNodeStatus returns the node status -func GetNodeStatus(c echo.Context) (*common.StatusResponse, error) { - cc, ok := c.(*GatewayContext) - if !ok { - return nil, errors.New("gateway context not found") - } - - cl, err := common.NewNodeClient(cc.grpcAddr) - if err != nil { - return nil, err - } - resp, err := cl.Status(bgCtx(), &common.StatusRequest{}) - if err != nil { - return nil, err - } - return resp, nil -} - -// GetSVCParams returns the SVC params -func GetSVCParams(c echo.Context) (*common.SVCParamsResponse, error) { - cc, ok := c.(*GatewayContext) - if !ok { - return nil, errors.New("gateway context not found") - } - - cl, err := common.NewSVCClient(cc.grpcAddr) - if err != nil { - return nil, err - } - resp, err := cl.Params(bgCtx(), &common.SVCParamsRequest{}) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/pkg/gateway/middleware/vaults.go b/pkg/gateway/middleware/vaults.go deleted file mode 100644 index 27d38de1d..000000000 --- a/pkg/gateway/middleware/vaults.go +++ /dev/null @@ -1,80 +0,0 @@ -package middleware - -import ( - "fmt" - - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/crypto/mpc" - "github.com/onsonr/sonr/internal/context" - "lukechampine.com/blake3" -) - -func Spawn(c echo.Context) (CreatePasskeyParams, error) { - cc := c.(*GatewayContext) - block := fmt.Sprintf("%d", CurrentBlock(c)) - handle := GetHandle(c) - origin := GetOrigin(c) - challenge := GetSessionChallenge(c) - sid := GetSessionID(c) - nonce, err := calcNonce(sid) - if err != nil { - return defaultCreatePasskeyParams(), err - } - encl, err := mpc.GenEnclave(nonce) - if err != nil { - return defaultCreatePasskeyParams(), err - } - cc.stagedEnclaves[sid] = encl - context.WriteCookie(c, context.SonrAddress, encl.Address()) - return CreatePasskeyParams{ - Address: encl.Address(), - Handle: handle, - Name: origin, - Challenge: challenge, - CreationBlock: block, - }, nil -} - -func Claim() (CreatePasskeyParams, error) { - return CreatePasskeyParams{}, nil -} - -// Uses blake3 to hash the sessionID to generate a nonce of length 12 bytes -func calcNonce(sessionID string) ([]byte, error) { - hash := blake3.New(32, nil) - _, err := hash.Write([]byte(sessionID)) - if err != nil { - return nil, err - } - // Read the hash into a byte slice - nonce := make([]byte, 12) - _, err = hash.Write(nonce) - if err != nil { - return nil, err - } - return nonce, nil -} - -// ╭───────────────────────────────────────────────────────────╮ -// │ Create Passkey (/register/passkey) │ -// ╰───────────────────────────────────────────────────────────╯ - -// defaultCreatePasskeyParams returns a default CreatePasskeyParams -func defaultCreatePasskeyParams() CreatePasskeyParams { - return CreatePasskeyParams{ - Address: "", - Handle: "", - Name: "", - Challenge: "", - CreationBlock: "", - } -} - -// CreatePasskeyParams represents the parameters for creating a passkey -type CreatePasskeyParams struct { - Address string - Handle string - Name string - Challenge string - CreationBlock string -} diff --git a/pkg/gateway/routes/routes.go b/pkg/gateway/routes/routes.go deleted file mode 100644 index f8aab252b..000000000 --- a/pkg/gateway/routes/routes.go +++ /dev/null @@ -1,21 +0,0 @@ -package routes - -import ( - "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/gateway/handlers" -) - -func Register(e *echo.Echo) error { - // Register View Handlers - e.GET("/", handlers.HandleIndex) - e.GET("/register", handlers.RenderProfileCreate) - e.POST("/register/passkey", handlers.RenderPasskeyCreate) - e.POST("/register/finish", handlers.RenderVaultLoading) - - // Register Validation Handlers - e.POST("/register/profile/handle", handlers.CheckProfileHandle) - e.POST("/register/profile/is_human", handlers.CheckIsHumanSum) - e.POST("/submit/profile/handle", handlers.SubmitProfileHandle) - e.POST("/submit/credential", handlers.SubmitPublicKeyCredential) - return nil -} diff --git a/pkg/gateway/views/error.templ b/pkg/gateway/views/error.templ deleted file mode 100644 index f04cc2a6c..000000000 --- a/pkg/gateway/views/error.templ +++ /dev/null @@ -1,19 +0,0 @@ -package views - -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) - -templ ErrorView(err string) { - @layout.View("Error | Sonr.ID") { - @layout.Container() { - @hero.TitleDesc("Uh oh!", "Something went wrong.") -
-

- { err } -

-
- } - } -} diff --git a/pkg/gateway/views/initial.templ b/pkg/gateway/views/initial.templ deleted file mode 100644 index afba155ca..000000000 --- a/pkg/gateway/views/initial.templ +++ /dev/null @@ -1,31 +0,0 @@ -package views - -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) - -templ InitialView() { - @layout.View("Sonr.ID") { - @layout.Container() { - @hero.TitleDesc("Sonr.ID", "The decentralized identity layer for the web.") - @hero.StartButton() - @hero.SocialButtonsRow() - } - } -} - -templ ReturningView() { - @layout.View("Login | Sonr.ID") { - @layout.Container() { - @hero.TitleDesc("Welcome Back!", "Continue with your existing Sonr.ID.") -
- - - Log back in - - -
- } - } -} diff --git a/pkg/gateway/views/loading.templ b/pkg/gateway/views/loading.templ deleted file mode 100644 index 7f5463751..000000000 --- a/pkg/gateway/views/loading.templ +++ /dev/null @@ -1,14 +0,0 @@ -package views - -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) - -templ LoadingView() { - @layout.View("Loading... | Sonr.ID") { - @layout.Container() { - @hero.TitleDesc("Loading Vault", "This will be used to login to your vault.") - } - } -} diff --git a/pkg/gateway/views/register.templ b/pkg/gateway/views/register.templ deleted file mode 100644 index b32a6f288..000000000 --- a/pkg/gateway/views/register.templ +++ /dev/null @@ -1,55 +0,0 @@ -package views - -import ( - "github.com/onsonr/sonr/internal/nebula/card" - "github.com/onsonr/sonr/internal/nebula/form" - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/input" - "github.com/onsonr/sonr/internal/nebula/layout" -) - -templ RegisterProfileView(firstNumber int, lastNumber int) { - @layout.View("New Profile | Sonr.ID") { - @layout.Container() { - @hero.TitleDesc("Basic Info", "Tell us a little about yourself.") - @form.Root("/register/passkey", "create-profile") { - @form.Body() { - @form.Header() { -
- - -
- } - @input.Handle() - @input.Name() - @input.HumanSlider(firstNumber, lastNumber) - @form.Footer() { - @form.CancelButton() - @form.SubmitButton("Next") - } - } - } - } - } -} - -templ RegisterPasskeyView(address string, handle string, name string, challenge string, creationBlock string) { - @layout.View("Register | Sonr.ID") { - @layout.Container() { - @hero.TitleDesc("Link a PassKey", "This will be used to login to your vault.") - @form.Root("/register/finish", "passkey-form") { - - @form.Body() { - @form.Header() { - @card.SonrProfile(address, name, handle, creationBlock) - } - @input.CoinSelect() - @form.Footer() { - @input.Passkey(address, handle, challenge) - @form.CancelButton() - } - } - } - } - } -} diff --git a/pkg/vault/handlers/payment.go b/pkg/vault/handlers/payment.go deleted file mode 100644 index d527c5ab8..000000000 --- a/pkg/vault/handlers/payment.go +++ /dev/null @@ -1,93 +0,0 @@ -package handlers - -// -// // Constants for supported payment methods -// const ( -// MethodCard = "basic-card" -// MethodGooglePay = "https://google.com/pay" -// MethodApplePay = "https://apple.com/apple-pay" -// MethodSonrWallet = "https://sonr.id/wallet" -// ) -// -// // InitiatePayment starts the payment request flow -// func InitiatePayment(c echo.Context, request PaymentRequest) error { -// return StartPayment(request).Render(c.Request().Context(), c.Response().Writer) -// } -// -// // Helper functions to create payment requests -// func NewBasicCardPayment(amount float64, currency string, label string) PaymentRequest { -// return PaymentRequest{ -// MethodData: []PaymentMethodData{ -// { -// SupportedMethods: MethodCard, -// Data: map[string]any{ -// "supportedNetworks": []string{"visa", "mastercard"}, -// "supportedTypes": []string{"credit", "debit"}, -// }, -// }, -// }, -// Details: PaymentDetails{ -// Total: PaymentItem{ -// Label: label, -// Amount: Money{ -// Currency: currency, -// Value: formatAmount(amount), -// }, -// }, -// }, -// Options: PaymentOptions{ -// RequestPayerName: true, -// RequestPayerEmail: true, -// }, -// } -// } -// -// // Example usage: -// func PaymentHandler(c echo.Context) error { -// request := NewBasicCardPayment(99.99, "USD", "Product Purchase") -// -// // Add display items -// request.Details.DisplayItems = []PaymentItem{ -// { -// Label: "Product Price", -// Amount: Money{ -// Currency: "USD", -// Value: "89.99", -// }, -// }, -// { -// Label: "Tax", -// Amount: Money{ -// Currency: "USD", -// Value: "10.00", -// }, -// }, -// } -// -// // Add shipping options -// request.Details.ShippingOptions = []ShippingOption{ -// { -// ID: "standard", -// Label: "Standard Shipping", -// Amount: Money{ -// Currency: "USD", -// Value: "0.00", -// }, -// Selected: true, -// }, -// { -// ID: "express", -// Label: "Express Shipping", -// Amount: Money{ -// Currency: "USD", -// Value: "10.00", -// }, -// }, -// } -// -// return InitiatePayment(c, request) -// } -// -// func formatAmount(amount float64) string { -// return fmt.Sprintf("%.2f", amount) -// } diff --git a/pkg/vault/routes/routes.go b/pkg/vault/routes/routes.go deleted file mode 100644 index b5f14f341..000000000 --- a/pkg/vault/routes/routes.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build js && wasm -// +build js,wasm - -// Package vault provides the routes for the Decentralized Web Node (...or Sonr Motr). -package vault - -import ( - "github.com/labstack/echo/v4" - - "github.com/onsonr/sonr/internal/config/motr" -) - -// RegisterRoutes registers the Decentralized Web Node API routes. -func RegisterRoutes(e *echo.Echo, config *motr.Config) { -} diff --git a/pkg/vault/vault.go b/pkg/vault/vault.go deleted file mode 100644 index f7e34c8a3..000000000 --- a/pkg/vault/vault.go +++ /dev/null @@ -1 +0,0 @@ -package vault diff --git a/pkg/vault/views/initial.templ b/pkg/vault/views/initial.templ deleted file mode 100644 index 729477f3d..000000000 --- a/pkg/vault/views/initial.templ +++ /dev/null @@ -1,16 +0,0 @@ -package views - -import ( - "github.com/onsonr/sonr/internal/nebula/hero" - "github.com/onsonr/sonr/internal/nebula/layout" -) - -templ InitialView() { - @layout.View("Sonr.ID") { - @layout.Container() { - @hero.TitleDesc("Sonr.ID", "The decentralized identity layer for the web.") - @hero.StartButton() - @hero.SocialButtonsRow() - } - } -} diff --git a/pkl/matrix.net/Homeserver.pkl b/pkl/matrix.net/Homeserver.pkl index 24f5b4171..af82a8c98 100644 --- a/pkl/matrix.net/Homeserver.pkl +++ b/pkl/matrix.net/Homeserver.pkl @@ -3,7 +3,7 @@ open module matrix.net.Homeserver version = 2 global = new { -server_name = read("env:MATRIX_SERVER_NAME") ?? "" +server_name = read("env:MATRIX_SERVER_NAME") ?? "mx.sonr.id" private_key = "matrix_key.pem" old_private_keys = new Listing {} key_validity_period = "168h0m0s" @@ -21,10 +21,9 @@ max_size_estimated = "1gb" max_age = "1h" } -well_known_server_name = "" -well_known_client_name = read("env:MATRIX_CLIENT_NAME") ?? "" -well_known_sliding_sync_proxy = "" - +well_known_server_name = "sonr.id" +well_known_client_name = read("env:MATRIX_CLIENT_NAME") ?? "sonr.id" +well_known_sliding_sync_proxy = read("env:MATRIX_SLIDING_SYNC_PROXY") ?? "" trusted_third_party_id_servers = new Listing { "matrix.org" "vector.im" @@ -54,7 +53,7 @@ jetstream = new { addresses = new Listing {} disable_tls_validation = false storage_path = "./" -topic_prefix = "Dendrite" +topic_prefix = "_matrix" } metrics = new { diff --git a/deploy/config/sonr.app.pkl b/pkl/sonr.net/App.pkl similarity index 98% rename from deploy/config/sonr.app.pkl rename to pkl/sonr.net/App.pkl index b3f4cf9af..0352e7103 100644 --- a/deploy/config/sonr.app.pkl +++ b/pkl/sonr.net/App.pkl @@ -1,3 +1,5 @@ +module sonr.net.App + import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl" `minimum-gas-prices` = "0usnr" diff --git a/deploy/config/sonr.config.pkl b/pkl/sonr.net/Config.pkl similarity index 99% rename from deploy/config/sonr.config.pkl rename to pkl/sonr.net/Config.pkl index 8355f6dfb..ef4eb9a7a 100644 --- a/deploy/config/sonr.config.pkl +++ b/pkl/sonr.net/Config.pkl @@ -1,3 +1,5 @@ +module sonr.net.Config + import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl" version = "0.38.12" diff --git a/pkl/sonr.net/Hway.pkl b/pkl/sonr.net/Hway.pkl index 707c8eca7..20778417f 100644 --- a/pkl/sonr.net/Hway.pkl +++ b/pkl/sonr.net/Hway.pkl @@ -1,6 +1,5 @@ @go.Package { name = "github.com/onsonr/sonr/internal/config/hway" } - open module sonr.net.Hway import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl" @@ -14,4 +13,4 @@ sonrApiUrl: String = "http://localhost:1317" sonrGrpcUrl: String = "http://localhost:9090" sonrRpcUrl: String = "http://localhost:26657" psqlDSN: String - +turnstileSiteKey: String = read("env:TURNSTILE_SITE_KEY") ?? "" diff --git a/pkl/sonr.net/Motr.pkl b/pkl/sonr.net/Motr.pkl index fee4e88ed..285d45741 100644 --- a/pkl/sonr.net/Motr.pkl +++ b/pkl/sonr.net/Motr.pkl @@ -32,20 +32,3 @@ class Config { sonrChainId: String } -class Environment { - @JsonField - isDevelopment: Boolean - - @JsonField - cacheVersion: String - - @JsonField - httpserverPath: String - - @JsonField - wasmExecPath: String - - @JsonField - wasmPath: String -} - diff --git a/pkl/sonr.net/PklProject b/pkl/sonr.net/PklProject index 16362f342..eba443065 100644 --- a/pkl/sonr.net/PklProject +++ b/pkl/sonr.net/PklProject @@ -18,5 +18,5 @@ amends "../basePklProject.pkl" package { name = "sonr.net" - version = "0.0.1" + version = "0.0.2" } diff --git a/pkl/sonr.orm/UCAN.pkl b/pkl/sonr.net/UCAN.pkl similarity index 90% rename from pkl/sonr.orm/UCAN.pkl rename to pkl/sonr.net/UCAN.pkl index 4c895e36e..507d3a3b6 100644 --- a/pkl/sonr.orm/UCAN.pkl +++ b/pkl/sonr.net/UCAN.pkl @@ -1,6 +1,6 @@ @go.Package { name = "github.com/onsonr/sonr/crypto/ucan/attns" } -module sonr.orm.UCAN +module sonr.net.UCAN import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl" @@ -31,10 +31,16 @@ import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl" // └─ TRANSFER/SEND +// TODO: Move to x/dwn typealias CapVault = "crud/asset" | "crud/authzgrant" | "crud/profile" | "crud/record" | "use/recovery" | "use/sync" | "use/signer" +// TODO: Move to x/did typealias CapAccount = "exec/broadcast" | "exec/query" | "exec/simulate" | "exec/vote" | "exec/delegate" | "exec/invoke" | "exec/send" +// TODO: Move to x/svc typealias CapInterchain = "transfer/swap" | "transfer/send" | "transfer/atomic" | "transfer/batch" | "transfer/p2p" | "transfer/send" +// TODO: Move to x/dwn typealias ResVault = "ks/enclave" | "loc/cid" | "loc/entity" | "loc/ipns" | "addr/sonr" | "chain/code" +// TODO: Move to x/did typealias ResAccount = "acc/sequence" | "acc/number" | "chain/id" | "asset/code" | "authz/grant" +// TODO: Move to x/svc typealias ResInterchain = "channnel/port" | "chain/id" | "chain/name" | "acc/host" | "acc/controller" diff --git a/pkl/sonr.orm/PklProject b/pkl/sonr.orm/PklProject deleted file mode 100644 index 82020b1ae..000000000 --- a/pkl/sonr.orm/PklProject +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//===----------------------------------------------------------------------===// -/// Common types for operations across the sonr ecosystem -amends "../basePklProject.pkl" - -package { - name = "sonr.orm" - version = "0.0.1" -} diff --git a/pkl/sonr.orm/PklProject.deps.json b/pkl/sonr.orm/PklProject.deps.json deleted file mode 100644 index 836079aad..000000000 --- a/pkl/sonr.orm/PklProject.deps.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "schemaVersion": 1, - "resolvedDependencies": {} -} \ No newline at end of file diff --git a/scripts/init_env.sh b/scripts/init_env.sh deleted file mode 100755 index 777273679..000000000 --- a/scripts/init_env.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -set -e - -ROOT_DIR=$(git rev-parse --show-toplevel) -export TURNSTILE_SITE_KEY=$(skate get TURNSTILE_SITE_KEY) -# export KEY="user1" -# export KEY2="user2" -# -# export CHAIN_ID=${CHAIN_ID:-"sonr-testnet-1"} -# export MONIKER="florence" -# export KEYALGO="secp256k1" -# export KEYRING=${KEYRING:-"test"} -# export HOME_DIR=$(eval echo "${HOME_DIR:-"~/.sonr"}") -# export BINARY=${BINARY:-sonrd} -# export DENOM=${DENOM:-usnr} -# -# export CLEAN=${CLEAN:-"true"} -# export RPC=${RPC:-"26657"} -# export REST=${REST:-"1317"} -# export PROFF=${PROFF:-"6969"} -# export P2P=${P2P:-"26656"} -# export GRPC=${GRPC:-"9090"} -# export GRPC_WEB=${GRPC_WEB:-"9091"} -# export ROSETTA=${ROSETTA:-"8420"} -# export BLOCK_TIME=${BLOCK_TIME:-"5s"} - -# Check if process-compose is installed to $ROOT_DIR/build -if [ ! -f "$ROOT_DIR/bin/process-compose" ]; then - echo "process-compose not found. Installing..." - sh -c "$(curl --location https://raw.githubusercontent.com/F1bonacc1/process-compose/main/scripts/get-pc.sh)" -- -d -b $ROOT_DIR/bin -fi - -# Check if pkl-gen-go is installed to $GOPATH/bin -if [ ! -f "$GOPATH/bin/pkl-gen-go" ]; then - echo "pkl-gen-go not found. Installing..." - go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest -fi - -# Check if sqlc is installed to $GOPATH/bin -if [ ! -f "$GOPATH/bin/sqlc" ]; then - echo "sqlc not found. Installing..." - go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest -fi - -# Check if goreleaser is installed to $GOPATH/bin -if [ ! -f "$GOPATH/bin/goreleaser" ]; then - echo "goreleaser not found. Installing..." - go install github.com/goreleaser/goreleaser/v2@latest -fi - -# Check if templ is installed to $GOPATH/bin -if [ ! -f "$GOPATH/bin/templ" ]; then - echo "templ not found. Installing..." - go install github.com/a-h/templ/cmd/templ@latest -fi - diff --git a/scripts/ipfs_config.sh b/scripts/ipfs_config.sh deleted file mode 100755 index c490b5b5f..000000000 --- a/scripts/ipfs_config.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - - -rm -rf ~/.ipfs - -# Initialize IPFS -ipfs init - -# Set up the Cloudflare IPFS gateway peers -ipfs config --json Peering.Peers '[ -{"ID": "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE", "Addrs": ["/dnsaddr/node-1.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z", "Addrs": ["/dnsaddr/node-2.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa", "Addrs": ["/dnsaddr/node-3.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx", "Addrs": ["/dnsaddr/node-4.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ", "Addrs": ["/dnsaddr/node-5.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G", "Addrs": ["/dnsaddr/node-6.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3", "Addrs": ["/dnsaddr/node-7.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP", "Addrs": ["/dnsaddr/node-8.ingress.cloudflare-ipfs.com"]}, -{"ID": "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi", "Addrs": ["/dnsaddr/node-9.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx", "Addrs": ["/dnsaddr/node-10.ingress.cloudflare-ipfs.com"]}, -{"ID": "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5", "Addrs": ["/dnsaddr/node-11.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev", "Addrs": ["/dnsaddr/node-12.ingress.cloudflare-ipfs.com"]} -]' - -# Make sure ipfs is publicly accessible -ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' diff --git a/scripts/test_dop_node.sh b/scripts/test_dop_node.sh index 888e81aba..6d144c19f 100755 --- a/scripts/test_dop_node.sh +++ b/scripts/test_dop_node.sh @@ -17,5 +17,5 @@ TX_INDEX_INDEXER=$(doppler secrets get TX_INDEXER --plain --project sonr --confi TX_INDEX_PSQL_CONN=$(doppler secrets get TX_PSQL_CONN --plain --project sonr --config test) # Run the node setup with all variables properly exported -KEY0_NAME=$ACC0 KEY0_MNEMONIC=$MNEM0 KEY1_NAME=$ACC1 KEY1_MNEMONIC=$MNEM1 CHAIN_ID=$CHAIN_ID TX_INDEX_INDEXER=$TX_INDEX_INDEXER TX_INDEX_PSQL_CONN=$TX_INDEX_PSQL_CONN sh scripts/test_node.sh +CLEAN=true KEY0_NAME=$ACC0 KEY0_MNEMONIC=$MNEM0 KEY1_NAME=$ACC1 KEY1_MNEMONIC=$MNEM1 CHAIN_ID=$CHAIN_ID TX_INDEX_INDEXER=$TX_INDEX_INDEXER TX_INDEX_PSQL_CONN=$TX_INDEX_PSQL_CONN sh scripts/test_node.sh