Documentation ¶
Index ¶
- Constants
- func AsyncRequestRestLike(e2eID int, recipient, request, paramsJSON []byte, cb RestlikeCallback) error
- func ConstructIdentity(pubKey []byte, codesetVersion int) ([]byte, error)
- func CreateUserFriendlyErrorMessage(errStr string) string
- func DecodePrivateURL(url, password string) (string, error)
- func DecodePublicURL(url string) (string, error)
- func DownloadAndVerifySignedNdfWithUrl(url, cert string) ([]byte, error)
- func EnableGrpcLogs(writer LogWriter)
- func GenerateChannel(cmixID int, name, description string, privacyLevel int) ([]byte, error)
- func GenerateChannelIdentity(cmixID int) ([]byte, error)
- func GenerateSecret(numBytes int) []byte
- func GetChannelInfo(prettyPrint string) ([]byte, error)
- func GetChannelJSON(prettyPrint string) ([]byte, error)
- func GetDefaultCMixParams() []byte
- func GetDefaultE2EParams() []byte
- func GetDefaultE2eFileTransferParams() []byte
- func GetDefaultFileTransferParams() []byte
- func GetDefaultSingleUseParams() []byte
- func GetDependencies() string
- func GetFactsFromContact(marshaledContact []byte) ([]byte, error)
- func GetGitVersion() string
- func GetIDFromContact(marshaledContact []byte) ([]byte, error)
- func GetNotificationsReport(notificationCSV string, marshalledServices []byte) ([]byte, error)
- func GetPubkeyFromContact(marshaledContact []byte) ([]byte, error)
- func GetPublicChannelIdentity(marshaledPublic []byte) ([]byte, error)
- func GetPublicChannelIdentityFromPrivate(marshaledPrivate []byte) ([]byte, error)
- func GetSavedChannelPrivateKeyUNSAFE(cmixID int, channelIdBase64 string) (string, error)
- func GetShareUrlType(url string) (int, error)
- func GetVersion() string
- func ImportPrivateIdentity(password string, data []byte) ([]byte, error)
- func IsNicknameValid(nick string) error
- func IsRegisteredWithUD(e2eId int) (bool, error)
- func LoadReceptionIdentity(key string, cmixId int) ([]byte, error)
- func LogLevel(level int) error
- func LookupUD(e2eID int, udContact []byte, cb UdLookupCallback, lookupId []byte, ...) ([]byte, error)
- func MultiLookupUD(e2eID int, udContact []byte, cb UdMultiLookupCallback, lookupIds []byte, ...) error
- func NewCmix(ndfJSON, storageDir string, password []byte, registrationCode string) error
- func NewCmixFromBackup(ndfJSON, storageDir, backupPassphrase string, ...) ([]byte, error)
- func NewEventModel(em EventModel) channels.EventModel
- func RegisterForNotifications(e2eId int, token string) error
- func RegisterLogWriter(writer LogWriter)
- func RequestRestLike(e2eID int, recipient, request, paramsJSON []byte) ([]byte, error)
- func RestlikeRequest(cmixId, connectionID int, request, e2eParamsJSON []byte) ([]byte, error)
- func RestlikeRequestAuth(cmixId, authConnectionID int, request, e2eParamsJSON []byte) ([]byte, error)
- func SearchUD(e2eID int, udContact []byte, cb UdSearchCallback, ...) ([]byte, error)
- func SetDashboardURL(newURL string)
- func SetFactsOnContact(marshaledContact []byte, factListJSON []byte) ([]byte, error)
- func SetOffset(offset int64)
- func SetTimeSource(timeNow netTime.TimeSource)
- func StoreReceptionIdentity(key string, identity []byte, cmixId int) error
- func TransmitSingleUse(e2eID int, recipient []byte, tag string, payload, paramsJSON []byte, ...) ([]byte, error)
- func UnregisterForNotifications(e2eId int) error
- func UpdateCommonErrors(jsonFile string) error
- type AuthCallbacks
- type AuthenticatedConnection
- type Backup
- type BackupReport
- type ChannelDbCipher
- type ChannelGeneration
- type ChannelInfo
- type ChannelMessageReceptionCallback
- type ChannelSendReport
- type ChannelsManager
- func LoadChannelsManager(cmixID int, storageTag string, eventBuilder EventModelBuilder) (*ChannelsManager, error)
- func LoadChannelsManagerGoEventModel(cmixID int, storageTag string, goEventBuilder channels.EventModelBuilder) (*ChannelsManager, error)
- func NewChannelsManager(cmixID int, privateIdentity []byte, eventBuilder EventModelBuilder) (*ChannelsManager, error)
- func NewChannelsManagerGoEventModel(cmixID int, privateIdentity []byte, goEventBuilder channels.EventModelBuilder) (*ChannelsManager, error)
- func (cm *ChannelsManager) DeleteNickname(ch []byte) error
- func (cm *ChannelsManager) ExportPrivateIdentity(password string) ([]byte, error)
- func (cm *ChannelsManager) GetChannels() ([]byte, error)
- func (cm *ChannelsManager) GetID() int
- func (cm *ChannelsManager) GetIdentity() ([]byte, error)
- func (cm *ChannelsManager) GetNickname(ch []byte) (string, error)
- func (cm *ChannelsManager) GetShareURL(cmixID int, host string, maxUses int, marshalledChanId []byte) ([]byte, error)
- func (cm *ChannelsManager) GetStorageTag() string
- func (cm *ChannelsManager) JoinChannel(channelPretty string) ([]byte, error)
- func (cm *ChannelsManager) LeaveChannel(marshalledChanId []byte) error
- func (cm *ChannelsManager) RegisterReceiveHandler(messageType int, listenerCb ChannelMessageReceptionCallback) error
- func (cm *ChannelsManager) ReplayChannel(marshalledChanId []byte) error
- func (cm *ChannelsManager) SendAdminGeneric(adminPrivateKey, marshalledChanId []byte, messageType int, message []byte, ...) ([]byte, error)
- func (cm *ChannelsManager) SendGeneric(marshalledChanId []byte, messageType int, message []byte, leaseTimeMS int64, ...) ([]byte, error)
- func (cm *ChannelsManager) SendMessage(marshalledChanId []byte, message string, leaseTimeMS int64, ...) ([]byte, error)
- func (cm *ChannelsManager) SendReaction(marshalledChanId []byte, reaction string, messageToReactTo []byte, ...) ([]byte, error)
- func (cm *ChannelsManager) SendReply(marshalledChanId []byte, message string, messageToReactTo []byte, ...) ([]byte, error)
- func (cm *ChannelsManager) SetNickname(newNick string, ch []byte) error
- type ClientError
- type Cmix
- func (c *Cmix) AddHealthCallback(nhc NetworkHealthCallback) int64
- func (c *Cmix) ChangeNumberOfNodeRegistrations(toRun, timeoutMS int) error
- func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) (*Connection, error)
- func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact, e2eParamsJSON []byte) (*AuthenticatedConnection, error)
- func (c *Cmix) GetID() int
- func (c *Cmix) GetNodeRegistrationStatus() ([]byte, error)
- func (c *Cmix) GetReceptionRegistrationValidationSignature() []byte
- func (c *Cmix) GetRunningProcesses() ([]byte, error)
- func (c *Cmix) HasRunningProcessies() bool
- func (c *Cmix) IsHealthy() bool
- func (c *Cmix) IsReady(percentReady float64) ([]byte, error)
- func (c *Cmix) MakeLegacyReceptionIdentity() ([]byte, error)
- func (c *Cmix) MakeReceptionIdentity() ([]byte, error)
- func (c *Cmix) NetworkFollowerStatus() int
- func (c *Cmix) PauseNodeRegistrations(timeoutMS int) error
- func (c *Cmix) ReadyToSend() bool
- func (c *Cmix) RegisterClientErrorCallback(clientError ClientError)
- func (c *Cmix) RemoveHealthCallback(funcID int64)
- func (c *Cmix) StartNetworkFollower(timeoutMS int) error
- func (c *Cmix) StopNetworkFollower() error
- func (c *Cmix) TrackServices(cb TrackServicesCallback)
- func (c *Cmix) TrackServicesWithIdentity(e2eId int, cb TrackServicesCallback) error
- func (c *Cmix) WaitForNetwork(timeoutMS int) bool
- func (c *Cmix) WaitForRoundResult(roundList []byte, mdc MessageDeliveryCallback, timeoutMS int) error
- type Connection
- type DummyTraffic
- type E2ESendReport
- type E2e
- func (e *E2e) AddPartnerCallback(partnerID []byte, cb AuthCallbacks) error
- func (e *E2e) AddService(tag string, processor Processor) error
- func (e *E2e) CallAllReceivedRequests()
- func (e *E2e) Confirm(partnerContact []byte) (int64, error)
- func (e *E2e) DeleteAllRequests() error
- func (e *E2e) DeleteContact(partnerID []byte) error
- func (e *E2e) DeletePartnerCallback(partnerID []byte) error
- func (e *E2e) DeleteReceiveRequests() error
- func (e *E2e) DeleteRequest(partnerID []byte) error
- func (e *E2e) DeleteSentRequests() error
- func (e *E2e) FirstPartitionSize() int
- func (e *E2e) GetAllPartnerIDs() ([]byte, error)
- func (e *E2e) GetContact() []byte
- func (e *E2e) GetHistoricalDHPrivkey() ([]byte, error)
- func (e *E2e) GetHistoricalDHPubkey() ([]byte, error)
- func (e *E2e) GetID() int
- func (e *E2e) GetReceivedRequest(partnerID []byte) ([]byte, error)
- func (e *E2e) GetReceptionID() []byte
- func (e *E2e) GetUdAddressFromNdf() string
- func (e *E2e) GetUdCertFromNdf() []byte
- func (e *E2e) GetUdContactFromNdf() ([]byte, error)
- func (e *E2e) HasAuthenticatedChannel(partnerId []byte) (bool, error)
- func (e *E2e) PartitionSize(payloadIndex int) int
- func (e *E2e) PayloadSize() int
- func (e *E2e) RegisterListener(senderID []byte, messageType int, newListener Listener) error
- func (e *E2e) RemoveService(tag string) error
- func (e *E2e) ReplayConfirm(partnerID []byte) (int64, error)
- func (e *E2e) Request(partnerContact, factsListJson []byte) (int64, error)
- func (e *E2e) Reset(partnerContact []byte) (int64, error)
- func (e *E2e) SecondPartitionSize() int
- func (e *E2e) SendE2E(messageType int, recipientId, payload, e2eParamsJSON []byte) ([]byte, error)
- func (e *E2e) VerifyOwnership(receivedContact, verifiedContact []byte, e2eId int) (bool, error)
- type EventModel
- type EventModelBuilder
- type EventReport
- type FilePartTracker
- type FileSend
- type FileTransfer
- func (f *FileTransfer) CloseSend(tidBytes []byte) error
- func (f *FileTransfer) MaxFileNameLen() int
- func (f *FileTransfer) MaxFileSize() int
- func (f *FileTransfer) MaxFileTypeLen() int
- func (f *FileTransfer) MaxPreviewSize() int
- func (f *FileTransfer) Receive(tidBytes []byte) ([]byte, error)
- func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte, callback FileTransferReceiveProgressCallback, period int) error
- func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte, callback FileTransferSentProgressCallback, period int) error
- func (f *FileTransfer) Send(payload, recipientID []byte, retry float32, ...) ([]byte, error)
- type FileTransferReceiveProgressCallback
- type FileTransferSentProgressCallback
- type Group
- type GroupChat
- func (g *GroupChat) GetGroup(groupId []byte) (*Group, error)
- func (g *GroupChat) GetGroups() ([]byte, error)
- func (g *GroupChat) JoinGroup(serializedGroupData []byte) error
- func (g *GroupChat) LeaveGroup(groupId []byte) error
- func (g *GroupChat) MakeGroup(membershipBytes, message, name []byte) ([]byte, error)
- func (g *GroupChat) NumGroups() int
- func (g *GroupChat) ResendRequest(groupId []byte) ([]byte, error)
- func (g *GroupChat) Send(groupId, message []byte, tag string) ([]byte, error)
- type GroupChatMessage
- type GroupChatProcessor
- type GroupReport
- type GroupRequest
- type GroupSendReport
- type IsReadyInfo
- type Listener
- type LogWriter
- type Message
- type MessageDeliveryCallback
- type NetworkHealthCallback
- type NodeRegistrationReport
- type NotificationReport
- type NotificationReports
- type Processor
- type Progress
- type ReceiveFileCallback
- type ReceivedChannelMessageReport
- type ReceivedFile
- type ReceptionIdentity
- type ReporterFunc
- type RestlikeCallback
- type RestlikeMessage
- type RoundsList
- type ShareURL
- type SingleUseCallback
- type SingleUseCallbackReport
- type SingleUseResponse
- type SingleUseResponseReport
- type SingleUseSendReport
- type Stopper
- type TrackServicesCallback
- type UdLookupCallback
- type UdMultiLookupCallback
- type UdNetworkStatus
- type UdSearchCallback
- type UpdateBackupFunc
- type UserDiscovery
- func (ud *UserDiscovery) ConfirmFact(confirmationID, code string) error
- func (ud *UserDiscovery) GetContact() ([]byte, error)
- func (ud *UserDiscovery) GetFacts() []byte
- func (ud *UserDiscovery) GetID() int
- func (ud *UserDiscovery) PermanentDeleteAccount(factJson []byte) error
- func (ud *UserDiscovery) RemoveFact(factJson []byte) error
- func (ud *UserDiscovery) SendRegisterFact(factJson []byte) (string, error)
Constants ¶
const ( UnrecognizedCode = "UR: " UnrecognizedMessage = UnrecognizedCode + "Unrecognized error from XX backend, please report" )
Error codes
Variables ¶
This section is empty.
Functions ¶
func AsyncRequestRestLike ¶
func AsyncRequestRestLike(e2eID int, recipient, request, paramsJSON []byte, cb RestlikeCallback) error
AsyncRequestRestLike sends an asynchronous restlike request to a given contact.
Parameters:
- e2eID - ID of the e2e object in the tracker
- recipient - marshalled contact.Contact object
- request - JSON marshalled RestlikeMessage
- paramsJSON - JSON marshalled single.RequestParams
- cb - RestlikeCallback callback
Returns an error, and the RestlikeCallback will be called with the results of JSON marshalling the response when received.
func ConstructIdentity ¶
ConstructIdentity constructs a [channel.Identity] from a user's public key and codeset version.
Parameters:
- pubKey - The Ed25519 public key.
- codesetVersion - The version of the codeset used to generate the identity.
Returns:
- JSON of [channel.Identity].
func CreateUserFriendlyErrorMessage ¶
CreateUserFriendlyErrorMessage will convert the passed in error string to an error string that is user-friendly if a substring match is found to a common error. Common errors is a map that can be updated using UpdateCommonErrors. If the error is not common, some simple parsing is done on the error message to make it more user-accessible, removing backend specific jargon.
Parameters:
- errStr - an error returned from the backend.
Returns
- A user-friendly error message. This should be devoid of technical speak but still be meaningful for front-end or back-end teams.
func DecodePrivateURL ¶
DecodePrivateURL decodes the channel URL, using the password, into a channel pretty print. This function can only be used for private or secret channel URLs. To get the privacy level of a channel URL, use GetShareUrlType.
Parameters:
- url - The channel's share URL. Should be received from another user or generated via [GetShareURL].
- password - The password needed to decrypt the secret data in the URL.
Returns:
- The channel pretty print.
func DecodePublicURL ¶
DecodePublicURL decodes the channel URL into a channel pretty print. This function can only be used for public channel URLs. To get the privacy level of a channel URL, use GetShareUrlType.
Parameters:
- url - The channel's share URL. Should be received from another user or generated via [GetShareURL].
Returns:
- The channel pretty print.
func DownloadAndVerifySignedNdfWithUrl ¶
DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. The NDF is processed into a protobuf containing a signature that is verified using the cert string passed in. The NDF is returned as marshaled byte data that may be used to start a client.
func GenerateChannel ¶
GenerateChannel is used to create a channel a new channel of which you are the admin. It is only for making new channels, not joining existing ones.
It returns a pretty print of the channel and the private key.
Parameters:
- cmixID - The tracked cmix object ID. This can be retrieved using Cmix.GetID.
- name - The name of the new channel. The name must be between 3 and 24 characters inclusive. It can only include upper and lowercase unicode letters, digits 0 through 9, and underscores (_). It cannot be changed once a channel is created.
- description - The description of a channel. The description is optional but cannot be longer than 144 characters and can include all unicode characters. It cannot be changed once a channel is created.
- privacyLevel - The broadcast.PrivacyLevel of the channel. 0 = public, 1 = private, and 2 = secret. Refer to the comment below for more information.
Returns:
- []byte - ChannelGeneration describes a generated channel. It contains both the public channel info and the private key for the channel in PEM format.
The [broadcast.PrivacyLevel] of a channel indicates the level of channel information revealed when sharing it via URL. For any channel besides public channels, the secret information is encrypted and a password is required to share and join a channel.
- A privacy level of [broadcast.Public] reveals all the information including the name, description, privacy level, public key and salt.
- A privacy level of [broadcast.Private] reveals only the name and description.
- A privacy level of [broadcast.Secret] reveals nothing.
func GenerateChannelIdentity ¶
GenerateChannelIdentity creates a new private channel identity ([channel.PrivateIdentity]). The public component can be retrieved as JSON via GetPublicChannelIdentityFromPrivate.
Parameters:
- cmixID - The tracked cmix object ID. This can be retrieved using Cmix.GetID.
Returns:
- Marshalled bytes of [channel.PrivateIdentity].
func GenerateSecret ¶
GenerateSecret creates a secret password using a system-based pseudorandom number generator.
Parameters:
- numBytes - The size of secret. It should be set to 32, but can be set higher in certain cases.
func GetChannelInfo ¶
GetChannelInfo returns the info about a channel from its public description.
Parameters:
- prettyPrint - The pretty print of the channel.
The pretty print will be of the format:
<Speakeasy-v3:Test_Channel|description:Channel description.|level:Public|created:1666718081766741100|secrets:+oHcqDbJPZaT3xD5NcdLY8OjOMtSQNKdKgLPmr7ugdU=|rCI0wr01dHFStjSFMvsBzFZClvDIrHLL5xbCOPaUOJ0=|493|1|7cBhJxVfQxWo+DypOISRpeWdQBhuQpAZtUbQHjBm8NQ=>
Returns:
- []byte - JSON of ChannelInfo, which describes all relevant channel info.
func GetChannelJSON ¶
GetChannelJSON returns the JSON of the channel for the given pretty print.
Parameters:
- prettyPrint - The pretty print of the channel.
Returns:
- JSON of the [broadcast.Channel] object.
Example JSON of [broadcast.Channel]:
{ "ReceptionID": "Ja/+Jh+1IXZYUOn+IzE3Fw/VqHOscomD0Q35p4Ai//kD", "Name": "My_Channel", "Description": "Here is information about my channel.", "Salt": "+tlrU/htO6rrV3UFDfpQALUiuelFZ+Cw9eZCwqRHk+g=", "RsaPubKeyHash": "PViT1mYkGBj6AYmE803O2RpA7BX24EjgBdldu3pIm4o=", "RsaPubKeyLength": 5, "RSASubPayloads": 1, "Secret": "JxZt/wPx2luoPdHY6jwbXqNlKnixVU/oa9DgypZOuyI=", "Level": 0 }
func GetDefaultCMixParams ¶
func GetDefaultCMixParams() []byte
GetDefaultCMixParams returns a JSON serialized object with all of the cMix parameters and their default values. Call this function and modify the JSON to change cMix settings.
func GetDefaultE2EParams ¶
func GetDefaultE2EParams() []byte
GetDefaultE2EParams returns a JSON serialized object with all of the E2E parameters and their default values. Call this function and modify the JSON to change E2E settings.
func GetDefaultE2eFileTransferParams ¶
func GetDefaultE2eFileTransferParams() []byte
GetDefaultE2eFileTransferParams returns a JSON serialized object with all the E2E file transfer parameters and their default values. Call this function and modify the JSON to change single use settings.
func GetDefaultFileTransferParams ¶
func GetDefaultFileTransferParams() []byte
GetDefaultFileTransferParams returns a JSON serialized object with all the file transfer parameters and their default values. Call this function and modify the JSON to change file transfer settings.
func GetDefaultSingleUseParams ¶
func GetDefaultSingleUseParams() []byte
GetDefaultSingleUseParams returns a JSON serialized object with all the single-use parameters and their default values. Call this function and modify the JSON to change single use settings.
func GetFactsFromContact ¶
GetFactsFromContact returns the fact list in the contact.Contact object.
Parameters:
- marshaledContact - the JSON marshalled bytes of contact.Contact
Returns:
- []byte - the JSON marshalled bytes of fact.FactList
func GetIDFromContact ¶
GetIDFromContact returns the ID in the contact.Contact object.
Parameters:
- marshaledContact - JSON marshalled bytes of contact.Contact
Returns:
- []byte - bytes of the id.ID object
func GetNotificationsReport ¶
GetNotificationsReport parses the received notification data to determine which notifications are for this user. // This returns the JSON-marshalled NotificationReports.
Parameters:
- notificationCSV - the notification data received from the notifications' server.
- marshalledServices - the JSON-marshalled list of services the backend keeps track of. Refer to Cmix.TrackServices or Cmix.TrackServicesWithIdentity for information about this.
Returns:
- []byte - A JSON marshalled NotificationReports. Some NotificationReport's within in this structure may have their NotificationReport.ForMe set to false. These may be ignored.
func GetPubkeyFromContact ¶
GetPubkeyFromContact returns the DH public key in the contact.Contact object.
Parameters:
- marshaledContact - JSON marshalled bytes of contact.Contact
Returns:
- []byte - JSON marshalled bytes of the [cyclic.Int] object
func GetPublicChannelIdentity ¶
GetPublicChannelIdentity constructs a public identity ([channel.Identity]) from a bytes version and returns it JSON marshaled.
Parameters:
- marshaledPublic - Bytes of the public identity ([channel.Identity]).
Returns:
- JSON of the constructed [channel.Identity].
func GetPublicChannelIdentityFromPrivate ¶
GetPublicChannelIdentityFromPrivate returns the public identity ([channel.Identity]) contained in the given private identity ([channel.PrivateIdentity]).
Parameters:
- marshaledPrivate - Bytes of the private identity (channel.PrivateIdentity]).
Returns:
- JSON of the public [channel.Identity].
func GetSavedChannelPrivateKeyUNSAFE ¶
GetSavedChannelPrivateKeyUNSAFE loads the private key from storage for the given channel ID.
NOTE: This function is unsafe and only for debugging purposes only.
Parameters:
- cmixID - ID of Cmix object in tracker.
- channelIdBase64 - The id.ID of the channel in base 64 encoding.
Returns:
- The PEM file of the private key.
func GetShareUrlType ¶
GetShareUrlType determines the [broadcast.PrivacyLevel] of the channel URL. If the URL is an invalid channel URL, an error is returned.
Parameters:
- url - The channel share URL.
Returns:
- An int that corresponds to the [broadcast.PrivacyLevel] as outlined below.
Possible returns:
0 = public channel 1 = private channel 2 = secret channel
func ImportPrivateIdentity ¶
ImportPrivateIdentity generates a new [channel.PrivateIdentity] from exported data.
Parameters:
- password - The password used to encrypt the identity.
- data - The encrypted data.
Returns:
- JSON of [channel.PrivateIdentity].
func IsNicknameValid ¶
IsNicknameValid checks if a nickname is valid.
Rules:
- A nickname must not be longer than 24 characters.
- A nickname must not be shorter than 1 character.
func IsRegisteredWithUD ¶
IsRegisteredWithUD is a function which checks the internal state files to determine if a user has registered with UD in the past.
Parameters:
- e2eID - REQUIRED. The tracked e2e object ID. This can be retrieved using E2e.GetID.
Returns:
- bool - A boolean representing true if the user has been registered with UD already or false if it has not been registered already.
- error - An error should only be returned if the internal tracker failed to retrieve an E2e object given the e2eId. If an error was returned, the registration state check was not performed properly, and the boolean returned should be ignored.
func LoadReceptionIdentity ¶
LoadReceptionIdentity loads the given identity in Cmix storage with the given key.
func LogLevel ¶
LogLevel sets level of logging. All logs at the set level and below will be displayed (e.g., when log level is ERROR, only ERROR, CRITICAL, and FATAL messages will be printed).
Log level options:
TRACE - 0 DEBUG - 1 INFO - 2 WARN - 3 ERROR - 4 CRITICAL - 5 FATAL - 6
The default log level without updates is INFO.
func LookupUD ¶
func LookupUD(e2eID int, udContact []byte, cb UdLookupCallback, lookupId []byte, singleRequestParamsJSON []byte) ([]byte, error)
LookupUD returns the public key of the passed ID as known by the user discovery system or returns by the timeout.
Parameters:
- e2eID - e2e object ID in the tracker
- udContact - the marshalled bytes of the contact.Contact object
- lookupId - the marshalled bytes of the id.ID object for the user that LookupUD will look up.
- singleRequestParams - the JSON marshalled bytes of single.RequestParams
Returns:
- []byte - the JSON marshalled bytes of the SingleUseSendReport object, which can be passed into Cmix.WaitForRoundResult to see if the send succeeded.
func MultiLookupUD ¶
func MultiLookupUD(e2eID int, udContact []byte, cb UdMultiLookupCallback, lookupIds []byte, singleRequestParamsJSON []byte) error
MultiLookupUD returns the public key of all passed in IDs as known by the user discovery system or returns by the timeout.
Parameters:
- e2eID - e2e object ID in the tracker
- udContact - the marshalled bytes of the contact.Contact object
- lookupIds - JSON marshalled list of []*id.ID object for the users that MultiLookupUD will look up.
- singleRequestParams - the JSON marshalled bytes of single.RequestParams
Returns:
- []byte - the JSON marshalled bytes of the SingleUseSendReport object, which can be passed into Cmix.WaitForRoundResult to see if the send succeeded.
func NewCmix ¶
NewCmix creates user storage, generates keys, connects, and registers with the network. Note that this does not register a username/identity, but merely creates a new cryptographic identity for adding such information at a later date.
Users of this function should delete the storage directory on error.
func NewCmixFromBackup ¶
func NewCmixFromBackup(ndfJSON, storageDir, backupPassphrase string, sessionPassword, backupFileContents []byte) ([]byte, error)
NewCmixFromBackup initializes a new e2e storage from an encrypted backup. Users of this function should delete the storage directory on error. Users of this function should call LoadCmix as normal once this call succeeds.
Parameters:
- ndfJSON - JSON of the NDF.
- storageDir - directory for the storage files.
- sessionPassword - password to decrypt the data in the storageDir.
- backupPassphrase - backup passphrase provided by the user. Used to decrypt backup.
- backupFileContents - the file contents of the backup.
Returns:
- []byte - the JSON marshalled bytes of the BackupReport object.
func NewEventModel ¶
func NewEventModel(em EventModel) channels.EventModel
NewEventModel is a constructor for a toEventModel. This will take in an EventModel and wraps it around the toEventModel.
func RegisterForNotifications ¶
RegisterForNotifications allows a client to register for push notifications. The token is a firebase messaging token.
Parameters:
- e2eId - ID of the E2E object in the E2E tracker
func RegisterLogWriter ¶
func RegisterLogWriter(writer LogWriter)
RegisterLogWriter registers a callback on which logs are written.
func RequestRestLike ¶
RequestRestLike sends a restlike request to a given contact.
Parameters:
- e2eID - ID of the e2e object in the tracker
- recipient - marshalled contact.Contact object
- request - JSON marshalled RestlikeMessage
- paramsJSON - JSON marshalled single.RequestParams
Returns:
- []byte - JSON marshalled restlike.Message
func RestlikeRequest ¶
RestlikeRequest performs a normal restlike request.
Parameters:
- cmixId - ID of the cMix object in the tracker
- connectionID - ID of the connection in the tracker
- request - JSON marshalled RestlikeMessage
- e2eParamsJSON - JSON marshalled xxdk.E2EParams
Returns:
- []byte - JSON marshalled RestlikeMessage
func RestlikeRequestAuth ¶
func RestlikeRequestAuth(cmixId, authConnectionID int, request, e2eParamsJSON []byte) ([]byte, error)
RestlikeRequestAuth performs an authenticated restlike request.
Parameters:
- cmixId - ID of the cMix object in the tracker
- authConnectionID - ID of the authenticated connection in the tracker
- request - JSON marshalled RestlikeMessage
- e2eParamsJSON - JSON marshalled xxdk.E2EParams
Returns:
- []byte - JSON marshalled RestlikeMessage
func SearchUD ¶
func SearchUD(e2eID int, udContact []byte, cb UdSearchCallback, factListJSON, singleRequestParamsJSON []byte) ([]byte, error)
SearchUD searches user discovery 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.
Parameters:
- e2eID - e2e object ID in the tracker
- udContact - the marshalled bytes of the contact.Contact for the user discovery server
- factListJSON - the JSON marshalled bytes of fact.FactList
- singleRequestParams - the JSON marshalled bytes of single.RequestParams
Returns:
- []byte - the JSON marshalled bytes of the SingleUseSendReport object, which can be passed into Cmix.WaitForRoundResult to see if the send operation succeeded.
func SetDashboardURL ¶
func SetDashboardURL(newURL string)
SetDashboardURL is a function which modifies the base dashboard URL that is returned as part of any send report. Internally, this is defaulted to "https://dashboard.xx.network". This should only be called if the user explicitly wants to modify the dashboard URL. This function is not thread-safe, and as such should only be called on setup.
Parameters:
- newURL - A valid URL that will be used for round look up on any send report.
func SetFactsOnContact ¶
SetFactsOnContact replaces the facts on the contact with the passed in facts pass in empty facts in order to clear the facts.
Parameters:
- marshaledContact - the JSON marshalled bytes of contact.Contact
- factListJSON - the JSON marshalled bytes of fact.FactList
Returns:
- []byte - marshalled bytes of the modified contact.Contact
func SetOffset ¶
func SetOffset(offset int64)
SetOffset will set an internal offset variable. All calls to netTime.Now will have this offset applied to this value.
Parameters:
- offset is a time by which netTime.Now will be offset. This value may be negative or positive. This expects a 64-bit integer value which will represent the number in microseconds this offset will be.
func SetTimeSource ¶
func SetTimeSource(timeNow netTime.TimeSource)
SetTimeSource will set the time source that will be used when retrieving the current time using netTime.Now. This should be called BEFORE Login() and only be called once. Using this after Login is undefined behavior that may result in a crash.
Parameters:
- timeNow is an object which adheres to netTime.TimeSource. Specifically, this object should a NowMs() method which return a 64-bit integer value.
func StoreReceptionIdentity ¶
StoreReceptionIdentity stores the given identity in Cmix storage with the given key. This is the ideal way to securely store identities, as the caller of this function is only required to store the given key separately rather than the keying material.
func TransmitSingleUse ¶
func TransmitSingleUse(e2eID int, recipient []byte, tag string, payload, paramsJSON []byte, responseCB SingleUseResponse) ([]byte, error)
TransmitSingleUse transmits payload to recipient via single-use.
Parameters:
- e2eID - ID of the e2e object in the tracker
- recipient - marshalled contact.Contact object
- tag - identifies the single-use message
- payload - message contents
- paramsJSON - JSON marshalled single.RequestParams
- responseCB - the callback that will be called when a response is received
Returns:
- []byte - the JSON marshalled bytes of the SingleUseSendReport object, which can be passed into WaitForRoundResult to see if the send succeeded.
func UnregisterForNotifications ¶
UnregisterForNotifications turns off notifications for this client.
Parameters:
- e2eId - ID of the E2E object in the E2E tracker
func UpdateCommonErrors ¶
UpdateCommonErrors updates the internal error mapping database. This internal database maps errors returned from the backend to user-friendly error messages.
Parameters:
- jsonFile - contents of a JSON file whose format conforms to the example below.
Example Input:
{ "Failed to Unmarshal Conversation": "Could not retrieve conversation", "Failed to unmarshal SentRequestMap": "Failed to pull up friend requests", "cannot create username when network is not health": "Cannot create username, unable to connect to network", }
Types ¶
type AuthCallbacks ¶
type AuthCallbacks interface { Request(contact, receptionId []byte, ephemeralId, roundId int64) Confirm(contact, receptionId []byte, ephemeralId, roundId int64) Reset(contact, receptionId []byte, ephemeralId, roundId int64) }
AuthCallbacks is the bindings-specific interface for auth.Callbacks methods.
type AuthenticatedConnection ¶
type AuthenticatedConnection struct {
Connection
}
func (*AuthenticatedConnection) IsAuthenticated ¶
func (_ *AuthenticatedConnection) IsAuthenticated() bool
type Backup ¶
type Backup struct {
// contains filtered or unexported fields
}
Backup is a bindings-level struct encapsulating the backup.Backup client object.
func InitializeBackup ¶
func InitializeBackup(e2eID, udID int, backupPassPhrase string, cb UpdateBackupFunc) (*Backup, error)
InitializeBackup creates a bindings-layer Backup object.
Parameters:
- e2eID - ID of the E2e object in the e2e tracker.
- udID - ID of the UserDiscovery object in the ud tracker.
- backupPassPhrase - backup passphrase provided by the user. Used to decrypt backup.
- cb - the callback to be called when a backup is triggered.
func ResumeBackup ¶
func ResumeBackup(e2eID, udID int, cb UpdateBackupFunc) ( *Backup, error)
ResumeBackup resumes the backup processes with a new callback. Call this function only when resuming a backup that has already been initialized or to replace the callback. To start the backup for the first time or to use a new password, use InitializeBackup.
Parameters:
- e2eID - ID of the E2e object in the e2e tracker.
- udID - ID of the UserDiscovery object in the ud tracker.
- cb - the callback to be called when a backup is triggered. This will replace any callback that has been passed into InitializeBackup.
func (*Backup) AddJson ¶
AddJson stores the argument within the Backup structure.
Params
- json - JSON string
func (*Backup) IsBackupRunning ¶
IsBackupRunning returns true if the backup has been initialized and is running. Returns false if it has been stopped.
func (*Backup) StopBackup ¶
StopBackup stops the backup processes and deletes the user's password from storage. To enable backups again, call InitializeBackup.
type BackupReport ¶
type BackupReport struct { // The list of restored E2E partner IDs RestoredContacts []*id.ID // The backup parameters found within the backup file Params string }
BackupReport is the bindings' representation of the return values of NewCmixFromBackup.
Example BackupReport:
{ "RestoredContacts": [ "U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID", "15tNdkKbYXoMn58NO6VbDMDWFEyIhTWEGsvgcJsHWAgD" ], "Params": "" }
type ChannelDbCipher ¶
type ChannelDbCipher struct {
// contains filtered or unexported fields
}
ChannelDbCipher is the bindings layer representation of the [channel.Cipher].
func GetChannelDbCipherTrackerFromID ¶
func GetChannelDbCipherTrackerFromID(id int) (*ChannelDbCipher, error)
GetChannelDbCipherTrackerFromID returns the ChannelDbCipher with the corresponding ID in the tracker.
func NewChannelsDatabaseCipher ¶
func NewChannelsDatabaseCipher(cmixID int, password []byte, plaintTextBlockSize int) (*ChannelDbCipher, error)
NewChannelsDatabaseCipher constructs a ChannelDbCipher object.
Parameters:
- cmixID - The tracked Cmix object ID.
- password - The password for storage. This should be the same password passed into NewCmix.
- plaintTextBlockSize - The maximum size of a payload to be encrypted. A payload passed into ChannelDbCipher.Encrypt that is larger than plaintTextBlockSize will result in an error.
func (*ChannelDbCipher) Decrypt ¶
func (c *ChannelDbCipher) Decrypt(ciphertext []byte) ([]byte, error)
Decrypt will decrypt the passed in encrypted value. The plaintext will be returned by this function. Any padding will be discarded within this function.
Parameters:
- ciphertext - the encrypted data returned by ChannelDbCipher.Encrypt.
func (*ChannelDbCipher) Encrypt ¶
func (c *ChannelDbCipher) Encrypt(plaintext []byte) ([]byte, error)
Encrypt will encrypt the raw data. It will return a ciphertext. Padding is done on the plaintext so all encrypted data looks uniform at rest.
Parameters:
- plaintext - The data to be encrypted. This must be smaller than the block size passed into NewChannelsDatabaseCipher. If it is larger, this will return an error.
func (*ChannelDbCipher) GetID ¶
func (c *ChannelDbCipher) GetID() int
GetID returns the ID for this ChannelDbCipher in the channelDbCipherTracker.
type ChannelGeneration ¶
ChannelGeneration contains information about a newly generated channel. It contains the public channel info formatted in pretty print and the private key for the channel in PEM format.
Example JSON:
{ "Channel": "\u003cSpeakeasy-v3:name|description:desc|level:Public|created:1665489600000000000|secrets:zjHmrPPMDQ0tNSANjAmQfKhRpJIdJMU+Hz5hsZ+fVpk=|qozRNkADprqb38lsnU7WxCtGCq9OChlySCEgl4NHjI4=|2|328|7aZQAtuVjE84q4Z09iGytTSXfZj9NyTa6qBp0ueKjCI=\u003e", "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\nMCYCAQACAwDVywIDAQABAgMAlVECAgDvAgIA5QICAJECAgCVAgIA1w==\n-----END RSA PRIVATE KEY-----" }
type ChannelInfo ¶
ChannelInfo contains information about a channel.
Example of ChannelInfo JSON:
{ "Name": "Test Channel", "Description": "This is a test channel", "ChannelID": "RRnpRhmvXtW9ugS1nILJ3WfttdctDvC2jeuH43E0g/0D", }
type ChannelMessageReceptionCallback ¶
type ChannelMessageReceptionCallback interface {
Callback(receivedChannelMessageReport []byte, err error) int
}
ChannelMessageReceptionCallback is the callback that returns the context for a channel message via the Callback. It must return a unique UUID for the message by which it can be referenced later
type ChannelSendReport ¶
type ChannelSendReport struct { MessageId []byte RoundsList EphId int64 }
ChannelSendReport is the bindings' representation of the return values of ChannelsManager's Send operations.
JSON Example:
{ "MessageId": "0kitNxoFdsF4q1VMSI/xPzfCnGB2l+ln2+7CTHjHbJw=", "Rounds":[1,5,9], "EphId": 0 }
type ChannelsManager ¶
type ChannelsManager struct {
// contains filtered or unexported fields
}
ChannelsManager is a bindings-layer struct that wraps a channels.Manager interface.
func LoadChannelsManager ¶
func LoadChannelsManager(cmixID int, storageTag string, eventBuilder EventModelBuilder) (*ChannelsManager, error)
LoadChannelsManager loads an existing ChannelsManager.
This is for loading a manager for an identity that has already been created. The channel manager should have previously been created with NewChannelsManager and the storage is retrievable with ChannelsManager.GetStorageTag.
Parameters:
- cmixID - The tracked cmix object ID. This can be retrieved using Cmix.GetID.
- storageTag - The storage tag associated with the previously created channel manager and retrieved with ChannelsManager.GetStorageTag.
- event - An interface that contains a function that initialises and returns the event model that is bindings-compatible.
func LoadChannelsManagerGoEventModel ¶
func LoadChannelsManagerGoEventModel(cmixID int, storageTag string, goEventBuilder channels.EventModelBuilder) (*ChannelsManager, error)
LoadChannelsManagerGoEventModel loads an existing ChannelsManager. This is not compatible with GoMobile Bindings because it receives the go event model. This is for creating a manager for an identity for the first time. The channel manager should have first been created with NewChannelsManagerGoEventModel and then the storage tag can be retrieved with ChannelsManager.GetStorageTag
Parameters:
- cmixID - The tracked cmix object ID. This can be retrieved using Cmix.GetID.
- storageTag - retrieved with ChannelsManager.GetStorageTag
- goEvent - A function that initialises and returns the event model that is not compatible with GoMobile bindings.
func NewChannelsManager ¶
func NewChannelsManager(cmixID int, privateIdentity []byte, eventBuilder EventModelBuilder) (*ChannelsManager, error)
NewChannelsManager creates a new ChannelsManager from a new private identity ([channel.PrivateIdentity]).
This is for creating a manager for an identity for the first time. For generating a new one channel identity, use GenerateChannelIdentity. To reload this channel manager, use LoadChannelsManager, passing in the storage tag retrieved by ChannelsManager.GetStorageTag.
Parameters:
- cmixID - The tracked Cmix object ID. This can be retrieved using Cmix.GetID.
- privateIdentity - Bytes of a private identity ([channel.PrivateIdentity]) that is generated by GenerateChannelIdentity.
- event - An interface that contains a function that initialises and returns the event model that is bindings-compatible.
func NewChannelsManagerGoEventModel ¶
func NewChannelsManagerGoEventModel(cmixID int, privateIdentity []byte, goEventBuilder channels.EventModelBuilder) (*ChannelsManager, error)
NewChannelsManagerGoEventModel creates a new ChannelsManager from a new private identity ([channel.PrivateIdentity]). This is not compatible with GoMobile Bindings because it receives the go event model.
This is for creating a manager for an identity for the first time. For generating a new one channel identity, use GenerateChannelIdentity. To reload this channel manager, use LoadChannelsManagerGoEventModel, passing in the storage tag retrieved by ChannelsManager.GetStorageTag.
Parameters:
- cmixID - The tracked Cmix object ID. This can be retrieved using Cmix.GetID.
- privateIdentity - Bytes of a private identity ([channel.PrivateIdentity]) that is generated by GenerateChannelIdentity.
- goEvent - A function that initialises and returns the event model that is not compatible with GoMobile bindings.
func (*ChannelsManager) DeleteNickname ¶
func (cm *ChannelsManager) DeleteNickname(ch []byte) error
DeleteNickname deletes the nickname for a given channel.
func (*ChannelsManager) ExportPrivateIdentity ¶
func (cm *ChannelsManager) ExportPrivateIdentity(password string) ([]byte, error)
ExportPrivateIdentity encrypts and exports the private identity to a portable string.
func (*ChannelsManager) GetChannels ¶
func (cm *ChannelsManager) GetChannels() ([]byte, error)
GetChannels returns the IDs of all channels that have been joined.
Returns:
- []byte - A JSON marshalled list of IDs.
JSON Example:
{ "U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID", "15tNdkKbYXoMn58NO6VbDMDWFEyIhTWEGsvgcJsHWAgD" }
func (*ChannelsManager) GetID ¶
func (cm *ChannelsManager) GetID() int
GetID returns the channelManagerTracker ID for the ChannelsManager object.
func (*ChannelsManager) GetIdentity ¶
func (cm *ChannelsManager) GetIdentity() ([]byte, error)
GetIdentity returns the marshaled public identity ([channel.Identity]) that the channel is using.
func (*ChannelsManager) GetNickname ¶
func (cm *ChannelsManager) GetNickname(ch []byte) (string, error)
GetNickname returns the nickname set for a given channel. Returns an error if there is no nickname set.
func (*ChannelsManager) GetShareURL ¶
func (cm *ChannelsManager) GetShareURL(cmixID int, host string, maxUses int, marshalledChanId []byte) ([]byte, error)
GetShareURL generates a URL that can be used to share this channel with others on the given host.
A URL comes in one of three forms based on the privacy level set when generating the channel. Each privacy level hides more information than the last with the lowest level revealing everything and the highest level revealing nothing. For any level above the lowest, a password is returned, which will be required when decoding the URL.
The maxUses is the maximum number of times this URL can be used to join a channel. If it is set to 0, then it can be shared unlimited times. The max uses is set as a URL parameter using the key [broadcast.MaxUsesKey]. Note that this number is also encoded in the secret data for private and secret URLs, so if the number is changed in the URL, is will be verified when calling [ChannelsManager.JoinChannelFromURL]. There is no enforcement for public URLs.
Parameters:
- cmixID - The tracked Cmix object ID.
- host - The URL to append the channel info to.
- maxUses - The maximum number of uses the link can be used (0 for unlimited).
- marshalledChanId - A marshalled channel ID (id.ID).
Returns:
- JSON of ShareURL.
func (*ChannelsManager) GetStorageTag ¶
func (cm *ChannelsManager) GetStorageTag() string
GetStorageTag returns the storage tag needed to reload the manager.
func (*ChannelsManager) JoinChannel ¶
func (cm *ChannelsManager) JoinChannel(channelPretty string) ([]byte, error)
JoinChannel joins the given channel. It will fail if the channel has already been joined.
Parameters:
- channelPretty - A portable channel string. Should be received from another user or generated via GenerateChannel.
The pretty print will be of the format:
<Speakeasy-v3:Test_Channel|description:Channel description.|level:Public|created:1666718081766741100|secrets:+oHcqDbJPZaT3xD5NcdLY8OjOMtSQNKdKgLPmr7ugdU=|rCI0wr01dHFStjSFMvsBzFZClvDIrHLL5xbCOPaUOJ0=|493|1|7cBhJxVfQxWo+DypOISRpeWdQBhuQpAZtUbQHjBm8NQ=>
Returns:
- []byte - JSON of ChannelInfo, which describes all relevant channel info.
func (*ChannelsManager) LeaveChannel ¶
func (cm *ChannelsManager) LeaveChannel(marshalledChanId []byte) error
LeaveChannel leaves the given channel. It will return an error if the channel was not previously joined.
Parameters:
- marshalledChanId - A JSON marshalled channel ID (id.ID).
func (*ChannelsManager) RegisterReceiveHandler ¶
func (cm *ChannelsManager) RegisterReceiveHandler(messageType int, listenerCb ChannelMessageReceptionCallback) error
RegisterReceiveHandler is used to register handlers for non-default message types. They can be processed by modules. It is important that such modules sync up with the event model implementation.
There can only be one handler per channels.MessageType, and this will return an error on any re-registration.
Parameters:
- messageType - represents the channels.MessageType which will have a registered listener.
- listenerCb - the callback which will be executed when a channel message of messageType is received.
func (*ChannelsManager) ReplayChannel ¶
func (cm *ChannelsManager) ReplayChannel(marshalledChanId []byte) error
ReplayChannel replays all messages from the channel within the network's memory (~3 weeks) over the event model.
Parameters:
- marshalledChanId - A JSON marshalled channel ID (id.ID).
func (*ChannelsManager) SendAdminGeneric ¶
func (cm *ChannelsManager) SendAdminGeneric(adminPrivateKey, marshalledChanId []byte, messageType int, message []byte, leaseTimeMS int64, cmixParamsJSON []byte) ([]byte, error)
SendAdminGeneric is used to send a raw message over a channel encrypted with admin keys, identifying it as sent by the admin. In general, it should be wrapped in a function that defines the wire protocol. If the final message, before being sent over the wire, is too long, this will return an error. The message must be at most 510 bytes long.
Parameters:
- adminPrivateKey - The PEM-encoded admin RSA private key.
- marshalledChanId - A JSON marshalled channel ID (id.ID).
- messageType - The message type of the message. This will be a valid channels.MessageType.
- message - The contents of the message. The message should be at most 510 bytes. This need not be of data type string, as the message could be a specified format that the channel may recognize.
- leaseTimeMS - The lease of the message. This will be how long the message is valid until, in milliseconds. As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport.
func (*ChannelsManager) SendGeneric ¶
func (cm *ChannelsManager) SendGeneric(marshalledChanId []byte, messageType int, message []byte, leaseTimeMS int64, cmixParamsJSON []byte) ([]byte, error)
SendGeneric is used to send a raw message over a channel. In general, it should be wrapped in a function that defines the wire protocol. If the final message, before being sent over the wire, is too long, this will return an error. Due to the underlying encoding using compression, it isn't possible to define the largest payload that can be sent, but it will always be possible to send a payload of 802 bytes at minimum. The meaning of validUntil depends on the use case.
Parameters:
- marshalledChanId - A JSON marshalled channel ID (id.ID).
- messageType - The message type of the message. This will be a valid channels.MessageType.
- message - The contents of the message. This need not be of data type string, as the message could be a specified format that the channel may recognize.
- leaseTimeMS - The lease of the message. This will be how long the message is valid until, in milliseconds. As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport.
func (*ChannelsManager) SendMessage ¶
func (cm *ChannelsManager) SendMessage(marshalledChanId []byte, message string, leaseTimeMS int64, cmixParamsJSON []byte) ([]byte, error)
SendMessage is used to send a formatted message over a channel. Due to the underlying encoding using compression, it isn't possible to define the largest payload that can be sent, but it will always be possible to send a payload of 798 bytes at minimum.
The message will auto delete validUntil after the round it is sent in, lasting forever if channels.ValidForever is used.
Parameters:
- marshalledChanId - A JSON marshalled channel ID (id.ID).
- message - The contents of the message. The message should be at most 510 bytes. This is expected to be Unicode, and thus a string data type is expected
- leaseTimeMS - The lease of the message. This will be how long the message is valid until, in milliseconds. As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport
func (*ChannelsManager) SendReaction ¶
func (cm *ChannelsManager) SendReaction(marshalledChanId []byte, reaction string, messageToReactTo []byte, cmixParamsJSON []byte) ([]byte, error)
SendReaction is used to send a reaction to a message over a channel. The reaction must be a single emoji with no other characters, and will be rejected otherwise. Users will drop the reaction if they do not recognize the reactTo message.
Parameters:
- marshalledChanId - A JSON marshalled channel ID (id.ID).
- reaction - The user's reaction. This should be a single emoji with no other characters. As such, a Unicode string is expected.
- messageToReactTo - The marshalled [channel.MessageID] of the message you wish to reply to. This may be found in the ChannelSendReport if replying to your own. Alternatively, if reacting to another user's message, you may retrieve it via the ChannelMessageReceptionCallback registered using RegisterReceiveHandler.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport.
func (*ChannelsManager) SendReply ¶
func (cm *ChannelsManager) SendReply(marshalledChanId []byte, message string, messageToReactTo []byte, leaseTimeMS int64, cmixParamsJSON []byte) ([]byte, error)
SendReply is used to send a formatted message over a channel. Due to the underlying encoding using compression, it isn't possible to define the largest payload that can be sent, but it will always be possible to send a payload of 766 bytes at minimum.
If the message ID the reply is sent to is nonexistent, the other side will post the message as a normal message and not a reply. The message will auto delete validUntil after the round it is sent in, lasting forever if channels.ValidForever is used.
Parameters:
- marshalledChanId - A JSON marshalled channel ID (id.ID).
- message - The contents of the message. The message should be at most 510 bytes. This is expected to be Unicode, and thus a string data type is expected.
- messageToReactTo - The marshalled [channel.MessageID] of the message you wish to reply to. This may be found in the ChannelSendReport if replying to your own. Alternatively, if reacting to another user's message, you may retrieve it via the ChannelMessageReceptionCallback registered using RegisterReceiveHandler.
- leaseTimeMS - The lease of the message. This will be how long the message is valid until, in milliseconds. As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport
func (*ChannelsManager) SetNickname ¶
func (cm *ChannelsManager) SetNickname(newNick string, ch []byte) error
SetNickname sets the nickname for a given channel. The nickname must be valid according to IsNicknameValid.
type ClientError ¶
type ClientError interface {
Report(source, message, trace string)
}
type Cmix ¶
type Cmix struct {
// contains filtered or unexported fields
}
Cmix wraps the xxdk.Cmix struct, implementing additional functions to support the bindings Cmix interface.
func LoadCmix ¶
LoadCmix will load an existing user storage from the storageDir using the password. This will fail if the user storage does not exist or the password is incorrect.
The password is passed as a byte array so that it can be cleared from memory and stored as securely as possible using the MemGuard library.
LoadCmix does not block on network connection and instead loads and starts subprocesses to perform network operations.
func (*Cmix) AddHealthCallback ¶
func (c *Cmix) AddHealthCallback(nhc NetworkHealthCallback) int64
AddHealthCallback adds a callback that gets called whenever the network health changes. Returns a registration ID that can be used to unregister.
func (*Cmix) ChangeNumberOfNodeRegistrations ¶
ChangeNumberOfNodeRegistrations changes the number of parallel node registrations up to the initialized maximum.
Parameters:
- toRun - The number of parallel node registrations.
- timeoutMS - The timeout, in milliseconds, to wait when changing node registrations before failing.
func (*Cmix) Connect ¶
func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) ( *Connection, error)
Connect performs auth key negotiation with the given recipient and returns a Connection object for the newly created partner.Manager.
This function is to be used sender-side and will block until the partner.Manager is confirmed.
Parameters:
- e2eId - ID of the E2E object in the e2e tracker
- recipientContact - marshalled contact.Contact object
- e2eParamsJSON - JSON marshalled byte of xxdk.E2EParams object
func (*Cmix) ConnectWithAuthentication ¶
func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact, e2eParamsJSON []byte) (*AuthenticatedConnection, error)
ConnectWithAuthentication is called by the client (i.e., the one establishing connection with the server). Once a connect.Connection has been established with the server, it then authenticates their identity to the server.
func (*Cmix) GetNodeRegistrationStatus ¶
GetNodeRegistrationStatus returns the current state of node registration.
Returns:
- []byte - A marshalled NodeRegistrationReport containing the number of nodes the user is registered with and the number of nodes present in the NDF.
- An error if it cannot get the node registration status. The most likely cause is that the network is unhealthy.
func (*Cmix) GetReceptionRegistrationValidationSignature ¶
GetReceptionRegistrationValidationSignature returns the signature provided by the xx network.
func (*Cmix) GetRunningProcesses ¶
GetRunningProcesses returns the names of all running processes at the time of this call. Note that this list may change and is subject to race conditions if multiple threads are in the process of starting or stopping.
Returns:
- []byte - A JSON marshalled list of all running processes.
JSON Example:
{ "FileTransfer{BatchBuilderThread, FilePartSendingThread#0, FilePartSendingThread#1, FilePartSendingThread#2, FilePartSendingThread#3}", "MessageReception Worker 0" }
func (*Cmix) HasRunningProcessies ¶
HasRunningProcessies checks if any background threads are running and returns true if one or more are.
This is meant to be used when NetworkFollowerStatus returns xxdk.Stopping. Due to the handling of comms on iOS, where the OS can block indefinitely, it may not enter the stopped state appropriately. This can be used instead.
func (*Cmix) IsHealthy ¶
IsHealthy returns true if the network is read to be in a healthy state where messages can be sent.
func (*Cmix) IsReady ¶
IsReady returns true if at least percentReady of node registrations has completed. If not all have completed, then it returns false and howClose will be a percent (0-1) of node registrations completed.
Parameters:
- percentReady - The percentage of nodes required to be registered with to be ready. This is a number between 0 and 1.
Returns:
- JSON of IsReadyInfo.
func (*Cmix) MakeLegacyReceptionIdentity ¶
MakeLegacyReceptionIdentity generates the legacy identity for receiving messages. As with all legacy calls, this should primarily be used for the xx messenger team.
func (*Cmix) MakeReceptionIdentity ¶
MakeReceptionIdentity generates a new cryptographic identity for receiving messages.
func (*Cmix) NetworkFollowerStatus ¶
NetworkFollowerStatus gets the state of the network follower. It returns a status with the following values:
Stopped - 0 Running - 2000 Stopping - 3000
func (*Cmix) PauseNodeRegistrations ¶
PauseNodeRegistrations stops all node registrations and returns a function to resume them.
Parameters:
- timeoutMS - The timeout, in milliseconds, to wait when stopping threads before failing.
func (*Cmix) ReadyToSend ¶
ReadyToSend determines if the network is ready to send messages on. It returns true if the network is healthy and if the client has registered with at least 70% of the nodes. Returns false otherwise.
func (*Cmix) RegisterClientErrorCallback ¶
func (c *Cmix) RegisterClientErrorCallback(clientError ClientError)
RegisterClientErrorCallback registers the callback to handle errors from the long-running threads controlled by StartNetworkFollower and StopNetworkFollower.
func (*Cmix) RemoveHealthCallback ¶
RemoveHealthCallback removes a health callback using its registration ID.
func (*Cmix) StartNetworkFollower ¶
StartNetworkFollower kicks off the tracking of the network. It starts long- running network threads and returns an object for checking state and stopping those threads.
Call this when returning from sleep and close when going back to sleep.
These threads may become a significant drain on battery when offline, ensure they are stopped if there is no internet access.
Threads Started:
- Network Follower (/network/follow.go) tracks the network events and hands them off to workers for handling.
- Historical Round Retrieval (/network/rounds/historical.go) retrieves data about rounds that are too old to be stored by the client.
- Message Retrieval Worker Group (/network/rounds/retrieve.go) requests all messages in a given round from the gateway of the last nodes.
- Message Handling Worker Group (/network/message/handle.go) decrypts and partitions messages when signals via the Switchboard.
- Health Tracker (/network/health), via the network instance, tracks the state of the network.
- Garbled Messages (/network/message/garbled.go) can be signaled to check all recent messages that could be decoded. It uses a message store on disk for persistence.
- Critical Messages (/network/message/critical.go) ensures all protocol layer mandatory messages are sent. It uses a message store on disk for persistence.
- KeyExchange Trigger (/keyExchange/trigger.go) responds to sent rekeys and executes them.
- KeyExchange Confirm (/keyExchange/confirm.go) responds to confirmations of successful rekey operations.
- Auth Callback (/auth/callback.go) handles both auth confirm and requests.
func (*Cmix) StopNetworkFollower ¶
StopNetworkFollower stops the network follower if it is running. It returns an error if the follower is in the wrong state to stop or if it fails to stop it.
If the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed.
func (*Cmix) TrackServices ¶
func (c *Cmix) TrackServices(cb TrackServicesCallback)
TrackServices will return via a callback the list of services the backend keeps track of, which is formally referred to as a message.ServiceList. This may be passed into other bindings call which may need context on the available services for this client. This will provide services for all identities that the client tracks.
Parameters:
- cb - A TrackServicesCallback, which will be passed the marshalled message.ServiceList.
func (*Cmix) TrackServicesWithIdentity ¶
func (c *Cmix) TrackServicesWithIdentity(e2eId int, cb TrackServicesCallback) error
TrackServicesWithIdentity will return via a callback the list of services the backend keeps track of for the provided identity. This may be passed into other bindings call which may need context on the available services for this single identity. This will only return services for the given identity.
Parameters:
- e2eID - e2e object ID in the tracker.
- cb - A TrackServicesCallback, which will be passed the marshalled message.ServiceList.
func (*Cmix) WaitForNetwork ¶
WaitForNetwork will block until either the network is healthy or the passed timeout is reached. It will return true if the network is healthy.
func (*Cmix) WaitForRoundResult ¶
func (c *Cmix) WaitForRoundResult( roundList []byte, mdc MessageDeliveryCallback, timeoutMS int) error
WaitForRoundResult allows the caller to get notified if the rounds a message was sent in successfully completed. Under the hood, this uses an API that uses the internal round data, network historical round lookup, and waiting on network events to determine what has (or will) occur.
This function takes the marshaled send report to ensure a memory leak does not occur as a result of both sides of the bindings holding a reference to the same pointer.
Parameters:
- roundList - JSON marshalled bytes of RoundsList or JSON of any send report that inherits a bindings.RoundsList object
- mdc - callback that adheres to the MessageDeliveryCallback interface
- timeoutMS - timeout when the callback will return if no state update occurs, in milliseconds
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is the bindings' representation of a connect.Connection object that can be tracked by ID.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close deletes this Connection's partner.Manager and releases resources.
func (*Connection) GetPartner ¶
func (c *Connection) GetPartner() []byte
GetPartner returns the partner.Manager for this Connection.
func (*Connection) RegisterListener ¶
func (c *Connection) RegisterListener(messageType int, newListener Listener) error
RegisterListener is used for E2E reception and allows for reading data sent from the partner.Manager.
func (*Connection) SendE2E ¶
func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error)
SendE2E is a wrapper for sending specifically to the Connection's partner.Manager.
Returns:
- []byte - the JSON marshalled bytes of the E2ESendReport object, which can be passed into Cmix.WaitForRoundResult to see if the send succeeded.
type DummyTraffic ¶
type DummyTraffic struct {
// contains filtered or unexported fields
}
DummyTraffic is the bindings-layer dummy (or "cover") traffic manager. T The manager can be used to set and get the status of the thread responsible for sending dummy messages.
func NewDummyTrafficManager ¶
func NewDummyTrafficManager(cmixId, maxNumMessages, avgSendDeltaMS, randomRangeMS int) (*DummyTraffic, error)
NewDummyTrafficManager creates a DummyTraffic manager and initialises the dummy traffic sending thread. Note that the manager does not start sending dummy traffic until true is passed into DummyTraffic.SetStatus. The time duration between each sending operation and the amount of messages sent each interval are randomly generated values with bounds defined by the given parameters below.
Parameters:
- cmixId - a Cmix object ID in the tracker.
- maxNumMessages - the upper bound of the random number of messages sent each sending cycle. Suggested value: 5.
- avgSendDeltaMS - the average duration, in milliseconds, to wait between sends. Suggested value: 60000.
- randomRangeMS - the upper bound of the interval between sending cycles, in milliseconds. Sends occur every avgSendDeltaMS +/- a random duration with an upper bound of randomRangeMS. Suggested value: 1000.
func (*DummyTraffic) GetStatus ¶
func (dt *DummyTraffic) GetStatus() bool
GetStatus returns the current state of the DummyTraffic manager's sending thread. Note that this function does not return the status set by the most recent call to SetStatus. Instead, this call returns the current status of the sending thread. This is due to the small delay that may occur between calling SetStatus and the sending thread taking into effect that status change.
Returns:
- bool - Returns true if sending thread is sending dummy messages and false if sending thread is paused/stopped and is not sending dummy messages.
func (*DummyTraffic) SetStatus ¶
func (dt *DummyTraffic) SetStatus(status bool) error
SetStatus sets the state of the DummyTraffic manager's send thread by passing in a boolean parameter. There may be a small delay in between this call and the status of the sending thread to change accordingly. For example, passing false into this call while the sending thread is currently sending messages will not cancel nor halt the sending operation, but will pause the thread once that operation has completed.
Parameters:
- status - Input should be true if you want to send dummy messages and false if you want to pause dummy messages.
Returns:
- error - if the DummyTraffic.SetStatus is called too frequently, causing the internal status channel to fill.
type E2ESendReport ¶
type E2ESendReport struct { RoundsList RoundURL string MessageID []byte Timestamp int64 KeyResidue []byte }
E2ESendReport is the bindings' representation of the return values of SendE2E.
E2ESendReport Example JSON:
{ "Rounds": [ 1, 4, 9], "RoundURL":"https://dashboard.xx.network/rounds/25?xxmessenger=true", "MessageID": "iM34yCIr4Je8ZIzL9iAAG1UWAeDiHybxMTioMAaezvs=", "Timestamp": 1661532254302612000, "KeyResidue": "9q2/A69EAuFM1hFAT7Bzy5uGOQ4T6bPFF72h5PlgCWE=" }
type E2e ¶
type E2e struct {
// contains filtered or unexported fields
}
E2e wraps the xxdk.E2e, implementing additional functions to support the bindings E2e interface.
func Login ¶
func Login(cmixId int, callbacks AuthCallbacks, identity, e2eParamsJSON []byte) (*E2e, error)
Login creates and returns a new E2e object and adds it to the e2eTrackerSingleton. Identity should be created via Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a default auth.Callbacks will be used.
func LoginEphemeral ¶
func LoginEphemeral(cmixId int, callbacks AuthCallbacks, identity, e2eParamsJSON []byte) (*E2e, error)
LoginEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton. Identity should be created via Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in here. If callbacks is left nil, a default auth.Callbacks will be used.
func (*E2e) AddPartnerCallback ¶
func (e *E2e) AddPartnerCallback(partnerID []byte, cb AuthCallbacks) error
AddPartnerCallback adds a new callback that overrides the generic auth callback for the given partner ID.
Parameters:
- partnerID - the marshalled bytes of the id.ID object.
func (*E2e) AddService ¶
AddService adds a service for all partners of the given tag, which will call back on the given processor. These can be sent to using the tag fields in the Params object.
Passing nil for the processor allows you to create a service that is never called but will be visible by notifications. Processes added this way are generally not end-to-end encrypted messages themselves, but other protocols that piggyback on e2e relationships to start communication.
func (*E2e) CallAllReceivedRequests ¶
func (e *E2e) CallAllReceivedRequests()
CallAllReceivedRequests will iterate through all pending contact requests and replay them on the callbacks.
func (*E2e) Confirm ¶
Confirm sends a confirmation for a received request. It can only be called once. This both sends keying material to the other party and creates a channel in the e2e handler, after which e2e messages can be sent to the partner using E2e.SendE2E.
The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure.
A confirmation cannot be sent for a contact who has not sent a request or who is already a partner. This can only be called once for a specific contact. The confirmation sends as a critical message; if the round it sends on fails, it will be auto resent by the cMix client.
If the confirmation must be resent, use ReplayConfirm.
Parameters:
- partnerContact - the marshalled bytes of the contact.Contact object.
Returns:
- int64 - ID of the round (convert to uint64)
func (*E2e) DeleteAllRequests ¶
DeleteAllRequests clears all requests from auth storage.
func (*E2e) DeleteContact ¶
DeleteContact removes a partner from E2e's storage.
Parameters:
- partnerID - the marshalled bytes of id.ID.
func (*E2e) DeletePartnerCallback ¶
DeletePartnerCallback deletes the callback that overrides the generic auth callback for the given partner ID.
Parameters:
- partnerID - the marshalled bytes of the id.ID object.
func (*E2e) DeleteReceiveRequests ¶
DeleteReceiveRequests clears all received requests from auth storage.
func (*E2e) DeleteRequest ¶
DeleteRequest deletes sent or received requests for a specific partner ID.
Parameters:
- partnerID - the marshalled bytes of the id.ID object.
func (*E2e) DeleteSentRequests ¶
DeleteSentRequests clears all sent requests from auth storage.
func (*E2e) FirstPartitionSize ¶
FirstPartitionSize returns the max partition payload size for the first payload.
func (*E2e) GetAllPartnerIDs ¶
GetAllPartnerIDs returns a list of all partner IDs that the user has an E2E relationship with.
Returns:
- []byte - the marshalled bytes of []*id.ID.
func (*E2e) GetContact ¶
GetContact returns a marshalled contact.Contact object for the E2e ReceptionIdentity.
func (*E2e) GetHistoricalDHPrivkey ¶
GetHistoricalDHPrivkey returns the user's marshalled historical DH private key.
Returns:
- []byte - the marshalled bytes of the cyclic.Int object.
func (*E2e) GetHistoricalDHPubkey ¶
GetHistoricalDHPubkey returns the user's marshalled historical DH public key.
Returns:
- []byte - the marshalled bytes of the cyclic.Int object.
func (*E2e) GetReceivedRequest ¶
GetReceivedRequest returns a contact if there is a received request for it.
Parameters:
- partnerID - the marshalled bytes of the id.ID object.
Returns:
- []byte - the marshalled bytes of the contact.Contact object.
func (*E2e) GetReceptionID ¶
GetReceptionID returns the marshalled default IDs.
Returns:
- []byte - the marshalled bytes of the id.ID object.
func (*E2e) GetUdAddressFromNdf ¶
GetUdAddressFromNdf retrieve the User Discovery's network address fom the NDF.
func (*E2e) GetUdCertFromNdf ¶
GetUdCertFromNdf retrieves the User Discovery's TLS certificate (in PEM format) from the NDF.
func (*E2e) GetUdContactFromNdf ¶
GetUdContactFromNdf assembles the User Discovery's contact file from the data within the NDF.
Returns
- []byte - A byte marshalled contact.Contact.
func (*E2e) HasAuthenticatedChannel ¶
HasAuthenticatedChannel returns true if an authenticated channel with the partner exists, otherwise returns false.
Parameters:
- partnerId - the marshalled bytes of the id.ID object.
func (*E2e) PartitionSize ¶
PartitionSize returns the partition payload size for the given payload index. The first payload is index 0.
func (*E2e) PayloadSize ¶
PayloadSize returns the max payload size for a partitionable E2E message.
func (*E2e) RegisterListener ¶
RegisterListener registers a new listener.
Parameters:
- senderId - the user ID who sends messages to this user that this function will register a listener for.
- messageType - message type from the sender you want to listen for.
- newListener: A provider for a callback to hear a message. Do not pass nil to this.
func (*E2e) RemoveService ¶
RemoveService removes all services for the given tag.
func (*E2e) ReplayConfirm ¶
ReplayConfirm resends a confirmation to the partner. It will fail to send if the send relationship with the partner has already ratcheted.
The confirmation sends as a critical message; if the round it sends on fails, it will be auto resent by the cMix client.
This will not be useful if either side has ratcheted.
Parameters:
- partnerID - the marshalled bytes of the id.ID object.
Returns:
- int64 - ID of the round (convert to uint64)
func (*E2e) Request ¶
Request sends a contact request from the user identity in the imported E2e structure to the passed contact, as well as the passed facts (it will error if they are too long).
The other party must accept the request by calling Confirm to be able to send messages using E2e.SendE2E. When the other party does so, the "confirm" callback will get called.
The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure.
A request cannot be sent for a contact who has already received a request or who is already a partner.
The request sends as a critical message, if the round it sends on fails, it will be auto resent by the cMix client.
Parameters:
- partnerContact - the marshalled bytes of the contact.Contact object.
- factsListJson - the JSON marshalled bytes of fact.FactList.
Returns:
- int64 - ID of the round (convert to uint64)
func (*E2e) Reset ¶
Reset sends a contact reset request from the user identity in the imported e2e structure to the passed contact, as well as the passed facts (it will error if they are too long).
This deletes all traces of the relationship with the partner from e2e and create a new relationship from scratch.
The round the reset is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure.
A request cannot be sent for a contact who has already received a request or who is already a partner.
Parameters:
- partnerContact - the marshalled bytes of the contact.Contact object.
Returns:
- int64 - ID of the round (convert to uint64)
func (*E2e) SecondPartitionSize ¶
SecondPartitionSize returns the max partition payload size for all payloads after the first payload.
func (*E2e) SendE2E ¶
SendE2E send a message containing the payload to the recipient of the passed message type, per the given parameters--encrypted with end-to-end encryption.
Parameters:
- recipientId - the marshalled bytes of the id.ID object.
- e2eParams - the marshalled bytes of the e2e.Params object.
Returns:
- []byte - the JSON marshalled bytes of the E2ESendReport object, which can be passed into Cmix.WaitForRoundResult to see if the send succeeded.
func (*E2e) VerifyOwnership ¶
VerifyOwnership checks if the received ownership proof is valid.
Parameters:
- receivedContact, verifiedContact - the marshalled bytes of the contact.Contact object.
- e2eId - ID of the e2e handler
type EventModel ¶
type EventModel interface { // JoinChannel is called whenever a channel is joined locally. // // Parameters: // - channel - Returns the pretty print representation of a channel. JoinChannel(channel string) // LeaveChannel is called whenever a channel is left locally. // // Parameters: // - ChannelId - The marshalled channel [id.ID]. LeaveChannel(channelID []byte) // ReceiveMessage is called whenever a message is received on a given // channel. It may be called multiple times on the same message. It is // incumbent on the user of the API to filter such called by message ID. // // Parameters: // - channelID - The marshalled channel [id.ID]. // - messageID - The bytes of the [channel.MessageID] of the received // message. // - nickname - The nickname of the sender of the message. // - text - The content of the message. // - timestamp - Time the message was received; represented as nanoseconds // since unix epoch. // - pubKey - The sender's Ed25519 public key. // - codeset - The codeset version. // - lease - The number of nanoseconds that the message is valid for. // - roundId - The ID of the round that the message was received on. // - mType - the type of the message, always 1 for this call // - status - the [channels.SentStatus] of the message. // // Statuses will be enumerated as such: // Sent = 0 // Delivered = 1 // Failed = 2 // // Returns a non-negative unique UUID for the message that it can be // referenced by later with [EventModel.UpdateSentStatus]. ReceiveMessage(channelID, messageID []byte, nickname, text string, pubKey []byte, codeset int, timestamp, lease, roundId, mType, status int64) int64 // ReceiveReply is called whenever a message is received that is a reply on // a given channel. It may be called multiple times on the same message. It // is incumbent on the user of the API to filter such called by message ID. // // Messages may arrive our of order, so a reply in theory can arrive before // the initial message. As a result, it may be important to buffer replies. // // Parameters: // - channelID - The marshalled channel [id.ID]. // - messageID - The bytes of the [channel.MessageID] of the received // message. // - reactionTo - The [channel.MessageID] for the message that received a // reply. // - nickname - The nickname of the sender of the message. // - text - The content of the message. // - pubKey - The sender's Ed25519 public key. // - codeset - The codeset version. // - timestamp - Time the message was received; represented as nanoseconds // since unix epoch. // - lease - The number of nanoseconds that the message is valid for. // - roundId - The ID of the round that the message was received on. // - mType - the type of the message, always 1 for this call // - status - the [channels.SentStatus] of the message. // // Statuses will be enumerated as such: // Sent = 0 // Delivered = 1 // Failed = 2 // // Returns a non-negative unique UUID for the message that it can be // referenced by later with [EventModel.UpdateSentStatus]. ReceiveReply(channelID, messageID, reactionTo []byte, nickname, text string, pubKey []byte, codeset int, timestamp, lease, roundId, mType, status int64) int64 // ReceiveReaction is called whenever a reaction to a message is received // on a given channel. It may be called multiple times on the same reaction. // It is incumbent on the user of the API to filter such called by message // ID. // // Messages may arrive our of order, so a reply in theory can arrive before // the initial message. As a result, it may be important to buffer // reactions. // // Parameters: // - channelID - The marshalled channel [id.ID]. // - messageID - The bytes of the [channel.MessageID] of the received // message. // - reactionTo - The [channel.MessageID] for the message that received a // reply. // - nickname - The nickname of the sender of the message. // - reaction - The contents of the reaction message. // - pubKey - The sender's Ed25519 public key. // - codeset - The codeset version. // - timestamp - Time the message was received; represented as nanoseconds // since unix epoch. // - lease - The number of nanoseconds that the message is valid for. // - roundId - The ID of the round that the message was received on. // - mType - the type of the message, always 1 for this call // - status - the [channels.SentStatus] of the message. // // Statuses will be enumerated as such: // Sent = 0 // Delivered = 1 // Failed = 2 // // Returns a non-negative unique uuid for the message by which it can be // referenced later with UpdateSentStatus ReceiveReaction(channelID, messageID, reactionTo []byte, nickname, reaction string, pubKey []byte, codeset int, timestamp, lease, roundId, mType, status int64) int64 // UpdateSentStatus is called whenever the sent status of a message has // changed. // // Parameters: // - messageID - The bytes of the [channel.MessageID] of the received // message. // - status - the [channels.SentStatus] of the message. // // Statuses will be enumerated as such: // Sent = 0 // Delivered = 1 // Failed = 2 UpdateSentStatus( uuid int64, messageID []byte, timestamp, roundID, status int64) }
EventModel is an interface which an external party which uses the channels system passed an object which adheres to in order to get events on the channel.
type EventModelBuilder ¶
type EventModelBuilder interface {
Build(path string) EventModel
}
EventModelBuilder builds an event model
type EventReport ¶
EventReport is a public struct which represents the contents of an event report.
Example JSON:
{ "Priority": 1, "Category": "Test Events", "EventType": "Ping", "Details": "This is an example of an event report" }
type FilePartTracker ¶
type FilePartTracker struct {
// contains filtered or unexported fields
}
FilePartTracker contains the fileTransfer.FilePartTracker.
func (FilePartTracker) GetNumParts ¶
func (fpt FilePartTracker) GetNumParts() int
GetNumParts returns the total number of file parts in the transfer.
func (FilePartTracker) GetPartStatus ¶
func (fpt FilePartTracker) GetPartStatus(partNum int) int
GetPartStatus returns the status of the file part with the given part number.
The possible values for the status are:
- 0 < Part does not exist
- 0 = unsent
- 1 = arrived (sender has sent a part, and it has arrived)
- 2 = received (receiver has received a part)
type FileSend ¶
type FileSend struct { // Name is the human-readable file name. Get max length from // [FileTransfer.MaxFileNameLen]. Name string // Type is a shorthand that identifies the type of file. Get max length from // [FileTransfer.MaxFileTypeLen]. Type string // Preview of the file data (e.g. a thumbnail). Get max length from // [FileTransfer.MaxPreviewSize]. Preview []byte // Contents is the full file contents. Get max length from // [FileTransfer.MaxFileSize]. Contents []byte }
FileSend contains the file and its metadata to send. This structure is JSON marshalled and passed as the payload to FileTransfer.Send.
Example JSON:
{ "Name": "testfile.txt", "Type": "text file", "Preview": "RMlsZSBwCmV2aWV3Lg==", "Contents": "RMlsZSBjb250ZW50cy4=" }
type FileTransfer ¶
type FileTransfer struct {
// contains filtered or unexported fields
}
FileTransfer object is a bindings-layer struct which wraps a fileTransfer.FileTransfer interface.
func InitFileTransfer ¶
func InitFileTransfer(e2eID int, receiveFileCallback ReceiveFileCallback, e2eFileTransferParamsJson, fileTransferParamsJson []byte) (*FileTransfer, error)
InitFileTransfer creates a bindings-level file transfer manager.
Parameters:
- e2eID - ID of E2e object in tracker.
- receiveFileCallback - A callback that is called when a new file transfer is received.
- e2eFileTransferParamsJson - JSON of gitlab.com/elixxir/client/v5/fileTransfer/e2e.Params.
- fileTransferParamsJson - JSON of fileTransfer.Params.
Returns:
- New FileTransfer object.
func (*FileTransfer) CloseSend ¶
func (f *FileTransfer) CloseSend(tidBytes []byte) error
CloseSend deletes a file from the internal storage once a transfer has completed or reached the retry limit. If neither of those condition are met, an error is returned.
This function should be called once a transfer completes or errors out (as reported by the progress callback).
Parameters:
- tidBytes - the file transfer's unique fileTransfer.TransferID.
func (*FileTransfer) MaxFileNameLen ¶
func (f *FileTransfer) MaxFileNameLen() int
MaxFileNameLen returns the max number of bytes allowed for a file name.
func (*FileTransfer) MaxFileSize ¶
func (f *FileTransfer) MaxFileSize() int
MaxFileSize returns the max number of bytes allowed for a file.
func (*FileTransfer) MaxFileTypeLen ¶
func (f *FileTransfer) MaxFileTypeLen() int
MaxFileTypeLen returns the max number of bytes allowed for a file type.
func (*FileTransfer) MaxPreviewSize ¶
func (f *FileTransfer) MaxPreviewSize() int
MaxPreviewSize returns the max number of bytes allowed for a file preview.
func (*FileTransfer) Receive ¶
func (f *FileTransfer) Receive(tidBytes []byte) ([]byte, error)
Receive returns the full file on the completion of the transfer. It deletes internal references to the data and unregisters any attached progress callback. Returns an error if the transfer is not complete, the full file cannot be verified, or if the transfer cannot be found.
Receive can only be called once the progress callback returns that the file transfer is complete.
Parameters:
- tidBytes - The file transfer's unique fileTransfer.TransferID.
func (*FileTransfer) RegisterReceivedProgressCallback ¶
func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte, callback FileTransferReceiveProgressCallback, period int) error
RegisterReceivedProgressCallback allows for the registration of a callback to track the progress of an individual received file transfer.
The callback will be called immediately when added to report the current progress of the transfer. It will then call every time a file part is received, the transfer completes, or a fatal error occurs. It is called at most once every period regardless of the number of progress updates.
In the event that the client is closed and resumed, this function must be used to re-register any callbacks previously registered.
Once the callback reports that the transfer has completed, the recipient can get the full file by calling Receive.
Parameters:
- tidBytes - The file transfer's unique fileTransfer.TransferID.
- callback - A callback that reports the progress of the file transfer. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- period - The progress callback will be limited from triggering only once per period. It is a duration in milliseconds. This value should depend on how frequently you want to receive updates, and should be tuned to your implementation.
func (*FileTransfer) RegisterSentProgressCallback ¶
func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte, callback FileTransferSentProgressCallback, period int) error
RegisterSentProgressCallback allows for the registration of a callback to track the progress of an individual sent file transfer.
The callback will be called immediately when added to report the current progress of the transfer. It will then call every time a file part arrives, the transfer completes, or a fatal error occurs. It is called at most once every period regardless of the number of progress updates.
In the event that the client is closed and resumed, this function must be used to re-register any callbacks previously registered with this function or Send.
Parameters:
- tidBytes - The file transfer's unique fileTransfer.TransferID.
- callback - A callback that reports the progress of the file transfer. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- period - The progress callback will be limited from triggering only once per period. It is a duration in milliseconds. This value should depend on how frequently you want to receive updates, and should be tuned to your implementation.
func (*FileTransfer) Send ¶
func (f *FileTransfer) Send(payload, recipientID []byte, retry float32, callback FileTransferSentProgressCallback, period int) ([]byte, error)
Send initiates the sending of a file to a recipient and returns a transfer ID that uniquely identifies this file transfer. Progress for the file transfer is reported to that passed in callback.
Parameters:
- payload - JSON of FileSend, which contains the file contents and its metadata.
- recipientID - marshalled bytes of the recipient's id.ID.
- retry - The number of sending retries allowed on send failure (e.g. a retry of 2.0 with 6 parts means 12 total possible sends).
- callback - A callback that reports the progress of the file transfer. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- period - The progress callback will be limited from triggering only once per period. It is a duration in milliseconds. This value should depend on how frequently you want to receive updates, and should be tuned to your implementation.
Returns:
- The bytes of the unique fileTransfer.TransferID.
type FileTransferReceiveProgressCallback ¶
type FileTransferReceiveProgressCallback interface { // Callback is called when a file part is received or an error occurs. Once // a transfer completes, the file can be received using // [FileTransfer.Receive]. // // Parameters: // - payload - JSON of [Progress], which describes the progress of the // current transfer. // - t - file part tracker that allows the lookup of the status of // individual file parts. // - err - Fatal errors during receiving. If an error is returned, the // transfer has failed and will not resume. Callback(payload []byte, t *FilePartTracker, err error) }
FileTransferReceiveProgressCallback is a bindings-layer interface that is called with the progress of a received file.
type FileTransferSentProgressCallback ¶
type FileTransferSentProgressCallback interface { // Callback is called when a file part is sent or an error occurs. Once a // transfer completes, it should be closed using [FileTransfer.CloseSend]. // // Parameters: // - payload - JSON of [Progress], which describes the progress of the // current transfer. // - t - file part tracker that allows the lookup of the status of // individual file parts. // - err - Fatal errors during sending. If an error is returned, the // transfer has failed and will not resume. It must be cleared using // [FileTransfer.CloseSend]. Callback(payload []byte, t *FilePartTracker, err error) }
FileTransferSentProgressCallback is a bindings-layer interface that contains a callback that is called when the sent progress updates.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group structure contains the identifying and membership information of a group chat.
func DeserializeGroup ¶
DeserializeGroup converts the results of Group.Serialize into a Group so that its methods can be called.
func (*Group) GetCreatedMS ¶
GetCreatedMS returns the time the group was created in milliseconds. This is also the time the group requests were sent.
func (*Group) GetCreatedNano ¶
GetCreatedNano returns the time the group was created in nanoseconds. This is also the time the group requests were sent.
func (*Group) GetInitMessage ¶
GetInitMessage returns initial message sent with the group request.
func (*Group) GetMembership ¶
GetMembership retrieves a list of group members. The list is in order; the first contact is the leader/creator of the group. All subsequent members are ordered by their ID.
Returns:
- []byte - JSON marshalled [group.Membership], which is an array of [group.Member].
Example JSON [group.Membership] return:
[ { "ID": "U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID", "DhKey": { "Value": 3534334367214237261, "Fingerprint": 16801541511233098363 } }, { "ID": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", "DhKey": { "Value": 7497468244883513247, "Fingerprint": 16801541511233098363 } } ]
type GroupChat ¶
type GroupChat struct {
// contains filtered or unexported fields
}
GroupChat is a binding-layer group chat manager.
func NewGroupChat ¶
func NewGroupChat(e2eID int, requestFunc GroupRequest, processor GroupChatProcessor) (*GroupChat, error)
NewGroupChat creates a bindings-layer group chat manager.
Parameters:
- e2eID - e2e object ID in the tracker.
- requestFunc - a callback to handle group chat requests.
- processor - the group chat message processor.
func (*GroupChat) GetGroup ¶
GetGroup returns the group with the group ID. If no group exists, then the error "failed to find group" is returned.
Parameters:
- groupId - The byte data representing a group ID (a byte marshalled id.ID). This can be pulled from a marshalled GroupReport.
Returns:
- Group - The bindings-layer representation of a group.
func (*GroupChat) GetGroups ¶
GetGroups returns a list of group IDs that the user is a member of.
Returns:
- []byte - a JSON marshalled []*id.ID representing all group ID's.
func (*GroupChat) JoinGroup ¶
JoinGroup allows a user to join a group when a request is received. If an error is returned, handle it properly first; you may then retry later with the same trackedGroupId.
Parameters:
- serializedGroupData - the result of calling Group.Serialize() on any Group object returned over the bindings
func (*GroupChat) LeaveGroup ¶
LeaveGroup deletes a group so a user no longer has access.
Parameters:
- groupId - the byte data representing a group ID. This can be pulled from a marshalled GroupReport.
func (*GroupChat) MakeGroup ¶
MakeGroup creates a new Group and sends a group request to all members in the group.
Parameters:
- membershipBytes - the JSON marshalled list of []*id.ID; it contains the IDs of members the user wants to add to the group.
- message - the initial message sent to all members in the group. This is an optional parameter and may be nil.
- name - the name of the group decided by the creator. This is an optional parameter and may be nil. If nil the group will be assigned the default name.
Returns:
- []byte - the JSON marshalled bytes of the GroupReport object, which can be passed into Cmix.WaitForRoundResult to see if the group request message send succeeded.
func (*GroupChat) ResendRequest ¶
ResendRequest resends a group request to all members in the group.
Parameters:
- groupId - a byte representation of a group's ID. This can be found in the report returned by GroupChat.MakeGroup.
Returns:
- []byte - the JSON marshalled bytes of the GroupReport object, which can be passed into WaitForRoundResult to see if the group request message send succeeded.
func (*GroupChat) Send ¶
Send is the bindings-level function for sending to a group.
Parameters:
- groupId - the byte data representing a group ID. This can be pulled from marshalled GroupReport.
- message - the message that the user wishes to send to the group.
- tag - the tag associated with the message. This tag may be empty.
Returns:
- []byte - the JSON marshalled bytes of the GroupSendReport object, which can be passed into Cmix.WaitForRoundResult to see if the group message send succeeded.
type GroupChatMessage ¶
type GroupChatMessage struct { // GroupId is the ID of the group that this message was sent on. GroupId []byte // SenderId is the ID of the sender of this message. SenderId []byte // MessageId is the ID of this group message. MessageId []byte // Payload is the content of the message. Payload []byte // Timestamp is the time this message was sent on. Timestamp int64 }
GroupChatMessage is the bindings layer representation of the [groupChat.MessageReceive].
GroupChatMessage Example JSON:
{ "GroupId": "AAAAAAAJlasAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE", "SenderId": "AAAAAAAAB8gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", "MessageId": "Zm9ydHkgZml2ZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "Payload": "Zm9ydHkgZml2ZQ==", "Timestamp": 1663009269474079000 }
type GroupChatProcessor ¶
type GroupChatProcessor interface { Process(decryptedMessage, msg, receptionId []byte, ephemeralId, roundId int64, roundUrl string, err error) fmt.Stringer }
GroupChatProcessor manages the handling of received group chat messages. The decryptedMessage field will be a JSON marshalled GroupChatMessage.
type GroupReport ¶
type GroupReport struct { Id []byte RoundsList RoundURL string Status int }
GroupReport is returned when creating a new group and contains the ID of the group, a list of rounds that the group requests were sent on, and the status of the send operation.
Example GroupReport JSON:
{ "Id": "AAAAAAAAAM0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE", "Rounds": [25, 64], "RoundURL": "https://dashboard.xx.network/rounds/25?xxmessenger=true", "Status": 1 }
type GroupRequest ¶
type GroupRequest interface {
Callback(g *Group)
}
GroupRequest is a bindings-layer interface that handles a group reception.
Parameters:
- g - a bindings layer Group object.
type GroupSendReport ¶
type GroupSendReport struct { RoundsList RoundURL string Timestamp int64 MessageID []byte }
GroupSendReport is returned when sending a group message. It contains the round ID sent on and the timestamp of the send operation.
Example GroupSendReport JSON:
{ "Rounds": [25, 64], "RoundURL": "https://dashboard.xx.network/rounds/25?xxmessenger=true", "Timestamp": 1662577352813112000, "MessageID": "69ug6FA50UT2q6MWH3hne9PkHQ+H9DnEDsBhc0m0Aww=" }
type IsReadyInfo ¶
IsReadyInfo contains information on if the network is ready and how close it is to being ready.
Example JSON:
{ "IsReady": true, "HowClose": 0.534 }
type Listener ¶
type Listener interface { // Hear is called to receive a message in the UI. // // Parameters: // - item - JSON marshalled Message object Hear(item []byte) // Name returns a name; used for debugging. Name() string }
Listener provides a callback to hear a message.
An object implementing this interface can be called back when the client gets a message of the type that the registerer specified at registration time.
type Message ¶
type Message struct { MessageType int ID []byte Payload []byte Sender []byte RecipientID []byte EphemeralID int64 Timestamp int64 // Message timestamp of when the user sent Encrypted bool RoundId int RoundURL string }
Message is the bindings' representation of a receive.Message.
JSON example:
{ "MessageType":1, "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", "EphemeralID":17,"Timestamp":1653580439357351000, "Encrypted":false, "RoundId":19 }
type MessageDeliveryCallback ¶
type MessageDeliveryCallback interface {
EventCallback(delivered, timedOut bool, roundResults []byte)
}
MessageDeliveryCallback gets called on the determination if all events related to a message send were successful.
If delivered == true, timedOut == false && roundResults != nil
If delivered == false, roundResults == nil
If timedOut == true, delivered == false && roundResults == nil
type NetworkHealthCallback ¶
type NetworkHealthCallback interface {
Callback(bool)
}
NetworkHealthCallback contains a callback that is used to receive notification if network health changes.
type NodeRegistrationReport ¶
NodeRegistrationReport is the report structure which Cmix.GetNodeRegistrationStatus returns JSON marshalled.
type NotificationReport ¶
type NotificationReport struct { // ForMe determines whether this value is for the user. If it is // false, this report may be ignored. ForMe bool // Type is the type of notification. The list can be seen Type string // Source is the source of the notification. Source []byte }
NotificationReport is the bindings' representation for notifications for this user.
Example NotificationReport JSON:
{ "ForMe": true, "Type": "e2e", "Source": "dGVzdGVyMTIzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" }
Given the Type, the Source value will have specific contextual meanings. Below is a table that will define the contextual meaning of the Source field given all possible Type fields.
TYPE | SOURCE | DESCRIPTION ----------+--------------------+-------------------------------------------------------- "default" | recipient user ID | A message with no association. "request" | sender user ID | A channel request has been received, from Source. "reset" | sender user ID | A channel reset has been received. "confirm" | sender user ID | A channel request has been accepted. "silent" | sender user ID | A message where the user should not be notified. "e2e" | sender user ID | A reception of an E2E message. "group" | group ID | A reception of a group chat message. "endFT" | sender user ID | The last message sent confirming end of file transfer. "groupRQ" | sender user ID | A request from Source to join a group chat.
type NotificationReports ¶
type NotificationReports []NotificationReport
NotificationReports is a list of [NotificationReport]s. This will be returned via GetNotificationsReport as a JSON marshalled byte data.
Example JSON:
[ { "ForMe": true, // boolean "Type": "e2e", // string "Source": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" // bytes of id.ID encoded as base64 string }, { "ForMe": true, "Type": "e2e", "Source": "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" }, { "ForMe": true, "Type": "e2e", "Source": "AAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" } ]
type Processor ¶
type Processor interface { Process(message []byte, receptionId []byte, ephemeralId int64, roundId int64) fmt.Stringer }
Processor is the bindings-specific interface for message.Processor methods.
type Progress ¶
type Progress struct { TransferID *ftCrypto.TransferID // Transfer ID Completed bool // Status of transfer (true if done) Transmitted int // Number of file parts sent/received Total int // Total number of file parts }
Progress contains the progress information of a transfer. It is returned by [FileTransferSentProgressCallback.Callback] and [FileTransferReceiveProgressCallback.Callback].
Example JSON:
{ "TransferID": "RyJcMqtI3IIM1+YMxRwCcFiOX6AGuIzS+vQaPnqXVT8=", "Completed": false, "Transmitted": 128, "Total": 2048 }
type ReceiveFileCallback ¶
type ReceiveFileCallback interface { // Callback is called when a new file transfer is received. // // Parameters: // - payload - JSON of [ReceivedFile], which contains information about the // incoming file transfer. Callback(payload []byte) }
ReceiveFileCallback is a bindings-layer interface that contains a callback that is called when a file is received.
type ReceivedChannelMessageReport ¶
type ReceivedChannelMessageReport struct { ChannelId []byte MessageId []byte MessageType int Nickname string PubKey []byte Codeset int Content []byte Timestamp int64 Lease int64 RoundsList }
ReceivedChannelMessageReport is a report structure returned via the ChannelMessageReceptionCallback. This report gives the context for the channel the message was sent to and the message itself. This is returned via the callback as JSON marshalled bytes.
JSON Example:
{ "ChannelId": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "MessageId": "3S6DiVjWH9mLmjy1oaam/3x45bJQzOW6u2KgeUn59wA=", "ReplyTo":"cxMyGUFJ+Ff1Xp2X+XkIpOnNAQEZmv8SNP5eYH4tCik=", "MessageType": 42, "SenderUsername": "hunter2", "Content": "YmFuX2JhZFVTZXI=", "Timestamp": 1662502150335283000, "Lease": 25, "Rounds": [ 1, 4, 9], }
type ReceivedFile ¶
type ReceivedFile struct { TransferID *ftCrypto.TransferID // ID of the file transfer SenderID *id.ID // ID of the file sender Preview []byte // A preview of the file Name string // Name of the file Type string // String that indicates type of file Size int // The size of the file, in bytes }
ReceivedFile contains the metadata of a new received file transfer. It is received from a sender on a new file transfer. It is returned by [ReceiveFileCallback.Callback].
Example JSON:
{ "TransferID": "0U+QY1nMOUzQGxGpqZyxDw8Cd6+qm8t870CzLtVoUM8=", "SenderID": "UL3+S8XdJHAfUtCUm7iZMxW8orR8Nd5JM9Ky7/5jds8D", "Preview": "aXQNcyBtZSBhIHByZXZpZXc=", "Name": "testfile.txt", "Type": "text file", "Size": 2048 }
type ReceptionIdentity ¶
type ReceptionIdentity struct { ID []byte // User ID (base64) RSAPrivatePem []byte // RSA Private key (PEM format) Salt []byte // Salt for identity (base64) DHKeyPrivate []byte // DH Private key E2eGrp []byte }
ReceptionIdentity struct.
JSON example:
{ "ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" "E2eGrp": "eyJnZW4iOiIyIiwicHJpbWUiOiJlMmVlOTgzZDAzMWRjMWRiNmYxYTdhNjdkZjBlOWE4ZTU1NjFkYjhlOGQ0OTQxMzM5NGMwNDliN2E4YWNjZWRjMjk4NzA4ZjEyMTk1MWQ5Y2Y5MjBlYzVkMTQ2NzI3YWE0YWU1MzViMDkyMmM2ODhiNTViM2RkMmFlZGY2YzAxYzk0NzY0ZGFiOTM3OTM1YWE4M2JlMzZlNjc3NjA3MTNhYjQ0YTYzMzdjMjBlNzg2MTU3NWU3NDVkMzFmOGI5ZTlhZDg0MTIxMThjNjJhM2UyZTI5ZGY0NmIwODY0ZDBjOTUxYzM5NGE1Y2JiZGM2YWRjNzE4ZGQyYTNlMDQxMDIzZGJiNWFiMjNlYmI0NzQyZGU5YzE2ODdiNWIzNGZhNDhjMzUyMTYzMmM0YTUzMGU4ZmZiMWJjNTFkYWRkZjQ1M2IwYjI3MTdjMmJjNjY2OWVkNzZiNGJkZDVjOWZmNTU4ZTg4ZjI2ZTU3ODUzMDJiZWRiY2EyM2VhYzVhY2U5MjA5NmVlOGE2MDY0MmZiNjFlOGYzZDI0OTkwYjhjYjEyZWU0NDhlZWY3OGUxODRjNzI0MmRkMTYxYzc3MzhmMzJiZjI5YTg0MTY5ODk3ODgyNWI0MTExYjRiYzNlMWUxOTg0NTUwOTU5NTgzMzNkNzc2ZDhiMmJlZWVkM2ExYTFhMjIxYTZlMzdlNjY0YTY0YjgzOTgxYzQ2ZmZkZGMxYTQ1ZTNkNTIxMWFhZjhiZmJjMDcyNzY4YzRmNTBkN2Q3ODAzZDJkNGYyNzhkZTgwMTRhNDczMjM2MzFkN2UwNjRkZTgxYzBjNmJmYTQzZWYwZTY5OTg4NjBmMTM5MGI1ZDNmZWFjYWYxNjk2MDE1Y2I3OWMzZjljMmQ5M2Q5NjExMjBjZDBlNWYxMmNiYjY4N2VhYjA0NTI0MWY5Njc4OWMzOGU4OWQ3OTYxMzhlNjMxOWJlNjJlMzVkODdiMTA0OGNhMjhiZTM4OWI1NzVlOTk0ZGNhNzU1NDcxNTg0YTA5ZWM3MjM3NDJkYzM1ODczODQ3YWVmNDlmNjZlNDM4NzMifQ==" }
type ReporterFunc ¶
ReporterFunc is a bindings-layer interface that receives info from the Event Manager.
Parameters:
- payload - JSON marshalled EventReport object
type RestlikeCallback ¶
RestlikeCallback is the public function type bindings can use to make an asynchronous restlike request.
Parameters:
- []byte - JSON marshalled restlike.Message
- error - an error (the results of calling json.Marshal on the message)
type RestlikeMessage ¶
type RestlikeMessage struct { Version uint32 Headers []byte Content []byte Method int URI string Error string }
RestlikeMessage is the bindings' representation of a restlike.Message
JSON example:
{ "Version":1, "Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", "Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", "Method":2, "URI":"xx://CmixRestlike/rest", "Error":"" }
type RoundsList ¶
type RoundsList struct {
Rounds []uint64
}
RoundsList contains a list of round IDs.
JSON Example:
[1001,1003,1006]
func (RoundsList) Marshal ¶
func (rl RoundsList) Marshal() ([]byte, error)
Marshal JSON marshals the RoundsList.
type ShareURL ¶
type ShareURL struct {}
ShareURL is returned from ChannelsManager.GetShareURL. It includes the channel's share URL and password, if it needs one.
JSON example for a public channel:
{ "url": "https://internet.speakeasy.tech/?0Name=name&1Description=desc&2Level=Public&3Created=1665489600000000000&e=%2FWNZvuHPuv%2Bx23XbZXVNzCi7y8rUSxkh75MpR9UrsCo%3D&k=ddX1CH52xH%2F%2Fb6lKrbvDghdSmCQr90ktsOAZ%2FrhEonI%3D&l=2&m=0&p=328&s=%2FD%2FoQP2mio3XAWfhmWF0xmZrpj4nAsb9JLXj%2B0Mzq9Y%3D&v=1", "password": "" }
JSON example for a private channel:
{ "url": "https://internet.speakeasy.tech/?0Name=name&1Description=desc&3Created=1665489600000000000&d=5AZQirb%2FYrmUITLn%2FFzCaGek1APfJnd2q0KwORGj%2BnbGg26kTShG6cfD3w6c%2BA3RDzxuKDSDN0zS4n1LbjiGe0KYdb8eJVeyRZtld516hfojNDXNAwZq8zbeZy4jjbF627fcLHRNS%2FaII4uJ5UB3gLUeBeZGraaybCCu3FIj1N4RbcJ5cQgT7hBf93bHmJc%3D&m=0&v=1", "password": "tribune gangrene labrador italics nutmeg process exhume legal" }
JSON example for a secret channel:
{ "url": "https://internet.speakeasy.tech/?d=w5evLthm%2Fq2j11g6PPtV0QoLaAqNCIER0OqxhxL%2FhpGVJI0057ZPgGBrKoJNE1%2FdoVuU35%2FhohuW%2BWvGlx6IuHoN6mDj0HfNj6Lo%2B8GwIaD6jOEwUcH%2FMKGsKnoqFsMaMPd5gXYgdHvA8l5SRe0gSCVqGKUaG6JgL%2FDu4iyjY7v4ykwZdQ7soWOcBLHDixGEkVLpwsCrPVHkT2K0W6gV74GIrQ%3D%3D&m=0&v=1", "password": "frenzy contort staple thicket consuming affiliate scion demeanor" }
type SingleUseCallback ¶
SingleUseCallback func is passed into Listen and called when messages are received.
Parameters:
- callbackReport - the JSON marshalled bytes of the SingleUseCallbackReport object, which can be passed into Cmix.WaitForRoundResult to see if the send operation succeeded.
type SingleUseCallbackReport ¶
type SingleUseCallbackReport struct { RoundsList RoundURL string Payload []byte Partner *id.ID EphID int64 ReceptionID *id.ID }
SingleUseCallbackReport is the bindings-layer struct used to represent single -use messages received by a callback passed into single.Listen.
SingleUseCallbackReport JSON example:
{ "Rounds":[1,5,9], "RoundURL": "https://dashboard.xx.network/rounds/25?xxmessenger=true", "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", "Partner":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", "EphID":1655533, "ReceptionID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} }
type SingleUseResponse ¶
SingleUseResponse is the public facing callback function passed by bindings clients into TransmitSingleUse.
Parameters:
- callbackReport - the JSON marshalled bytes of the SingleUseResponseReport object, which can be passed into Cmix.WaitForRoundResult to see if the send operation succeeded.
type SingleUseResponseReport ¶
type SingleUseResponseReport struct { RoundsList RoundURL string Payload []byte ReceptionID *id.ID EphID int64 Err error }
SingleUseResponseReport is the bindings-layer struct used to represent information passed to the single.Response callback interface in response to single.TransmitRequest.
SingleUseResponseReport JSON example:
{ "Rounds":[1,5,9], "RoundURL": "https://dashboard.xx.network/rounds/25?xxmessenger=true", "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", "EphID":1655533, "ReceptionID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"}, "Err":"", }
type SingleUseSendReport ¶
type SingleUseSendReport struct { RoundsList RoundURL string ReceptionID *id.ID EphID int64 }
SingleUseSendReport is the bindings-layer struct used to represent information returned by single.TransmitRequest.
SingleUseSendReport JSON example:
{ "Rounds":[1,5,9], "RoundURL": "https://dashboard.xx.network/rounds/25?xxmessenger=true", "EphID":1655533, "ReceptionID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} }
type Stopper ¶
type Stopper interface {
Stop()
}
Stopper is a public interface returned by Listen, allowing users to stop the registered listener.
func Listen ¶
func Listen(e2eID int, tag string, cb SingleUseCallback) (Stopper, error)
Listen starts a single-use listener on a given tag using the passed in E2e object and SingleUseCallback func.
Parameters:
- e2eID - ID of the e2e object in the tracker
- tag - identifies the single-use message
- cb - the callback that will be called when a response is received
Returns:
- Stopper - an interface containing a function used to stop the listener
type TrackServicesCallback ¶
TrackServicesCallback is the callback for Cmix.TrackServices. This will pass to the user a JSON-marshalled list of backend services. If there was an error retrieving or marshalling the service list, there is an error for the second parameter which will be non-null.
Parameters:
- marshalData - JSON marshalled bytes of message.ServiceList, which is an array of id.ID and message.Service.
- err - JSON unmarshalling error
Example JSON:
[ { "Id": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // bytes of id.ID encoded as base64 string "Services": [ { "Identifier": "AQID", // bytes encoded as base64 string "Tag": "TestTag 1", // string "Metadata": "BAUG" // bytes encoded as base64 string } ] }, { "Id": "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", "Services": [ { "Identifier": "AQID", "Tag": "TestTag 2", "Metadata": "BAUG" } ] }, ]
type UdLookupCallback ¶
UdLookupCallback contains the callback called by LookupUD that returns the contact that matches the passed in ID.
Parameters:
- contactBytes - the marshalled bytes of contact.Contact returned from the lookup, or nil if an error occurs
- err - any errors that occurred in the lookup
type UdMultiLookupCallback ¶
type UdMultiLookupCallback interface {
Callback(contactListJSON []byte, failedIDs []byte, err error)
}
UdMultiLookupCallback contains the callback called by MultiLookupUD that returns the contacts which match the passed in IDs.
Parameters:
contactListJSON - the JSON marshalled bytes of []contact.Contact, or nil if an error occurs.
JSON Example: { "<xxc(2)F8dL9EC6gy+RMJuk3R+Au6eGExo02Wfio5cacjBcJRwDEgB7Ugdw/BAr6RkCABkWAFV1c2VybmFtZTA7c4LzV05sG+DMt+rFB0NIJg==xxc>", "<xxc(2)eMhAi/pYkW5jCmvKE5ZaTglQb+fTo1D8NxVitr5CCFADEgB7Ugdw/BAr6RoCABkWAFV1c2VybmFtZTE7fElAa7z3IcrYrrkwNjMS2w==xxc>", "<xxc(2)d7RJTu61Vy1lDThDMn8rYIiKSe1uXA/RCvvcIhq5Yg4DEgB7Ugdw/BAr6RsCABkWAFV1c2VybmFtZTI7N3XWrxIUpR29atpFMkcR6A==xxc>" }
failedIDs - JSON marshalled list of []*id.ID objects which failed lookup
err - any errors that occurred in the multilookup.
type UdNetworkStatus ¶
type UdNetworkStatus interface { // UdNetworkStatus returns: // - int - a xxdk.Status int UdNetworkStatus() int }
UdNetworkStatus contains the UdNetworkStatus, which is a bindings-level interface for ud.udNetworkStatus.
type UdSearchCallback ¶
UdSearchCallback contains the callback called by SearchUD that returns a list of contact.Contact objects that match the list of facts passed into SearchUD.
Parameters:
contactListJSON - the JSON marshalled bytes of []contact.Contact, or nil if an error occurs.
JSON Example: { "<xxc(2)F8dL9EC6gy+RMJuk3R+Au6eGExo02Wfio5cacjBcJRwDEgB7Ugdw/BAr6RkCABkWAFV1c2VybmFtZTA7c4LzV05sG+DMt+rFB0NIJg==xxc>", "<xxc(2)eMhAi/pYkW5jCmvKE5ZaTglQb+fTo1D8NxVitr5CCFADEgB7Ugdw/BAr6RoCABkWAFV1c2VybmFtZTE7fElAa7z3IcrYrrkwNjMS2w==xxc>", "<xxc(2)d7RJTu61Vy1lDThDMn8rYIiKSe1uXA/RCvvcIhq5Yg4DEgB7Ugdw/BAr6RsCABkWAFV1c2VybmFtZTI7N3XWrxIUpR29atpFMkcR6A==xxc>" }
err - any errors that occurred in the search.
type UpdateBackupFunc ¶
type UpdateBackupFunc interface {
UpdateBackup(encryptedBackup []byte)
}
UpdateBackupFunc contains a function callback that returns new backups.
type UserDiscovery ¶
type UserDiscovery struct {
// contains filtered or unexported fields
}
UserDiscovery is a bindings-layer struct that wraps an ud.Manager interface.
func NewOrLoadUd ¶
func NewOrLoadUd(e2eID int, follower UdNetworkStatus, username string, registrationValidationSignature, cert, contactFile []byte, address string) ( *UserDiscovery, error)
NewOrLoadUd loads an existing UserDiscovery from storage or creates a new UserDiscovery if there is no storage data. Regardless of storage state, the UserDiscovery object returned will be registered with the User Discovery service. If the user is not already registered, a call to register will occur internally. If the user is already registered, this call will simply load state and return to you a UserDiscovery object. Some parameters are required for registering with the service, but are not required if the user is already registered. These will be noted in the parameters section as "SEMI-REQUIRED".
Certain parameters are required every call to this function. These parameters are listed below as "REQUIRED". For example, parameters need be provided to specify how to connect to the User Discovery service. These parameters specifically may be used to contact either the UD server hosted by the xx network team or a custom third-party operated server. For the former, all the information may be fetched from the NDF using the bindings. These fetch methods are detailed in the parameters section.
Params
- e2eID - REQUIRED. The tracked e2e object ID. This is returned by E2e.GetID.
- follower - REQUIRED. Network follower function. This will check if the network follower is running.
- username - SEMI-REQUIRED. The username the user wants to register with UD. If the user is already registered, this field may be blank. If the user is not already registered, these field must be populated with a username that meets the requirements of the UD service. For example, in the xx network's UD service, the username must not be registered by another user.
- registrationValidationSignature - SEMI-REQUIRED. A signature provided by the xx network (i.e. the client registrar). If the user is not already registered, this field is required in order to register with the xx network. This may be nil if the user is already registered or connecting to a third-party UD service unassociated with the xx network.
- cert - REQUIRED. The TLS certificate for the UD server this call will connect with. If this is nil, you may not contact the UD server hosted by the xx network. Third-party services may vary. You may use the UD server run by the xx network team by using E2e.GetUdCertFromNdf.
- contactFile - REQUIRED. The data within a marshalled contact.Contact. This represents the contact file of the server this call will connect with. If this is nil, you may not contact the UD server hosted by the xx network. Third-party services may vary. You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf.
- address - REQUIRED. The IP address of the UD server this call will connect with. You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf. If this is nil, you may not contact the UD server hosted by the xx network. Third-party services may vary.
Returns
- A Manager object which is registered to the specified UD service.
func NewUdManagerFromBackup ¶
func NewUdManagerFromBackup(e2eID int, follower UdNetworkStatus, cert, contactFile []byte, address string) (*UserDiscovery, error)
NewUdManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered. Confirmed facts have already been restored via the call NewCmixFromBackup.
Parameters:
- e2eID - e2e object ID in the tracker
- follower - network follower func wrapped in UdNetworkStatus
- cert - the TLS certificate for the UD server this call will connect with. You may use the UD server run by the xx network team by using E2e.GetUdCertFromNdf.
- contactFile - the data within a marshalled contact.Contact. This represents the contact file of the server this call will connect with. You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf.
- address - the IP address of the UD server this call will connect with. You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf.
func (*UserDiscovery) ConfirmFact ¶
func (ud *UserDiscovery) 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 (*UserDiscovery) GetContact ¶
func (ud *UserDiscovery) GetContact() ([]byte, error)
GetContact returns the marshalled bytes of the contact.Contact for UD as retrieved from the NDF.
func (*UserDiscovery) GetFacts ¶
func (ud *UserDiscovery) GetFacts() []byte
GetFacts returns a JSON marshalled list of fact.Fact objects that exist within the Store's registeredFacts map.
func (*UserDiscovery) GetID ¶
func (ud *UserDiscovery) GetID() int
GetID returns the udTracker ID for the UserDiscovery object.
func (*UserDiscovery) PermanentDeleteAccount ¶
func (ud *UserDiscovery) PermanentDeleteAccount(factJson []byte) 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.
Parameters:
- factJson - a JSON marshalled fact.Fact
func (*UserDiscovery) RemoveFact ¶
func (ud *UserDiscovery) RemoveFact(factJson []byte) 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.
Parameters:
- factJson - a JSON marshalled fact.Fact
func (*UserDiscovery) SendRegisterFact ¶
func (ud *UserDiscovery) SendRegisterFact(factJson []byte) (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.
Parameters:
- factJson - a JSON marshalled fact.Fact
Source Files ¶
- authenticatedConnection.go
- backup.go
- channels.go
- cmix.go
- connect.go
- delivery.go
- dummy.go
- e2e.go
- e2eAuth.go
- e2eHandler.go
- errors.go
- fileTransfer.go
- follow.go
- group.go
- identity.go
- listener.go
- logging.go
- ndf.go
- notifications.go
- params.go
- restlike.go
- restlikeSingle.go
- secrets.go
- single.go
- timeNow.go
- ud.go
- version.go