gateway

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodAuthn      jsonrpc.Method = "kgw.authn"
	MethodAuthnParam jsonrpc.Method = "kgw.authn_param"
)

Variables

This section is empty.

Functions

func DefaultClientOptions added in v0.2.0

func DefaultClientOptions() *clientOptions

DefaultClientOptions returns the default client options, which ensure the connection has a cookie jar.

Types

type AuthnParameterRequest added in v0.2.0

type AuthnParameterRequest struct{}

type AuthnParameterResponse added in v0.2.0

type AuthnParameterResponse struct {
	Nonce          string `json:"nonce"`
	Statement      string `json:"statement"` // optional
	IssueAt        string `json:"issue_at"`
	ExpirationTime string `json:"expiration_time"`
	// client can use those to precheck before signing
	ChainID string `json:"chain_id"` // the chain id of the gateway
	Domain  string `json:"domain"`   // the domain of the gateway
	Version string `json:"version"`  // the authn version used by the gateway
	URI     string `json:"uri"`      // the endpoint used for authn
}

AuthnParameterResponse defines the result when request for gateway(KGW) authentication. It's the parameters that will be used to compose the message(SIWE like) to sign.

type AuthnRequest added in v0.2.0

type AuthnRequest struct {
	Nonce     string          `json:"nonce"`  // identifier for authn session
	Sender    types.HexBytes  `json:"sender"` // sender public key
	Signature *auth.Signature `json:"signature"`
}

AuthnRequest is a request for authentication from the kgw.

type AuthnResponse added in v0.2.0

type AuthnResponse struct{}

type Client added in v0.2.0

type Client interface {
	// Authn sends an authentication request to the gateway.
	// It will set a cookie in the client if successful.
	Authn(ctx context.Context, req *AuthnRequest) error

	// GetAuthnParameter returns the parameters that will be used to compose the
	// authentication message that will be signed by the client.
	GetAuthnParameter(ctx context.Context) (*AuthnParameterResponse, error)
}

Client is the interface for the Kwil gateway client.

type ClientOption added in v0.2.0

type ClientOption func(*clientOptions)

func WithHTTPClient added in v0.2.0

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient sets the http client for the client. This allows custom http clients to be used.

func WithJSONRPCClient added in v0.2.0

func WithJSONRPCClient(userClient *rpcclient.JSONRPCClient) ClientOption

WithJSONRPCClient sets the jsonrpc client for the client. This allows custom user clients to be used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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