feature/dwn database state (#18)

* refactor: move database, navigator scripts to state package

* feat: add Schema config for dwn

* test: add unit tests for InitializeDatabase

* feat: use templated index.html for the DWN frontend

* feat: introduce templ generation for templ

* chore(deps): update devbox.json to use latest packages

* chore: update devbox to use bun

* feat: introduce dwn config generation

* feat: add motr.mjs for vault management

* refactor: move front end from  to  (alert)

* feat: implement devbox integration and devbox-based process management

* feat: embed motr.mjs script for offline demo

* refactor: embed motr.mjs data in embed.go

* chore: update workflows to use actions/checkout@v4

* refactor: move process-compose.yaml to deploy directory

* refactor: remove unnecessary JSON conversion
This commit is contained in:
Prad Nukala
2024-09-21 21:42:51 -04:00
committed by GitHub
parent a115b79db7
commit a4dbb41202
89 changed files with 1257 additions and 968 deletions
+33
View File
@@ -0,0 +1,33 @@
{
email team@sonr.id
}
# Vaults at vault.sonr.id
vault.sonr.id {
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
resolvers 1.1.1.1
}
# Match paths that are bech32 addresses
@vault path_regexp vaultPath ^/([a-z0-9]{42})(/.*|)$
handle @vault {
# Rewrite to IPFS gateway format
uri replace /{re.vaultPath.0} /ipns/{re.vaultPath.1}{re.vaultPath.2}
# Proxy to IPFS gateway
reverse_proxy http://localhost:8080
}
file_server
header {
Content-Type .wasm application/wasm
Service-Worker-Allowed "/"
# Add any other necessary headers
}
# Optional: Enable compression
encode zstd gzip
}
-1
View File
@@ -1 +0,0 @@
{"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"match":[{"host":["vault.sonr.id"]}],"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"headers","response":{"replace":{"Content-Type":[{"replace":"application/wasm","search_regexp":".wasm"}]},"set":{"Service-Worker-Allowed":["/"]}}},{"encodings":{"gzip":{},"zstd":{}},"handler":"encode","prefer":["zstd","gzip"]}]},{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"rewrite","uri_substring":[{"find":"/{http.regexp.vaultPath.0}","replace":"/ipns/{http.regexp.vaultPath.1}{http.regexp.vaultPath.2}"}]},{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:8080"}]}]}]}],"match":[{"path_regexp":{"name":"vaultPath","pattern":"^/([a-z0-9]{42})(/.*|)$"}}]},{"handle":[{"handler":"file_server","hide":["./Caddyfile"]}]}]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"subjects":["vault.sonr.id"],"issuers":[{"challenges":{"dns":{"provider":{"api_token":"{env.CLOUDFLARE_API_TOKEN}","name":"cloudflare"},"resolvers":["1.1.1.1"]}},"email":"team@sonr.id","module":"acme"}]}]}}}}
+2
View File
@@ -7,4 +7,6 @@ type Config struct {
Sonr *Sonr `pkl:"sonr" json:"sonr,omitempty"`
Motr *Motr `pkl:"motr" json:"motr,omitempty"`
Schema *Schema `pkl:"schema" json:"schema,omitempty"`
}
-1
View File
@@ -8,7 +8,6 @@ import (
)
type Dwn struct {
Config any `pkl:"config"`
}
// LoadFromPath loads the pkl module at the given path and evaluates it into a Dwn
+24
View File
@@ -0,0 +1,24 @@
// Code generated from Pkl module `dwn`. DO NOT EDIT.
package dwn
type Schema struct {
Version int `pkl:"version"`
Account string `pkl:"account" json:"account,omitempty"`
Asset string `pkl:"asset" json:"asset,omitempty"`
Chain string `pkl:"chain" json:"chain,omitempty"`
Credential string `pkl:"credential" json:"credential,omitempty"`
Jwk string `pkl:"jwk" json:"jwk,omitempty"`
Grant string `pkl:"grant" json:"grant,omitempty"`
Keyshare string `pkl:"keyshare" json:"keyshare,omitempty"`
PublicKey string `pkl:"publicKey" json:"publicKey,omitempty"`
Profile string `pkl:"profile" json:"profile,omitempty"`
}
+1
View File
@@ -9,4 +9,5 @@ func init() {
pkl.RegisterMapping("dwn#IPFS", IPFS{})
pkl.RegisterMapping("dwn#Sonr", Sonr{})
pkl.RegisterMapping("dwn#Motr", Motr{})
pkl.RegisterMapping("dwn#Schema", Schema{})
}
+34 -12
View File
@@ -21,6 +21,9 @@ class Config {
@JsonField
motr: Motr
@JsonField
schema: Schema
}
class IPFS {
@@ -42,6 +45,37 @@ class Motr {
origin: String
}
class Schema {
version: Int
@JsonField
account: String
@JsonField
asset: String
@JsonField
chain: String
@JsonField
credential: String
@JsonField
jwk: String
@JsonField
grant: String
@JsonField
keyshare: String
@JsonField
publicKey: String
@JsonField
profile: String
}
class Sonr {
@JsonField
apiUrl: String
@@ -60,16 +94,4 @@ class Sonr {
}
config = new Config {
ipfs = new IPFS {
apiUrl = "https://api.sonr-ipfs.land"
gatewayUrl = "https://ipfs.sonr.land"
}
sonr = new Sonr {
apiUrl = "https://api.sonr.land"
grpcUrl = "https://grpc.sonr.land"
rpcUrl = "https://rpc.sonr.land"
webSocketUrl = "wss://rpc.sonr.land/ws"
}
}