Documentation ¶
Index ¶
- Constants
- Variables
- func InitialiseService(store Store, overwrite bool) error
- func IsInitialised(store Store) (bool, error)
- func NewAuth(log *zap.Logger, cfgStore RSAStore, tokenExpiry time.Duration) (*auth, error)
- func ParseSubmitTransactionRequest(r *http.Request) (*walletpb.SubmitTransactionRequest, commands.Errors)
- type Auth
- type AutomaticConsentPolicy
- type Claims
- type ConsentConfirmation
- type ConsentRequest
- type CreateWalletRequest
- type CreateWalletResponse
- type ErrorResponse
- type ErrorsResponse
- type ExplicitConsentPolicy
- type GenKeyPairRequest
- type ImportWalletRequest
- type KeyKeyResponse
- type KeyResponse
- type KeysResponse
- type ListMethodsV2Response
- type LoginWalletRequest
- type NetworkResponse
- type NodeForward
- type Policy
- type RSAKeys
- type RSAStore
- type SentTransaction
- type Service
- func (s *Service) CheckTx(token string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) CreateWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) GenerateKeyPair(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) GetNetwork(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (s *Service) GetNetworkChainID(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) GetPublicKey(t string, w http.ResponseWriter, _ *http.Request, ps httprouter.Params)
- func (s *Service) HandleRequestV2(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) Health(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) ImportWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) ListMethodsV2(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) ListPublicKeys(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (s *Service) Login(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) Revoke(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (s *Service) SignAny(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) SignTx(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *Service) SignTxCommit(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *Service) SignTxSync(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) TaintKey(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *Service) UpdateMeta(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *Service) VerifyAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) Version(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- type SignAnyRequest
- type SignAnyResponse
- type Store
- type SuccessResponse
- type TaintKeyRequest
- type TokenResponse
- type TraceIDKey
- type UpdateMetaRequest
- type VerifyAnyRequest
- type VerifyAnyResponse
- type VersionResponse
- type WalletHandler
Constants ¶
const ( TxnValidationFailure uint32 = 51 TxnDecodingFailure uint32 = 60 TxnInternalError uint32 = 70 TxnUnknownCommandError uint32 = 80 TxnSpamError uint32 = 89 )
const (
LengthForSessionHashSeed = 10
)
const TXIDLENGTH = 20
Variables ¶
var ( ErrInvalidToken = errors.New("invalid token") ErrInvalidClaims = errors.New("invalid claims") ErrInvalidOrMissingToken = newErrorResponse("invalid or missing token") ErrCouldNotReadRequest = errors.New("couldn't read request") ErrCouldNotGetBlockHeight = errors.New("couldn't get last block height") ErrCouldNotGetChainID = errors.New("couldn't get chain-id") ErrShouldBeBase64Encoded = errors.New("should be base64 encoded") ErrRSAKeysAlreadyExists = errors.New("RSA keys already exist") ErrRejectedSignRequest = errors.New("user rejected sign request") ErrInterruptedConsentRequest = errors.New("process to request consent has been interrupted") )
var ( ErrCouldNotReadRequestBody = errors.New("couldn't read the HTTP request body") ErrRequestCannotBeBlank = errors.New("request can't be blank") )
var ErrSessionNotFound = errors.New("session not found")
Functions ¶
func InitialiseService ¶
func IsInitialised ¶
Types ¶
type Auth ¶
type Auth interface { NewSession(name string) (string, error) VerifyToken(token string) (string, error) Revoke(token string) (string, error) }
Auth ...
type AutomaticConsentPolicy ¶
type AutomaticConsentPolicy struct{}
func (*AutomaticConsentPolicy) Ask ¶
func (p *AutomaticConsentPolicy) Ask(_ *v1.SubmitTransactionRequest, _ string, _ time.Time) (bool, error)
func (*AutomaticConsentPolicy) Report ¶
func (p *AutomaticConsentPolicy) Report(_ SentTransaction)
type ConsentConfirmation ¶
type ConsentRequest ¶
type ConsentRequest struct { TxID string Tx *v1.SubmitTransactionRequest ReceivedAt time.Time Confirmation chan ConsentConfirmation }
type CreateWalletRequest ¶
type CreateWalletRequest struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` }
CreateWalletRequest describes the request for CreateWallet.
func ParseCreateWalletRequest ¶
func ParseCreateWalletRequest(r *http.Request) (*CreateWalletRequest, commands.Errors)
type CreateWalletResponse ¶
type CreateWalletResponse struct { RecoveryPhrase string `json:"recoveryPhrase"` Token string `json:"token"` }
CreateWalletResponse returns the authentication token and the auto-generated recovery phrase of the created wallet.
type ErrorResponse ¶
type ErrorResponse struct { ErrorStr string `json:"error"` Details []string `json:"details,omitempty"` }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type ErrorsResponse ¶
type ExplicitConsentPolicy ¶
type ExplicitConsentPolicy struct {
// contains filtered or unexported fields
}
func (*ExplicitConsentPolicy) Ask ¶
func (p *ExplicitConsentPolicy) Ask(tx *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error)
func (*ExplicitConsentPolicy) Report ¶
func (p *ExplicitConsentPolicy) Report(tx SentTransaction)
type GenKeyPairRequest ¶
type GenKeyPairRequest struct { Passphrase string `json:"passphrase"` Meta []wallet.Metadata `json:"meta"` }
GenKeyPairRequest describes the request for GenerateKeyPair.
func ParseGenKeyPairRequest ¶
func ParseGenKeyPairRequest(r *http.Request) (*GenKeyPairRequest, commands.Errors)
type ImportWalletRequest ¶
type ImportWalletRequest struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` RecoveryPhrase string `json:"recoveryPhrase"` Version uint32 `json:"version"` }
ImportWalletRequest describes the request for ImportWallet.
func ParseImportWalletRequest ¶
func ParseImportWalletRequest(r *http.Request) (*ImportWalletRequest, commands.Errors)
type KeyKeyResponse ¶ added in v0.55.0
type KeyResponse ¶
type KeyResponse struct {
Key KeyKeyResponse `json:"key"`
}
KeyResponse describes the response to a request that returns a single key.
type KeysResponse ¶
type KeysResponse struct {
Keys []KeyKeyResponse `json:"keys"`
}
KeysResponse describes the response to a request that returns a list of keys.
type ListMethodsV2Response ¶
type ListMethodsV2Response struct {
RegisteredMethods []string `json:"registeredMethods"`
}
type LoginWalletRequest ¶
type LoginWalletRequest struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` }
LoginWalletRequest describes the request for CreateWallet, LoginWallet.
func ParseLoginWalletRequest ¶
func ParseLoginWalletRequest(r *http.Request) (*LoginWalletRequest, commands.Errors)
type NetworkResponse ¶
NetworkResponse describes the response to a request that returns app hosts info.
type NodeForward ¶
type NodeForward interface { SendTx(context.Context, *commandspb.Transaction, api.SubmitTransactionRequest_Type, int) (*api.SubmitTransactionResponse, error) CheckTx(context.Context, *commandspb.Transaction, int) (*api.CheckTransactionResponse, error) HealthCheck(context.Context) error LastBlockHeightAndHash(context.Context) (*api.LastBlockHeightResponse, int, error) }
NodeForward ...
type Policy ¶
type Policy interface { Ask(tx *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error) Report(tx SentTransaction) }
func NewAutomaticConsentPolicy ¶
func NewAutomaticConsentPolicy() Policy
func NewExplicitConsentPolicy ¶
func NewExplicitConsentPolicy(ctx context.Context, consentRequests chan ConsentRequest, sentTransactions chan SentTransaction) Policy
type RSAKeys ¶
func GenerateRSAKeys ¶
type SentTransaction ¶
type SentTransaction struct { TxHash string TxID string Tx *commandspb.Transaction Error error SentAt time.Time }
type Service ¶
type Service struct { *httprouter.Router // contains filtered or unexported fields }
func NewService ¶
func (*Service) CheckTx ¶
func (s *Service) CheckTx(token string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) CreateWallet ¶
func (s *Service) CreateWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) GenerateKeyPair ¶
func (s *Service) GenerateKeyPair(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) GetNetwork ¶
func (s *Service) GetNetwork(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Service) GetNetworkChainID ¶
func (s *Service) GetNetworkChainID(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) GetPublicKey ¶
func (s *Service) GetPublicKey(t string, w http.ResponseWriter, _ *http.Request, ps httprouter.Params)
func (*Service) HandleRequestV2 ¶
func (s *Service) HandleRequestV2(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) Health ¶
func (s *Service) Health(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) ImportWallet ¶
func (s *Service) ImportWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) ListMethodsV2 ¶
func (s *Service) ListMethodsV2(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) ListPublicKeys ¶
func (s *Service) ListPublicKeys(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Service) Login ¶
func (s *Service) Login(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) Revoke ¶
func (s *Service) Revoke(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Service) SignAny ¶
func (s *Service) SignAny(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) SignTx ¶
func (s *Service) SignTx(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Service) SignTxCommit ¶
func (s *Service) SignTxCommit(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Service) SignTxSync ¶
func (s *Service) SignTxSync(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Service) TaintKey ¶
func (s *Service) TaintKey(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Service) UpdateMeta ¶
func (s *Service) UpdateMeta(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Service) VerifyAny ¶
func (s *Service) VerifyAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) Version ¶
func (s *Service) Version(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
type SignAnyRequest ¶
type SignAnyRequest struct { // InputData is the payload to generate a signature from. I should be // base 64 encoded. InputData string `json:"inputData"` // PubKey is used to retrieve the private key to sign the InputDate. PubKey string `json:"pubKey"` // contains filtered or unexported fields }
SignAnyRequest describes the request for SignAny.
func ParseSignAnyRequest ¶
func ParseSignAnyRequest(r *http.Request) (*SignAnyRequest, commands.Errors)
type SignAnyResponse ¶
type SignAnyResponse struct { HexSignature string `json:"hexSignature"` Base64Signature string `json:"base64Signature"` }
SignAnyResponse describes the response for SignAny.
type SuccessResponse ¶
type SuccessResponse struct {
Success bool `json:"success"`
}
SuccessResponse describes the response to a request that returns a simple true/false answer.
type TaintKeyRequest ¶
type TaintKeyRequest struct {
Passphrase string `json:"passphrase"`
}
TaintKeyRequest describes the request for TaintKey.
func ParseTaintKeyRequest ¶
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
}
TokenResponse describes the response to a request that returns a token.
type TraceIDKey ¶ added in v0.55.0
type TraceIDKey struct{}
type UpdateMetaRequest ¶
type UpdateMetaRequest struct { Passphrase string `json:"passphrase"` Meta []wallet.Metadata `json:"meta"` }
UpdateMetaRequest describes the request for UpdateMetadata.
func ParseUpdateMetaRequest ¶
type VerifyAnyRequest ¶
type VerifyAnyRequest struct { // InputData is the payload to be verified. It should be base64 encoded. InputData string `json:"inputData"` // Signature is the signature to check against the InputData. It should be // base64 encoded. Signature string `json:"signature"` // PubKey is the public key used along the signature to check the InputData. PubKey string `json:"pubKey"` // contains filtered or unexported fields }
VerifyAnyRequest describes the request for VerifyAny.
func ParseVerifyAnyRequest ¶
func ParseVerifyAnyRequest(r *http.Request) (*VerifyAnyRequest, commands.Errors)
type VerifyAnyResponse ¶
type VerifyAnyResponse struct {
Valid bool `json:"success"`
}
VerifyAnyResponse describes the response for VerifyAny.
type VersionResponse ¶
type VersionResponse struct { Version string `json:"version"` VersionHash string `json:"versionHash"` }
VersionResponse describes the response to a request that returns app version info.
type WalletHandler ¶
type WalletHandler interface { CreateWallet(name, passphrase string) (string, error) ImportWallet(name, passphrase, recoveryPhrase string, version uint32) error LoginWallet(name, passphrase string) error LogoutWallet(name string) SecureGenerateKeyPair(name, passphrase string, meta []wallet.Metadata) (string, error) GetPublicKey(name, pubKey string) (wallet.PublicKey, error) ListPublicKeys(name string) ([]wallet.PublicKey, error) SignTx(name string, req *walletpb.SubmitTransactionRequest, height uint64, chainID string) (*commandspb.Transaction, error) SignAny(name string, inputData []byte, pubKey string) ([]byte, error) VerifyAny(inputData, sig []byte, pubKey string) (bool, error) TaintKey(name, pubKey, passphrase string) error UpdateMeta(name, pubKey, passphrase string, meta []wallet.Metadata) error }
WalletHandler ...