server

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSchema

func LoadSchema(_db *sql.DB, path string) error

Types

type AuthConfig added in v1.1.0

type AuthConfig struct {
	AuthType       string
	AuthServerUrl  string
	SupabaseUrl    string
	SupabaseApiKey string
}

type Config

type Config struct {
	DevMode         bool
	Port            int
	DbConnectionUrl string
	ClientOrigin    string
	AuthType        string
	AuthServerUrl   string
	SupabaseUrl     string
	SupabaseApiKey  string
}

type PublicWallet added in v1.2.0

type PublicWallet struct {
	PublicKey tss.PubkeyStr
	BKs       map[string]tss.BK
}

type Server

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

func NewServer

func NewServer(vault Vault, config *Config, wasmBinary []byte, logging bool) *Server

NewServer creates a new server object used in the "cmd" package and in tests

func (*Server) AcceptDeviceHandler added in v1.2.0

func (server *Server) AcceptDeviceHandler(w http.ResponseWriter, r *http.Request)

AcceptDeviceHandler is called by a device already part of the TSS wallet. In collaboration with the server and the new device, a new share is created for the new device

func (*Server) AddRoute added in v1.1.0

func (server *Server) AddRoute(method string, pattern string, h http.HandlerFunc) error

AddRoute adds an endpoint to the server. Note that it will go through authMiddleware for security reasons.

func (*Server) AuthorizeHandler

func (server *Server) AuthorizeHandler(w http.ResponseWriter, r *http.Request)

AuthorizeHandler is responsible for creating an access token allowing for a tss request to be performed It uses identityMiddleware to get the userId from auth provider based on a generic bearer token provided by the client It then creates an access token linked to that userId, stores it in cache and returns it

func (*Server) CustomAuth

func (server *Server) CustomAuth(authServerUrl, token string) (string, error)

CustomAuth gets the userId from a generic CustomAuth auth provider, based on a token representing a session or connexion Calls the generic CustomAuth auth provider using the webhook provided (auth config) with agreed upon API contract

func (*Server) DkgHandler

func (server *Server) DkgHandler(w http.ResponseWriter, r *http.Request)

DkgHandler performs the dkg process from the server side goes through the authMiddleware to confirm the access token and get the userId

func (*Server) ExportHandler added in v1.2.0

func (server *Server) ExportHandler(w http.ResponseWriter, r *http.Request)

ExportHandler exports the private key from the server and client shares goes through the authMiddleware to confirm the access token and get the userId requires the client share (provided in URL parameter)

func (*Server) GetInterHandlersChannels added in v1.2.0

func (server *Server) GetInterHandlersChannels(userId string) (chan string, chan string, chan string, chan string, chan *tss.ServerAdd, chan struct{}, chan struct{}, chan struct{}, error)

Returns channels : metadata, adder, new device done, existing device done

func (*Server) IdentifyHandler

func (server *Server) IdentifyHandler(w http.ResponseWriter, r *http.Request)

IdentifyHandler is responsible for getting a unique identifier of a user from the auth provider It uses identityMiddleware to get the userId from auth provider based on a generic bearer token provided by the client, then returns it

func (*Server) RegisterDeviceHandler added in v1.2.0

func (server *Server) RegisterDeviceHandler(w http.ResponseWriter, r *http.Request)

RegisterDeviceHandler is called by a new device wanting to "join" the wallet by creating a new share for itself, in collaboration with existing peers

func (*Server) Router

func (server *Server) Router() http.Handler

Router returns the router of the server (useful for tests)

func (*Server) RpcHandler

func (server *Server) RpcHandler(w http.ResponseWriter, r *http.Request)

RpcHandler is used for debug operations : it logs every RPC-JSON requests and the return value

func (*Server) ServeWasm

func (server *Server) ServeWasm(w http.ResponseWriter, r *http.Request)

ServeWasm is responsible for serving the wasm module

func (*Server) SignHandler

func (server *Server) SignHandler(w http.ResponseWriter, r *http.Request)

SignHandler performs the signing process from the server side goes through the authMiddleware to confirm the access token and get the userId requires a hex-encoded message to be signed (provided in URL parameter)

func (*Server) Start

func (server *Server) Start()

Start starts the web server on given port

func (*Server) Supabase

func (server *Server) Supabase(supabaseUrl, supabaseApiKey, jwt string) (string, error)

Supabase calls Supabase server to get the userId, based on the Supabase JWT provided

func (*Server) UpdateGetAuthConfig added in v1.1.0

func (server *Server) UpdateGetAuthConfig(getAuthConfig func(context.Context, *Server) (*AuthConfig, error))

UpdateGetAuthConfig changes the auth config getter

func (*Server) Vault added in v1.1.0

func (server *Server) Vault() Vault

Vault returns the vault of the server (useful for tests)

type SupabaseUser

type SupabaseUser struct {
	ID string `json:"id"`
}

type Vault added in v1.1.0

type Vault interface {
	WalletExists(ctx context.Context, foreignKey string) error
	StoreWallet(ctx context.Context, foreignKey string, peerID string, userAgent string, dkgResult *tss.DkgResult) (string, error)
	RetrieveWallet(ctx context.Context, foreignKey string) (*tss.DkgResult, error)
	AddPeer(ctx context.Context, foreignKey string, peerID string, userAgent string, updatedDkgResult *tss.DkgResult) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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