v2

package
v0.73.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: AGPL-3.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const VWTPrefix = "VWT"

VWTPrefix is the scheme that prefixes the token in the Authorization HTTP header It is our non-standard scheme that stands for Vega Wallet Token.

Variables

View Source
var (
	ErrAdminEndpointsNotExposed                 = errors.New("administrative endpoints are not exposed, for security reasons")
	ErrAuthorizationHeaderIsRequired            = errors.New("the Authorization header is required")
	ErrAuthorizationHeaderOnlySupportsVWTScheme = errors.New("the Authorization header only support the VWT scheme")
	ErrAuthorizationTokenIsNotValidVWT          = errors.New("the Authorization value is not a valid VWT")
	ErrCouldNotReadRequestBody                  = errors.New("couldn't read the HTTP request body")
	ErrOriginHeaderIsRequired                   = errors.New("the Origin header is required")
	ErrRequestCannotBeBlank                     = errors.New("the request can't be blank")
)

Functions

This section is empty.

Types

type API

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

func NewAPI

func NewAPI(log *zap.Logger, clientAPI ClientAPI, connectionsManager *connections.Manager) *API

NewAPI builds the wallet JSON-RPC API with specific methods that are intended to be publicly exposed to third-party applications in a non-trustable environment. Because of the nature of the environment from where these methods are called, (the "wild, wild web"), no administration methods are exposed. We don't want malicious third-party applications to leverage administration capabilities that could expose the user and/or compromise his wallets.

func (*API) CheckHealth

func (a *API) CheckHealth(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (*API) HandleRequest

func (a *API) HandleRequest(w http.ResponseWriter, httpRequest *http.Request, _ httprouter.Params)

func (*API) ListMethods

func (a *API) ListMethods(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

type ClientAPI

type ClientAPI interface {
	ConnectWallet(ctx context.Context, hostname string) (wallet.Wallet, *jsonrpc.ErrorDetails)
	GetChainID(ctx context.Context) (jsonrpc.Result, *jsonrpc.ErrorDetails)
	ListKeys(ctx context.Context, connectedWallet api.ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)
	CheckTransaction(ctx context.Context, params jsonrpc.Params, connectedWallet api.ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)
	SignTransaction(ctx context.Context, rawParams jsonrpc.Params, connectedWallet api.ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)
	SendTransaction(ctx context.Context, rawParams jsonrpc.Params, connectedWallet api.ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)
}

type Command

type Command func(ctx context.Context, lw *responseWriter, httpRequest *http.Request, rpcRequest jsonrpc.Request) (jsonrpc.Result, *jsonrpc.ErrorDetails)

type ErrorDetails

type ErrorDetails struct {
	// Message provides a short description of the error.
	// The message SHOULD be limited to a concise single sentence.
	Message string `json:"message"`

	// Data is a primitive or a structured value that contains additional
	// information about the error. This may be omitted.
	// The value of this member is defined by the Server (e.g. detailed error
	// information, nested errors etc.).
	Data string `json:"data,omitempty"`
}

ErrorDetails is returned when an HTTP call encounters an error.

type ListMethodsResponse

type ListMethodsResponse struct {
	RegisteredMethods []string `json:"registeredMethods"`
}

type Response

type Response struct {
	// Result is REQUIRED on success. This member MUST NOT exist if there was an
	// error invoking the method.
	Result Result `json:"result,omitempty"`

	// Error is REQUIRED on error. This member MUST NOT exist if there was no
	// error triggered during invocation.
	Error *ErrorDetails `json:"error,omitempty"`
}

type Result

type Result interface{}

Result is just a nicer way to describe what's expected to be returned by the handlers.

type StdTime

type StdTime struct{}

func NewStdTime

func NewStdTime() *StdTime

func (*StdTime) Now

func (t *StdTime) Now() time.Time

type VWT

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

VWT stands for Vega Wallet Token. It has the following format:

VWT <TOKEN>

Example:

VWT QK6QoNLA2XEZdLFLxkFlq2oTX8cp8Xw1GOzxDAM0aSXxQAR33CGkvDh4vh2ZyQSh

func AsVWT

func AsVWT(token connections.Token) VWT

func ExtractVWT

func ExtractVWT(r *http.Request) (VWT, error)

ExtractVWT extracts the Vega Wallet Token from the `Authorization` header.

func ParseVWT

func ParseVWT(rawVWT string) (VWT, error)

ParseVWT parses a VWT into a VWT. If malformed, an error is returned.

func (VWT) String

func (t VWT) String() string

func (VWT) Token

func (t VWT) Token() connections.Token

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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