Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
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 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 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 ¶
ExtractVWT extracts the Vega Wallet Token from the `Authorization` header.
func (VWT) Token ¶
func (t VWT) Token() connections.Token