util

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: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AMCLRandomSeedSize = 48
)
View Source
const (
	SecretNotInitialised string = "initialise me"
)

SecretNotInitialised is used to identify an uninitialised AWS secret.

Variables

View Source
var (
	// GetDoMockHTTPClientFunc fetches the mock client's `Do` func
	GetDoMockHTTPClientFunc func(req *http.Request) (*http.Response, error)
)

Functions

func BLSSign

func BLSSign(seed, payload []byte) ([]byte, error)

func BLSVerify

func BLSVerify(seed, msg, sig []byte) error

func CreateAMCLRng

func CreateAMCLRng() (*crypto.Rand, error)

CreateAMCLRng creates a new AMCL RNG with a random seed

func DecodeJSON

func DecodeJSON(r *http.Request, v interface{}) error

DecodeJSON decodes request JSON body returns ServerError on failure

func DecodeRequest

func DecodeRequest(req interface{}, hr *http.Request) error

func NewLogger

func NewLogger(cfg *config.Logging) *zap.SugaredLogger

func NewTestLogger

func NewTestLogger() *zap.SugaredLogger

func RandomBytes

func RandomBytes(size int) ([]byte, error)

func URLActionApprove

func URLActionApprove(baseURL, actionID string) string

func URLActionMessages

func URLActionMessages(baseURL, actionID string) string

func URLActionReject

func URLActionReject(baseURL, actionID string) string

func URLClientInit

func URLClientInit(baseURL string) string

func URLRegisterConfirm

func URLRegisterConfirm(baseURL string) string

func ZKPOnePass

func ZKPOnePass(zkpID, zkpToken []byte, pin int) ([]byte, error)

Types

type AWSStore

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

func (*AWSStore) Del

func (s *AWSStore) Del(key string) error

Del deletes the named key.

func (*AWSStore) Get

func (s *AWSStore) Get(key string) ([]byte, error)

Get returns the value of the named key, or error if not found.

func (*AWSStore) Init

func (s *AWSStore) Init() error

Init sets up the AWS session and checks the connection by reading the secret.

func (*AWSStore) Set

func (s *AWSStore) Set(key string, data []byte) error

Set adds/updates the named key with value in data.

type Client

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

func NewHTTPClient

func NewHTTPClient() *Client

func NewHTTPMockClient

func NewHTTPMockClient() *Client

func (*Client) Request

func (c *Client) Request(method string, url string, reqData interface{}, respData interface{}, headers http.Header) error

func (*Client) RequestNoLog

func (c *Client) RequestNoLog(method string, url string, reqData interface{}, respData interface{}, headers http.Header) error

type FileStore

type FileStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*FileStore) Del

func (s *FileStore) Del(key string) error

func (*FileStore) Get

func (s *FileStore) Get(key string) ([]byte, error)

func (*FileStore) Init

func (s *FileStore) Init() error

func (*FileStore) Set

func (s *FileStore) Set(key string, data []byte) error

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient interface

type KVStore

type KVStore interface {
	// Get returns the data for given key. If key is not found, return nil, defs.KVErrNotFound
	Get(key string) ([]byte, error)
	Set(key string, data []byte) error
	Del(key string) error
	Init() error
}

KVStore is an interface to a simple key-value store used by the core lib

func CreateStore

func CreateStore(cfg *config.Config) KVStore

func NewAWSStore

func NewAWSStore(cfg config.AWSConfig) KVStore

NewAWSStore creates and return the AWS KVStore.

func NewFileStore

func NewFileStore(fileName string) KVStore

func NewOciStore

func NewOciStore(cfg config.OciConfig) KVStore

type MockHTTPClient

type MockHTTPClient struct {
	DoFunc func(req *http.Request) (*http.Response, error)
}

func (*MockHTTPClient) Do

func (mc *MockHTTPClient) Do(req *http.Request) (*http.Response, error)

Do is the mock client's `Do` func

type OciStore

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

func (*OciStore) Del

func (s *OciStore) Del(key string) error

func (*OciStore) Get

func (s *OciStore) Get(key string) ([]byte, error)

func (*OciStore) Init

func (s *OciStore) Init() error

func (*OciStore) Set

func (s *OciStore) Set(key string, data []byte) error

Jump to

Keyboard shortcuts

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