feature/driver indexed db (#14)

* fix: update commitizen version

* feat: add WASM build tags to db actions

* feat: Update all actions to follow `AddAsset` for error handling

* feat: remove database dependency in dwn and motr commands

* feat: add basic info form to registration view

* feat: implement basic browser navigation component

* refactor: move database related files to middleware

* fix: remove unused test command

* fix: update source directory for buf-publish workflow

* feat: embed dwn config data

* feat: add Sync RPC to query service

* refactor: rename  package to  for better organization

* feat: add new javascript exception handling for server requests

* refactor: move dwn.wasm to embed directory

* refactor: move server files to a new directory

* refactor: move session related code to client package

* refactor: Update dwn.wasm build path

* refactor: move dwn wasm build to vfs

* feat: introduce config loading middleware

* feat: introduce DWN config and address JSON

* refactor: move dwn wasm build output to embed directory

* feat: introduce  config and IndexedDB model

* refactor: move DWN config file generation to vfs

* refactor: move config package to

* feat: add Sonr.ID IPFS gateway proxy

* feat: add SWT data structure

* feat: update index.html to use Sonr styles and scripts

* feat(dwn): remove index.html server endpoint

* feat: add Navigator API for web credential management
This commit is contained in:
Prad Nukala
2024-09-18 02:22:17 -04:00
committed by GitHub
parent 8022428e37
commit 2c1cf56e3c
150 changed files with 2819 additions and 6661 deletions
+14
View File
@@ -0,0 +1,14 @@
// Code generated from Pkl module `dwn`. DO NOT EDIT.
package dwn
type Config struct {
Ipfs *IPFS `pkl:"ipfs" json:"ipfs,omitempty"`
Sonr *Sonr `pkl:"sonr" json:"sonr,omitempty"`
Keyshare *string `pkl:"keyshare" json:"keyshare,omitempty"`
Address *string `pkl:"address" json:"address,omitempty"`
Vault *IndexedDB `pkl:"vault" json:"vault,omitempty"`
}
+37
View File
@@ -0,0 +1,37 @@
// Code generated from Pkl module `dwn`. DO NOT EDIT.
package dwn
import (
"context"
"github.com/apple/pkl-go/pkl"
)
type Dwn struct {
Config any `pkl:"config"`
}
// LoadFromPath loads the pkl module at the given path and evaluates it into a Dwn
func LoadFromPath(ctx context.Context, path string) (ret *Dwn, err error) {
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
if err != nil {
return nil, err
}
defer func() {
cerr := evaluator.Close()
if err == nil {
err = cerr
}
}()
ret, err = Load(ctx, evaluator, pkl.FileSource(path))
return ret, err
}
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Dwn
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Dwn, error) {
var ret Dwn
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
return nil, err
}
return &ret, nil
}
+8
View File
@@ -0,0 +1,8 @@
// Code generated from Pkl module `dwn`. DO NOT EDIT.
package dwn
type IPFS struct {
ApiUrl string `pkl:"apiUrl"`
GatewayUrl string `pkl:"gatewayUrl"`
}
+8
View File
@@ -0,0 +1,8 @@
// Code generated from Pkl module `dwn`. DO NOT EDIT.
package dwn
type IndexedDB struct {
Name string `pkl:"name"`
Version int `pkl:"version"`
}
+12
View File
@@ -0,0 +1,12 @@
// Code generated from Pkl module `dwn`. DO NOT EDIT.
package dwn
type Sonr struct {
ApiUrl string `pkl:"apiUrl"`
GrpcUrl string `pkl:"grpcUrl"`
RpcUrl string `pkl:"rpcUrl"`
WebSocketUrl string `pkl:"webSocketUrl"`
}
+12
View File
@@ -0,0 +1,12 @@
// Code generated from Pkl module `dwn`. DO NOT EDIT.
package dwn
import "github.com/apple/pkl-go/pkl"
func init() {
pkl.RegisterMapping("dwn", Dwn{})
pkl.RegisterMapping("dwn#Config", Config{})
pkl.RegisterMapping("dwn#IPFS", IPFS{})
pkl.RegisterMapping("dwn#Sonr", Sonr{})
pkl.RegisterMapping("dwn#IndexedDB", IndexedDB{})
}
+62
View File
@@ -0,0 +1,62 @@
@go.Package { name = "github.com/onsonr/sonr/config/dwn" }
module dwn
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
typealias JSON = String
class JsonField extends go.Field {
structTags {
["json"] = "%{name},omitempty"
}
}
class Config {
@JsonField
ipfs: IPFS
@JsonField
sonr: Sonr
@JsonField
keyshare: JSON?
@JsonField
address: String?
@JsonField
vault: IndexedDB
}
class IndexedDB {
name: String = "vault"
version: Int = 1
}
class IPFS {
apiUrl: String
gatewayUrl: String
}
class Sonr {
apiUrl: String
grpcUrl: String
rpcUrl: String
webSocketUrl: String
}
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"
}
}
+86 -142
View File
@@ -1,64 +1,56 @@
@go.Package { name = "github.com/onsonr/sonr/internal/dwn/models" }
@go.Package { name = "github.com/onsonr/sonr/internal/vfs/models" }
module models
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
typealias Base58 = String
typealias Base64 = String
typealias Bech32 = String
typealias Keccak = String
typealias DID = String
typealias ChainCode = UInt
typealias Scope = String
typealias Hex = String
typealias UTF8 = String
class PrimaryKey extends go.Field {
structTags {
["gorm"] = "primaryKey,autoIncrement"
["json"] = "%{name},omitempty"
["query"] = "%{name}"
}
}
class Unique extends go.Field {
structTags {
["gorm"] = "unique"
["json"] = "%{name},omitempty"
}
}
class Default extends go.Field {
defaultValue: String
structTags {
["gorm"] = "default:%{defaultValue}"
["json"] = "%{name},omitempty"
}
}
class NotNull extends go.Field {
structTags {
["gorm"] = "not null"
}
}
class ForeignKey extends go.Field {
references: String
structTags {
["gorm"] = "foreignKey:%{references}"
}
}
class JsonField extends go.Field {
structTags {
["json"] = "%{name},omitempty"
["param"] = "%{name}"
}
}
class Account {
@PrimaryKey
id: UInt
id: DID
@JsonField
name: String
@JsonField
address: String
address: Bech32|Keccak|String
@JsonField
publicKey: String
publicKey: Base58
@JsonField
chainCode: ChainCode
@JsonField
index: Int
@JsonField
controller: Bech32
@JsonField
createdAt: String?
@@ -66,7 +58,7 @@ class Account {
class Asset {
@PrimaryKey
id: UInt
id: DID
@JsonField
name: String
@@ -78,7 +70,7 @@ class Asset {
decimals: Int
@JsonField
chainId: Int?
chainCode: ChainCode
@JsonField
createdAt: String?
@@ -86,7 +78,7 @@ class Asset {
class Chain {
@PrimaryKey
id: UInt
id: DID
@JsonField
name: String
@@ -94,19 +86,22 @@ class Chain {
@JsonField
networkId: String
@JsonField
chainCode: ChainCode
@JsonField
createdAt: String?
}
class Credential {
@PrimaryKey
id: UInt
id: DID
@JsonField
subject: String
@JsonField
controller: String
controller: Bech32
@JsonField
attestationType: String
@@ -115,13 +110,13 @@ class Credential {
origin: String
@JsonField
credentialId: String
credentialId: Base64
@JsonField
publicKey: String
publicKey: Base64
@JsonField
transport: String
transport: List<String>
@JsonField
signCount: UInt
@@ -148,6 +143,54 @@ class Credential {
updatedAt: String?
}
class Grant {
@PrimaryKey
id: UInt
@JsonField
subject: String
@JsonField
controller: Bech32
@JsonField
origin: String
@JsonField
token: String
@JsonField
scopes: List<String>
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
class Keyshare {
@PrimaryKey
id: DID
@JsonField
data: Base64
@JsonField
role: Int
@JsonField
createdAt: String?
@JsonField
lastRefreshed: String?
}
class PublicKey {
@PrimaryKey
id: DID
}
class Profile {
@PrimaryKey
id: String
@@ -156,7 +199,7 @@ class Profile {
subject: String
@JsonField
controller: String
controller: Bech32
@JsonField
originUri: String?
@@ -174,103 +217,4 @@ class Profile {
updatedAt: String?
}
class Property {
@PrimaryKey
id: UInt
@JsonField
profileId: String
@JsonField
key: String
@JsonField
accumulator: String
@JsonField
propertyKey: String
}
class Keyshare {
@PrimaryKey
id: UInt
@JsonField
data: String
@JsonField
role: Int
@JsonField
createdAt: String?
}
class Permission {
@PrimaryKey
id: UInt
@JsonField
serviceId: String
@JsonField
grants: String
@JsonField
scopes: String
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
class DiscoveryDocument {
@JsonField
issuer: String
@JsonField
authorization_endpoint: String
@JsonField
token_endpoint: String
@JsonField
userinfo_endpoint: String
@JsonField
jwks_uri: String
@JsonField
registration_endpoint: String
@JsonField
scopes_supported: List<String>
@JsonField
response_types_supported: List<String>
@JsonField
response_modes_supported: List<String>
@JsonField
subject_types_supported: List<String>
@JsonField
id_token_signing_alg_values_supported: List<String>
@JsonField
claims_supported: List<String>
@JsonField
grant_types_supported: List<String>
@JsonField
acr_values_supported: List<String>
@JsonField
token_endpoint_auth_methods_supported: List<String>
}
+9 -1
View File
@@ -1,4 +1,4 @@
@go.Package { name = "github.com/onsonr/sonr/internal/dwn/txns" }
@go.Package { name = "github.com/onsonr/sonr/internal/vfs/txns" }
module txns
@@ -25,6 +25,14 @@ class Proposal {
description: String
}
class SWT {
origin: String
location: String
identifier: String
scopes: List<String>
properties: Map<String, String>
expiryBlock: Int
}
/// Gov module messages
class MsgGovSubmitProposal extends Msg {