mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 18:01:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6bd0c9819 |
@@ -2,7 +2,6 @@
|
|||||||
name = "cz_conventional_commits"
|
name = "cz_conventional_commits"
|
||||||
tag_format = "v$version"
|
tag_format = "v$version"
|
||||||
version_scheme = "semver"
|
version_scheme = "semver"
|
||||||
version = "0.5.27"
|
version = "0.5.21"
|
||||||
update_changelog_on_bump = true
|
update_changelog_on_bump = true
|
||||||
major_version_zero = true
|
major_version_zero = true
|
||||||
changelog_file = "./docs/docs/changelog.md"
|
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ updates:
|
|||||||
- package-ecosystem: "gomod" # See documentation for possible values
|
- package-ecosystem: "gomod" # See documentation for possible values
|
||||||
directory: "/" # Location of package manifests
|
directory: "/" # Location of package manifests
|
||||||
schedule:
|
schedule:
|
||||||
interval: "monthly"
|
interval: "weekly"
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
name: Run All Checks
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
merge_group:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tidy-pr:
|
|
||||||
name: Tidy PR
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
permissions:
|
|
||||||
contents: read # for TimonVS/pr-labeler-action to read config file
|
|
||||||
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: TimonVS/pr-labeler-action@v5
|
|
||||||
with:
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
|
|
||||||
|
|
||||||
test-builds:
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Run Build Tests
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
- name: Run Sonrd Build
|
|
||||||
run: make build
|
|
||||||
- name: Run Hway Build
|
|
||||||
run: make build-hway
|
|
||||||
- name: Run Motr Build
|
|
||||||
run: make build-motr
|
|
||||||
|
|
||||||
test-unit:
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Run Unit Tests
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
- run: make test-unit
|
|
||||||
|
|
||||||
test-race:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name == 'merge_group'
|
|
||||||
name: Run Race Tests
|
|
||||||
continue-on-error: true
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
- run: make test-race
|
|
||||||
|
|
||||||
test-cover:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name == 'merge_group'
|
|
||||||
name: Run Coverage Tests
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
- run: make test-cover
|
|
||||||
|
|
||||||
validate-release:
|
|
||||||
if: github.event_name == 'merge_group'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Verify Release Config
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- name: Check GoReleaser Config
|
|
||||||
uses: goreleaser/goreleaser-action@v6
|
|
||||||
with:
|
|
||||||
distribution: goreleaser
|
|
||||||
version: latest
|
|
||||||
args: check
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: GoReleaser Dry Run
|
|
||||||
uses: goreleaser/goreleaser-action@v6
|
|
||||||
with:
|
|
||||||
distribution: goreleaser
|
|
||||||
version: latest
|
|
||||||
args: release --snapshot --clean --skip=publish
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
name: Deploy Networks
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
reboot-devnet:
|
||||||
|
name: Devnet Deploy
|
||||||
|
runs-on: goliath
|
||||||
|
environment: "Devnet"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
branch: develop
|
||||||
|
|
||||||
|
- name: Stop Existing Network
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
make stop-uds
|
||||||
|
make clean
|
||||||
|
|
||||||
|
- name: Start Updated Network
|
||||||
|
run: |
|
||||||
|
make start-uds
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
name: PR Labeler
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pr-labeler:
|
||||||
|
permissions:
|
||||||
|
contents: read # for TimonVS/pr-labeler-action to read config file
|
||||||
|
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: TimonVS/pr-labeler-action@v5
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
|
||||||
@@ -1,31 +1,18 @@
|
|||||||
name: Publish Versioned Assets
|
name: Publish Docs via GitHub Pages
|
||||||
on:
|
on:
|
||||||
release:
|
push:
|
||||||
types: [published]
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
paths:
|
||||||
|
- "docs/**"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
issues: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
buf_push:
|
deploy:
|
||||||
name: Publish to buf.build/onsonr/sonr
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
|
||||||
# Run `git checkout`
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
# Install the `buf` CLI
|
|
||||||
- uses: bufbuild/buf-setup-action@v1
|
|
||||||
# Push only the Input in `proto` to the BSR
|
|
||||||
- uses: bufbuild/buf-push-action@v1
|
|
||||||
continue-on-error: true
|
|
||||||
with:
|
|
||||||
input: proto
|
|
||||||
buf_token: ${{ secrets.BUF_TOKEN }}
|
|
||||||
|
|
||||||
publish-docs:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Publish Docs
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Configure Git Credentials
|
- name: Configure Git Credentials
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
name: Publish Versioned Assets
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
buf_push_core:
|
||||||
|
name: Publish to buf.build/onsonr/sonr
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Run `git checkout`
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
# Install the `buf` CLI
|
||||||
|
- uses: bufbuild/buf-setup-action@v1
|
||||||
|
# Push only the Input in `proto` to the BSR
|
||||||
|
- uses: bufbuild/buf-push-action@v1
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
input: proto
|
||||||
|
buf_token: ${{ secrets.BUF_TOKEN }}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
name: Run Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
merge_group:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-unit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Run Unit Tests
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- run: make test-unit
|
||||||
|
|
||||||
|
test-race:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Run Race Tests
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- run: make test-race
|
||||||
|
|
||||||
|
test-cover:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Run Coverage Tests
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- run: make test-cover
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
name: Versioned Release
|
name: Scheduled Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_dispatch:
|
||||||
types: [closed]
|
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
@@ -11,27 +10,8 @@ permissions:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bump-version:
|
goreleaser:
|
||||||
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop'
|
name: Release motr, sonrd, and DWN
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Bump Current Version
|
|
||||||
outputs:
|
|
||||||
new_tag: ${{ steps.bump.outputs.new_tag }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Create bump and changelog
|
|
||||||
id: bump
|
|
||||||
uses: commitizen-tools/commitizen-action@master
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
increment: "PATCH"
|
|
||||||
|
|
||||||
new-release:
|
|
||||||
name: Run GoReleaser on New Tag
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -56,12 +36,14 @@ jobs:
|
|||||||
- name: Release
|
- name: Release
|
||||||
uses: goreleaser/goreleaser-action@v6
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
distribution: goreleaser
|
distribution: goreleaser-pro
|
||||||
version: latest
|
version: latest
|
||||||
args: release --clean
|
args: release --clean
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
||||||
|
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||||
GITHUB_PERSONAL_AUTH_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
GITHUB_PERSONAL_AUTH_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
|
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
CLOUDSMITH_TOKEN: ${{ secrets.CLOUDSMITH_TOKEN }}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
name: Update Version
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-tests:
|
||||||
|
name: "Run tests"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- name: Run tests
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
bump-version:
|
||||||
|
needs: [run-tests]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: "Bump Version"
|
||||||
|
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Create bump and changelog
|
||||||
|
uses: commitizen-tools/commitizen-action@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
increment: "PATCH"
|
||||||
+4
-9
@@ -1,5 +1,4 @@
|
|||||||
# Binaries
|
# Binaries
|
||||||
no
|
|
||||||
.data
|
.data
|
||||||
schemas
|
schemas
|
||||||
*.db
|
*.db
|
||||||
@@ -61,7 +60,10 @@ override.tf.json
|
|||||||
|
|
||||||
.terraformrc
|
.terraformrc
|
||||||
terraform.rc
|
terraform.rc
|
||||||
flake.lock
|
|
||||||
|
Taskfile.yml
|
||||||
|
|
||||||
|
!deploy/**/Taskfile.yml
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@@ -96,11 +98,4 @@ sonr.wiki
|
|||||||
!buf.lock
|
!buf.lock
|
||||||
|
|
||||||
.air.toml
|
.air.toml
|
||||||
mprocs.yaml
|
|
||||||
mprocs.log
|
|
||||||
tools-stamp
|
|
||||||
sonr.log
|
|
||||||
deploy/conf
|
|
||||||
|
|
||||||
interchaintest-downloader
|
|
||||||
.haptic
|
|
||||||
|
|||||||
+15
-8
@@ -3,17 +3,11 @@ version: 2
|
|||||||
project_name: sonr
|
project_name: sonr
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- id: motr
|
|
||||||
main: ./cmd/motr
|
|
||||||
binary: app
|
|
||||||
goos:
|
|
||||||
- js
|
|
||||||
goarch:
|
|
||||||
- wasm
|
|
||||||
|
|
||||||
- id: sonr
|
- id: sonr
|
||||||
main: ./cmd/sonrd
|
main: ./cmd/sonrd
|
||||||
binary: sonrd
|
binary: sonrd
|
||||||
|
builder: go
|
||||||
|
gobinary: go
|
||||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
@@ -39,6 +33,8 @@ builds:
|
|||||||
- id: hway
|
- id: hway
|
||||||
main: ./cmd/hway
|
main: ./cmd/hway
|
||||||
binary: hway
|
binary: hway
|
||||||
|
builder: go
|
||||||
|
gobinary: go
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- darwin
|
- darwin
|
||||||
@@ -68,6 +64,7 @@ archives:
|
|||||||
format: tar.gz
|
format: tar.gz
|
||||||
files:
|
files:
|
||||||
- src: README*
|
- src: README*
|
||||||
|
- src: CHANGELOG*
|
||||||
wrap_in_directory: true
|
wrap_in_directory: true
|
||||||
|
|
||||||
- id: hway
|
- id: hway
|
||||||
@@ -80,6 +77,7 @@ archives:
|
|||||||
format: tar.gz
|
format: tar.gz
|
||||||
files:
|
files:
|
||||||
- src: README*
|
- src: README*
|
||||||
|
- src: CHANGELOG*
|
||||||
wrap_in_directory: true
|
wrap_in_directory: true
|
||||||
|
|
||||||
nfpms:
|
nfpms:
|
||||||
@@ -173,8 +171,17 @@ release:
|
|||||||
replace_existing_draft: true
|
replace_existing_draft: true
|
||||||
replace_existing_artifacts: true
|
replace_existing_artifacts: true
|
||||||
extra_files:
|
extra_files:
|
||||||
|
- glob: ./CHANGELOG*
|
||||||
- glob: ./README*
|
- glob: ./README*
|
||||||
|
|
||||||
|
cloudsmiths:
|
||||||
|
- organization: sonr
|
||||||
|
repository: sonr
|
||||||
|
distributions:
|
||||||
|
deb: "ubuntu/xenial"
|
||||||
|
alpine: "alpine/v3.8"
|
||||||
|
rpm: "el/7"
|
||||||
|
|
||||||
announce:
|
announce:
|
||||||
telegram:
|
telegram:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
GOPATH:
|
|
||||||
sh: go env GOPATH
|
|
||||||
BIN_DIR: "{{.GOPATH}}/bin"
|
|
||||||
BINARY: "{{.BIN_DIR}}/hway"
|
|
||||||
OS:
|
|
||||||
sh: uname -s
|
|
||||||
ARCH:
|
|
||||||
sh: uname -m
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
build:
|
|
||||||
desc: Build the hway binary
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- gum spin --spinner dot --title "Build Hway Single Target ({{.OS}}/{{.ARCH}})..." -- goreleaser build --snapshot --clean --single-target --id hway -o {{.BIN_DIR}}/hway
|
|
||||||
|
|
||||||
install:
|
|
||||||
desc: Install the hway binary
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- gum spin --spinner dot --title "Install Hway Single Target ({{.OS}}/{{.ARCH}})..." -- make install-hway
|
|
||||||
|
|
||||||
start:
|
|
||||||
desc: Start the hway daemon
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- "{{.BINARY}}"
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
ROOT:
|
|
||||||
sh: git rev-parse --show-toplevel
|
|
||||||
tasks:
|
|
||||||
init:
|
|
||||||
desc: Setup ipfs with Cloudflare
|
|
||||||
silent: true
|
|
||||||
vars:
|
|
||||||
PEERS: |
|
|
||||||
'[
|
|
||||||
{"ID": "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE", "Addrs": ["/dnsaddr/node-1.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z", "Addrs": ["/dnsaddr/node-2.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa", "Addrs": ["/dnsaddr/node-3.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx", "Addrs": ["/dnsaddr/node-4.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ", "Addrs": ["/dnsaddr/node-5.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G", "Addrs": ["/dnsaddr/node-6.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3", "Addrs": ["/dnsaddr/node-7.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP", "Addrs": ["/dnsaddr/node-8.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi", "Addrs": ["/dnsaddr/node-9.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx", "Addrs": ["/dnsaddr/node-10.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5", "Addrs": ["/dnsaddr/node-11.ingress.cloudflare-ipfs.com"]},
|
|
||||||
{"ID": "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev", "Addrs": ["/dnsaddr/node-12.ingress.cloudflare-ipfs.com"]}
|
|
||||||
]'
|
|
||||||
cmds:
|
|
||||||
- rm -rf ~/.ipfs
|
|
||||||
- ipfs init
|
|
||||||
- ipfs config --json Peering.Peers {{.PEERS}}
|
|
||||||
- ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
|
|
||||||
|
|
||||||
mount:
|
|
||||||
desc: Mount the ipfs,ipns directories
|
|
||||||
silent: true
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
cmds:
|
|
||||||
- ipfs config --json Mounts.FuseAllowOther true
|
|
||||||
|
|
||||||
start:
|
|
||||||
desc: Start the ipfs daemon
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- cmd: ipfs daemon --migrate
|
|
||||||
platforms:
|
|
||||||
- darwin
|
|
||||||
- task: mount
|
|
||||||
- cmd: ipfs daemon --mount
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
GOPATH:
|
|
||||||
sh: go env GOPATH
|
|
||||||
BIN_DIR: "{{.GOPATH}}/bin"
|
|
||||||
OS:
|
|
||||||
sh: uname -s
|
|
||||||
ARCH:
|
|
||||||
sh: uname -m
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
init:
|
|
||||||
desc: Initialize postgresql
|
|
||||||
silent: true
|
|
||||||
dir: deploy/apps/chainindex
|
|
||||||
cmds:
|
|
||||||
- cmd: sudo -u postgres psql -f seed.sql
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
- cmd: sudo -u postgres psql -d chainindex -f schema.sql
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
reset:
|
|
||||||
desc: Reset postgresql
|
|
||||||
silent: true
|
|
||||||
dir: deploy/apps/chainindex
|
|
||||||
cmds:
|
|
||||||
- cmd: sudo -u postgres psql -d chainindex -f reset.sql
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
BINARY: sonrd
|
|
||||||
BUILD_FLAGS: -mod=readonly -trimpath
|
|
||||||
BUILD_TAGS: netgo,ledger
|
|
||||||
COMMIT:
|
|
||||||
sh: git rev-parse HEAD
|
|
||||||
VERSION:
|
|
||||||
sh: git describe --tags --always
|
|
||||||
tasks:
|
|
||||||
build:
|
|
||||||
desc: Build the sonrd binary
|
|
||||||
cmds:
|
|
||||||
- >
|
|
||||||
go build
|
|
||||||
{{.BUILD_FLAGS}}
|
|
||||||
-tags "{{.BUILD_TAGS}}"
|
|
||||||
-ldflags "
|
|
||||||
-X github.com/cosmos/cosmos-sdk/version.Name=sonr
|
|
||||||
-X github.com/cosmos/cosmos-sdk/version.AppName=sonrd
|
|
||||||
-X github.com/cosmos/cosmos-sdk/version.Version={{.VERSION}}
|
|
||||||
-X github.com/cosmos/cosmos-sdk/version.Commit={{.COMMIT}}
|
|
||||||
-X github.com/cosmos/cosmos-sdk/version.BuildTags={{.BUILD_TAGS}}
|
|
||||||
"
|
|
||||||
-o ./build/{{.BINARY}}
|
|
||||||
./cmd/sonrd
|
|
||||||
env:
|
|
||||||
CGO_ENABLED: 1
|
|
||||||
GOARCH:
|
|
||||||
sh: go env GOARCH
|
|
||||||
GOOS:
|
|
||||||
sh: go env GOOS
|
|
||||||
|
|
||||||
install:
|
|
||||||
desc: Install sonrd
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- gum spin --spinner dot --title "Installing sonr daemon..." -- make install
|
|
||||||
|
|
||||||
start:
|
|
||||||
desc: Start the sonr node
|
|
||||||
cmds:
|
|
||||||
- sh scripts/test_dop_node.sh
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
ROOT:
|
|
||||||
sh: git rev-parse --show-toplevel
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
init:
|
|
||||||
desc: Configure synapse homeserver with PKL
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- pkl eval pkl/matrix.net/Homeserver.pkl -f yaml -o deploy/conf/synapse/homeserver.yaml
|
|
||||||
env:
|
|
||||||
MATRIX_CLIENT_NAME: sonr.id
|
|
||||||
MATRIX_SERVER_NAME: sonr.id
|
|
||||||
MATRIX_SERVER_URL: http://localhost:8008
|
|
||||||
MATRIX_SLIDING_SYNC_PROXY: http://localhost:8008
|
|
||||||
MATRIX_PSQL_CONN: postgresql://matrixhs_user:matrixhs_password123@localhost:5432/sonr
|
|
||||||
MATRIX_REGISTRATION_SHARED_SECRET: secret
|
|
||||||
MATRIX_ENABLE_RECATCHA: false
|
|
||||||
MATRIX_RECATCHA_PUBLIC_KEY: ""
|
|
||||||
MATRIX_RECATCHA_PRIVATE_KEY: ""
|
|
||||||
MATRIX_RECATCHA_BYPASS_SECRET: ""
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
ROOT:
|
|
||||||
sh: git rev-parse --show-toplevel
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
init:
|
|
||||||
desc: Configure tigerbeetle database
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- pkl eval pkl/matrix.net/Homeserver.pkl -f yaml -o deploy/conf/synapse/homeserver.yaml
|
|
||||||
@@ -1,37 +1,3 @@
|
|||||||
## v0.5.27 (2024-12-16)
|
|
||||||
|
|
||||||
## v0.5.26 (2024-12-13)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- Correct regular expression for version tags in release workflow
|
|
||||||
|
|
||||||
## v0.5.25 (2024-12-11)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- enable GoReleaser releases on tags and snapshots
|
|
||||||
- automate release on tag and workflow dispatch
|
|
||||||
|
|
||||||
## v0.5.24 (2024-12-11)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- prevent duplicate releases
|
|
||||||
|
|
||||||
## v0.5.23 (2024-12-11)
|
|
||||||
|
|
||||||
### Refactor
|
|
||||||
|
|
||||||
- rename scheduled release workflow to versioned release
|
|
||||||
- remove changelog from release artifacts
|
|
||||||
|
|
||||||
## v0.5.22 (2024-12-11)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- Implement passkey-based authentication and registration flow
|
|
||||||
|
|
||||||
## v0.5.21 (2024-12-11)
|
## v0.5.21 (2024-12-11)
|
||||||
|
|
||||||
### Feat
|
### Feat
|
||||||
+37
@@ -1,3 +1,40 @@
|
|||||||
|
FROM jetpackio/devbox:latest AS sonrvm
|
||||||
|
|
||||||
|
# Installing your devbox project
|
||||||
|
WORKDIR /code
|
||||||
|
USER root:root
|
||||||
|
|
||||||
|
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
|
||||||
|
|
||||||
|
USER ${DEVBOX_USER}:${DEVBOX_USER}
|
||||||
|
|
||||||
|
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
|
||||||
|
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} process-compose.yaml process-compose.yaml
|
||||||
|
|
||||||
|
RUN devbox run -- echo "Installed Packages."
|
||||||
|
|
||||||
|
ENTRYPOINT ["devbox", "run"]
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
|
FROM jetpackio/devbox:latest AS sonr-runner
|
||||||
|
|
||||||
|
WORKDIR /code
|
||||||
|
USER root:root
|
||||||
|
|
||||||
|
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
|
||||||
|
|
||||||
|
USER ${DEVBOX_USER}:${DEVBOX_USER}
|
||||||
|
|
||||||
|
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
|
||||||
|
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} process-compose.yaml process-compose.yaml
|
||||||
|
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . .
|
||||||
|
|
||||||
|
RUN devbox run -- echo "Installed Packages."
|
||||||
|
|
||||||
|
RUN git config --global --add safe.directory /code
|
||||||
|
ENTRYPOINT ["devbox", "run", "testnet"]
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
FROM golang:1.22-alpine AS go-builder
|
FROM golang:1.22-alpine AS go-builder
|
||||||
|
|
||||||
SHELL ["/bin/sh", "-ecuxo", "pipefail"]
|
SHELL ["/bin/sh", "-ecuxo", "pipefail"]
|
||||||
|
|||||||
@@ -87,12 +87,6 @@ else
|
|||||||
go build -mod=readonly $(BUILD_FLAGS) -o build/sonrd ./cmd/sonrd
|
go build -mod=readonly $(BUILD_FLAGS) -o build/sonrd ./cmd/sonrd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
build-motr: go.sum
|
|
||||||
GOOS=js GOARCH=wasm go build -o static/wasm/app.wasm ./cmd/motr/main.go
|
|
||||||
|
|
||||||
build-hway: go.sum
|
|
||||||
go build -o build/hway ./cmd/hway
|
|
||||||
|
|
||||||
build-windows-client: go.sum
|
build-windows-client: go.sum
|
||||||
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/sonrd.exe ./cmd/sonrd
|
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/sonrd.exe ./cmd/sonrd
|
||||||
|
|
||||||
@@ -106,9 +100,6 @@ endif
|
|||||||
install: go.sum
|
install: go.sum
|
||||||
go install -mod=readonly $(BUILD_FLAGS) ./cmd/sonrd
|
go install -mod=readonly $(BUILD_FLAGS) ./cmd/sonrd
|
||||||
|
|
||||||
install-hway: go.sum
|
|
||||||
go install -mod=readonly ./cmd/hway
|
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
### Tools & dependencies
|
### Tools & dependencies
|
||||||
|
|
||||||
@@ -193,6 +184,7 @@ format: format-tools
|
|||||||
|
|
||||||
mod-tidy:
|
mod-tidy:
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
cd interchaintest && go mod tidy
|
||||||
|
|
||||||
.PHONY: format-tools lint format mod-tidy
|
.PHONY: format-tools lint format mod-tidy
|
||||||
|
|
||||||
@@ -310,12 +302,71 @@ testnet-basic: setup-testnet
|
|||||||
sh-testnet: mod-tidy
|
sh-testnet: mod-tidy
|
||||||
CHAIN_ID="sonr-testnet-1" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh
|
CHAIN_ID="sonr-testnet-1" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh
|
||||||
|
|
||||||
.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet dop-testnet
|
.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
### generation ###
|
||||||
|
###############################################################################
|
||||||
|
.PHONY: gen-pkl gen-templ
|
||||||
|
|
||||||
|
gen-pkl: init-env
|
||||||
|
pkl-gen-go pkl/sonr.orm/UCAN.pkl
|
||||||
|
pkl-gen-go pkl/sonr.orm/Models.pkl
|
||||||
|
pkl-gen-go pkl/sonr.conf/Hway.pkl
|
||||||
|
pkl-gen-go pkl/sonr.conf/Motr.pkl
|
||||||
|
|
||||||
|
gen-templ: init-env
|
||||||
|
templ generate
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
### custom builds ###
|
||||||
|
###############################################################################
|
||||||
|
.PHONY: build-motr build-hway logs-hway logs-sonr
|
||||||
|
|
||||||
|
build-motr:
|
||||||
|
GOOS=js GOARCH=wasm go build -o static/wasm/app.wasm ./cmd/motr/main.go
|
||||||
|
|
||||||
|
build-hway: gen-templ
|
||||||
|
go build -o build/hway ./cmd/hway
|
||||||
|
|
||||||
|
logs-hway: init-env
|
||||||
|
bin/process-compose process logs hway --port $(PC_PORT_NUM) --follow
|
||||||
|
|
||||||
|
logs-sonr: init-env
|
||||||
|
bin/process-compose process logs sonr --port $(PC_PORT_NUM) --follow
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
### Network Start/Stop ###
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
.PHONY: deploy start start-tui start-uds stop stop-uds restart status
|
||||||
|
|
||||||
|
start: build-hway init-env
|
||||||
|
bin/process-compose up --port $(PC_PORT_NUM) --log-file $(PC_LOG_FILE) --detached -f deploy/process-compose.yaml
|
||||||
|
|
||||||
|
start-tui: build-hway init-env
|
||||||
|
bin/process-compose up --port $(PC_PORT_NUM) --log-file $(PC_LOG_FILE) -f deploy/process-compose.yaml
|
||||||
|
|
||||||
|
start-uds: build-hway init-env
|
||||||
|
bin/process-compose up --use-uds --unix-socket $(PC_SOCKET_PATH) --log-file $(PC_LOG_FILE) --detached -f deploy/process-compose.yaml
|
||||||
|
|
||||||
|
stop: init-env
|
||||||
|
bin/process-compose down --port $(PC_PORT_NUM)
|
||||||
|
|
||||||
|
stop-uds: init-env
|
||||||
|
bin/process-compose down --use-uds --unix-socket $(PC_SOCKET_PATH)
|
||||||
|
|
||||||
|
status: init-env
|
||||||
|
bin/process-compose project state --port $(PC_PORT_NUM)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
### help ###
|
### help ###
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
cd ./proto && bunx buf dep update && bunx buf build && bunx buf push
|
||||||
|
sh ./.github/scripts/upload_cdn.sh
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Usage: make <target>"
|
@echo "Usage: make <target>"
|
||||||
@echo ""
|
@echo ""
|
||||||
@@ -327,5 +378,7 @@ help:
|
|||||||
@echo " sh-testnet : Shell local devnet"
|
@echo " sh-testnet : Shell local devnet"
|
||||||
@echo " ictest-basic : Basic end-to-end test"
|
@echo " ictest-basic : Basic end-to-end test"
|
||||||
@echo " ictest-ibc : IBC end-to-end test"
|
@echo " ictest-ibc : IBC end-to-end test"
|
||||||
|
@echo " templ : Generate templ files"
|
||||||
|
@echo " vault : Build vault.wasm"
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
|
|||||||
@@ -37,3 +37,4 @@ Sonr would not have been possible without the direct and indirect support of the
|
|||||||
- [Forum](https://github.com/onsonr/sonr/discussions)
|
- [Forum](https://github.com/onsonr/sonr/discussions)
|
||||||
- [Issues](https://github.com/onsonr/sonr/issues)
|
- [Issues](https://github.com/onsonr/sonr/issues)
|
||||||
- [Twitter](https://sonr.io/twitter)
|
- [Twitter](https://sonr.io/twitter)
|
||||||
|
- [Dev Chat](https://sonr.io/discord)
|
||||||
|
|||||||
-137
@@ -1,137 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
VERSION:
|
|
||||||
sh: git describe --tags --abbrev=0
|
|
||||||
COMMIT:
|
|
||||||
sh: git rev-parse --short HEAD
|
|
||||||
ROOT:
|
|
||||||
sh: git rev-parse --show-toplevel
|
|
||||||
OS:
|
|
||||||
sh: uname -s
|
|
||||||
TASKS:
|
|
||||||
sh: task -l
|
|
||||||
DOPPLER_TOKEN:
|
|
||||||
sh: skate get DOPPLER_NETWORK
|
|
||||||
|
|
||||||
includes:
|
|
||||||
hway:
|
|
||||||
taskfile: .taskfiles/Hway.yml
|
|
||||||
ipfs:
|
|
||||||
taskfile: .taskfiles/IPFS.yml
|
|
||||||
postgres:
|
|
||||||
taskfile: .taskfiles/Postgres.yml
|
|
||||||
sonrd:
|
|
||||||
taskfile: .taskfiles/Sonrd.yml
|
|
||||||
synapse:
|
|
||||||
taskfile: .taskfiles/Synapse.yml
|
|
||||||
tigerbeetle:
|
|
||||||
taskfile: .taskfiles/TigerBeetle.yml
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
default:
|
|
||||||
cmds:
|
|
||||||
- gh run ls -L 3
|
|
||||||
- gum format -- "# Sonr ({{.OS}}-{{.VERSION}})" " - ({{.COMMIT}}) {{.ROOT}}"
|
|
||||||
- task -l -j | jq -r '.tasks[].name' | fzf --height=16 | xargs task
|
|
||||||
silent: true
|
|
||||||
|
|
||||||
deps:
|
|
||||||
desc: Install go dependencies
|
|
||||||
silent: true
|
|
||||||
vars:
|
|
||||||
DEPS:
|
|
||||||
[
|
|
||||||
"github.com/apple/pkl-go/cmd/pkl-gen-go@latest",
|
|
||||||
"github.com/sqlc-dev/sqlc/cmd/sqlc@latest",
|
|
||||||
"github.com/goreleaser/goreleaser/v2@latest",
|
|
||||||
"github.com/a-h/templ/cmd/templ@latest",
|
|
||||||
]
|
|
||||||
cmds:
|
|
||||||
- for: { var: DEPS }
|
|
||||||
cmd: gum spin --spinner dot --title "Installing go dependencies..." -- go install {{.ITEM}}
|
|
||||||
|
|
||||||
pkl-gen:
|
|
||||||
desc: Generate PKL files
|
|
||||||
silent: true
|
|
||||||
dir: "pkl/sonr.net"
|
|
||||||
vars:
|
|
||||||
FILES: ["Hway.pkl", "Motr.pkl", "UCAN.pkl"]
|
|
||||||
cmds:
|
|
||||||
- for: { var: FILES }
|
|
||||||
cmd: gum spin --spinner dot --title "Generating PKL in Go..." -- pkl-gen-go {{.ITEM}}
|
|
||||||
|
|
||||||
proto-gen:
|
|
||||||
desc: Generate proto files
|
|
||||||
silent: true
|
|
||||||
cmd: gum spin --spinner dot --title "Generating Protobufs..." -- make proto-gen
|
|
||||||
|
|
||||||
sqlc-gen:
|
|
||||||
desc: Generate SQLC files
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- gum spin --spinner dot --title "Generating SQLC..." -- sqlc generate -f internal/database/sqlc.yaml
|
|
||||||
|
|
||||||
templ-gen:
|
|
||||||
desc: Generate templ files
|
|
||||||
silent: true
|
|
||||||
cmd: gum spin --spinner dot --title "Generating Templ..." -- templ generate
|
|
||||||
|
|
||||||
start:
|
|
||||||
desc: Start the Network
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- task: postgres:reset
|
|
||||||
- task: ipfs:init
|
|
||||||
- task: ipfs:mount
|
|
||||||
- task: sonrd:install
|
|
||||||
- task: hway:build
|
|
||||||
- task: procs-up
|
|
||||||
|
|
||||||
status:
|
|
||||||
desc: Check the status of the Network
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- task: procs-attach
|
|
||||||
|
|
||||||
stop:
|
|
||||||
desc: Stop the Network
|
|
||||||
silent: true
|
|
||||||
cmds:
|
|
||||||
- task: procs-down
|
|
||||||
|
|
||||||
procs-up:
|
|
||||||
internal: true
|
|
||||||
dir: "deploy"
|
|
||||||
cmds:
|
|
||||||
- cmd: process-compose up
|
|
||||||
platforms:
|
|
||||||
- darwin
|
|
||||||
|
|
||||||
- cmd: process-compose up --use-uds --unix-socket /tmp/sonr-network.sock -D
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
procs-down:
|
|
||||||
internal: true
|
|
||||||
dir: "deploy"
|
|
||||||
cmds:
|
|
||||||
- cmd: process-compose down
|
|
||||||
platforms:
|
|
||||||
- darwin
|
|
||||||
|
|
||||||
- cmd: process-compose down --use-uds --unix-socket /tmp/sonr-network.sock
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
procs-attach:
|
|
||||||
internal: true
|
|
||||||
dir: "deploy"
|
|
||||||
cmds:
|
|
||||||
- cmd: process-compose attach --use-uds --unix-socket /tmp/sonr-network.sock
|
|
||||||
platforms:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
- cmd: process-compose attach
|
|
||||||
platforms:
|
|
||||||
- darwin
|
|
||||||
+2430
-760
File diff suppressed because it is too large
Load Diff
+2132
-55
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,9 @@ const _ = grpc.SupportPackageIsVersion9
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Query_Params_FullMethodName = "/dwn.v1.Query/Params"
|
Query_Params_FullMethodName = "/dwn.v1.Query/Params"
|
||||||
|
Query_Schema_FullMethodName = "/dwn.v1.Query/Schema"
|
||||||
Query_Allocate_FullMethodName = "/dwn.v1.Query/Allocate"
|
Query_Allocate_FullMethodName = "/dwn.v1.Query/Allocate"
|
||||||
|
Query_Sync_FullMethodName = "/dwn.v1.Query/Sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryClient is the client API for Query service.
|
// QueryClient is the client API for Query service.
|
||||||
@@ -31,9 +33,15 @@ const (
|
|||||||
type QueryClient interface {
|
type QueryClient interface {
|
||||||
// Params queries all parameters of the module.
|
// Params queries all parameters of the module.
|
||||||
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
||||||
|
// Schema queries the DID document by its id. And returns the required PKL
|
||||||
|
// information
|
||||||
|
Schema(ctx context.Context, in *QuerySchemaRequest, opts ...grpc.CallOption) (*QuerySchemaResponse, error)
|
||||||
// Allocate initializes a Target Vault available for claims with a compatible
|
// Allocate initializes a Target Vault available for claims with a compatible
|
||||||
// Authentication mechanism. The default authentication mechanism is WebAuthn.
|
// Authentication mechanism. The default authentication mechanism is WebAuthn.
|
||||||
Allocate(ctx context.Context, in *QueryAllocateRequest, opts ...grpc.CallOption) (*QueryAllocateResponse, error)
|
Allocate(ctx context.Context, in *QueryAllocateRequest, opts ...grpc.CallOption) (*QueryAllocateResponse, error)
|
||||||
|
// Sync queries the DID document by its id. And returns the required PKL
|
||||||
|
// information
|
||||||
|
Sync(ctx context.Context, in *QuerySyncRequest, opts ...grpc.CallOption) (*QuerySyncResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type queryClient struct {
|
type queryClient struct {
|
||||||
@@ -54,6 +62,16 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts .
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *queryClient) Schema(ctx context.Context, in *QuerySchemaRequest, opts ...grpc.CallOption) (*QuerySchemaResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(QuerySchemaResponse)
|
||||||
|
err := c.cc.Invoke(ctx, Query_Schema_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *queryClient) Allocate(ctx context.Context, in *QueryAllocateRequest, opts ...grpc.CallOption) (*QueryAllocateResponse, error) {
|
func (c *queryClient) Allocate(ctx context.Context, in *QueryAllocateRequest, opts ...grpc.CallOption) (*QueryAllocateResponse, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(QueryAllocateResponse)
|
out := new(QueryAllocateResponse)
|
||||||
@@ -64,6 +82,16 @@ func (c *queryClient) Allocate(ctx context.Context, in *QueryAllocateRequest, op
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *queryClient) Sync(ctx context.Context, in *QuerySyncRequest, opts ...grpc.CallOption) (*QuerySyncResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(QuerySyncResponse)
|
||||||
|
err := c.cc.Invoke(ctx, Query_Sync_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// QueryServer is the server API for Query service.
|
// QueryServer is the server API for Query service.
|
||||||
// All implementations must embed UnimplementedQueryServer
|
// All implementations must embed UnimplementedQueryServer
|
||||||
// for forward compatibility.
|
// for forward compatibility.
|
||||||
@@ -72,9 +100,15 @@ func (c *queryClient) Allocate(ctx context.Context, in *QueryAllocateRequest, op
|
|||||||
type QueryServer interface {
|
type QueryServer interface {
|
||||||
// Params queries all parameters of the module.
|
// Params queries all parameters of the module.
|
||||||
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
|
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
|
||||||
|
// Schema queries the DID document by its id. And returns the required PKL
|
||||||
|
// information
|
||||||
|
Schema(context.Context, *QuerySchemaRequest) (*QuerySchemaResponse, error)
|
||||||
// Allocate initializes a Target Vault available for claims with a compatible
|
// Allocate initializes a Target Vault available for claims with a compatible
|
||||||
// Authentication mechanism. The default authentication mechanism is WebAuthn.
|
// Authentication mechanism. The default authentication mechanism is WebAuthn.
|
||||||
Allocate(context.Context, *QueryAllocateRequest) (*QueryAllocateResponse, error)
|
Allocate(context.Context, *QueryAllocateRequest) (*QueryAllocateResponse, error)
|
||||||
|
// Sync queries the DID document by its id. And returns the required PKL
|
||||||
|
// information
|
||||||
|
Sync(context.Context, *QuerySyncRequest) (*QuerySyncResponse, error)
|
||||||
mustEmbedUnimplementedQueryServer()
|
mustEmbedUnimplementedQueryServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,9 +122,15 @@ type UnimplementedQueryServer struct{}
|
|||||||
func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) {
|
func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedQueryServer) Schema(context.Context, *QuerySchemaRequest) (*QuerySchemaResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Schema not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedQueryServer) Allocate(context.Context, *QueryAllocateRequest) (*QueryAllocateResponse, error) {
|
func (UnimplementedQueryServer) Allocate(context.Context, *QueryAllocateRequest) (*QueryAllocateResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Allocate not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Allocate not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedQueryServer) Sync(context.Context, *QuerySyncRequest) (*QuerySyncResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Sync not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
|
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
|
||||||
func (UnimplementedQueryServer) testEmbeddedByValue() {}
|
func (UnimplementedQueryServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
@@ -130,6 +170,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Query_Schema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(QuerySchemaRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(QueryServer).Schema(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Query_Schema_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(QueryServer).Schema(ctx, req.(*QuerySchemaRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
func _Query_Allocate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _Query_Allocate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(QueryAllocateRequest)
|
in := new(QueryAllocateRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@@ -148,6 +206,24 @@ func _Query_Allocate_Handler(srv interface{}, ctx context.Context, dec func(inte
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Query_Sync_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(QuerySyncRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(QueryServer).Sync(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Query_Sync_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(QueryServer).Sync(ctx, req.(*QuerySyncRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
@@ -159,10 +235,18 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "Params",
|
MethodName: "Params",
|
||||||
Handler: _Query_Params_Handler,
|
Handler: _Query_Params_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Schema",
|
||||||
|
Handler: _Query_Schema_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "Allocate",
|
MethodName: "Allocate",
|
||||||
Handler: _Query_Allocate_Handler,
|
Handler: _Query_Allocate_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Sync",
|
||||||
|
Handler: _Query_Sync_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "dwn/v1/query.proto",
|
Metadata: "dwn/v1/query.proto",
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/go-webauthn/webauthn/protocol"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *GatewayContext) NewChallenge() string {
|
|
||||||
chal, _ := protocol.CreateChallenge()
|
|
||||||
chalStr := chal.String()
|
|
||||||
return chalStr
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cc *GatewayContext) ListCredentials(handle string) ([]*CredentialDescriptor, error) {
|
|
||||||
creds, err := cc.GetCredentialsByHandle(bgCtx(), handle)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return CredentialArrayToDescriptors(creds), nil
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
gocontext "context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/medama-io/go-useragent"
|
|
||||||
"github.com/onsonr/sonr/crypto/mpc"
|
|
||||||
"github.com/onsonr/sonr/internal/config/hway"
|
|
||||||
hwayorm "github.com/onsonr/sonr/internal/database/hwayorm"
|
|
||||||
"github.com/onsonr/sonr/pkg/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GatewayContext struct {
|
|
||||||
echo.Context
|
|
||||||
*hwayorm.Queries
|
|
||||||
agent useragent.UserAgent
|
|
||||||
id string
|
|
||||||
ipfsClient common.IPFS
|
|
||||||
tokenStore common.IPFSTokenStore
|
|
||||||
stagedEnclaves map[string]mpc.Enclave
|
|
||||||
grpcAddr string
|
|
||||||
turnstileSiteKey string
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetGateway(c echo.Context) (*GatewayContext, error) {
|
|
||||||
cc, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return nil, echo.NewHTTPError(http.StatusInternalServerError, "Gateway Context not found")
|
|
||||||
}
|
|
||||||
return cc, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func UseGateway(env hway.Hway, ipc common.IPFS, db *hwayorm.Queries) echo.MiddlewareFunc {
|
|
||||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
||||||
return func(c echo.Context) error {
|
|
||||||
ua := useragent.NewParser()
|
|
||||||
ctx := &GatewayContext{
|
|
||||||
Context: c,
|
|
||||||
turnstileSiteKey: env.GetTurnstileSiteKey(),
|
|
||||||
agent: ua.Parse(c.Request().UserAgent()),
|
|
||||||
Queries: db,
|
|
||||||
ipfsClient: ipc,
|
|
||||||
grpcAddr: env.GetSonrGrpcUrl(),
|
|
||||||
tokenStore: common.NewUCANStore(ipc),
|
|
||||||
}
|
|
||||||
return next(ctx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BG() gocontext.Context {
|
|
||||||
ctx := gocontext.Background()
|
|
||||||
return ctx
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cc *GatewayContext) ReadCookie(k common.CookieKey) string {
|
|
||||||
return common.ReadCookieUnsafe(cc.Context, k)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cc *GatewayContext) WriteCookie(k common.CookieKey, v string) {
|
|
||||||
common.WriteCookie(cc.Context, k, v)
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
hwayorm "github.com/onsonr/sonr/internal/database/hwayorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
func UpdateProfile(c echo.Context) (*hwayorm.Profile, error) {
|
|
||||||
ctx, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return nil, echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found")
|
|
||||||
}
|
|
||||||
address := c.FormValue("address")
|
|
||||||
handle := c.FormValue("handle")
|
|
||||||
name := c.FormValue("name")
|
|
||||||
profile, err := ctx.UpdateProfile(bgCtx(), hwayorm.UpdateProfileParams{
|
|
||||||
Address: address,
|
|
||||||
Handle: handle,
|
|
||||||
Name: name,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &profile, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ReadProfile(c echo.Context) (*hwayorm.Profile, error) {
|
|
||||||
ctx, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return nil, echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found")
|
|
||||||
}
|
|
||||||
handle := c.Param("handle")
|
|
||||||
profile, err := ctx.GetProfileByHandle(bgCtx(), handle)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &profile, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteProfile(c echo.Context) error {
|
|
||||||
ctx, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Profile Context not found")
|
|
||||||
}
|
|
||||||
address := c.Param("address")
|
|
||||||
err := ctx.SoftDeleteProfile(bgCtx(), address)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
|
|
||||||
"github.com/a-h/templ"
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/views"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Render(c echo.Context, cmp templ.Component) error {
|
|
||||||
// Create a buffer to store the rendered HTML
|
|
||||||
buf := &bytes.Buffer{}
|
|
||||||
// Render the component to the buffer
|
|
||||||
err := cmp.Render(c.Request().Context(), buf)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the content type
|
|
||||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
|
||||||
|
|
||||||
// Write the buffered content to the response
|
|
||||||
_, err = c.Response().Write(buf.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
c.Response().WriteHeader(200)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func RenderError(c echo.Context, err error) error {
|
|
||||||
return Render(c, views.ErrorView(err.Error()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func RenderInitial(c echo.Context) error {
|
|
||||||
return Render(c, views.InitialView())
|
|
||||||
}
|
|
||||||
|
|
||||||
func RenderLoading(c echo.Context) error {
|
|
||||||
return Render(c, views.LoadingView())
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/onsonr/sonr/pkg/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ParamsBank returns the bank params
|
|
||||||
func (cc *GatewayContext) ParamsBank() (*common.BankParamsResponse, error) {
|
|
||||||
cl, err := common.NewBankClient(cc.grpcAddr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp, err := cl.Params(bgCtx(), &common.BankParamsRequest{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParamsDID returns the DID params
|
|
||||||
func (cc *GatewayContext) ParamsDID() (*common.DIDParamsResponse, error) {
|
|
||||||
cl, err := common.NewDIDClient(cc.grpcAddr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp, err := cl.Params(bgCtx(), &common.DIDParamsRequest{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParamsDWN returns the DWN params
|
|
||||||
func (cc *GatewayContext) ParamsDWN() (*common.DWNParamsResponse, error) {
|
|
||||||
cl, err := common.NewDWNClient(cc.grpcAddr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp, err := cl.Params(bgCtx(), &common.DWNParamsRequest{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParamsSVC returns the SVC params
|
|
||||||
func (cc *GatewayContext) ParamsSVC() (*common.SVCParamsResponse, error) {
|
|
||||||
cl, err := common.NewSVCClient(cc.grpcAddr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp, err := cl.Params(bgCtx(), &common.SVCParamsRequest{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusBlock returns the current block
|
|
||||||
func (cc *GatewayContext) StatusBlock() string {
|
|
||||||
qc, err := common.NewNodeClient(cc.grpcAddr)
|
|
||||||
if err != nil {
|
|
||||||
return "-1"
|
|
||||||
}
|
|
||||||
resp, err := qc.Status(bgCtx(), &common.StatusRequest{})
|
|
||||||
if err != nil {
|
|
||||||
return "-1"
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%d", resp.GetHeight())
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusNode returns the node status
|
|
||||||
func (cc *GatewayContext) StatusNode() (*common.StatusResponse, error) {
|
|
||||||
cl, err := common.NewNodeClient(cc.grpcAddr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp, err := cl.Status(bgCtx(), &common.StatusRequest{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TxBroadcast broadcasts a transaction to the network
|
|
||||||
func (cc *GatewayContext) TxBroadcast() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TxEncode encodes a transaction
|
|
||||||
func (cc *GatewayContext) TxEncode() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TxDecode decodes a transaction
|
|
||||||
func (cc *GatewayContext) TxDecode() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TxSimulate simulates a transaction on the network
|
|
||||||
func (cc *GatewayContext) TxSimulate() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
gocontext "context"
|
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/onsonr/sonr/pkg/common"
|
|
||||||
"github.com/segmentio/ksuid"
|
|
||||||
"lukechampine.com/blake3"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewSession(c echo.Context) error {
|
|
||||||
cc, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
baseSessionCreateParams := BaseSessionCreateParams(cc)
|
|
||||||
cc.id = baseSessionCreateParams.ID
|
|
||||||
if _, err := cc.CreateSession(bgCtx(), baseSessionCreateParams); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// Set Cookie
|
|
||||||
if err := common.WriteCookie(c, common.SessionID, cc.id); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uses blake3 to hash the sessionID to generate a nonce of length 12 bytes
|
|
||||||
func GetNonce(sessionID string) ([]byte, error) {
|
|
||||||
hash := blake3.New(32, nil)
|
|
||||||
_, err := hash.Write([]byte(sessionID))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// Read the hash into a byte slice
|
|
||||||
nonce := make([]byte, 12)
|
|
||||||
_, err = hash.Write(nonce)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return nonce, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ForbiddenDevice returns true if the device is unavailable
|
|
||||||
func ForbiddenDevice(c echo.Context) bool {
|
|
||||||
cc, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return cc.agent.IsBot() || cc.agent.IsTV()
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetOrigin(c echo.Context) string {
|
|
||||||
return c.Request().Host
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSessionID(c echo.Context) string {
|
|
||||||
// Check from context
|
|
||||||
cc, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
// check from cookie
|
|
||||||
if cc.id == "" {
|
|
||||||
if ok := common.CookieExists(c, common.SessionID); !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
cc.id = common.ReadCookieUnsafe(c, common.SessionID)
|
|
||||||
}
|
|
||||||
return cc.id
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAuthChallenge(c echo.Context) string {
|
|
||||||
cc, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
s, err := cc.GetChallengeBySessionID(bgCtx(), cc.id)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetProfileHandle(c echo.Context) string {
|
|
||||||
// First check for the cookie
|
|
||||||
handle := common.ReadCookieUnsafe(c, common.UserHandle)
|
|
||||||
if handle != "" {
|
|
||||||
return handle
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then check the session
|
|
||||||
cc, ok := c.(*GatewayContext)
|
|
||||||
if !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
s, err := cc.GetSessionByID(bgCtx(), cc.id)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
profile, err := cc.GetProfileByID(bgCtx(), s.ProfileID)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return profile.Handle
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// func GetHumanVerificationNumbers(c echo.Context) (int64, int64) {
|
|
||||||
// cc, ok := c.(*GatewayContext)
|
|
||||||
// if !ok {
|
|
||||||
// return 0, 0
|
|
||||||
// }
|
|
||||||
// s, err := cc.dbq.GetHumanVerificationNumbers(bgCtx(), cc.id)
|
|
||||||
// if err != nil {
|
|
||||||
// return 0, 0
|
|
||||||
// }
|
|
||||||
// return s.IsHumanFirst, s.IsHumanLast
|
|
||||||
// }
|
|
||||||
|
|
||||||
// utility function to get a context
|
|
||||||
func bgCtx() gocontext.Context {
|
|
||||||
ctx := gocontext.Background()
|
|
||||||
return ctx
|
|
||||||
}
|
|
||||||
|
|
||||||
func getOrCreateSessionID(c echo.Context) string {
|
|
||||||
if ok := common.CookieExists(c, common.SessionID); !ok {
|
|
||||||
sessionID := ksuid.New().String()
|
|
||||||
common.WriteCookie(c, common.SessionID, sessionID)
|
|
||||||
return sessionID
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionID, err := common.ReadCookie(c, common.SessionID)
|
|
||||||
if err != nil {
|
|
||||||
sessionID = ksuid.New().String()
|
|
||||||
common.WriteCookie(c, common.SessionID, sessionID)
|
|
||||||
}
|
|
||||||
return sessionID
|
|
||||||
}
|
|
||||||
|
|
||||||
func boolToInt64(b bool) int64 {
|
|
||||||
if b {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/go-webauthn/webauthn/protocol"
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/medama-io/go-useragent"
|
|
||||||
hwayorm "github.com/onsonr/sonr/internal/database/hwayorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Define the credential structure matching our frontend data
|
|
||||||
type CredentialDescriptor struct {
|
|
||||||
ID string `json:"id"`
|
|
||||||
RawID string `json:"rawId"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
AuthenticatorAttachment string `json:"authenticatorAttachment"`
|
|
||||||
Transports string `json:"transports"`
|
|
||||||
ClientExtensionResults map[string]string `json:"clientExtensionResults"`
|
|
||||||
Response struct {
|
|
||||||
AttestationObject string `json:"attestationObject"`
|
|
||||||
ClientDataJSON string `json:"clientDataJSON"`
|
|
||||||
} `json:"response"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CredentialDescriptor) ToModel(handle, origin string) *hwayorm.Credential {
|
|
||||||
return &hwayorm.Credential{
|
|
||||||
Handle: handle,
|
|
||||||
Origin: origin,
|
|
||||||
CredentialID: c.ID,
|
|
||||||
Type: c.Type,
|
|
||||||
Transports: c.Transports,
|
|
||||||
AuthenticatorAttachment: c.AuthenticatorAttachment,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CredentialArrayToDescriptors(credentials []hwayorm.Credential) []*CredentialDescriptor {
|
|
||||||
var descriptors []*CredentialDescriptor
|
|
||||||
for _, cred := range credentials {
|
|
||||||
cd := &CredentialDescriptor{
|
|
||||||
ID: cred.CredentialID,
|
|
||||||
RawID: cred.CredentialID,
|
|
||||||
Type: cred.Type,
|
|
||||||
AuthenticatorAttachment: cred.AuthenticatorAttachment,
|
|
||||||
Transports: cred.Transports,
|
|
||||||
}
|
|
||||||
descriptors = append(descriptors, cd)
|
|
||||||
}
|
|
||||||
return descriptors
|
|
||||||
}
|
|
||||||
|
|
||||||
func BaseSessionCreateParams(e echo.Context) hwayorm.CreateSessionParams {
|
|
||||||
// f := rand.Intn(5) + 1
|
|
||||||
// l := rand.Intn(4) + 1
|
|
||||||
challenge, _ := protocol.CreateChallenge()
|
|
||||||
id := getOrCreateSessionID(e)
|
|
||||||
ua := useragent.NewParser()
|
|
||||||
s := ua.Parse(e.Request().UserAgent())
|
|
||||||
|
|
||||||
return hwayorm.CreateSessionParams{
|
|
||||||
ID: id,
|
|
||||||
BrowserName: s.GetBrowser(),
|
|
||||||
BrowserVersion: s.GetMajorVersion(),
|
|
||||||
ClientIpaddr: e.RealIP(),
|
|
||||||
Platform: s.GetOS(),
|
|
||||||
IsMobile: s.IsMobile(),
|
|
||||||
IsTablet: s.IsTablet(),
|
|
||||||
IsDesktop: s.IsDesktop(),
|
|
||||||
IsBot: s.IsBot(),
|
|
||||||
IsTv: s.IsTV(),
|
|
||||||
// IsHumanFirst: int64(f),
|
|
||||||
// IsHumanLast: int64(l),
|
|
||||||
Challenge: challenge.String(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭───────────────────────────────────────────────────────────╮
|
|
||||||
// │ Create Passkey (/register/passkey) │
|
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
// CreatePasskeyParams represents the parameters for creating a passkey
|
|
||||||
type CreatePasskeyParams struct {
|
|
||||||
Address string
|
|
||||||
Handle string
|
|
||||||
Name string
|
|
||||||
Challenge string
|
|
||||||
CreationBlock string
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭───────────────────────────────────────────────────────────╮
|
|
||||||
// │ Create Profile (/register/profile) │
|
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
// CreateProfileParams represents the parameters for creating a profile
|
|
||||||
type CreateProfileParams struct {
|
|
||||||
TurnstileSiteKey string
|
|
||||||
FirstNumber int
|
|
||||||
LastNumber int
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sum returns the sum of the first and last number
|
|
||||||
func (d CreateProfileParams) Sum() int {
|
|
||||||
return d.FirstNumber + d.LastNumber
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package context
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/onsonr/sonr/crypto/mpc"
|
|
||||||
"github.com/onsonr/sonr/pkg/common"
|
|
||||||
"lukechampine.com/blake3"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (cc *GatewayContext) Spawn(handle, origin string) (*CreatePasskeyParams, error) {
|
|
||||||
challenge := GetAuthChallenge(cc)
|
|
||||||
sid := GetSessionID(cc)
|
|
||||||
nonce, err := calcNonce(sid)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
encl, err := mpc.GenEnclave(nonce)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
cc.stagedEnclaves[sid] = encl
|
|
||||||
common.WriteCookie(cc, common.SonrAddress, encl.Address())
|
|
||||||
return &CreatePasskeyParams{
|
|
||||||
Address: encl.Address(),
|
|
||||||
Handle: handle,
|
|
||||||
Name: origin,
|
|
||||||
Challenge: challenge,
|
|
||||||
CreationBlock: cc.StatusBlock(),
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uses blake3 to hash the sessionID to generate a nonce of length 12 bytes
|
|
||||||
func calcNonce(sessionID string) ([]byte, error) {
|
|
||||||
hash := blake3.New(32, nil)
|
|
||||||
_, err := hash.Write([]byte(sessionID))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// Read the hash into a byte slice
|
|
||||||
nonce := make([]byte, 12)
|
|
||||||
_, err = hash.Write(nonce)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return nonce, nil
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
// Package gateway provides the default routes for the Sonr hway.
|
|
||||||
package gateway
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/labstack/echo-contrib/echoprometheus"
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
echomiddleware "github.com/labstack/echo/v4/middleware"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/context"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/handlers"
|
|
||||||
config "github.com/onsonr/sonr/internal/config/hway"
|
|
||||||
hwayorm "github.com/onsonr/sonr/internal/database/hwayorm"
|
|
||||||
"github.com/onsonr/sonr/pkg/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Gateway = *echo.Echo
|
|
||||||
|
|
||||||
// New returns a new Gateway instance
|
|
||||||
func New(env config.Hway, ipc common.IPFS, dbq *hwayorm.Queries) (Gateway, error) {
|
|
||||||
e := echo.New()
|
|
||||||
|
|
||||||
// Built-in middleware
|
|
||||||
e.Use(echomiddleware.Logger())
|
|
||||||
e.Use(echomiddleware.Recover())
|
|
||||||
e.IPExtractor = echo.ExtractIPDirect()
|
|
||||||
e.Use(echoprometheus.NewMiddleware("hway"))
|
|
||||||
e.Use(context.UseGateway(env, ipc, dbq))
|
|
||||||
|
|
||||||
// Register View Handlers
|
|
||||||
e.HTTPErrorHandler = handlers.ErrorHandler
|
|
||||||
e.GET("/", handlers.IndexHandler)
|
|
||||||
handlers.RegisterHandler(e.Group("/register"))
|
|
||||||
return e, nil
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/context"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ErrorHandler(err error, c echo.Context) {
|
|
||||||
if he, ok := err.(*echo.HTTPError); ok {
|
|
||||||
// Log the error if needed
|
|
||||||
c.Logger().Errorf("Error: %v", he.Message)
|
|
||||||
context.RenderError(c, he)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/context"
|
|
||||||
)
|
|
||||||
|
|
||||||
func IndexHandler(c echo.Context) error {
|
|
||||||
id := context.GetSessionID(c)
|
|
||||||
if id == "" {
|
|
||||||
context.NewSession(c)
|
|
||||||
}
|
|
||||||
return context.RenderInitial(c)
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/context"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/islands"
|
|
||||||
"github.com/onsonr/sonr/app/gateway/views"
|
|
||||||
hwayorm "github.com/onsonr/sonr/internal/database/hwayorm"
|
|
||||||
"github.com/onsonr/sonr/pkg/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
func RegisterHandler(g *echo.Group) {
|
|
||||||
g.GET("/", renderProfileForm)
|
|
||||||
g.POST("/profile", validateProfileForm)
|
|
||||||
g.GET("/passkey", renderPasskeyForm)
|
|
||||||
g.POST("/passkey", validatePasskeyForm)
|
|
||||||
g.GET("/vault", renderVaultStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭──────────────────────────────────────────────────────╮
|
|
||||||
// │ Registration Views │
|
|
||||||
// ╰──────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
func renderProfileForm(c echo.Context) error {
|
|
||||||
params := context.CreateProfileParams{
|
|
||||||
FirstNumber: 6,
|
|
||||||
LastNumber: 3,
|
|
||||||
}
|
|
||||||
return context.Render(c, views.RegisterProfileView(params.FirstNumber, params.LastNumber))
|
|
||||||
}
|
|
||||||
|
|
||||||
func renderPasskeyForm(c echo.Context) error {
|
|
||||||
cc, err := context.GetGateway(c)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
handle := c.FormValue("handle")
|
|
||||||
origin := c.FormValue("origin")
|
|
||||||
name := c.FormValue("name")
|
|
||||||
cc.InsertProfile(context.BG(), hwayorm.InsertProfileParams{
|
|
||||||
Handle: handle,
|
|
||||||
Origin: origin,
|
|
||||||
Name: name,
|
|
||||||
})
|
|
||||||
|
|
||||||
params, err := cc.Spawn(handle, origin)
|
|
||||||
if err != nil {
|
|
||||||
return context.RenderError(c, err)
|
|
||||||
}
|
|
||||||
return context.Render(c, views.RegisterPasskeyView(params.Address, params.Handle, params.Name, params.Challenge, params.CreationBlock))
|
|
||||||
}
|
|
||||||
|
|
||||||
func renderVaultStatus(c echo.Context) error {
|
|
||||||
return context.Render(c, views.LoadingView())
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭─────────────────────────────────────────────────────────╮
|
|
||||||
// │ Validation Components │
|
|
||||||
// ╰─────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
func validateProfileForm(c echo.Context) error {
|
|
||||||
cc, err := context.GetGateway(c)
|
|
||||||
if err != nil {
|
|
||||||
return context.RenderError(c, err)
|
|
||||||
}
|
|
||||||
handle := c.FormValue("handle")
|
|
||||||
if handle == "" {
|
|
||||||
return context.Render(c, islands.InputHandleError(handle, "Please enter a 4-16 character handle"))
|
|
||||||
}
|
|
||||||
notok, err := cc.CheckHandleExists(context.BG(), handle)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if notok {
|
|
||||||
return context.Render(c, islands.InputHandleError(handle, "Handle is already taken"))
|
|
||||||
}
|
|
||||||
cc.WriteCookie(common.UserHandle, handle)
|
|
||||||
return context.Render(c, islands.InputHandleSuccess(handle))
|
|
||||||
}
|
|
||||||
|
|
||||||
func validatePasskeyForm(c echo.Context) error {
|
|
||||||
cc, err := context.GetGateway(c)
|
|
||||||
if err != nil {
|
|
||||||
return context.RenderError(c, err)
|
|
||||||
}
|
|
||||||
handle := context.GetProfileHandle(c)
|
|
||||||
origin := c.Request().Host
|
|
||||||
credentialJSON := c.FormValue("credential")
|
|
||||||
cred := &context.CredentialDescriptor{}
|
|
||||||
|
|
||||||
// Unmarshal the credential JSON
|
|
||||||
err = json.Unmarshal([]byte(credentialJSON), cred)
|
|
||||||
if err != nil {
|
|
||||||
return context.RenderError(c, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
md := cred.ToModel(handle, origin)
|
|
||||||
_, err = cc.InsertCredential(context.BG(), hwayorm.InsertCredentialParams{
|
|
||||||
Handle: md.Handle,
|
|
||||||
CredentialID: md.CredentialID,
|
|
||||||
Origin: md.Origin,
|
|
||||||
Type: md.Type,
|
|
||||||
Transports: md.Transports,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return context.RenderError(c, err)
|
|
||||||
}
|
|
||||||
return context.Render(c, views.LoadingView())
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package islands
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
templ HumanSlider(firstNumber int, lastNumber int) {
|
|
||||||
<div hx-target="this" hx-swap="outerHTML">
|
|
||||||
<sl-range name="is_human" label={ humanLabel(firstNumber, lastNumber) } help-text="Prove you are a human." min="0" max="9" step="1" hx-post="/register/profile/is_human"></sl-range>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ HumanSliderError(firstNumber int, lastNumber int) {
|
|
||||||
<sl-range name="is_human" label={ humanLabel(firstNumber, lastNumber) } help-text="Prove you are a human." min="0" max="9" step="1"></sl-range>
|
|
||||||
<div slot="help-text">
|
|
||||||
<sl-icon name="x-lg" library="sonr"></sl-icon>
|
|
||||||
Invalid Human Sum
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ HumanSliderSuccess() {
|
|
||||||
<sl-range name="is_human" label="Success! Welcome Human." help-text="Prove you are a human." min="0" max="9" step="1" value="9" disabled></sl-range>
|
|
||||||
}
|
|
||||||
|
|
||||||
func humanLabel(firstNumber int, lastNumber int) string {
|
|
||||||
return fmt.Sprintf("What is %d + %d?", firstNumber, lastNumber)
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ Form(action, id string) {
|
|
||||||
<form method="GET" action={ templ.SafeURL(action) } id={ id } hx-post={ action } hx-target="#{ id }" hx-swap="outerHTML">
|
|
||||||
{ children... }
|
|
||||||
</form>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ FormHeader() {
|
|
||||||
<div slot="header">
|
|
||||||
<div class="w-full py-2">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ FormBody() {
|
|
||||||
<sl-card class="card-form max-w-lg mx-auto">
|
|
||||||
{ children... }
|
|
||||||
<style>
|
|
||||||
.card-form {
|
|
||||||
space-y: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-form [slot='header'] {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-form [slot='footer'] {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</sl-card>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ FormFooter() {
|
|
||||||
<div slot="footer">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ FormCancel() {
|
|
||||||
<sl-button href="/" outline>
|
|
||||||
<sl-icon slot="prefix" name="x-lg"></sl-icon>
|
|
||||||
Cancel
|
|
||||||
</sl-button>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ FormSubmit(text string) {
|
|
||||||
<sl-button type="submit">
|
|
||||||
{ text }
|
|
||||||
<sl-icon slot="suffix" name="arrow-right" library="sonr"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
}
|
|
||||||
@@ -1,573 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
var (
|
|
||||||
nebulaHandle = templ.NewOnceHandle()
|
|
||||||
tailwindHandle = templ.NewOnceHandle()
|
|
||||||
alpineHandle = templ.NewOnceHandle()
|
|
||||||
dexieHandle = templ.NewOnceHandle()
|
|
||||||
htmxHandle = templ.NewOnceHandle()
|
|
||||||
turnstileHandle = templ.NewOnceHandle()
|
|
||||||
)
|
|
||||||
|
|
||||||
func Head(title string, nebulaVersion string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<head>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = Turnstile().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = Tailwind().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = Alpine().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = Htmx().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = Dexie().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = Nebula(nebulaVersion).Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var2 string
|
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 25, Col: 16}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</title><!-- Sets the status bar style to transparent --><meta name=\"apple-mobile-web-app-capable\" content=\"yes\"><meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\"><link rel=\"icon\" type=\"image/png\" href=\"https://cdn.sonr.id/favicon.png\"><style>\n \t\t@keyframes fade-in {\n \t\tfrom { opacity: 0; }\n \t\t}\n\n \t\t@keyframes fade-out {\n \t\tto { opacity: 0; }\n \t\t}\n\n \t\t@keyframes slide-from-right {\n \t\tfrom { transform: translateX(90px); }\n \t\t}\n\n \t\t@keyframes slide-to-left {\n \t\tto { transform: translateX(-90px); }\n \t\t}\n\n \t\t.slide-it {\n \t\tview-transition-name: slide-it;\n \t\t}\n\n \t\t::view-transition-old(slide-it) {\n \t\tanimation: 180ms cubic-bezier(0.4, 0, 1, 1) both fade-out,\n \t\t600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left;\n \t\t}\n \t\t::view-transition-new(slide-it) {\n \t\tanimation: 420ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,\n \t\t600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right;\n \t\t}\n\t\t</style>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</head>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭──────────────────────────────────────────────────────────╮
|
|
||||||
// │ 3rd Party Libraries │
|
|
||||||
// ╰──────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
// Tailwind css dependencies
|
|
||||||
func Tailwind() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var3 == nil {
|
|
||||||
templ_7745c5c3_Var3 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"https://cdn.tailwindcss.com?plugins=typography,aspect-ratio,container-queries\"></script> <script src=\"https://kit.fontawesome.com/9909219bb5.js\" crossorigin=\"anonymous\"></script>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = tailwindHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turnstile is used for cloudflare challenges
|
|
||||||
func Turnstile() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var5 == nil {
|
|
||||||
templ_7745c5c3_Var5 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"https://challenges.cloudflare.com/turnstile/v0/api.js\" async defer></script>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = turnstileHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alpine is a component that renders the Alpine.js library
|
|
||||||
func Alpine() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var7 == nil {
|
|
||||||
templ_7745c5c3_Var7 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var8 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var9 string
|
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("alpinejs", "3.14.6", "dist/cdn.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 86, Col: 68}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var10 string
|
|
||||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@alpinejs/focus", "3.14.6", "dist/cdn.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 87, Col: 75}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = alpineHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dexie is a component that renders the Dexie.js library
|
|
||||||
func Dexie() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var11 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var11 == nil {
|
|
||||||
templ_7745c5c3_Var11 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var13 string
|
|
||||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie", "4.0.10", "dist/dexie.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 94, Col: 67}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var14 string
|
|
||||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie-export-import", "4.1.4", "dist/dexie-export-import.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 95, Col: 94}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = dexieHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Htmx is a component that renders the Htmx.js library
|
|
||||||
func Htmx() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var15 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var15 == nil {
|
|
||||||
templ_7745c5c3_Var15 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var16 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var17 string
|
|
||||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx.org", "1.9.12", "dist/htmx.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 102, Col: 69}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var18 string
|
|
||||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-include-vals", "2.0.0", "include-vals.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 103, Col: 84}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var19 string
|
|
||||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-path-params", "2.0.0", "path-params.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 104, Col: 82}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var20 string
|
|
||||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-alpine-morph", "2.0.0", "alpine-morph.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 105, Col: 84}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var21 string
|
|
||||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-sse", "2.2.2", "sse.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 106, Col: 66}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var22 string
|
|
||||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-ws", "2.0.2", "ws.min.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 107, Col: 64}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nebula is a component that renders the Nebula.js library
|
|
||||||
func Nebula(version string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var23 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var23 == nil {
|
|
||||||
templ_7745c5c3_Var23 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<link rel=\"stylesheet\" media=\"(prefers-color-scheme:light)\" href=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var24 string
|
|
||||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/light.css"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 116, Col: 71}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><link rel=\"stylesheet\" media=\"(prefers-color-scheme:dark)\" href=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var25 string
|
|
||||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/dark.css"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 121, Col: 70}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" onload=\"document.documentElement.classList.add('sl-theme-dark');\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Var26 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script type=\"module\" src=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var27 string
|
|
||||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/shoelace-autoloader.js"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_head.templ`, Line: 125, Col: 98}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = nebulaHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var26), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭───────────────────────────────────────────────────────────╮
|
|
||||||
// │ Helper Functions │
|
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
func jsDelivrURL(pkg string, version string, path string) string {
|
|
||||||
return fmt.Sprintf("https://cdn.jsdelivr.net/npm/%s@%s/%s", pkg, version, path)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ HeroTitle(title string, subtitle string) {
|
|
||||||
<div class="flex flex-col items-center justify-center h-full w-full gap-2.5">
|
|
||||||
<h1 class="text-2xl md:text-3xl lg:text-4xl font-bold">
|
|
||||||
{ title }
|
|
||||||
</h1>
|
|
||||||
<p class="text-md md:text-lg lg:text-xl font-medium text-gray-500">
|
|
||||||
{ subtitle }
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ HeroStart() {
|
|
||||||
<div class="pt-1.5 mb-3 flex flex-col items-center justify-center h-full">
|
|
||||||
<sl-button size="large" hx-target="#container" hx-get="/register" hx-push-url="/register" type="button">
|
|
||||||
<sl-icon slot="prefix" library="sonr" name="sonr"></sl-icon>
|
|
||||||
Create Vault
|
|
||||||
<sl-icon slot="suffix" library="sonr" name="arrow-right"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ HeroSocials() {
|
|
||||||
<div class="pt-1.5 flex flex-row items-center justify-center h-full gap-3">
|
|
||||||
<sl-button circle outline href="https://sonr.io">
|
|
||||||
<sl-icon name="home" library="sonr" label="Home"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
<sl-button circle outline href="https://onsonr.dev">
|
|
||||||
<sl-icon name="docs" library="sonr" label="Docs"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
<sl-button circle outline href="https://github.com/onsonr/sonr">
|
|
||||||
<sl-icon name="social-github" library="sonr" label="Open Source"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
func HeroTitle(title string, subtitle string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
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("<div class=\"flex flex-col items-center justify-center h-full w-full gap-2.5\"><h1 class=\"text-2xl md:text-3xl lg:text-4xl font-bold\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var2 string
|
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_hero.templ`, Line: 6, Col: 10}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><p class=\"text-md md:text-lg lg:text-xl font-medium text-gray-500\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var3 string
|
|
||||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(subtitle)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_hero.templ`, Line: 9, Col: 13}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func HeroStart() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var4 == nil {
|
|
||||||
templ_7745c5c3_Var4 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"pt-1.5 mb-3 flex flex-col items-center justify-center h-full\"><sl-button size=\"large\" hx-target=\"#container\" hx-get=\"/register\" hx-push-url=\"/register\" type=\"button\"><sl-icon slot=\"prefix\" library=\"sonr\" name=\"sonr\"></sl-icon> Create Vault <sl-icon slot=\"suffix\" library=\"sonr\" name=\"arrow-right\"></sl-icon></sl-button></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func HeroSocials() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var5 == nil {
|
|
||||||
templ_7745c5c3_Var5 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"pt-1.5 flex flex-row items-center justify-center h-full gap-3\"><sl-button circle outline href=\"https://sonr.io\"><sl-icon name=\"home\" library=\"sonr\" label=\"Home\"></sl-icon></sl-button> <sl-button circle outline href=\"https://onsonr.dev\"><sl-icon name=\"docs\" library=\"sonr\" label=\"Docs\"></sl-icon></sl-button> <sl-button circle outline href=\"https://github.com/onsonr/sonr\"><sl-icon name=\"social-github\" library=\"sonr\" label=\"Open Source\"></sl-icon></sl-button></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ LayoutContainer() {
|
|
||||||
<div id="container" class="flex fixed inset-0 z-[99] w-screen min-h-screen">
|
|
||||||
<div class="relative flex flex-wrap items-center w-full min-h-full px-4 py-6 sm:px-6 md:px-8">
|
|
||||||
<div class="relative w-full max-w-screen-lg mx-auto">
|
|
||||||
<div class="flex flex-col items-center justify-center min-h-full gap-4">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
// Columns is a component that renders a responsive flex container that stacks on mobile
|
|
||||||
templ LayoutColumns() {
|
|
||||||
<div class="flex flex-col h-full w-full gap-4 md:gap-6 md:flex-row md:flex-wrap">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rows is a component that renders a responsive flex container that wraps on mobile
|
|
||||||
templ LayoutRows() {
|
|
||||||
<div class="flex flex-col w-full gap-3 sm:flex-row sm:flex-wrap sm:gap-4">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ LayoutSeparator(text string) {
|
|
||||||
<div class="relative py-6">
|
|
||||||
<div class="absolute inset-0 flex items-center"><span class="w-full border-t"></span></div>
|
|
||||||
<div class="relative flex justify-center text-xs uppercase">
|
|
||||||
<span class="px-2 text-neutral-500">{ text }</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
// Layout is a component that renders the general layout of the application
|
|
||||||
templ LayoutView(title string) {
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
@Head(title, "0.0.11")
|
|
||||||
<body class="flex items-center justify-center h-full lg:p-24 md:16 p-4 no-scrollbar">
|
|
||||||
<main class="flex-row items-center justify-center mx-auto w-fit max-w-screen-lg gap-y-3">
|
|
||||||
{ children... }
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
}
|
|
||||||
|
|
||||||
func Clsx(attrs ...templ.Attributes) templ.Attributes {
|
|
||||||
merged := templ.Attributes{}
|
|
||||||
for _, attr := range attrs {
|
|
||||||
for k, v := range attr {
|
|
||||||
merged[k] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return merged
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
func LayoutContainer() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"container\" class=\"flex fixed inset-0 z-[99] w-screen min-h-screen\"><div class=\"relative flex flex-wrap items-center w-full min-h-full px-4 py-6 sm:px-6 md:px-8\"><div class=\"relative w-full max-w-screen-lg mx-auto\"><div class=\"flex flex-col items-center justify-center min-h-full gap-4\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Columns is a component that renders a responsive flex container that stacks on mobile
|
|
||||||
func LayoutColumns() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var2 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var2 == nil {
|
|
||||||
templ_7745c5c3_Var2 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col h-full w-full gap-4 md:gap-6 md:flex-row md:flex-wrap\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var2.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rows is a component that renders a responsive flex container that wraps on mobile
|
|
||||||
func LayoutRows() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var3 == nil {
|
|
||||||
templ_7745c5c3_Var3 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col w-full gap-3 sm:flex-row sm:flex-wrap sm:gap-4\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func LayoutSeparator(text string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var4 == nil {
|
|
||||||
templ_7745c5c3_Var4 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"relative py-6\"><div class=\"absolute inset-0 flex items-center\"><span class=\"w-full border-t\"></span></div><div class=\"relative flex justify-center text-xs uppercase\"><span class=\"px-2 text-neutral-500\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var5 string
|
|
||||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/base_layout.templ`, Line: 33, Col: 45}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></div></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Layout is a component that renders the general layout of the application
|
|
||||||
func LayoutView(title string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var6 == nil {
|
|
||||||
templ_7745c5c3_Var6 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = Head(title, "0.0.11").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<body class=\"flex items-center justify-center h-full lg:p-24 md:16 p-4 no-scrollbar\"><main class=\"flex-row items-center justify-center mx-auto w-fit max-w-screen-lg gap-y-3\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var6.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main></body></html>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func Clsx(attrs ...templ.Attributes) templ.Attributes {
|
|
||||||
merged := templ.Attributes{}
|
|
||||||
for _, attr := range attrs {
|
|
||||||
for k, v := range attr {
|
|
||||||
merged[k] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return merged
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ ErrorView(err string) {
|
|
||||||
@LayoutView("Error | Sonr.ID") {
|
|
||||||
@LayoutContainer() {
|
|
||||||
@HeroTitle("Uh oh!", "Something went wrong.")
|
|
||||||
<div class="pt-3 flex flex-col items-center justify-center h-full">
|
|
||||||
<p class="text-red-500">
|
|
||||||
{ err }
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
func ErrorView(err string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_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 = HeroTitle("Uh oh!", "Something went wrong.").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <div class=\"pt-3 flex flex-col items-center justify-center h-full\"><p class=\"text-red-500\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var4 string
|
|
||||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(err)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/gateway/views/view_errors.templ`, Line: 9, Col: 10}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutView("Error | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ InitialView() {
|
|
||||||
@LayoutView("Sonr.ID") {
|
|
||||||
@LayoutContainer() {
|
|
||||||
@HeroTitle("Sonr.ID", "The decentralized identity layer for the web.")
|
|
||||||
@HeroStart()
|
|
||||||
@HeroSocials()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
templ ReturningView() {
|
|
||||||
@LayoutView("Login | Sonr.ID") {
|
|
||||||
@LayoutContainer() {
|
|
||||||
@HeroTitle("Welcome Back!", "Continue with your existing Sonr.ID.")
|
|
||||||
<div class="pt-3 flex flex-col items-center justify-center h-full">
|
|
||||||
<sl-button hx-target="#container" hx-get="/register" type="button">
|
|
||||||
<sl-icon slot="prefix" library="sonr" name="sonr"></sl-icon>
|
|
||||||
Log back in
|
|
||||||
<sl-icon slot="suffix" library="sonr" name="arrow-right"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ LoadingView() {
|
|
||||||
@LayoutView("Loading... | Sonr.ID") {
|
|
||||||
@LayoutContainer() {
|
|
||||||
@HeroTitle("Loading Vault", "This will be used to login to your vault.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
func LoadingView() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_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 = HeroTitle("Loading Vault", "This will be used to login to your vault.").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutView("Loading... | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
import "github.com/onsonr/sonr/app/gateway/islands"
|
|
||||||
|
|
||||||
templ RegisterProfileView(firstNumber int, lastNumber int) {
|
|
||||||
@LayoutView("New Profile | Sonr.ID") {
|
|
||||||
@LayoutContainer() {
|
|
||||||
@HeroTitle("Basic Info", "Tell us a little about yourself.")
|
|
||||||
@Form("/register/passkey", "create-profile") {
|
|
||||||
@FormBody() {
|
|
||||||
@FormHeader() {
|
|
||||||
<div class="w-full py-2">
|
|
||||||
<sl-avatar shape="circle" size="large" src="https://avatars.githubusercontent.com/u/101929?v=4"></sl-avatar>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@islands.InputHandle()
|
|
||||||
@islands.HumanSlider(firstNumber, lastNumber)
|
|
||||||
@FormFooter() {
|
|
||||||
@FormCancel()
|
|
||||||
@FormSubmit("Next")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
templ RegisterPasskeyView(address string, handle string, name string, challenge string, creationBlock string) {
|
|
||||||
@LayoutView("Register | Sonr.ID") {
|
|
||||||
@LayoutContainer() {
|
|
||||||
@HeroTitle("Link a PassKey", "This will be used to login to your vault.")
|
|
||||||
@Form("/register/finish", "passkey-form") {
|
|
||||||
<input type="hidden" name="credential" id="credential-data" required/>
|
|
||||||
@FormBody() {
|
|
||||||
@FormHeader() {
|
|
||||||
@islands.CardAccount(address, name, handle, creationBlock)
|
|
||||||
}
|
|
||||||
@islands.CoinSelect()
|
|
||||||
@FormFooter() {
|
|
||||||
@islands.InputPasskey(address, handle, challenge)
|
|
||||||
@FormCancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,363 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
import "github.com/onsonr/sonr/app/gateway/islands"
|
|
||||||
|
|
||||||
func RegisterProfileView(firstNumber int, lastNumber int) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_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 = HeroTitle("Basic Info", "Tell us a little about yourself.").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var5 := 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_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"w-full py-2\"><sl-avatar shape=\"circle\" size=\"large\" src=\"https://avatars.githubusercontent.com/u/101929?v=4\"></sl-avatar></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = FormHeader().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = islands.InputHandle().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = islands.HumanSlider(firstNumber, lastNumber).Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Var7 := 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 = FormCancel().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = FormSubmit("Next").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = FormFooter().Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = FormBody().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = Form("/register/passkey", "create-profile").Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutView("New Profile | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterPasskeyView(address string, handle string, name string, challenge string, creationBlock string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var8 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var8 == nil {
|
|
||||||
templ_7745c5c3_Var8 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var9 := 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_Var10 := 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 = HeroTitle("Link a PassKey", "This will be used to login to your vault.").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Var11 := 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("<input type=\"hidden\" name=\"credential\" id=\"credential-data\" required>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var13 := 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 = islands.CardAccount(address, name, handle, creationBlock).Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = FormHeader().Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = islands.CoinSelect().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Var14 := 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 = islands.InputPasskey(address, handle, challenge).Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = FormCancel().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = FormFooter().Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = FormBody().Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = Form("/register/finish", "passkey-form").Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var10), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutView("Register | Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package handlers
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package handlers
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package handlers
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
//go:build js && wasm
|
|
||||||
|
|
||||||
package vault
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
echomiddleware "github.com/labstack/echo/v4/middleware"
|
|
||||||
"github.com/onsonr/sonr/app/vault/context"
|
|
||||||
"github.com/onsonr/sonr/internal/config/motr"
|
|
||||||
"github.com/onsonr/sonr/internal/database/motrorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Vault = *echo.Echo
|
|
||||||
|
|
||||||
// New returns a new Vault instance
|
|
||||||
func New(config *motr.Config, dbq *motrorm.Queries) (Vault, error) {
|
|
||||||
e := echo.New()
|
|
||||||
// Override default behaviors
|
|
||||||
e.IPExtractor = echo.ExtractIPDirect()
|
|
||||||
e.HTTPErrorHandler = handleError()
|
|
||||||
|
|
||||||
// Built-in middleware
|
|
||||||
e.Use(echomiddleware.Logger())
|
|
||||||
e.Use(echomiddleware.Recover())
|
|
||||||
e.Use(context.WASMMiddleware)
|
|
||||||
registerRoutes(e)
|
|
||||||
return e, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleError() echo.HTTPErrorHandler {
|
|
||||||
return func(err error, c echo.Context) {
|
|
||||||
if he, ok := err.(*echo.HTTPError); ok {
|
|
||||||
// Log the error if needed
|
|
||||||
c.Logger().Errorf("Error: %v", he.Message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterRoutes registers the Decentralized Web Node API routes.
|
|
||||||
func registerRoutes(e *echo.Echo) {
|
|
||||||
}
|
|
||||||
@@ -1,243 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
func Form(action, id string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form hx-post=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var2 string
|
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(action)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/vault/views/base_form.templ`, Line: 4, Col: 23}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"#{ id }\" hx-swap=\"outerHTML\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</form>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func FormHeader() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var3 == nil {
|
|
||||||
templ_7745c5c3_Var3 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div slot=\"header\"><div class=\"w-full py-2\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func FormBody() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var4 == nil {
|
|
||||||
templ_7745c5c3_Var4 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<sl-card class=\"card-form max-w-lg mx-auto\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var4.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<style>\n\t\t.card-form {\n\t\t\t\tspace-y: 1rem;\n\t\t}\n\n \t.card-form [slot='header'] {\n \tdisplay: flex;\n \talign-items: center;\n \t justify-content: space-between;\n\t }\n\n\t .card-form [slot='footer'] {\n \t \tdisplay: flex;\n \tjustify-content: space-between;\n \talign-items: center;\n \t}\n\t\t</style></sl-card>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func FormFooter() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var5 == nil {
|
|
||||||
templ_7745c5c3_Var5 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div slot=\"footer\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var5.Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func FormCancel() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var6 == nil {
|
|
||||||
templ_7745c5c3_Var6 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<sl-button href=\"/\" outline><sl-icon slot=\"prefix\" name=\"x-lg\"></sl-icon> Cancel</sl-button>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func FormSubmit(text string) templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var7 == nil {
|
|
||||||
templ_7745c5c3_Var7 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<sl-button type=\"submit\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var8 string
|
|
||||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/vault/views/base_form.templ`, Line: 55, Col: 8}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <sl-icon slot=\"suffix\" name=\"arrow-right\" library=\"sonr\"></sl-icon></sl-button>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
var (
|
|
||||||
nebulaHandle = templ.NewOnceHandle()
|
|
||||||
tailwindHandle = templ.NewOnceHandle()
|
|
||||||
alpineHandle = templ.NewOnceHandle()
|
|
||||||
dexieHandle = templ.NewOnceHandle()
|
|
||||||
htmxHandle = templ.NewOnceHandle()
|
|
||||||
turnstileHandle = templ.NewOnceHandle()
|
|
||||||
)
|
|
||||||
|
|
||||||
templ Head(title string, nebulaVersion string) {
|
|
||||||
<head>
|
|
||||||
@Turnstile()
|
|
||||||
@Tailwind()
|
|
||||||
@Alpine()
|
|
||||||
@Htmx()
|
|
||||||
@Dexie()
|
|
||||||
@Nebula(nebulaVersion)
|
|
||||||
<meta charset="UTF-8"/>
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
||||||
<title>{ title }</title>
|
|
||||||
<!-- Sets the status bar style to transparent -->
|
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
|
|
||||||
<link rel="icon" type="image/png" href="https://cdn.sonr.id/favicon.png"/>
|
|
||||||
<style>
|
|
||||||
@keyframes fade-in {
|
|
||||||
from { opacity: 0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fade-out {
|
|
||||||
to { opacity: 0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes slide-from-right {
|
|
||||||
from { transform: translateX(90px); }
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes slide-to-left {
|
|
||||||
to { transform: translateX(-90px); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-it {
|
|
||||||
view-transition-name: slide-it;
|
|
||||||
}
|
|
||||||
|
|
||||||
::view-transition-old(slide-it) {
|
|
||||||
animation: 180ms cubic-bezier(0.4, 0, 1, 1) both fade-out,
|
|
||||||
600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left;
|
|
||||||
}
|
|
||||||
::view-transition-new(slide-it) {
|
|
||||||
animation: 420ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,
|
|
||||||
600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{ children... }
|
|
||||||
</head>
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭──────────────────────────────────────────────────────────╮
|
|
||||||
// │ 3rd Party Libraries │
|
|
||||||
// ╰──────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
// Tailwind css dependencies
|
|
||||||
templ Tailwind() {
|
|
||||||
@tailwindHandle.Once() {
|
|
||||||
<script src="https://cdn.tailwindcss.com?plugins=typography,aspect-ratio,container-queries"></script>
|
|
||||||
<script src="https://kit.fontawesome.com/9909219bb5.js" crossorigin="anonymous"></script>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turnstile is used for cloudflare challenges
|
|
||||||
templ Turnstile() {
|
|
||||||
@turnstileHandle.Once() {
|
|
||||||
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alpine is a component that renders the Alpine.js library
|
|
||||||
templ Alpine() {
|
|
||||||
@alpineHandle.Once() {
|
|
||||||
<script src={ jsDelivrURL("alpinejs", "3.14.6", "dist/cdn.min.js") }></script>
|
|
||||||
<script src={ jsDelivrURL("@alpinejs/focus", "3.14.6", "dist/cdn.min.js") }></script>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dexie is a component that renders the Dexie.js library
|
|
||||||
templ Dexie() {
|
|
||||||
@dexieHandle.Once() {
|
|
||||||
<script src={ jsDelivrURL("dexie", "4.0.10", "dist/dexie.min.js") }></script>
|
|
||||||
<script src={ jsDelivrURL("dexie-export-import", "4.1.4", "dist/dexie-export-import.min.js") }></script>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Htmx is a component that renders the Htmx.js library
|
|
||||||
templ Htmx() {
|
|
||||||
@htmxHandle.Once() {
|
|
||||||
<script src={ jsDelivrURL("htmx.org", "1.9.12", "dist/htmx.min.js") }></script>
|
|
||||||
<script src={ jsDelivrURL("htmx-ext-include-vals", "2.0.0", "include-vals.min.js") }></script>
|
|
||||||
<script src={ jsDelivrURL("htmx-ext-path-params", "2.0.0", "path-params.min.js") }></script>
|
|
||||||
<script src={ jsDelivrURL("htmx-ext-alpine-morph", "2.0.0", "alpine-morph.min.js") }></script>
|
|
||||||
<script src={ jsDelivrURL("htmx-ext-sse", "2.2.2", "sse.min.js") }></script>
|
|
||||||
<script src={ jsDelivrURL("htmx-ext-ws", "2.0.2", "ws.min.js") }></script>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nebula is a component that renders the Nebula.js library
|
|
||||||
templ Nebula(version string) {
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
media="(prefers-color-scheme:light)"
|
|
||||||
href={ jsDelivrURL("@onsonr/nebula", version, "cdn/themes/light.css") }
|
|
||||||
/>
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
media="(prefers-color-scheme:dark)"
|
|
||||||
href={ jsDelivrURL("@onsonr/nebula", version, "cdn/themes/dark.css") }
|
|
||||||
onload="document.documentElement.classList.add('sl-theme-dark');"
|
|
||||||
/>
|
|
||||||
@nebulaHandle.Once() {
|
|
||||||
<script type="module" src={ jsDelivrURL("@onsonr/nebula", version, "cdn/shoelace-autoloader.js") }></script>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ╭───────────────────────────────────────────────────────────╮
|
|
||||||
// │ Helper Functions │
|
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
func jsDelivrURL(pkg string, version string, path string) string {
|
|
||||||
return fmt.Sprintf("https://cdn.jsdelivr.net/npm/%s@%s/%s", pkg, version, path)
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ HeroTitle(title string, subtitle string) {
|
|
||||||
<div class="flex flex-col items-center justify-center h-full w-full gap-2.5">
|
|
||||||
<h1 class="text-2xl md:text-3xl lg:text-4xl font-bold">
|
|
||||||
{ title }
|
|
||||||
</h1>
|
|
||||||
<p class="text-md md:text-lg lg:text-xl font-medium text-gray-500">
|
|
||||||
{ subtitle }
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ HeroStart() {
|
|
||||||
<div class="pt-1.5 mb-3 flex flex-col items-center justify-center h-full">
|
|
||||||
<sl-button size="large" hx-target="#container" hx-get="/register" hx-push-url="/register" type="button">
|
|
||||||
<sl-icon slot="prefix" library="sonr" name="sonr"></sl-icon>
|
|
||||||
Create Vault
|
|
||||||
<sl-icon slot="suffix" library="sonr" name="arrow-right"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ HeroSocials() {
|
|
||||||
<div class="pt-1.5 flex flex-row items-center justify-center h-full gap-3">
|
|
||||||
<sl-button circle outline href="https://sonr.io">
|
|
||||||
<sl-icon name="home" library="sonr" label="Home"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
<sl-button circle outline href="https://onsonr.dev">
|
|
||||||
<sl-icon name="docs" library="sonr" label="Docs"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
<sl-button circle outline href="https://github.com/onsonr/sonr">
|
|
||||||
<sl-icon name="social-github" library="sonr" label="Open Source"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
templ LayoutContainer() {
|
|
||||||
<div id="container" class="flex fixed inset-0 z-[99] w-screen min-h-screen">
|
|
||||||
<div class="relative flex flex-wrap items-center w-full min-h-full px-4 py-6 sm:px-6 md:px-8">
|
|
||||||
<div class="relative w-full max-w-screen-lg mx-auto">
|
|
||||||
<div class="flex flex-col items-center justify-center min-h-full gap-4">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
// Columns is a component that renders a responsive flex container that stacks on mobile
|
|
||||||
templ LayoutColumns() {
|
|
||||||
<div class="flex flex-col h-full w-full gap-4 md:gap-6 md:flex-row md:flex-wrap">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rows is a component that renders a responsive flex container that wraps on mobile
|
|
||||||
templ LayoutRows() {
|
|
||||||
<div class="flex flex-col w-full gap-3 sm:flex-row sm:flex-wrap sm:gap-4">
|
|
||||||
{ children... }
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
templ LayoutSeparator(text string) {
|
|
||||||
<div class="relative py-6">
|
|
||||||
<div class="absolute inset-0 flex items-center"><span class="w-full border-t"></span></div>
|
|
||||||
<div class="relative flex justify-center text-xs uppercase">
|
|
||||||
<span class="px-2 text-neutral-500">{ text }</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
// Layout is a component that renders the general layout of the application
|
|
||||||
templ LayoutView(title string) {
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
@Head(title, "0.0.11")
|
|
||||||
<body class="flex items-center justify-center h-full lg:p-24 md:16 p-4 no-scrollbar">
|
|
||||||
<main class="flex-row items-center justify-center mx-auto w-fit max-w-screen-lg gap-y-3">
|
|
||||||
{ children... }
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
}
|
|
||||||
|
|
||||||
func Clsx(attrs ...templ.Attributes) templ.Attributes {
|
|
||||||
merged := templ.Attributes{}
|
|
||||||
for _, attr := range attrs {
|
|
||||||
for k, v := range attr {
|
|
||||||
merged[k] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return merged
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
templ InitialView() {
|
|
||||||
@LayoutView("Sonr.ID") {
|
|
||||||
@LayoutContainer() {
|
|
||||||
@HeroTitle("Sonr.ID", "The decentralized identity layer for the web.")
|
|
||||||
@HeroStart()
|
|
||||||
@HeroSocials()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.2.793
|
|
||||||
package views
|
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
||||||
|
|
||||||
import "github.com/a-h/templ"
|
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
func InitialView() templ.Component {
|
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_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 = HeroTitle("Sonr.ID", "The decentralized identity layer for the web.").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = HeroStart().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = HeroSocials().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
templ_7745c5c3_Err = LayoutView("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
+4
-9
@@ -7,7 +7,7 @@
|
|||||||
"binary": "sonrd",
|
"binary": "sonrd",
|
||||||
"bech32_prefix": "idx",
|
"bech32_prefix": "idx",
|
||||||
"docker_image": {
|
"docker_image": {
|
||||||
"repository": "ghcr.io/onsonr/sonr",
|
"repository": "core",
|
||||||
"version": "local"
|
"version": "local"
|
||||||
},
|
},
|
||||||
"gas_prices": "0usnr",
|
"gas_prices": "0usnr",
|
||||||
@@ -24,18 +24,13 @@
|
|||||||
"1317": "1317",
|
"1317": "1317",
|
||||||
"9090": "9090"
|
"9090": "9090"
|
||||||
},
|
},
|
||||||
"encoding-options": [
|
"encoding-options": ["wasm", "tokenfactory"],
|
||||||
"wasm",
|
|
||||||
"tokenfactory"
|
|
||||||
],
|
|
||||||
"config_file_overrides": [
|
"config_file_overrides": [
|
||||||
{
|
{
|
||||||
"file": "config/config.toml",
|
"file": "config/config.toml",
|
||||||
"paths": {
|
"paths": {
|
||||||
"moniker": "florence",
|
"moniker": "localvalmoniker",
|
||||||
"rpc.cors_allowed_origins": [
|
"rpc.cors_allowed_origins": ["*"]
|
||||||
"*"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
+46
-40
@@ -5,27 +5,28 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/onsonr/sonr/pkg/common"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/onsonr/sonr/app/gateway"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
|
"github.com/onsonr/sonr/crypto/ucan"
|
||||||
|
"github.com/onsonr/sonr/internal/gateway"
|
||||||
|
"github.com/onsonr/sonr/pkg/common/ipfs"
|
||||||
|
config "github.com/onsonr/sonr/pkg/config/hway"
|
||||||
|
"github.com/onsonr/sonr/pkg/database/sessions"
|
||||||
|
"github.com/onsonr/sonr/pkg/didauth/producer"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command line flags
|
// Command line flags
|
||||||
var (
|
var (
|
||||||
servePort int // Gateway http entry point (default 3000)
|
servePort int // Gateway http entry point (default 3000)
|
||||||
|
configDir string // Hway config directory (default hway)
|
||||||
|
sqliteFile string // SQLite database file (default hway.db)
|
||||||
chainID string // Current chain ID (default sonr-testnet-1)
|
chainID string // Current chain ID (default sonr-testnet-1)
|
||||||
ipfsGatewayURL string // IPFS gateway URL (default localhost:8080)
|
ipfsGatewayURL string // IPFS gateway URL (default localhost:8080)
|
||||||
sonrAPIURL string // Sonr API URL (default localhost:1317)
|
sonrAPIURL string // Sonr API URL (default localhost:1317)
|
||||||
sonrGrpcURL string // Sonr gRPC URL (default localhost:9090)
|
sonrGrpcURL string // Sonr gRPC URL (default localhost:9090)
|
||||||
sonrRPCURL string // Sonr RPC URL (default localhost:26657)
|
sonrRPCURL string // Sonr RPC URL (default localhost:26657)
|
||||||
|
|
||||||
psqlHost string // PostgresSQL Host Flag
|
|
||||||
psqlPort string // PostgresSQL Port Flag
|
|
||||||
psqlUser string // PostgresSQL User Flag
|
|
||||||
psqlPass string // PostgresSQL Password Flag
|
|
||||||
psqlDB string // PostgresSQL Database Flag
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func rootCmd() *cobra.Command {
|
func rootCmd() *cobra.Command {
|
||||||
@@ -37,15 +38,7 @@ func rootCmd() *cobra.Command {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ipc, err := common.NewIPFS()
|
e, err := setupServer(env)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
dbq, err := setupPostgresDB()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
e, err := gateway.New(env, ipc, dbq)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -57,37 +50,50 @@ func rootCmd() *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().IntVar(&servePort, "serve-port", 3000, "Port to serve the gateway on")
|
cmd.Flags().IntVar(&servePort, "serve-port", 3000, "Port to serve the gateway on")
|
||||||
|
cmd.Flags().StringVar(&configDir, "config-dir", "hway", "Directory to store config files")
|
||||||
|
cmd.Flags().StringVar(&sqliteFile, "sqlite-file", "hway.db", "File to store sqlite database")
|
||||||
cmd.Flags().StringVar(&chainID, "chain-id", "sonr-testnet-1", "Chain ID")
|
cmd.Flags().StringVar(&chainID, "chain-id", "sonr-testnet-1", "Chain ID")
|
||||||
cmd.Flags().StringVar(&ipfsGatewayURL, "ipfs-gateway-url", "localhost:8080", "IPFS gateway URL")
|
cmd.Flags().StringVar(&ipfsGatewayURL, "ipfs-gateway-url", "localhost:8080", "IPFS gateway URL")
|
||||||
cmd.Flags().StringVar(&sonrAPIURL, "sonr-api-url", "localhost:1317", "Sonr API URL")
|
cmd.Flags().StringVar(&sonrAPIURL, "sonr-api-url", "localhost:1317", "Sonr API URL")
|
||||||
cmd.Flags().StringVar(&sonrGrpcURL, "sonr-grpc-url", "localhost:9090", "Sonr gRPC URL")
|
cmd.Flags().StringVar(&sonrGrpcURL, "sonr-grpc-url", "localhost:9090", "Sonr gRPC URL")
|
||||||
cmd.Flags().StringVar(&sonrRPCURL, "sonr-rpc-url", "localhost:26657", "Sonr RPC URL")
|
cmd.Flags().StringVar(&sonrRPCURL, "sonr-rpc-url", "localhost:26657", "Sonr RPC URL")
|
||||||
cmd.Flags().StringVar(&psqlHost, "psql-host", "localhost", "PostgresSQL Host")
|
|
||||||
cmd.Flags().StringVar(&psqlPort, "psql-port", "5432", "PostgresSQL Port")
|
|
||||||
cmd.Flags().StringVar(&psqlUser, "psql-user", "highway_user", "PostgresSQL User")
|
|
||||||
cmd.Flags().StringVar(&psqlPass, "psql-pass", "highway_password123", "PostgresSQL Password")
|
|
||||||
cmd.Flags().StringVar(&psqlDB, "psql-db", "highway", "PostgresSQL Database")
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatPsqlDSN() string {
|
func loadEnvImplFromArgs(args []string) (config.Hway, error) {
|
||||||
if psqlHost == "" {
|
cmd := rootCmd()
|
||||||
return ""
|
if err := cmd.ParseFlags(args); err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
host := psqlHost
|
env := &config.HwayImpl{
|
||||||
port := "5432"
|
ServePort: servePort,
|
||||||
|
ConfigDir: configDir,
|
||||||
if parts := strings.Split(psqlHost, ":"); len(parts) == 2 {
|
SqliteFile: sqliteFile,
|
||||||
host = parts[0]
|
ChainId: chainID,
|
||||||
port = parts[1]
|
IpfsGatewayUrl: ipfsGatewayURL,
|
||||||
|
SonrApiUrl: sonrAPIURL,
|
||||||
|
SonrGrpcUrl: sonrGrpcURL,
|
||||||
|
SonrRpcUrl: sonrRPCURL,
|
||||||
}
|
}
|
||||||
|
return env, nil
|
||||||
dsn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=verify-full",
|
}
|
||||||
host, port, psqlUser, psqlPass, psqlDB)
|
|
||||||
|
// setupServer sets up the server
|
||||||
log.Printf("Attempting to connect to PostgreSQL with DSN: host=%s port=%s user=%s dbname=%s",
|
func setupServer(env config.Hway) (*echo.Echo, error) {
|
||||||
host, port, psqlUser, psqlDB) // Don't log the password
|
ipc, err := ipfs.NewClient()
|
||||||
|
if err != nil {
|
||||||
return dsn
|
return nil, err
|
||||||
|
}
|
||||||
|
db, err := sessions.NewGormDB(env)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
e := echo.New()
|
||||||
|
e.IPExtractor = echo.ExtractIPDirect()
|
||||||
|
e.Use(middleware.Logger())
|
||||||
|
e.Use(middleware.Recover())
|
||||||
|
e.Use(producer.Middleware(ipc, ucan.ServicePermissions))
|
||||||
|
gateway.RegisterRoutes(e, env, db)
|
||||||
|
return e, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5"
|
|
||||||
config "github.com/onsonr/sonr/internal/config/hway"
|
|
||||||
hwayorm "github.com/onsonr/sonr/internal/database/hwayorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// main is the entry point for the application
|
// main is the entry point for the application
|
||||||
@@ -20,30 +15,3 @@ func main() {
|
|||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadEnvImplFromArgs(args []string) (config.Hway, error) {
|
|
||||||
cmd := rootCmd()
|
|
||||||
if err := cmd.ParseFlags(args); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
env := &config.HwayImpl{
|
|
||||||
ServePort: servePort,
|
|
||||||
ChainId: chainID,
|
|
||||||
IpfsGatewayUrl: ipfsGatewayURL,
|
|
||||||
SonrApiUrl: sonrAPIURL,
|
|
||||||
SonrGrpcUrl: sonrGrpcURL,
|
|
||||||
SonrRpcUrl: sonrRPCURL,
|
|
||||||
PsqlDSN: formatPsqlDSN(),
|
|
||||||
}
|
|
||||||
return env, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func setupPostgresDB() (*hwayorm.Queries, error) {
|
|
||||||
pgdsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", psqlHost, psqlUser, psqlPass, psqlDB)
|
|
||||||
conn, err := pgx.Connect(context.Background(), pgdsn)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return hwayorm.New(conn), nil
|
|
||||||
}
|
|
||||||
|
|||||||
+39
-243
@@ -4,256 +4,52 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"database/sql"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
||||||
_ "github.com/ncruces/go-sqlite3/driver"
|
"github.com/labstack/echo/v4"
|
||||||
_ "github.com/ncruces/go-sqlite3/embed"
|
"github.com/onsonr/sonr/internal/vault"
|
||||||
vault "github.com/onsonr/sonr/app/vault"
|
"github.com/onsonr/sonr/pkg/common/wasm"
|
||||||
"github.com/onsonr/sonr/internal/config/motr"
|
"github.com/onsonr/sonr/pkg/config/motr"
|
||||||
"github.com/onsonr/sonr/internal/database/motrorm"
|
"github.com/onsonr/sonr/pkg/didauth/controller"
|
||||||
sink "github.com/onsonr/sonr/internal/database/sink"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Global buffer pool to reduce allocations
|
env *motr.Environment
|
||||||
bufferPool = sync.Pool{
|
config *motr.Config
|
||||||
New: func() interface{} {
|
err error
|
||||||
return new(bytes.Buffer)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cached JS globals
|
|
||||||
jsGlobal = js.Global()
|
|
||||||
jsUint8Array = jsGlobal.Get("Uint8Array")
|
|
||||||
jsResponse = jsGlobal.Get("Response")
|
|
||||||
jsPromise = jsGlobal.Get("Promise")
|
|
||||||
jsWasmHTTP = jsGlobal.Get("wasmhttp")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func broadcastTx(this js.Value, args []js.Value) interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func simulateTx(this js.Value, args []js.Value) interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func processConfig(this js.Value, args []js.Value) interface{} {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
configString := args[0].String()
|
||||||
|
if err := json.Unmarshal([]byte(configString), &config); err != nil {
|
||||||
|
println("Error parsing config:", err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configString := "TODO"
|
// Load dwn config
|
||||||
config, _ := loadConfig(configString)
|
js.Global().Set("broadcastTx", js.FuncOf(broadcastTx))
|
||||||
dbq, err := createDB()
|
js.Global().Set("simulateTx", js.FuncOf(simulateTx))
|
||||||
if err != nil {
|
js.Global().Set("processConfig", js.FuncOf(processConfig))
|
||||||
log.Fatal(err)
|
|
||||||
return
|
e := echo.New()
|
||||||
}
|
e.Use(wasm.ContextMiddleware)
|
||||||
e, err := vault.New(config, dbq)
|
e.Use(controller.Middleware(nil))
|
||||||
if err != nil {
|
vault.RegisterRoutes(e, config)
|
||||||
log.Fatal(err)
|
wasm.ServeFetch(e)
|
||||||
return
|
|
||||||
}
|
|
||||||
serveFetch(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// loadConfig loads the config from the given JSON string
|
|
||||||
func loadConfig(configString string) (*motr.Config, error) {
|
|
||||||
var config motr.Config
|
|
||||||
err := json.Unmarshal([]byte(configString), &config)
|
|
||||||
return &config, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// createDB initializes and returns a configured database connection
|
|
||||||
func createDB() (*motrorm.Queries, error) {
|
|
||||||
db, err := sql.Open("sqlite3", ":memory:")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// create tables
|
|
||||||
if _, err := db.ExecContext(context.Background(), sink.SchemaVaultSQL); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return motrorm.New(db), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// serveFetch serves HTTP requests with optimized handler management
|
|
||||||
func serveFetch(handler http.Handler) func() {
|
|
||||||
h := handler
|
|
||||||
if h == nil {
|
|
||||||
h = http.DefaultServeMux
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optimize prefix handling
|
|
||||||
prefix := strings.TrimRight(jsWasmHTTP.Get("path").String(), "/")
|
|
||||||
if prefix != "" {
|
|
||||||
mux := http.NewServeMux()
|
|
||||||
mux.Handle(prefix+"/", http.StripPrefix(prefix, h))
|
|
||||||
h = mux
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create request handler function
|
|
||||||
cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
|
||||||
promise, resolve, reject := newPromiseOptimized()
|
|
||||||
|
|
||||||
go handleRequest(h, args[1], resolve, reject)
|
|
||||||
|
|
||||||
return promise
|
|
||||||
})
|
|
||||||
|
|
||||||
jsWasmHTTP.Call("setHandler", cb)
|
|
||||||
return cb.Release
|
|
||||||
}
|
|
||||||
|
|
||||||
// handleRequest processes the request with panic recovery
|
|
||||||
func handleRequest(h http.Handler, jsReq js.Value, resolve, reject func(interface{})) {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
var errMsg string
|
|
||||||
if err, ok := r.(error); ok {
|
|
||||||
errMsg = fmt.Sprintf("wasmhttp: panic: %+v", err)
|
|
||||||
} else {
|
|
||||||
errMsg = fmt.Sprintf("wasmhttp: panic: %v", r)
|
|
||||||
}
|
|
||||||
reject(errMsg)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
recorder := newResponseRecorder()
|
|
||||||
h.ServeHTTP(recorder, buildRequest(jsReq))
|
|
||||||
resolve(recorder.jsResponse())
|
|
||||||
}
|
|
||||||
|
|
||||||
// buildRequest creates an http.Request from JS Request
|
|
||||||
func buildRequest(jsReq js.Value) *http.Request {
|
|
||||||
// Get request body
|
|
||||||
arrayBuffer, err := awaitPromiseOptimized(jsReq.Call("arrayBuffer"))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create body buffer
|
|
||||||
jsBody := jsUint8Array.New(arrayBuffer)
|
|
||||||
bodyLen := jsBody.Get("length").Int()
|
|
||||||
body := make([]byte, bodyLen)
|
|
||||||
js.CopyBytesToGo(body, jsBody)
|
|
||||||
|
|
||||||
// Create request
|
|
||||||
req := httptest.NewRequest(
|
|
||||||
jsReq.Get("method").String(),
|
|
||||||
jsReq.Get("url").String(),
|
|
||||||
bytes.NewReader(body),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Set headers efficiently
|
|
||||||
headers := jsReq.Get("headers")
|
|
||||||
headersIt := headers.Call("entries")
|
|
||||||
for {
|
|
||||||
entry := headersIt.Call("next")
|
|
||||||
if entry.Get("done").Bool() {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
pair := entry.Get("value")
|
|
||||||
req.Header.Set(pair.Index(0).String(), pair.Index(1).String())
|
|
||||||
}
|
|
||||||
|
|
||||||
return req
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResponseRecorder with optimized buffer handling
|
|
||||||
type ResponseRecorder struct {
|
|
||||||
*httptest.ResponseRecorder
|
|
||||||
buffer *bytes.Buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
func newResponseRecorder() *ResponseRecorder {
|
|
||||||
return &ResponseRecorder{
|
|
||||||
ResponseRecorder: httptest.NewRecorder(),
|
|
||||||
buffer: bufferPool.Get().(*bytes.Buffer),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// jsResponse creates a JS Response with optimized memory usage
|
|
||||||
func (rr *ResponseRecorder) jsResponse() js.Value {
|
|
||||||
defer func() {
|
|
||||||
rr.buffer.Reset()
|
|
||||||
bufferPool.Put(rr.buffer)
|
|
||||||
}()
|
|
||||||
|
|
||||||
res := rr.Result()
|
|
||||||
defer res.Body.Close()
|
|
||||||
|
|
||||||
// Prepare response body
|
|
||||||
body := js.Undefined()
|
|
||||||
if res.ContentLength != 0 {
|
|
||||||
if _, err := io.Copy(rr.buffer, res.Body); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
bodyBytes := rr.buffer.Bytes()
|
|
||||||
body = jsUint8Array.New(len(bodyBytes))
|
|
||||||
js.CopyBytesToJS(body, bodyBytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare response init object
|
|
||||||
init := make(map[string]interface{}, 3)
|
|
||||||
if res.StatusCode != 0 {
|
|
||||||
init["status"] = res.StatusCode
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(res.Header) > 0 {
|
|
||||||
headers := make(map[string]interface{}, len(res.Header))
|
|
||||||
for k, v := range res.Header {
|
|
||||||
if len(v) > 0 {
|
|
||||||
headers[k] = v[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
init["headers"] = headers
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsResponse.New(body, init)
|
|
||||||
}
|
|
||||||
|
|
||||||
// newPromiseOptimized creates a new JavaScript Promise with optimized callback handling
|
|
||||||
func newPromiseOptimized() (js.Value, func(interface{}), func(interface{})) {
|
|
||||||
var (
|
|
||||||
resolve func(interface{})
|
|
||||||
reject func(interface{})
|
|
||||||
promiseFunc = js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
|
||||||
resolve = func(v interface{}) { args[0].Invoke(v) }
|
|
||||||
reject = func(v interface{}) { args[1].Invoke(v) }
|
|
||||||
return js.Undefined()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
defer promiseFunc.Release()
|
|
||||||
|
|
||||||
return jsPromise.New(promiseFunc), resolve, reject
|
|
||||||
}
|
|
||||||
|
|
||||||
// awaitPromiseOptimized waits for Promise resolution with optimized channel handling
|
|
||||||
func awaitPromiseOptimized(promise js.Value) (js.Value, error) {
|
|
||||||
done := make(chan struct{})
|
|
||||||
var (
|
|
||||||
result js.Value
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
thenFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
|
||||||
result = args[0]
|
|
||||||
close(done)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
defer thenFunc.Release()
|
|
||||||
|
|
||||||
catchFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
|
||||||
err = js.Error{Value: args[0]}
|
|
||||||
close(done)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
defer catchFunc.Release()
|
|
||||||
|
|
||||||
promise.Call("then", thenFunc).Call("catch", catchFunc)
|
|
||||||
<-done
|
|
||||||
|
|
||||||
return result, err
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rootCmd := NewRootCmd()
|
rootCmd := NewRootCmd()
|
||||||
|
|
||||||
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
||||||
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err)
|
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@@ -601,11 +601,11 @@ func (p *PointBls12377G1) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12377G1) MarshalJSON() ([]byte, error) {
|
func (p *PointBls12377G1) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12377G1) UnmarshalJSON(input []byte) error {
|
func (p *PointBls12377G1) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -874,11 +874,11 @@ func (p *PointBls12377G2) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12377G2) MarshalJSON() ([]byte, error) {
|
func (p *PointBls12377G2) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12377G2) UnmarshalJSON(input []byte) error {
|
func (p *PointBls12377G2) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -573,11 +573,11 @@ func (p *PointBls12381G1) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12381G1) MarshalJSON() ([]byte, error) {
|
func (p *PointBls12381G1) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12381G1) UnmarshalJSON(input []byte) error {
|
func (p *PointBls12381G1) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -823,11 +823,11 @@ func (p *PointBls12381G2) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12381G2) MarshalJSON() ([]byte, error) {
|
func (p *PointBls12381G2) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointBls12381G2) UnmarshalJSON(input []byte) error {
|
func (p *PointBls12381G2) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,14 +336,14 @@ func pointUnmarshalText(input []byte) (Point, error) {
|
|||||||
return curve.Point.FromAffineCompressed(buffer)
|
return curve.Point.FromAffineCompressed(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pointMarshalJSON(point Point) ([]byte, error) {
|
func pointMarshalJson(point Point) ([]byte, error) {
|
||||||
m := make(map[string]string, 2)
|
m := make(map[string]string, 2)
|
||||||
m["type"] = point.CurveName()
|
m["type"] = point.CurveName()
|
||||||
m["value"] = hex.EncodeToString(point.ToAffineCompressed())
|
m["value"] = hex.EncodeToString(point.ToAffineCompressed())
|
||||||
return json.Marshal(m)
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pointUnmarshalJSON(input []byte) (Point, error) {
|
func pointUnmarshalJson(input []byte) (Point, error) {
|
||||||
var m map[string]string
|
var m map[string]string
|
||||||
|
|
||||||
err := json.Unmarshal(input, &m)
|
err := json.Unmarshal(input, &m)
|
||||||
|
|||||||
@@ -682,11 +682,11 @@ func (p *PointEd25519) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointEd25519) MarshalJSON() ([]byte, error) {
|
func (p *PointEd25519) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointEd25519) UnmarshalJSON(input []byte) error {
|
func (p *PointEd25519) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -653,11 +653,11 @@ func (p *PointK256) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointK256) MarshalJSON() ([]byte, error) {
|
func (p *PointK256) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointK256) UnmarshalJSON(input []byte) error {
|
func (p *PointK256) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -701,11 +701,11 @@ func (p *BenchPointP256) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *BenchPointP256) MarshalJSON() ([]byte, error) {
|
func (p *BenchPointP256) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *BenchPointP256) UnmarshalJSON(input []byte) error {
|
func (p *BenchPointP256) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -651,11 +651,11 @@ func (p *PointP256) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointP256) MarshalJSON() ([]byte, error) {
|
func (p *PointP256) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointP256) UnmarshalJSON(input []byte) error {
|
func (p *PointP256) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -669,11 +669,11 @@ func (p *PointPallas) UnmarshalText(input []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointPallas) MarshalJSON() ([]byte, error) {
|
func (p *PointPallas) MarshalJSON() ([]byte, error) {
|
||||||
return pointMarshalJSON(p)
|
return pointMarshalJson(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PointPallas) UnmarshalJSON(input []byte) error {
|
func (p *PointPallas) UnmarshalJSON(input []byte) error {
|
||||||
pt, err := pointUnmarshalJSON(input)
|
pt, err := pointUnmarshalJson(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
package keys
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/ed25519"
|
|
||||||
"crypto/rsa"
|
|
||||||
"crypto/x509"
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p/core/crypto"
|
|
||||||
mb "github.com/multiformats/go-multibase"
|
|
||||||
varint "github.com/multiformats/go-varint"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// KeyPrefix indicates a decentralized identifier that uses the key method
|
|
||||||
KeyPrefix = "did:key"
|
|
||||||
// MulticodecKindRSAPubKey rsa-x509-pub https://github.com/multiformats/multicodec/pull/226
|
|
||||||
MulticodecKindRSAPubKey = 0x1205
|
|
||||||
// MulticodecKindEd25519PubKey ed25519-pub
|
|
||||||
MulticodecKindEd25519PubKey = 0xed
|
|
||||||
// MulticodecKindSecp256k1PubKey secp256k1-pub
|
|
||||||
MulticodecKindSecp256k1PubKey = 0x1206
|
|
||||||
)
|
|
||||||
|
|
||||||
// DID is a DID:key identifier
|
|
||||||
type DID struct {
|
|
||||||
crypto.PubKey
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewDID constructs an Identifier from a public key
|
|
||||||
func NewDID(pub crypto.PubKey) (DID, error) {
|
|
||||||
switch pub.Type() {
|
|
||||||
case crypto.Ed25519, crypto.RSA, crypto.Secp256k1:
|
|
||||||
return DID{PubKey: pub}, nil
|
|
||||||
default:
|
|
||||||
return DID{}, fmt.Errorf("unsupported key type: %s", pub.Type())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewFromPubKey constructs an Identifier from a public key
|
|
||||||
func NewFromPubKey(pub PubKey) DID {
|
|
||||||
return DID{PubKey: pub}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MulticodecType indicates the type for this multicodec
|
|
||||||
func (id DID) MulticodecType() uint64 {
|
|
||||||
switch id.Type() {
|
|
||||||
case crypto.RSA:
|
|
||||||
return MulticodecKindRSAPubKey
|
|
||||||
case crypto.Ed25519:
|
|
||||||
return MulticodecKindEd25519PubKey
|
|
||||||
case crypto.Secp256k1:
|
|
||||||
return MulticodecKindSecp256k1PubKey
|
|
||||||
default:
|
|
||||||
panic("unexpected crypto type")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns this did:key formatted as a string
|
|
||||||
func (id DID) String() string {
|
|
||||||
raw, err := id.Raw()
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
t := id.MulticodecType()
|
|
||||||
size := varint.UvarintSize(t)
|
|
||||||
data := make([]byte, size+len(raw))
|
|
||||||
n := varint.PutUvarint(data, t)
|
|
||||||
copy(data[n:], raw)
|
|
||||||
|
|
||||||
b58BKeyStr, err := mb.Encode(mb.Base58BTC, data)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("%s:%s", KeyPrefix, b58BKeyStr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// VerifyKey returns the backing implementation for a public key, one of:
|
|
||||||
// *rsa.PublicKey, ed25519.PublicKey
|
|
||||||
func (id DID) VerifyKey() (interface{}, error) {
|
|
||||||
rawPubBytes, err := id.Raw()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
switch id.Type() {
|
|
||||||
case crypto.RSA:
|
|
||||||
verifyKeyiface, err := x509.ParsePKIXPublicKey(rawPubBytes)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
verifyKey, ok := verifyKeyiface.(*rsa.PublicKey)
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("public key is not an RSA key. got type: %T", verifyKeyiface)
|
|
||||||
}
|
|
||||||
return verifyKey, nil
|
|
||||||
case crypto.Ed25519:
|
|
||||||
return ed25519.PublicKey(rawPubBytes), nil
|
|
||||||
case crypto.Secp256k1:
|
|
||||||
// Handle both compressed and uncompressed Secp256k1 public keys
|
|
||||||
if len(rawPubBytes) == 65 || len(rawPubBytes) == 33 {
|
|
||||||
return rawPubBytes, nil
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("invalid Secp256k1 public key length: %d", len(rawPubBytes))
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("unrecognized Public Key type: %s", id.Type())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse turns a string into a key method ID
|
|
||||||
func Parse(keystr string) (DID, error) {
|
|
||||||
var id DID
|
|
||||||
if !strings.HasPrefix(keystr, KeyPrefix) {
|
|
||||||
return id, fmt.Errorf("decentralized identifier is not a 'key' type")
|
|
||||||
}
|
|
||||||
|
|
||||||
keystr = strings.TrimPrefix(keystr, KeyPrefix+":")
|
|
||||||
|
|
||||||
enc, data, err := mb.Decode(keystr)
|
|
||||||
if err != nil {
|
|
||||||
return id, fmt.Errorf("decoding multibase: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if enc != mb.Base58BTC {
|
|
||||||
return id, fmt.Errorf("unexpected multibase encoding: %s", mb.EncodingToStr[enc])
|
|
||||||
}
|
|
||||||
|
|
||||||
keyType, n, err := varint.FromUvarint(data)
|
|
||||||
if err != nil {
|
|
||||||
return id, err
|
|
||||||
}
|
|
||||||
|
|
||||||
switch keyType {
|
|
||||||
case MulticodecKindRSAPubKey:
|
|
||||||
pub, err := crypto.UnmarshalRsaPublicKey(data[n:])
|
|
||||||
if err != nil {
|
|
||||||
return id, err
|
|
||||||
}
|
|
||||||
return DID{pub}, nil
|
|
||||||
case MulticodecKindEd25519PubKey:
|
|
||||||
pub, err := crypto.UnmarshalEd25519PublicKey(data[n:])
|
|
||||||
if err != nil {
|
|
||||||
return id, err
|
|
||||||
}
|
|
||||||
return DID{pub}, nil
|
|
||||||
case MulticodecKindSecp256k1PubKey:
|
|
||||||
// Handle both compressed and uncompressed formats
|
|
||||||
keyData := data[n:]
|
|
||||||
if len(keyData) != 33 && len(keyData) != 65 {
|
|
||||||
return id, fmt.Errorf("invalid Secp256k1 public key length: %d", len(keyData))
|
|
||||||
}
|
|
||||||
pub, err := crypto.UnmarshalSecp256k1PublicKey(keyData)
|
|
||||||
if err != nil {
|
|
||||||
return id, fmt.Errorf("failed to unmarshal Secp256k1 key: %w", err)
|
|
||||||
}
|
|
||||||
return DID{pub}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return id, fmt.Errorf("unrecognized key type multicodec prefix: %x", data[0])
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package keys
|
|
||||||
|
|
||||||
type DIDMethod string
|
|
||||||
|
|
||||||
const (
|
|
||||||
DIDMethodKey DIDMethod = "key"
|
|
||||||
DIDMethodSonr DIDMethod = "sonr"
|
|
||||||
DIDMehthodBitcoin DIDMethod = "btcr"
|
|
||||||
DIDMethodEthereum DIDMethod = "ethr"
|
|
||||||
DIDMethodCbor DIDMethod = "cbor"
|
|
||||||
DIDMethodCID DIDMethod = "cid"
|
|
||||||
DIDMethodIPFS DIDMethod = "ipfs"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (d DIDMethod) String() string {
|
|
||||||
return string(d)
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package parsers
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package parsers
|
|
||||||
|
|
||||||
type CosmosPrefix string
|
|
||||||
|
|
||||||
const (
|
|
||||||
ATOMPrefix CosmosPrefix = "cosmos"
|
|
||||||
AXELARPrefix CosmosPrefix = "axelar"
|
|
||||||
EVMOSPrefix CosmosPrefix = "evmos"
|
|
||||||
OSMOPrefix CosmosPrefix = "osmo"
|
|
||||||
SONRPrefix CosmosPrefix = "idx"
|
|
||||||
STARSPrefix CosmosPrefix = "stars"
|
|
||||||
)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package parsers
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package parsers
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package parsers
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
package parsers
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
package keys
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"crypto/ecdsa"
|
|
||||||
"encoding/hex"
|
|
||||||
|
|
||||||
p2pcrypto "github.com/libp2p/go-libp2p/core/crypto"
|
|
||||||
p2ppb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
|
||||||
"github.com/onsonr/sonr/crypto/core/curves"
|
|
||||||
"golang.org/x/crypto/sha3"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PubKey interface {
|
|
||||||
Bytes() []byte
|
|
||||||
Raw() ([]byte, error)
|
|
||||||
Equals(b p2pcrypto.Key) bool
|
|
||||||
Type() p2ppb.KeyType
|
|
||||||
Hex() string
|
|
||||||
Verify(msg []byte, sig []byte) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type pubKey struct {
|
|
||||||
publicPoint curves.Point
|
|
||||||
method string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewPubKey(pk curves.Point) PubKey {
|
|
||||||
return &pubKey{
|
|
||||||
publicPoint: pk,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p pubKey) Bytes() []byte {
|
|
||||||
return p.publicPoint.ToAffineCompressed()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p pubKey) Raw() ([]byte, error) {
|
|
||||||
return p.publicPoint.ToAffineCompressed(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p pubKey) Equals(b p2pcrypto.Key) bool {
|
|
||||||
if b == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
apbz, err := b.Raw()
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
bbz, err := p.Raw()
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return bytes.Equal(apbz, bbz)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p pubKey) Hex() string {
|
|
||||||
return hex.EncodeToString(p.publicPoint.ToAffineCompressed())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p pubKey) Type() p2ppb.KeyType {
|
|
||||||
return p2ppb.KeyType_Secp256k1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p pubKey) Verify(data []byte, sigBz []byte) (bool, error) {
|
|
||||||
sig, err := deserializeSignature(sigBz)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
pp, err := getEcdsaPoint(p.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
pk := &ecdsa.PublicKey{
|
|
||||||
Curve: pp.Curve,
|
|
||||||
X: pp.X,
|
|
||||||
Y: pp.Y,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hash the message using SHA3-256
|
|
||||||
hash := sha3.New256()
|
|
||||||
hash.Write(data)
|
|
||||||
digest := hash.Sum(nil)
|
|
||||||
|
|
||||||
return ecdsa.Verify(pk, digest, sig.R, sig.S), nil
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package keys
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/onsonr/sonr/crypto/core/curves"
|
|
||||||
)
|
|
||||||
|
|
||||||
// getEcdsaPoint builds an elliptic curve point from a compressed byte slice
|
|
||||||
func getEcdsaPoint(pubKey []byte) (*curves.EcPoint, error) {
|
|
||||||
crv := curves.K256()
|
|
||||||
x := new(big.Int).SetBytes(pubKey[1:33])
|
|
||||||
y := new(big.Int).SetBytes(pubKey[33:])
|
|
||||||
ecCurve, err := crv.ToEllipticCurve()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error converting curve: %v", err)
|
|
||||||
}
|
|
||||||
return &curves.EcPoint{X: x, Y: y, Curve: ecCurve}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SerializeSecp256k1Signature serializes an ECDSA signature into a byte slice
|
|
||||||
func serializeSignature(sig *curves.EcdsaSignature) ([]byte, error) {
|
|
||||||
rBytes := sig.R.Bytes()
|
|
||||||
sBytes := sig.S.Bytes()
|
|
||||||
|
|
||||||
sigBytes := make([]byte, 66) // V (1 byte) + R (32 bytes) + S (32 bytes)
|
|
||||||
sigBytes[0] = byte(sig.V)
|
|
||||||
copy(sigBytes[33-len(rBytes):33], rBytes)
|
|
||||||
copy(sigBytes[66-len(sBytes):66], sBytes)
|
|
||||||
return sigBytes, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeserializeSecp256k1Signature deserializes an ECDSA signature from a byte slice
|
|
||||||
func deserializeSignature(sigBytes []byte) (*curves.EcdsaSignature, error) {
|
|
||||||
if len(sigBytes) != 66 {
|
|
||||||
return nil, errors.New("malformed signature: not the correct size")
|
|
||||||
}
|
|
||||||
sig := &curves.EcdsaSignature{
|
|
||||||
V: int(sigBytes[0]),
|
|
||||||
R: new(big.Int).SetBytes(sigBytes[1:33]),
|
|
||||||
S: new(big.Int).SetBytes(sigBytes[33:66]),
|
|
||||||
}
|
|
||||||
return sig, nil
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package mpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/onsonr/sonr/crypto/core/curves"
|
|
||||||
"github.com/onsonr/sonr/crypto/core/protocol"
|
|
||||||
"github.com/onsonr/sonr/crypto/keys"
|
|
||||||
"github.com/onsonr/sonr/crypto/tecdsa/dklsv1/dkg"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ╭───────────────────────────────────────────────────────────╮
|
|
||||||
// │ Exported Generics │
|
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
type (
|
|
||||||
AliceOut *dkg.AliceOutput
|
|
||||||
BobOut *dkg.BobOutput
|
|
||||||
Point curves.Point
|
|
||||||
Role string // Role is the type for the role
|
|
||||||
Message *protocol.Message // Message is the protocol.Message that is used for MPC
|
|
||||||
Signature *curves.EcdsaSignature // Signature is the type for the signature
|
|
||||||
RefreshFunc interface{ protocol.Iterator } // RefreshFunc is the type for the refresh function
|
|
||||||
SignFunc interface{ protocol.Iterator } // SignFunc is the type for the sign function
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
RoleVal = "validator"
|
|
||||||
RoleUser = "user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Enclave defines the interface for key management operations
|
|
||||||
type Enclave interface {
|
|
||||||
Address() string // Address returns the Sonr address of the keyEnclave
|
|
||||||
DID() keys.DID // DID returns the DID of the keyEnclave
|
|
||||||
Export(key []byte) ([]byte, error) // Export returns encrypted enclave data
|
|
||||||
Import(data []byte, key []byte) error // Import decrypts and loads enclave data
|
|
||||||
IsValid() bool // IsValid returns true if the keyEnclave is valid
|
|
||||||
PubKey() keys.PubKey // PubKey returns the public key of the keyEnclave
|
|
||||||
Refresh() (Enclave, error) // Refresh returns a new keyEnclave
|
|
||||||
Serialize() ([]byte, error) // Serialize returns the serialized keyEnclave
|
|
||||||
Sign(data []byte) ([]byte, error) // Sign returns the signature of the data
|
|
||||||
Verify(data []byte, sig []byte) (bool, error) // Verify returns true if the signature is valid
|
|
||||||
}
|
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
package mpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/rand"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func randNonce() []byte {
|
|
||||||
nonce := make([]byte, 12)
|
|
||||||
rand.Read(nonce)
|
|
||||||
return nonce
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestKeyShareGeneration(t *testing.T) {
|
|
||||||
t.Run("Generate Valid Enclave", func(t *testing.T) {
|
|
||||||
nonce := randNonce()
|
|
||||||
// Generate enclave
|
|
||||||
enclave, err := GenEnclave(nonce)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, enclave)
|
|
||||||
|
|
||||||
// Validate enclave contents
|
|
||||||
assert.True(t, enclave.IsValid())
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Export and Import", func(t *testing.T) {
|
|
||||||
nonce := randNonce()
|
|
||||||
// Generate original enclave
|
|
||||||
original, err := GenEnclave(nonce)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Test key for encryption/decryption (32 bytes)
|
|
||||||
testKey := []byte("test-key-12345678-test-key-123456")
|
|
||||||
|
|
||||||
// Test Export/Import
|
|
||||||
t.Run("Full Enclave", func(t *testing.T) {
|
|
||||||
// Export enclave
|
|
||||||
data, err := original.Export(testKey)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotEmpty(t, data)
|
|
||||||
|
|
||||||
// Create new empty enclave
|
|
||||||
newEnclave, err := GenEnclave(nonce)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Import enclave
|
|
||||||
err = newEnclave.Import(data, testKey)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Verify the imported enclave works by signing
|
|
||||||
testData := []byte("test message")
|
|
||||||
sig, err := newEnclave.Sign(testData)
|
|
||||||
require.NoError(t, err)
|
|
||||||
valid, err := newEnclave.Verify(testData, sig)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.True(t, valid)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Test Invalid Key
|
|
||||||
t.Run("Invalid Key", func(t *testing.T) {
|
|
||||||
data, err := original.Export(testKey)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
wrongKey := []byte("wrong-key-12345678")
|
|
||||||
err = original.Import(data, wrongKey)
|
|
||||||
assert.Error(t, err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEnclaveOperations(t *testing.T) {
|
|
||||||
t.Run("Signing and Verification", func(t *testing.T) {
|
|
||||||
nonce := randNonce()
|
|
||||||
// Generate valid enclave
|
|
||||||
enclave, err := GenEnclave(nonce)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Test signing
|
|
||||||
testData := []byte("test message")
|
|
||||||
signature, err := enclave.Sign(testData)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, signature)
|
|
||||||
|
|
||||||
// Verify the signature
|
|
||||||
valid, err := enclave.Verify(testData, signature)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.True(t, valid)
|
|
||||||
|
|
||||||
// Test invalid data verification
|
|
||||||
invalidData := []byte("wrong message")
|
|
||||||
valid, err = enclave.Verify(invalidData, signature)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.False(t, valid)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Address and Public Key", func(t *testing.T) {
|
|
||||||
nonce := randNonce()
|
|
||||||
enclave, err := GenEnclave(nonce)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Test Address
|
|
||||||
addr := enclave.Address()
|
|
||||||
assert.NotEmpty(t, addr)
|
|
||||||
assert.True(t, strings.HasPrefix(addr, "idx"))
|
|
||||||
|
|
||||||
// Test Public Key
|
|
||||||
pubKey := enclave.PubKey()
|
|
||||||
assert.NotNil(t, pubKey)
|
|
||||||
assert.NotEmpty(t, pubKey.Bytes())
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Refresh Operation", func(t *testing.T) {
|
|
||||||
nonce := randNonce()
|
|
||||||
enclave, err := GenEnclave(nonce)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Test refresh
|
|
||||||
refreshedEnclave, err := enclave.Refresh()
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, refreshedEnclave)
|
|
||||||
|
|
||||||
// Verify refreshed enclave is valid
|
|
||||||
assert.True(t, refreshedEnclave.IsValid())
|
|
||||||
|
|
||||||
// Verify it maintains the same address
|
|
||||||
assert.Equal(t, enclave.Address(), refreshedEnclave.Address())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEnclaveSerialization(t *testing.T) {
|
|
||||||
t.Run("Marshal and Unmarshal", func(t *testing.T) {
|
|
||||||
nonce := randNonce()
|
|
||||||
// Generate original enclave
|
|
||||||
original, err := GenEnclave(nonce)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, original)
|
|
||||||
|
|
||||||
// Marshal
|
|
||||||
keyclave, ok := original.(*keyEnclave)
|
|
||||||
require.True(t, ok)
|
|
||||||
|
|
||||||
data, err := keyclave.Serialize()
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotEmpty(t, data)
|
|
||||||
|
|
||||||
// Unmarshal
|
|
||||||
restored := &keyEnclave{}
|
|
||||||
err = restored.Unmarshal(data)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Verify restored enclave
|
|
||||||
assert.Equal(t, keyclave.Addr, restored.Addr)
|
|
||||||
assert.True(t, keyclave.PubPoint.Equal(restored.PubPoint))
|
|
||||||
assert.True(t, restored.IsValid())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
package mpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/aes"
|
|
||||||
"crypto/cipher"
|
|
||||||
"crypto/ecdsa"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/onsonr/sonr/crypto/core/curves"
|
|
||||||
"github.com/onsonr/sonr/crypto/keys"
|
|
||||||
"golang.org/x/crypto/sha3"
|
|
||||||
)
|
|
||||||
|
|
||||||
// keyEnclave implements the Enclave interface
|
|
||||||
type keyEnclave struct {
|
|
||||||
// Serialized fields
|
|
||||||
Addr string `json:"address"`
|
|
||||||
PubPoint curves.Point `json:"-"`
|
|
||||||
PubBytes []byte `json:"pub_key"`
|
|
||||||
ValShare Message `json:"val_share"`
|
|
||||||
UserShare Message `json:"user_share"`
|
|
||||||
|
|
||||||
// Extra fields
|
|
||||||
nonce []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func newEnclave(valShare, userShare Message, nonce []byte) (Enclave, error) {
|
|
||||||
pubPoint, err := getAlicePubPoint(valShare)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
addr, err := computeSonrAddr(pubPoint)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &keyEnclave{
|
|
||||||
Addr: addr,
|
|
||||||
PubPoint: pubPoint,
|
|
||||||
ValShare: valShare,
|
|
||||||
UserShare: userShare,
|
|
||||||
nonce: nonce,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Address returns the Sonr address of the keyEnclave
|
|
||||||
func (k *keyEnclave) Address() string {
|
|
||||||
return k.Addr
|
|
||||||
}
|
|
||||||
|
|
||||||
// DID returns the DID of the keyEnclave
|
|
||||||
func (k *keyEnclave) DID() keys.DID {
|
|
||||||
return keys.NewFromPubKey(k.PubKey())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export returns encrypted enclave data
|
|
||||||
func (k *keyEnclave) Export(key []byte) ([]byte, error) {
|
|
||||||
data, err := k.Serialize()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to serialize enclave: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
hashedKey := hashKey(key)
|
|
||||||
block, err := aes.NewCipher(hashedKey)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
aesgcm, err := cipher.NewGCM(block)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return aesgcm.Seal(nil, k.nonce, data, nil), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Import decrypts and loads enclave data
|
|
||||||
func (k *keyEnclave) Import(data []byte, key []byte) error {
|
|
||||||
hashedKey := hashKey(key)
|
|
||||||
block, err := aes.NewCipher(hashedKey)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
aesgcm, err := cipher.NewGCM(block)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
decrypted, err := aesgcm.Open(nil, k.nonce, data, nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return k.Unmarshal(decrypted)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsValid returns true if the keyEnclave is valid
|
|
||||||
func (k *keyEnclave) IsValid() bool {
|
|
||||||
return k.PubPoint != nil && k.ValShare != nil && k.UserShare != nil && k.Addr != ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// PubKey returns the public key of the keyEnclave
|
|
||||||
func (k *keyEnclave) PubKey() keys.PubKey {
|
|
||||||
return keys.NewPubKey(k.PubPoint)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refresh returns a new keyEnclave
|
|
||||||
func (k *keyEnclave) Refresh() (Enclave, error) {
|
|
||||||
refreshFuncVal, err := valRefreshFunc(k)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
refreshFuncUser, err := userRefreshFunc(k)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return ExecuteRefresh(refreshFuncVal, refreshFuncUser, k.nonce)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sign returns the signature of the data
|
|
||||||
func (k *keyEnclave) Sign(data []byte) ([]byte, error) {
|
|
||||||
userSign, err := userSignFunc(k, data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
valSign, err := valSignFunc(k, data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return ExecuteSigning(valSign, userSign)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify returns true if the signature is valid
|
|
||||||
func (k *keyEnclave) Verify(data []byte, sig []byte) (bool, error) {
|
|
||||||
edSig, err := deserializeSignature(sig)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
ePub, err := getEcdsaPoint(k.PubPoint.ToAffineUncompressed())
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
pk := &ecdsa.PublicKey{
|
|
||||||
Curve: ePub.Curve,
|
|
||||||
X: ePub.X,
|
|
||||||
Y: ePub.Y,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hash the message using SHA3-256
|
|
||||||
hash := sha3.New256()
|
|
||||||
hash.Write(data)
|
|
||||||
digest := hash.Sum(nil)
|
|
||||||
|
|
||||||
return ecdsa.Verify(pk, digest, edSig.R, edSig.S), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Marshal returns the JSON encoding of keyEnclave
|
|
||||||
func (k *keyEnclave) Serialize() ([]byte, error) {
|
|
||||||
// Store compressed public point bytes before marshaling
|
|
||||||
k.PubBytes = k.PubPoint.ToAffineCompressed()
|
|
||||||
return json.Marshal(k)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal parses the JSON-encoded data and stores the result
|
|
||||||
func (k *keyEnclave) Unmarshal(data []byte) error {
|
|
||||||
if err := json.Unmarshal(data, k); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// Reconstruct Point from bytes
|
|
||||||
curve := curves.K256()
|
|
||||||
point, err := curve.NewIdentityPoint().FromAffineCompressed(k.PubBytes)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
k.PubPoint = point
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user