api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT, Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIEndpoint

type APIEndpoint multiaddr.Multiaddr

rpc api endpoint

type CommonAuth

type CommonAuth struct {
	Internal struct {
		AuthVerify  func(ctx context.Context, token string) ([]permission.Permission, error) `perm:"read"`
		AuthNew     func(ctx context.Context, perms []permission.Permission) ([]byte, error) `perm:"admin"`
		Version     func(context.Context) (common.Version, error)                            `perm:"read"`
		LogList     func(context.Context) ([]string, error)                                  `perm:"write"`
		LogSetLevel func(context.Context, string, string) error                              `perm:"write"`
	}
}

common API permissions constraints

func (*CommonAuth) AuthNew

func (c *CommonAuth) AuthNew(ctx context.Context, perms []permission.Permission) ([]byte, error)

func (*CommonAuth) AuthVerify

func (c *CommonAuth) AuthVerify(ctx context.Context, token string) ([]permission.Permission, error)

func (*CommonAuth) LogList

func (c *CommonAuth) LogList(ctx context.Context) ([]string, error)

func (*CommonAuth) LogSetLevel

func (c *CommonAuth) LogSetLevel(ctx context.Context, group, level string) error

func (*CommonAuth) Version

func (c *CommonAuth) Version(ctx context.Context) (common.Version, error)

Version implements API.Version

type IFullAPI

func PermissionedFullAPI

func PermissionedFullAPI(a IFullAPI) IFullAPI

type ServiceAuth

type ServiceAuth struct {
	CommonAuth
	WalletAuth
	WalletLockAuth
	StrategyAuth
}

full service API permissions constraints

type StrategyAuth

type StrategyAuth struct {
	Internal struct {
		NewMsgTypeTemplate     func(ctx context.Context, name string, codes []int) error                                     `perm:"admin" local:"required"`
		NewMethodTemplate      func(ctx context.Context, name string, methods []string) error                                `perm:"admin" local:"required"`
		NewKeyBindCustom       func(ctx context.Context, name, address string, codes []int, methods []core.MethodName) error `perm:"admin" local:"required"`
		NewKeyBindFromTemplate func(ctx context.Context, name, address, mttName, mtName string) error                        `perm:"admin" local:"required"`
		NewGroup               func(ctx context.Context, name string, keyBindNames []string) error                           `perm:"admin" local:"required"`
		NewWalletToken         func(ctx context.Context, groupName string) (token string, err error)                         `perm:"admin" local:"required"`

		GetMsgTypeTemplate      func(ctx context.Context, name string) (*storage.MsgTypeTemplate, error) `perm:"admin" local:"required"`
		GetMethodTemplateByName func(ctx context.Context, name string) (*storage.MethodTemplate, error)  `perm:"admin" local:"required"`
		GetKeyBindByName        func(ctx context.Context, name string) (*storage.KeyBind, error)         `perm:"admin" local:"required"`
		GetKeyBinds             func(ctx context.Context, address string) ([]*storage.KeyBind, error)    `perm:"admin" local:"required"`
		GetGroupByName          func(ctx context.Context, name string) (*storage.Group, error)           `perm:"admin" local:"required"`
		GetWalletTokensByGroup  func(ctx context.Context, groupName string) ([]string, error)            `perm:"admin" local:"required"`
		GetWalletTokenInfo      func(ctx context.Context, token string) (*storage.GroupAuth, error)      `perm:"admin" local:"required"`

		ListGroups           func(ctx context.Context, fromIndex, toIndex int) ([]*storage.Group, error)           `perm:"admin" local:"required"`
		ListKeyBinds         func(ctx context.Context, fromIndex, toIndex int) ([]*storage.KeyBind, error)         `perm:"admin" local:"required"`
		ListMethodTemplates  func(ctx context.Context, fromIndex, toIndex int) ([]*storage.MethodTemplate, error)  `perm:"admin" local:"required"`
		ListMsgTypeTemplates func(ctx context.Context, fromIndex, toIndex int) ([]*storage.MsgTypeTemplate, error) `perm:"admin" local:"required"`

		PushMsgTypeIntoKeyBind func(ctx context.Context, name string, codes []int) (*storage.KeyBind, error)      `perm:"admin" local:"required"`
		PushMethodIntoKeyBind  func(ctx context.Context, name string, methods []string) (*storage.KeyBind, error) `perm:"admin" local:"required"`
		PullMsgTypeFromKeyBind func(ctx context.Context, name string, codes []int) (*storage.KeyBind, error)      `perm:"admin" local:"required"`
		PullMethodFromKeyBind  func(ctx context.Context, name string, methods []string) (*storage.KeyBind, error) `perm:"admin" local:"required"`

		RemoveToken            func(ctx context.Context, token string) error                                                  `perm:"admin" local:"required"`
		RemoveKeyBind          func(ctx context.Context, name string) error                                                   `perm:"admin" local:"required"`
		RemoveKeyBindByAddress func(ctx context.Context, address string) (int64, error)                                       `perm:"admin" local:"required"`
		RemoveGroup            func(ctx context.Context, name string) error                                                   `perm:"admin" local:"required"`
		RemoveMethodTemplate   func(ctx context.Context, name string) error                                                   `perm:"admin" local:"required"`
		RemoveMsgTypeTemplate  func(ctx context.Context, name string) error                                                   `perm:"admin" local:"required"`
		ScopeWallet            func(ctx context.Context) (*core.AddressScope, error)                                          `perm:"admin" local:"required"`
		ContainWallet          func(ctx context.Context, address core.Address) bool                                           `perm:"admin" local:"required"`
		Verify                 func(ctx context.Context, address core.Address, msgType core.MsgType, msg *core.Message) error `perm:"admin" local:"required"`
	}
}

func (*StrategyAuth) ContainWallet

func (o *StrategyAuth) ContainWallet(ctx context.Context, address core.Address) bool

func (*StrategyAuth) GetGroupByName

func (o *StrategyAuth) GetGroupByName(ctx context.Context, name string) (*storage.Group, error)

func (*StrategyAuth) GetKeyBindByName

func (o *StrategyAuth) GetKeyBindByName(ctx context.Context, name string) (*storage.KeyBind, error)

func (*StrategyAuth) GetKeyBinds

func (o *StrategyAuth) GetKeyBinds(ctx context.Context, address string) ([]*storage.KeyBind, error)

func (*StrategyAuth) GetMethodTemplateByName

func (o *StrategyAuth) GetMethodTemplateByName(ctx context.Context, name string) (*storage.MethodTemplate, error)

func (*StrategyAuth) GetMsgTypeTemplate

func (o *StrategyAuth) GetMsgTypeTemplate(ctx context.Context, name string) (*storage.MsgTypeTemplate, error)

func (*StrategyAuth) GetWalletTokenInfo

func (o *StrategyAuth) GetWalletTokenInfo(ctx context.Context, token string) (*storage.GroupAuth, error)

func (*StrategyAuth) GetWalletTokensByGroup

func (o *StrategyAuth) GetWalletTokensByGroup(ctx context.Context, groupName string) ([]string, error)

func (*StrategyAuth) ListGroups

func (o *StrategyAuth) ListGroups(ctx context.Context, fromIndex, toIndex int) ([]*storage.Group, error)

func (*StrategyAuth) ListKeyBinds

func (o *StrategyAuth) ListKeyBinds(ctx context.Context, fromIndex, toIndex int) ([]*storage.KeyBind, error)

func (*StrategyAuth) ListMethodTemplates

func (o *StrategyAuth) ListMethodTemplates(ctx context.Context, fromIndex, toIndex int) ([]*storage.MethodTemplate, error)

func (*StrategyAuth) ListMsgTypeTemplates

func (o *StrategyAuth) ListMsgTypeTemplates(ctx context.Context, fromIndex, toIndex int) ([]*storage.MsgTypeTemplate, error)

func (*StrategyAuth) NewGroup

func (o *StrategyAuth) NewGroup(ctx context.Context, name string, keyBindNames []string) error

func (*StrategyAuth) NewKeyBindCustom

func (o *StrategyAuth) NewKeyBindCustom(ctx context.Context, name, address string, codes []int, methods []core.MethodName) error

func (*StrategyAuth) NewKeyBindFromTemplate

func (o *StrategyAuth) NewKeyBindFromTemplate(ctx context.Context, name, address, mttName, mtName string) error

func (*StrategyAuth) NewMethodTemplate

func (o *StrategyAuth) NewMethodTemplate(ctx context.Context, name string, methods []string) error

func (*StrategyAuth) NewMsgTypeTemplate

func (o *StrategyAuth) NewMsgTypeTemplate(ctx context.Context, name string, codes []int) error

func (*StrategyAuth) NewWalletToken

func (o *StrategyAuth) NewWalletToken(ctx context.Context, groupName string) (token string, err error)

func (*StrategyAuth) PullMethodFromKeyBind

func (o *StrategyAuth) PullMethodFromKeyBind(ctx context.Context, name string, methods []string) (*storage.KeyBind, error)

func (*StrategyAuth) PullMsgTypeFromKeyBind

func (o *StrategyAuth) PullMsgTypeFromKeyBind(ctx context.Context, name string, codes []int) (*storage.KeyBind, error)

func (*StrategyAuth) PushMethodIntoKeyBind

func (o *StrategyAuth) PushMethodIntoKeyBind(ctx context.Context, name string, methods []string) (*storage.KeyBind, error)

func (*StrategyAuth) PushMsgTypeIntoKeyBind

func (o *StrategyAuth) PushMsgTypeIntoKeyBind(ctx context.Context, name string, codes []int) (*storage.KeyBind, error)

func (*StrategyAuth) RemoveGroup

func (o *StrategyAuth) RemoveGroup(ctx context.Context, name string) error

func (*StrategyAuth) RemoveKeyBind

func (o *StrategyAuth) RemoveKeyBind(ctx context.Context, name string) error

func (*StrategyAuth) RemoveKeyBindByAddress

func (o *StrategyAuth) RemoveKeyBindByAddress(ctx context.Context, address string) (int64, error)

func (*StrategyAuth) RemoveMethodTemplate

func (o *StrategyAuth) RemoveMethodTemplate(ctx context.Context, name string) error

func (*StrategyAuth) RemoveMsgTypeTemplate

func (o *StrategyAuth) RemoveMsgTypeTemplate(ctx context.Context, name string) error

func (*StrategyAuth) RemoveToken

func (o *StrategyAuth) RemoveToken(ctx context.Context, token string) error

func (*StrategyAuth) ScopeWallet

func (o *StrategyAuth) ScopeWallet(ctx context.Context) (*core.AddressScope, error)

func (*StrategyAuth) Verify

func (o *StrategyAuth) Verify(ctx context.Context, address core.Address, msgType core.MsgType, msg *core.Message) error

type WalletAuth

type WalletAuth struct {
	Internal struct {
		WalletNew    func(ctx context.Context, kt core.KeyType) (core.Address, error)                                          `perm:"admin"`
		WalletHas    func(ctx context.Context, address core.Address) (bool, error)                                             `perm:"write"`
		WalletList   func(ctx context.Context) ([]core.Address, error)                                                         `perm:"write"`
		WalletSign   func(ctx context.Context, signer core.Address, toSign []byte, meta core.MsgMeta) (*core.Signature, error) `perm:"sign"`
		WalletExport func(ctx context.Context, addr core.Address) (*core.KeyInfo, error)                                       `perm:"admin"`
		WalletImport func(ctx context.Context, ki *core.KeyInfo) (core.Address, error)                                         `perm:"admin"`
		WalletDelete func(ctx context.Context, addr core.Address) error                                                        `perm:"admin"`
	}
}

wallet API permissions constraints

func (*WalletAuth) WalletDelete

func (c *WalletAuth) WalletDelete(ctx context.Context, addr core.Address) error

func (*WalletAuth) WalletExport

func (c *WalletAuth) WalletExport(ctx context.Context, a core.Address) (*core.KeyInfo, error)

func (*WalletAuth) WalletHas

func (c *WalletAuth) WalletHas(ctx context.Context, addr core.Address) (bool, error)

func (*WalletAuth) WalletImport

func (c *WalletAuth) WalletImport(ctx context.Context, ki *core.KeyInfo) (core.Address, error)

func (*WalletAuth) WalletList

func (c *WalletAuth) WalletList(ctx context.Context) ([]core.Address, error)

func (*WalletAuth) WalletNew

func (c *WalletAuth) WalletNew(ctx context.Context, keyType core.KeyType) (core.Address, error)

func (*WalletAuth) WalletSign

func (c *WalletAuth) WalletSign(ctx context.Context, signer core.Address, toSign []byte, meta core.MsgMeta) (*core.Signature, error)

type WalletLockAuth

type WalletLockAuth struct {
	Internal struct {
		SetPassword func(ctx context.Context, password string) error `perm:"admin" local:"required"`
		Unlock      func(ctx context.Context, password string) error `perm:"admin" local:"required"`
		Lock        func(ctx context.Context, password string) error `perm:"admin" local:"required"`
		LockState   func(ctx context.Context) bool                   `perm:"admin"`
	}
}

func (*WalletLockAuth) Lock

func (c *WalletLockAuth) Lock(ctx context.Context, password string) error

func (*WalletLockAuth) LockState

func (c *WalletLockAuth) LockState(ctx context.Context) bool

func (*WalletLockAuth) SetPassword

func (c *WalletLockAuth) SetPassword(ctx context.Context, password string) error

func (*WalletLockAuth) Unlock

func (c *WalletLockAuth) Unlock(ctx context.Context, password string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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