ud

package
v5.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: BSD-2-Clause, BSD-2-Clause Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const LookupTag = "xxNetwork_UdLookup"

LookupTag specifies which callback to trigger when UD receives a lookup request.

View Source
const SearchTag = "xxNetwork_UdSearch"

SearchTag specifies which callback to trigger when UD receives a search request.

Variables

View Source
var ErrChannelLeaseSignature = errors.New("failure to validate lease signature")
View Source
var File_udMessages_proto protoreflect.FileDescriptor

Functions

func InitStoreFromBackup

func InitStoreFromBackup(kv *versioned.KV,
	username, email, phone fact.Fact) error

InitStoreFromBackup initializes the UD storage from the backup subsystem.

func IsRegistered

func IsRegistered(kv *versioned.KV) bool

IsRegistered loads from storage if the user is registered with user discovery.

func Lookup

func Lookup(user udE2e,
	udContact contact.Contact, callback lookupCallback,
	uid *id.ID, p single.RequestParams) ([]id.Round,
	receptionID.EphemeralIdentity, error)

Lookup returns the public key of the passed ID as known by the user discovery system or returns by the timeout.

func Search(user udE2e,
	udContact contact.Contact, callback searchCallback,
	list fact.FactList,
	params single.RequestParams) ([]id.Round,
	receptionID.EphemeralIdentity, error)

Search searches for the passed Facts. The searchCallback will return a list of contacts, each having the facts it hit against. This is NOT intended to be used to search for multiple users at once; that can have a privacy reduction. Instead, it is intended to be used to search for a user where multiple pieces of information is known.

func UnmarshallRegistrationDisk

func UnmarshallRegistrationDisk(data []byte) (registrationDisk, error)

UnmarshallRegistrationDisk unmarshalls a registrationDisk

Types

type Comms

type Comms interface {
	// SendRegisterUser is the gRPC send function for the user registering
	// their username with the UD service.
	SendRegisterUser(host *connect.Host, message *pb.UDBUserRegistration) (*messages.Ack, error)
	// SendRegisterFact is the gRPC send function for the user registering
	// a fact.Fact (email/phone number) with the UD service.
	SendRegisterFact(host *connect.Host, message *pb.FactRegisterRequest) (*pb.FactRegisterResponse, error)
	// SendConfirmFact is the gRPC send function for the user confirming
	// their fact.Fact has been registered successfully with the UD service.
	SendConfirmFact(host *connect.Host, message *pb.FactConfirmRequest) (*messages.Ack, error)
	// SendRemoveFact is the gRPC send function for the user removing
	// a registered fact.Fact from the UD service. This fact.Fact must be
	// owned by the user.
	SendRemoveFact(host *connect.Host, message *pb.FactRemovalRequest) (*messages.Ack, error)
	// SendRemoveUser is the gRPC send function for the user removing
	// their username from the UD service.
	SendRemoveUser(host *connect.Host, message *pb.FactRemovalRequest) (*messages.Ack, error)
	// AddHost is a function which adds a connect.Host object to the internal
	// comms manager. This will be used here exclusively for adding
	// the UD service if it does not currently exist within the internal
	// manger.
	AddHost(hid *id.ID, address string,
		cert []byte, params connect.HostParams) (host *connect.Host, err error)
	// GetHost retrieves a connect.Host object from the internal comms manager.
	// This will be used exclusively to retrieve the UD service's connect.Host
	// object. This will be used to send to the UD service on the above
	// gRPC send functions.
	GetHost(hostId *id.ID) (*connect.Host, bool)
	// contains filtered or unexported methods
}

Comms is a sub-interface of the client.Comms interface. This contains RPCs and methods relevant to sending to the UD service.

type Contact

type Contact struct {
	UserID    []byte      `protobuf:"bytes,1,opt,name=userID,proto3" json:"userID,omitempty"`
	PubKey    []byte      `protobuf:"bytes,2,opt,name=pubKey,proto3" json:"pubKey,omitempty"`
	Username  string      `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"`
	TrigFacts []*HashFact `protobuf:"bytes,4,rep,name=trigFacts,proto3" json:"trigFacts,omitempty"`
	// contains filtered or unexported fields
}

Describes a user lookup result. The ID, public key, and the facts inputted that brought up this user.

func (*Contact) Descriptor deprecated

func (*Contact) Descriptor() ([]byte, []int)

Deprecated: Use Contact.ProtoReflect.Descriptor instead.

func (*Contact) GetPubKey

func (x *Contact) GetPubKey() []byte

func (*Contact) GetTrigFacts

func (x *Contact) GetTrigFacts() []*HashFact

func (*Contact) GetUserID

func (x *Contact) GetUserID() []byte

func (*Contact) GetUsername

func (x *Contact) GetUsername() string

func (*Contact) ProtoMessage

func (*Contact) ProtoMessage()

func (*Contact) ProtoReflect

func (x *Contact) ProtoReflect() protoreflect.Message

func (*Contact) Reset

func (x *Contact) Reset()

func (*Contact) String

func (x *Contact) String() string

type HashFact

type HashFact struct {
	Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
	Type int32  `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"`
	// contains filtered or unexported fields
}

Contains the Hash and its Type

func (*HashFact) Descriptor deprecated

func (*HashFact) Descriptor() ([]byte, []int)

Deprecated: Use HashFact.ProtoReflect.Descriptor instead.

func (*HashFact) GetHash

func (x *HashFact) GetHash() []byte

func (*HashFact) GetType

func (x *HashFact) GetType() int32

func (*HashFact) ProtoMessage

func (*HashFact) ProtoMessage()

func (*HashFact) ProtoReflect

func (x *HashFact) ProtoReflect() protoreflect.Message

func (*HashFact) Reset

func (x *HashFact) Reset()

func (*HashFact) String

func (x *HashFact) String() string

type LookupResponse

type LookupResponse struct {
	PubKey   []byte `protobuf:"bytes,1,opt,name=pubKey,proto3" json:"pubKey,omitempty"`
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	Error    string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

Message sent from UDB for looking up a user

func (*LookupResponse) Descriptor deprecated

func (*LookupResponse) Descriptor() ([]byte, []int)

Deprecated: Use LookupResponse.ProtoReflect.Descriptor instead.

func (*LookupResponse) GetError

func (x *LookupResponse) GetError() string

func (*LookupResponse) GetPubKey

func (x *LookupResponse) GetPubKey() []byte

func (*LookupResponse) GetUsername

func (x *LookupResponse) GetUsername() string

func (*LookupResponse) ProtoMessage

func (*LookupResponse) ProtoMessage()

func (*LookupResponse) ProtoReflect

func (x *LookupResponse) ProtoReflect() protoreflect.Message

func (*LookupResponse) Reset

func (x *LookupResponse) Reset()

func (*LookupResponse) String

func (x *LookupResponse) String() string

type LookupSend

type LookupSend struct {
	UserID []byte `protobuf:"bytes,1,opt,name=userID,proto3" json:"userID,omitempty"`
	// contains filtered or unexported fields
}

Message sent to UDB for looking up a user

func (*LookupSend) Descriptor deprecated

func (*LookupSend) Descriptor() ([]byte, []int)

Deprecated: Use LookupSend.ProtoReflect.Descriptor instead.

func (*LookupSend) GetUserID

func (x *LookupSend) GetUserID() []byte

func (*LookupSend) ProtoMessage

func (*LookupSend) ProtoMessage()

func (*LookupSend) ProtoReflect

func (x *LookupSend) ProtoReflect() protoreflect.Message

func (*LookupSend) Reset

func (x *LookupSend) Reset()

func (*LookupSend) String

func (x *LookupSend) String() string

type Manager

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

Manager is the control structure for the contacting the user discovery service.

func NewManagerFromBackup

func NewManagerFromBackup(user udE2e, comms Comms,
	follower udNetworkStatus, cert, contactFile []byte,
	address string) (*Manager, error)

NewManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered and restore already registered facts into store.

Params

  • user is an interface that adheres to the xxdk.E2e object.
  • comms is an interface that adheres to client.Comms object.
  • follower is a method off of xxdk.Cmix which returns the network follower's status.
  • networkValidationSig is a signature provided by the network (i.e. the client registrar). This may be nil, however UD may return an error in some cases (e.g. in a production level environment).
  • cert is the TLS certificate for the UD server this call will connect with.
  • contactFile is the data within a marshalled contact.Contact. This represents the contact file of the server this call will connect with.
  • address is the IP address of the UD server this call will connect with.

Returns

  • A Manager object which is registered to the specified UD service.

func NewOrLoad

func NewOrLoad(user udE2e, comms Comms, follower udNetworkStatus,
	username string, networkValidationSig,
	cert, contactFile []byte, address string) (*Manager, error)

NewOrLoad loads an existing Manager from storage or creates a new one if there is no extant storage information. Parameters need be provided to specify how to connect to the User Discovery service. These parameters may be used to contact either the UD server hosted by the xx network team or a custom third-party operated server.

Params

  • user is an interface that adheres to the xxdk.E2e object.
  • comms is an interface that adheres to client.Comms object.
  • follower is a method off of xxdk.Cmix which returns the network follower's status.
  • username is the name of the user as it is registered with UD. This will be what the end user provides if through the bindings.
  • networkValidationSig is a signature provided by the network (i.e. the client registrar). This may be nil, however UD may return an error in some cases (e.g. in a production level environment).
  • cert is the TLS certificate for the UD server this call will connect with.
  • contactFile is the data within a marshalled contact.Contact. This represents the contact file of the server this call will connect with.
  • address is the IP address of the UD server this call will connect with.

Returns

  • A Manager object which is registered to the specified UD service.

func (*Manager) ConfirmFact

func (m *Manager) ConfirmFact(confirmationID, code string) error

ConfirmFact confirms a fact first registered via SendRegisterFact. The confirmation ID comes from SendRegisterFact while the code will come over the associated communications system.

func (*Manager) GetContact

func (m *Manager) GetContact() contact.Contact

GetContact returns the contact.Contact for UD.

func (*Manager) GetFacts

func (m *Manager) GetFacts() fact.FactList

GetFacts returns a list of fact.Fact objects that exist within the Store's registeredFacts map.

func (*Manager) GetStringifiedFacts

func (m *Manager) GetStringifiedFacts() []string

GetStringifiedFacts returns a list of stringified facts from the Store's registeredFacts map.

func (*Manager) PermanentDeleteAccount

func (m *Manager) PermanentDeleteAccount(f fact.Fact) error

PermanentDeleteAccount removes the username associated with this user from the UD service. This will only take a username type fact, and the fact must be associated with this user.

func (*Manager) RemoveFact

func (m *Manager) RemoveFact(f fact.Fact) error

RemoveFact removes a previously confirmed fact. This will fail if the fact passed in is not UD service does not associate this fact with this user.

func (*Manager) SendRegisterFact

func (m *Manager) SendRegisterFact(f fact.Fact) (string, error)

SendRegisterFact adds a fact for the user to user discovery. Will only succeed if the user is already registered and the system does not have the fact currently registered for any user.

This does not complete the fact registration process, it returns a confirmation ID instead. Over the communications system the fact is associated with, a code will be sent. This confirmation ID needs to be called along with the code to finalize the fact.

func (*Manager) StartChannelNameService

func (m *Manager) StartChannelNameService() (channels.NameService, error)

StartChannelNameService creates a new clientIDTracker and returns a reference to it's type as the NameService interface. However, it's scheduler thread isn't started until it's Start method is called.

type SearchResponse

type SearchResponse struct {

	// ID of the session created
	Contacts []*Contact `protobuf:"bytes,1,rep,name=contacts,proto3" json:"contacts,omitempty"`
	Error    string     `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

Message sent from UDB to client in response to a search

func (*SearchResponse) Descriptor deprecated

func (*SearchResponse) Descriptor() ([]byte, []int)

Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead.

func (*SearchResponse) GetContacts

func (x *SearchResponse) GetContacts() []*Contact

func (*SearchResponse) GetError

func (x *SearchResponse) GetError() string

func (*SearchResponse) ProtoMessage

func (*SearchResponse) ProtoMessage()

func (*SearchResponse) ProtoReflect

func (x *SearchResponse) ProtoReflect() protoreflect.Message

func (*SearchResponse) Reset

func (x *SearchResponse) Reset()

func (*SearchResponse) String

func (x *SearchResponse) String() string

type SearchSend

type SearchSend struct {

	// PublicKey used in the registration
	Fact []*HashFact `protobuf:"bytes,1,rep,name=fact,proto3" json:"fact,omitempty"`
	// contains filtered or unexported fields
}

Message sent to UDB to search for users

func (*SearchSend) Descriptor deprecated

func (*SearchSend) Descriptor() ([]byte, []int)

Deprecated: Use SearchSend.ProtoReflect.Descriptor instead.

func (*SearchSend) GetFact

func (x *SearchSend) GetFact() []*HashFact

func (*SearchSend) ProtoMessage

func (*SearchSend) ProtoMessage()

func (*SearchSend) ProtoReflect

func (x *SearchSend) ProtoReflect() protoreflect.Message

func (*SearchSend) Reset

func (x *SearchSend) Reset()

func (*SearchSend) String

func (x *SearchSend) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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