controller

package
v0.6.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidToken is returned when the token is invalid
	ErrInvalidToken = fmt.Errorf("invalid token")
)
View Source
var PrimaryAccountaddress string = "primary"

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// Address returns the controller's address
	Address() string

	// Get the controller's DID
	Did() string

	// PrimaryIdentity returns the controller's DID document
	PrimaryIdentity() *types.DidDocument

	// PrimaryTxHash returns the controller's primary identity transaction hash
	PrimaryTxHash() string

	// BlockchainIdentities returns the controller's blockchain identities
	BlockchainIdentities() []*types.DidDocument

	// Createmodels.Account creates a new models.Account for the controller
	CreateAccount(name string, coinType crypto.CoinType) (models.Account, error)

	// GetAccount returns an account by Address or DID
	GetAccount(id string) (models.Account, error)

	// Listmodels.Accounts returns the controller's models.Accounts
	ListAccounts() ([]models.Account, error)

	// SendMail sends a message between two Controllers
	SendMail(address string, to string, body string) error

	// ReadMail reads the controller's inbox
	ReadMail(address string) ([]*models.InboxMessage, error)

	// Sign signs a message with the controller's models.Account
	Sign(address string, msg []byte) ([]byte, error)

	// Verify verifies a signature with the controller's models.Account
	Verify(address string, msg []byte, sig []byte) (bool, error)
}

func LoadController

func LoadController(doc *types.DidDocument) (Controller, error)

func NewController

func NewController(options ...Option) (Controller, error)

type Option

type Option func(*Options)

func WithBroadcastTx added in v0.6.9

func WithBroadcastTx() Option

func WithConfigHandlers

func WithConfigHandlers(handlers ...mpc.OnConfigGenerated) Option

func WithIPFSDisabled

func WithIPFSDisabled() Option

func WithUsername added in v0.6.9

func WithUsername(username string) Option

func WithWebauthnCredential

func WithWebauthnCredential(cred *crypto.WebauthnCredential) Option

type Options

type Options struct {
	// The controller's on config generated handler
	OnConfigGenerated []mpc.OnConfigGenerated

	// Credential to authorize the controller
	WebauthnCredential *crypto.WebauthnCredential

	// Disable IPFS
	DisableIPFS bool

	// Broadcast the transaction
	BroadcastTx bool

	// Username for the controller
	Username string
}

type User added in v0.6.11

type User struct {
	// DID of the user
	Did string `json:"_id"`

	// DID document of the primary identity
	Username string `json:"username"`
	// contains filtered or unexported fields
}

func LoadUser added in v0.6.11

func LoadUser(token *jwt.Token) (*User, error)

func NewUser added in v0.6.11

func NewUser(c Controller, username string) *User

func (*User) JWT added in v0.6.14

func (u *User) JWT() (string, error)

func (*User) JWTClaims added in v0.6.14

func (u *User) JWTClaims() jwt.MapClaims

func (*User) ListAccounts added in v0.6.14

func (u *User) ListAccounts() ([]*v1.Account, error)

func (*User) PrimaryIdentity added in v0.6.11

func (u *User) PrimaryIdentity() (*types.DidDocument, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL