lib

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const WsTimeout = time.Second * 60

Variables

This section is empty.

Functions

func DecodeBase64RSAKey

func DecodeBase64RSAKey(req *Request, base64PrivateKey string) error

func EncodeBase64RSAKey

func EncodeBase64RSAKey(privateKeyByte []byte) string

func GenTimestamp

func GenTimestamp(req *Request)

func GetClientInitHttpHeaders

func GetClientInitHttpHeaders(req *Request) http.Header

func New

func New(cfg *config.Config, kv util.KVStore) (*signingAgent, error)

func NewFeed

func NewFeed(feedUrl string, agent SigningAgentClient, serveFu ServeCB) *feed

func SignRequest

func SignRequest(req *Request) error

Types

type Agent

type Agent struct {
	Name        string `json:"name"`
	ID          string `json:"id"`
	BLSSeed     []byte `json:"bls_seed"`
	AccountCode string `json:"account_code,omitempty"`
	ZKPID       []byte `json:"zkpid,omitempty"`
	ZKPToken    []byte `json:"zkptoken,omitempty"`
	Pending     bool   `json:"pending"`
}

type ErrHandler

type ErrHandler func(err error)

type Handler

type Handler func(message []byte)

type MockSigningAgentClient

type MockSigningAgentClient struct {
	GetSystemAgentIDCalled     bool
	GetAgentZKPOnePassCalled   bool
	ClientRegisterCalled       bool
	ClientInitCalled           bool
	ClientRegisterFinishCalled bool
	ActionApproveCalled        bool
	GetAgentIDCalled           bool
	GetAgentNameCalled         bool
	ActionRejectCalled         bool
	Counter                    int
	NextError                  error
	NextClientInitError        error
	NextRegisterError          error
	NextRegisterFinishError    error
	NextZKPOnePass             []byte
	NextAgentID                string
	NextAgentName              string
	LastRegisteredName         string
	NextClientRegisterResponse *api.ClientRegisterResponse
	NextRegisterInitResponse   *api.QredoRegisterInitResponse
	NextRegisterFinishResponse *api.ClientRegisterFinishResponse
	LastRegisterRequest        *api.QredoRegisterInitRequest
	LastRegisterFinishRequest  *api.ClientRegisterFinishRequest
	LastRef                    string
	LastApiKey                 string
	Last64PrivateKey           string
	LastActionId               string
	LastRejectActionId         string
	LastAgentID                string
}

func NewMockSigningAgentClient

func NewMockSigningAgentClient(agentId string) *MockSigningAgentClient

func (*MockSigningAgentClient) ActionApprove

func (m *MockSigningAgentClient) ActionApprove(actionID string) error

func (*MockSigningAgentClient) ActionReject

func (m *MockSigningAgentClient) ActionReject(actionID string) error

func (*MockSigningAgentClient) ClientInit

func (m *MockSigningAgentClient) ClientInit(register *api.QredoRegisterInitRequest, ref, apikey, b64PrivateKey string) (*api.QredoRegisterInitResponse, error)

func (*MockSigningAgentClient) ClientRegister

func (m *MockSigningAgentClient) ClientRegister(name string) (*api.ClientRegisterResponse, error)

func (*MockSigningAgentClient) ClientRegisterFinish

func (*MockSigningAgentClient) GetAgentID

func (m *MockSigningAgentClient) GetAgentID() string

func (*MockSigningAgentClient) GetAgentName added in v1.0.1

func (m *MockSigningAgentClient) GetAgentName(agentID string) string

func (*MockSigningAgentClient) GetAgentZKPOnePass

func (m *MockSigningAgentClient) GetAgentZKPOnePass() ([]byte, error)

func (*MockSigningAgentClient) GetSystemAgentID

func (m *MockSigningAgentClient) GetSystemAgentID() string

func (*MockSigningAgentClient) ReadAction

func (m *MockSigningAgentClient) ReadAction(string, ServeCB) *feed

func (*MockSigningAgentClient) SetSystemAgentID

func (m *MockSigningAgentClient) SetSystemAgentID(agetID string) error

type Request

type Request struct {
	Uri       string
	Body      []byte
	ApiKey    string
	Timestamp string
	Signature string
	RsaKey    *rsa.PrivateKey
}

type ServeCB

type ServeCB func(string, Handler, ErrHandler) (chan struct{}, chan struct{}, error)

type SigningAgentClient

type SigningAgentClient interface {
	// ClientInit starts the agent registration process
	ClientInit(register *api.QredoRegisterInitRequest, ref, apikey, b64PrivateKey string) (*api.QredoRegisterInitResponse, error)
	// ClientRegister starts the simplified agent registration procedure
	// by generating BLS and EC key pairs and returns the public keys
	ClientRegister(name string) (*api.ClientRegisterResponse, error)
	// ClientRegisterFinish concludes the agent registration process
	ClientRegisterFinish(req *api.ClientRegisterFinishRequest, ref string) (*api.ClientRegisterFinishResponse, error)
	// GetAgentID returns the agent id if registered
	GetAgentID() string
	// GetAgentName returns the agent name if registered
	GetAgentName(agentID string) string

	// ActionApprove signs actionID and sends it for approval to the Qredo backend
	ActionApprove(actionID string) error
	// ActionReject sends a rejection to the Qredo backend for actionID
	ActionReject(actionID string) error

	// SetSystemAgentID function to collect agent ID to storage, so the system will default to a single agent ID (AgentID)
	SetSystemAgentID(agetID string) error
	// GetSystemAgentID function to get agent ID that was stored during registration process.
	GetSystemAgentID() string
	// GetAgentZKPOnePass function to generate Zero Knowladge Proof one password (for auth header).
	GetAgentZKPOnePass() ([]byte, error)

	// ReadAction connect to qredo web socket stream by given feed url and return Feed object
	ReadAction(string, ServeCB) *feed
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(store util.KVStore) *Storage

func (*Storage) AddAgent

func (s *Storage) AddAgent(id string, c *Agent) error

func (*Storage) AddPending

func (s *Storage) AddPending(ref string, c *Agent) error

func (*Storage) GetAgent

func (s *Storage) GetAgent(id string) *Agent

func (*Storage) GetPending

func (s *Storage) GetPending(ref string) *Agent

func (*Storage) GetSystemAgentID

func (s *Storage) GetSystemAgentID() string

func (*Storage) RemoveAgent

func (s *Storage) RemoveAgent(id string) error

func (*Storage) RemovePending

func (s *Storage) RemovePending(ref string) error

func (*Storage) SetSystemAgentID

func (s *Storage) SetSystemAgentID(agentID string) error

type WsActionInfoEvent

type WsActionInfoEvent struct {
	ID         string `json:"id"`
	AgentID    string `json:"coreClientID"`
	Type       string `json:"type"`
	Status     string `json:"status"`
	Timestamp  int64  `json:"timestamp"`
	ExpireTime int64  `json:"expireTime"`
}

type WsActionInfoHandler

type WsActionInfoHandler func(event *WsActionInfoEvent)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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