api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package api provides API and client to Cerberus.

Package api is a generated GoMock package.

Index

Constants

View Source
const PublicKeyHeader = "Public-Key"

PublicKeyHeader is name for public key http header.

View Source
const SignatureHeader = "Signature"

SignatureHeader is name for signature http header.

Variables

View Source
var ErrInvalidPublicKey = fmt.Errorf("%w: public key is invalid", ErrInvalidRequest)

ErrInvalidPublicKey is returned when public key is invalid.

View Source
var ErrInvalidRequest = errors.New("invalid request")

ErrInvalidRequest is returned when request is invalid.

View Source
var ErrInvalidSignature = fmt.Errorf("%w: signature is invalid", ErrInvalidRequest)

ErrInvalidSignature is returned when signature is invalid.

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when object is not found.

View Source
var ErrNotVerified = errors.New("failed to verify message")

ErrNotVerified is returned when signature is wrong.

Functions

func GetAminoSecp256k1PubKey added in v0.1.0

func GetAminoSecp256k1PubKey(k []byte) []byte

GetAminoSecp256k1PubKey adds amino secp256k1 pubkey prefix to pubkey(including length-prefix).

func GetMessageToSign added in v0.2.0

func GetMessageToSign(r *http.Request) ([]byte, error)

GetMessageToSign returns message to sign.

func IsAddressValid

func IsAddressValid(s string) bool

IsAddressValid check is address is matching with regexp.

func Sign

func Sign(r *http.Request, pk crypto.PrivKey) error

Sign signs http request.

func Verify

func Verify(r *http.Request) error

Verify verifies request's signature with public key.

Types

type Cerberus

type Cerberus interface {
	SavePDV(ctx context.Context, p schema.PDV) (string, error)
	ReceivePDV(ctx context.Context, address string) (schema.PDV, error)
	GetPDVMeta(ctx context.Context, address string) (PDVMeta, error)
}

Cerberus provides user-friendly API methods.

func NewClient

func NewClient(host string, pk secp256k1.PrivKeySecp256k1) Cerberus

NewClient returns client with http.DefaultClient.

func NewClientWithHTTPClient

func NewClientWithHTTPClient(host string, pk secp256k1.PrivKeySecp256k1, c *http.Client) Cerberus

NewClientWithHTTPClient returns client with provided http.Client.

type Error

type Error struct {
	Error string `json:"error"`
}

Error ... swagger:model Error

type MockCerberus

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

MockCerberus is a mock of Cerberus interface

func NewMockCerberus

func NewMockCerberus(ctrl *gomock.Controller) *MockCerberus

NewMockCerberus creates a new mock instance

func (*MockCerberus) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockCerberus) GetPDVMeta added in v0.2.4

func (m *MockCerberus) GetPDVMeta(ctx context.Context, address string) (PDVMeta, error)

GetPDVMeta mocks base method

func (*MockCerberus) ReceivePDV

func (m *MockCerberus) ReceivePDV(ctx context.Context, address string) (schema.PDV, error)

ReceivePDV mocks base method

func (*MockCerberus) SavePDV

func (m *MockCerberus) SavePDV(ctx context.Context, p schema.PDV) (string, error)

SavePDV mocks base method

type MockCerberusMockRecorder

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

MockCerberusMockRecorder is the mock recorder for MockCerberus

func (*MockCerberusMockRecorder) GetPDVMeta added in v0.2.4

func (mr *MockCerberusMockRecorder) GetPDVMeta(ctx, address interface{}) *gomock.Call

GetPDVMeta indicates an expected call of GetPDVMeta

func (*MockCerberusMockRecorder) ReceivePDV

func (mr *MockCerberusMockRecorder) ReceivePDV(ctx, address interface{}) *gomock.Call

ReceivePDV indicates an expected call of ReceivePDV

func (*MockCerberusMockRecorder) SavePDV

func (mr *MockCerberusMockRecorder) SavePDV(ctx, p interface{}) *gomock.Call

SavePDV indicates an expected call of SavePDV

type PDVMeta added in v0.2.4

type PDVMeta struct {
	// ObjectTypes represents how much certain pdv data pdv contains.
	ObjectTypes map[schema.PDVType]uint16 `json:"object_types"`
	Reward      uint64                    `json:"reward"`
}

PDVMeta contains info about PDV.

type SavePDVResponse

type SavePDVResponse struct {
	Address string `json:"address"`
}

SavePDVResponse ... swagger:model SavePDVResponse

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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