Samuel Hawksby-Robinson 7cd7430d31
Improved Local Pairing Separation of Concerns (#3248)
* Moved all configs into config.go

* Completed build out of new config structures

* Completed SenderClient process flow

* Completed sync data Mounter and client integration

* Completed installation data Mounter and client integration

* House keeping, small refactor to match conventions.

PayloadEncryptor is passed by value and used as a pointer to the instance value and not a shared pointer.

* Reintroduced explicit Mounter field type

* Completed ReceiverClient structs and flows

* Finished BaseClient function parity with old acc

* Integrated new Clients into tests

Solved some test breaks caused by encryptors sharing pointers to their managed payloads

* Built out SenderServer and ReceiverServer structs

With all associated functions and integrated with endpoints.

* Updated tests to handle new Server types

* Added docs and additional refinement

* Renamed some files to better match the content of those files

* Added json tags to config fields that were missing explicit tags.

* fix tests relating to payload locking

* Addressing feedback from @ilmotta

* Addressed feedback from @qfrank
2023-03-23 11:44:15 +00:00

101 lines
2.8 KiB
Go

package pairing
import (
"crypto/ecdsa"
"crypto/tls"
"github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/params"
)
type SenderConfig struct {
// SenderConfig.KeystorePath must end with keyUID
KeystorePath string `json:"keystorePath"`
// DeviceType SendPairInstallation need this information
DeviceType string `json:"deviceType"`
KeyUID string `json:"keyUID"`
Password string `json:"password"`
DB *multiaccounts.Database `json:"-"`
}
type ReceiverConfig struct {
NodeConfig *params.NodeConfig `json:"nodeConfig"`
// ReceiverConfig.KeystorePath must not end with keyUID (because keyUID is not known yet)
KeystorePath string `json:"keystorePath"`
// DeviceType SendPairInstallation need this information
DeviceType string `json:"deviceType"`
KDFIterations int `json:"kdfIterations"`
// SettingCurrentNetwork corresponding to field current_network from table settings, so that we can override current network from sender
SettingCurrentNetwork string `json:"settingCurrentNetwork"`
DB *multiaccounts.Database `json:"-"`
LoggedInKeyUID string `json:"-"`
}
type ServerConfig struct {
// Timeout the number of milliseconds after which the pairing server will automatically terminate
Timeout uint `json:"timeout"`
// Connection fields, not json (un)marshalled
// Required for the server, but MUST NOT come from client
PK *ecdsa.PublicKey `json:"-"`
EK []byte `json:"-"`
Cert *tls.Certificate `json:"-"`
Hostname string `json:"-"`
Mode Mode `json:"-"`
}
type ClientConfig struct{}
type SenderServerConfig struct {
SenderConfig *SenderConfig `json:"senderConfig"`
ServerConfig *ServerConfig `json:"serverConfig"`
}
type SenderClientConfig struct {
SenderConfig *SenderConfig `json:"senderConfig"`
ClientConfig *ClientConfig `json:"clientConfig"`
}
type ReceiverClientConfig struct {
ReceiverConfig *ReceiverConfig `json:"receiverConfig"`
ClientConfig *ClientConfig `json:"clientConfig"`
}
type ReceiverServerConfig struct {
ReceiverConfig *ReceiverConfig `json:"receiverConfig"`
ServerConfig *ServerConfig `json:"serverConfig"`
}
func NewSenderServerConfig() *SenderServerConfig {
return &SenderServerConfig{
SenderConfig: new(SenderConfig),
ServerConfig: new(ServerConfig),
}
}
func NewSenderClientConfig() *SenderClientConfig {
return &SenderClientConfig{
SenderConfig: new(SenderConfig),
ClientConfig: new(ClientConfig),
}
}
func NewReceiverClientConfig() *ReceiverClientConfig {
return &ReceiverClientConfig{
ReceiverConfig: new(ReceiverConfig),
ClientConfig: new(ClientConfig),
}
}
func NewReceiverServerConfig() *ReceiverServerConfig {
return &ReceiverServerConfig{
ReceiverConfig: new(ReceiverConfig),
ServerConfig: new(ServerConfig),
}
}