wasm

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: BSD-2-Clause Imports: 37 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncRequestRestLike

func AsyncRequestRestLike(_ js.Value, args []js.Value) any

AsyncRequestRestLike sends an asynchronous restlike request to a given contact.

The RestlikeCallback will be called with the results of JSON marshalling the response when received.

Parameters:

Returns:

  • Throws a TypeError if parsing the parameters or making the request fails.

func ConstructIdentity

func ConstructIdentity(_ js.Value, args []js.Value) any

ConstructIdentity constructs a channel.Identity from a user's public key and codeset version.

Parameters:

  • args[0] - The Ed25519 public key (Uint8Array).
  • args[1] - The version of the codeset used to generate the identity (int).

Returns:

  • JSON of channel.Identity (Uint8Array).
  • Throws a TypeError if constructing the identity fails.

func CreateUserFriendlyErrorMessage

func CreateUserFriendlyErrorMessage(_ js.Value, args []js.Value) any

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:

  • args[0] - an error returned from the backend (string).

Returns

  • A user-friendly error message. This should be devoid of technical speak but still be meaningful for front-end or back-end teams (string).

func DecodePrivateURL

func DecodePrivateURL(_ js.Value, args []js.Value) any

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:

  • args[0] - The channel's share URL (string). Should be received from another user or generated via ChannelsManager.GetShareURL.
  • args[1] - The password needed to decrypt the secret data in the URL (string).

Returns:

  • The channel pretty print (string)

func DecodePublicURL

func DecodePublicURL(_ js.Value, args []js.Value) any

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:

Returns:

  • The channel pretty print (string).

func DeserializeGroup

func DeserializeGroup(_ js.Value, args []js.Value) any

DeserializeGroup converts the results of Group.Serialize into a bindings.Group so that its methods can be called.

Parameters:

Returns:

  • Javascript representation of the GroupChat object.
  • Throws a TypeError if getting the group fails.

func DownloadAndVerifySignedNdfWithUrl

func DownloadAndVerifySignedNdfWithUrl(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - The URL to download from (string).
  • args[1] - The NDF certificate (string).

Returns a promise:

  • Resolves to the JSON of the NDF (ndf.NetworkDefinition) (Uint8Array).
  • Rejected with an error if downloading fails.

func EnableGrpcLogs

func EnableGrpcLogs(_ js.Value, args []js.Value) any

EnableGrpcLogs sets GRPC trace logging.

Parameters:

  • args[0] - a function that accepts a string and writes to a log. It must be of the form func(string).

func GenerateChannel

func GenerateChannel(_ js.Value, args []js.Value) any

GenerateChannel is used to create a channel a new channel of which you are the admin. It is only for making new channels, not joining existing ones.

It returns a pretty print of the channel and the private key.

The name cannot be longer that __ characters. The description cannot be longer than __ and can only use ______ characters.

Parameters:

  • args[0] - ID of Cmix object in tracker (int).
  • args[1] - The name of the new channel (string). 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.
  • args[2] - The description of a channel (string). 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.
  • args[3] - The broadcast.PrivacyLevel of the channel (int). 0 = public, 1 = private, and 2 = secret. Refer to the comment below for more information.

Returns:

  • JSON of bindings.ChannelGeneration, which describes a generated channel. It contains both the public channel info and the private key for the channel in PEM format (Uint8Array).
  • Throws a TypeError if generating the channel fails.

The broadcast.PrivacyLevel of a channel indicates the level of channel information revealed when sharing it via URL. For any channel besides public channels, the secret information is encrypted and a password is required to share and join a channel.

  • A privacy level of broadcast.Public reveals all the information including the name, description, privacy level, public key and salt.
  • A privacy level of broadcast.Private reveals only the name and description.
  • A privacy level of broadcast.Secret reveals nothing.

func GenerateChannelIdentity

func GenerateChannelIdentity(_ js.Value, args []js.Value) any

GenerateChannelIdentity creates a new private channel identity (channel.PrivateIdentity). The public component can be retrieved as JSON via GetPublicChannelIdentityFromPrivate.

Parameters:

  • args[0] - ID of Cmix object in tracker (int).

Returns:

func GenerateSecret

func GenerateSecret(_ js.Value, args []js.Value) any

GenerateSecret creates a secret password using a system-based pseudorandom number generator.

Parameters:

  • args[0] - The size of secret. It should be set to 32, but can be set higher in certain cases, but not lower (int).

Returns:

  • Secret password (Uint8Array).

func GetChannelInfo

func GetChannelInfo(_ js.Value, args []js.Value) any

GetChannelInfo returns the info about a channel from its public description.

Parameters:

  • args[0] - The pretty print of the channel (string).

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:

  • JSON of bindings.ChannelInfo, which describes all relevant channel info (Uint8Array).
  • Throws a TypeError if getting the channel info fails.

func GetChannelJSON

func GetChannelJSON(_ js.Value, args []js.Value) any

GetChannelJSON returns the JSON of the channel for the given pretty print.

Parameters:

  • args[0] - The pretty print of the channel (string).

Returns:

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 GetClientDependencies

func GetClientDependencies(js.Value, []js.Value) any

GetClientDependencies returns the client's dependencies (xxdk.DEPENDENCIES).

Returns:

  • Dependency list (string).

func GetClientGitVersion

func GetClientGitVersion(js.Value, []js.Value) any

GetClientGitVersion returns the current client xxDK git version (xxdk.GITVERSION).

Returns:

  • Git version (string).

func GetClientVersion

func GetClientVersion(js.Value, []js.Value) any

GetClientVersion returns the current client xxDK semantic version (xxdk.SEMVER).

Returns:

  • Current version (string).

func GetContactFromReceptionIdentity

func GetContactFromReceptionIdentity(_ js.Value, args []js.Value) any

GetContactFromReceptionIdentity returns the contact.Contact object from the xxdk.ReceptionIdentity.

Parameters:

Returns:

  • Marshalled bytes of contact.Contact (string).
  • Throws a TypeError if unmarshalling the identity fails.

func GetDefaultCMixParams

func GetDefaultCMixParams(js.Value, []js.Value) any

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.

Returns:

func GetDefaultE2EParams

func GetDefaultE2EParams(js.Value, []js.Value) any

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.

Returns:

func GetDefaultE2eFileTransferParams

func GetDefaultE2eFileTransferParams(js.Value, []js.Value) any

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.

Returns:

func GetDefaultFileTransferParams

func GetDefaultFileTransferParams(js.Value, []js.Value) any

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.

Returns:

func GetDefaultSingleUseParams

func GetDefaultSingleUseParams(js.Value, []js.Value) any

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.

Returns:

func GetFactsFromContact

func GetFactsFromContact(_ js.Value, args []js.Value) any

GetFactsFromContact returns the fact list in the contact.Contact object.

Parameters:

Returns:

  • JSON of fact.FactList (Uint8Array).
  • Throws a TypeError if loading the contact fails.

func GetIDFromContact

func GetIDFromContact(_ js.Value, args []js.Value) any

GetIDFromContact returns the ID in the contact.Contact object.

Parameters:

Returns:

  • Marshalled bytes of id.ID (Uint8Array).
  • Throws a TypeError if loading the ID from the contact file fails.

func GetPubkeyFromContact

func GetPubkeyFromContact(_ js.Value, args []js.Value) any

GetPubkeyFromContact returns the DH public key in the contact.Contact object.

Parameters:

Returns:

  • Bytes of the cyclic.Int object (Uint8Array).
  • Throws a TypeError if loading the public key from the contact file fails.

func GetPublicChannelIdentity

func GetPublicChannelIdentity(_ js.Value, args []js.Value) any

GetPublicChannelIdentity constructs a public identity (channel.Identity) from a bytes version and returns it JSON marshaled.

Parameters:

Returns:

  • JSON of the constructed channel.Identity (Uint8Array).
  • Throws a TypeError if unmarshalling the bytes or marshalling the identity fails.

func GetPublicChannelIdentityFromPrivate

func GetPublicChannelIdentityFromPrivate(_ js.Value, args []js.Value) any

GetPublicChannelIdentityFromPrivate returns the public identity (channel.Identity) contained in the given private identity (channel.PrivateIdentity).

Parameters:

  • args[0] - Bytes of the private identity (channel.PrivateIdentity]) (Uint8Array).

Returns:

  • JSON of the public identity (channel.Identity) (Uint8Array).
  • Throws a TypeError if unmarshalling the bytes or marshalling the identity fails.

func GetSavedChannelPrivateKeyUNSAFE

func GetSavedChannelPrivateKeyUNSAFE(_ js.Value, args []js.Value) any

GetSavedChannelPrivateKeyUNSAFE loads the private key from storage for the given channel ID.

NOTE: This function is unsafe and only for debugging purposes only.

Parameters:

  • args[0] - ID of Cmix object in tracker (int).
  • args[1] - The id.ID of the channel in base 64 encoding (string).

Returns:

  • The PEM file of the private key (string).
  • Throws a TypeError if retrieving the Cmix object or the private key fails.

func GetShareUrlType

func GetShareUrlType(_ js.Value, args []js.Value) any

GetShareUrlType determines the broadcast.PrivacyLevel of the channel URL. If the URL is an invalid channel URL, an error is returned.

Parameters:

  • args[0] - The channel share URL (string).

Returns:

  • An int that corresponds to the broadcast.PrivacyLevel as outlined below.
  • Throws a TypeError if parsing the URL fails.

Possible returns:

0 = public channel
1 = private channel
2 = secret channel

func GetVersion

func GetVersion(js.Value, []js.Value) any

GetVersion returns the current xxDK WASM semantic version.

Returns:

  • Current version (string).

func ImportPrivateIdentity

func ImportPrivateIdentity(_ js.Value, args []js.Value) any

ImportPrivateIdentity generates a new channel.PrivateIdentity from exported data.

Parameters:

  • args[0] - The password used to encrypt the identity (string).
  • args[2] - The encrypted data (Uint8Array).

Returns:

func InitFileTransfer

func InitFileTransfer(_ js.Value, args []js.Value) any

InitFileTransfer creates a bindings-level file transfer manager.

Parameters:

Returns:

  • Javascript representation of the FileTransfer object.
  • Throws a TypeError initialising the file transfer manager fails.

func InitializeBackup

func InitializeBackup(_ js.Value, args []js.Value) any

InitializeBackup creates a bindings-layer Backup object.

Parameters:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - ID of UserDiscovery object in tracker (int).
  • args[2] - Backup passphrase provided by the user (string). Used to decrypt the backup.
  • args[3] - The callback to be called when a backup is triggered. Must be Javascript object that has functions that implement the bindings.UpdateBackupFunc interface.

Returns:

  • Javascript representation of the Backup object.
  • Throws a TypeError if initializing the Backup fails.

func IsNicknameValid

func IsNicknameValid(_ js.Value, args []js.Value) any

IsNicknameValid checks if a nickname is valid.

Rules:

  1. A nickname must not be longer than 24 characters.
  2. A nickname must not be shorter than 1 character.

Parameters:

  • args[0] - Nickname to check (string).

Returns:

  • A Javascript Error object if the nickname is invalid with the reason why.
  • Null if the nickname is valid.

func Listen

func Listen(_ js.Value, args []js.Value) any

Listen starts a single-use listener on a given tag using the passed in E2e object and SingleUseCallback func.

Parameters:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Tag that identifies the single-use message (string).
  • args[2] - The callback that will be called when a response is received. It is a Javascript object that has functions that implement the bindings.SingleUseCallback interface.

Returns:

  • Javascript representation of the Stopper object, an interface containing a function used to stop the listener.
  • Throws a TypeError if listening fails.

func LoadChannelsManager

func LoadChannelsManager(_ js.Value, args []js.Value) any

LoadChannelsManager loads an existing ChannelsManager.

This is for loading a manager for an identity that has already been created. The channel manager should have previously been created with NewChannelsManager and the storage is retrievable with ChannelsManager.GetStorageTag.

Parameters:

Returns:

  • Javascript representation of the ChannelsManager object.
  • Throws a TypeError if loading the manager fails.

func LoadChannelsManagerWithIndexedDb

func LoadChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) any

LoadChannelsManagerWithIndexedDb loads an existing ChannelsManager using an existing indexedDb database as a backend to manage the event model.

This is for loading a manager for an identity that has already been created. The channel manager should have previously been created with NewChannelsManagerWithIndexedDb and the storage is retrievable with ChannelsManager.GetStorageTag.

Parameters:

  • args[0] - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.
  • args[1] - The storage tag associated with the previously created channel manager and retrieved with ChannelsManager.GetStorageTag (string).
  • args[2] - Function that takes in the same parameters as [indexedDb.MessageReceivedCallback]. On the Javascript side, the UUID is returned as an int and the channelID as a Uint8Array. The row in the database that was updated can be found using the UUID. The channel ID is provided so that the recipient can filter if they want to the processes the update now or not. An "update" bool is present which tells you if the row is new or if it is an edited old row.
  • args[3] - ID of ChannelDbCipher object in tracker (int). Create this object with NewChannelsDatabaseCipher and get its id with ChannelDbCipher.GetID.

Returns a promise:

  • Resolves to a Javascript representation of the ChannelsManager object.
  • Rejected with an error if loading indexedDb or the manager fails.
  • Throws a TypeError if the cipher ID does not correspond to a cipher.

func LoadChannelsManagerWithIndexedDbUnsafe

func LoadChannelsManagerWithIndexedDbUnsafe(_ js.Value, args []js.Value) any

LoadChannelsManagerWithIndexedDbUnsafe loads an existing ChannelsManager using an existing indexedDb database as a backend to manage the event model. This should only be used to load unsafe channel managers created by NewChannelsManagerWithIndexedDbUnsafe.

This is for loading a manager for an identity that has already been created. The channel manager should have previously been created with NewChannelsManagerWithIndexedDb and the storage is retrievable with ChannelsManager.GetStorageTag.

Parameters:

  • args[0] - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.
  • args[1] - The storage tag associated with the previously created channel manager and retrieved with ChannelsManager.GetStorageTag (string).
  • args[2] - Function that takes in the same parameters as [indexedDb.MessageReceivedCallback]. On the Javascript side, the UUID is returned as an int and the channelID as a Uint8Array. The row in the database that was updated can be found using the UUID. The channel ID is provided so that the recipient can filter if they want to the processes the update now or not. An "update" bool is present which tells you if the row is new or if it is an edited old row

Returns a promise:

  • Resolves to a Javascript representation of the ChannelsManager object.
  • Rejected with an error if loading indexedDb or the manager fails.

func LoadCmix

func LoadCmix(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - Storage directory path (string).
  • args[1] - Password used for storage (Uint8Array).
  • args[2] - JSON of xxdk.CMIXParams (Uint8Array).

Returns a promise:

  • Resolves to a Javascript representation of the Cmix object.
  • Rejected with an error if loading Cmix fails.

func LoadReceptionIdentity

func LoadReceptionIdentity(_ js.Value, args []js.Value) any

LoadReceptionIdentity loads the given identity in Cmix storage with the given key.

Parameters:

  • args[0] - Storage key (string).
  • args[1] - ID of Cmix object in tracker (int).

Returns:

  • JSON of the stored xxdk.ReceptionIdentity object (Uint8Array).
  • Throws a TypeError if the identity cannot be retrieved from storage.

func LogLevel

func LogLevel(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - Log level (int).

Returns:

  • Throws TypeError if the log level is invalid.

func LogToFile

func LogToFile(_ js.Value, args []js.Value) any

LogToFile enables logging to a file that can be downloaded.

Parameters:

  • args[0] - Log level (int).
  • args[1] - Log file name (string).
  • args[2] - Max log file size, in bytes (int).

Returns:

  • A Javascript representation of the LogFile object, which allows accessing the contents of the log file and other metadata.

func Login

func Login(_ js.Value, args []js.Value) any

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.

Parameters:

Returns:

  • Javascript representation of the E2e object.
  • Throws a TypeError if logging in fails.

func LoginEphemeral

func LoginEphemeral(_ js.Value, args []js.Value) any

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.

Parameters:

Returns:

  • Javascript representation of the E2e object.
  • Throws a TypeError if logging in fails.

func LookupUD

func LookupUD(_ js.Value, args []js.Value) any

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

Parameters:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Marshalled bytes of the User Discovery's contact.Contact (Uint8Array).
  • args[2] - Javascript object that has functions that implement the bindings.UdLookupCallback interface.
  • args[3] - Marshalled bytes of the id.ID for the user to look up (Uint8Array).
  • args[4] - JSON of single.RequestParams (Uint8Array).

Returns a promise:

func NewChannelsDatabaseCipher

func NewChannelsDatabaseCipher(_ js.Value, args []js.Value) any

NewChannelsDatabaseCipher constructs a ChannelDbCipher object.

Parameters:

  • args[0] - The tracked Cmix object ID (int).
  • args[1] - The password for storage. This should be the same password passed into NewCmix (Uint8Array).
  • args[2] - The maximum size of a payload to be encrypted. A payload passed into ChannelDbCipher.Encrypt that is larger than this value will result in an error (int).

Returns:

  • JavaScript representation of the ChannelDbCipher object.
  • Throws a TypeError if creating the cipher fails.

func NewChannelsManager

func NewChannelsManager(_ js.Value, args []js.Value) any

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:

Returns:

  • Javascript representation of the ChannelsManager object.
  • Throws a TypeError if creating the manager fails.

func NewChannelsManagerWithIndexedDb

func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) any

NewChannelsManagerWithIndexedDb creates a new ChannelsManager from a new private identity (channel.PrivateIdentity) and using indexedDb as a backend to manage the 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 LoadChannelsManagerWithIndexedDb, passing in the storage tag retrieved by ChannelsManager.GetStorageTag.

This function initialises an indexedDb database.

Parameters:

  • args[0] - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.
  • args[1] - Bytes of a private identity (channel.PrivateIdentity) that is generated by GenerateChannelIdentity (Uint8Array).
  • args[2] - Function that takes in the same parameters as [indexedDb.MessageReceivedCallback]. On the Javascript side, the UUID is returned as an int and the channelID as a Uint8Array. The row in the database that was updated can be found using the UUID. The channel ID is provided so that the recipient can filter if they want to the processes the update now or not. An "update" bool is present which tells you if the row is new or if it is an edited old row.
  • args[3] - ID of ChannelDbCipher object in tracker (int). Create this object with NewChannelsDatabaseCipher and get its id with ChannelDbCipher.GetID.

Returns a promise:

  • Resolves to a Javascript representation of the ChannelsManager object.
  • Rejected with an error if loading indexedDb or the manager fails.
  • Throws a TypeError if the cipher ID does not correspond to a cipher.

func NewChannelsManagerWithIndexedDbUnsafe

func NewChannelsManagerWithIndexedDbUnsafe(_ js.Value, args []js.Value) any

NewChannelsManagerWithIndexedDbUnsafe creates a new ChannelsManager from a new private identity (channel.PrivateIdentity) and using indexedDb as a backend to manage the event model. However, the data is written in plain text and not encrypted. It is recommended that you do not use this in production.

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 LoadChannelsManagerWithIndexedDbUnsafe, passing in the storage tag retrieved by ChannelsManager.GetStorageTag.

This function initialises an indexedDb database.

Parameters:

  • args[0] - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.
  • args[1] - Bytes of a private identity (channel.PrivateIdentity) that is generated by GenerateChannelIdentity (Uint8Array).
  • args[2] - Function that takes in the same parameters as [indexedDb.MessageReceivedCallback]. On the Javascript side, the UUID is returned as an int and the channelID as a Uint8Array. The row in the database that was updated can be found using the UUID. The channel ID is provided so that the recipient can filter if they want to the processes the update now or not. An "update" bool is present which tells you if the row is new or if it is an edited old row

Returns a promise:

  • Resolves to a Javascript representation of the ChannelsManager object.
  • Rejected with an error if loading indexedDb or the manager fails.

func NewCmix

func NewCmix(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - NDF JSON (ndf.NetworkDefinition) (string).
  • args[1] - Storage directory path (string).
  • args[2] - Password used for storage (Uint8Array).
  • args[3] - Registration code (string).

Returns:

  • Throws a TypeError if creating new Cmix fails.

func NewCmixFromBackup

func NewCmixFromBackup(_ js.Value, args []js.Value) any

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:

  • args[0] - JSON of the NDF (ndf.NetworkDefinition) (string).
  • args[1] - Storage directory (string).
  • args[2] - Backup passphrase (string).
  • args[3] - Session password (Uint8Array).
  • args[4] - Backup file contents (Uint8Array).

Returns:

func NewDummyTrafficManager

func NewDummyTrafficManager(_ js.Value, args []js.Value) any

NewDummyTrafficManager creates a DummyTraffic manager and initialises the dummy traffic sending thread. Note that the manager does not start sending dummy traffic until true is passed into DummyTraffic.SetStatus. The time duration between each sending operation and the amount of messages sent each interval are randomly generated values with bounds defined by the given parameters below.

Parameters:

  • args[0] - A Cmix object ID in the tracker (int).
  • args[1] - The maximum number of the random number of messages sent each sending cycle (int).
  • args[2] - The average duration, in milliseconds, to wait between sends (int).
  • args[3] - The upper bound of the interval between sending cycles, in milliseconds. Sends occur every average send (args[2]) +/- a random duration with an upper bound of args[3] (int).

Returns:

  • Javascript representation of the DummyTraffic object.
  • Throws a TypeError if creating the manager fails.

func NewGroupChat

func NewGroupChat(_ js.Value, args []js.Value) any

NewGroupChat creates a bindings-layer group chat manager.

Parameters:

Returns:

  • Javascript representation of the GroupChat object.
  • Throws a TypeError if creating the GroupChat fails.

func NewOrLoadUd

func NewOrLoadUd(_ js.Value, args []js.Value) any

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

Params

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Javascript object that has functions that implement the bindings.UdNetworkStatus interface. This is the network follower function wrapped in bindings.UdNetworkStatus.
  • args[2] - The username the user wants to register with UD. If the user is already registered, this field may be blank (string).
  • args[3] - The registration validation signature; a signature provided by the network (i.e., the client registrar). This may be nil; however, UD may return an error in some cases (e.g., in a production level environment) (Uint8Array).
  • args[4] - 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 (Uint8Array).
  • args[5] - Marshalled bytes of the contact.Contact of the server this call will connect with. You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf (Uint8Array).
  • args[6] - 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 (string).

Returns:

  • Javascript representation of the UserDiscovery object that is registered to the specified UD service.
  • Throws a TypeError if creating or loading fails.

func NewUdManagerFromBackup

func NewUdManagerFromBackup(_ js.Value, args []js.Value) any

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

Note that it can take in both ane email address and a phone number or both. However, at least one fact must be specified; providing no facts will return an error.

Parameters:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Javascript object that has functions that implement the bindings.UdNetworkStatus interface. This is the network follower function wrapped in bindings.UdNetworkStatus.
  • args[2] - 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 (Uint8Array).
  • args[3] - Marshalled bytes of the contact.Contact of the server this call will connect with. You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf (Uint8Array).
  • args[4] - 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 (string).

Returns:

  • Javascript representation of the UserDiscovery object that is loaded from backup.
  • Throws a TypeError if getting UD from backup fails.

func RegisterLogWriter

func RegisterLogWriter(_ js.Value, args []js.Value) any

RegisterLogWriter registers a callback on which logs are written.

Parameters:

  • args[0] - a function that accepts a string and writes to a log. It must be of the form func(string).

func RequestRestLike

func RequestRestLike(_ js.Value, args []js.Value) any

RequestRestLike sends a restlike request to a given contact.

Parameters:

Returns a promise:

  • Resolves to the JSON of the bindings.Message, which can be passed into Cmix.WaitForRoundResult to see if the send succeeded (Uint8Array).
  • Rejected with an error if parsing the parameters or making the request fails.

func RestlikeRequest

func RestlikeRequest(_ js.Value, args []js.Value) any

RestlikeRequest performs a normal restlike request.

Parameters:

Returns a promise:

func RestlikeRequestAuth

func RestlikeRequestAuth(_ js.Value, args []js.Value) any

RestlikeRequestAuth performs an authenticated restlike request.

Parameters:

Returns a promise:

func ResumeBackup

func ResumeBackup(_ js.Value, args []js.Value) any

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:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - ID of UserDiscovery object in tracker (int).
  • args[2] - The callback to be called when a backup is triggered. Must be Javascript object that has functions that implement the bindings.UpdateBackupFunc interface. This will replace any callback that has been passed into InitializeBackup.

Returns:

  • Javascript representation of the Backup object.
  • Throws a TypeError if initializing the Backup fails.

func SearchUD

func SearchUD(_ js.Value, args []js.Value) any

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:

Returns a promise:

func SetDashboardURL

func SetDashboardURL(_ js.Value, args []js.Value) any

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:

  • args[0] - A valid URL that will be used for round look up on any send report (string).

func SetFactsOnContact

func SetFactsOnContact(_ js.Value, args []js.Value) any

SetFactsOnContact replaces the facts on the contact with the passed in facts pass in empty facts in order to clear the facts.

Parameters:

Returns:

  • Marshalled bytes of the modified contact.Contact (string).
  • Throws a TypeError if loading or modifying the contact fails.

func SetOffset

func SetOffset(_ js.Value, args []js.Value) any

SetOffset will set an internal offset variable. All calls to netTime.Now will have this offset applied to this value.

Parameters:

  • args[0] - 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 (int).

func SetTimeSource

func SetTimeSource(_ js.Value, args []js.Value) any

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

func StoreReceptionIdentity(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - Storage key (string).
  • args[1] - JSON of the xxdk.ReceptionIdentity object (Uint8Array).
  • args[2] - ID of Cmix object in tracker (int).

Returns:

  • Throws a TypeError if the identity cannot be stored in storage.

func TransmitSingleUse

func TransmitSingleUse(_ js.Value, args []js.Value) any

TransmitSingleUse transmits payload to recipient via single-use.

Parameters:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Marshalled bytes of the recipient contact.Contact (Uint8Array).
  • args[2] - Tag that identifies the single-use message (string).
  • args[3] - Message contents (Uint8Array).
  • args[4] - JSON of single.RequestParams (Uint8Array).
  • args[5] - The callback that will be called when a response is received. It is a Javascript object that has functions that implement the bindings.SingleUseResponse interface.

Returns a promise:

func UpdateCommonErrors

func UpdateCommonErrors(_ js.Value, args []js.Value) any

UpdateCommonErrors updates the internal error mapping database. This internal database maps errors returned from the backend to user-friendly error messages.

Parameters:

  • args[0] - Contents of a JSON file whose format conforms to the example below (string).

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",
}

Returns:

  • Throws a TypeError if the JSON cannot be unmarshalled.

Types

type AuthenticatedConnection

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

AuthenticatedConnection wraps the bindings.AuthenticatedConnection object so its methods can be wrapped to be Javascript compatible.

func (*AuthenticatedConnection) Close

func (ac *AuthenticatedConnection) Close(js.Value, []js.Value) any

Close deletes this AuthenticatedConnection's partner.Manager and releases resources.

Returns:

  • Throws a TypeError if closing fails.

func (*AuthenticatedConnection) GetId

func (ac *AuthenticatedConnection) GetId(js.Value, []js.Value) any

GetId returns the ID for this bindings.AuthenticatedConnection in the authenticatedConnectionTracker.

Returns:

  • Tracker ID (int).

func (*AuthenticatedConnection) GetPartner

func (ac *AuthenticatedConnection) GetPartner(js.Value, []js.Value) any

GetPartner returns the partner.Manager for this AuthenticatedConnection.

Returns:

  • Marshalled bytes of the partner's id.ID (Uint8Array).

func (*AuthenticatedConnection) IsAuthenticated

func (ac *AuthenticatedConnection) IsAuthenticated(js.Value, []js.Value) any

IsAuthenticated returns true.

Returns:

  • True (boolean).

func (*AuthenticatedConnection) RegisterListener

func (ac *AuthenticatedConnection) RegisterListener(
	_ js.Value, args []js.Value) any

RegisterListener is used for E2E reception and allows for reading data sent from the partner.Manager.

Parameters:

Returns:

  • Throws a TypeError is registering the listener fails.

func (*AuthenticatedConnection) SendE2E

func (ac *AuthenticatedConnection) SendE2E(_ js.Value, args []js.Value) any

SendE2E is a wrapper for sending specifically to the AuthenticatedConnection's partner.Manager.

Parameters:

  • args[0] - Message type from catalog.MessageType (int).
  • args[1] - Message payload (Uint8Array).

Returns a promise:

type Backup

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

Backup wraps the bindings.Backup object so its methods can be wrapped to be Javascript compatible.

func (*Backup) AddJson

func (b *Backup) AddJson(_ js.Value, args []js.Value) any

AddJson stores the argument within the Backup structure.

Parameters:

  • args[0] - JSON to store (string).

func (*Backup) IsBackupRunning

func (b *Backup) IsBackupRunning(js.Value, []js.Value) any

IsBackupRunning returns true if the backup has been initialized and is running. Returns false if it has been stopped.

Returns:

  • If the backup is running (boolean).

func (*Backup) StopBackup

func (b *Backup) StopBackup(js.Value, []js.Value) any

StopBackup stops the backup processes and deletes the user's password from storage. To enable backups again, call InitializeBackup.

Returns:

  • Throws a TypeError if stopping the backup fails.

type ChannelDbCipher

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

ChannelDbCipher wraps the bindings.ChannelDbCipher object so its methods can be wrapped to be Javascript compatible.

func (*ChannelDbCipher) Decrypt

func (c *ChannelDbCipher) Decrypt(_ js.Value, args []js.Value) any

Decrypt will decrypt the passed in encrypted value. The plaintext will be returned by this function. Any padding will be discarded within this function.

Parameters:

Returns:

  • The plaintext of the ciphertext passed in (Uint8Array).
  • Throws a TypeError if it fails to encrypt the plaintext.

func (*ChannelDbCipher) Encrypt

func (c *ChannelDbCipher) Encrypt(_ js.Value, args []js.Value) any

Encrypt will encrypt the raw data. It will return a ciphertext. Padding is done on the plaintext so all encrypted data looks uniform at rest.

Parameters:

  • args[0] - The data to be encrypted (Uint8Array). This must be smaller than the block size passed into NewChannelsDatabaseCipher. If it is larger, this will return an error.

Returns:

  • The ciphertext of the plaintext passed in (Uint8Array).
  • Throws a TypeError if it fails to encrypt the plaintext.

func (*ChannelDbCipher) GetID

func (c *ChannelDbCipher) GetID(js.Value, []js.Value) any

GetID returns the ID for this bindings.ChannelDbCipher in the channelDbCipherTracker.

Returns:

  • Tracker ID (int).

func (*ChannelDbCipher) MarshalJSON added in v0.1.10

func (c *ChannelDbCipher) MarshalJSON(js.Value, []js.Value) any

MarshalJSON marshals the cipher into valid JSON.

Returns:

  • JSON of the cipher (Uint8Array).
  • Throws a TypeError if marshalling fails.

func (*ChannelDbCipher) UnmarshalJSON added in v0.1.10

func (c *ChannelDbCipher) UnmarshalJSON(_ js.Value, args []js.Value) any

UnmarshalJSON unmarshalls JSON into the cipher. This function adheres to the json.Unmarshaler interface.

Note that this function does not transfer the internal RNG. Use channel.NewCipherFromJSON to properly reconstruct a cipher from JSON.

Parameters:

  • args[0] - JSON data to unmarshal (Uint8Array).

Returns:

  • JSON of the cipher (Uint8Array).
  • Throws a TypeError if marshalling fails.

type ChannelsManager

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

ChannelsManager wraps the bindings.ChannelsManager object so its methods can be wrapped to be Javascript compatible.

func (*ChannelsManager) DeleteNickname

func (ch *ChannelsManager) DeleteNickname(_ js.Value, args []js.Value) any

DeleteNickname deletes the nickname for a given channel.

Parameters:

  • args[0] - Marshalled bytes if the channel's id.ID (Uint8Array).

Returns:

  • Throws TypeError if deleting the nickname fails.

func (*ChannelsManager) ExportPrivateIdentity

func (ch *ChannelsManager) ExportPrivateIdentity(_ js.Value, args []js.Value) any

ExportPrivateIdentity encrypts and exports the private identity to a portable string.

Parameters:

  • args[0] - Password to encrypt the identity with (string).

Returns:

  • JSON of the encrypted private identity (Uint8Array).
  • Throws TypeError if exporting the identity fails.

func (*ChannelsManager) GetChannels

func (ch *ChannelsManager) GetChannels(js.Value, []js.Value) any

GetChannels returns the IDs of all channels that have been joined.

Returns:

  • JSON of an array of marshalled id.ID (Uint8Array).
  • Throws a TypeError if getting the channels fails.

JSON Example:

{
  "U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID",
  "15tNdkKbYXoMn58NO6VbDMDWFEyIhTWEGsvgcJsHWAgD"
}

func (*ChannelsManager) GetID

func (ch *ChannelsManager) GetID(js.Value, []js.Value) any

GetID returns the ID for this ChannelsManager in the ChannelsManager tracker.

Returns:

  • Tracker ID (int).

func (*ChannelsManager) GetIdentity

func (ch *ChannelsManager) GetIdentity(js.Value, []js.Value) any

GetIdentity returns the marshaled public identity (channel.Identity) that the channel is using.

Returns:

  • JSON of the channel.Identity (Uint8Array).
  • Throws TypeError if marshalling the identity fails.

func (*ChannelsManager) GetNickname

func (ch *ChannelsManager) GetNickname(_ js.Value, args []js.Value) any

GetNickname returns the nickname set for a given channel. Returns an error if there is no nickname set.

Parameters:

  • args[0] - Marshalled bytes if the channel's id.ID (Uint8Array).

Returns:

  • The nickname (string).
  • Throws TypeError if the channel has no nickname set.

func (*ChannelsManager) GetShareURL

func (ch *ChannelsManager) GetShareURL(_ js.Value, args []js.Value) any

GetShareURL generates a URL that can be used to share this channel with others on the given host.

A URL comes in one of three forms based on the privacy level set when generating the channel. Each privacy level hides more information than the last with the lowest level revealing everything and the highest level revealing nothing. For any level above the lowest, a password is returned, which will be required when decoding the URL.

The maxUses is the maximum number of times this URL can be used to join a channel. If it is set to 0, then it can be shared unlimited times. The max uses is set as a URL parameter using the key broadcast.MaxUsesKey. Note that this number is also encoded in the secret data for private and secret URLs, so if the number is changed in the URL, is will be verified when calling DecodePublicURL or DecodePrivateURL. There is no enforcement for public URLs.

Parameters:

  • args[0] - ID of Cmix object in tracker (int).
  • args[1] - The URL to append the channel info to (string).
  • args[2] - The maximum number of uses the link can be used (0 for unlimited) (int).
  • args[3] - Marshalled bytes of the channel id.ID (Uint8Array).

Returns:

  • JSON of bindings.ShareURL (Uint8Array).
  • Throws a TypeError if generating the URL fails.

func (*ChannelsManager) GetStorageTag

func (ch *ChannelsManager) GetStorageTag(js.Value, []js.Value) any

GetStorageTag returns the storage tag needed to reload the manager.

Returns:

  • Storage tag (string).

func (*ChannelsManager) JoinChannel

func (ch *ChannelsManager) JoinChannel(_ js.Value, args []js.Value) any

JoinChannel joins the given channel. It will fail if the channel has already been joined.

Parameters:

  • args[0] - A portable channel string. Should be received from another user or generated via GenerateChannel (string).

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:

  • JSON of bindings.ChannelInfo, which describes all relevant channel info (Uint8Array).
  • Throws a TypeError if joining the channel fails.

func (*ChannelsManager) LeaveChannel

func (ch *ChannelsManager) LeaveChannel(_ js.Value, args []js.Value) any

LeaveChannel leaves the given channel. It will return an error if the channel was not previously joined.

Parameters:

  • args[0] - Marshalled bytes of the channel id.ID (Uint8Array).

Returns:

  • Throws a TypeError if the channel does not exist.

func (*ChannelsManager) RegisterReceiveHandler

func (ch *ChannelsManager) RegisterReceiveHandler(_ js.Value, args []js.Value) any

RegisterReceiveHandler is used to register handlers for non-default message types. They can be processed by modules. It is important that such modules sync up with the event model implementation.

There can only be one handler per [channels.MessageType], and this will return an error on any re-registration.

Parameters:

  • args[0] - The message type of the message. This will be a valid [channels.MessageType] (int).
  • args[1] - Javascript object that has functions that implement the bindings.ChannelMessageReceptionCallback interface. This callback will be executed when a channel message of the messageType is received.

Returns:

  • Throws a TypeError if registering the handler fails.

func (*ChannelsManager) ReplayChannel

func (ch *ChannelsManager) ReplayChannel(_ js.Value, args []js.Value) any

ReplayChannel replays all messages from the channel within the network's memory (~3 weeks) over the event model.

Parameters:

  • args[0] - Marshalled bytes of the channel id.ID (Uint8Array).

Returns:

  • Throws a TypeError if the replay fails.

func (*ChannelsManager) SendAdminGeneric

func (ch *ChannelsManager) SendAdminGeneric(_ js.Value, args []js.Value) any

SendAdminGeneric is used to send a raw message over a channel encrypted with admin keys, identifying it as sent by the admin. In general, it should be wrapped in a function that defines the wire protocol. If the final message, before being sent over the wire, is too long, this will return an error. The message must be at most 510 bytes long.

Parameters:

  • args[0] - The PEM-encode admin RSA private key (Uint8Array).
  • args[1] - Marshalled bytes of the channel id.ID (Uint8Array).
  • args[2] - The message type of the message. This will be a valid [channels.MessageType] (int).
  • args[3] - The contents of the message (Uint8Array).
  • args[4] - 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 (int).
  • args[5] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SendGeneric

func (ch *ChannelsManager) SendGeneric(_ js.Value, args []js.Value) any

SendGeneric is used to send a raw message over a channel. In general, it should be wrapped in a function which defines the wire protocol. If the final message, before being sent over the wire, is too long, this will return an error. Due to the underlying encoding using compression, it isn't possible to define the largest payload that can be sent, but it will always be possible to send a payload of 802 bytes at minimum. The meaning of validUntil depends on the use case.

Parameters:

  • args[0] - Marshalled bytes of the channel id.ID (Uint8Array).
  • args[1] - The message type of the message. This will be a valid [channels.MessageType] (int).
  • args[2] - The contents of the message (Uint8Array).
  • args[3] - 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 (int).
  • args[4] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SendMessage

func (ch *ChannelsManager) SendMessage(_ js.Value, args []js.Value) any

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:

  • args[0] - Marshalled bytes of the channel id.ID (Uint8Array).
  • args[1] - The contents of the message (string).
  • args[2] - 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 (int).
  • args[3] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SendReaction

func (ch *ChannelsManager) SendReaction(_ js.Value, args []js.Value) any

SendReaction is used to send a reaction to a message over a channel. The reaction must be a single emoji with no other characters, and will be rejected otherwise. Users will drop the reaction if they do not recognize the reactTo message.

Parameters:

  • args[0] - Marshalled bytes of the channel id.ID (Uint8Array).
  • args[1] - The user's reaction. This should be a single emoji with no other characters. As such, a Unicode string is expected (string).
  • args[2] - JSON of channel.MessageID of the message you wish to reply to. This may be found in the bindings.ChannelSendReport if replying to your own. Alternatively, if reacting to another user's message, you may retrieve it via the ChannelMessageReceptionCallback registered using RegisterReceiveHandler (Uint8Array).
  • args[3] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SendReply

func (ch *ChannelsManager) SendReply(_ js.Value, args []js.Value) any

SendReply is used to send a formatted message over a channel. Due to the underlying encoding using compression, it isn't possible to define the largest payload that can be sent, but it will always be possible to send a payload of 766 bytes at minimum.

If the message ID the reply is sent to is nonexistent, the other side will post the message as a normal message and not a reply. The message will auto delete validUntil after the round it is sent in, lasting forever if [channels.ValidForever] is used.

Parameters:

  • args[0] - Marshalled bytes of the channel id.ID (Uint8Array).
  • args[1] - 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 (string).
  • args[2] - JSON of channel.MessageID of the message you wish to reply to. This may be found in the bindings.ChannelSendReport if replying to your own. Alternatively, if reacting to another user's message, you may retrieve it via the bindings.ChannelMessageReceptionCallback registered using RegisterReceiveHandler (Uint8Array).
  • args[3] - 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 (int).
  • args[4] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SetNickname

func (ch *ChannelsManager) SetNickname(_ js.Value, args []js.Value) any

SetNickname sets the nickname for a given channel. The nickname must be valid according to IsNicknameValid.

Parameters:

  • args[0] - The nickname to set (string).
  • args[1] - Marshalled bytes if the channel's id.ID (Uint8Array).

Returns:

  • Throws TypeError if unmarshalling the ID fails or the nickname is invalid.

type Cmix

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

Cmix wraps the bindings.Cmix object so its methods can be wrapped to be Javascript compatible.

func (*Cmix) AddHealthCallback

func (c *Cmix) AddHealthCallback(_ js.Value, args []js.Value) any

AddHealthCallback adds a callback that gets called whenever the network health changes. Returns a registration ID that can be used to unregister.

Parameters:

Returns:

  • A registration ID that can be used to unregister the callback (int).

func (*Cmix) ChangeNumberOfNodeRegistrations

func (c *Cmix) ChangeNumberOfNodeRegistrations(_ js.Value, args []js.Value) any

ChangeNumberOfNodeRegistrations changes the number of parallel node registrations up to the initialized maximum.

Parameters:

  • args[0] - The number of parallel node registrations (int).
  • args[1] - The timeout, in milliseconds, to wait when changing node registrations before failing (int).

Returns:

  • Throws TypeError if changing registrations fails.

func (*Cmix) Connect

func (c *Cmix) Connect(_ js.Value, args []js.Value) any

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:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Marshalled bytes of the recipient contact.Contact (Uint8Array).
  • args[3] - JSON of xxdk.E2EParams (Uint8Array).

Returns a promise:

  • Resolves to a Javascript representation of the Connection object.
  • Rejected with an error if loading the parameters or connecting fails.

func (*Cmix) ConnectWithAuthentication

func (c *Cmix) ConnectWithAuthentication(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Marshalled bytes of the recipient contact.Contact (Uint8Array).
  • args[3] - JSON of xxdk.E2EParams (Uint8Array).

Returns a promise:

  • Resolves to a Javascript representation of the Connection object.
  • Rejected with an error if loading the parameters or connecting fails.

func (*Cmix) GetID

func (c *Cmix) GetID(js.Value, []js.Value) any

GetID returns the ID for this bindings.Cmix in the cmixTracker.

Returns:

  • Tracker ID (int).

func (*Cmix) GetNodeRegistrationStatus

func (c *Cmix) GetNodeRegistrationStatus(js.Value, []js.Value) any

GetNodeRegistrationStatus returns the current state of node registration.

Returns:

  • JSON of bindings.NodeRegistrationReport containing the number of nodes that the user is registered with and the number of nodes present in the NDF.
  • An error if it cannot get the node registration status. The most likely cause is that the network is unhealthy.

func (*Cmix) GetReceptionRegistrationValidationSignature

func (c *Cmix) GetReceptionRegistrationValidationSignature(
	js.Value, []js.Value) any

GetReceptionRegistrationValidationSignature returns the signature provided by the xx network.

Returns:

  • Reception registration validation signature (Uint8Array).

func (*Cmix) GetRunningProcesses

func (c *Cmix) GetRunningProcesses(js.Value, []js.Value) any

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:

  • JSON of strings (Uint8Array).
  • Throws TypeError if getting the processes fails.

JSON Example:

{
  "FileTransfer{BatchBuilderThread, FilePartSendingThread#0, FilePartSendingThread#1, FilePartSendingThread#2, FilePartSendingThread#3}",
  "MessageReception Worker 0"
}

func (*Cmix) HasRunningProcessies

func (c *Cmix) HasRunningProcessies(js.Value, []js.Value) any

HasRunningProcessies checks if any background threads are running and returns true if one or more are.

This is meant to be used when Cmix.NetworkFollowerStatus returns 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.

Returns:

  • True if there are running processes (boolean).

func (*Cmix) IsHealthy

func (c *Cmix) IsHealthy(js.Value, []js.Value) any

IsHealthy returns true if the network is read to be in a healthy state where messages can be sent.

Returns:

  • True if the network is healthy (boolean).

func (*Cmix) IsReady

func (c *Cmix) IsReady(_ js.Value, args []js.Value) any

IsReady returns true if at least the given percent of node registrations have completed. If not all have completed, then it returns false and howClose will be a percent (0-1) of node registrations completed.

Parameters:

  • args[0] - The percentage of nodes required to be registered with to be ready. This is a number between 0 and 1 (float64).

Returns:

func (*Cmix) MakeLegacyReceptionIdentity

func (c *Cmix) MakeLegacyReceptionIdentity(js.Value, []js.Value) any

MakeLegacyReceptionIdentity generates the legacy identity for receiving messages.

Returns a promise:

  • Resolves to the JSON of the xxdk.ReceptionIdentity object (Uint8Array).
  • Rejected with an error if creating a new legacy identity fails.

func (*Cmix) MakeReceptionIdentity

func (c *Cmix) MakeReceptionIdentity(js.Value, []js.Value) any

MakeReceptionIdentity generates a new cryptographic identity for receiving messages.

Returns a promise:

  • Resolves to the JSON of the xxdk.ReceptionIdentity object (Uint8Array).
  • Rejected with an error if creating a new identity fails.

func (*Cmix) NetworkFollowerStatus

func (c *Cmix) NetworkFollowerStatus(js.Value, []js.Value) any

NetworkFollowerStatus gets the state of the network follower. It returns a status with the following values:

Stopped  - 0
Running  - 2000
Stopping - 3000

Returns:

  • Network status code (int).

func (*Cmix) PauseNodeRegistrations

func (c *Cmix) PauseNodeRegistrations(_ js.Value, args []js.Value) any

PauseNodeRegistrations stops all node registrations and returns a function to resume them.

Parameters:

  • args[0] - The timeout, in milliseconds, to wait when stopping threads before failing (int).

Returns:

  • Throws TypeError if pausing fails.

func (*Cmix) ReadyToSend

func (c *Cmix) ReadyToSend(js.Value, []js.Value) any

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.

Returns:

  • Returns true if network is ready to send on (boolean).

func (*Cmix) RegisterClientErrorCallback

func (c *Cmix) RegisterClientErrorCallback(_ js.Value, args []js.Value) any

RegisterClientErrorCallback registers the callback to handle errors from the long-running threads controlled by StartNetworkFollower and StopNetworkFollower.

Parameters:

func (*Cmix) RemoveHealthCallback

func (c *Cmix) RemoveHealthCallback(_ js.Value, args []js.Value) any

RemoveHealthCallback removes a health callback using its registration ID.

Parameters:

  • args[0] - Callback registration ID (int).

func (*Cmix) StartNetworkFollower

func (c *Cmix) StartNetworkFollower(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - Timeout when stopping threads in milliseconds (int).

Returns:

  • Throws a TypeError if starting the network follower fails.

func (*Cmix) StopNetworkFollower

func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) any

StopNetworkFollower stops the network follower if it is running.

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.

Returns:

  • Throws a TypeError if the follower is in the wrong state to stop or if it fails to stop.

func (*Cmix) TrackServices

func (c *Cmix) TrackServices(_ js.Value, args []js.Value) any

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 call that may need context on the available services for this client.

Parameters:

func (*Cmix) TrackServicesWithIdentity added in v0.1.10

func (c *Cmix) TrackServicesWithIdentity(_ js.Value, args []js.Value) any

TrackServicesWithIdentity will return via a callback the list of services the backend keeps track of for the provided identity. This may be passed into other bindings call which may need context on the available services for this single identity. This will only return services for the given identity.

Parameters:

  • args[0] - ID of E2e object in tracker (int).
  • args[1] - Javascript object that has functions that implement the bindings.ClientError interface.

Returns:

  • Throws TypeError if the E2e ID is invalid.

func (*Cmix) WaitForNetwork

func (c *Cmix) WaitForNetwork(_ js.Value, args []js.Value) any

WaitForNetwork will block until either the network is healthy or the passed timeout is reached. It will return true if the network is healthy.

Parameters:

  • args[0] - Timeout when stopping threads in milliseconds (int).

Returns a promise:

  • A promise that resolves if the network is healthy and rejects if the network is not healthy.

func (*Cmix) WaitForRoundResult

func (c *Cmix) WaitForRoundResult(_ js.Value, args []js.Value) any

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.

roundList is a JSON marshalled bindings.RoundsList or any JSON marshalled send report that inherits a bindings.RoundsList object.

Parameters:

Returns:

  • Throws a TypeError if the parameters are invalid or getting round results fails.

type Connection

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

Connection wraps the bindings.Connection object so its methods can be wrapped to be Javascript compatible.

func (*Connection) Close

func (c *Connection) Close(js.Value, []js.Value) any

Close deletes this Connection's partner.Manager and releases resources.

Returns:

  • Throws a TypeError if closing fails.

func (*Connection) GetId

func (c *Connection) GetId(js.Value, []js.Value) any

GetId returns the ID for this bindings.Connection in the connectionTracker.

Returns:

  • Tracker ID (int).

func (*Connection) GetPartner

func (c *Connection) GetPartner(js.Value, []js.Value) any

GetPartner returns the partner.Manager for this Connection.

Returns:

  • Marshalled bytes of the partner's id.ID (Uint8Array).

func (*Connection) RegisterListener

func (c *Connection) RegisterListener(_ js.Value, args []js.Value) any

RegisterListener is used for E2E reception and allows for reading data sent from the partner.Manager.

Parameters:

Returns:

  • Throws a TypeError is registering the listener fails.

func (*Connection) SendE2E

func (c *Connection) SendE2E(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - Message type from catalog.MessageType (int).
  • args[1] - Message payload (Uint8Array).

Returns a promise:

type DummyTraffic

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

DummyTraffic wraps the bindings.DummyTraffic object so its methods can be wrapped to be Javascript compatible.

func (*DummyTraffic) GetStatus

func (dt *DummyTraffic) GetStatus(js.Value, []js.Value) any

GetStatus returns the current state of the DummyTraffic manager's sending thread. Note that this function does not return the status set by the most recent call to DummyTraffic.SetStatus. Instead, this call returns the current status of the sending thread. This is due to the small delay that may occur between calling DummyTraffic.SetStatus and the sending thread taking into effect that status change.

Returns:

  • Returns true if sending thread is sending dummy messages and false if sending thread is paused/stopped and is not sending dummy messages (boolean).

func (*DummyTraffic) SetStatus

func (dt *DummyTraffic) SetStatus(_ js.Value, args []js.Value) any

SetStatus sets the state of the DummyTraffic manager's send thread by passing in a boolean parameter. There may be a small delay in between this call and the status of the sending thread to change accordingly. For example, passing false into this call while the sending thread is currently sending messages will not cancel nor halt the sending operation, but will pause the thread once that operation has completed.

Parameters:

  • args[0] - Input should be true if you want to send dummy messages and false if you want to pause dummy messages (boolean).

Returns:

  • Throws a TypeError if the DummyTraffic.SetStatus is called too frequently, causing the internal status channel to fill.

type E2e

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

E2e wraps the bindings.E2e object so its methods can be wrapped to be Javascript compatible.

func (*E2e) AddPartnerCallback

func (e *E2e) AddPartnerCallback(_ js.Value, args []js.Value) any

AddPartnerCallback adds a new callback that overrides the generic auth callback for the given partner ID.

Parameters:

  • args[0] - Marshalled bytes of the partner id.ID (Uint8Array).
  • args[1] - Javascript object that has functions that implement the bindings.AuthCallbacks interface.

Returns:

  • Throws TypeError if the id.ID cannot be unmarshalled.

func (*E2e) AddService

func (e *E2e) AddService(_ js.Value, args []js.Value) any

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.

Parameters:

  • args[0] - tag for the service (string).
  • args[1] - Javascript object that has functions that implement the bindings.Processor interface.

Returns:

  • Throws TypeError if registering the service fails.

func (*E2e) CallAllReceivedRequests

func (e *E2e) CallAllReceivedRequests(js.Value, []js.Value) any

CallAllReceivedRequests will iterate through all pending contact requests and replay them on the callbacks.

func (*E2e) Confirm

func (e *E2e) Confirm(_ js.Value, args []js.Value) any

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 E2e.ReplayConfirm.

Parameters:

Returns a promise:

  • Resolves to the ID of the round (int).
  • Rejected with an error if sending the confirmation fails.

func (*E2e) DeleteAllRequests

func (e *E2e) DeleteAllRequests(js.Value, []js.Value) any

DeleteAllRequests clears all requests from auth storage.

Returns:

  • Throws TypeError if the deletion fails.

func (*E2e) DeleteContact

func (e *E2e) DeleteContact(_ js.Value, args []js.Value) any

DeleteContact removes a partner from E2e's storage.

Parameters:

  • args[0] - Marshalled bytes of the partner id.ID (Uint8Array).

Returns:

  • Throws TypeError if deleting the partner fails.

func (*E2e) DeletePartnerCallback

func (e *E2e) DeletePartnerCallback(_ js.Value, args []js.Value) any

DeletePartnerCallback deletes the callback that overrides the generic auth callback for the given partner ID.

Parameters:

  • args[0] - Marshalled bytes of the partner id.ID (Uint8Array).

Returns:

  • Throws TypeError if the id.ID cannot be unmarshalled.

func (*E2e) DeleteReceiveRequests

func (e *E2e) DeleteReceiveRequests(js.Value, []js.Value) any

DeleteReceiveRequests clears all received requests from auth storage.

Returns:

  • Throws TypeError if the deletion fails.

func (*E2e) DeleteRequest

func (e *E2e) DeleteRequest(_ js.Value, args []js.Value) any

DeleteRequest deletes sent or received requests for a specific partner ID.

Parameters:

Returns:

  • Throws TypeError if the deletion fails.

func (*E2e) DeleteSentRequests

func (e *E2e) DeleteSentRequests(js.Value, []js.Value) any

DeleteSentRequests clears all sent requests from auth storage.

Returns:

  • Throws TypeError if the deletion fails.

func (*E2e) FirstPartitionSize

func (e *E2e) FirstPartitionSize(js.Value, []js.Value) any

FirstPartitionSize returns the max partition payload size for the first payload.

Returns:

  • Max partition payload size (int).

func (*E2e) GetAllPartnerIDs

func (e *E2e) GetAllPartnerIDs(js.Value, []js.Value) any

GetAllPartnerIDs returns a list of all partner IDs that the user has an E2E relationship with.

Returns:

  • JSON of array of id.ID (Uint8Array).
  • Throws TypeError if getting partner IDs fails.

func (*E2e) GetContact

func (e *E2e) GetContact(js.Value, []js.Value) any

GetContact returns a contact.Contact object for the E2e bindings.ReceptionIdentity.

Returns:

func (*E2e) GetHistoricalDHPrivkey

func (e *E2e) GetHistoricalDHPrivkey(js.Value, []js.Value) any

GetHistoricalDHPrivkey returns the user's marshalled historical DH private key.

Returns:

  • JSON of cyclic.Int (Uint8Array).
  • Throws TypeError if getting the key fails.

func (*E2e) GetHistoricalDHPubkey

func (e *E2e) GetHistoricalDHPubkey(js.Value, []js.Value) any

GetHistoricalDHPubkey returns the user's marshalled historical DH public key. key.

Returns:

  • JSON of cyclic.Int (Uint8Array).
  • Throws TypeError if getting the key fails.

func (*E2e) GetID

func (e *E2e) GetID(js.Value, []js.Value) any

GetID returns the ID for this E2e in the E2e tracker.

Returns:

  • Tracker ID (int).

func (*E2e) GetReceivedRequest

func (e *E2e) GetReceivedRequest(_ js.Value, args []js.Value) any

GetReceivedRequest returns a contact if there is a received request for it.

Parameters:

Returns:

  • Marshalled bytes of contact.Contact (Uint8Array).
  • Throws TypeError if getting the received request fails.

func (*E2e) GetReceptionID

func (e *E2e) GetReceptionID(js.Value, []js.Value) any

GetReceptionID returns the marshalled default IDs.

Returns:

  • Marshalled bytes of id.ID (Uint8Array).

func (*E2e) GetUdAddressFromNdf

func (e *E2e) GetUdAddressFromNdf(js.Value, []js.Value) any

GetUdAddressFromNdf retrieve the User Discovery's network address fom the NDF.

Returns:

  • User Discovery's address (string).

func (*E2e) GetUdCertFromNdf

func (e *E2e) GetUdCertFromNdf(js.Value, []js.Value) any

GetUdCertFromNdf retrieves the User Discovery's TLS certificate from the NDF.

Returns:

  • Public certificate in PEM format (Uint8Array).

func (*E2e) GetUdContactFromNdf

func (e *E2e) GetUdContactFromNdf(js.Value, []js.Value) any

GetUdContactFromNdf assembles the User Discovery's contact file from the data within the NDF.

Returns

  • Marshalled bytes of contact.Contact (Uint8Array).
  • Throws a TypeError if the contact file cannot be loaded.

func (*E2e) HasAuthenticatedChannel

func (e *E2e) HasAuthenticatedChannel(_ js.Value, args []js.Value) any

HasAuthenticatedChannel returns true if an authenticated channel with the partner exists, otherwise returns false.

Parameters:

  • args[0] - Marshalled bytes of id.ID (Uint8Array).

Returns:

  • Existence of authenticated channel (boolean).
  • Throws TypeError if unmarshalling the ID or getting the channel fails.

func (*E2e) PartitionSize

func (e *E2e) PartitionSize(_ js.Value, args []js.Value) any

PartitionSize returns the partition payload size for the given payload index. The first payload is index 0.

Parameters:

  • args[0] - Payload index (int).

Returns:

  • Partition payload size (int).

func (*E2e) PayloadSize

func (e *E2e) PayloadSize(js.Value, []js.Value) any

PayloadSize returns the max payload size for a partitionable E2E message.

Returns:

  • Max payload size (int).

func (*E2e) RegisterListener

func (e *E2e) RegisterListener(_ js.Value, args []js.Value) any

RegisterListener registers a new listener.

Parameters:

  • args[0] - Marshalled byte of the user id.ID who sends messages to this user that this function will register a listener for (Uint8Array).
  • args[1] - Message type from catalog.MessageType you want to listen for (int).
  • args[2] - Javascript object that has functions that implement the bindings.Listener interface; do not pass nil as the listener.

Returns:

  • Throws TypeError if registering the service fails.

func (*E2e) RemoveService

func (e *E2e) RemoveService(_ js.Value, args []js.Value) any

RemoveService removes all services for the given tag.

Parameters:

  • args[0] - Tag of services to remove (string).

Returns:

  • Throws TypeError if removing the services fails.

func (*E2e) ReplayConfirm

func (e *E2e) ReplayConfirm(_ js.Value, args []js.Value) any

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:

Returns a promise:

  • Resolves to the ID of the round (int).
  • Rejected with an error if resending the confirmation fails.

func (*E2e) Request

func (e *E2e) Request(_ js.Value, args []js.Value) any

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 E2e.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:

Returns a promise:

  • Resolves to the ID of the round (int).
  • Rejected with an error if sending the request fails.

func (*E2e) Reset

func (e *E2e) Reset(_ js.Value, args []js.Value) any

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:

Returns a promise:

  • Resolves to the ID of the round (int).
  • Rejected with an error if sending the reset fails.

func (*E2e) SecondPartitionSize

func (e *E2e) SecondPartitionSize(js.Value, []js.Value) any

SecondPartitionSize returns the max partition payload size for all payloads after the first payload.

Returns:

  • Max payload size (int).

func (*E2e) SendE2E

func (e *E2e) SendE2E(_ js.Value, args []js.Value) any

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:

  • args[0] - Message type from catalog.MessageType (int).
  • args[1] - Marshalled bytes of id.ID (Uint8Array).
  • args[2] - Message payload (Uint8Array).
  • args[3] - JSON xxdk.E2EParams (Uint8Array).

Returns a promise:

func (*E2e) VerifyOwnership

func (e *E2e) VerifyOwnership(_ js.Value, args []js.Value) any

VerifyOwnership checks if the received ownership proof is valid.

Parameters:

  • args[0] - Marshalled bytes of the received contact.Contact (Uint8Array).
  • args[1] - Marshalled bytes of the verified contact.Contact (Uint8Array).
  • args[2] - ID of E2e object in tracker (int).

Returns:

  • Returns true if the ownership is valid (boolean).
  • Throws TypeError if loading the parameters fails.

type FilePartTracker

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

FilePartTracker wraps the bindings.FilePartTracker object so its methods can be wrapped to be Javascript compatible.

func (*FilePartTracker) GetNumParts

func (fpt *FilePartTracker) GetNumParts(js.Value, []js.Value) any

GetNumParts returns the total number of file parts in the transfer.

Returns:

  • Number of parts (int).

func (*FilePartTracker) GetPartStatus

func (fpt *FilePartTracker) GetPartStatus(_ js.Value, args []js.Value) any

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)

Parameters:

  • args[0] - Index of part (int).

Returns:

  • Part status (int).

type FileTransfer

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

FileTransfer wraps the bindings.FileTransfer object so its methods can be wrapped to be Javascript compatible.

func (*FileTransfer) CloseSend

func (f *FileTransfer) CloseSend(_ js.Value, args []js.Value) any

CloseSend deletes a file from the internal storage once a transfer has completed or reached the retry limit. Returns an error if the transfer has not run out of retries.

This function should be called once a transfer completes or errors out (as reported by the progress callback).

Parameters:

Returns:

  • Throws a TypeError if the file transfer is incomplete.

func (*FileTransfer) MaxFileNameLen

func (f *FileTransfer) MaxFileNameLen(js.Value, []js.Value) any

MaxFileNameLen returns the max number of bytes allowed for a file name.

Returns:

  • Max file name length (int).

func (*FileTransfer) MaxFileSize

func (f *FileTransfer) MaxFileSize(js.Value, []js.Value) any

MaxFileSize returns the max number of bytes allowed for a file.

Returns:

  • Max file size (int).

func (*FileTransfer) MaxFileTypeLen

func (f *FileTransfer) MaxFileTypeLen(js.Value, []js.Value) any

MaxFileTypeLen returns the max number of bytes allowed for a file type.

Returns:

  • Max file type length (int).

func (*FileTransfer) MaxPreviewSize

func (f *FileTransfer) MaxPreviewSize(js.Value, []js.Value) any

MaxPreviewSize returns the max number of bytes allowed for a file preview.

Returns:

  • Max preview size (int).

func (*FileTransfer) Receive

func (f *FileTransfer) Receive(_ js.Value, args []js.Value) any

Receive returns the full file on the completion of the transfer. It deletes internal references to the data and unregisters any attached progress callbacks. 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:

Returns:

  • File contents (Uint8Array).
  • Throws a TypeError the file transfer is incomplete or Receive has already been called.

func (*FileTransfer) RegisterReceivedProgressCallback

func (f *FileTransfer) RegisterReceivedProgressCallback(
	_ js.Value, args []js.Value) any

RegisterReceivedProgressCallback allows for the registration of a callback to track the progress of an individual received file transfer.

This should be done when a new transfer is received on the ReceiveCallback.

Parameters:

Returns:

  • Throws a TypeError if registering the callback fails.

func (*FileTransfer) RegisterSentProgressCallback

func (f *FileTransfer) RegisterSentProgressCallback(
	_ js.Value, args []js.Value) any

RegisterSentProgressCallback allows for the registration of a callback to track the progress of an individual sent file transfer.

SentProgressCallback is auto registered on Send; this function should be called when resuming clients or registering extra callbacks.

Parameters:

Returns:

  • Throws a TypeError if registering the callback fails.

func (*FileTransfer) Send

func (f *FileTransfer) Send(_ js.Value, args []js.Value) any

Send is the bindings-level function for sending a file.

Parameters:

  • args[0] - JSON of bindings.FileSend (Uint8Array).
  • args[1] - Marshalled bytes of the recipient id.ID (Uint8Array).
  • args[2] - Number of retries allowed (float).
  • args[3] - Javascript object that has functions that implement the bindings.FileTransferSentProgressCallback interface.
  • args[4] - Duration, in milliseconds, to wait between progress callbacks triggering (int).

Returns a promise:

  • Resolves to a unique ID for this file transfer (Uint8Array).
  • Rejected with an error if sending fails.

type Group

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

Group wraps the bindings.Group object so its methods can be wrapped to be Javascript compatible.

func (*Group) GetCreatedMS

func (g *Group) GetCreatedMS(js.Value, []js.Value) any

GetCreatedMS returns the time the group was created in milliseconds. This is also the time the group requests were sent.

Returns:

  • The time the group was created, in milliseconds (int).

func (*Group) GetCreatedNano

func (g *Group) GetCreatedNano(js.Value, []js.Value) any

GetCreatedNano returns the time the group was created in nanoseconds. This is also the time the group requests were sent.

Returns:

  • The time the group was created, in nanoseconds (int).

func (*Group) GetID

func (g *Group) GetID(js.Value, []js.Value) any

GetID return the 33-byte unique group ID. This represents the id.ID object.

Returns:

  • Marshalled bytes of the group id.ID (Uint8Array).

func (*Group) GetInitMessage

func (g *Group) GetInitMessage(js.Value, []js.Value) any

GetInitMessage returns initial message sent with the group request.

Returns:

  • Initial group message contents (Uint8Array).

func (*Group) GetMembership

func (g *Group) GetMembership(js.Value, []js.Value) any

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:

  • JSON of group.Membership (Uint8Array).
  • Throws a TypeError if marshalling fails.

func (*Group) GetName

func (g *Group) GetName(js.Value, []js.Value) any

GetName returns the name set by the user for the group.

Returns:

  • Group name (Uint8Array).

func (*Group) Serialize

func (g *Group) Serialize(js.Value, []js.Value) any

Serialize serializes the Group.

Returns:

  • Byte representation of the Group (Uint8Array).

type GroupChat

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

GroupChat wraps the bindings.GroupChat object so its methods can be wrapped to be Javascript compatible.

func (*GroupChat) GetGroup

func (g *GroupChat) GetGroup(_ js.Value, args []js.Value) any

GetGroup returns the group with the group ID. If no group exists, then the error "failed to find group" is returned.

Parameters:

  • args[0] - The marshalled bytes of the group id.ID (Uint8Array). This can be found in the report returned by GroupChat.MakeGroup.

Returns:

  • Javascript representation of the GroupChat object.
  • Throws a TypeError if getting the group fails.

func (*GroupChat) GetGroups

func (g *GroupChat) GetGroups(js.Value, []js.Value) any

GetGroups returns a list of group IDs that the user is a member of.

Returns:

  • JSON of array of id.ID representing all group ID's (Uint8Array).
  • Throws a TypeError if getting the groups fails.

func (*GroupChat) JoinGroup

func (g *GroupChat) JoinGroup(_ js.Value, args []js.Value) any

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:

Returns:

  • Throws a TypeError if joining the group fails.

func (*GroupChat) LeaveGroup

func (g *GroupChat) LeaveGroup(_ js.Value, args []js.Value) any

LeaveGroup deletes a group so a user no longer has access.

Parameters:

  • args[0] - The marshalled bytes of the group id.ID (Uint8Array). This can be found in the report returned by GroupChat.MakeGroup.

Returns:

  • Throws a TypeError if leaving the group fails.

func (*GroupChat) MakeGroup

func (g *GroupChat) MakeGroup(_ js.Value, args []js.Value) any

MakeGroup creates a new group and sends a group request to all members in the group.

Parameters:

  • args[0] - JSON of array of id.ID; it contains the IDs of members the user wants to add to the group (Uint8Array).
  • args[1] - The initial message sent to all members in the group. This is an optional parameter and may be nil (Uint8Array).
  • args[2] - 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 (Uint8Array).

Returns a promise:

func (*GroupChat) NumGroups

func (g *GroupChat) NumGroups(js.Value, []js.Value) any

NumGroups returns the number of groups the user is a part of.

Returns:

  • Number of groups (int).

func (*GroupChat) ResendRequest

func (g *GroupChat) ResendRequest(_ js.Value, args []js.Value) any

ResendRequest resends a group request to all members in the group.

Parameters:

  • args[0] - The marshalled bytes of the group id.ID (Uint8Array). This can be found in the report returned by GroupChat.MakeGroup.

Returns a promise:

func (*GroupChat) Send

func (g *GroupChat) Send(_ js.Value, args []js.Value) any

Send is the bindings-level function for sending to a group.

Parameters:

  • args[0] - The marshalled bytes of the group id.ID (Uint8Array). This can be found in the report returned by GroupChat.MakeGroup.
  • args[1] - The message that the user wishes to send to the group (Uint8Array).
  • args[2] - The tag associated with the message (string). This tag may be empty.

Returns a promise:

type JsConsoleLogListener

type JsConsoleLogListener struct {
	jww.Threshold
	js.Value
	// contains filtered or unexported fields
}

JsConsoleLogListener redirects log output to the Javascript console.

func NewJsConsoleLogListener

func NewJsConsoleLogListener(threshold jww.Threshold) *JsConsoleLogListener

NewJsConsoleLogListener initialises a new log listener that listener for the specific threshold and prints the logs to the Javascript console.

func (*JsConsoleLogListener) Listen

func (ll *JsConsoleLogListener) Listen(t jww.Threshold) io.Writer

Listen is called for every logging event. This function adheres to the jwalterweatherman.LogListener type.

type LogFile

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

LogFile represents a virtual log file in memory. It contains a circular buffer that limits the log file, overwriting the oldest logs.

func NewLogFile

func NewLogFile(
	name string, threshold jww.Threshold, maxSize int) (*LogFile, error)

NewLogFile initialises a new LogFile for log writing.

func (*LogFile) GetFile

func (lf *LogFile) GetFile(js.Value, []js.Value) any

GetFile returns the entire log file.

Returns:

  • Log file contents (string).

func (*LogFile) Listen

func (lf *LogFile) Listen(t jww.Threshold) io.Writer

Listen is called for every logging event. This function adheres to the jwalterweatherman.LogListener type.

func (*LogFile) MaxSize

func (lf *LogFile) MaxSize(js.Value, []js.Value) any

MaxSize returns the max size, in bytes, that the log file is allowed to be.

Returns:

  • Max file size (int).

func (*LogFile) Name

func (lf *LogFile) Name(js.Value, []js.Value) any

Name returns the name of the log file.

Returns:

  • File name (string).

func (*LogFile) Size

func (lf *LogFile) Size(js.Value, []js.Value) any

Size returns the current size, in bytes, written to the log file.

Returns:

  • Current file size (int).

func (*LogFile) Threshold

func (lf *LogFile) Threshold(js.Value, []js.Value) any

Threshold returns the log level threshold used in the file.

Returns:

  • Log level (string).

type ShareURL

type ShareURL struct {
	URL      string `json:"url"`
	Password string `json:"password"`
}

ShareURL is returned by GetShareURL containing the sharable URL and a password, if the channel is private.

type Stopper

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

Stopper wraps the bindings.Stopper interface so its methods can be wrapped to be Javascript compatible.

func (*Stopper) Stop

func (s *Stopper) Stop(js.Value, []js.Value) any

Stop stops the registered listener.

type UserDiscovery

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

UserDiscovery wraps the bindings.UserDiscovery object so its methods can be wrapped to be Javascript compatible.

func (*UserDiscovery) ConfirmFact

func (ud *UserDiscovery) ConfirmFact(_ js.Value, args []js.Value) any

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

Parameters:

  • args[0] - Confirmation ID (string).
  • args[1] - Code (string).

Returns:

  • Throws TypeError if confirming the fact fails.

func (*UserDiscovery) GetContact

func (ud *UserDiscovery) GetContact(js.Value, []js.Value) any

GetContact returns the marshalled bytes of the contact.Contact for UD as retrieved from the NDF.

Returns:

  • Marshalled bytes of contact.Contact (Uint8Array).
  • Throws TypeError if getting the contact fails.

func (*UserDiscovery) GetFacts

func (ud *UserDiscovery) GetFacts(js.Value, []js.Value) any

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

Returns:

func (*UserDiscovery) GetID

func (ud *UserDiscovery) GetID(js.Value, []js.Value) any

GetID returns the ID for this UserDiscovery in the UserDiscovery tracker.

Returns:

  • Tracker ID (int).

func (*UserDiscovery) PermanentDeleteAccount

func (ud *UserDiscovery) PermanentDeleteAccount(_ js.Value, args []js.Value) any

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:

Returns:

  • Throws TypeError if deletion fails.

func (*UserDiscovery) RemoveFact

func (ud *UserDiscovery) RemoveFact(_ js.Value, args []js.Value) any

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:

Returns:

  • Throws TypeError if removing the fact fails.

func (*UserDiscovery) SendRegisterFact

func (ud *UserDiscovery) SendRegisterFact(_ js.Value, args []js.Value) any

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:

Returns:

  • The confirmation ID (string).
  • Throws TypeError if sending the fact fails.

Jump to

Keyboard shortcuts

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