feature/1121 implement ucan validation (#1176)

- **refactor: remove unused auth components**
- **refactor: improve devbox configuration and deployment process**
- **refactor: improve devnet and testnet setup**
- **fix: update templ version to v0.2.778**
- **refactor: rename pkl/net.matrix to pkl/matrix.net**
- **refactor: migrate webapp components to nebula**
- **refactor: protobuf types**
- **chore: update dependencies for improved security and stability**
- **feat: implement landing page and vault gateway servers**
- **refactor: Migrate data models to new module structure and update
related files**
- **feature/1121-implement-ucan-validation**
- **refactor: Replace hardcoded constants with model types in attns.go**
- **feature/1121-implement-ucan-validation**
- **chore: add origin Host struct and update main function to handle
multiple hosts**
- **build: remove unused static files from dwn module**
- **build: remove unused static files from dwn module**
- **refactor: Move DWN models to common package**
- **refactor: move models to pkg/common**
- **refactor: move vault web app assets to embed module**
- **refactor: update session middleware import path**
- **chore: configure port labels and auto-forwarding behavior**
- **feat: enhance devcontainer configuration**
- **feat: Add UCAN middleware for Echo with flexible token validation**
- **feat: add JWT middleware for UCAN authentication**
- **refactor: update package URI and versioning in PklProject files**
- **fix: correct sonr.pkl import path**
- **refactor: move JWT related code to auth package**
- **feat: introduce vault configuration retrieval and management**
- **refactor: Move vault components to gateway module and update file
paths**
- **refactor: remove Dexie and SQLite database implementations**
- **feat: enhance frontend with PWA features and WASM integration**
- **feat: add Devbox features and streamline Dockerfile**
- **chore: update dependencies to include TigerBeetle**
- **chore(deps): update go version to 1.23**
- **feat: enhance devnet setup with PATH environment variable and
updated PWA manifest**
- **fix: upgrade tigerbeetle-go dependency and remove indirect
dependency**
- **feat: add PostgreSQL support to devnet and testnet deployments**
- **refactor: rename keyshare cookie to token cookie**
- **feat: upgrade Go version to 1.23.3 and update dependencies**
- **refactor: update devnet and testnet configurations**
- **feat: add IPFS configuration for devnet**
- **I'll help you update the ipfs.config.pkl to include all the peers
from the shell script. Here's the updated configuration:**
- **refactor: move mpc package to crypto directory**
- **feat: add BIP32 support for various cryptocurrencies**
- **feat: enhance ATN.pkl with additional capabilities**
- **refactor: simplify smart account and vault attenuation creation**
- **feat: add new capabilities to the Attenuation type**
- **refactor: Rename MPC files for clarity and consistency**
- **feat: add DIDKey support for cryptographic operations**
- **feat: add devnet and testnet deployment configurations**
- **fix: correct key derivation in bip32 package**
- **refactor: rename crypto/bip32 package to crypto/accaddr**
- **fix: remove duplicate indirect dependency**
- **refactor: move vault package to root directory**
- **refactor: update routes for gateway and vault**
- **refactor: remove obsolete web configuration file**
- **refactor: remove unused TigerBeetle imports and update host
configuration**
- **refactor: adjust styles directory path**
- **feat: add broadcastTx and simulateTx functions to gateway**
- **feat: add PinVault handler**
This commit is contained in:
Prad Nukala
2024-12-02 14:27:18 -05:00
committed by GitHub
parent 2a128af227
commit 31bcc21c35
535 changed files with 9357 additions and 10950 deletions
+36
View File
@@ -0,0 +1,36 @@
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
package attns
import (
"context"
"github.com/apple/pkl-go/pkl"
)
type ATN struct {
}
// LoadFromPath loads the pkl module at the given path and evaluates it into a ATN
func LoadFromPath(ctx context.Context, path string) (ret *ATN, 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 ATN
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*ATN, error) {
var ret ATN
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
return nil, err
}
return &ret, nil
}
+109
View File
@@ -0,0 +1,109 @@
package attns
import (
"github.com/onsonr/sonr/x/dwn/types/attns/capability"
"github.com/onsonr/sonr/x/dwn/types/attns/policytype"
"github.com/onsonr/sonr/x/dwn/types/attns/resourcetype"
"github.com/ucan-wg/go-ucan"
)
const (
CapOwner = capability.CAPOWNER
CapOperator = capability.CAPOPERATOR
CapObserver = capability.CAPOBSERVER
CapAuthenticate = capability.CAPAUTHENTICATE
CapAuthorize = capability.CAPAUTHORIZE
CapDelegate = capability.CAPDELEGATE
CapInvoke = capability.CAPINVOKE
CapExecute = capability.CAPEXECUTE
CapPropose = capability.CAPPROPOSE
CapSign = capability.CAPSIGN
CapSetPolicy = capability.CAPSETPOLICY
CapSetThreshold = capability.CAPSETTHRESHOLD
CapRecover = capability.CAPRECOVER
CapSocial = capability.CAPSOCIAL
ResAccount = resourcetype.RESACCOUNT
ResTransaction = resourcetype.RESTRANSACTION
ResPolicy = resourcetype.RESPOLICY
ResRecovery = resourcetype.RESRECOVERY
ResVault = resourcetype.RESVAULT
PolicyThreshold = policytype.POLICYTHRESHOLD
PolicyTimelock = policytype.POLICYTIMELOCK
PolicyWhitelist = policytype.POLICYWHITELIST
)
// NewVaultResource creates a new resource identifier
func NewResource(resType resourcetype.ResourceType, path string) ucan.Resource {
return ucan.NewStringLengthResource(string(resType), path)
}
// Attenuation represents the type of attenuation
type Attenuation string
const (
// AttentuationSmartAccount represents the smart account attenuation
AttentuationSmartAccount = Attenuation("smart_account")
// AttentuationVault represents the vault attenuation
AttentuationVault = Attenuation("vault")
)
// Cap returns the capability for the given Attenuation
func (a Attenuation) NewCap(c capability.Capability) ucan.Capability {
return a.GetCapabilities().Cap(c.String())
}
// NestedCapabilities returns the nested capabilities for the given Attenuation
func (a Attenuation) GetCapabilities() ucan.NestedCapabilities {
var caps []string
switch a {
case AttentuationSmartAccount:
caps = baseSmartAccountCapabilities()
case AttentuationVault:
caps = baseVaultCapabilities()
}
return ucan.NewNestedCapabilities(caps...)
}
// Equals returns true if the given Attenuation is equal to the receiver
func (a Attenuation) Equals(b Attenuation) bool {
return a == b
}
// String returns the string representation of the Attenuation
func (a Attenuation) String() string {
return string(a)
}
// SmartAccountCapabilities defines the capability hierarchy
func baseSmartAccountCapabilities() []string {
return []string{
CapOwner.String(),
CapOperator.String(),
CapObserver.String(),
CapExecute.String(),
CapPropose.String(),
CapSign.String(),
CapSetPolicy.String(),
CapSetThreshold.String(),
CapRecover.String(),
CapSocial.String(),
}
}
// VaultCapabilities defines the capability hierarchy
func baseVaultCapabilities() []string {
return []string{
CapOwner.String(),
CapOperator.String(),
CapObserver.String(),
CapAuthenticate.String(),
CapAuthorize.String(),
CapDelegate.String(),
CapInvoke.String(),
CapExecute.String(),
CapRecover.String(),
}
}
@@ -0,0 +1,73 @@
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
package capability
import (
"encoding"
"fmt"
)
type Capability string
const (
CAPOWNER Capability = "CAP_OWNER"
CAPOPERATOR Capability = "CAP_OPERATOR"
CAPOBSERVER Capability = "CAP_OBSERVER"
CAPAUTHENTICATE Capability = "CAP_AUTHENTICATE"
CAPAUTHORIZE Capability = "CAP_AUTHORIZE"
CAPDELEGATE Capability = "CAP_DELEGATE"
CAPINVOKE Capability = "CAP_INVOKE"
CAPEXECUTE Capability = "CAP_EXECUTE"
CAPPROPOSE Capability = "CAP_PROPOSE"
CAPSIGN Capability = "CAP_SIGN"
CAPSETPOLICY Capability = "CAP_SET_POLICY"
CAPSETTHRESHOLD Capability = "CAP_SET_THRESHOLD"
CAPRECOVER Capability = "CAP_RECOVER"
CAPSOCIAL Capability = "CAP_SOCIAL"
CAPVOTE Capability = "CAP_VOTE"
)
// String returns the string representation of Capability
func (rcv Capability) String() string {
return string(rcv)
}
var _ encoding.BinaryUnmarshaler = new(Capability)
// UnmarshalBinary implements encoding.BinaryUnmarshaler for Capability.
func (rcv *Capability) UnmarshalBinary(data []byte) error {
switch str := string(data); str {
case "CAP_OWNER":
*rcv = CAPOWNER
case "CAP_OPERATOR":
*rcv = CAPOPERATOR
case "CAP_OBSERVER":
*rcv = CAPOBSERVER
case "CAP_AUTHENTICATE":
*rcv = CAPAUTHENTICATE
case "CAP_AUTHORIZE":
*rcv = CAPAUTHORIZE
case "CAP_DELEGATE":
*rcv = CAPDELEGATE
case "CAP_INVOKE":
*rcv = CAPINVOKE
case "CAP_EXECUTE":
*rcv = CAPEXECUTE
case "CAP_PROPOSE":
*rcv = CAPPROPOSE
case "CAP_SIGN":
*rcv = CAPSIGN
case "CAP_SET_POLICY":
*rcv = CAPSETPOLICY
case "CAP_SET_THRESHOLD":
*rcv = CAPSETTHRESHOLD
case "CAP_RECOVER":
*rcv = CAPRECOVER
case "CAP_SOCIAL":
*rcv = CAPSOCIAL
case "CAP_VOTE":
*rcv = CAPVOTE
default:
return fmt.Errorf(`illegal: "%s" is not a valid Capability`, str)
}
return nil
}
+8
View File
@@ -0,0 +1,8 @@
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
package attns
import "github.com/apple/pkl-go/pkl"
func init() {
pkl.RegisterMapping("sonr.motr.ATN", ATN{})
}
@@ -0,0 +1,37 @@
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
package policytype
import (
"encoding"
"fmt"
)
type PolicyType string
const (
POLICYTHRESHOLD PolicyType = "POLICY_THRESHOLD"
POLICYTIMELOCK PolicyType = "POLICY_TIMELOCK"
POLICYWHITELIST PolicyType = "POLICY_WHITELIST"
)
// String returns the string representation of PolicyType
func (rcv PolicyType) String() string {
return string(rcv)
}
var _ encoding.BinaryUnmarshaler = new(PolicyType)
// UnmarshalBinary implements encoding.BinaryUnmarshaler for PolicyType.
func (rcv *PolicyType) UnmarshalBinary(data []byte) error {
switch str := string(data); str {
case "POLICY_THRESHOLD":
*rcv = POLICYTHRESHOLD
case "POLICY_TIMELOCK":
*rcv = POLICYTIMELOCK
case "POLICY_WHITELIST":
*rcv = POLICYWHITELIST
default:
return fmt.Errorf(`illegal: "%s" is not a valid PolicyType`, str)
}
return nil
}
@@ -0,0 +1,43 @@
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
package resourcetype
import (
"encoding"
"fmt"
)
type ResourceType string
const (
RESACCOUNT ResourceType = "RES_ACCOUNT"
RESTRANSACTION ResourceType = "RES_TRANSACTION"
RESPOLICY ResourceType = "RES_POLICY"
RESRECOVERY ResourceType = "RES_RECOVERY"
RESVAULT ResourceType = "RES_VAULT"
)
// String returns the string representation of ResourceType
func (rcv ResourceType) String() string {
return string(rcv)
}
var _ encoding.BinaryUnmarshaler = new(ResourceType)
// UnmarshalBinary implements encoding.BinaryUnmarshaler for ResourceType.
func (rcv *ResourceType) UnmarshalBinary(data []byte) error {
switch str := string(data); str {
case "RES_ACCOUNT":
*rcv = RESACCOUNT
case "RES_TRANSACTION":
*rcv = RESTRANSACTION
case "RES_POLICY":
*rcv = RESPOLICY
case "RES_RECOVERY":
*rcv = RESRECOVERY
case "RES_VAULT":
*rcv = RESVAULT
default:
return fmt.Errorf(`illegal: "%s" is not a valid ResourceType`, str)
}
return nil
}
+46
View File
@@ -0,0 +1,46 @@
package attns
import (
"fmt"
"github.com/onsonr/sonr/x/dwn/types/attns/capability"
"github.com/onsonr/sonr/x/dwn/types/attns/policytype"
"github.com/ucan-wg/go-ucan"
)
// CreateSmartAccountAttenuations creates default attenuations for a smart account
func CreateSmartAccountAttenuations(
accountAddr string,
) ucan.Attenuations {
caps := AttentuationSmartAccount.GetCapabilities()
return ucan.Attenuations{
// Owner capabilities
{Cap: caps.Cap(CapOwner.String()), Rsc: NewResource(ResAccount, accountAddr)},
// Operation capabilities
{Cap: caps.Cap(capability.CAPEXECUTE.String()), Rsc: NewResource(ResTransaction, fmt.Sprintf("%s:*", accountAddr))},
{Cap: caps.Cap(capability.CAPPROPOSE.String()), Rsc: NewResource(ResTransaction, fmt.Sprintf("%s:*", accountAddr))},
{Cap: caps.Cap(capability.CAPSIGN.String()), Rsc: NewResource(ResTransaction, fmt.Sprintf("%s:*", accountAddr))},
// Policy capabilities
{Cap: caps.Cap(capability.CAPSETPOLICY.String()), Rsc: NewResource(ResPolicy, fmt.Sprintf("%s:*", accountAddr))},
{Cap: caps.Cap(capability.CAPSETTHRESHOLD.String()), Rsc: NewResource(ResPolicy, fmt.Sprintf("%s:threshold", accountAddr))},
}
}
// CreateSmartAccountPolicyAttenuation creates attenuations for policy management
func CreateSmartAccountPolicyAttenuation(
accountAddr string,
policyType policytype.PolicyType,
) ucan.Attenuations {
caps := AttentuationSmartAccount.GetCapabilities()
return ucan.Attenuations{
{
Cap: caps.Cap(capability.CAPSETPOLICY.String()),
Rsc: NewResource(
ResPolicy,
fmt.Sprintf("%s:%s", accountAddr, policyType),
),
},
}
}
+47
View File
@@ -0,0 +1,47 @@
package attns
import (
"fmt"
"github.com/onsonr/sonr/x/dwn/types/attns/capability"
"github.com/onsonr/sonr/x/dwn/types/attns/policytype"
"github.com/onsonr/sonr/x/dwn/types/attns/resourcetype"
"github.com/ucan-wg/go-ucan"
)
// CreateVaultAttenuations creates default attenuations for a smart account
func CreateVaultAttenuations(
accountAddr string,
) ucan.Attenuations {
caps := AttentuationVault.GetCapabilities()
return ucan.Attenuations{
// Owner capabilities
{Cap: caps.Cap(capability.CAPOWNER.String()), Rsc: NewResource(resourcetype.RESACCOUNT, accountAddr)},
// Operation capabilities
{Cap: caps.Cap(capability.CAPEXECUTE.String()), Rsc: NewResource(resourcetype.RESTRANSACTION, fmt.Sprintf("%s:*", accountAddr))},
{Cap: caps.Cap(capability.CAPPROPOSE.String()), Rsc: NewResource(resourcetype.RESTRANSACTION, fmt.Sprintf("%s:*", accountAddr))},
{Cap: caps.Cap(capability.CAPSIGN.String()), Rsc: NewResource(resourcetype.RESTRANSACTION, fmt.Sprintf("%s:*", accountAddr))},
// Policy capabilities
{Cap: caps.Cap(capability.CAPSETPOLICY.String()), Rsc: NewResource(resourcetype.RESPOLICY, fmt.Sprintf("%s:*", accountAddr))},
{Cap: caps.Cap(capability.CAPSETTHRESHOLD.String()), Rsc: NewResource(resourcetype.RESPOLICY, fmt.Sprintf("%s:threshold", accountAddr))},
}
}
// CreateVaultPolicyAttenuation creates attenuations for policy management
func CreateVaultPolicyAttenuation(
accountAddr string,
policyType policytype.PolicyType,
) ucan.Attenuations {
caps := AttentuationVault.GetCapabilities()
return ucan.Attenuations{
{
Cap: caps.Cap(capability.CAPSETPOLICY.String()),
Rsc: NewResource(
resourcetype.RESPOLICY,
fmt.Sprintf("%s:%s", accountAddr, policyType),
),
},
}
}
+13 -31
View File
@@ -1,36 +1,18 @@
package types
// Define capability hierarchy for smart account operations
const (
// Root capabilities
CAP_OWNER = "OWNER" // Full account control
CAP_OPERATOR = "OPERATOR" // Can perform operations
CAP_OBSERVER = "OBSERVER" // Can view account state
// Operation capabilities
CAP_EXECUTE = "EXECUTE" // Can execute transactions
CAP_PROPOSE = "PROPOSE" // Can propose transactions
CAP_SIGN = "SIGN" // Can sign transactions
// Policy capabilities
CAP_SET_POLICY = "SET_POLICY" // Can modify account policies
CAP_SET_THRESHOLD = "SET_THRESHOLD" // Can modify signing threshold
// Recovery capabilities
CAP_RECOVER = "RECOVER" // Can initiate recovery
CAP_SOCIAL = "SOCIAL" // Can act as social recovery
)
// Resource types for smart account operations
type ResourceType string
const (
RES_ACCOUNT = "account"
RES_TRANSACTION = "tx"
RES_POLICY = "policy"
RES_RECOVERY = "recovery"
)
// Capability hierarchy for smart account operations
// ----------------------------------------------
// OWNER
//
// └─ OPERATOR
// ├─ EXECUTE
// ├─ PROPOSE
// └─ SIGN
// └─ SET_POLICY
// └─ SET_THRESHOLD
// └─ RECOVER
// └─ SOCIAL
//
// DefaultIndex is the default global index
const DefaultIndex uint64 = 1
+690 -76
View File
@@ -72,9 +72,14 @@ func (m *GenesisState) GetParams() Params {
// Params defines the set of module parameters.
type Params struct {
IpfsActive bool `protobuf:"varint,1,opt,name=ipfs_active,json=ipfsActive,proto3" json:"ipfs_active,omitempty"`
LocalRegistrationEnabled bool `protobuf:"varint,2,opt,name=local_registration_enabled,json=localRegistrationEnabled,proto3" json:"local_registration_enabled,omitempty"`
Schema *Schema `protobuf:"bytes,4,opt,name=schema,proto3" json:"schema,omitempty"`
// Whitelisted Key Types
AllowedPublicKeys map[string]*KeyInfo `protobuf:"bytes,1,rep,name=allowed_public_keys,json=allowedPublicKeys,proto3" json:"allowed_public_keys,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// ConveyancePreference defines the conveyance preference
ConveyancePreference string `protobuf:"bytes,2,opt,name=conveyance_preference,json=conveyancePreference,proto3" json:"conveyance_preference,omitempty"`
// AttestationFormats defines the attestation formats
AttestationFormats []string `protobuf:"bytes,3,rep,name=attestation_formats,json=attestationFormats,proto3" json:"attestation_formats,omitempty"`
Schema *Schema `protobuf:"bytes,4,opt,name=schema,proto3" json:"schema,omitempty"`
AllowedOperators []string `protobuf:"bytes,5,rep,name=allowed_operators,json=allowedOperators,proto3" json:"allowed_operators,omitempty"`
}
func (m *Params) Reset() { *m = Params{} }
@@ -109,18 +114,25 @@ func (m *Params) XXX_DiscardUnknown() {
var xxx_messageInfo_Params proto.InternalMessageInfo
func (m *Params) GetIpfsActive() bool {
func (m *Params) GetAllowedPublicKeys() map[string]*KeyInfo {
if m != nil {
return m.IpfsActive
return m.AllowedPublicKeys
}
return false
return nil
}
func (m *Params) GetLocalRegistrationEnabled() bool {
func (m *Params) GetConveyancePreference() string {
if m != nil {
return m.LocalRegistrationEnabled
return m.ConveyancePreference
}
return false
return ""
}
func (m *Params) GetAttestationFormats() []string {
if m != nil {
return m.AttestationFormats
}
return nil
}
func (m *Params) GetSchema() *Schema {
@@ -130,6 +142,13 @@ func (m *Params) GetSchema() *Schema {
return nil
}
func (m *Params) GetAllowedOperators() []string {
if m != nil {
return m.AllowedOperators
}
return nil
}
// Capability reprensents the available capabilities of a decentralized web node
type Capability struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
@@ -199,6 +218,75 @@ func (m *Capability) GetResources() []string {
return nil
}
// KeyInfo defines information for accepted PubKey types
type KeyInfo struct {
Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
Algorithm string `protobuf:"bytes,2,opt,name=algorithm,proto3" json:"algorithm,omitempty"`
Encoding string `protobuf:"bytes,3,opt,name=encoding,proto3" json:"encoding,omitempty"`
Curve string `protobuf:"bytes,4,opt,name=curve,proto3" json:"curve,omitempty"`
}
func (m *KeyInfo) Reset() { *m = KeyInfo{} }
func (m *KeyInfo) String() string { return proto.CompactTextString(m) }
func (*KeyInfo) ProtoMessage() {}
func (*KeyInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_8e7492a25d5871dc, []int{3}
}
func (m *KeyInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *KeyInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_KeyInfo.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *KeyInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_KeyInfo.Merge(m, src)
}
func (m *KeyInfo) XXX_Size() int {
return m.Size()
}
func (m *KeyInfo) XXX_DiscardUnknown() {
xxx_messageInfo_KeyInfo.DiscardUnknown(m)
}
var xxx_messageInfo_KeyInfo proto.InternalMessageInfo
func (m *KeyInfo) GetRole() string {
if m != nil {
return m.Role
}
return ""
}
func (m *KeyInfo) GetAlgorithm() string {
if m != nil {
return m.Algorithm
}
return ""
}
func (m *KeyInfo) GetEncoding() string {
if m != nil {
return m.Encoding
}
return ""
}
func (m *KeyInfo) GetCurve() string {
if m != nil {
return m.Curve
}
return ""
}
// Resource reprensents the available resources of a decentralized web node
type Resource struct {
Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
@@ -209,7 +297,7 @@ func (m *Resource) Reset() { *m = Resource{} }
func (m *Resource) String() string { return proto.CompactTextString(m) }
func (*Resource) ProtoMessage() {}
func (*Resource) Descriptor() ([]byte, []int) {
return fileDescriptor_8e7492a25d5871dc, []int{3}
return fileDescriptor_8e7492a25d5871dc, []int{4}
}
func (m *Resource) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@@ -270,7 +358,7 @@ func (m *Schema) Reset() { *m = Schema{} }
func (m *Schema) String() string { return proto.CompactTextString(m) }
func (*Schema) ProtoMessage() {}
func (*Schema) Descriptor() ([]byte, []int) {
return fileDescriptor_8e7492a25d5871dc, []int{4}
return fileDescriptor_8e7492a25d5871dc, []int{5}
}
func (m *Schema) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@@ -372,7 +460,9 @@ func (m *Schema) GetProfile() string {
func init() {
proto.RegisterType((*GenesisState)(nil), "dwn.v1.GenesisState")
proto.RegisterType((*Params)(nil), "dwn.v1.Params")
proto.RegisterMapType((map[string]*KeyInfo)(nil), "dwn.v1.Params.AllowedPublicKeysEntry")
proto.RegisterType((*Capability)(nil), "dwn.v1.Capability")
proto.RegisterType((*KeyInfo)(nil), "dwn.v1.KeyInfo")
proto.RegisterType((*Resource)(nil), "dwn.v1.Resource")
proto.RegisterType((*Schema)(nil), "dwn.v1.Schema")
}
@@ -380,40 +470,50 @@ func init() {
func init() { proto.RegisterFile("dwn/v1/genesis.proto", fileDescriptor_8e7492a25d5871dc) }
var fileDescriptor_8e7492a25d5871dc = []byte{
// 519 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x93, 0x31, 0x6f, 0x13, 0x31,
0x14, 0xc7, 0x73, 0x34, 0xbd, 0xe6, 0x5e, 0x2b, 0x04, 0x56, 0x85, 0x4c, 0x84, 0x2e, 0x51, 0x06,
0x54, 0x21, 0x94, 0x53, 0x61, 0xab, 0xb2, 0x50, 0x84, 0x58, 0xd1, 0x75, 0x63, 0x89, 0x9c, 0xbb,
0xd7, 0x8b, 0x9b, 0x3b, 0xfb, 0x64, 0x3b, 0x49, 0xf3, 0x15, 0x98, 0x18, 0x19, 0x3b, 0x33, 0xf1,
0x31, 0x3a, 0x76, 0x64, 0x42, 0x28, 0x19, 0xe0, 0x23, 0x30, 0x22, 0xdb, 0x97, 0x12, 0x16, 0xeb,
0xfd, 0x7f, 0xff, 0xe7, 0xe7, 0xff, 0x8b, 0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x0e, 0xee, 0xd6, 0x71, 0xf0, 0x73, 0x1d,
0x07, 0x9f, 0x37, 0x71, 0xeb, 0x6e, 0x13, 0xb7, 0xbe, 0x6f, 0xe2, 0xd6, 0xc7, 0x41, 0xc1, 0xcd,
0x74, 0x3e, 0x19, 0x66, 0xb2, 0x4a, 0xa4, 0xd0, 0x52, 0xa8, 0xc4, 0x1d, 0xd7, 0x89, 0xfd, 0x2a,
0xcc, 0xaa, 0x46, 0x3d, 0x09, 0xdd, 0x1f, 0xfc, 0xf5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d,
0x36, 0x1c, 0x5c, 0x29, 0x03, 0x00, 0x00,
// 677 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x54, 0x4f, 0x6f, 0xd3, 0x30,
0x1c, 0x6d, 0xd6, 0x3f, 0x5b, 0xdd, 0x09, 0x36, 0xaf, 0x4c, 0xa1, 0x42, 0x5d, 0x55, 0x69, 0xa8,
0x02, 0xd4, 0x68, 0xdb, 0x05, 0x4d, 0xbb, 0x30, 0x04, 0x08, 0xed, 0xc0, 0x94, 0x69, 0x17, 0x2e,
0x95, 0x9b, 0xfc, 0xda, 0x7a, 0x4d, 0xec, 0xc8, 0x76, 0xd3, 0xe5, 0x2b, 0x20, 0x0e, 0x1c, 0x39,
0xee, 0x23, 0xf0, 0x31, 0x76, 0xdc, 0x91, 0x13, 0x42, 0xdb, 0x01, 0x3e, 0x02, 0x47, 0x64, 0x3b,
0xe9, 0x36, 0xc4, 0x25, 0xfa, 0xbd, 0xf7, 0x9c, 0xdf, 0x7b, 0x3f, 0xdb, 0x09, 0x6a, 0x86, 0x73,
0xe6, 0xa5, 0x3b, 0xde, 0x18, 0x18, 0x48, 0x2a, 0xfb, 0x89, 0xe0, 0x8a, 0xe3, 0x5a, 0x38, 0x67,
0xfd, 0x74, 0xa7, 0xd5, 0x1c, 0xf3, 0x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0x00,
}
func (this *Params) Equal(that interface{}) bool {
@@ -435,15 +535,36 @@ func (this *Params) Equal(that interface{}) bool {
} else if this == nil {
return false
}
if this.IpfsActive != that1.IpfsActive {
if len(this.AllowedPublicKeys) != len(that1.AllowedPublicKeys) {
return false
}
if this.LocalRegistrationEnabled != that1.LocalRegistrationEnabled {
for i := range this.AllowedPublicKeys {
if !this.AllowedPublicKeys[i].Equal(that1.AllowedPublicKeys[i]) {
return false
}
}
if this.ConveyancePreference != that1.ConveyancePreference {
return false
}
if len(this.AttestationFormats) != len(that1.AttestationFormats) {
return false
}
for i := range this.AttestationFormats {
if this.AttestationFormats[i] != that1.AttestationFormats[i] {
return false
}
}
if !this.Schema.Equal(that1.Schema) {
return false
}
if len(this.AllowedOperators) != len(that1.AllowedOperators) {
return false
}
for i := range this.AllowedOperators {
if this.AllowedOperators[i] != that1.AllowedOperators[i] {
return false
}
}
return true
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@@ -499,6 +620,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.AllowedOperators) > 0 {
for iNdEx := len(m.AllowedOperators) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.AllowedOperators[iNdEx])
copy(dAtA[i:], m.AllowedOperators[iNdEx])
i = encodeVarintGenesis(dAtA, i, uint64(len(m.AllowedOperators[iNdEx])))
i--
dAtA[i] = 0x2a
}
}
if m.Schema != nil {
{
size, err := m.Schema.MarshalToSizedBuffer(dAtA[:i])
@@ -511,25 +641,47 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x22
}
if m.LocalRegistrationEnabled {
i--
if m.LocalRegistrationEnabled {
dAtA[i] = 1
} else {
dAtA[i] = 0
if len(m.AttestationFormats) > 0 {
for iNdEx := len(m.AttestationFormats) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.AttestationFormats[iNdEx])
copy(dAtA[i:], m.AttestationFormats[iNdEx])
i = encodeVarintGenesis(dAtA, i, uint64(len(m.AttestationFormats[iNdEx])))
i--
dAtA[i] = 0x1a
}
i--
dAtA[i] = 0x10
}
if m.IpfsActive {
if len(m.ConveyancePreference) > 0 {
i -= len(m.ConveyancePreference)
copy(dAtA[i:], m.ConveyancePreference)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConveyancePreference)))
i--
if m.IpfsActive {
dAtA[i] = 1
} else {
dAtA[i] = 0
dAtA[i] = 0x12
}
if len(m.AllowedPublicKeys) > 0 {
for k := range m.AllowedPublicKeys {
v := m.AllowedPublicKeys[k]
baseI := i
if v != nil {
{
size, err := v.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
i -= len(k)
copy(dAtA[i:], k)
i = encodeVarintGenesis(dAtA, i, uint64(len(k)))
i--
dAtA[i] = 0xa
i = encodeVarintGenesis(dAtA, i, uint64(baseI-i))
i--
dAtA[i] = 0xa
}
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
@@ -587,6 +739,57 @@ func (m *Capability) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *KeyInfo) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *KeyInfo) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *KeyInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Curve) > 0 {
i -= len(m.Curve)
copy(dAtA[i:], m.Curve)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Curve)))
i--
dAtA[i] = 0x22
}
if len(m.Encoding) > 0 {
i -= len(m.Encoding)
copy(dAtA[i:], m.Encoding)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Encoding)))
i--
dAtA[i] = 0x1a
}
if len(m.Algorithm) > 0 {
i -= len(m.Algorithm)
copy(dAtA[i:], m.Algorithm)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Algorithm)))
i--
dAtA[i] = 0x12
}
if len(m.Role) > 0 {
i -= len(m.Role)
copy(dAtA[i:], m.Role)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Role)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *Resource) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@@ -743,16 +946,39 @@ func (m *Params) Size() (n int) {
}
var l int
_ = l
if m.IpfsActive {
n += 2
if len(m.AllowedPublicKeys) > 0 {
for k, v := range m.AllowedPublicKeys {
_ = k
_ = v
l = 0
if v != nil {
l = v.Size()
l += 1 + sovGenesis(uint64(l))
}
mapEntrySize := 1 + len(k) + sovGenesis(uint64(len(k))) + l
n += mapEntrySize + 1 + sovGenesis(uint64(mapEntrySize))
}
}
if m.LocalRegistrationEnabled {
n += 2
l = len(m.ConveyancePreference)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
if len(m.AttestationFormats) > 0 {
for _, s := range m.AttestationFormats {
l = len(s)
n += 1 + l + sovGenesis(uint64(l))
}
}
if m.Schema != nil {
l = m.Schema.Size()
n += 1 + l + sovGenesis(uint64(l))
}
if len(m.AllowedOperators) > 0 {
for _, s := range m.AllowedOperators {
l = len(s)
n += 1 + l + sovGenesis(uint64(l))
}
}
return n
}
@@ -783,6 +1009,31 @@ func (m *Capability) Size() (n int) {
return n
}
func (m *KeyInfo) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Role)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
l = len(m.Algorithm)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
l = len(m.Encoding)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
l = len(m.Curve)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
return n
}
func (m *Resource) Size() (n int) {
if m == nil {
return 0
@@ -967,10 +1218,10 @@ func (m *Params) Unmarshal(dAtA []byte) error {
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field IpfsActive", wireType)
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AllowedPublicKeys", wireType)
}
var v int
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
@@ -980,17 +1231,126 @@ func (m *Params) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
v |= int(b&0x7F) << shift
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
m.IpfsActive = bool(v != 0)
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.AllowedPublicKeys == nil {
m.AllowedPublicKeys = make(map[string]*KeyInfo)
}
var mapkey string
var mapvalue *KeyInfo
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
var stringLenmapkey uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapkey := int(stringLenmapkey)
if intStringLenmapkey < 0 {
return ErrInvalidLengthGenesis
}
postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthGenesis
}
if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF
}
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey
} else if fieldNum == 2 {
var mapmsglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
mapmsglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if mapmsglen < 0 {
return ErrInvalidLengthGenesis
}
postmsgIndex := iNdEx + mapmsglen
if postmsgIndex < 0 {
return ErrInvalidLengthGenesis
}
if postmsgIndex > l {
return io.ErrUnexpectedEOF
}
mapvalue = &KeyInfo{}
if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil {
return err
}
iNdEx = postmsgIndex
} else {
iNdEx = entryPreIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.AllowedPublicKeys[mapkey] = mapvalue
iNdEx = postIndex
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field LocalRegistrationEnabled", wireType)
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ConveyancePreference", wireType)
}
var v int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
@@ -1000,12 +1360,56 @@ func (m *Params) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
v |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
m.LocalRegistrationEnabled = bool(v != 0)
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ConveyancePreference = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AttestationFormats", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.AttestationFormats = append(m.AttestationFormats, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType)
@@ -1042,6 +1446,38 @@ func (m *Params) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AllowedOperators", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.AllowedOperators = append(m.AllowedOperators, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
@@ -1241,6 +1677,184 @@ func (m *Capability) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *KeyInfo) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: KeyInfo: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: KeyInfo: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Role = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Algorithm", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Algorithm = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Encoding", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Encoding = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Curve", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Curve = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Resource) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
+1 -3
View File
@@ -18,9 +18,7 @@ func NewMsgUpdateParams(
) *MsgUpdateParams {
return &MsgUpdateParams{
Authority: sender.String(),
Params: Params{
IpfsActive: someValue,
},
Params: Params{},
}
}
+91 -14
View File
@@ -3,17 +3,24 @@ package types
import (
"encoding/json"
"github.com/onsonr/sonr/pkg/common"
orm "github.com/onsonr/sonr/pkg/common/models"
"github.com/onsonr/sonr/pkg/common/models"
"github.com/onsonr/sonr/pkg/common/models/keyalgorithm"
"github.com/onsonr/sonr/pkg/common/models/keycurve"
"github.com/onsonr/sonr/pkg/common/models/keyencoding"
"github.com/onsonr/sonr/pkg/common/models/keyrole"
)
// DefaultParams returns default module parameters.
func DefaultParams() Params {
// TODO:
return Params{
IpfsActive: true,
LocalRegistrationEnabled: true,
Schema: DefaultSchema(),
ConveyancePreference: "direct",
AttestationFormats: []string{"packed", "android-key", "fido-u2f", "apple"},
Schema: DefaultSchema(),
AllowedOperators: []string{ // TODO:
"localhost",
"didao.xyz",
"sonr.id",
},
}
}
@@ -36,13 +43,83 @@ func (p Params) Validate() error {
// DefaultSchema returns the default schema
func DefaultSchema() *Schema {
return &Schema{
Version: common.SchemaVersion,
Account: common.GetSchema(&orm.Account{}),
Asset: common.GetSchema(&orm.Asset{}),
Chain: common.GetSchema(&orm.Chain{}),
Credential: common.GetSchema(&orm.Credential{}),
Grant: common.GetSchema(&orm.Grant{}),
Keyshare: common.GetSchema(&orm.Keyshare{}),
Profile: common.GetSchema(&orm.Profile{}),
Version: SchemaVersion,
Account: GetSchema(&models.Account{}),
Asset: GetSchema(&models.Asset{}),
Chain: GetSchema(&models.Chain{}),
Credential: GetSchema(&models.Credential{}),
Grant: GetSchema(&models.Grant{}),
Keyshare: GetSchema(&models.Keyshare{}),
Profile: GetSchema(&models.Profile{}),
}
}
func DefaultKeyInfos() map[string]*KeyInfo {
return map[string]*KeyInfo{
// Identity Key Info
// Sonr Controller Key Info - From MPC
"auth.dwn": {
Role: keyrole.Invocation.String(),
Curve: keycurve.P256.String(),
Algorithm: keyalgorithm.Ecdsa.String(),
Encoding: keyencoding.Hex.String(),
},
// Sonr Vault Shared Key Info - From Registration
"auth.zk": {
Role: keyrole.Assertion.String(),
Curve: keycurve.Bls12381.String(),
Algorithm: keyalgorithm.Es256k.String(),
Encoding: keyencoding.Multibase.String(),
},
// Blockchain Key Info
// Ethereum Key Info
"auth.ethereum": {
Role: keyrole.Delegation.String(),
Curve: keycurve.Keccak256.String(),
Algorithm: keyalgorithm.Ecdsa.String(),
Encoding: keyencoding.Hex.String(),
},
// Bitcoin/IBC Key Info
"auth.bitcoin": {
Role: keyrole.Delegation.String(),
Curve: keycurve.Secp256k1.String(),
Algorithm: keyalgorithm.Ecdsa.String(),
Encoding: keyencoding.Hex.String(),
},
// Authentication Key Info
// Browser based WebAuthn
"webauthn.browser": {
Role: keyrole.Authentication.String(),
Curve: keycurve.P256.String(),
Algorithm: keyalgorithm.Es256.String(),
Encoding: keyencoding.Raw.String(),
},
// FIDO U2F
"webauthn.fido": {
Role: keyrole.Authentication.String(),
Curve: keycurve.P256.String(),
Algorithm: keyalgorithm.Es256.String(),
Encoding: keyencoding.Raw.String(),
},
// Cross-Platform Passkeys
"webauthn.passkey": {
Role: keyrole.Authentication.String(),
Curve: keycurve.Ed25519.String(),
Algorithm: keyalgorithm.Eddsa.String(),
Encoding: keyencoding.Raw.String(),
},
}
}
// # Genesis Structures
//
// Equal returns true if two key infos are equal
func (k *KeyInfo) Equal(b *KeyInfo) bool {
if k == nil && b == nil {
return true
}
return false
}
+39
View File
@@ -0,0 +1,39 @@
package types
import (
"reflect"
"strings"
)
const SchemaVersion = 1
func toCamelCase(s string) string {
if s == "" {
return s
}
if len(s) == 1 {
return strings.ToLower(s)
}
return strings.ToLower(s[:1]) + s[1:]
}
func GetSchema(structType interface{}) string {
t := reflect.TypeOf(structType)
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
if t.Kind() != reflect.Struct {
return ""
}
var fields []string
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
fieldName := toCamelCase(field.Name)
fields = append(fields, fieldName)
}
// Add "++" at the beginning, separated by a comma
return "++, " + strings.Join(fields, ", ")
}
-42
View File
@@ -1,42 +0,0 @@
package types
import (
"github.com/ipfs/boxo/files"
"github.com/onsonr/sonr/pkg/core/dwn"
"github.com/onsonr/sonr/x/dwn/types/static"
)
const (
kFileNameConfigJSON = "dwn.json"
kFileNameIndexHTML = "index.html"
kFileNameWorkerJS = "sw.js"
)
type Vault = files.Directory
func SpawnVault(keyshareJSON string, adddress string, chainID string, schema *dwn.Schema) (Vault, error) {
dwnCfg := &dwn.Config{
MotrKeyshare: keyshareJSON,
MotrAddress: adddress,
IpfsGatewayUrl: "https://ipfs.sonr.land",
SonrApiUrl: "https://api.sonr.land",
SonrRpcUrl: "https://rpc.sonr.land",
SonrChainId: chainID,
VaultSchema: schema,
}
cnf, err := dwnCfg.MarshalJSON()
if err != nil {
return nil, err
}
return setupVaultDirectory(cnf), nil
}
// spawnVaultDirectory creates a new directory with the default files
func setupVaultDirectory(cfgBz []byte) files.Directory {
return files.NewMapDirectory(map[string]files.Node{
kFileNameConfigJSON: files.NewBytesFile(cfgBz),
kFileNameIndexHTML: files.NewBytesFile(static.IndexHTML),
kFileNameWorkerJS: files.NewBytesFile(static.WorkerJS),
})
}
-36
View File
@@ -1,36 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<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>Sonr DWN</title>
<script type="text/javascript">
if ("serviceWorker" in navigator) {
// Register the service worker
window.addEventListener("load", function () {
navigator.serviceWorker
.register("/sw.js")
.then(function (registration) {
console.log(
"Service Worker registered with scope:",
registration.scope,
);
})
.catch(function (error) {
console.log("Service Worker registration failed:", error);
});
});
}
</script>
</head>
<body
class="flex items-center justify-center h-full bg-zinc-50 lg:p-24 md:16 p-4"
>
<main
class="flex-row items-center justify-center mx-auto w-fit max-w-screen-sm gap-y-3"
>
<div hx-get="/#" swap="outerHTML">Loading...</div>
</main>
</body>
</html>
-11
View File
@@ -1,11 +0,0 @@
package static
import (
_ "embed"
)
//go:embed index.html
var IndexHTML []byte
//go:embed sw.js
var WorkerJS []byte
-258
View File
@@ -1,258 +0,0 @@
// Cache names for different types of resources
const CACHE_NAMES = {
wasm: 'wasm-cache-v1',
static: 'static-cache-v1',
dynamic: 'dynamic-cache-v1'
};
// Import required scripts
importScripts(
"https://cdn.jsdelivr.net/gh/golang/go@go1.22.5/misc/wasm/wasm_exec.js",
"https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js",
);
// Initialize WASM HTTP listener
const wasmInstance = registerWasmHTTPListener("https://cdn.sonr.id/wasm/app.wasm");
// MessageChannel port for WASM communication
let wasmPort;
// Request queue for offline operations
let requestQueue = new Map();
// Setup message channel handler
self.addEventListener('message', async (event) => {
if (event.data.type === 'PORT_INITIALIZATION') {
wasmPort = event.data.port;
setupWasmCommunication();
}
});
function setupWasmCommunication() {
wasmPort.onmessage = async (event) => {
const { type, data } = event.data;
switch (type) {
case 'WASM_REQUEST':
handleWasmRequest(data);
break;
case 'SYNC_REQUEST':
processSyncQueue();
break;
}
};
// Notify that WASM is ready
wasmPort.postMessage({ type: 'WASM_READY' });
}
// Enhanced install event
self.addEventListener("install", (event) => {
event.waitUntil(
Promise.all([
skipWaiting(),
// Cache WASM binary and essential resources
caches.open(CACHE_NAMES.wasm).then(cache =>
cache.addAll([
'https://cdn.sonr.id/wasm/app.wasm',
'https://cdn.jsdelivr.net/gh/golang/go@go1.22.5/misc/wasm/wasm_exec.js'
])
)
])
);
});
// Enhanced activate event
self.addEventListener("activate", (event) => {
event.waitUntil(
Promise.all([
clients.claim(),
// Clean up old caches
caches.keys().then(keys =>
Promise.all(
keys.map(key => {
if (!Object.values(CACHE_NAMES).includes(key)) {
return caches.delete(key);
}
})
)
)
])
);
});
// Intercept fetch events
self.addEventListener('fetch', (event) => {
const request = event.request;
// Handle API requests differently from static resources
if (request.url.includes('/api/')) {
event.respondWith(handleApiRequest(request));
} else {
event.respondWith(handleStaticRequest(request));
}
});
async function handleApiRequest(request) {
try {
// Try to make the request
const response = await fetch(request.clone());
// If successful, pass through WASM handler
if (response.ok) {
return await processWasmResponse(request, response);
}
// If offline or failed, queue the request
await queueRequest(request);
// Return cached response if available
const cachedResponse = await caches.match(request);
if (cachedResponse) {
return cachedResponse;
}
// Return offline response
return new Response(
JSON.stringify({ error: 'Currently offline' }),
{
status: 503,
headers: { 'Content-Type': 'application/json' }
}
);
} catch (error) {
await queueRequest(request);
return new Response(
JSON.stringify({ error: 'Request failed' }),
{
status: 500,
headers: { 'Content-Type': 'application/json' }
}
);
}
}
async function handleStaticRequest(request) {
// Check cache first
const cachedResponse = await caches.match(request);
if (cachedResponse) {
return cachedResponse;
}
try {
const response = await fetch(request);
// Cache successful responses
if (response.ok) {
const cache = await caches.open(CACHE_NAMES.static);
cache.put(request, response.clone());
}
return response;
} catch (error) {
// Return offline page for navigation requests
if (request.mode === 'navigate') {
return caches.match('/offline.html');
}
throw error;
}
}
async function processWasmResponse(request, response) {
// Clone the response before processing
const responseClone = response.clone();
try {
// Process through WASM
const processedResponse = await wasmInstance.processResponse(responseClone);
// Notify client through message channel
if (wasmPort) {
wasmPort.postMessage({
type: 'RESPONSE',
requestId: request.headers.get('X-Wasm-Request-ID'),
response: processedResponse
});
}
return processedResponse;
} catch (error) {
console.error('WASM processing error:', error);
return response;
}
}
async function queueRequest(request) {
const serializedRequest = await serializeRequest(request);
requestQueue.set(request.url, serializedRequest);
// Register for background sync
try {
await self.registration.sync.register('wasm-sync');
} catch (error) {
console.error('Sync registration failed:', error);
}
}
async function serializeRequest(request) {
const headers = {};
for (const [key, value] of request.headers.entries()) {
headers[key] = value;
}
return {
url: request.url,
method: request.method,
headers,
body: await request.text(),
timestamp: Date.now()
};
}
// Handle background sync
self.addEventListener('sync', (event) => {
if (event.tag === 'wasm-sync') {
event.waitUntil(processSyncQueue());
}
});
async function processSyncQueue() {
const requests = Array.from(requestQueue.values());
for (const serializedRequest of requests) {
try {
const response = await fetch(new Request(serializedRequest.url, {
method: serializedRequest.method,
headers: serializedRequest.headers,
body: serializedRequest.body
}));
if (response.ok) {
requestQueue.delete(serializedRequest.url);
// Notify client of successful sync
if (wasmPort) {
wasmPort.postMessage({
type: 'SYNC_COMPLETE',
url: serializedRequest.url
});
}
}
} catch (error) {
console.error('Sync failed for request:', error);
}
}
}
// Handle payment requests
self.addEventListener("canmakepayment", function (e) {
e.respondWith(Promise.resolve(true));
});
// Handle periodic sync if available
self.addEventListener('periodicsync', (event) => {
if (event.tag === 'wasm-sync') {
event.waitUntil(processSyncQueue());
}
});