diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..84fc8e536 --- /dev/null +++ b/.envrc @@ -0,0 +1,7 @@ +# Automatically sets up your devbox environment whenever you cd into this +# directory via our direnv integration: + +eval "$(devbox generate direnv --print-envrc)" + +# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/ +# for more details diff --git a/.github/workflows/pr-merged.yml b/.github/workflows/pr-merged.yml new file mode 100644 index 000000000..07ccc0a85 --- /dev/null +++ b/.github/workflows/pr-merged.yml @@ -0,0 +1,29 @@ +name: PR Merged - Bump Version and Tag + +on: + pull_request: + types: + - closed + branches: + - develop + +permissions: + contents: write + +jobs: + bump-version-and-tag: + if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'feature/') + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Bump version and update changelog + uses: commitizen-tools/commitizen-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Push changes and tag + run: git push && git push --tags diff --git a/.github/workflows/sync-branches.yml b/.github/workflows/sync-branches.yml index f383af556..a06b683eb 100644 --- a/.github/workflows/sync-branches.yml +++ b/.github/workflows/sync-branches.yml @@ -1,61 +1,45 @@ -name: Scheduled Production Release +name: Sync Branches on: - schedule: - - cron: "0 0 * * MON" # Runs every Monday at 00:00 UTC - workflow_dispatch: + push: + tags: + - "*" + permissions: - contents: write # Grants the workflow permission to push changes + contents: write jobs: - production-release: + sync-branches: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 with: - fetch-depth: 0 # Fetch all history for accurate merging - ref: develop # Start from the develop branch + fetch-depth: 0 - - name: Set up Git user + - name: Check if tag is on develop or master + id: check-branch run: | - git config user.name "GitHub Action" - git config user.email "action@github.com" + if git branch -r --contains ${{ github.ref }} | grep -q 'origin/develop\|origin/master'; then + echo "SYNC_NEEDED=true" >> $GITHUB_OUTPUT + else + echo "SYNC_NEEDED=false" >> $GITHUB_OUTPUT + fi - - name: Install Devbox - uses: jetpack-io/devbox-install-action@v0.7.0 + - name: Sync develop to master + if: steps.check-branch.outputs.SYNC_NEEDED == 'true' + uses: devmasx/merge-branch@master + with: + type: now + from_branch: develop + target_branch: master + github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Install dependencies - run: devbox install - - - name: Bump Version with Commitizen - run: | - # Use Commitizen to bump version - devbox shell -- cz bump --yes --changelog - - # Get the new version - NEW_VERSION=$(devbox shell -- cz version --project) - echo "New version: $NEW_VERSION" - - # Tag the new version - git tag -a "v$NEW_VERSION" -m "Release $NEW_VERSION" - - - name: Merge develop into master - run: | - # Switch to master branch - git checkout master - - # Merge develop into master with a merge commit - git merge develop --no-ff -m "Merge develop into master for release v$NEW_VERSION" - - - name: Push Changes and Tags - run: | - git push origin master - git push origin --tags - - - name: Merge back into develop - run: | - git checkout develop - git merge master --no-ff -m "Merge master back into develop after release v$NEW_VERSION" - git push origin develop + - name: Sync master back to develop + if: steps.check-branch.outputs.SYNC_NEEDED == 'true' + uses: devmasx/merge-branch@master + with: + type: now + from_branch: master + target_branch: develop + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 69daa6b83..19afcdb8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ 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} deploy/process-compose.yaml process-compose.yaml RUN devbox run -- echo "Installed Packages." @@ -26,7 +26,7 @@ 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} deploy/process-compose.yaml process-compose.yaml COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . . RUN devbox run -- echo "Installed Packages." diff --git a/Makefile b/Makefile index f50571638..6e91f82c3 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,13 @@ endif install: go.sum go install -mod=readonly $(BUILD_FLAGS) ./cmd/sonrd +deps: + @echo "(go) Installing go dependencies" + @which air > /dev/null || go install github.com/air-verse/air@latest + @which templ > /dev/null || go install github.com/a-h/templ/cmd/templ@latest + @which xcaddy > /dev/null || go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest + @mkdir -p ./bin + @[ ! -f ./bin/caddy ] && xcaddy build --with github.com/caddy-dns/cloudflare && mv ./caddy ./bin/caddy || echo "Caddy already exists" ######################################## ### Tools & dependencies @@ -293,8 +300,6 @@ sh-testnet: mod-tidy .PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet - - ############################################################################### ### templ & vault ### ############################################################################### @@ -303,27 +308,31 @@ sh-testnet: mod-tidy dwn: @echo "(dwn) Building dwn.wasm -> IPFS Vault" - GOOS=js GOARCH=wasm go build -o ./internal/vfs/app.wasm ./internal/dwn/main.go + GOOS=js GOARCH=wasm go build -o ./pkg/vault/app.wasm ./internal/dwn/main.go motr: @echo "(web) Building app.wasm -> Deploy to Cloudflare Workers" GOOS=js GOARCH=wasm go build -o ./web/build/app.wasm ./web/src/main.go -xcaddy: - @echo "(proxy) Building Cloudflare/Caddy proxy" - go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest - mkdir -p ./bin - xcaddy build --with github.com/caddy-dns/cloudflare - mv ./caddy ./bin/caddy - ./bin/caddy adapt > ./config/caddy/caddy.json +templ: + @echo "(templ) Generating templ files" + templ generate + +pkl: + @echo "(pkl) Building PKL" + go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/dwn.pkl + go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/orm.pkl + go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/web.pkl + go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/txns.pkl ipfs-cluster-start: @echo "(ipfs) Starting ipfs-cluster" ipfs-cluster-service init --consensus crdt ipfs-cluster-service daemon -caddy-start: +xcaddy: @echo "(proxy) Starting caddy" +# ./bin/caddy adapt ./config/caddy/Caddyfile > ./config/caddy/caddy.json ./bin/caddy run --config ./config/caddy/caddy.json ############################################################################### diff --git a/cmd/sonrd/main.go b/cmd/sonrd/main.go index fcca52569..5944aa356 100644 --- a/cmd/sonrd/main.go +++ b/cmd/sonrd/main.go @@ -8,12 +8,12 @@ import ( _ "github.com/joho/godotenv/autoload" "github.com/onsonr/sonr/app" - "github.com/onsonr/sonr/internal/tui" + "github.com/onsonr/sonr/internal/cli" ) func main() { rootCmd := NewRootCmd() - tui.AddTUICmds(rootCmd) + cli.AddTUICmds(rootCmd) if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err) diff --git a/caddyfile b/config/caddy/Caddyfile similarity index 100% rename from caddyfile rename to config/caddy/Caddyfile diff --git a/config/caddy/caddy.json b/config/caddy/caddy.json index cb91d1d7d..e69de29bb 100644 --- a/config/caddy/caddy.json +++ b/config/caddy/caddy.json @@ -1 +0,0 @@ -{"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"match":[{"host":["vault.sonr.id"]}],"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"headers","response":{"replace":{"Content-Type":[{"replace":"application/wasm","search_regexp":".wasm"}]},"set":{"Service-Worker-Allowed":["/"]}}},{"encodings":{"gzip":{},"zstd":{}},"handler":"encode","prefer":["zstd","gzip"]}]},{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"rewrite","uri_substring":[{"find":"/{http.regexp.vaultPath.0}","replace":"/ipns/{http.regexp.vaultPath.1}{http.regexp.vaultPath.2}"}]},{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:8080"}]}]}]}],"match":[{"path_regexp":{"name":"vaultPath","pattern":"^/([a-z0-9]{42})(/.*|)$"}}]},{"handle":[{"handler":"file_server","hide":["./Caddyfile"]}]}]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"subjects":["vault.sonr.id"],"issuers":[{"challenges":{"dns":{"provider":{"api_token":"{env.CLOUDFLARE_API_TOKEN}","name":"cloudflare"},"resolvers":["1.1.1.1"]}},"email":"team@sonr.id","module":"acme"}]}]}}}} diff --git a/config/dwn/Config.pkl.go b/config/dwn/Config.pkl.go index 2a9caa0e3..69b448bea 100644 --- a/config/dwn/Config.pkl.go +++ b/config/dwn/Config.pkl.go @@ -7,4 +7,6 @@ type Config struct { Sonr *Sonr `pkl:"sonr" json:"sonr,omitempty"` Motr *Motr `pkl:"motr" json:"motr,omitempty"` + + Schema *Schema `pkl:"schema" json:"schema,omitempty"` } diff --git a/config/dwn/Dwn.pkl.go b/config/dwn/Dwn.pkl.go index 3dcb752ea..8bc5e41f5 100644 --- a/config/dwn/Dwn.pkl.go +++ b/config/dwn/Dwn.pkl.go @@ -8,7 +8,6 @@ import ( ) type Dwn struct { - Config any `pkl:"config"` } // LoadFromPath loads the pkl module at the given path and evaluates it into a Dwn diff --git a/config/dwn/Schema.pkl.go b/config/dwn/Schema.pkl.go new file mode 100644 index 000000000..4ded3ac6a --- /dev/null +++ b/config/dwn/Schema.pkl.go @@ -0,0 +1,24 @@ +// Code generated from Pkl module `dwn`. DO NOT EDIT. +package dwn + +type Schema struct { + Version int `pkl:"version"` + + Account string `pkl:"account" json:"account,omitempty"` + + Asset string `pkl:"asset" json:"asset,omitempty"` + + Chain string `pkl:"chain" json:"chain,omitempty"` + + Credential string `pkl:"credential" json:"credential,omitempty"` + + Jwk string `pkl:"jwk" json:"jwk,omitempty"` + + Grant string `pkl:"grant" json:"grant,omitempty"` + + Keyshare string `pkl:"keyshare" json:"keyshare,omitempty"` + + PublicKey string `pkl:"publicKey" json:"publicKey,omitempty"` + + Profile string `pkl:"profile" json:"profile,omitempty"` +} diff --git a/config/dwn/init.pkl.go b/config/dwn/init.pkl.go index a966d2720..5654e722a 100644 --- a/config/dwn/init.pkl.go +++ b/config/dwn/init.pkl.go @@ -9,4 +9,5 @@ func init() { pkl.RegisterMapping("dwn#IPFS", IPFS{}) pkl.RegisterMapping("dwn#Sonr", Sonr{}) pkl.RegisterMapping("dwn#Motr", Motr{}) + pkl.RegisterMapping("dwn#Schema", Schema{}) } diff --git a/config/pkl/dwn.pkl b/config/pkl/dwn.pkl index 9d747b863..ea4cea655 100644 --- a/config/pkl/dwn.pkl +++ b/config/pkl/dwn.pkl @@ -21,6 +21,9 @@ class Config { @JsonField motr: Motr + + @JsonField + schema: Schema } class IPFS { @@ -42,6 +45,37 @@ class Motr { origin: String } +class Schema { + version: Int + + @JsonField + account: String + + @JsonField + asset: String + + @JsonField + chain: String + + @JsonField + credential: String + + @JsonField + jwk: String + + @JsonField + grant: String + + @JsonField + keyshare: String + + @JsonField + publicKey: String + + @JsonField + profile: String +} + class Sonr { @JsonField apiUrl: String @@ -60,16 +94,4 @@ class Sonr { } -config = new Config { - ipfs = new IPFS { - apiUrl = "https://api.sonr-ipfs.land" - gatewayUrl = "https://ipfs.sonr.land" - } - sonr = new Sonr { - apiUrl = "https://api.sonr.land" - grpcUrl = "https://grpc.sonr.land" - rpcUrl = "https://rpc.sonr.land" - webSocketUrl = "wss://rpc.sonr.land/ws" - } -} diff --git a/.air.toml b/deploy/air.toml similarity index 100% rename from .air.toml rename to deploy/air.toml diff --git a/docker-compose.yaml b/deploy/docker-compose.yaml similarity index 100% rename from docker-compose.yaml rename to deploy/docker-compose.yaml diff --git a/deploy/process-compose.dev.yaml b/deploy/process-compose.dev.yaml new file mode 100644 index 000000000..9c032f704 --- /dev/null +++ b/deploy/process-compose.dev.yaml @@ -0,0 +1,25 @@ +version: "0.6" + +processes: + sonr: + namespace: testnet + command: "devbox run sonr" + restart: on_failure + max_restarts: 3 + depends: + + caddy: + namespace: testnet + command: "devbox run xcaddy" + restart: on_failure + max_restarts: 3 + depends: + - sonr + + air: + namespace: testnet + command: "devbox run air" + restart: on_failure + max_restarts: 3 + depends: + - sonr diff --git a/process-compose.yaml b/deploy/process-compose.yaml similarity index 88% rename from process-compose.yaml rename to deploy/process-compose.yaml index a42170e72..bac7f39b2 100644 --- a/process-compose.yaml +++ b/deploy/process-compose.yaml @@ -10,7 +10,7 @@ processes: caddy: namespace: testnet - command: "make caddy-start" + command: "make xcaddy" restart: on_failure max_restarts: 3 depends: diff --git a/devbox.json b/devbox.json index 2794c3221..fc2339b91 100644 --- a/devbox.json +++ b/devbox.json @@ -2,11 +2,9 @@ "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json", "packages": [ "go@1.22", - "templ@latest", "bun@latest", "ipfs-cluster@latest", - "air@latest", - "commitizen@latest" + "process-compose@latest" ], "env": { "CLOUDFLARE_API_TOKEN": "$CLOUDFLARE_API_TOKEN", @@ -14,49 +12,56 @@ "PROJECT_BIN": "$PROJECT_DIR/bin", "GOPATH": "$HOME/go", "PATH": "$HOME/go/bin:$PROJECT_BIN:$PATH", + "TEMPL_EXPERIMENT": "rawgo", "CHAIN_ID": "sonr-testnet-1", "DENOM": "usnr", "KEYRING": "test", - "MONIKER": "florence" + "MONIKER": "florence", + "ENV": "$ENVIRONMENT" }, "shell": { "scripts": { "install": [ "make install" ], + "install:deps": [ + "make deps" + ], "build": [ - "make build", - "make local-image" + "make build" ], "build:dwn": [ - "templ generate", "make dwn" ], + "build:image": [ + "make local-image" + ], "build:motr": [ - "templ generate", "make motr" ], "gen:proto": [ "make proto-gen" ], "gen:pkl": [ - "go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/dwn.pkl", - "go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/orm.pkl", - "go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/web.pkl", - "go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/txns.pkl" + "make pkl" ], "gen:templ": [ - "templ generate" + "make templ" ], - "dev": [ - "air" + "serve:local": [ + "process-compose -f ./deploy/process-compose.dev.yaml" ], - "start-proxy": [ - "./bin/caddy run --config ./config/caddy/caddy.conf" + "serve:testnet": [ + "process-compose -f ./deploy/process-compose.yaml" ], - "testnet": [ - "make xcaddy", - "devbox services up" + "air": [ + "air -c ./deploy/air.toml" + ], + "xcaddy": [ + "make xcaddy" + ], + "sonr": [ + "make sh-testnet" ] } } diff --git a/go.mod b/go.mod index 2c4c4c64c..6b3704989 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( cosmossdk.io/x/nft v0.1.0 cosmossdk.io/x/tx v0.13.3 cosmossdk.io/x/upgrade v0.1.1 - github.com/a-h/templ v0.2.771 + github.com/a-h/templ v0.2.778 github.com/apple/pkl-go v0.8.0 github.com/btcsuite/btcd/btcec/v2 v2.3.3 github.com/charmbracelet/bubbles v0.19.0 diff --git a/go.sum b/go.sum index f532766b3..29da40697 100644 --- a/go.sum +++ b/go.sum @@ -832,8 +832,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/a-h/templ v0.2.771 h1:4KH5ykNigYGGpCe0fRJ7/hzwz72k3qFqIiiLLJskbSo= -github.com/a-h/templ v0.2.771/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w= +github.com/a-h/templ v0.2.778 h1:VzhOuvWECrwOec4790lcLlZpP4Iptt5Q4K9aFxQmtaM= +github.com/a-h/templ v0.2.778/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= diff --git a/internal/tui/dexmodel/dexmodel.go b/internal/cli/dexmodel/dexmodel.go similarity index 100% rename from internal/tui/dexmodel/dexmodel.go rename to internal/cli/dexmodel/dexmodel.go diff --git a/internal/tui/tui.go b/internal/cli/tui.go similarity index 91% rename from internal/tui/tui.go rename to internal/cli/tui.go index 0ac4d76c0..f49f6c7cf 100644 --- a/internal/tui/tui.go +++ b/internal/cli/tui.go @@ -1,12 +1,12 @@ -package tui +package cli import ( "fmt" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/onsonr/sonr/internal/tui/dexmodel" - "github.com/onsonr/sonr/internal/tui/txmodel" + "github.com/onsonr/sonr/internal/cli/dexmodel" + "github.com/onsonr/sonr/internal/cli/txmodel" "github.com/spf13/cobra" ) diff --git a/internal/tui/txmodel/txmodel.go b/internal/cli/txmodel/txmodel.go similarity index 100% rename from internal/tui/txmodel/txmodel.go rename to internal/cli/txmodel/txmodel.go diff --git a/internal/dwn/front/scripts/api.go b/internal/dwn/front/scripts/api.go deleted file mode 100644 index 3856deda2..000000000 --- a/internal/dwn/front/scripts/api.go +++ /dev/null @@ -1,6 +0,0 @@ -package scripts - -type ( - DatabaseAPI interface{} - NavigatorAPI interface{} -) diff --git a/internal/dwn/front/scripts/database.templ b/internal/dwn/front/scripts/database.templ deleted file mode 100644 index 2d6c6ffd8..000000000 --- a/internal/dwn/front/scripts/database.templ +++ /dev/null @@ -1,21 +0,0 @@ -package scripts - -templ InitializeDatabase() { - -} diff --git a/internal/dwn/front/scripts/database_templ.go b/internal/dwn/front/scripts/database_templ.go deleted file mode 100644 index 58dfb6a73..000000000 --- a/internal/dwn/front/scripts/database_templ.go +++ /dev/null @@ -1,37 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.771 -package scripts - -//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 InitializeDatabase() templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var1 := templ.GetChildren(ctx) - if templ_7745c5c3_Var1 == nil { - templ_7745c5c3_Var1 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/dwn/front/scripts/navigator.templ b/internal/dwn/front/scripts/navigator.templ deleted file mode 100644 index 8d61f5785..000000000 --- a/internal/dwn/front/scripts/navigator.templ +++ /dev/null @@ -1,41 +0,0 @@ -package scripts - -templ CreateCredential() { - -} - -templ GetCredential() { - -} diff --git a/internal/dwn/front/scripts/navigator_templ.go b/internal/dwn/front/scripts/navigator_templ.go deleted file mode 100644 index 4c6db52ff..000000000 --- a/internal/dwn/front/scripts/navigator_templ.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.771 -package scripts - -//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 CreateCredential() templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var1 := templ.GetChildren(ctx) - if templ_7745c5c3_Var1 == nil { - templ_7745c5c3_Var1 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func GetCredential() templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_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 - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/internal/dwn/main.go b/internal/dwn/main.go index 92b4cb8dd..6aad26089 100644 --- a/internal/dwn/main.go +++ b/internal/dwn/main.go @@ -4,17 +4,138 @@ package main import ( + "bytes" + "fmt" + "io" + "net/http" + "net/http/httptest" + "strings" + "syscall/js" + "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front" + promise "github.com/nlepage/go-js-promise" "github.com/onsonr/sonr/internal/dwn/handlers" "github.com/onsonr/sonr/internal/dwn/middleware" - "github.com/onsonr/sonr/internal/vfs" + "github.com/onsonr/sonr/pkg/nebula" ) func main() { e := echo.New() e.Use(middleware.UseSession) - front.RegisterViews(e) + nebula.RouteViews(e) handlers.RegisterState(e) - vfs.Serve(e) + Serve(e) +} + +// Serve serves HTTP requests using handler or http.DefaultServeMux if handler is nil. +func Serve(handler http.Handler) func() { + h := handler + if h == nil { + h = http.DefaultServeMux + } + + prefix := js.Global().Get("wasmhttp").Get("path").String() + for strings.HasSuffix(prefix, "/") { + prefix = strings.TrimSuffix(prefix, "/") + } + + if prefix != "" { + mux := http.NewServeMux() + mux.Handle(prefix+"/", http.StripPrefix(prefix, h)) + h = mux + } + + cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resPromise, resolve, reject := promise.New() + + go func() { + defer func() { + if r := recover(); r != nil { + if err, ok := r.(error); ok { + reject(fmt.Sprintf("wasmhttp: panic: %+v\n", err)) + } else { + reject(fmt.Sprintf("wasmhttp: panic: %v\n", r)) + } + } + }() + + res := NewResponseRecorder() + + h.ServeHTTP(res, Request(args[0])) + + resolve(res.JSResponse()) + }() + + return resPromise + }) + + js.Global().Get("wasmhttp").Call("setHandler", cb) + + return cb.Release +} + +// Request builds and returns the equivalent http.Request +func Request(r js.Value) *http.Request { + jsBody := js.Global().Get("Uint8Array").New(promise.Await(r.Call("arrayBuffer"))) + body := make([]byte, jsBody.Get("length").Int()) + js.CopyBytesToGo(body, jsBody) + + req := httptest.NewRequest( + r.Get("method").String(), + r.Get("url").String(), + bytes.NewBuffer(body), + ) + + headersIt := r.Get("headers").Call("entries") + for { + e := headersIt.Call("next") + if e.Get("done").Bool() { + break + } + v := e.Get("value") + req.Header.Set(v.Index(0).String(), v.Index(1).String()) + } + + return req +} + +// ResponseRecorder uses httptest.ResponseRecorder to build a JS Response +type ResponseRecorder struct { + *httptest.ResponseRecorder +} + +// NewResponseRecorder returns a new ResponseRecorder +func NewResponseRecorder() ResponseRecorder { + return ResponseRecorder{httptest.NewRecorder()} +} + +// JSResponse builds and returns the equivalent JS Response +func (rr ResponseRecorder) JSResponse() js.Value { + res := rr.Result() + + body := js.Undefined() + if res.ContentLength != 0 { + b, err := io.ReadAll(res.Body) + if err != nil { + panic(err) + } + body = js.Global().Get("Uint8Array").New(len(b)) + js.CopyBytesToJS(body, b) + } + + init := make(map[string]interface{}, 2) + + if res.StatusCode != 0 { + init["status"] = res.StatusCode + } + + if len(res.Header) != 0 { + headers := make(map[string]interface{}, len(res.Header)) + for k := range res.Header { + headers[k] = res.Header.Get(k) + } + init["headers"] = headers + } + + return js.Global().Get("Response").New(body, init) } diff --git a/internal/tui/authmodel/authmodel.go b/internal/tui/authmodel/authmodel.go deleted file mode 100644 index 2f83c115f..000000000 --- a/internal/tui/authmodel/authmodel.go +++ /dev/null @@ -1,322 +0,0 @@ -package txmodel - -import ( - "fmt" - "strings" - - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/huh" - "github.com/charmbracelet/lipgloss" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -const maxWidth = 100 - -var ( - red = lipgloss.AdaptiveColor{Light: "#FE5F86", Dark: "#FE5F86"} - indigo = lipgloss.AdaptiveColor{Light: "#5A56E0", Dark: "#7571F9"} - green = lipgloss.AdaptiveColor{Light: "#02BA84", Dark: "#02BF87"} -) - -type Styles struct { - Base, - HeaderText, - Status, - StatusHeader, - Highlight, - ErrorHeaderText, - Help lipgloss.Style -} - -func NewStyles(lg *lipgloss.Renderer) *Styles { - s := Styles{} - s.Base = lg.NewStyle(). - Padding(1, 2, 0, 1) - s.HeaderText = lg.NewStyle(). - Foreground(indigo). - Bold(true). - Padding(0, 1, 0, 1) - s.Status = lg.NewStyle(). - Border(lipgloss.RoundedBorder()). - BorderForeground(indigo). - PaddingLeft(1). - MarginTop(1) - s.StatusHeader = lg.NewStyle(). - Foreground(green). - Bold(true) - s.Highlight = lg.NewStyle(). - Foreground(lipgloss.Color("212")) - s.ErrorHeaderText = s.HeaderText. - Foreground(red) - s.Help = lg.NewStyle(). - Foreground(lipgloss.Color("240")) - return &s -} - -type state int - -const ( - statusNormal state = iota - stateDone -) - -type Model struct { - state state - lg *lipgloss.Renderer - styles *Styles - form *huh.Form - width int - message *tx.TxBody -} - -func NewModel() Model { - m := Model{width: maxWidth} - m.lg = lipgloss.DefaultRenderer() - m.styles = NewStyles(m.lg) - - m.form = huh.NewForm( - huh.NewGroup( - huh.NewInput(). - Key("from"). - Title("From Address"). - Placeholder("cosmos1..."). - Validate(func(s string) error { - if !strings.HasPrefix(s, "cosmos1") { - return fmt.Errorf("invalid address format") - } - return nil - }), - - huh.NewInput(). - Key("to"). - Title("To Address"). - Placeholder("cosmos1..."). - Validate(func(s string) error { - if !strings.HasPrefix(s, "cosmos1") { - return fmt.Errorf("invalid address format") - } - return nil - }), - - huh.NewInput(). - Key("amount"). - Title("Amount"). - Placeholder("100"). - Validate(func(s string) error { - if _, err := sdk.ParseCoinNormalized(s + "atom"); err != nil { - return fmt.Errorf("invalid coin amount") - } - return nil - }), - - huh.NewSelect[string](). - Key("denom"). - Title("Denom"). - Options(huh.NewOptions("atom", "osmo", "usnr", "snr")...), - - huh.NewInput(). - Key("memo"). - Title("Memo"). - Placeholder("Optional"), - - huh.NewConfirm(). - Key("done"). - Title("Ready to convert?"). - Validate(func(v bool) error { - if !v { - return fmt.Errorf("Please confirm when you're ready to convert") - } - return nil - }). - Affirmative("Yes, convert!"). - Negative("Not yet"), - ), - ). - WithWidth(60). - WithShowHelp(false). - WithShowErrors(false) - - return m -} - -func (m Model) Init() tea.Cmd { - return m.form.Init() -} - -func min(x, y int) int { - if x > y { - return y - } - return x -} - -func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - switch msg := msg.(type) { - case tea.WindowSizeMsg: - m.width = min(msg.Width, maxWidth) - m.styles.Base.GetHorizontalFrameSize() - case tea.KeyMsg: - switch msg.String() { - case "esc", "ctrl+c", "q": - return m, tea.Quit - } - } - - var cmds []tea.Cmd - - form, cmd := m.form.Update(msg) - if f, ok := form.(*huh.Form); ok { - m.form = f - cmds = append(cmds, cmd) - } - - if m.form.State == huh.StateCompleted { - m.buildMessage() - cmds = append(cmds, tea.Quit) - } - - return m, tea.Batch(cmds...) -} - -func (m Model) View() string { - s := m.styles - - switch m.form.State { - case huh.StateCompleted: - pklCode := m.generatePkl() - messageView := m.getMessageView() - var b strings.Builder - fmt.Fprintf(&b, "Final Tx:\n\n%s\n\n%s", pklCode, messageView) - return s.Status.Margin(0, 1).Padding(1, 2).Width(80).Render(b.String()) + "\n\n" - default: - var schemaType string - if m.form.GetString("schemaType") != "" { - schemaType = "Schema Type: " + m.form.GetString("schemaType") - } - - v := strings.TrimSuffix(m.form.View(), "\n\n") - form := m.lg.NewStyle().Margin(1, 0).Render(v) - - var status string - { - preview := "(Preview will appear here)" - if m.form.GetString("schema") != "" { - preview = m.generatePkl() - } - - const statusWidth = 40 - statusMarginLeft := m.width - statusWidth - lipgloss.Width(form) - s.Status.GetMarginRight() - status = s.Status. - Height(lipgloss.Height(form)). - Width(statusWidth). - MarginLeft(statusMarginLeft). - Render(s.StatusHeader.Render("Pkl Preview") + "\n" + - schemaType + "\n\n" + - preview) - } - - errors := m.form.Errors() - header := m.appBoundaryView("Sonr TX Builder") - if len(errors) > 0 { - header = m.appErrorBoundaryView(m.errorView()) - } - body := lipgloss.JoinHorizontal(lipgloss.Top, form, status) - - footer := m.appBoundaryView(m.form.Help().ShortHelpView(m.form.KeyBinds())) - if len(errors) > 0 { - footer = m.appErrorBoundaryView("") - } - - return s.Base.Render(header + "\n" + body + "\n\n" + footer) - } -} - -func (m Model) errorView() string { - var s string - for _, err := range m.form.Errors() { - s += err.Error() - } - return s -} - -func (m Model) appBoundaryView(text string) string { - return lipgloss.PlaceHorizontal( - m.width, - lipgloss.Left, - m.styles.HeaderText.Render(text), - lipgloss.WithWhitespaceChars("="), - lipgloss.WithWhitespaceForeground(indigo), - ) -} - -func (m Model) appErrorBoundaryView(text string) string { - return lipgloss.PlaceHorizontal( - m.width, - lipgloss.Left, - m.styles.ErrorHeaderText.Render(text), - lipgloss.WithWhitespaceChars("="), - lipgloss.WithWhitespaceForeground(red), - ) -} - -func (m Model) generatePkl() string { - schemaType := m.form.GetString("schemaType") - schema := m.form.GetString("schema") - - // This is a placeholder for the actual conversion logic - // In a real implementation, you would parse the schema and generate Pkl code - return fmt.Sprintf("// Converted from %s\n\nclass ConvertedSchema {\n // TODO: Implement conversion from %s\n // Original schema:\n /*\n%s\n */\n}", schemaType, schemaType, schema) -} - -func (m *Model) buildMessage() { - from := m.form.GetString("from") - to := m.form.GetString("to") - amount := m.form.GetString("amount") - denom := m.form.GetString("denom") - memo := m.form.GetString("memo") - - coin, _ := sdk.ParseCoinNormalized(fmt.Sprintf("%s%s", amount, denom)) - sendMsg := &banktypes.MsgSend{ - FromAddress: from, - ToAddress: to, - Amount: sdk.NewCoins(coin), - } - - anyMsg, _ := codectypes.NewAnyWithValue(sendMsg) - m.message = &tx.TxBody{ - Messages: []*codectypes.Any{anyMsg}, - Memo: memo, - } -} - -func (m Model) getMessageView() string { - if m.message == nil { - return "Current Message: None" - } - - interfaceRegistry := codectypes.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) - jsonBytes, _ := marshaler.MarshalJSON(m.message) - - return fmt.Sprintf("Current Message:\n%s", string(jsonBytes)) -} - -func RunTUIForm() (*tx.TxBody, error) { - m := NewModel() - p := tea.NewProgram(m) - - finalModel, err := p.Run() - if err != nil { - return nil, fmt.Errorf("failed to run program: %w", err) - } - - finalM, ok := finalModel.(Model) - if !ok || finalM.message == nil { - return nil, fmt.Errorf("form not completed") - } - - return finalM.message, nil -} diff --git a/internal/vfs/index.html b/internal/vfs/index.html deleted file mode 100644 index 4820ee925..000000000 --- a/internal/vfs/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - Sonr DWN - - - -
-
Loading...
-
- - diff --git a/internal/vfs/server.go b/internal/vfs/server.go deleted file mode 100644 index 73c640f9b..000000000 --- a/internal/vfs/server.go +++ /dev/null @@ -1,128 +0,0 @@ -//go:build js && wasm - -package vfs - -import ( - "bytes" - "fmt" - "io" - "net/http" - "net/http/httptest" - "strings" - "syscall/js" - - promise "github.com/nlepage/go-js-promise" -) - -// Serve serves HTTP requests using handler or http.DefaultServeMux if handler is nil. -func Serve(handler http.Handler) func() { - h := handler - if h == nil { - h = http.DefaultServeMux - } - - prefix := js.Global().Get("wasmhttp").Get("path").String() - for strings.HasSuffix(prefix, "/") { - prefix = strings.TrimSuffix(prefix, "/") - } - - if prefix != "" { - mux := http.NewServeMux() - mux.Handle(prefix+"/", http.StripPrefix(prefix, h)) - h = mux - } - - cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - resPromise, resolve, reject := promise.New() - - go func() { - defer func() { - if r := recover(); r != nil { - if err, ok := r.(error); ok { - reject(fmt.Sprintf("wasmhttp: panic: %+v\n", err)) - } else { - reject(fmt.Sprintf("wasmhttp: panic: %v\n", r)) - } - } - }() - - res := NewResponseRecorder() - - h.ServeHTTP(res, Request(args[0])) - - resolve(res.JSResponse()) - }() - - return resPromise - }) - - js.Global().Get("wasmhttp").Call("setHandler", cb) - - return cb.Release -} - -// Request builds and returns the equivalent http.Request -func Request(r js.Value) *http.Request { - jsBody := js.Global().Get("Uint8Array").New(promise.Await(r.Call("arrayBuffer"))) - body := make([]byte, jsBody.Get("length").Int()) - js.CopyBytesToGo(body, jsBody) - - req := httptest.NewRequest( - r.Get("method").String(), - r.Get("url").String(), - bytes.NewBuffer(body), - ) - - headersIt := r.Get("headers").Call("entries") - for { - e := headersIt.Call("next") - if e.Get("done").Bool() { - break - } - v := e.Get("value") - req.Header.Set(v.Index(0).String(), v.Index(1).String()) - } - - return req -} - -// ResponseRecorder uses httptest.ResponseRecorder to build a JS Response -type ResponseRecorder struct { - *httptest.ResponseRecorder -} - -// NewResponseRecorder returns a new ResponseRecorder -func NewResponseRecorder() ResponseRecorder { - return ResponseRecorder{httptest.NewRecorder()} -} - -// JSResponse builds and returns the equivalent JS Response -func (rr ResponseRecorder) JSResponse() js.Value { - res := rr.Result() - - body := js.Undefined() - if res.ContentLength != 0 { - b, err := io.ReadAll(res.Body) - if err != nil { - panic(err) - } - body = js.Global().Get("Uint8Array").New(len(b)) - js.CopyBytesToJS(body, b) - } - - init := make(map[string]interface{}, 2) - - if res.StatusCode != 0 { - init["status"] = res.StatusCode - } - - if len(res.Header) != 0 { - headers := make(map[string]interface{}, len(res.Header)) - for k := range res.Header { - headers[k] = res.Header.Get(k) - } - init["headers"] = headers - } - - return js.Global().Get("Response").New(body, init) -} diff --git a/pkg/builder/schema.go b/pkg/builder/schema.go new file mode 100644 index 000000000..212aae6a2 --- /dev/null +++ b/pkg/builder/schema.go @@ -0,0 +1,22 @@ +package builder + +import "github.com/onsonr/sonr/config/dwn" + +type SchemaVersion = int + +var CurrentSchemaVersion SchemaVersion = 1 + +func DefaultSchema() *dwn.Schema { + return &dwn.Schema{ + Version: CurrentSchemaVersion, + Account: "++, id, name, address, publicKey, chainCode, index, controller, createdAt", + Asset: "++, id, name, symbol, decimals, chainCode, createdAt", + Chain: "++, id, name, networkId, chainCode, createdAt", + Credential: "++, id, subject, controller, attestationType, origin, label, deviceId, credentialId, publicKey, transport, signCount, userPresent, userVerified, backupEligible, backupState, cloneWarning, createdAt, updatedAt", + Jwk: "++, kty, crv, x, y, n, e", + Grant: "++, subject, controller, origin, token, scopes, createdAt, updatedAt", + Keyshare: "++, id, data, role, createdAt, lastRefreshed", + PublicKey: "++, role, algorithm, encoding, curve, key_type, raw, jwk", + Profile: "++, id, subject, controller, originUri, publicMetadata, privateMetadata, createdAt, updatedAt", + } +} diff --git a/pkg/builder/vault.go b/pkg/builder/vault.go new file mode 100644 index 000000000..a17c48330 --- /dev/null +++ b/pkg/builder/vault.go @@ -0,0 +1,53 @@ +package builder + +import ( + "github.com/cosmos/cosmos-sdk/types/bech32" + "github.com/ipfs/boxo/files" + "github.com/onsonr/crypto/mpc" + "github.com/onsonr/sonr/pkg/vault" +) + +type Vault struct { + FS files.Node + ValKs mpc.Share +} + +func NewVault(subject string, origin string, chainID string) (*Vault, error) { + shares, err := mpc.GenerateKeyshares() + var ( + valKs = shares[0] + usrKs = shares[1] + ) + usrKsJSON, err := usrKs.Marshal() + if err != nil { + return nil, err + } + sonrAddr, err := bech32.ConvertAndEncode("idx", valKs.GetPublicKey()) + if err != nil { + return nil, err + } + + cnfg := vault.NewConfig(usrKsJSON, sonrAddr, chainID, DefaultSchema()) + cnfgFile, err := vault.MarshalConfigFile(cnfg) + if err != nil { + return nil, err + } + + idxFile, err := vault.IndexHTMLFile(cnfg) + if err != nil { + return nil, err + } + + fileMap := map[string]files.Node{ + "config.json": cnfgFile, + "motr.mjs": vault.MotrMJSFile(), + "sw.js": vault.SWJSFile(), + "app.wasm": vault.DWNWasmFile(), + "index.html": idxFile, + } + + return &Vault{ + FS: files.NewMapDirectory(fileMap), + ValKs: valKs, + }, nil +} diff --git a/internal/dwn/front/blocks/alert.templ b/pkg/nebula/blocks/alert.templ similarity index 100% rename from internal/dwn/front/blocks/alert.templ rename to pkg/nebula/blocks/alert.templ diff --git a/internal/dwn/front/blocks/alert_templ.go b/pkg/nebula/blocks/alert_templ.go similarity index 94% rename from internal/dwn/front/blocks/alert_templ.go rename to pkg/nebula/blocks/alert_templ.go index 8f0ef422d..9b00895d4 100644 --- a/internal/dwn/front/blocks/alert_templ.go +++ b/pkg/nebula/blocks/alert_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -15,6 +15,9 @@ func Alert(variant Variant, icon Icon, title, message string) templ.Component { func alertElement(attrs templ.Attributes, title, message string, icon templ.Component) 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() { @@ -53,7 +56,7 @@ func alertElement(attrs templ.Attributes, title, message string, icon templ.Comp 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/dwn/front/blocks/alert.templ`, Line: 10, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/alert.templ`, Line: 10, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -66,7 +69,7 @@ func alertElement(attrs templ.Attributes, title, message string, icon templ.Comp var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(message) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/alert.templ`, Line: 11, Col: 43} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/alert.templ`, Line: 11, Col: 43} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { diff --git a/internal/dwn/front/blocks/badge.templ b/pkg/nebula/blocks/badge.templ similarity index 100% rename from internal/dwn/front/blocks/badge.templ rename to pkg/nebula/blocks/badge.templ diff --git a/internal/dwn/front/blocks/badge_templ.go b/pkg/nebula/blocks/badge_templ.go similarity index 97% rename from internal/dwn/front/blocks/badge_templ.go rename to pkg/nebula/blocks/badge_templ.go index 335ca7cc4..202f7ab97 100644 --- a/internal/dwn/front/blocks/badge_templ.go +++ b/pkg/nebula/blocks/badge_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime" func PoweredBySonr() 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() { diff --git a/internal/dwn/front/blocks/blocks.go b/pkg/nebula/blocks/blocks.go similarity index 100% rename from internal/dwn/front/blocks/blocks.go rename to pkg/nebula/blocks/blocks.go diff --git a/internal/dwn/front/blocks/button.templ b/pkg/nebula/blocks/button.templ similarity index 100% rename from internal/dwn/front/blocks/button.templ rename to pkg/nebula/blocks/button.templ diff --git a/internal/dwn/front/blocks/button_templ.go b/pkg/nebula/blocks/button_templ.go similarity index 92% rename from internal/dwn/front/blocks/button_templ.go rename to pkg/nebula/blocks/button_templ.go index 5101c3270..e5dd0aade 100644 --- a/internal/dwn/front/blocks/button_templ.go +++ b/pkg/nebula/blocks/button_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -87,6 +87,9 @@ func Button(opts ...ButtonOpt) templ.Component { func renderButton(attrs templ.Attributes) 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() { @@ -129,6 +132,9 @@ func renderButton(attrs templ.Attributes) templ.Component { func renderHxGetButton(c *button, attrs templ.Attributes) 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() { @@ -151,7 +157,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxGet) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 25} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -164,7 +170,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTarget) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 69} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -177,7 +183,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTrigger) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 96} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 96} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -190,7 +196,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxSwap) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 117} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 117} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -223,6 +229,9 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component { func renderHxPostButton(c *button, attrs templ.Attributes) 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() { @@ -245,7 +254,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxPost) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -258,7 +267,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTarget) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -271,7 +280,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTrigger) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 79} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 79} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -284,7 +293,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxSwap) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 100} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 100} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { diff --git a/internal/dwn/front/blocks/card.templ b/pkg/nebula/blocks/card.templ similarity index 100% rename from internal/dwn/front/blocks/card.templ rename to pkg/nebula/blocks/card.templ diff --git a/internal/dwn/front/blocks/card_templ.go b/pkg/nebula/blocks/card_templ.go similarity index 94% rename from internal/dwn/front/blocks/card_templ.go rename to pkg/nebula/blocks/card_templ.go index 5314204d6..686fd68a9 100644 --- a/internal/dwn/front/blocks/card_templ.go +++ b/pkg/nebula/blocks/card_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -15,6 +15,9 @@ func Card(id string, size Size) templ.Component { func renderCard(id string, attrs templ.Attributes) 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() { @@ -37,7 +40,7 @@ func renderCard(id string, attrs templ.Attributes) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(id) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/card.templ`, Line: 8, Col: 13} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/card.templ`, Line: 8, Col: 13} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -70,6 +73,9 @@ func renderCard(id string, attrs templ.Attributes) templ.Component { func ProfileCard() 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() { diff --git a/internal/dwn/front/blocks/fonts.templ b/pkg/nebula/blocks/fonts.templ similarity index 100% rename from internal/dwn/front/blocks/fonts.templ rename to pkg/nebula/blocks/fonts.templ diff --git a/internal/dwn/front/blocks/fonts_templ.go b/pkg/nebula/blocks/fonts_templ.go similarity index 88% rename from internal/dwn/front/blocks/fonts_templ.go rename to pkg/nebula/blocks/fonts_templ.go index 9a07c2c8f..8141bc7c2 100644 --- a/internal/dwn/front/blocks/fonts_templ.go +++ b/pkg/nebula/blocks/fonts_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -27,6 +27,9 @@ func Text(content string) templ.Component { func renderText(level int, 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() { @@ -51,7 +54,7 @@ func renderText(level int, text string) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(text) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 23, Col: 10} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 23, Col: 10} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -69,7 +72,7 @@ func renderText(level int, text string) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(text) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 27, Col: 10} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 27, Col: 10} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -87,7 +90,7 @@ func renderText(level int, text string) templ.Component { 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/dwn/front/blocks/fonts.templ`, Line: 31, Col: 10} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 31, Col: 10} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -105,7 +108,7 @@ func renderText(level int, text string) templ.Component { 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: `internal/dwn/front/blocks/fonts.templ`, Line: 35, Col: 10} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 35, Col: 10} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -123,6 +126,9 @@ func renderText(level int, text string) templ.Component { func renderLink(attrs templ.Attributes, 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() { @@ -153,7 +159,7 @@ func renderLink(attrs templ.Attributes, text string) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(text) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 42, Col: 8} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 42, Col: 8} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -170,6 +176,9 @@ func renderLink(attrs templ.Attributes, text string) templ.Component { func renderStrong(attrs templ.Attributes, 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() { @@ -200,7 +209,7 @@ func renderStrong(attrs templ.Attributes, text string) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(text) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 48, Col: 8} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 48, Col: 8} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -217,6 +226,9 @@ func renderStrong(attrs templ.Attributes, text string) templ.Component { func renderEmphasis(attrs templ.Attributes, 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() { @@ -247,7 +259,7 @@ func renderEmphasis(attrs templ.Attributes, text string) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(text) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 54, Col: 8} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 54, Col: 8} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -264,6 +276,9 @@ func renderEmphasis(attrs templ.Attributes, text string) templ.Component { func renderCode(attrs templ.Attributes, 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() { @@ -294,7 +309,7 @@ func renderCode(attrs templ.Attributes, text string) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(text) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 60, Col: 8} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 60, Col: 8} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { diff --git a/internal/dwn/front/blocks/global.templ b/pkg/nebula/blocks/global.templ similarity index 100% rename from internal/dwn/front/blocks/global.templ rename to pkg/nebula/blocks/global.templ diff --git a/internal/dwn/front/blocks/global_templ.go b/pkg/nebula/blocks/global_templ.go similarity index 92% rename from internal/dwn/front/blocks/global_templ.go rename to pkg/nebula/blocks/global_templ.go index cc9d6bbc1..fa527537a 100644 --- a/internal/dwn/front/blocks/global_templ.go +++ b/pkg/nebula/blocks/global_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime" func Spacer() 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() { @@ -37,6 +40,9 @@ func Spacer() templ.Component { func ServiceWorker(path 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() { @@ -63,6 +69,9 @@ func ServiceWorker(path string) templ.Component { func defaultStyles() 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() { @@ -89,6 +98,9 @@ func defaultStyles() templ.Component { func Rows() 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() { @@ -123,6 +135,9 @@ func Rows() templ.Component { func Columns() 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() { diff --git a/internal/dwn/front/blocks/icons.templ b/pkg/nebula/blocks/icons.templ similarity index 100% rename from internal/dwn/front/blocks/icons.templ rename to pkg/nebula/blocks/icons.templ diff --git a/internal/dwn/front/blocks/icons_templ.go b/pkg/nebula/blocks/icons_templ.go similarity index 94% rename from internal/dwn/front/blocks/icons_templ.go rename to pkg/nebula/blocks/icons_templ.go index f5cfcfeb0..ab14ff8d4 100644 --- a/internal/dwn/front/blocks/icons_templ.go +++ b/pkg/nebula/blocks/icons_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -24,6 +24,9 @@ func (v Icons) Render() templ.Component { func renderIconVariant(v Icons) 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() { @@ -72,6 +75,9 @@ func renderIconVariant(v Icons) templ.Component { func SonrIcon() 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() { diff --git a/internal/dwn/front/blocks/inputs.templ b/pkg/nebula/blocks/inputs.templ similarity index 100% rename from internal/dwn/front/blocks/inputs.templ rename to pkg/nebula/blocks/inputs.templ diff --git a/internal/dwn/front/blocks/inputs_templ.go b/pkg/nebula/blocks/inputs_templ.go similarity index 90% rename from internal/dwn/front/blocks/inputs_templ.go rename to pkg/nebula/blocks/inputs_templ.go index d9e67437f..7938e89cc 100644 --- a/internal/dwn/front/blocks/inputs_templ.go +++ b/pkg/nebula/blocks/inputs_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -19,6 +19,9 @@ const ( func TextInput(state InputState, label string, placeholder 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() { @@ -43,7 +46,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/inputs.templ`, Line: 15, Col: 128} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/inputs.templ`, Line: 15, Col: 128} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -61,7 +64,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/inputs.templ`, Line: 20, Col: 128} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/inputs.templ`, Line: 20, Col: 128} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -79,7 +82,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/inputs.templ`, Line: 25, Col: 128} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/inputs.templ`, Line: 25, Col: 128} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { diff --git a/internal/dwn/front/blocks/panel.templ b/pkg/nebula/blocks/panel.templ similarity index 100% rename from internal/dwn/front/blocks/panel.templ rename to pkg/nebula/blocks/panel.templ diff --git a/internal/dwn/front/blocks/panel_templ.go b/pkg/nebula/blocks/panel_templ.go similarity index 93% rename from internal/dwn/front/blocks/panel_templ.go rename to pkg/nebula/blocks/panel_templ.go index ac23cc111..39b623cbe 100644 --- a/internal/dwn/front/blocks/panel_templ.go +++ b/pkg/nebula/blocks/panel_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -13,6 +13,9 @@ import "github.com/labstack/echo/v4" func Breadcrumbs() 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() { @@ -71,6 +74,9 @@ func Breadcrumbs() templ.Component { func breadcrumbItem(title string, active bool) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { @@ -94,7 +100,7 @@ func breadcrumbItem(title string, active bool) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/panel.templ`, Line: 25, Col: 126} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/panel.templ`, Line: 25, Col: 126} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -112,7 +118,7 @@ func breadcrumbItem(title string, active bool) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/panel.templ`, Line: 27, Col: 118} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/panel.templ`, Line: 27, Col: 118} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -130,6 +136,9 @@ func breadcrumbItem(title string, active bool) templ.Component { func breadcrumbIcon() 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() { @@ -156,6 +165,9 @@ func breadcrumbIcon() templ.Component { func Panel(c echo.Context, 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() { diff --git a/internal/dwn/front/blocks/radios.templ b/pkg/nebula/blocks/radios.templ similarity index 100% rename from internal/dwn/front/blocks/radios.templ rename to pkg/nebula/blocks/radios.templ diff --git a/internal/dwn/front/blocks/radios_templ.go b/pkg/nebula/blocks/radios_templ.go similarity index 94% rename from internal/dwn/front/blocks/radios_templ.go rename to pkg/nebula/blocks/radios_templ.go index 32524a069..3777323bb 100644 --- a/internal/dwn/front/blocks/radios_templ.go +++ b/pkg/nebula/blocks/radios_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime" func RadioGroup() 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() { diff --git a/internal/dwn/front/blocks/sizes.templ b/pkg/nebula/blocks/sizes.templ similarity index 100% rename from internal/dwn/front/blocks/sizes.templ rename to pkg/nebula/blocks/sizes.templ diff --git a/internal/dwn/front/blocks/sizes_templ.go b/pkg/nebula/blocks/sizes_templ.go similarity index 97% rename from internal/dwn/front/blocks/sizes_templ.go rename to pkg/nebula/blocks/sizes_templ.go index dfd3259f5..3a6e40584 100644 --- a/internal/dwn/front/blocks/sizes_templ.go +++ b/pkg/nebula/blocks/sizes_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/dwn/front/blocks/tabs.templ b/pkg/nebula/blocks/tabs.templ similarity index 100% rename from internal/dwn/front/blocks/tabs.templ rename to pkg/nebula/blocks/tabs.templ diff --git a/internal/dwn/front/blocks/tabs_templ.go b/pkg/nebula/blocks/tabs_templ.go similarity index 97% rename from internal/dwn/front/blocks/tabs_templ.go rename to pkg/nebula/blocks/tabs_templ.go index 0d5e9bfea..1966f74e9 100644 --- a/internal/dwn/front/blocks/tabs_templ.go +++ b/pkg/nebula/blocks/tabs_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package blocks //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime" func Tabs() 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() { @@ -45,6 +48,9 @@ func Tabs() templ.Component { func Table() 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() { diff --git a/internal/dwn/front/islands/forms.go b/pkg/nebula/islands/forms.go similarity index 100% rename from internal/dwn/front/islands/forms.go rename to pkg/nebula/islands/forms.go diff --git a/internal/dwn/front/islands/register.templ b/pkg/nebula/islands/register.templ similarity index 100% rename from internal/dwn/front/islands/register.templ rename to pkg/nebula/islands/register.templ diff --git a/internal/dwn/front/islands/register_templ.go b/pkg/nebula/islands/register_templ.go similarity index 92% rename from internal/dwn/front/islands/register_templ.go rename to pkg/nebula/islands/register_templ.go index b49a513a7..2f56be082 100644 --- a/internal/dwn/front/islands/register_templ.go +++ b/pkg/nebula/islands/register_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package islands //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -13,6 +13,9 @@ import "github.com/labstack/echo/v4" func BasicInfo(c echo.Context, state FormState) 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() { @@ -42,6 +45,9 @@ func BasicInfo(c echo.Context, state FormState) templ.Component { func CreateCredentials(c echo.Context, state FormState) 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() { @@ -64,6 +70,9 @@ func CreateCredentials(c echo.Context, state FormState) templ.Component { func PrivacyTerms(c echo.Context, state FormState) 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() { diff --git a/internal/dwn/front/routes.go b/pkg/nebula/router.go similarity index 60% rename from internal/dwn/front/routes.go rename to pkg/nebula/router.go index be07b244c..99854b117 100644 --- a/internal/dwn/front/routes.go +++ b/pkg/nebula/router.go @@ -1,12 +1,12 @@ -package front +package nebula import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/views" + "github.com/onsonr/sonr/pkg/nebula/views" ) -func RegisterViews(e *echo.Echo) { - e.GET("/", views.HomeView) +func RouteViews(e *echo.Echo) { + e.GET("/home", views.HomeView) e.GET("/login", views.LoginView) e.GET("/register", views.RegisterView) e.GET("/profile", views.ProfileView) diff --git a/internal/dwn/front/views/home.templ b/pkg/nebula/views/home.templ similarity index 92% rename from internal/dwn/front/views/home.templ rename to pkg/nebula/views/home.templ index 4a49ab882..249053097 100644 --- a/internal/dwn/front/views/home.templ +++ b/pkg/nebula/views/home.templ @@ -2,7 +2,7 @@ package views import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func HomeView(c echo.Context) error { diff --git a/internal/dwn/front/views/home_templ.go b/pkg/nebula/views/home_templ.go similarity index 96% rename from internal/dwn/front/views/home_templ.go rename to pkg/nebula/views/home_templ.go index f0a877674..571a161e9 100644 --- a/internal/dwn/front/views/home_templ.go +++ b/pkg/nebula/views/home_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package views //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func HomeView(c echo.Context) error { @@ -20,6 +20,9 @@ func HomeView(c echo.Context) error { func renderHomeView() 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() { diff --git a/internal/dwn/front/views/login.templ b/pkg/nebula/views/login.templ similarity index 89% rename from internal/dwn/front/views/login.templ rename to pkg/nebula/views/login.templ index 936f439af..151a34f53 100644 --- a/internal/dwn/front/views/login.templ +++ b/pkg/nebula/views/login.templ @@ -2,7 +2,8 @@ package views import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" + ) func LoginView(c echo.Context) error { diff --git a/internal/dwn/front/views/login_templ.go b/pkg/nebula/views/login_templ.go similarity index 96% rename from internal/dwn/front/views/login_templ.go rename to pkg/nebula/views/login_templ.go index 250fb4dbb..e1a21a02d 100644 --- a/internal/dwn/front/views/login_templ.go +++ b/pkg/nebula/views/login_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package views //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func LoginView(c echo.Context) error { @@ -20,6 +20,9 @@ func LoginView(c echo.Context) error { func renderLoginView() 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() { diff --git a/internal/dwn/front/views/openid.templ b/pkg/nebula/views/openid.templ similarity index 86% rename from internal/dwn/front/views/openid.templ rename to pkg/nebula/views/openid.templ index e67e0625b..1f696607c 100644 --- a/internal/dwn/front/views/openid.templ +++ b/pkg/nebula/views/openid.templ @@ -2,7 +2,8 @@ package views import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" + ) func AuthorizeView(c echo.Context) error { diff --git a/internal/dwn/front/views/openid_templ.go b/pkg/nebula/views/openid_templ.go similarity index 93% rename from internal/dwn/front/views/openid_templ.go rename to pkg/nebula/views/openid_templ.go index f70831d99..d3883b7d6 100644 --- a/internal/dwn/front/views/openid_templ.go +++ b/pkg/nebula/views/openid_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package views //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func AuthorizeView(c echo.Context) error { @@ -20,6 +20,9 @@ func AuthorizeView(c echo.Context) error { func renderAuthorizeView() 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() { diff --git a/internal/dwn/front/views/profile.templ b/pkg/nebula/views/profile.templ similarity index 84% rename from internal/dwn/front/views/profile.templ rename to pkg/nebula/views/profile.templ index 984d54f8f..5a4c7e8f7 100644 --- a/internal/dwn/front/views/profile.templ +++ b/pkg/nebula/views/profile.templ @@ -2,7 +2,8 @@ package views import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" + ) func ProfileView(c echo.Context) error { diff --git a/internal/dwn/front/views/profile_templ.go b/pkg/nebula/views/profile_templ.go similarity index 93% rename from internal/dwn/front/views/profile_templ.go rename to pkg/nebula/views/profile_templ.go index 5c82cb17b..74bb0c9a7 100644 --- a/internal/dwn/front/views/profile_templ.go +++ b/pkg/nebula/views/profile_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package views //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func ProfileView(c echo.Context) error { @@ -20,6 +20,9 @@ func ProfileView(c echo.Context) error { func renderProfileView() 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() { diff --git a/internal/dwn/front/views/register.templ b/pkg/nebula/views/register.templ similarity index 82% rename from internal/dwn/front/views/register.templ rename to pkg/nebula/views/register.templ index 2ffaf38c1..3ef03b7e4 100644 --- a/internal/dwn/front/views/register.templ +++ b/pkg/nebula/views/register.templ @@ -2,8 +2,8 @@ package views import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" - "github.com/onsonr/sonr/internal/dwn/front/islands" + "github.com/onsonr/sonr/pkg/nebula/blocks" + "github.com/onsonr/sonr/pkg/nebula/islands" ) func RegisterView(c echo.Context) error { diff --git a/internal/dwn/front/views/register_templ.go b/pkg/nebula/views/register_templ.go similarity index 95% rename from internal/dwn/front/views/register_templ.go rename to pkg/nebula/views/register_templ.go index 8bf16f444..fbbd04e4a 100644 --- a/internal/dwn/front/views/register_templ.go +++ b/pkg/nebula/views/register_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package views //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,8 +10,8 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" - "github.com/onsonr/sonr/internal/dwn/front/islands" + "github.com/onsonr/sonr/pkg/nebula/blocks" + "github.com/onsonr/sonr/pkg/nebula/islands" ) func RegisterView(c echo.Context) error { @@ -21,6 +21,9 @@ func RegisterView(c echo.Context) error { func renderRegisterView(c echo.Context) 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() { diff --git a/internal/dwn/front/views/views.go b/pkg/nebula/views/views.go similarity index 100% rename from internal/dwn/front/views/views.go rename to pkg/nebula/views/views.go diff --git a/internal/vfs/app.wasm b/pkg/vault/app.wasm similarity index 62% rename from internal/vfs/app.wasm rename to pkg/vault/app.wasm index 0e2f21fa5..4be43299b 100755 Binary files a/internal/vfs/app.wasm and b/pkg/vault/app.wasm differ diff --git a/internal/vfs/embed.go b/pkg/vault/embed.go similarity index 53% rename from internal/vfs/embed.go rename to pkg/vault/embed.go index 7cd67797e..49ea7f0ea 100644 --- a/internal/vfs/embed.go +++ b/pkg/vault/embed.go @@ -1,9 +1,12 @@ -package vfs +package vault import ( + "bytes" + "context" _ "embed" "encoding/json" + "github.com/a-h/templ" "github.com/ipfs/boxo/files" "github.com/onsonr/sonr/config/dwn" ) @@ -11,20 +14,41 @@ import ( //go:embed app.wasm var dwnWasmData []byte -//go:embed index.html -var indexData []byte +//go:embed motr.mjs +var motrMJSData []byte //go:embed sw.js var swJSData []byte -// NewDWNConfigFile uses the config template to generate the dwn config file -func NewDWNConfigFile(keyshareJSON string, adddress string, chainID string) (files.Node, error) { +// NewConfig uses the config template to generate the dwn config file +func NewConfig(keyshareJSON string, adddress string, chainID string, schema *dwn.Schema) *dwn.Config { dwnCfg := &dwn.Config{ - Motr: createMotrConfig(keyshareJSON, adddress, "sonr.id"), - Ipfs: defaultIPFSConfig(), - Sonr: defaultSonrConfig(chainID), + Motr: createMotrConfig(keyshareJSON, adddress, "sonr.id"), + Ipfs: defaultIPFSConfig(), + Sonr: defaultSonrConfig(chainID), + Schema: schema, } - dwnConfigData, err := json.Marshal(dwnCfg) + return dwnCfg +} + +// Use IndexHTML template to generate the index file +func IndexHTMLFile(c *dwn.Config) (files.Node, error) { + str, err := templ.JSONString(c) + if err != nil { + return nil, err + } + w := bytes.NewBuffer(nil) + err = indexFile(str).Render(context.Background(), w) + if err != nil { + return nil, err + } + indexData := w.Bytes() + return files.NewBytesFile(indexData), nil +} + +// MarshalConfigFile uses the config template to generate the dwn config file +func MarshalConfigFile(c *dwn.Config) (files.Node, error) { + dwnConfigData, err := json.Marshal(c) if err != nil { return nil, err } @@ -36,9 +60,9 @@ func DWNWasmFile() files.Node { return files.NewBytesFile(dwnWasmData) } -// Use IndexHTML template to generate the index file -func IndexFile() files.Node { - return files.NewBytesFile(indexData) +// Use MotrMJS template to generate the dwn wasm file +func MotrMJSFile() files.Node { + return files.NewBytesFile(motrMJSData) } // Use ServiceWorkerJS template to generate the service worker file diff --git a/pkg/vault/index.templ b/pkg/vault/index.templ new file mode 100644 index 000000000..6f5b61e38 --- /dev/null +++ b/pkg/vault/index.templ @@ -0,0 +1,107 @@ +package vault + + +var motrHandle = templ.NewOnceHandle() + +templ importScripts() { + + + +} + +templ indexFile(cfg string) { + + + + + + + + @importScripts() + + Sonr DWN + + + +
+
Loading...
+
+ @motrHandle.Once() { + + @initializeMotr(cfg) + } + + +} + +script initializeMotr(config string) { + const motr = new Motr(JSON.parse(config)); + + async function demo() { + try { + // Insert a new account + const accountId = await motr.insertAccount({ + name: 'John Doe', + address: '0x1234567890123456789012345678901234567890', + publicKey: 'sample_public_key', + chainCode: 'SONR', + index: 0, + controller: 'sample_controller', + createdAt: new Date() + }); + + console.log('Inserted account with ID:', accountId); + + // Retrieve the account + const account = await motr.getAccount(accountId); + console.log('Retrieved account:', account); + + // Insert a new credential + const credentialId = await motr.insertCredential({ + subject: 'john@example.com', + label: 'John\'s Device', + controller: 'sample_controller', + attestationType: 'platform', + origin: 'https://app.sonr.io' + }); + + console.log('Inserted credential with ID:', credentialId); + + // Retrieve the credential + const credential = await motr.getCredential(credentialId); + console.log('Retrieved credential:', credential); + + document.getElementById('output').innerHTML = ` +

Demo Results:

+

Inserted account ID: ${accountId}

+

Retrieved account name: ${account.name}

+

Inserted credential ID: ${credentialId}

+

Retrieved credential subject: ${credential.subject}

+ `; + } catch (error) { + console.error('Error in demo:', error); + document.getElementById('output').innerHTML = `

Error: ${error.message}

`; + } + } + + // Run the demo when the page loads + window.onload = demo; +} + diff --git a/pkg/vault/index_templ.go b/pkg/vault/index_templ.go new file mode 100644 index 000000000..dbd1e5c5e --- /dev/null +++ b/pkg/vault/index_templ.go @@ -0,0 +1,169 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.778 +package vault + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +var motrHandle = templ.NewOnceHandle() + +func importScripts() 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 indexFile(cfg 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_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 = importScripts().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Sonr DWN
Loading...
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Var3 := 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 + } + templ_7745c5c3_Err = initializeMotr(cfg).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = motrHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), 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 initializeMotr(config string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_initializeMotr_4943`, + Function: `function __templ_initializeMotr_4943(config){const motr = new Motr(JSON.parse(config)); + + async function demo() { + try { + // Insert a new account + const accountId = await motr.insertAccount({ + name: 'John Doe', + address: '0x1234567890123456789012345678901234567890', + publicKey: 'sample_public_key', + chainCode: 'SONR', + index: 0, + controller: 'sample_controller', + createdAt: new Date() + }); + + console.log('Inserted account with ID:', accountId); + + // Retrieve the account + const account = await motr.getAccount(accountId); + console.log('Retrieved account:', account); + + // Insert a new credential + const credentialId = await motr.insertCredential({ + subject: 'john@example.com', + label: 'John\'s Device', + controller: 'sample_controller', + attestationType: 'platform', + origin: 'https://app.sonr.io' + }); + + console.log('Inserted credential with ID:', credentialId); + + // Retrieve the credential + const credential = await motr.getCredential(credentialId); + console.log('Retrieved credential:', credential); + + document.getElementById('output').innerHTML = ` + "`" + ` +

Demo Results:

+

Inserted account ID: ${accountId}

+

Retrieved account name: ${account.name}

+

Inserted credential ID: ${credentialId}

+

Retrieved credential subject: ${credential.subject}

+ ` + "`" + `; + } catch (error) { + console.error('Error in demo:', error); + document.getElementById('output').innerHTML = ` + "`" + `

Error: ${error.message}

` + "`" + `; + } + } + + // Run the demo when the page loads + window.onload = demo; +}`, + Call: templ.SafeScript(`__templ_initializeMotr_4943`, config), + CallInline: templ.SafeScriptInline(`__templ_initializeMotr_4943`, config), + } +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/vault/motr.mjs b/pkg/vault/motr.mjs new file mode 100644 index 000000000..cde5b7a68 --- /dev/null +++ b/pkg/vault/motr.mjs @@ -0,0 +1,253 @@ +// motr.mjs + +import Dexie from "dexie"; + +export class Motr { + constructor(config) { + this.config = config; + this.vault = null; + this.initializeVault(); + } + + initializeVault() { + const { schema } = this.config; + this.vault = new Dexie("Vault"); + this.vault.version(schema.version).stores(schema); + } + + // Account methods + async insertAccount(accountData) { + return this.vault.account.add(accountData); + } + + async getAccount(id) { + return this.vault.account.get(id); + } + + async updateAccount(id, accountData) { + return this.vault.account.update(id, accountData); + } + + async deleteAccount(id) { + return this.vault.account.delete(id); + } + + // Asset methods + async insertAsset(assetData) { + return this.vault.asset.add(assetData); + } + + async getAsset(id) { + return this.vault.asset.get(id); + } + + async updateAsset(id, assetData) { + return this.vault.asset.update(id, assetData); + } + + async deleteAsset(id) { + return this.vault.asset.delete(id); + } + + // Chain methods + async insertChain(chainData) { + return this.vault.chain.add(chainData); + } + + async getChain(id) { + return this.vault.chain.get(id); + } + + async updateChain(id, chainData) { + return this.vault.chain.update(id, chainData); + } + + async deleteChain(id) { + return this.vault.chain.delete(id); + } + + // Credential methods + async insertCredential(credentialData) { + const publicKey = await this.createPublicKeyCredential(credentialData); + credentialData.credentialId = publicKey.id; + credentialData.publicKey = publicKey.publicKey; + return this.vault.credential.add(credentialData); + } + + async getCredential(id) { + return this.vault.credential.get(id); + } + + async updateCredential(id, credentialData) { + return this.vault.credential.update(id, credentialData); + } + + async deleteCredential(id) { + return this.vault.credential.delete(id); + } + + // JWK methods + async insertJwk(jwkData) { + return this.vault.jwk.add(jwkData); + } + + async getJwk(id) { + return this.vault.jwk.get(id); + } + + async updateJwk(id, jwkData) { + return this.vault.jwk.update(id, jwkData); + } + + async deleteJwk(id) { + return this.vault.jwk.delete(id); + } + + // Grant methods + async insertGrant(grantData) { + return this.vault.grant.add(grantData); + } + + async getGrant(id) { + return this.vault.grant.get(id); + } + + async updateGrant(id, grantData) { + return this.vault.grant.update(id, grantData); + } + + async deleteGrant(id) { + return this.vault.grant.delete(id); + } + + // Keyshare methods + async insertKeyshare(keyshareData) { + return this.vault.keyshare.add(keyshareData); + } + + async getKeyshare(id) { + return this.vault.keyshare.get(id); + } + + async updateKeyshare(id, keyshareData) { + return this.vault.keyshare.update(id, keyshareData); + } + + async deleteKeyshare(id) { + return this.vault.keyshare.delete(id); + } + + // PublicKey methods + async insertPublicKey(publicKeyData) { + return this.vault.publicKey.add(publicKeyData); + } + + async getPublicKey(id) { + return this.vault.publicKey.get(id); + } + + async updatePublicKey(id, publicKeyData) { + return this.vault.publicKey.update(id, publicKeyData); + } + + async deletePublicKey(id) { + return this.vault.publicKey.delete(id); + } + + // Profile methods + async insertProfile(profileData) { + return this.vault.profile.add(profileData); + } + + async getProfile(id) { + return this.vault.profile.get(id); + } + + async updateProfile(id, profileData) { + return this.vault.profile.update(id, profileData); + } + + async deleteProfile(id) { + return this.vault.profile.delete(id); + } + + // WebAuthn methods + async createPublicKeyCredential(options) { + const publicKeyCredentialCreationOptions = { + challenge: new Uint8Array(32), + rp: { + name: this.config.motr.origin, + id: new URL(this.config.motr.origin).hostname, + }, + user: { + id: new TextEncoder().encode(options.subject), + name: options.subject, + displayName: options.label, + }, + pubKeyCredParams: [ + { alg: -7, type: "public-key" }, + { alg: -257, type: "public-key" }, + ], + authenticatorSelection: { + authenticatorAttachment: "platform", + userVerification: "required", + }, + timeout: 60000, + attestation: "direct", + }; + + try { + const credential = await navigator.credentials.create({ + publicKey: publicKeyCredentialCreationOptions, + }); + + const publicKeyJwk = await crypto.subtle.exportKey( + "jwk", + credential.response.getPublicKey(), + ); + + return { + id: credential.id, + publicKey: publicKeyJwk, + type: credential.type, + transports: credential.response.getTransports(), + }; + } catch (error) { + console.error("Error creating credential:", error); + throw error; + } + } + + async getPublicKeyCredential(options) { + const publicKeyCredentialRequestOptions = { + challenge: new Uint8Array(32), + rpId: new URL(this.config.motr.origin).hostname, + allowCredentials: options.allowCredentials || [], + userVerification: "required", + timeout: 60000, + }; + + try { + const assertion = await navigator.credentials.get({ + publicKey: publicKeyCredentialRequestOptions, + }); + + return { + id: assertion.id, + type: assertion.type, + rawId: new Uint8Array(assertion.rawId), + response: { + authenticatorData: new Uint8Array( + assertion.response.authenticatorData, + ), + clientDataJSON: new Uint8Array(assertion.response.clientDataJSON), + signature: new Uint8Array(assertion.response.signature), + userHandle: new Uint8Array(assertion.response.userHandle), + }, + }; + } catch (error) { + console.error("Error getting credential:", error); + throw error; + } + } +} diff --git a/internal/vfs/sw.js b/pkg/vault/sw.js similarity index 71% rename from internal/vfs/sw.js rename to pkg/vault/sw.js index a64d2c5ee..524912268 100644 --- a/internal/vfs/sw.js +++ b/pkg/vault/sw.js @@ -1,17 +1,16 @@ importScripts( "https://cdn.jsdelivr.net/gh/golang/go@go1.22.5/misc/wasm/wasm_exec.js", "https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js", - "https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js", ); registerWasmHTTPListener("app.wasm"); // Skip installed stage and jump to activating stage -addEventListener("install", (event) => { +self.addEventListener("install", (event) => { event.waitUntil(skipWaiting()); }); // Start controlling clients as soon as the SW is activated -addEventListener("activate", (event) => { +self.addEventListener("activate", (event) => { event.waitUntil(clients.claim()); }); diff --git a/proto/did/v1/tx.proto b/proto/did/v1/tx.proto index 5b832fb3e..7e620dfad 100644 --- a/proto/did/v1/tx.proto +++ b/proto/did/v1/tx.proto @@ -31,28 +31,6 @@ service Msg { rpc RegisterService(MsgRegisterService) returns (MsgRegisterServiceResponse); } -// MsgUpdateParams is the Msg/UpdateParams request type. -// -// Since: cosmos-sdk 0.47 -message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - - // authority is the address of the governance account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - - // params defines the parameters to update. - Params params = 2 [(gogoproto.nullable) = false]; - - // token is the macron token to authenticate the operation. - string token = 3; -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// -// Since: cosmos-sdk 0.47 -message MsgUpdateParamsResponse {} - // MsgAllocateVault is the message type for the AllocateVault RPC. message MsgAllocateVault { option (cosmos.msg.v1.signer) = "authority"; @@ -150,3 +128,25 @@ message MsgRegisterServiceResponse { bool success = 1; string did = 2; } + +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the parameters to update. + Params params = 2 [(gogoproto.nullable) = false]; + + // token is the macron token to authenticate the operation. + string token = 3; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParamsResponse {} diff --git a/web/src/pages/allocate.templ b/web/src/pages/allocate.templ index 086a39fb5..8bd4adcc1 100644 --- a/web/src/pages/allocate.templ +++ b/web/src/pages/allocate.templ @@ -2,7 +2,7 @@ package pages import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func AllocateView(c echo.Context) error { diff --git a/web/src/pages/allocate_templ.go b/web/src/pages/allocate_templ.go index 7493acc8a..a7cbf11ab 100644 --- a/web/src/pages/allocate_templ.go +++ b/web/src/pages/allocate_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package pages //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func AllocateView(c echo.Context) error { @@ -20,6 +20,9 @@ func AllocateView(c echo.Context) error { func renderAuthorizeView() 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() { diff --git a/web/src/pages/home.templ b/web/src/pages/home.templ index 99d42ff82..e41922bf0 100644 --- a/web/src/pages/home.templ +++ b/web/src/pages/home.templ @@ -2,7 +2,7 @@ package pages import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func HomeView(c echo.Context) error { diff --git a/web/src/pages/home_templ.go b/web/src/pages/home_templ.go index 7659d0953..e125f16f2 100644 --- a/web/src/pages/home_templ.go +++ b/web/src/pages/home_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.771 +// templ: version: v0.2.778 package pages //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/internal/dwn/front/blocks" + "github.com/onsonr/sonr/pkg/nebula/blocks" ) func HomeView(c echo.Context) error { @@ -20,6 +20,9 @@ func HomeView(c echo.Context) error { func renderHomeView() 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() { diff --git a/x/did/keeper/context.go b/x/did/keeper/context.go index 0aa199bf6..b347ef905 100644 --- a/x/did/keeper/context.go +++ b/x/did/keeper/context.go @@ -1,19 +1,46 @@ package keeper import ( + "context" + "crypto/sha256" + "fmt" "time" - "github.com/ipfs/kubo/client/rpc" - + nftkeeper "cosmossdk.io/x/nft/keeper" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ipfs/boxo/path" + "github.com/ipfs/kubo/client/rpc" + "github.com/ipfs/kubo/core/coreiface/options" + "github.com/onsonr/sonr/pkg/builder" "github.com/onsonr/sonr/x/did/types" "google.golang.org/grpc/peer" + "gopkg.in/macaroon.v2" ) +func (k Keeper) UnwrapCtx(goCtx context.Context) Context { + ctx := sdk.UnwrapSDKContext(goCtx) + peer, _ := peer.FromContext(goCtx) + return Context{SDKCtx: ctx, Peer: peer, Keeper: k} +} + type Context struct { - SDKCtx sdk.Context - Keeper Keeper - Peer *peer.Peer + SDKCtx sdk.Context + Keeper Keeper + Peer *peer.Peer + NFTKeeper nftkeeper.Keeper +} + +// AssembleVault assembles the initial vault +func (k Keeper) AssembleVault(ctx Context, subject string, origin string) (string, int64, error) { + v, err := builder.NewVault(subject, origin, "sonr-testnet") + if err != nil { + return "", 0, err + } + cid, err := k.ipfsClient.Unixfs().Add(context.Background(), v.FS) + if err != nil { + return "", 0, err + } + return cid.String(), ctx.CalculateExpiration(time.Second * 15), nil } // AverageBlockTime returns the average block time in seconds @@ -45,6 +72,26 @@ func (c Context) IsAnonymous() bool { return c.Peer.Addr == nil } +// IssueMacaroon creates a macaroon with the specified parameters. +func (c Context) IssueMacaroon(sharedMPCPubKey, location, id string, blockExpiry uint64) (*macaroon.Macaroon, error) { + // Derive the root key by hashing the shared MPC public key + rootKey := sha256.Sum256([]byte(sharedMPCPubKey)) + // Create the macaroon + m, err := macaroon.New(rootKey[:], []byte(id), location, macaroon.LatestVersion) + if err != nil { + return nil, err + } + + // Add the block expiry caveat + caveat := fmt.Sprintf("block-expiry=%d", blockExpiry) + err = m.AddFirstPartyCaveat([]byte(caveat)) + if err != nil { + return nil, err + } + + return m, nil +} + func (c Context) Params() *types.Params { p, err := c.Keeper.Params.Get(c.SDK()) if err != nil { @@ -61,6 +108,30 @@ func (c Context) PeerID() string { return c.Peer.Addr.String() } +// PinVaultController pins the initial vault to the local IPFS node +func (k Keeper) PinVaultController(_ sdk.Context, cid string, address string) (bool, error) { + // Resolve the path + path, err := path.NewPath(cid) + if err != nil { + return false, err + } + + // 1. Initialize vault.db sqlite database in local IPFS with Mount + + // 2. Insert the InitialWalletAccounts + + // 3. Publish the path to the IPNS + _, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address)) + if err != nil { + return false, err + } + + // 4. Insert the accounts into x/auth + + // 5. Insert the controller into state + return true, nil +} + func (c Context) SDK() sdk.Context { return c.SDKCtx } diff --git a/x/did/keeper/genesis.go b/x/did/keeper/genesis.go index 42aae121e..a1b904878 100644 --- a/x/did/keeper/genesis.go +++ b/x/did/keeper/genesis.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ipfs/boxo/path" - "google.golang.org/grpc/peer" "github.com/onsonr/sonr/x/did/types" ) @@ -71,9 +70,3 @@ func (k Keeper) HasPathInIPFS(ctx sdk.Context, cid string) (bool, error) { } return true, nil } - -func (k Keeper) UnwrapCtx(goCtx context.Context) Context { - ctx := sdk.UnwrapSDKContext(goCtx) - peer, _ := peer.FromContext(goCtx) - return Context{SDKCtx: ctx, Peer: peer, Keeper: k} -} diff --git a/x/did/keeper/vault.go b/x/did/keeper/vault.go deleted file mode 100644 index 465599745..000000000 --- a/x/did/keeper/vault.go +++ /dev/null @@ -1,86 +0,0 @@ -package keeper - -import ( - "context" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/bech32" - "github.com/ipfs/boxo/files" - "github.com/ipfs/boxo/path" - "github.com/ipfs/kubo/core/coreiface/options" - "github.com/onsonr/crypto/mpc" - "github.com/onsonr/sonr/internal/vfs" -) - -type Vault struct { - FS files.Node - ValKs mpc.Share -} - -func NewVault(subject string, origin string, chainID string) (*Vault, error) { - shares, err := mpc.GenerateKeyshares() - var ( - valKs = shares[0] - usrKs = shares[1] - ) - usrKsJSON, err := usrKs.Marshal() - if err != nil { - return nil, err - } - sonrAddr, err := bech32.ConvertAndEncode("idx", valKs.GetPublicKey()) - if err != nil { - return nil, err - } - cnfg, err := vfs.NewDWNConfigFile(usrKsJSON, sonrAddr, chainID) - if err != nil { - return nil, err - } - fileMap := map[string]files.Node{ - "config.json": cnfg, - "sw.js": vfs.SWJSFile(), - "app.wasm": vfs.DWNWasmFile(), - "index.html": vfs.IndexFile(), - } - return &Vault{ - FS: files.NewMapDirectory(fileMap), - ValKs: valKs, - }, nil -} - -// AssembleVault assembles the initial vault -func (k Keeper) AssembleVault(ctx Context, subject string, origin string) (string, int64, error) { - v, err := NewVault(subject, origin, "sonr-testnet") - if err != nil { - return "", 0, err - } - cid, err := k.ipfsClient.Unixfs().Add(context.Background(), v.FS) - if err != nil { - return "", 0, err - } - return cid.String(), ctx.CalculateExpiration(time.Second * 15), nil -} - -// PinVaultController pins the initial vault to the local IPFS node -func (k Keeper) PinVaultController(_ sdk.Context, cid string, address string) (bool, error) { - // Resolve the path - path, err := path.NewPath(cid) - if err != nil { - return false, err - } - - // 1. Initialize vault.db sqlite database in local IPFS with Mount - - // 2. Insert the InitialWalletAccounts - - // 3. Publish the path to the IPNS - _, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address)) - if err != nil { - return false, err - } - - // 4. Insert the accounts into x/auth - - // 5. Insert the controller into state - return true, nil -} diff --git a/x/did/types/codec.go b/x/did/types/codec.go index 4755546e2..c2913f290 100644 --- a/x/did/types/codec.go +++ b/x/did/types/codec.go @@ -30,6 +30,9 @@ func init() { // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateParams{}, ModuleName+"/MsgUpdateParams", nil) + cdc.RegisterConcrete(&MsgRegisterController{}, ModuleName+"/MsgRegisterController", nil) + cdc.RegisterConcrete(&MsgRegisterService{}, ModuleName+"/MsgRegisterService", nil) + cdc.RegisterConcrete(&MsgAllocateVault{}, ModuleName+"/MsgAllocateVault", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) {