Documentation ¶
Overview ¶
Package api provides API and client to Cerberus.
Package api is a generated GoMock package.
Index ¶
- Constants
- Variables
- func GetAminoSecp256k1PubKey(k []byte) []byte
- func GetMessageToSign(r *http.Request) ([]byte, error)
- func Sign(r *http.Request, pk crypto.PrivKey) error
- func Verify(r *http.Request) error
- type Cerberus
- type MockCerberus
- func (m *MockCerberus) EXPECT() *MockCerberusMockRecorder
- func (m *MockCerberus) GetPDVMeta(ctx context.Context, owner string, id uint64) (PDVMeta, error)
- func (m *MockCerberus) ListPDV(ctx context.Context, owner string, from uint64, limit uint16) ([]uint64, error)
- func (m *MockCerberus) ReceivePDV(ctx context.Context, owner string, id uint64) (schema.PDV, error)
- func (m *MockCerberus) SavePDV(ctx context.Context, p schema.PDV) (uint64, error)
- type MockCerberusMockRecorder
- func (mr *MockCerberusMockRecorder) GetPDVMeta(ctx, owner, id interface{}) *gomock.Call
- func (mr *MockCerberusMockRecorder) ListPDV(ctx, owner, from, limit interface{}) *gomock.Call
- func (mr *MockCerberusMockRecorder) ReceivePDV(ctx, owner, id interface{}) *gomock.Call
- func (mr *MockCerberusMockRecorder) SavePDV(ctx, p interface{}) *gomock.Call
- type PDVMeta
- type SavePDVResponse
Constants ¶
const PublicKeyHeader = "Public-Key"
PublicKeyHeader is name for public key http header.
const SignatureHeader = "Signature"
SignatureHeader is name for signature http header.
Variables ¶
var ErrInvalidPublicKey = fmt.Errorf("%w: public key is invalid", ErrInvalidRequest)
ErrInvalidPublicKey is returned when public key is invalid.
var ErrInvalidRequest = errors.New("invalid request")
ErrInvalidRequest is returned when request is invalid.
var ErrInvalidSignature = fmt.Errorf("%w: signature is invalid", ErrInvalidRequest)
ErrInvalidSignature is returned when signature is invalid.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when object is not found.
var ErrNotVerified = errors.New("failed to verify message")
ErrNotVerified is returned when signature is wrong.
Functions ¶
func GetAminoSecp256k1PubKey ¶ added in v0.1.0
GetAminoSecp256k1PubKey adds amino secp256k1 pubkey prefix to pubkey(including length-prefix).
func GetMessageToSign ¶ added in v0.2.0
GetMessageToSign returns message to sign.
Types ¶
type Cerberus ¶
type Cerberus interface { SavePDV(ctx context.Context, p schema.PDV) (uint64, error) ListPDV(ctx context.Context, owner string, from uint64, limit uint16) ([]uint64, error) ReceivePDV(ctx context.Context, owner string, id uint64) (schema.PDV, error) GetPDVMeta(ctx context.Context, owner string, id uint64) (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 ¶
NewClientWithHTTPClient returns client with provided http.Client.
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 ¶
func (m *MockCerberus) EXPECT() *MockCerberusMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockCerberus) GetPDVMeta ¶ added in v0.2.4
GetPDVMeta mocks base method
func (*MockCerberus) ListPDV ¶ added in v0.2.4
func (m *MockCerberus) ListPDV(ctx context.Context, owner string, from uint64, limit uint16) ([]uint64, error)
ListPDV mocks base method
func (*MockCerberus) ReceivePDV ¶
ReceivePDV 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, owner, id interface{}) *gomock.Call
GetPDVMeta indicates an expected call of GetPDVMeta
func (*MockCerberusMockRecorder) ListPDV ¶ added in v0.2.4
func (mr *MockCerberusMockRecorder) ListPDV(ctx, owner, from, limit interface{}) *gomock.Call
ListPDV indicates an expected call of ListPDV
func (*MockCerberusMockRecorder) ReceivePDV ¶
func (mr *MockCerberusMockRecorder) ReceivePDV(ctx, owner, id 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 {
ID uint64 `json:"id"`
}
SavePDVResponse ... swagger:model SavePDVResponse