Documentation ¶
Index ¶
- Constants
- func AsyncRequestRestLike(e2eID int, recipient, request, paramsJSON []byte, cb RestlikeCallback) error
- func CheckNoMessageErr(err string) bool
- func ConstructIdentity(pubKey []byte, codesetVersion int) ([]byte, error)
- func CreateUserFriendlyErrorMessage(errStr string) string
- func DecodeDMShareURL(url string) ([]byte, error)
- func DecodeInviteURL(url, password string) (string, error)
- func DecodePrivateURL(url, password string) (string, error)
- func DecodePublicURL(url string) (string, error)
- func DeriveRPCPublicKey(privateKey []byte) ([]byte, error)
- func DownloadAndVerifySignedNdfWithUrl(url, cert string) ([]byte, error)
- func EnableGrpcLogs(writer LogWriter)
- func GenerateChannelIdentity(cmixID int) ([]byte, error)
- func GenerateRandomRPCKey(cMixID int) ([]byte, error)
- func GenerateRandomReceptionID(cMixID int) ([]byte, error)
- func GenerateSecret(numBytes int) []byte
- func GetChannelInfo(prettyPrint string) ([]byte, error)
- func GetChannelJSON(prettyPrint string) ([]byte, error)
- func GetChannelNotificationReportsForMe(notificationFilterJSON []byte, notificationDataCSV string) ([]byte, error)
- func GetDefaultCMixParams() []byte
- func GetDefaultE2EParams() []byte
- func GetDefaultE2eFileTransferParams() []byte
- func GetDefaultFileTransferParams() []byte
- func GetDefaultSingleUseParams() []byte
- func GetDependencies() string
- func GetDmNotificationReportsForMe(notificationFilterJSON []byte, notificationDataCSV string) ([]byte, error)
- func GetFactsFromContact(marshaledContact []byte) ([]byte, error)
- func GetGitVersion() string
- func GetIDFromContact(marshaledContact []byte) ([]byte, error)
- func GetNoMessageErr() string
- func GetPubkeyFromContact(marshaledContact []byte) ([]byte, error)
- func GetPublicChannelIdentity(marshaledPublic []byte) ([]byte, error)
- func GetPublicChannelIdentityFromPrivate(marshaledPrivate []byte) ([]byte, error)
- func GetShareUrlType(url string) (int, error)
- func GetVersion() string
- func ImportPrivateIdentity(password string, data []byte) ([]byte, error)
- func IsNicknameValid(nickname 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 NewSynchronizedCmix(ndfJSON, storageDir, remoteStoragePathPrefix string, password []byte, ...) 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 TimeSource)
- func StoreReceptionIdentity(key string, identity []byte, cmixId int) error
- func SupportedEmojis() ([]byte, error)
- func SupportedEmojisMap() ([]byte, error)
- func TransmitSingleUse(e2eID int, recipient []byte, tag string, payload, paramsJSON []byte, ...) ([]byte, error)
- func UpdateCommonErrors(jsonFile string) error
- func ValidForever() int
- func ValidateReaction(reaction string) error
- type AdminKeysUpdateJSON
- type AuthCallbacks
- type AuthenticatedConnection
- type Backup
- type BackupReport
- type ChFilePartTracker
- type ChannelInfo
- type ChannelMessageReceptionCallback
- type ChannelSendReport
- type ChannelUICallbacks
- type ChannelUpdateJSON
- type ChannelsFileTransfer
- func (cft *ChannelsFileTransfer) CloseSend(fileIDBytes []byte) error
- func (cft *ChannelsFileTransfer) Download(fileInfoJSON []byte, progressCB FtReceivedProgressCallback, periodMS int) ([]byte, error)
- func (cft *ChannelsFileTransfer) GetExtensionBuilderID() int
- func (cft *ChannelsFileTransfer) MaxFileNameLen() int
- func (cft *ChannelsFileTransfer) MaxFileSize() int
- func (cft *ChannelsFileTransfer) MaxFileTypeLen() int
- func (cft *ChannelsFileTransfer) MaxPreviewSize() int
- func (cft *ChannelsFileTransfer) RegisterReceivedProgressCallback(fileIDBytes []byte, progressCB FtReceivedProgressCallback, periodMS int) error
- func (cft *ChannelsFileTransfer) RegisterSentProgressCallback(fileIDBytes []byte, progressCB FtSentProgressCallback, periodMS int) error
- func (cft *ChannelsFileTransfer) RetryUpload(fileIDBytes []byte, progressCB FtSentProgressCallback, periodMS int) error
- func (cft *ChannelsFileTransfer) Send(channelIdBytes, fileLinkJSON []byte, fileName, fileType string, preview []byte, ...) ([]byte, error)
- func (cft *ChannelsFileTransfer) Upload(fileData []byte, retry float32, progressCB FtSentProgressCallback, ...) ([]byte, error)
- type ChannelsManager
- func LoadChannelsManager(cmixID int, storageTag string, eventBuilder EventModelBuilder, ...) (*ChannelsManager, error)
- func LoadChannelsManagerGoEventModel(cmixID int, storageTag string, goEventBuilder channels.EventModelBuilder, ...) (*ChannelsManager, error)
- func LoadChannelsManagerMobile(cmixID int, storageTag, dbFilePath string, extensionBuilderIDsJSON []byte, ...) (*ChannelsManager, error)
- func NewChannelsManager(cmixID int, privateIdentity []byte, eventBuilder EventModelBuilder, ...) (*ChannelsManager, error)
- func NewChannelsManagerGoEventModel(cmixID int, privateIdentity, extensionBuilderIDsJSON []byte, ...) (*ChannelsManager, error)
- func NewChannelsManagerMobile(cmixID int, privateIdentity []byte, dbFilePath string, ...) (*ChannelsManager, error)
- func (cm *ChannelsManager) AreDMsEnabled(channelIdBytes []byte) (bool, error)
- func (cm *ChannelsManager) DeleteChannelAdminKey(channelIdBytes []byte) error
- func (cm *ChannelsManager) DeleteMessage(channelIdBytes, targetMessageIdBytes, cmixParamsJSON []byte) ([]byte, error)
- func (cm *ChannelsManager) DeleteNickname(channelIDBytes []byte) error
- func (cm *ChannelsManager) DisableDirectMessages(channelIdBytes []byte) error
- func (cm *ChannelsManager) EnableDirectMessages(channelIdBytes []byte) error
- func (cm *ChannelsManager) ExportChannelAdminKey(channelIDBytes []byte, encryptionPassword string) ([]byte, error)
- func (cm *ChannelsManager) ExportPrivateIdentity(password string) ([]byte, error)
- func (cm *ChannelsManager) GenerateChannel(name, description string, privacyLevel int) (string, error)
- func (cm *ChannelsManager) GetChannels() ([]byte, error)
- func (cm *ChannelsManager) GetID() int
- func (cm *ChannelsManager) GetIdentity() ([]byte, error)
- func (cm *ChannelsManager) GetMutedUsers(channelIDBytes []byte) ([]byte, error)
- func (cm *ChannelsManager) GetNickname(channelIDBytes []byte) (string, error)
- func (cm *ChannelsManager) GetNotificationLevel(channelIDBytes []byte) (int, error)
- func (cm *ChannelsManager) GetNotificationStatus(channelIDBytes []byte) (int, error)
- func (cm *ChannelsManager) GetShareURL(cmixID int, host string, maxUses int, channelIdBytes []byte) ([]byte, error)
- func (cm *ChannelsManager) GetStorageTag() string
- func (cm *ChannelsManager) ImportChannelAdminKey(channelIdBytes []byte, encryptionPassword string, encryptedPrivKey []byte) error
- func (cm *ChannelsManager) IsChannelAdmin(channelIDBytes []byte) (bool, error)
- func (cm *ChannelsManager) JoinChannel(channelPretty string) ([]byte, error)
- func (cm *ChannelsManager) LeaveChannel(channelIdBytes []byte) error
- func (cm *ChannelsManager) MuteUser(channelIdBytes, mutedUserPubKeyBytes []byte, undoAction bool, validUntilMS int, ...) ([]byte, error)
- func (cm *ChannelsManager) Muted(channelIDBytes []byte) (bool, error)
- func (cm *ChannelsManager) PinMessage(channelIdBytes, targetMessageIdBytes []byte, undoAction bool, validUntilMS int, ...) ([]byte, error)
- func (cm *ChannelsManager) RegisterReceiveHandler(messageType int, listenerCb ChannelMessageReceptionCallback, name string, ...) error
- func (cm *ChannelsManager) ReplayChannel(channelIdBytes []byte) error
- func (cm *ChannelsManager) SendAdminGeneric(channelIdBytes []byte, messageType int, message []byte, validUntilMS int64, ...) ([]byte, error)
- func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int, message []byte, validUntilMS int64, ...) ([]byte, error)
- func (cm *ChannelsManager) SendInvite(channelIdBytes, inviteToJson []byte, message string, host string, ...) ([]byte, error)
- func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string, validUntilMS int64, ...) ([]byte, error)
- func (cm *ChannelsManager) SendReaction(channelIdBytes []byte, reaction string, messageToReactTo []byte, ...) ([]byte, error)
- func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string, messageToReactTo []byte, ...) ([]byte, error)
- func (cm *ChannelsManager) SendSilent(channelIdBytes []byte, validUntilMS int64, cmixParamsJSON []byte) ([]byte, error)
- func (cm *ChannelsManager) SetMobileNotificationsLevel(channelIDBytes []byte, level, status int) error
- func (cm *ChannelsManager) SetNickname(nickname string, channelIDBytes []byte) error
- func (cm *ChannelsManager) VerifyChannelAdminKey(channelIdBytes []byte, encryptionPassword string, encryptedPrivKey []byte) (bool, 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) EKVGet(key string) ([]byte, error)
- func (c *Cmix) EKVSet(key string, value []byte) error
- func (c *Cmix) GetID() int
- func (c *Cmix) GetNodeRegistrationStatus() ([]byte, error)
- func (c *Cmix) GetReceptionID() []byte
- func (c *Cmix) GetReceptionRegistrationValidationSignature() []byte
- func (c *Cmix) GetRemoteKV() *RemoteKV
- 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) SetTrackNetworkPeriod(periodMS int)
- 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 DMClient
- func GetDMInstance(instanceID int) (*DMClient, error)
- func NewDMClient(cmixID, notificationsID int, privateIdentity []byte, ...) (*DMClient, error)
- func NewDMClientWithGoEventModel(cmixID, notificationsID int, privateIdentity []byte, receiver dm.EventModel, ...) (*DMClient, error)
- func NewDmManagerMobile(cmixID, notificationsID int, privateIdentity []byte, dbFilePath string, ...) (*DMClient, error)
- func (dmc *DMClient) BlockPartner(partnerPubKey []byte)
- func (dmc *DMClient) DeleteMessage(partnerPubKeyBytes []byte, partnerToken int32, targetMessageIdBytes []byte, ...) ([]byte, error)
- func (dmc *DMClient) ExportPrivateIdentity(password string) ([]byte, error)
- func (dmc *DMClient) GetBlockedPartners() []byte
- func (dmc *DMClient) GetID() int
- func (dmc *DMClient) GetIdentity() []byte
- func (dmc *DMClient) GetNickname() (string, error)
- func (dmc *DMClient) GetNotificationLevel(partnerPubKey []byte) (int, error)
- func (dmc *DMClient) GetPublicKey() []byte
- func (dmc *DMClient) GetShareURL(host string) ([]byte, error)
- func (dmc *DMClient) GetToken() int64
- func (dmc *DMClient) IsBlocked(partnerPubKey []byte) bool
- func (dmc *DMClient) Send(partnerPubKeyBytes []byte, partnerToken int32, messageType int, ...) ([]byte, error)
- func (dmc *DMClient) SendInvite(partnerPubKeyBytes []byte, partnerToken int32, inviteToChannelJson []byte, ...) ([]byte, error)
- func (dmc *DMClient) SendReaction(partnerPubKeyBytes []byte, partnerToken int32, reaction string, ...) ([]byte, error)
- func (dmc *DMClient) SendReply(partnerPubKeyBytes []byte, partnerToken int32, replyMessage string, ...) ([]byte, error)
- func (dmc *DMClient) SendSilent(partnerPubKeyBytes []byte, partnerToken int32, cmixParamsJSON []byte) ([]byte, error)
- func (dmc *DMClient) SendText(partnerPubKeyBytes []byte, partnerToken int32, message string, ...) ([]byte, error)
- func (dmc *DMClient) SetMobileNotificationsLevel(partnerPubKey []byte, level int) error
- func (dmc *DMClient) SetNickname(nick string) error
- func (dmc *DMClient) UnblockPartner(partnerPubKey []byte)
- type DMReceiver
- type DMReceiverBuilder
- type DMShareURL
- type DMUser
- type DmBlockedUserJSON
- type DmCallbacks
- type DmMessageDeletedJSON
- type DmMessageReceivedJSON
- type DmNotificationUpdateJSON
- type DmTokenUpdateJSON
- 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 FtReceivedProgress
- type FtReceivedProgressCallback
- type FtSentProgress
- type FtSentProgressCallback
- type GetTokenJson
- 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 KeyChangedByRemoteCallback
- type Listener
- type LogWriter
- type MapChangedByRemoteCallback
- type Message
- type MessageDeletedJSON
- type MessageDeliveryCallback
- type MessageReceivedJSON
- type MessageUpdateInfo
- type NetworkHealthCallback
- type NickNameUpdateJSON
- type NodeRegistrationReport
- type NotificationUpdateJSON
- type Notifications
- type Processor
- type Progress
- type RPCResponse
- type RPCResponseCallbacks
- type RPCServer
- type RPCServerCallback
- type ReceiveFileCallback
- type ReceivedChannelMessageReport
- type ReceivedFile
- type ReceptionIdentity
- type RemoteKV
- func (r *RemoteKV) Delete(key string, version int64) error
- func (r *RemoteKV) DeleteMapElement(mapName, elementName string, mapVersion int64) ([]byte, error)
- func (r *RemoteKV) DeleteRemoteKeyListener(key string, id int) error
- func (r *RemoteKV) DeleteRemoteMapListener(key string, id int) error
- func (r *RemoteKV) Get(key string, version int64) ([]byte, error)
- func (r *RemoteKV) GetAllRemoteKeyListeners() []byte
- func (r *RemoteKV) GetAllRemoteMapListeners() []byte
- func (r *RemoteKV) GetFullKey(key string, version int64) string
- func (r *RemoteKV) GetMap(mapName string, version int64) ([]byte, error)
- func (r *RemoteKV) GetMapElement(mapName, element string, version int64) ([]byte, error)
- func (r *RemoteKV) GetPrefix() string
- func (r *RemoteKV) GetRemoteKeyListeners(key string) []byte
- func (r *RemoteKV) GetRemoteMapListeners(key string) []byte
- func (r *RemoteKV) HasPrefix(prefix string) bool
- func (r *RemoteKV) IsMemStore() bool
- func (r *RemoteKV) ListenOnRemoteKey(key string, version int64, callback KeyChangedByRemoteCallback, ...) (int, error)
- func (r *RemoteKV) ListenOnRemoteMap(mapName string, version int64, callback MapChangedByRemoteCallback, ...) (int, error)
- func (r *RemoteKV) Prefix(prefix string) (*RemoteKV, error)
- func (r *RemoteKV) Root() (*RemoteKV, error)
- func (r *RemoteKV) Set(key string, objectJSON []byte) error
- func (r *RemoteKV) StoreMap(mapName string, valueJSON []byte, version int64) error
- func (r *RemoteKV) StoreMapElement(mapName, elementKey string, valueJSON []byte, version int64) error
- type RemoteStore
- type RemoteStoreFileSystem
- type RemoteStoreReport
- type ReporterFunc
- type RestlikeCallback
- type RestlikeMessage
- type RoundsList
- type ShareURL
- type SingleUseCallback
- type SingleUseCallbackReport
- type SingleUseResponse
- type SingleUseResponseReport
- type SingleUseSendReport
- type Stopper
- type TimeSource
- type TrackCompressedServicesCallback
- type TrackServicesCallback
- type TransactionOperation
- 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)
- type UserMutedJSON
Constants ¶
const ( // ChannelsNotifyNone results in no notifications. ChannelsNotifyNone = int64(channels.NotifyNone) // ChannelsNotifyPing results in notifications from tags, replies, and pins. ChannelsNotifyPing = int64(channels.NotifyPing) // ChannelsNotifyAll results in notifications from all messages except // silent ones and replays. ChannelsNotifyAll = int64(channels.NotifyAll) )
Notifications options
const ( // NickNameUpdate indicates the data is [NickNameUpdateJSON]. NickNameUpdate int64 = 1000 // NotificationUpdate indicates the data is [NotificationUpdateJSON]. NotificationUpdate int64 = 2000 // MessageReceived indicates the data is [MessageReceivedJSON]. MessageReceived int64 = 3000 // UserMuted indicates the data is [UserMutedJSON]. UserMuted int64 = 4000 // MessageDeleted indicates the data is [MessageDeletedJSON]. MessageDeleted int64 = 5000 // AdminKeyUpdate indicates the data is [AdminKeysUpdateJSON]. AdminKeyUpdate int64 = 6000 // DmTokenUpdate indicates the data is [DmTokenUpdateJSON]. DmTokenUpdate int64 = 7000 // ChannelUpdate indicates the data is [ChannelUpdateJSON]. ChannelUpdate int64 = 8000 )
Event types used by ChannelUICallbacks.
const ( // DmNotificationUpdate indicates the data is [DmNotificationUpdateJSON]. DmNotificationUpdate = 1000 // DmBlockedUser indicates the data is [DmBlockedUserJSON]. DmBlockedUser = 2000 // DmMessageReceived indicates the data is [DmMessageReceivedJSON]. DmMessageReceived int64 = 3000 // DmMessageDeleted indicates the data is [DmMessageDeletedJSON]. DmMessageDeleted int64 = 4000 )
DM event types
const ( UnrecognizedCode = "UR: " UnrecognizedMessage = UnrecognizedCode + "Unrecognized error from XX backend, please report" )
Error codes
const ( // NotificationsMute shows no notifications for the ID. NotificationsMute int64 = int64(notifications.Mute) // NotificationsWhenOpen shows notifications for this ID only when the app // is running and open. No registration or privacy leaks occur in this // state. NotificationsWhenOpen int64 = int64(notifications.WhenOpen) // NotificationsPush shows notifications for this ID as push notification // on applicable devices. This state has a minor privacy loss. NotificationsPush int64 = int64(notifications.Push) )
NotificationState indicates the status of notifications for an ID.
const ValidForeverBindings = -1
ValidForeverBindings is the value used to represent the maximum time a message can be valid for when used over the bindings.
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 CheckNoMessageErr ¶ added in v4.6.3
CheckNoMessageErr determines if the error returned by an EventModel function indicates that the message or item does not exist. It returns true if the error contains channels.NoMessageErr.
func ConstructIdentity ¶
ConstructIdentity creates a codename in a public channel.Identity from an extant identity for a given 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 DecodeDMShareURL ¶ added in v4.6.3
DecodeDMShareURL decodes the user's URL into a DMUser.
Parameters:
- url - The user's share URL. Should be received from another user or generated via DMClient.GetShareURL.
Returns:
- JSON of DMUser.
func DecodeInviteURL ¶ added in v4.7.1
DecodeInviteURL decodes the channel URL, using the password, into a channel pretty print. This function can only be used for URLs from invitations.
Parameters:
- url - The channel's invitation URL. Should be received from another user.
- password - The password needed to decrypt the secret data in the URL.
Returns:
- The channel pretty print.
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 DeriveRPCPublicKey ¶ added in v4.7.3
DeriveRPCPublicKey derives the public key from the given private key
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 GenerateChannelIdentity ¶
GenerateChannelIdentity creates a new private channel identity (channel.PrivateIdentity) from scratch and assigns it a codename.
The public component can be retrieved as JSON via GetPublicChannelIdentityFromPrivate.
Parameters:
- cmixID - ID of Cmix object in tracker. This can be retrieved using Cmix.GetID.
Returns:
- Marshalled bytes of channel.PrivateIdentity.
func GenerateRandomRPCKey ¶ added in v4.7.3
GenerateRandomRPCKey generates a random private key for a server
func GenerateRandomReceptionID ¶ added in v4.7.3
GenerateRandomReceptionID generates a random well formed reception id
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 GetChannelNotificationReportsForMe ¶ added in v4.7.1
func GetChannelNotificationReportsForMe(notificationFilterJSON []byte, notificationDataCSV string) ([]byte, error)
GetChannelNotificationReportsForMe checks the notification data against the filter list to determine which notifications belong to the user. A list of notification reports is returned detailing all notifications for the user.
Parameters:
- notificationFilterJSON - JSON of a slice of channels.NotificationFilter. It can optionally be the entire json return from NotificationUpdateJSON instead of just the needed subsection.
- notificationDataCSV - CSV containing notification data.
Example JSON of a slice of channels.NotificationFilter:
[ { "identifier": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUDYXN5bUlkZW50aWZpZXI=", "channelID": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUD", "tags": ["6de69009a93d53793ee344e8fb48fae194eaf51861d3cc51c7348c337d13aedf-usrping"], "allowLists": { "allowWithTags": {}, "allowWithoutTags": {"102": {}, "2": {}} } }, { "identifier": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUDc3ltSWRlbnRpZmllcg==", "channelID": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUD", "tags": ["6de69009a93d53793ee344e8fb48fae194eaf51861d3cc51c7348c337d13aedf-usrping"], "allowLists": { "allowWithTags": {}, "allowWithoutTags": {"1": {}, "40000": {}} } }, { "identifier": "jCRgFRQvzzKOb8DJ0fqCRLgr9kiHN9LpqHXVhyHhhlQDYXN5bUlkZW50aWZpZXI=", "channelID": "jCRgFRQvzzKOb8DJ0fqCRLgr9kiHN9LpqHXVhyHhhlQD", "tags": ["6de69009a93d53793ee344e8fb48fae194eaf51861d3cc51c7348c337d13aedf-usrping"], "allowLists": { "allowWithTags": {}, "allowWithoutTags": {"102": {}, "2": {}} } } ]
Returns:
- []byte - JSON of a slice of channels.NotificationReport.
Example return:
[ { "channel": "jOgZopfYj4zrE/AHtKmkf+QEWnfUKv9KfIy/+Bsg0PkD", "type": 1, "pingType": "usrMention" }, { "channel": "GKmfN/LKXQYM6++TC6DeZYqoxvSUPkh5UAHWODqh9zkD", "type": 2, "pingType": "usrReply" }, { "channel": "M+28xtj0coHrhDHfojGNcyb2c4maO7ZuheB6egS0Pc4D", "type": 1, "pingType": "" } ]
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.
See xxdk.CMIXParams for example JSON.
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 GetDmNotificationReportsForMe ¶ added in v4.7.1
func GetDmNotificationReportsForMe(notificationFilterJSON []byte, notificationDataCSV string) ([]byte, error)
GetDmNotificationReportsForMe checks the notification data against the filter list to determine which notifications belong to the user. A list of notification reports is returned detailing all notifications for the user.
Parameters:
- notificationFilterJSON - JSON of dm.NotificationFilter.
- notificationDataCSV - CSV containing notification data.
Example JSON of a slice of dm.NotificationFilter:
{ "identifier": "MWL6mvtZ9UUm7jP3ainyI4erbRl+wyVaO5MOWboP0rA=", "myID": "AqDqg6Tcs359dBNRBCX7XHaotRDhz1ZRQNXIsGaubvID", "tags": [ "61334HtH85DPIifvrM+JzRmLqfV5R4AMEmcPelTmFX0=", "zc/EPwtx5OKTVdwLcI15bghjJ7suNhu59PcarXE+m9o=", "FvArzVJ/082UEpMDCWJsopCLeLnxJV6NXINNkJTk3k8=" ], "PublicKeys": { "61334HtH85DPIifvrM+JzRmLqfV5R4AMEmcPelTmFX0=": "b3HygDv8gjteune9wgBm3YtVuAo2foOusRmj0m5nl6E=", "FvArzVJ/082UEpMDCWJsopCLeLnxJV6NXINNkJTk3k8=": "uOLitBZcCh2TEW406jXHJ+Rsi6LybsH8R1u4Mxv/7hA=", "zc/EPwtx5OKTVdwLcI15bghjJ7suNhu59PcarXE+m9o=": "lqLD1EzZBxB8PbILUJIfFq4JI0RKThpUQuNlTNgZAWk=" }, "allowedTypes": {"1": {}, "2": {}} }
Returns:
- []byte - JSON of a slice of dm.NotificationReport.
Example return:
[ {"partner": "WUSO3trAYeBf4UeJ5TEL+Q4usoyFf0shda0YUmZ3z8k=", "type": 1}, {"partner": "5MY652JsVv5YLE6wGRHIFZBMvLklACnT5UtHxmEOJ4o=", "type": 2} ]
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 GetNoMessageErr ¶ added in v4.6.3
func GetNoMessageErr() string
GetNoMessageErr returns the error channels.NoMessageErr, which must be returned by EventModel methods (such as EventModel.UpdateFromUUID, EventModel.UpdateFromMessageID, and EventModel.GetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identity (channel.PrivateIdentity).
Returns:
- JSON of the public channel.Identity.
func GetShareUrlType ¶
GetShareUrlType determines the [broadcast.PrivacyLevel] of the shared 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 from ChannelsManager.ExportPrivateIdentity.
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.
Parameters:
- nickname - Nickname to check.
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 NewSynchronizedCmix ¶ added in v4.7.1
func NewSynchronizedCmix(ndfJSON, storageDir, remoteStoragePathPrefix string, password []byte, remote RemoteStore) error
NewSynchronizedCmix clones a Cmix from remote storage. Parameters:
- ndfJSON - the NDF file used to connect to the network.
- storageDir - the local directory or path used for the encrypted key value store.
- remoteStoragePathPrefix - the remote "directory" or path prefix used by the RemoteStore when reading/writing files.
- password - the pssword used to decrypt the encrypted key value store.
- remote - the RemoteStore implementation to use for multi-device synchronization.
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 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 SupportedEmojis ¶ added in v4.5.0
SupportedEmojis returns a list of emojis that are supported by the backend. The list includes all emojis described in UTS #51 section A.1: Data Files.
Returns:
- []byte - JSON of an array of emoji.Emoji.
Example JSON:
[ { "character": "☹️", "name": "frowning face", "comment": "E0.7", "codePoint": "2639 FE0F", "group": "Smileys \u0026 Emotion", "subgroup": "face-concerned" }, { "character": "☺️", "name": "smiling face", "comment": "E0.6", "codePoint": "263A FE0F", "group": "Smileys \u0026 Emotion", "subgroup": "face-affection" }, { "character": "☢️", "name": "radioactive", "comment": "E1.0", "codePoint": "2622 FE0F", "group": "Symbols", "subgroup": "warning" } ]
func SupportedEmojisMap ¶ added in v4.6.3
SupportedEmojisMap returns a map of emojis that are supported by the backend as described by SupportedEmojis.
Returns:
- []byte - JSON of a map of emoji.Emoji.
Example JSON:
{ "☹️": { "character": "☹️", "name": "frowning face", "comment": "E0.7", "codePoint": "2639 FE0F", "group": "Smileys \u0026 Emotion", "subgroup": "face-concerned" }, "☺️": { "character": "☺️", "name": "smiling face", "comment": "E0.6", "codePoint": "263A FE0F", "group": "Smileys \u0026 Emotion", "subgroup": "face-affection" }, "☢️": { "character": "☢️", "name": "radioactive", "comment": "E1.0", "codePoint": "2622 FE0F", "group": "Symbols", "subgroup": "warning" }, }
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 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", }
func ValidForever ¶ added in v4.4.4
func ValidForever() int
ValidForever returns the value to use for validUntil when you want a message to be available for the maximum amount of time.
func ValidateReaction ¶ added in v4.5.0
ValidateReaction checks that the reaction only contains a single emoji. Returns InvalidReaction if the emoji is invalid.
Parameters:
- reaction - The reaction to validate.
Returns:
- Error emoji.InvalidReaction if the reaction is not a single emoji.
Types ¶
type AdminKeysUpdateJSON ¶ added in v4.7.1
type AdminKeysUpdateJSON struct { ChannelId *id.ID `json:"channelID"` IsAdmin bool `json:"IsAdmin"` }
AdminKeysUpdateJSON describes when you get or lose keys for a specific channel
Example JSON:
{ "channelID":"KdkEjm+OfQuK4AyZGAqh+XPQaLfRhsO5d2NT1EIScyJX", "IsAdmin":true }
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 ChFilePartTracker ¶ added in v4.6.3
type ChFilePartTracker struct {
// contains filtered or unexported fields
}
ChFilePartTracker contains the channelsFileTransfer.FilePartTracker.
func (ChFilePartTracker) GetNumParts ¶ added in v4.6.3
func (fpt ChFilePartTracker) GetNumParts() int
GetNumParts returns the total number of file parts in the transfer.
func (ChFilePartTracker) GetPartStatus ¶ added in v4.6.3
func (fpt ChFilePartTracker) 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 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 `json:"messageID,omitempty"` RoundsList `json:"roundsList"` EphId int64 `json:"ephId,omitempty"` }
ChannelSendReport is the bindings' representation of the return values of ChannelsManager's send operations. The messageID and ephID may not be present.
JSON Example:
{ "messageID": "0kitNxoFdsF4q1VMSI/xPzfCnGB2l+ln2+7CTHjHbJw=", "roundsList":[1,5,9], "ephId": 0 }
type ChannelUICallbacks ¶ added in v4.7.1
ChannelUICallbacks is used for providing callbacks to the UI from the EventModel.
type ChannelUpdateJSON ¶ added in v4.7.1
ChannelUpdateJSON is returned any time a Channel is joined/left.
Example JSON:
{ "channelID":"YSc2bDijXIVhmIsJk2OZQjU9ei2Dn6MS8tOpXlIaUpSV", "deleted":false" }
type ChannelsFileTransfer ¶ added in v4.6.3
type ChannelsFileTransfer struct {
// contains filtered or unexported fields
}
ChannelsFileTransfer manages the sending and receiving of file via channels. Refer to [channelsFileTransfer.FileTransfer] for additional documentation.
func InitChannelsFileTransfer ¶ added in v4.6.3
func InitChannelsFileTransfer( e2eID int, paramsJson []byte) (*ChannelsFileTransfer, error)
InitChannelsFileTransfer creates a file transfer manager for channels.
Parameters:
- e2eID - ID of E2e object in tracker.
- paramsJson - JSON of [channelsFileTransfer.Params].
Returns:
- New ChannelsFileTransfer object.
func (*ChannelsFileTransfer) CloseSend ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) CloseSend(fileIDBytes []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:
- fileIDBytes - Marshalled bytes of the file's fileTransfer.ID.
func (*ChannelsFileTransfer) Download ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) Download(fileInfoJSON []byte, progressCB FtReceivedProgressCallback, periodMS int) ([]byte, error)
Download begins the download of the file described in the marshalled [channelsFileTransfer.FileInfo]. The progress of the download is reported on the FtReceivedProgressCallback.
Once the download completes, the file will be stored in the event model with the given file ID and with the status channels.ReceptionProcessingComplete.
The FtReceivedProgressCallback only indicates the progress of the file download, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.
Parameters:
- fileInfoJSON - The JSON of [channelsFileTransfer.FileInfo] received on a channel.
- progressCB - A callback that reports the progress of the file download. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- periodMS - A progress callback will be limited from triggering only once per period, in milliseconds.
Returns:
- Marshalled bytes of fileTransfer.ID that uniquely identifies the file.
func (*ChannelsFileTransfer) GetExtensionBuilderID ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) GetExtensionBuilderID() int
GetExtensionBuilderID returns the ID of the extension builder in the tracker. Pass this ID into the channel manager creator to use file transfer manager in conjunction with channels.
func (*ChannelsFileTransfer) MaxFileNameLen ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) MaxFileNameLen() int
MaxFileNameLen returns the max number of bytes allowed for a file name.
func (*ChannelsFileTransfer) MaxFileSize ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) MaxFileSize() int
MaxFileSize returns the max number of bytes allowed for a file.
func (*ChannelsFileTransfer) MaxFileTypeLen ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) MaxFileTypeLen() int
MaxFileTypeLen returns the max number of bytes allowed for a file type.
func (*ChannelsFileTransfer) MaxPreviewSize ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) MaxPreviewSize() int
MaxPreviewSize returns the max number of bytes allowed for a file preview.
func (*ChannelsFileTransfer) RegisterReceivedProgressCallback ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) RegisterReceivedProgressCallback( fileIDBytes []byte, progressCB FtReceivedProgressCallback, periodMS int) error
RegisterReceivedProgressCallback allows for the registration of a callback to track the progress of an individual file download.
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 download completes, the file will be stored in the event model with the given file ID and with the status [channelsFileTransfer.Complete].
The FtReceivedProgressCallback only indicates the progress of the file download, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.
Parameters:
- fileIDBytes - Marshalled bytes of the file's fileTransfer.ID.
- progressCB - A callback that reports the progress of the file upload. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- periodMS - A progress callback will be limited from triggering only once per period, in milliseconds.
func (*ChannelsFileTransfer) RegisterSentProgressCallback ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) RegisterSentProgressCallback(fileIDBytes []byte, progressCB FtSentProgressCallback, periodMS int) error
RegisterSentProgressCallback allows for the registration of a callback to track the progress of an individual file upload. A FtSentProgressCallback is auto-registered on ChannelsFileTransfer.Send; this function should be called when resuming clients or registering extra callbacks.
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 ChannelsFileTransfer.Send.
The FtSentProgressCallback only indicates the progress of the file upload, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.
Parameters:
- fileIDBytes - Marshalled bytes of the file's fileTransfer.ID.
- progressCB - A callback that reports the progress of the file upload. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- periodMS - A progress callback will be limited from triggering only once per period, in milliseconds.
func (*ChannelsFileTransfer) RetryUpload ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) RetryUpload(fileIDBytes []byte, progressCB FtSentProgressCallback, periodMS int) error
RetryUpload retries uploading a failed file upload. Returns an error if the transfer has not failed.
This function should be called once a transfer errors out (as reported by the progress callback).
A new progress callback must be registered on retry. Any previously registered callbacks are defunct when the upload fails.
Parameters:
- fileIDBytes - Marshalled bytes of the file's fileTransfer.ID.
- progressCB - A callback that reports the progress of the file upload. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- periodMS - A progress callback will be limited from triggering only once per period, in milliseconds.
func (*ChannelsFileTransfer) Send ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) Send(channelIdBytes, fileLinkJSON []byte, fileName, fileType string, preview []byte, validUntilMS int, cmixParamsJSON []byte, pingsJSON []byte) ([]byte, error)
Send sends the specified file info to the channel. Once a file is uploaded via ChannelsFileTransfer.Upload, its file info (found in the event model) can be sent to any channel.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID to send the file to.
- fileLinkJSON - JSON of [channelsFileTransfer.Link] stored in the event model.
- fileName - Human-readable file name. Max length defined by [MaxFileNameLen].
- fileType - Shorthand that identifies the type of file. Max length defined by [MaxFileTypeLen].
- preview - A preview of the file data (e.g. a thumbnail). Max size defined by [MaxPreviewSize].
- validUntilMS - The duration, in milliseconds, that the file is available in the channel. For the maximum amount of time, use ValidForever.
- cmixParamsJSON - JSON of xxdk.CMIXParams. If left empty, GetDefaultCMixParams will be used internally.
- pingsJSON - JSON of a list of Ed25519 public keys that will receive notifications for this message. They must be in the channel and have notifications enabled.
Example pingsJSON:
[ "FgJMvgSsY4rrKkS/jSe+vFOJOs5qSSyOUSW7UtF9/KU=", "fPqcHtrJ398PAC35QyWXEU9PHzz8Z4BKQTCxSvpSygw=", "JnjCgh7g/+hNiI9VPKW01aRSxGOFmNulNCymy3ImXAo=" ]
Returns:
- JSON of ChannelSendReport.
func (*ChannelsFileTransfer) Upload ¶ added in v4.6.3
func (cft *ChannelsFileTransfer) Upload(fileData []byte, retry float32, progressCB FtSentProgressCallback, periodMS int) ([]byte, error)
Upload starts uploading the file to a new ID that can be sent to the specified channel when complete. To get progress information about the upload, a FtSentProgressCallback must be registered. All errors returned on the callback are fatal and the user must take action to either ChannelsFileTransfer.RetryUpload or ChannelsFileTransfer.CloseSend.
The file is added to the event model at the returned file ID with the status [channelsFileTransfer.Uploading]. Once the upload is complete, the file link is added to the event model with the status [channelsFileTransfer.Complete].
The FtSentProgressCallback only indicates the progress of the file upload, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.
Parameters:
- fileData - File contents. Max size defined by ChannelsFileTransfer.MaxFileSize.
- 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).
- progressCB - A callback that reports the progress of the file upload. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error.
- periodMS - A progress callback will be limited from triggering only once per period, in milliseconds.
Returns:
- Marshalled bytes of fileTransfer.ID that uniquely identifies the file.
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, extensionBuilderIDsJSON []byte, notificationsID int, uiCallbacks ChannelUICallbacks) (*ChannelsManager, error)
LoadChannelsManager loads an existing ChannelsManager for the given storage tag.
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 - ID of Cmix object in tracker. 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 initializes and returns the event model that is bindings-compatible.
- extensionBuilderIDsJSON - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]`.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- uiCallbacks - Callbacks to inform the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.
func LoadChannelsManagerGoEventModel ¶
func LoadChannelsManagerGoEventModel(cmixID int, storageTag string, goEventBuilder channels.EventModelBuilder, extensionBuilderIDsJSON []byte, notificationsID int, uiCallbacks ChannelUICallbacks) (*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 - ID of Cmix object in tracker. This can be retrieved using Cmix.GetID.
- storageTag - retrieved with ChannelsManager.GetStorageTag
- goEvent - A function that initializes and returns the event model that is not compatible with GoMobile bindings.
- extensionBuilderIDsJSON - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]`.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- uiCallbacks - Callbacks to inform the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.
func LoadChannelsManagerMobile ¶ added in v4.5.0
func LoadChannelsManagerMobile(cmixID int, storageTag, dbFilePath string, extensionBuilderIDsJSON []byte, notificationsID int, uiCallbacks ChannelUICallbacks) (*ChannelsManager, error)
LoadChannelsManagerMobile loads an existing ChannelsManager for the given storage tag backed with SqlLite for mobile use.
This is for loading a manager for an identity that has already been created. The channel manager should have previously been created with NewChannelsManagerMobile and the storage is retrievable with ChannelsManager.GetStorageTag.
Parameters:
- cmixID - ID of Cmix object in tracker. This can be retrieved using Cmix.GetID.
- storageTag - The storage tag associated with the previously created channel manager and retrieved with ChannelsManager.GetStorageTag.
- dbFilePath - absolute string path to the SqlLite database file
- extensionBuilderIDsJSON - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]`.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- uiCallbacks - Callbacks to inform the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.
func NewChannelsManager ¶
func NewChannelsManager(cmixID int, privateIdentity []byte, eventBuilder EventModelBuilder, extensionBuilderIDsJSON []byte, notificationsID int, uiCallbacks ChannelUICallbacks) (*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 - ID of Cmix object in tracker. This can be retrieved using Cmix.GetID.
- privateIdentity - Bytes of a private identity (channel.PrivateIdentity) that is generated by GenerateChannelIdentity.
- eventBuilder - An interface that contains a function that initialises and returns the event model that is bindings-compatible.
- extensionBuilderIDsJSON - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]`.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- uiCallbacks - Callbacks to inform the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.
func NewChannelsManagerGoEventModel ¶
func NewChannelsManagerGoEventModel(cmixID int, privateIdentity, extensionBuilderIDsJSON []byte, goEventBuilder channels.EventModelBuilder, notificationsID int, callbacks ChannelUICallbacks) ( *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 - ID of Cmix object in tracker. This can be retrieved using Cmix.GetID.
- privateIdentity - Bytes of a private identity (channel.PrivateIdentity) that is generated by GenerateChannelIdentity.
- goEventBuilder - A function that initializes and returns the event model that is not compatible with GoMobile bindings.
- extensionBuilderIDsJSON - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]`.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- uiCallbacks - Callbacks to inform the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.
func NewChannelsManagerMobile ¶ added in v4.5.0
func NewChannelsManagerMobile(cmixID int, privateIdentity []byte, dbFilePath string, extensionBuilderIDsJSON []byte, notificationsID int, uiCallbacks ChannelUICallbacks) (*ChannelsManager, error)
NewChannelsManagerMobile creates a new ChannelsManager from a new private identity cryptoChannel.PrivateIdentity backed with SqlLite for mobile use.
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 - ID of Cmix object in tracker. This can be retrieved using Cmix.GetID.
- privateIdentity - Bytes of a private identity (channel.PrivateIdentity) that is generated by GenerateChannelIdentity.
- dbFilePath - absolute string path to the SqlLite database file
- extensionBuilderIDsJSON - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]`.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- uiCallbacks - Callbacks to inform the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.
func (*ChannelsManager) AreDMsEnabled ¶ added in v4.5.0
func (cm *ChannelsManager) AreDMsEnabled(channelIdBytes []byte) (bool, error)
AreDMsEnabled returns the status of DMs for a given channel
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
Returns:
- DM status (bool) - true if DMs are enabled for passed in channel
func (*ChannelsManager) DeleteChannelAdminKey ¶ added in v4.4.4
func (cm *ChannelsManager) DeleteChannelAdminKey(channelIdBytes []byte) error
DeleteChannelAdminKey deletes the private key for the given channel.
CAUTION: This will remove admin access. This cannot be undone. If the private key is deleted, it cannot be recovered and the channel can never have another admin.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
func (*ChannelsManager) DeleteMessage ¶ added in v4.4.4
func (cm *ChannelsManager) DeleteMessage(channelIdBytes, targetMessageIdBytes, cmixParamsJSON []byte) ([]byte, error)
DeleteMessage deletes the targeted message from user's view. Users may delete their own messages but only the channel admin can delete other user's messages. If the user is not an admin of the channel or if they are not the sender of the targetMessage, then the error channels.NotAnAdminErr is returned.
If undoAction is true, then the targeted message is un-deleted.
Clients will drop the deletion if they do not recognize the target message.
Parameters:
- channelIdBytes - Marshalled bytes of channel id.ID.
- targetMessageIdBytes - The marshalled channel.MessageID of the message you want to delete.
- cmixParamsJSON - JSON of xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) DeleteNickname ¶
func (cm *ChannelsManager) DeleteNickname(channelIDBytes []byte) error
DeleteNickname removes the nickname for a given channel. The name will revert back to the codename for this channel instead.
Parameters:
- channelIDBytes - The marshalled bytes of the channel's id.ID.
func (*ChannelsManager) DisableDirectMessages ¶ added in v4.5.0
func (cm *ChannelsManager) DisableDirectMessages(channelIdBytes []byte) error
DisableDirectMessages removes the token for direct messaging for a given channel.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
func (*ChannelsManager) EnableDirectMessages ¶ added in v4.5.0
func (cm *ChannelsManager) EnableDirectMessages(channelIdBytes []byte) error
EnableDirectMessages enables the token for direct messaging for this channel.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
func (*ChannelsManager) ExportChannelAdminKey ¶ added in v4.4.4
func (cm *ChannelsManager) ExportChannelAdminKey( channelIDBytes []byte, encryptionPassword string) ([]byte, error)
ExportChannelAdminKey gets the private key for the given channel ID, encrypts it with the provided encryptionPassword, and exports it into a portable format. Returns an error if the user is not an admin of the channel.
This key can be provided to other users in a channel to grant them admin access using ChannelsManager.ImportChannelAdminKey.
The private key is encrypted using a key generated from the password using Argon2. Each call to ExportChannelAdminKey produces a different encrypted packet regardless if the same password is used for the same channel. It cannot be determined which channel the payload is for nor that two payloads are for the same channel.
The passwords between each call are not related. They can be the same or different with no adverse impact on the security properties.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
- encryptionPassword - The password used to encrypt the private key. The passwords between each call are not related. They can be the same or different with no adverse impact on the security properties.
Returns:
- Portable string of the channel private key encrypted with the password.
func (*ChannelsManager) ExportPrivateIdentity ¶
func (cm *ChannelsManager) ExportPrivateIdentity(password string) ([]byte, error)
ExportPrivateIdentity encrypts the private identity using the password and exports it to a portable string.
Parameters:
- password - The password used to encrypt the private identity.
Returns:
- []byte - Encrypted portable private identity.
func (*ChannelsManager) GenerateChannel ¶ added in v4.4.4
func (cm *ChannelsManager) GenerateChannel( name, description string, privacyLevel int) (string, error)
GenerateChannel creates a new channel with the user as the admin and returns the broadcast.Channel object. This function only create a channel and does not join it.
The private key is saved to storage and can be accessed with ExportChannelAdminKey.
Parameters:
- 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:
- string - The pretty print of the channel.
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 (*ChannelsManager) GetChannels ¶
func (cm *ChannelsManager) GetChannels() ([]byte, error)
GetChannels returns the IDs of all channels that have been joined.
Returns:
- []byte - A JSON marshalled array of id.ID.
JSON Example:
{ "U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID", "15tNdkKbYXoMn58NO6VbDMDWFEyIhTWEGsvgcJsHWAgD" }
func (*ChannelsManager) GetID ¶
func (cm *ChannelsManager) GetID() int
GetID returns the unique tracking ID for the ChannelsManager object.
func (*ChannelsManager) GetIdentity ¶
func (cm *ChannelsManager) GetIdentity() ([]byte, error)
GetIdentity returns the public identity (channel.Identity) of the user associated with this channel manager.
Returns:
- []byte - JSON of channel.Identity.
func (*ChannelsManager) GetMutedUsers ¶ added in v4.4.4
func (cm *ChannelsManager) GetMutedUsers(channelIDBytes []byte) ([]byte, error)
GetMutedUsers returns the list of the public keys for each muted user in the channel. If there are no muted user or if the channel does not exist, an empty list is returned.
Parameters:
- channelIDBytes - The marshalled bytes of the channel's id.ID.
Returns:
- []byte - JSON of an array of ed25519.PublicKey. Look below for an example.
Example return:
["k2IrybDXjJtqxjS6Tx/6m3bXvT/4zFYOJnACNWTvESE=","ocELv7KyeCskLz4cm0klLWhmFLYvQL2FMDco79GTXYw=","mmxoDgoTEYwaRyEzq5Npa24IIs+3B5LXhll/8K5yCv0="]
func (*ChannelsManager) GetNickname ¶
func (cm *ChannelsManager) GetNickname(channelIDBytes []byte) (string, error)
GetNickname returns the nickname set for a given channel.
Parameters:
- channelIDBytes - The marshalled bytes of the channel's id.ID.
Returns:
- string - The nickname for the channel.
func (*ChannelsManager) GetNotificationLevel ¶ added in v4.7.1
func (cm *ChannelsManager) GetNotificationLevel( channelIDBytes []byte) (int, error)
GetNotificationLevel returns the channels.NotificationLevel for the given channel.
Parameters:
- channelIDBytes - The marshalled bytes of the channel's id.ID.
Returns:
- int - The channels.NotificationLevel for the channel.
func (*ChannelsManager) GetNotificationStatus ¶ added in v4.7.1
func (cm *ChannelsManager) GetNotificationStatus( channelIDBytes []byte) (int, error)
GetNotificationStatus returns the notification status for the given channel.
Parameters:
- channelIDBytes - The marshalled bytes of the channel's id.ID.
Returns:
- int - The [notifications.NotificationState] for the channel.
func (*ChannelsManager) GetShareURL ¶
func (cm *ChannelsManager) GetShareURL(cmixID int, host string, maxUses int, channelIdBytes []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, it will be verified when calling DecodePublicURL and DecodePrivateURL. There is no enforcement for public URLs.
Parameters:
- cmixID - ID of Cmix object in tracker.
- host - The URL to append the channel info to.
- maxUses - The maximum number of uses the link can be used (0 for unlimited).
- channelIdBytes - Marshalled bytes of the channel (id.ID).
Returns:
- JSON of ShareURL.
func (*ChannelsManager) GetStorageTag ¶
func (cm *ChannelsManager) GetStorageTag() string
GetStorageTag returns the tag where this manager is stored. To be used when loading the manager. The storage tag is derived from the public key.
func (*ChannelsManager) ImportChannelAdminKey ¶ added in v4.4.4
func (cm *ChannelsManager) ImportChannelAdminKey(channelIdBytes []byte, encryptionPassword string, encryptedPrivKey []byte) error
ImportChannelAdminKey decrypts and imports the given encrypted private key and grants the user admin access to the channel the private key belongs to. Returns an error if the private key cannot be decrypted or if the private key is for the wrong channel.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
- encryptionPassword - The password used to encrypt the private key.
- encryptedPrivKey - The encrypted channel private key packet.
Returns:
- Returns the error channels.WrongPasswordErr for an invalid password.
- Returns the error channels.ChannelDoesNotExistsErr if the channel has not already been joined.
- Returns the error channels.WrongPrivateKeyErr if the private key does not belong to the channel.
func (*ChannelsManager) IsChannelAdmin ¶ added in v4.4.4
func (cm *ChannelsManager) IsChannelAdmin(channelIDBytes []byte) (bool, error)
IsChannelAdmin returns true if the user is an admin of the channel.
Parameters:
- channelIDBytes - The marshalled bytes of the channel's id.ID.
Returns:
- bool - True if the user is an admin in the channel and false otherwise.
func (*ChannelsManager) JoinChannel ¶
func (cm *ChannelsManager) JoinChannel(channelPretty string) ([]byte, error)
JoinChannel joins the given channel. It will return the error channels.ChannelAlreadyExistsErr if the channel has already been joined.
Parameters:
- channelPretty - A portable channel string. Should be received from another user or generated via ChannelsManager.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(channelIdBytes []byte) error
LeaveChannel leaves the given channel. It will return the error channels.ChannelDoesNotExistsErr if the channel was not previously joined.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
func (*ChannelsManager) MuteUser ¶ added in v4.4.4
func (cm *ChannelsManager) MuteUser(channelIdBytes, mutedUserPubKeyBytes []byte, undoAction bool, validUntilMS int, cmixParamsJSON []byte) ([]byte, error)
MuteUser is used to mute a user in a channel. Muting a user will cause all future messages from the user being dropped on reception. Muted users are also unable to send messages. Only the channel admin can mute a user; if the user is not an admin of the channel, then the error channels.NotAnAdminErr is returned.
If undoAction is true, then the targeted user will be unmuted.
Parameters:
- channelIdBytes - Marshalled bytes of channel id.ID.
- mutedUserPubKeyBytes - The ed25519.PublicKey of the user you want to mute.
- undoAction - Set to true to unmute the user.
- validUntilMS - The time, in milliseconds, that the user should be muted. To remain muted indefinitely, use ValidForever.
- cmixParamsJSON - JSON of xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) Muted ¶ added in v4.4.4
func (cm *ChannelsManager) Muted(channelIDBytes []byte) (bool, error)
Muted returns true if the user is currently muted in the given channel.
Parameters:
- channelIDBytes - The marshalled bytes of the channel's id.ID.
Returns:
- bool - True if the user is muted in the channel and false otherwise.
func (*ChannelsManager) PinMessage ¶ added in v4.4.4
func (cm *ChannelsManager) PinMessage(channelIdBytes, targetMessageIdBytes []byte, undoAction bool, validUntilMS int, cmixParamsJSON []byte) ([]byte, error)
PinMessage pins the target message to the top of a channel view for all users in the specified channel. Only the channel admin can pin user messages; if the user is not an admin of the channel, then the error channels.NotAnAdminErr is returned.
If undoAction is true, then the targeted message is unpinned.
Clients will drop the pin if they do not recognize the target message.
Parameters:
- channelIdBytes - Marshalled bytes of channel id.ID.
- targetMessageIdBytes - The marshalled channel.MessageID of the message you want to pin.
- undoAction - Set to true to unpin the message.
- validUntilMS - The time, in milliseconds, that the message should be pinned. To remain pinned indefinitely, use ValidForever.
- cmixParamsJSON - JSON of xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) RegisterReceiveHandler ¶
func (cm *ChannelsManager) RegisterReceiveHandler(messageType int, listenerCb ChannelMessageReceptionCallback, name string, userSpace, adminSpace, mutedSpace bool) error
RegisterReceiveHandler registers a listener for non-default message types so that they can be processed by modules. It is important that such modules collective up with the event model implementation.
There can only be one handler per channels.MessageType; the error channels.MessageTypeAlreadyRegistered will be returned on multiple registrations of the same type.
Parameters:
- messageType - The channels.MessageType that the listener listens for.
- listenerCb - The callback which will be executed when a channel message of messageType is received.
- name - A name describing what type of messages the listener picks up. This is used for debugging and logging.
- userSpace - Set to true if this listener can receive messages from normal users.
- adminSpace - Set to true if this listener can receive messages from admins.
- mutedSpace - Set to true if this listener can receive messages from muted users.
func (*ChannelsManager) ReplayChannel ¶
func (cm *ChannelsManager) ReplayChannel(channelIdBytes []byte) error
ReplayChannel replays all messages from the channel within the network's memory (~3 weeks) over the event model.
Returns the error channels.ChannelDoesNotExistsErr if the channel was not previously joined.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
func (*ChannelsManager) SendAdminGeneric ¶
func (cm *ChannelsManager) SendAdminGeneric(channelIdBytes []byte, messageType int, message []byte, validUntilMS int64, tracked bool, 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.
If the user is not an admin of the channel (i.e. does not have a private key for the channel saved to storage), then the error channels.NotAnAdminErr is returned.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's 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.
- validUntilMS - The lease of the message. This will be how long the message is available from the network, 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. Use channels.ValidForever to last the max message life.
- tracked - Set tracked to true if the message should be tracked in the sendTracker, which allows messages to be shown locally before they are received on the network. In general, all messages that will be displayed to the user should be tracked while all actions should not be.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) SendGeneric ¶
func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int, message []byte, validUntilMS int64, tracked bool, cmixParamsJSON []byte, pingsMapJSON []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 is not 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.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's 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.
- validUntilMS - The lease of the message. This will be how long the message is available from the network, 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. Use channels.ValidForever to last the max message life.
- tracked - Set tracked to true if the message should be tracked in the sendTracker, which allows messages to be shown locally before they are received on the network. In general, all messages that will be displayed to the user should be tracked while all actions should not be.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
- pingsMapJSON - JSON of a map of slices of ed25519.PublicKey of users that should receive mobile notifications for the message. Each slice keys on a channels.PingType that describes the type of notification it is.
Example pingsMapJSON:
{ "usrMention": [ "CLdKxbe8D2WVOpx1mT63TZ5CP/nesmxHLT5DUUalpe0=", "S2c6NXjNqgR11SCOaiQUughWaLpWBKNufPt6cbTVHMA=" ], "usrReply": [ "aaMzSeA6Cu2Aix2MlOwzrAI+NnpKshzvZRT02PZPVec=" ] }
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) SendInvite ¶ added in v4.7.1
func (cm *ChannelsManager) SendInvite(channelIdBytes, inviteToJson []byte, message string, host string, validUntilMS int64, cmixParamsJSON []byte, pingsJSON []byte) ( []byte, error)
SendInvite is used to send to a channel (invited) an invitation to another channel (invitee).
If the channel ID for the invitee channel is not recognized by the Manager, then an error will be returned.
The reception of an invitation will be handled by [EventModel.ReceiveMessage], passing in a channels.MessageType of value channels.Invitation. The message will be JSON encoded. Example invite JSON:
{ "text": "Check this channel out!", "inviteLink": "https://internet.speakeasy.tech/?0Name=name&1Description=description&2Level=Public&3Created=1687359213751145652&e=gnnLqhgsNJE7uFTLRsv1q%2FzgHBesVsezln4mg4mQZ70%3D&k=aOULKJDhSkNOou7CwsybaNTrdfrUS55%2Ffv%2FuHjX2Mc4%3D&l=928&m=0&p=1&s=cN2iHg6b5FdViS4q46QMolQUF0BZt98NEiO6NKrL1d0%3D&v=1", "password": "secret" }
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID This is invited channel.
- inviteToChannelJSON - A JSON marshalled channel. This should be the data of the invitee channel. This can be retrieved from GetChannelJSON.
- 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.
- host - The URL to append the channel info to.
- validUntilMS - The lease of the message. This will be how long the message is available from the network, 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. Use channels.ValidForever to last the max message life.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
- pingsJSON - JSON of a slice of public keys of users that should receive mobile notifications for the message.
Example pingsJSON:
[ "FgJMvgSsY4rrKkS/jSe+vFOJOs5qSSyOUSW7UtF9/KU=", "fPqcHtrJ398PAC35QyWXEU9PHzz8Z4BKQTCxSvpSygw=", "JnjCgh7g/+hNiI9VPKW01aRSxGOFmNulNCymy3ImXAo=" ]
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) SendMessage ¶
func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string, validUntilMS int64, cmixParamsJSON []byte, pingsJSON []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:
- channelIdBytes - Marshalled bytes of the channel's 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
- validUntilMS - The lease of the message. This will be how long the message is available from the network, 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. Use channels.ValidForever to last the max message life.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
- pingsJSON - JSON of a slice of public keys of users that should receive mobile notifications for the message.
Example pingsJSON:
[ "FgJMvgSsY4rrKkS/jSe+vFOJOs5qSSyOUSW7UtF9/KU=", "fPqcHtrJ398PAC35QyWXEU9PHzz8Z4BKQTCxSvpSygw=", "JnjCgh7g/+hNiI9VPKW01aRSxGOFmNulNCymy3ImXAo=" ]
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) SendReaction ¶
func (cm *ChannelsManager) SendReaction(channelIdBytes []byte, reaction string, messageToReactTo []byte, validUntilMS int64, 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.
Clients will drop the reaction if they do not recognize the reactTo message.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's 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.
- validUntilMS - The lease of the message. This will be how long the message is available from the network, 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. Use channels.ValidForever to last the max message life.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) SendReply ¶
func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string, messageToReactTo []byte, validUntilMS int64, cmixParamsJSON []byte, pingsJSON []byte) ([]byte, error)
SendReply is used to send a formatted message over a channel.
Due to the underlying encoding using compression, it is not 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 that the reply is sent to does not exist, then the other side will post the message as a normal message and not as a reply.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's 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].
- validUntilMS - The lease of the message. This will be how long the message is available from the network, 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. Use channels.ValidForever to last the max message life.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
- pingsJSON - JSON of a slice of public keys of users that should receive mobile notifications for the message.
Example pingsJSON:
[ "FgJMvgSsY4rrKkS/jSe+vFOJOs5qSSyOUSW7UtF9/KU=", "fPqcHtrJ398PAC35QyWXEU9PHzz8Z4BKQTCxSvpSygw=", "JnjCgh7g/+hNiI9VPKW01aRSxGOFmNulNCymy3ImXAo=" ]
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) SendSilent ¶ added in v4.7.1
func (cm *ChannelsManager) SendSilent(channelIdBytes []byte, validUntilMS int64, cmixParamsJSON []byte) ([]byte, error)
SendSilent is used to send to a channel a message with no notifications. Its primary purpose is to communicate new nicknames without calling [SendMessage].
It takes no payload intentionally as the message should be very lightweight.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
- validUntilMS - The lease of the message. This will be how long the message is available from the network, 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. Use channels.ValidForever to last the max message life.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
Returns:
- []byte - JSON of ChannelSendReport.
func (*ChannelsManager) SetMobileNotificationsLevel ¶ added in v4.7.1
func (cm *ChannelsManager) SetMobileNotificationsLevel( channelIDBytes []byte, level, status int) error
SetMobileNotificationsLevel sets the notification level for the given channel. The channels.NotificationLevel dictates the type of notifications received and the status controls weather the notification is push or in-app. If muted, both the level and status must be set to mute.
To use push notifications, a token must be registered with the notification manager. Note, when enabling push notifications, information may be shared with third parties (i.e., Firebase and Google's Palantir) and may represent a security risk to the user.
Parameters:
- channelIDBytes - The marshaled bytes of the channel's id.ID.
- level - The channels.NotificationLevel to set for the channel.
- status - The [notifications.NotificationState] to set for the channel.
func (*ChannelsManager) SetNickname ¶
func (cm *ChannelsManager) SetNickname( nickname string, channelIDBytes []byte) error
SetNickname sets the nickname for a given channel. The nickname must be valid according to IsNicknameValid.
Parameters:
- nickname - The new nickname.
- channelIDBytes - The marshalled bytes of the channel's id.ID.
func (*ChannelsManager) VerifyChannelAdminKey ¶ added in v4.4.4
func (cm *ChannelsManager) VerifyChannelAdminKey( channelIdBytes []byte, encryptionPassword string, encryptedPrivKey []byte) ( bool, error)
VerifyChannelAdminKey verifies that the encrypted private key can be decrypted and that it matches the expected channel. Returns false if private key does not belong to the given channel.
Parameters:
- channelIdBytes - Marshalled bytes of the channel's id.ID.
- encryptionPassword - The password used to encrypt the private key.
- encryptedPrivKey - The encrypted channel private key packet.
Returns:
- bool - True if the private key belongs to the channel and false otherwise.
- Returns the error channels.WrongPasswordErr for an invalid password.
- Returns the error channels.ChannelDoesNotExistsErr if the channel has not already been joined.
type ClientError ¶
type ClientError interface {
Report(source, message, trace string)
}
type Cmix ¶
Cmix wraps the xxdk.Cmix struct, implementing additional functions to support the bindings Cmix interface.
func GetCMixInstance ¶ added in v4.6.3
GetCMixInstance gets the bindings.Cmix for the given Cmix instanceID.
This function is not used by Go bindings and is intended to be used by other wrappers.
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 LoadSynchronizedCmix ¶ added in v4.7.1
func LoadSynchronizedCmix(storageDir, remoteStoragePathPrefix string, password []byte, remote RemoteStore, cmixParamsJSON []byte) (*Cmix, error)
LoadSynchronizedCmix will load an existing user storage from the storageDir along with a remote store object. Writes to any keys inside a synchronized prefix will be saved to a remote store transaction log, and writes from other cMix instances will be tracked by reading transaction logs written by other instances.
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. This can take a while if there are a lot of transactions to replay by other instances.
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) EKVGet ¶ added in v4.6.3
EKVGet allows access to a value inside secure encrypted key value store
func (*Cmix) EKVSet ¶ added in v4.6.3
EKVSet allows user to set a value inside secure encrypted key value store
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) GetReceptionID ¶ added in v4.6.3
GetReceptionID returns the Default Reception Identity for this cMix Instance
func (*Cmix) GetReceptionRegistrationValidationSignature ¶
GetReceptionRegistrationValidationSignature returns the signature provided by the xx network.
func (*Cmix) GetRemoteKV ¶ added in v4.7.1
GetRemoteKV returns the underlying RemoteKV storage so it can be interacted with directly. TODO: force this into a synchronized prefix?
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) SetTrackNetworkPeriod ¶ added in v4.4.4
SetTrackNetworkPeriod allows changing the frequency that follower threads are started.
Note that the frequency of the follower threads affect the power usage of the device following the network.
- Low period -> Higher frequency of polling -> Higher battery usage
- High period -> Lower frequency of polling -> Lower battery usage
This may be used to enable a low power (or battery optimization) mode for the end user.
Suggested values are provided, however there are no guarantees that these values will perfectly fit what the end user's device would require to match the user's expectations:
- Low Power Usage: 5000 milliseconds
- High Power Usage: 1000 milliseconds (default, see cmix.DefaultFollowPeriod
Parameters:
- periodMS - The duration of the period, in milliseconds.
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 that the backend keeps track of, which is formally referred to as a [message.ServiceList]. This may be passed into other bindings calls that 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 JSON of [message.ServiceList].
func (*Cmix) TrackServicesWithIdentity ¶
func (c *Cmix) TrackServicesWithIdentity(e2eId int, cb TrackServicesCallback, compressedCb TrackCompressedServicesCallback) error
TrackServicesWithIdentity will return, via a callback, the list of services that the backend keeps track of for the provided identity. This may be passed into other bindings calls that may need context on the available services for this single identity. This will only return services for the given identity.
Parameters:
- e2eID - ID of E2e object in tracker.
- cb - A TrackServicesCallback, which will be passed the JSON of [message.ServiceList].
- compressedCb - A TrackCompressedServicesCallback, which will be passed the JSON of [message.CompressedServiceList].
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 DMClient ¶ added in v4.4.4
type DMClient struct {
// contains filtered or unexported fields
}
DMClient is the bindings level interface for the direct messaging client. It implements all the dm.Client functions but converts from basic types that are friendly to gomobile and Javascript WASM interfaces (e.g., []byte, int, and string).
Users of the bindings API can create multiple DMClient objects, which are tracked via a private singleton.
func GetDMInstance ¶ added in v4.6.3
func NewDMClient ¶ added in v4.4.4
func NewDMClient(cmixID, notificationsID int, privateIdentity []byte, receiverBuilder DMReceiverBuilder, cbs DmCallbacks) (*DMClient, error)
NewDMClient creates a new DMClient from a private identity (codename.PrivateIdentity), used for direct messaging.
This is for instantiating a manager for an identity. For generating a new identity, use codename.GenerateIdentity. You should instantiate every load as there is no load function and associated state in this module.
Parameters:
- cmixID - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- privateIdentity - Bytes of a private identity (codename.PrivateIdentity) that is generated by codename.GenerateIdentity.
- receiverBuilder - An interface that contains a function that initialises and returns an EventModel that is bindings-compatible.
- cbs - Callbacks is an interface that provides updates about information relating to DM conversations. The interface may be nil, but if one is provided, each method must be implemented.
func NewDMClientWithGoEventModel ¶ added in v4.4.4
func NewDMClientWithGoEventModel(cmixID, notificationsID int, privateIdentity []byte, receiver dm.EventModel, cbs DmCallbacks) (*DMClient, error)
NewDMClientWithGoEventModel creates a new DMClient from a private identity (codename.PrivateIdentity). This is not compatible with GoMobile bindings because it receives the go event model.
This is for instantiating a manager for an identity. For generating a new identity, use codename.GenerateIdentity. You should instantiate every load as there is no load function and associated state in this module.
Parameters:
- cmixID - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- privateIdentity - Bytes of a private identity (codename.PrivateIdentity) that is generated by codename.GenerateIdentity.
- receiver - The dm.EventModel.
- cbs - Callbacks is an interface that provides updates about information relating to DM conversations. The interface may be nil, but if one is provided, each method must be implemented.
func NewDmManagerMobile ¶ added in v4.6.3
func NewDmManagerMobile(cmixID, notificationsID int, privateIdentity []byte, dbFilePath string, cbs DmCallbacks) (*DMClient, error)
NewDmManagerMobile loads an existing DMClient for the given storage tag backed with SqlLite for mobile use.
Parameters:
- cmixID - ID of Cmix object in tracker. This can be retrieved using Cmix.GetID.
- notificationsID - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID.
- privateIdentity - Bytes of a private identity (codename.PrivateIdentity) that is generated by codename.GenerateIdentity.
- dbFilePath - absolute string path to the SqlLite database file
- cbs - Callbacks is an interface that provides updates about information relating to DM conversations. The interface may be nil, but if one is provided, each method must be implemented.
func (*DMClient) BlockPartner ¶ added in v4.7.1
BlockPartner prevents receiving messages and notifications from the partner.
Parameters:
- partnerPubKey - The partner's Ed25519 public key to block.
func (*DMClient) DeleteMessage ¶ added in v4.7.1
func (dmc *DMClient) DeleteMessage(partnerPubKeyBytes []byte, partnerToken int32, targetMessageIdBytes []byte, cmixParamsJSON []byte) ([]byte, error)
DeleteMessage sends a message to the partner to delete a message this user sent. Also deletes it from the local database.
Parameters:
- partnerPubKeyBytes - The bytes of the public key of the partner's ED25519 signing key.
- partnerToken - The token used to derive the reception ID for the partner.
- targetMessageIdBytes - The bytes of the [message.ID] of the message to delete. This may be found in the ChannelSendReport.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
func (*DMClient) ExportPrivateIdentity ¶ added in v4.4.4
ExportPrivateIdentity encrypts and exports the private identity to a portable string.
func (*DMClient) GetBlockedPartners ¶ added in v4.7.1
GetBlockedPartners returns all partners who are blocked by this user.
Returns:
- []byte - JSON of of an array of ed25519.PublicKey.
Example return:
[ "TYWuCfyGBjNWDtl/Roa6f/o206yYPpuB6sX2kJZTe98=", "4JLRzgtW1SZ9c5pE+v0WwrGPj1t19AuU6Gg5IND5ymA=", "CWDqF1bnhulW2pko+zgmbDZNaKkmNtFdUgY4bTm2DhA=" ]
func (*DMClient) GetIdentity ¶ added in v4.4.4
GetIdentity returns the public identity associated with this client.
func (*DMClient) GetNickname ¶ added in v4.4.4
GetNickname gets the nickname associated with this DM user.
func (*DMClient) GetNotificationLevel ¶ added in v4.7.1
GetNotificationLevel returns the notification level for the given channel.
Parameters:
- partnerPubKey - The partner's Ed25519 public key.
Returns:
- int - The dm.NotificationLevel to set for the DM conversation.
func (*DMClient) GetPublicKey ¶ added in v4.4.4
GetPublicKey returns the bytes of the public key for this client.
func (*DMClient) GetShareURL ¶ added in v4.6.3
GetShareURL generates a URL that can be used to share a URL to initiate d direct messages with this user.
Parameters:
- host - The URL to append the DM info to.
Returns:
- JSON of DMShareURL.
func (*DMClient) IsBlocked ¶ added in v4.5.0
IsBlocked indicates if the given partner is blocked.
Parameters:
- partnerPubKey - The partner's Ed25519 public key to check.
func (*DMClient) Send ¶ added in v4.4.4
func (dmc *DMClient) Send(partnerPubKeyBytes []byte, partnerToken int32, messageType int, plaintext []byte, leaseTimeMS int64, cmixParamsJSON []byte) ([]byte, error)
Send is used to send a raw message. 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 is not 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 leaseTimeMS depends on the use case.
Parameters:
- partnerPubKeyBytes - The bytes of the public key of the partner's ED25519 signing key.
- partnerToken - The token used to derive the reception ID for the partner.
- messageType - The message type of the message. This will be a valid dm.MessageType.
- plaintext - 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 - JSON of xxdk.CMIXParams. If left empty, then GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport.
func (*DMClient) SendInvite ¶ added in v4.7.1
func (dmc *DMClient) SendInvite(partnerPubKeyBytes []byte, partnerToken int32, inviteToChannelJson []byte, message string, host string, cmixParamsJSON []byte) ([]byte, error)
SendInvite is used to send to a DM partner an invitation to another channel.
The reception of an invitation will be handled by dm.DMReceiver.Receive, passing in a dm.MessageType of value dm.InvitationType. The message will be JSON encoded. Example invite JSON:
{ "text": "Check this channel out!", "inviteLink": "https://internet.speakeasy.tech/?0Name=name&1Description=description&2Level=Public&3Created=1687359213751145652&e=gnnLqhgsNJE7uFTLRsv1q%2FzgHBesVsezln4mg4mQZ70%3D&k=aOULKJDhSkNOou7CwsybaNTrdfrUS55%2Ffv%2FuHjX2Mc4%3D&l=928&m=0&p=1&s=cN2iHg6b5FdViS4q46QMolQUF0BZt98NEiO6NKrL1d0%3D&v=1", "password": "secret" }
Parameters:
- partnerPubKeyBytes - The bytes of the public key of the partner's ED25519 signing key.
- partnerToken - The token used to derive the reception ID for the partner.
- inviteToChannelJson - A JSON marshalled channel. This should be the data of the invitee channel. This can be retrieved from GetChannelJSON.
- 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.
- host - The URL to append the channel info to.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
func (*DMClient) SendReaction ¶ added in v4.4.4
func (dmc *DMClient) SendReaction(partnerPubKeyBytes []byte, partnerToken int32, reaction string, reactToBytes []byte, cmixParamsJSON []byte) ([]byte, error)
SendReaction is used to send a reaction to a direct message. The reaction must be a single emoji with no other characters, and will be rejected otherwise.
Clients will drop the reaction if they do not recognize the reactTo message.
Parameters:
- partnerPubKeyBytes - The bytes of the public key of the partner's ED25519 signing key.
- partnerToken - The token used to derive the reception ID for the partner.
- reaction - The user's reaction. This should be a single emoji with no other characters. As such, a Unicode string is expected.
- reactToBytes - The bytes of the [message.ID] of the message you wish to react 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 ChannelsManager.RegisterReceiveHandler.
- cmixParamsJSON - JSON of xxdk.CMIXParams. If left empty, then GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport.
func (*DMClient) SendReply ¶ added in v4.4.4
func (dmc *DMClient) SendReply(partnerPubKeyBytes []byte, partnerToken int32, replyMessage string, replyToBytes []byte, leaseTimeMS int64, cmixParamsJSON []byte) ([]byte, error)
SendReply is used to send a formatted direct message reply.
If the message ID that the reply is sent to does not exist, then the other side will post the message as a normal message and not as a reply.
The message will auto delete leaseTime after the round it is sent in, lasting forever if ValidForever is used.
Parameters:
- partnerPubKeyBytes - The bytes of the public key of the partner's ED25519 signing key.
- partnerToken - The token used to derive the reception ID for the partner.
- replyMessage - The contents of the reply message. The message should be at most 510 bytes. This is expected to be Unicode, and thus a string data type is expected
- replyToBytes - The bytes of the [message.ID] 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 ChannelsManager.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 - JSON of xxdk.CMIXParams. If left empty, then GetDefaultCMixParams will be used internally.
Returns:
- []byte - A JSON marshalled ChannelSendReport
func (*DMClient) SendSilent ¶ added in v4.7.1
func (dmc *DMClient) SendSilent(partnerPubKeyBytes []byte, partnerToken int32, cmixParamsJSON []byte) ([]byte, error)
SendSilent is used to send to a channel a message with no notifications. Its primary purpose is to communicate new nicknames without calling [Send].
It takes no payload intentionally as the message should be very lightweight.
Parameters:
- partnerPubKeyBytes - The bytes of the public key of the partner's ED25519 signing key.
- partnerToken - The token used to derive the reception ID for the partner.
- cmixParamsJSON - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.
func (*DMClient) SendText ¶ added in v4.4.4
func (dmc *DMClient) SendText(partnerPubKeyBytes []byte, partnerToken int32, message string, leaseTimeMS int64, cmixParamsJSON []byte) ([]byte, error)
SendText is used to send a formatted direct message to a user.
Parameters:
- partnerPubKeyBytes - The bytes of the public key of the partner's ED25519 signing key.
- partnerToken - The token used to derive the reception ID for the partner.
- 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 - JSON of xxdk.CMIXParams. If left empty, then GetDefaultCMixParams will be used internally.
Returns:
- []byte - SON of ChannelSendReport.
func (*DMClient) SetMobileNotificationsLevel ¶ added in v4.7.1
SetMobileNotificationsLevel sets the notification level for the given DM conversation partner.
Parameters:
- partnerPubKey - The partner's Ed25519 public key.
- level - The dm.NotificationLevel to set for the DM conversation.
func (*DMClient) SetNickname ¶ added in v4.4.4
SetNickname sets the nickname to use for this user.
func (*DMClient) UnblockPartner ¶ added in v4.7.1
UnblockPartner unblocks a blocked partner to allow DM messages.
Parameters:
- partnerPubKey - The partner's Ed25519 public key to unblock.
type DMReceiver ¶ added in v4.4.4
type DMReceiver dm.DMReceiver
type DMReceiverBuilder ¶ added in v4.4.4
type DMReceiverBuilder interface {
Build(path string) DMReceiver
}
DMReceiverBuilder builds an event model.
type DMShareURL ¶ added in v4.6.3
type DMShareURL struct {}
DMShareURL is returned from DMClient.GetShareURL. It includes the user's share URL.
JSON example for a user:
{ "url": "https://internet.speakeasy.tech/?l=32&m=5&p=EfDzQDa4fQ5BoqNIMbECFDY9ckRr_fadd8F1jE49qJc%3D&t=4231817746&v=1", "password": "hunter2", }
type DMUser ¶ added in v4.6.3
DMUser is returned from DecodeDMShareURL. It includes the token and public key of the user who created the URL.
JSON example for a user:
{ "token": 4231817746, "publicKey": "EfDzQDa4fQ5BoqNIMbECFDY9ckRr/fadd8F1jE49qJc=" }
type DmBlockedUserJSON ¶ added in v4.7.1
type DmBlockedUserJSON struct { User ed25519.PublicKey `json:"user"` Blocked bool `json:"blocked"` }
DmBlockedUserJSON contains a user's public key and if they are blocked or unblocked.
Fields:
- User - The DM partner's ed25519.PublicKey.
- Blocked - True if the user is blocked and false if they are unblocked.
Example JSON:
{ "user": "pB87FR7Ci0EDVUEg+aTHl+CJFmzW9qCQEynURJgRBtM=", "blocked": true }
type DmCallbacks ¶ added in v4.7.1
type DmMessageDeletedJSON ¶ added in v4.7.1
DmMessageDeletedJSON is returned any time a DM message.
Fields:
- MessageID - The [message.ID] of the deleted message in the database.
Example JSON:
{ "messageID": "yGO7PZsOpEs+A1DgEIAyTXxpOwBEtMpShqV7h5EtJYw=" }
type DmMessageReceivedJSON ¶ added in v4.7.1
type DmMessageReceivedJSON struct { UUID uint64 `json:"uuid"` PubKey ed25519.PublicKey `json:"pubKey"` MessageUpdate bool `json:"messageUpdate"` ConversationUpdate bool `json:"conversationUpdate"` }
DmMessageReceivedJSON is returned any time a DM message is received or updated.
Fields:
- UUID - The UUID of the message in the database.
- PubKey - The public key of the sender.
- MessageUpdate - Is true if the message already exists and was edited.
- ConversationUpdate - Is true if the conversation was created or modified.
Example JSON:
{ "uuid": 3458558585156768347, "pubKey": "Ky0C1gc/j6ingV0+2v39Oc8ukBOf+Gp9HNiBwM7aIdQ=", "messageUpdate": true, "conversationUpdate": true }
type DmNotificationUpdateJSON ¶ added in v4.7.1
type DmNotificationUpdateJSON struct { NotificationFilter dm.NotificationFilter `json:"notificationFilter"` Changed []dm.NotificationState `json:"changed"` Deleted []ed25519.PublicKey `json:"deleted"` }
DmNotificationUpdateJSON contains updates describing DM notifications.
Fields:
- nfJSON - The dm.NotificationFilter, which is passed into GetDmNotificationReportsForMe to filter DM notifications for the user.
- changedStateListJSON - A slice of dm.NotificationState that includes all added or changed notification states for DM conversations.
- deletedListJSON - A slice of ed25519.PublicKey that includes conversation that were deleted.
Example JSON:
{ "notificationFilter": { "identifier": "MWL6mvtZ9UUm7jP3ainyI4erbRl+wyVaO5MOWboP0rA=", "myID": "aXCGa8Exf8ah0jKgQ5RpsJxRSCclgLnCVfHN/iKmyD4D", "tags": [ "V/6lH5Ovo2EnQVJLX/g6wFmYReNlMFnprLAAlhZ8S5g=", "+sSL0it/lwW7mTMTqJek1rvM1X04tm3Vu8lN6ISBG0k=" ], "publicKeys": { "+sSL0it/lwW7mTMTqJek1rvM1X04tm3Vu8lN6ISBG0k=": "WujWUQ/IRIZIRVDocUCU+jefl4SL55VCFjfh9enXh8A=", "V/6lH5Ovo2EnQVJLX/g6wFmYReNlMFnprLAAlhZ8S5g=": "nUXMBXLZIF1zhFulPpufEndQQnFwK9nIoMmdVqT0qDQ=" }, "allowedTypes": { "1": {}, "2": {} } }, "changed": [ { "pubKey": "nUXMBXLZIF1zhFulPpufEndQQnFwK9nIoMmdVqT0qDQ=", "level": 40 }, { "pubKey": "2IOMwtynDdZNLrfwuC+yjJR/AlsqtXSVi2m6Z8xDvsk=", "level": 10 } ], "deleted": [ "0gire0TcHxTCX/o/T7cl1UMhH/Wo+m6KyxY63VOafIo=" ] }
type DmTokenUpdateJSON ¶ added in v4.7.1
type DmTokenUpdateJSON struct { ChannelId *id.ID `json:"channelID"` SendToken bool `json:"sendToken"` }
DmTokenUpdateJSON describes when the sending of dm tokens is enabled or disabled on a specific channel
Example JSON:
{ "channelID":"KdkEjm+OfQuK4AyZGAqh+XPQaLfRhsO5d2NT1EIScyJX", "sendToken":true }
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 is by default paused, and as such the sending thread must be started by calling DummyTraffic.Start. 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 the status returned here may lag behind a user's earlier call to pause the sending thread. This is a result of a small delay (see DummyTraffic.Pause for more details)
Returns:
- bool - Returns true (dummy.Running) if the sending thread is sending messages and false (dummy.Paused) if the sending thread is not sending messages.
func (*DummyTraffic) Pause ¶ added in v4.4.4
func (dt *DummyTraffic) Pause() error
Pause will pause the Manager's sending thread, meaning messages will no longer be sent. After calling Pause, the sending thread may only be resumed by calling Resume.
There may be a small delay between this call and the pause taking effect. This is because Pause will not cancel the thread when it is in the process of sending messages, but will instead wait for that thread to complete. The thread will then be prevented from beginning another round of sending.
func (*DummyTraffic) Start ¶ added in v4.4.4
func (dt *DummyTraffic) Start() error
Start will start up the Manager's sending thread, meaning messages will
be sent. This should be called after calling NewManager, as by default the thread is paused. This may also be called after a call to Pause.
This will re-initialize the sending thread with a new randomly generated interval between sending dummy messages. This means that there is zero guarantee that the sending interval prior to pausing will be the same sending interval after a call to Start.
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. // // The API needs to return a UUID of the message that can be referenced at a // later time. // // messageID, timestamp, and roundID are all nillable and may be updated // based upon the UUID at a later date. A value of 0 will be passed for a // nilled timestamp or roundID. // // nickname may be empty, in which case the UI is expected to display the // codename. // // messageType is included in the call; it will always be [channels.Text] // (1) for this call, but it may be required in downstream databases. // // 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. // - messageType - 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: // - int64 - A non-negative unique UUID for the message that it can be // referenced by later with [EventModel.UpdateFromUUID]. ReceiveMessage(channelID, messageID []byte, nickname, text string, pubKey []byte, dmToken int32, codeset int, timestamp, lease, roundID, messageType, status int64, hidden bool) 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. // // The API needs to return a UUID of the message that can be referenced at a // later time. // // messageID, timestamp, and roundID are all nillable and may be updated // based upon the UUID at a later date. A value of 0 will be passed for a // nilled timestamp or roundID. // // nickname may be empty, in which case the UI is expected to display the // codename. // // messageType type is included in the call; it will always be // [channels.Text] (1) for this call, but it may be required in downstream // databases. // // 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. // - messageType - 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: // - int64 - A non-negative unique UUID for the message that it can be // referenced by later with [EventModel.UpdateFromUUID]. ReceiveReply(channelID, messageID, reactionTo []byte, nickname, text string, pubKey []byte, dmToken int32, codeset int, timestamp, lease, roundID, messageType, status int64, hidden bool) 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 // replies. // // The API needs to return a UUID of the message that can be referenced at a // later time. // // messageID, timestamp, and roundID are all nillable and may be updated // based upon the UUID at a later date. A value of 0 will be passed for a // nilled timestamp or roundID. // // nickname may be empty, in which case the UI is expected to display the // codename. // // messageType type is included in the call; it will always be // [channels.Text] (1) for this call, but it may be required in downstream // databases. // // 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. // - messageType - 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: // - int64 - A non-negative unique UUID for the message that it can be // referenced by later with [EventModel.UpdateFromUUID]. ReceiveReaction(channelID, messageID, reactionTo []byte, nickname, reaction string, pubKey []byte, dmToken int32, codeset int, timestamp, lease, roundID, messageType, status int64, hidden bool) int64 // UpdateFromUUID is called whenever a message at the UUID is modified. // // MessageID, Timestamp, RoundID, Pinned, Hidden, and Status in the // [MessageUpdateInfo] may be empty (as indicated by their associated // boolean) and updated based upon the UUID at a later date. // // Parameters: // - uuid - The unique identifier of the message in the database. // - messageUpdateInfoJSON - JSON of [MessageUpdateInfo]. // // Returns: // - Returns an error if the message cannot be updated. It must return the // error from GetNoMessageErr if the message does not exist. UpdateFromUUID(uuid int64, messageUpdateInfoJSON []byte) error // UpdateFromMessageID is called whenever a message with the message ID is // modified. // // Timestamp, RoundID, Pinned, Hidden, and Status in the [MessageUpdateInfo] // may be empty (as indicated by their associated boolean) and updated based // upon the UUID at a later date. // // Parameters: // - messageID - The bytes of the [channel.MessageID] of the received // message. // - messageUpdateInfoJSON - JSON of [MessageUpdateInfo]. // // Returns: // - int64 - A non-negative unique UUID for the message that it can be // referenced by later with [EventModel.UpdateFromUUID]. // - Returns an error if the message cannot be updated. It must return the // error from GetNoMessageErr if the message does not exist. UpdateFromMessageID( messageID []byte, messageUpdateInfoJSON []byte) (int64, error) // GetMessage returns the message with the given [channel.MessageID]. // // Parameters: // - messageID - The bytes of the [channel.MessageID] of the message. // // Returns: // - JSON of [channels.ModelMessage]. // - Returns an error if the message cannot be gotten. It must return the // error from GetNoMessageErr if the message does not exist. GetMessage(messageID []byte) ([]byte, error) // DeleteMessage deletes the message with the given [channel.MessageID] from // the database. // // Parameters: // - messageID - The bytes of the [channel.MessageID] of the message. // - Returns an error if the message cannot be deleted. It must return the // error from GetNoMessageErr if the message does not exist. DeleteMessage(messageID []byte) error // MuteUser mutes the given user or unmutes them. // // Parameters: // - channelID - The bytes of the [id.ID] of the channel the user is being // muted in. // - pubKey - The Ed25519 public key of the user that is muted or unmuted. MuteUser(channelID, pubkey []byte, unmute bool) }
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/v4/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 FtReceivedProgress ¶ added in v4.6.3
type FtReceivedProgress struct { ID ftCrypto.ID `json:"id"` // File ID Completed bool `json:"completed"` // True if transfer is successful Received int `json:"received"` // Number of parts received Total int `json:"total"` // Total number of file parts }
FtReceivedProgress contains the progress information of a received file transfer.
Example JSON:
{ "id": "RyJcMqtI3IIM1+YMxRwCcFiOX6AGuIzS+vQaPnqXVT8=", "completed": false, "received": 145, "Total": 2048 }
type FtReceivedProgressCallback ¶ added in v4.6.3
type FtReceivedProgressCallback interface {
Callback(payload []byte, fpt *ChFilePartTracker, err error)
}
FtReceivedProgressCallback contains the method Callback that is called when the progress on a received file changes or an error occurs in the transfer.
The ChFilePartTracker can be used to look up the status of individual file parts. Note, when completed == true, the ChFilePartTracker may be nil.
This callback only indicates the status of the file transfer, not the status of the file in the event model. Do NOT use this callback as an indicator of when the file is available in the event model.
Parameters:
- payload - JSON of FtReceivedProgress, which describes the progress of the current received transfer.
- fpt - File part tracker that allows the lookup of the status of individual file parts.
- err - Fatal errors during receiving.
type FtSentProgress ¶ added in v4.6.3
type FtSentProgress struct { ID ftCrypto.ID `json:"id"` // File ID Completed bool `json:"completed"` // True if transfer is successful Sent int `json:"sent"` // Number of parts sent Received int `json:"received"` // Number of parts received Total int `json:"total"` // Total number of file parts }
FtSentProgress contains the progress information of a sent file transfer.
Example JSON:
{ "id": "RyJcMqtI3IIM1+YMxRwCcFiOX6AGuIzS+vQaPnqXVT8=", "completed": false, "sent": 6, "received": 145, "Total": 2048 }
type FtSentProgressCallback ¶ added in v4.6.3
type FtSentProgressCallback interface {
Callback(payload []byte, fpt *ChFilePartTracker, err error)
}
FtSentProgressCallback contains the method Callback that is called when the progress on a sent file changes or an error occurs in the transfer.
The ChFilePartTracker can be used to look up the status of individual file parts. Note, when completed == true, the ChFilePartTracker may be nil.
Any error returned is fatal and the file must either be retried with ChannelsFileTransfer.RetryUpload or canceled with ChannelsFileTransfer.CloseSend.
This callback only indicates the status of the file transfer, not the status of the file in the event model. Do NOT use this callback as an indicator of when the file is available in the event model.
Parameters:
- payload - JSON of FtSentProgress, which describes the progress of the current sent transfer.
- fpt - File part tracker that allows the lookup of the status of individual file parts.
- err - Fatal errors during sending.
type GetTokenJson ¶ added in v4.7.1
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 KeyChangedByRemoteCallback ¶ added in v4.7.1
KeyChangedByRemoteCallback is the callback used to report local updates caused by a remote client editing their EKV
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 MapChangedByRemoteCallback ¶ added in v4.7.1
MapChangedByRemoteCallback is the callback used to report local updates caused by a remote client editing their EKV
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 MessageDeletedJSON ¶ added in v4.7.1
MessageDeletedJSON is returned any time a message is deleted.
Example JSON:
{ "messageID":"i9b7tL5sUmObxqW1LApC9H/yvnQzsRfq7yc8SCBtlK0=" }
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 MessageReceivedJSON ¶ added in v4.7.1
type MessageReceivedJSON struct { UUID int64 `json:"uuid"` ChannelID *id.ID `json:"channelID"` Update bool `json:"update"` }
MessageReceivedJSON is returned any time a message is received or updated. Update is true if the row is old and was edited.
Example JSON:
{ "uuid":32, "channelID":"Z1owNo+GvizWshVW/C5IJ1izPD5oqMkCGr+PsA5If4HZ", "update":false }
type MessageUpdateInfo ¶ added in v4.4.4
type MessageUpdateInfo struct { // MessageID is the bytes of the [channel.MessageID] of the received // message. MessageID []byte MessageIDSet bool // Timestamp, in milliseconds, when the message was sent. Timestamp int64 TimestampSet bool // RoundID is the [id.Round] the message was sent on. RoundID int64 RoundIDSet bool // Pinned is true if the message is pinned. Pinned bool PinnedSet bool // Hidden is true if the message is hidden Hidden bool HiddenSet bool // Status is the [channels.SentStatus] of the message. // Sent = 1 // Delivered = 2 // Failed = 3 Status int64 StatusSet bool }
MessageUpdateInfo contains the updated information for a channel message. Only update fields that have their set field set as true.
type NetworkHealthCallback ¶
type NetworkHealthCallback interface {
Callback(bool)
}
NetworkHealthCallback contains a callback that is used to receive notification if network health changes.
type NickNameUpdateJSON ¶ added in v4.7.1
type NickNameUpdateJSON struct { ChannelId *id.ID `json:"channelID"` Nickname string `json:"nickname"` Exists bool `json:"exists"` }
NickNameUpdateJSON is describes when your nickname changes due to a change on a remote.
Example JSON:
{ "channelID": "JsU7+QYpybOy/xgjYrJW675XRonGRoZj3YGFWzu/SoID", "nickname": "billNyeTheScienceGuy", "exists": true }
type NodeRegistrationReport ¶
NodeRegistrationReport is the report structure which Cmix.GetNodeRegistrationStatus returns JSON marshalled.
type NotificationUpdateJSON ¶ added in v4.7.1
type NotificationUpdateJSON struct { NotificationFilters []channels.NotificationFilter `json:"notificationFilters"` ChangedNotificationStates []channels.NotificationState `json:"changedNotificationStates"` DeletedNotificationStates []*id.ID `json:"deletedNotificationStates"` MaxState clientNotif.NotificationState `json:"maxState"` }
NotificationUpdateJSON describes any time a notification level changes.
Contains:
- notificationFilters - JSON of slice of channels.NotificationFilter, which is passed into GetChannelNotificationReportsForMe to filter channel notifications for the user.
- changedNotificationStates - JSON of slice of channels.NotificationState of added or changed channel notification statuses.
- deletedNotificationStates - JSON of slice of id.ID of deleted channel notification statuses.
- maxState - The global notification state.
Example JSON:
{ "notificationFilters": [ { "identifier": "Z1owNo+GvizWshVW/C5IJ1izPD5oqMkCGr+PsA5If4EDQXN5bW1Ub1B1YmxpY0JjYXN0", "channelID": "Z1owNo+GvizWshVW/C5IJ1izPD5oqMkCGr+PsA5If4ED", "tags": ["af35cdae2159477d79f7ab33bf0bb73ccc1f212bfdc1b3ae78cf398c02878e01-usrping"], "allowLists": { "allowWithTags": {"2": {}}, "allowWithoutTags": {"102": {}} } }, { "identifier": "Z1owNo+GvizWshVW/C5IJ1izPD5oqMkCGr+PsA5If4EDU3ltbWV0cmljQnJvYWRjYXN0", "channelID": "Z1owNo+GvizWshVW/C5IJ1izPD5oqMkCGr+PsA5If4ED", "tags": ["af35cdae2159477d79f7ab33bf0bb73ccc1f212bfdc1b3ae78cf398c02878e01-usrping"], "allowLists": { "allowWithTags": {"1": {}, "40000": {}}, "allowWithoutTags": {} } }, { "identifier": "xsrTzBVFS9s0ccPpgSwBRjCFP5ZYUibswfnhLbjrePoDQXN5bW1Ub1B1YmxpY0JjYXN0", "channelID": "xsrTzBVFS9s0ccPpgSwBRjCFP5ZYUibswfnhLbjrePoD", "tags": ["4f4b35a64a3bd7b06614c2f48d0cdda8b2220ca0fcba78cd2ed11ba38afc92f2-usrping"], "allowLists": { "allowWithTags": {"2": {}}, "allowWithoutTags": {"102": {}} } } ], "changedNotificationStates": [ { "channelID": "Z1owNo+GvizWshVW/C5IJ1izPD5oqMkCGr+PsA5If4ED", "level": 20, "status": 2 }, { "channelID": "gZ4uFg/NaSGJVED3hH+PsezGwkZExgPeRxITlfjXZDUD", "level": 40, "status": 2 } ], "deletedNotificationStates": [ "ZGVsZXRlZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" ], "maxState": 2 }
type Notifications ¶ added in v4.7.1
type Notifications struct {
// contains filtered or unexported fields
}
func LoadNotifications ¶ added in v4.7.1
func LoadNotifications(cmixId int) (*Notifications, error)
func LoadNotificationsDummy ¶ added in v4.7.1
func LoadNotificationsDummy(cmixId int) (*Notifications, error)
func (*Notifications) AddToken ¶ added in v4.7.1
func (n *Notifications) AddToken(newToken, app string) error
AddToken registers the Token with the remote server if this manager is in set to register, otherwise it will return ErrRemoteRegistrationDisabled This will add the token to the list of tokens which are forwarded the messages for connected IDs. the App will tell the server what App to forward the notifications to.
func (*Notifications) GetID ¶ added in v4.7.1
func (n *Notifications) GetID() int
GetID returns the ID of the notifications object
func (*Notifications) GetMaxState ¶ added in v4.7.1
func (n *Notifications) GetMaxState() int64
GetMaxState returns the current MaxState
func (*Notifications) GetToken ¶ added in v4.7.1
func (n *Notifications) GetToken() ([]byte, error)
GetToken returns the token if it exists
{ "exists":true, "Token":"Z1owNo+GvizWshVW/C5IJ1izPD5oqMkCGr+PsA5If4HZ", "App":"havenIOS" }
func (*Notifications) RemoveToken ¶ added in v4.7.1
func (n *Notifications) RemoveToken() error
RemoveToken removes the given Token from the server It will remove all registered identities if it is the last Token
func (*Notifications) SetMaxState ¶ added in v4.7.1
func (n *Notifications) SetMaxState(maxState int64) error
SetMaxState sets the maximum functional state of any identity downstream moduals will be told to clamp any state greater than maxState down to maxState. Depending on UX requirements, they may still show the state in an altered manner, for example greying out a description. This is designed so when the state is raised, the old configs are maintained. This will unregister / re-register with the push server when leaving or entering the Push maxState. The default maxState is Push will return an error if the maxState isnt a valid state
MaxState can be:
Mute shows no notifications for the ID. - Mute = 0 WhenOpen shows notifications for this ID only when the app is running and open. No registration or privacy leaks occur in this state. - WhenOpen = 1 Push shows notifications for this ID as push notification on applicable devices. This state has a minor privacy loss. - Push = 2
type Processor ¶
type Processor interface { Process( message, tags, metadata, receptionId []byte, ephemeralId, 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 RPCResponse ¶ added in v4.7.3
type RPCResponse interface { // Callback calls success or error function if/when the // response is received. Meant to be very similar to Promise/async // found in other languages. // RPC will call respFn 3 times: sent, round finished, and // response received. Callback(cbs RPCResponseCallbacks) RPCResponse // Await waits until the response is complete returns the final // response bytes Await() []byte }
Response interface for RPC responses from the [Send] function. Provides for the ability to call a callback on error or success or to listen on the channels directly.
func RPCSend ¶ added in v4.7.3
func RPCSend(cMixID int, recipient, pubkey, request []byte) RPCResponse
RPCSend sends an RPC `request` to the provided server `recipient` and `pubkey`. It returns a `Response` Object which
type RPCResponseCallbacks ¶ added in v4.7.3
RPCResponseCallbacks implements the callback functions for an RPCResponse This is required because of gomobile restrictions.
type RPCServer ¶ added in v4.7.3
type RPCServer interface { // Start listening on the server's cMix Identity Start() // Stop listening on the server's cMix Identity // Note: if you want to stop all network traffic, do // so with the cMix network client. Stop() }
RPCServer is the interface for the RPC server, users should add a callback then start listening for RPC requests.
func LoadRPCServer ¶ added in v4.7.3
func LoadRPCServer(cMixID int, callback RPCServerCallback) ( RPCServer, error)
LoadRPCServer load key and id from disk and return an RPC server
func NewRPCServer ¶ added in v4.7.3
func NewRPCServer(cMixID int, callback RPCServerCallback, receptionID, privateKey []byte) (RPCServer, error)
NewRPCServer returns a new RPC server with the specified reception ID and private Key
type RPCServerCallback ¶ added in v4.7.3
RPCServerCallback implements the server callback function This is required due to gomobile restrictions.
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", "RSAPrivate":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" "E2eGrp": "eyJnZW4iOiIyIiwicHJpbWUiOiJlMmVlOTgzZDAzMWRjMWRiNmYxYTdhNjdkZjBlOWE4ZTU1NjFkYjhlOGQ0OTQxMzM5NGMwNDliN2E4YWNjZWRjMjk4NzA4ZjEyMTk1MWQ5Y2Y5MjBlYzVkMTQ2NzI3YWE0YWU1MzViMDkyMmM2ODhiNTViM2RkMmFlZGY2YzAxYzk0NzY0ZGFiOTM3OTM1YWE4M2JlMzZlNjc3NjA3MTNhYjQ0YTYzMzdjMjBlNzg2MTU3NWU3NDVkMzFmOGI5ZTlhZDg0MTIxMThjNjJhM2UyZTI5ZGY0NmIwODY0ZDBjOTUxYzM5NGE1Y2JiZGM2YWRjNzE4ZGQyYTNlMDQxMDIzZGJiNWFiMjNlYmI0NzQyZGU5YzE2ODdiNWIzNGZhNDhjMzUyMTYzMmM0YTUzMGU4ZmZiMWJjNTFkYWRkZjQ1M2IwYjI3MTdjMmJjNjY2OWVkNzZiNGJkZDVjOWZmNTU4ZTg4ZjI2ZTU3ODUzMDJiZWRiY2EyM2VhYzVhY2U5MjA5NmVlOGE2MDY0MmZiNjFlOGYzZDI0OTkwYjhjYjEyZWU0NDhlZWY3OGUxODRjNzI0MmRkMTYxYzc3MzhmMzJiZjI5YTg0MTY5ODk3ODgyNWI0MTExYjRiYzNlMWUxOTg0NTUwOTU5NTgzMzNkNzc2ZDhiMmJlZWVkM2ExYTFhMjIxYTZlMzdlNjY0YTY0YjgzOTgxYzQ2ZmZkZGMxYTQ1ZTNkNTIxMWFhZjhiZmJjMDcyNzY4YzRmNTBkN2Q3ODAzZDJkNGYyNzhkZTgwMTRhNDczMjM2MzFkN2UwNjRkZTgxYzBjNmJmYTQzZWYwZTY5OTg4NjBmMTM5MGI1ZDNmZWFjYWYxNjk2MDE1Y2I3OWMzZjljMmQ5M2Q5NjExMjBjZDBlNWYxMmNiYjY4N2VhYjA0NTI0MWY5Njc4OWMzOGU4OWQ3OTYxMzhlNjMxOWJlNjJlMzVkODdiMTA0OGNhMjhiZTM4OWI1NzVlOTk0ZGNhNzU1NDcxNTg0YTA5ZWM3MjM3NDJkYzM1ODczODQ3YWVmNDlmNjZlNDM4NzMifQ==" }
type RemoteKV ¶ added in v4.7.1
type RemoteKV struct {
// contains filtered or unexported fields
}
RemoteKV implements a bindings-friendly subset of a versioned.KV. It has additional features to store and load maps. It uses strings of json for versioned.Object to get and set all data. All operations over the bindings interface are prefixed by the "bindings" prefix, and this prefix is always remotely synchronized.
RemoteKV is instantiated and an instance is acquired via the Cmix object Cmix.GetRemoteKV function. (TODO: write this function)
func (*RemoteKV) DeleteMapElement ¶ added in v4.7.1
DeleteMapElement removes a versioned map element from the KV.
func (*RemoteKV) DeleteRemoteKeyListener ¶ added in v4.7.1
DeleteRemoteKeyListener deletes a specific id for a provided key
func (*RemoteKV) DeleteRemoteMapListener ¶ added in v4.7.1
DeleteRemoteMapListener deletes a specific id for a provided key
func (*RemoteKV) Get ¶ added in v4.7.1
Get returns the object stored at the specified version. returns a json of versioned.Object
func (*RemoteKV) GetAllRemoteKeyListeners ¶ added in v4.7.1
GetAllRemoteKeyListeners returns a JSON of all the listener keys mapped to a list of ids.
func (*RemoteKV) GetAllRemoteMapListeners ¶ added in v4.7.1
GetAllRemoteMapListeners returns a JSON of all the listener keys mapped to a list of ids.
func (*RemoteKV) GetFullKey ¶ added in v4.7.1
GetFullKey returns the key with all prefixes appended
func (*RemoteKV) GetMap ¶ added in v4.7.1
GetMap loads a versioned map from the KV. This relies on the underlying remote [KV.GetMap] function to lock and control updates, but it uses versioned.Object values.
func (*RemoteKV) GetMapElement ¶ added in v4.7.1
GetMapElement loads a versioned map element from the KV. This relies on the underlying remote [KV.GetMapElement] function to lock and control updates, but it uses versioned.Object values.
func (*RemoteKV) GetRemoteKeyListeners ¶ added in v4.7.1
GetRemoteKeyListeners returns a JSON array of ids for the given key.
func (*RemoteKV) GetRemoteMapListeners ¶ added in v4.7.1
GetRemoteMapListeners returns a JSON array of ids for the given key.
func (*RemoteKV) IsMemStore ¶ added in v4.7.1
IsMemStore returns true if the underlying KV is memory based
func (*RemoteKV) ListenOnRemoteKey ¶ added in v4.7.1
func (r *RemoteKV) ListenOnRemoteKey(key string, version int64, callback KeyChangedByRemoteCallback, localEvents bool) (int, error)
ListenOnRemoteKey sets up a callback listener for the object specified by the key and version. It returns the ID of the callback or -1 and an error. The version and "localEvents" flags are only respected on first call.
func (*RemoteKV) ListenOnRemoteMap ¶ added in v4.7.1
func (r *RemoteKV) ListenOnRemoteMap(mapName string, version int64, callback MapChangedByRemoteCallback, localEvents bool) (int, error)
ListenOnRemoteMap allows the caller to receive updates when the map or map elements are updated. It returns the ID of the callback or -1 and an error. The version and "localEvents" flags are only respected on first call.
func (*RemoteKV) Set ¶ added in v4.7.1
Set upserts new data into the storage When calling this, you are responsible for prefixing the key with the correct type optionally unique id! Call MakeKeyWithPrefix() to do so. The [Object] should contain the versioning if you are maintaining such a functionality.
func (*RemoteKV) StoreMap ¶ added in v4.7.1
StoreMap saves a versioned map element into the KV. This relies on the underlying remote [KV.StoreMap] function to lock and control updates, but it uses versioned.Object values. All Map storage functions update the remote. valueJSON is a json of map[string]*versioned.Object
func (*RemoteKV) StoreMapElement ¶ added in v4.7.1
func (r *RemoteKV) StoreMapElement(mapName, elementKey string, valueJSON []byte, version int64) error
StoreMapElement stores a versioned map element into the KV. This relies on the underlying remote [KV.StoreMapElement] function to lock and control updates, but it uses versioned.Object values. All Map storage functions update the remote. valueJSON is a json of a versioned.Object
type RemoteStore ¶ added in v4.7.1
type RemoteStore interface { // FileIO is used to write and read files. Refer to [collective.FileIO]. collective.FileIO // GetLastModified returns when the file at the given file path was last // modified. If the implementation that adheres to this interface does not // support this, FileIO.Write or FileIO.Read should be implemented to either // write a separate timestamp file or add a prefix. // // Returns an RFC3339 timestamp string GetLastModified(path string) (string, error) // GetLastWrite retrieves the most recent successful write operation that // was received by RemoteStore. // // Returns an RFC3339 timestamp string GetLastWrite() (string, error) // ReadDir reads the named directory, returning all its // directory entries sorted by filename as json of a []string ReadDir(path string) ([]byte, error) }
RemoteStore is the mechanism that all remote storage implementations should adhere to. Bindings clients must implement this interface to use collective synchronized KV functionality.
type RemoteStoreFileSystem ¶ added in v4.7.1
type RemoteStoreFileSystem struct {
// contains filtered or unexported fields
}
RemoteStoreFileSystem is a structure adhering to RemoteStore. This utilizes the os.File IO operations. Implemented for testing purposes for transaction logs.
func NewFileSystemRemoteStorage ¶ added in v4.7.1
func NewFileSystemRemoteStorage(baseDir string) *RemoteStoreFileSystem
NewFileSystemRemoteStorage is a constructor for RemoteStoreFileSystem.
Parameters:
- baseDir - The base directory that all file operations will be performed. It must contain a file delimiter (i.e., `/`).
func (*RemoteStoreFileSystem) GetLastModified ¶ added in v4.7.1
func (r *RemoteStoreFileSystem) GetLastModified(path string) (string, error)
GetLastModified returns when the file at the given file path was last modified. If the implementation that adheres to this interface does not support this, [Write] or [Read] should be implemented to either write a separate timestamp file or add a prefix.
Returns:
- []byte - JSON of RemoteStoreReport.
func (*RemoteStoreFileSystem) GetLastWrite ¶ added in v4.7.1
func (r *RemoteStoreFileSystem) GetLastWrite() (string, error)
GetLastWrite retrieves the most recent successful write operation that was received by RemoteStoreFileSystem.
Returns:
- []byte - JSON of RemoteStoreReport.
type RemoteStoreReport ¶ added in v4.7.1
type RemoteStoreReport struct { // Key is the key of the transaction that was written to remote. Getting // this via the callback indicates that there is a report for this key. Key string // Value is the value of the transaction that was written to remote for // the key. Value []byte // LastModified is the timestamp (in nanoseconds) of the last time the // specific path was modified. Refer to collective.RemoteKV.GetLastModified. LastModified int64 `json:"lastModified"` // LastWrite is the timestamp (in nanoseconds) of the last write to the // remote storage interface by any device. Refer to // collective.RemoteKV.GetLastWrite. LastWrite int64 `json:"lastWrite"` // Any error that occurs. It is omitted when no error occurred. Error string `json:"error,omitempty"` }
RemoteStoreReport represents the report from any call to a method of RemoteStore.
Example JSON:
{ "key": "exampleKey", "value": "ZXhhbXBsZVZhbHVl", "lastModified": 1679173966663412908, "lastWrite": 1679130886663413268, "error": "Example error (may not exist if successful)" }
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 TimeSource ¶ added in v4.7.1
type TimeSource interface {
NowMs() int64
}
TimeSource is a copy of netTime.TimeSource. For some reason, Go bindings only allows this interface, not the one found in netTime.
type TrackCompressedServicesCallback ¶ added in v4.7.1
TrackCompressedServicesCallback is the callback for Cmix.TrackServices that passes a JSON-marshalled list of compressed backend services. If an error occurs while retrieving or marshalling the service list, then err will be non-null.
Parameters:
- marshalData - JSON of [message.CompressedServiceList], which is a map of id.ID to an array of [message.CompressedService].
- err - Error that occurs during retrieval or marshalling. Null otherwise.
Example JSON:
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD": [ { "Identifier": null, "Tags": ["test"], "Metadata": null } ], "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD": [ { "Identifier": null, "Tags": ["test"], "Metadata": null } ], "AAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD": [ { "Identifier": null, "Tags": ["test"], "Metadata": null } ] }
type TrackServicesCallback ¶
TrackServicesCallback is the callback for Cmix.TrackServices that passes a JSON-marshalled list of uncompressed backend services. If an error occurs while retrieving or marshalling the service list, then err will be non-null.
Parameters:
- marshalData - JSON of [message.ServiceList], which is a map id.ID to an array of [message.Service].
- err - Error that occurs during retrieval or marshalling. Null otherwise.
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 TransactionOperation ¶ added in v4.7.1
TransactionOperation provides a function which mutates the object in the desired way. Receives and sends a JSON object. dataJSON must be JSON of the form:
{ Error: "string", NewObject: { // Used to determine version Upgrade, if any Version uint64 // Set when this object is written Timestamp time.Time // Serialized version of original object Data []byte } }
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
type UserMutedJSON ¶ added in v4.7.1
type UserMutedJSON struct { ChannelID *id.ID `json:"channelID"` PubKey ed25519.PublicKey `json:"pubKey"` Unmute bool `json:"unmute"` }
UserMutedJSON is returned for the MuteUser method of the impl.
Example JSON:
{ "channelID":"YSc2bDijXIVhmIsJk2OZQjU9ei2Dn6MS8tOpXlIaUpSV", "pubKey":"hClzdWkMI+LM7KDFxC/iuyIc0oiMzcBXBFgH0haZAjc=", "unmute":false }
Source Files ¶
- authenticatedConnection.go
- backup.go
- channels.go
- channelsCallbacks.go
- channelsFileTransfer.go
- cmix.go
- collective.go
- connect.go
- delivery.go
- dm.go
- docs.go
- dummy.go
- e2e.go
- e2eAuth.go
- e2eHandler.go
- emoji.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
- rpc.go
- secrets.go
- single.go
- timeNow.go
- ud.go
- version.go