wasm

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: BSD-2-Clause Imports: 45 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 an error if parsing the parameters or making the request fails.

func CheckNoMessageErr added in v0.3.3

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

CheckNoMessageErr determines if the error returned by an EventModel function indicates that the message or item does not exist. It returns true if the error contains channels.NoMessageErr.

Parameters:

  • args[0] - Error to check (Error).

Returns

  • True if the error contains channels.NoMessageErr (boolean).

func ConstructIdentity

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

ConstructIdentity creates a codename in a public [channel.Identity] from an extant identity for a given 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 an error 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 DecodeDMShareURL added in v0.3.3

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

DecodeDMShareURL decodes the user's URL into a DMUser.

Parameters:

  • args[0] - The user's share URL. Should be received from another user or generated via DMClient.GetShareURL (string).

Returns:

  • JSON of DMUser (Uint8Array).
  • Throws an exception on error.

func DecodeInviteURL added in v0.3.4

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

DecodeInviteURL decodes the channel URL, using the password, into a channel pretty print. This function can only be used for URLs from invitations.

Parameters:

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

Returns:

  • The channel pretty print (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 an error 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 GenerateChannelIdentity

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

GenerateChannelIdentity creates a new private channel identity ([channel.PrivateIdentity]) from scratch and assigns it a codename.

The public component can be retrieved as JSON via GetPublicChannelIdentityFromPrivate.

Parameters:

  • args[0] - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.

Returns:

  • Marshalled bytes of [channel.PrivateIdentity] (Uint8Array).
  • Throws an error if generating the identity fails.

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 an error 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 GetChannelNotificationReportsForMe added in v0.3.4

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

GetChannelNotificationReportsForMe checks the notification data against the filter list to determine which notifications belong to the user. A list of notification reports is returned detailing all notifications for the user.

Parameters:

Example JSON of a slice of channels.NotificationFilter:

 [
   {
	    "identifier": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUDYXN5bUlkZW50aWZpZXI=",
	    "channelID": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUD",
	    "tags": ["6de69009a93d53793ee344e8fb48fae194eaf51861d3cc51c7348c337d13aedf-usrping"],
	    "allowLists": {
	      "allowWithTags": {},
	      "allowWithoutTags": {"102":{}, "2":{}}
	    }
	  },
	  {
	    "identifier": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUDc3ltSWRlbnRpZmllcg==",
	    "channelID": "O8NUg0KaDo18ybTKajXM/sgqEYS37+lewPhGV/2sMAUD",
	    "tags": ["6de69009a93d53793ee344e8fb48fae194eaf51861d3cc51c7348c337d13aedf-usrping"],
	    "allowLists": {
	      "allowWithTags": {},
	      "allowWithoutTags": {"1":{}, "40000":{}}
	    }
	  },
	  {
	    "identifier": "jCRgFRQvzzKOb8DJ0fqCRLgr9kiHN9LpqHXVhyHhhlQDYXN5bUlkZW50aWZpZXI=",
	    "channelID": "jCRgFRQvzzKOb8DJ0fqCRLgr9kiHN9LpqHXVhyHhhlQD",
	    "tags": ["6de69009a93d53793ee344e8fb48fae194eaf51861d3cc51c7348c337d13aedf-usrping"],
	    "allowLists": {
	      "allowWithTags": {},
	      "allowWithoutTags": {"102":{}, "2":{}}
	    }
	  }
	]

Returns:

Example return:

[
  {
    "channel": "jOgZopfYj4zrE/AHtKmkf+QEWnfUKv9KfIy/+Bsg0PkD",
    "type": 1,
    "pingType": "usrMention"
  },
  {
    "channel": "GKmfN/LKXQYM6++TC6DeZYqoxvSUPkh5UAHWODqh9zkD",
    "type": 2,
    "pingType": "usrReply"
  },
  {
    "channel": "M+28xtj0coHrhDHfojGNcyb2c4maO7ZuheB6egS0Pc4D",
    "type": 1,
    "pingType": ""
  }
]

func 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 an error 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 GetDmNotificationReportsForMe added in v0.3.4

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

GetDmNotificationReportsForMe checks the notification data against the filter list to determine which notifications belong to the user. A list of notification reports is returned detailing all notifications for the user.

Parameters:

  • args[0] - JSON of dm.NotificationFilter (Uint8Array).
  • args[1] - CSV containing notification data (string).

Example JSON of a slice of dm.NotificationFilter:

{
  "identifier": "MWL6mvtZ9UUm7jP3ainyI4erbRl+wyVaO5MOWboP0rA=",
  "myID": "AqDqg6Tcs359dBNRBCX7XHaotRDhz1ZRQNXIsGaubvID",
  "tags": [
    "61334HtH85DPIifvrM+JzRmLqfV5R4AMEmcPelTmFX0=",
    "zc/EPwtx5OKTVdwLcI15bghjJ7suNhu59PcarXE+m9o=",
    "FvArzVJ/082UEpMDCWJsopCLeLnxJV6NXINNkJTk3k8="
  ],
  "PublicKeys": {
    "61334HtH85DPIifvrM+JzRmLqfV5R4AMEmcPelTmFX0=": "b3HygDv8gjteune9wgBm3YtVuAo2foOusRmj0m5nl6E=",
    "FvArzVJ/082UEpMDCWJsopCLeLnxJV6NXINNkJTk3k8=": "uOLitBZcCh2TEW406jXHJ+Rsi6LybsH8R1u4Mxv/7hA=",
    "zc/EPwtx5OKTVdwLcI15bghjJ7suNhu59PcarXE+m9o=": "lqLD1EzZBxB8PbILUJIfFq4JI0RKThpUQuNlTNgZAWk="
  },
  "allowedTypes": {"1": {}, "2": {}}
}

Returns a promise:

  • Resolves to a JSON of a slice of dm.NotificationReport (Uint8Array).
  • Rejected with an error if getting the reports fails.

Example slice of dm.NotificationReport return:

[
  {"partner": "WUSO3trAYeBf4UeJ5TEL+Q4usoyFf0shda0YUmZ3z8k=", "type": 1},
  {"partner": "5MY652JsVv5YLE6wGRHIFZBMvLklACnT5UtHxmEOJ4o=", "type": 2}
]

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 an error 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 an error if loading the ID from the contact file fails.

func GetNoMessageErr added in v0.3.3

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

GetNoMessageErr returns the error channels.NoMessageErr, which must be returned by EventModel methods (such as EventModel.UpdateFromUUID, EventModel.UpdateFromMessageID, and EventModel.GetMessage) when the message cannot be found.

Returns:

  • channels.NoMessageErr error message (string).

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 an error 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:

  • args[0] - Bytes of the public identity ([channel.Identity]) (Uint8Array).

Returns:

  • JSON of the constructed [channel.Identity] (Uint8Array).
  • Throws an error 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 an error if unmarshalling the bytes or marshalling the identity 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 (int).
  • Throws an error 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 GetWasmSemanticVersion added in v0.3.0

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

GetWasmSemanticVersion returns the current version of the WASM client, it's old version before being updated, and if it has been updated.

Returns:

  • JSON of VersionInfo (Uint8Array).
  • Throws an error if getting the version failed.

func GetXXDKSemanticVersion added in v0.3.0

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

GetXXDKSemanticVersion returns the current version of the xxdk client, it's old version before being updated, and if it has been updated.

Returns:

  • JSON of VersionInfo (Uint8Array).
  • Throws an error if getting the version failed.

func ImportPrivateIdentity

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

ImportPrivateIdentity generates a new [channel.PrivateIdentity] from exported data.

Parameters:

Returns:

  • JSON of [channel.PrivateIdentity] (Uint8Array).
  • Throws an error if importing the identity fails.

func InitChannelsFileTransfer added in v0.3.3

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

InitChannelsFileTransfer creates a file transfer manager for channels.

Parameters:

Returns:

Returns a promise:

  • Resolves to a Javascript representation of the ChannelsFileTransfer object.
  • Rejected with an error if creating the file transfer object fails.

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 an error 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 an error 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 an error if listening fails.

func LoadChannelsManager

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

LoadChannelsManager loads an existing ChannelsManager for the given storage tag.

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

Parameters:

Returns:

  • Javascript representation of the ChannelsManager object.
  • Throws an error 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:

Returns a promise:

  • Resolves to a Javascript representation of the ChannelsManager object.
  • Rejected with an error if loading indexedDb or the manager fails.
  • Throws an error 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] - Path to Javascript file that starts the worker (string).
  • args[2] - The storage tag associated with the previously created channel manager and retrieved with ChannelsManager.GetStorageTag (string).
  • args[3] - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]` (Uint8Array).
  • args[4] - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID (int).
  • args[5] - A Javascript object that implements the function on bindings.ChannelUICallbacks. It is a callback that informs the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.

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 LoadNotifications added in v0.3.4

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

LoadNotifications returns a JS wrapped implementation of bindings.Notifications.

Parameters:

  • args[0] - the cMixID integer

Returns a notifications object or throws an error

func LoadNotificationsDummy added in v0.3.4

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

LoadNotificationsDummy returns a JS wrapped implementation of bindings.Notifications with a dummy notifications implementation.

Parameters:

  • args[0] - the cMixID integer

Returns a notifications object or throws an error

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 an error if the identity cannot be retrieved from storage.

func LoadSynchronizedCmix added in v0.3.4

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

LoadSynchronizedCmix will LoadCmix using a RemoteStore to establish a synchronized RemoteKV.

Parameters:

  • args[0] - Storage directory path (string).
  • args[1] - The remote "directory" or path prefix used by the RemoteStore when reading/writing files (string).
  • args[2] - Password used for storage (Uint8Array).
  • args[3] - Javascript RemoteStore implementation.
  • args[4] - 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 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 an error 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 an error 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 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 an error 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] - Path to Javascript file that starts the worker (string).
  • args[2] - Bytes of a private identity ([channel.PrivateIdentity]) that is generated by GenerateChannelIdentity (Uint8Array).
  • args[3] - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]` (Uint8Array).
  • args[4] - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID (int).
  • args[5] - A Javascript object that implements the function on bindings.ChannelUICallbacks. It is a callback that informs the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.
  • args[6] - ID of DbCipher object in tracker (int). Create this object with NewDatabaseCipher and get its id with DbCipher.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 an error 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] - Path to Javascript file that starts the worker (string).
  • args[2] - Bytes of a private identity ([channel.PrivateIdentity]) that is generated by GenerateChannelIdentity (Uint8Array).
  • args[3] - JSON of an array of integers of channels.ExtensionBuilder IDs. The ID can be retrieved from an object with an extension builder (e.g., ChannelsFileTransfer.GetExtensionBuilderID). Leave empty if not using extension builders. Example: `[2,11,5]` (Uint8Array).
  • args[4] - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID (int).
  • args[5] - A Javascript object that implements the function on bindings.ChannelUICallbacks. It is a callback that informs the UI about various events. The entire interface can be nil, but if defined, each method must be implemented.

Returns a promise:

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

FIXME: package names in comments for indexedDb

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 a promise:

  • Resolves on success.
  • Rejected with an error if creating a new cMix client 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 NewDMClient added in v0.3.0

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

NewDMClient creates a new DMClient from a private identity (codename.PrivateIdentity), used for direct messaging.

This is for instantiating a manager for an identity. For generating a new identity, use codename.GenerateIdentity. You should instantiate every load as there is no load function and associated state in this module.

Parameters:

Returns:

  • Javascript representation of the DMClient object.
  • Throws an error if creating the manager fails.

func NewDMClientWithIndexedDb added in v0.3.0

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

NewDMClientWithIndexedDb creates a new DMClient from a private identity (codename.PrivateIdentity) and an indexedDbWorker as a backend to manage the event model.

This is for instantiating a manager for an identity. For generating a new identity, use codename.GenerateIdentity. You should instantiate every load as there is no load function and associated state in this module.

This function initialises an indexedDbWorker database.

Parameters:

Returns:

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

func NewDMClientWithIndexedDbUnsafe added in v0.3.0

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

NewDMClientWithIndexedDbUnsafe creates a new DMClient from a private identity (codename.PrivateIdentity) and an indexedDbWorker 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 instantiating a manager for an identity. For generating a new identity, use codename.GenerateIdentity. You should instantiate every load as there is no load function and associated state in this module.

This function initialises an indexedDbWorker database.

Parameters:

  • args[0] - ID of Cmix object in tracker (int). This can be retrieved using Cmix.GetID.
  • args[1] - ID of Notifications object in tracker. This can be retrieved using Notifications.GetID (int).
  • args[2] - Path to Javascript file that starts the worker (string).
  • args[3] - Bytes of a private identity (codename.PrivateIdentity) that is generated by codename.GenerateIdentity (Uint8Array).
  • args[4] - A Javascript object that implements the function on bindings.DmCallbacks. It is a callback that informs the UI about updates relating to DM conversations. The interface may be null, but if one is provided, each method must be implemented.

Returns a promise:

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

func NewDatabaseCipher added in v0.3.4

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

NewDatabaseCipher constructs a DbCipher 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 DbCipher.Encrypt that is larger than this value will result in an error (int).

Returns:

  • JavaScript representation of the DbCipher object.
  • Throws an error if creating the cipher fails.

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 is by default paused, and as such the sending thread must be started by calling DummyTraffic.Start. The time duration between each sending operation and the amount of messages sent each interval are randomly generated values with bounds defined by the given parameters below.

Parameters:

  • 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 an error 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 an error 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 an error if creating or loading fails.

func NewSynchronizedCmix added in v0.3.4

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

NewSynchronizedCmix clones a cMix from remote storage.

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] - The remote "directory" or path prefix used by the RemoteStore when reading/writing files (string).
  • args[3] - Password used for storage (Uint8Array).
  • args[4] - Javascript RemoteStore implementation.

Returns a promise:

  • Resolves on success.
  • Rejected with an error if creating a new cMix client 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 an error 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 an error 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 an error 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 an error if the identity cannot be stored in storage.

func SupportedEmojis added in v0.3.0

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

SupportedEmojis returns a list of emojis that are supported by the backend. The list includes all emojis described in UTS #51 section A.1: Data Files.

Returns:

  • JSON of an array of emoji.Emoji (Uint8Array).
  • Throws an error if marshalling the JSON fails.

Example JSON:

	[
	  {
     "character": "☹️",
     "name": "frowning face",
     "comment": "E0.7",
     "codePoint": "2639 FE0F",
     "group": "Smileys \u0026 Emotion",
     "subgroup": "face-concerned"
	  },
	  {
     "character": "☺️",
     "name": "smiling face",
     "comment": "E0.6",
     "codePoint": "263A FE0F",
     "group": "Smileys \u0026 Emotion",
     "subgroup": "face-affection"
	  },
	  {
     "character": "☢️",
     "name": "radioactive",
     "comment": "E1.0",
     "codePoint": "2622 FE0F",
     "group": "Symbols",
     "subgroup": "warning"
	  }
	]

func SupportedEmojisMap added in v0.3.3

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

SupportedEmojisMap returns a map of emojis that are supported by the backend as described by SupportedEmojis.

Returns:

  • JSON of a map of emoji.Emoji (Uint8Array).
  • Throws an error if marshalling the JSON fails.

Example JSON:

	[
	  {
     "character": "☹️",
     "name": "frowning face",
     "comment": "E0.7",
     "codePoint": "2639 FE0F",
     "group": "Smileys \u0026 Emotion",
     "subgroup": "face-concerned"
	  },
	  {
     "character": "☺️",
     "name": "smiling face",
     "comment": "E0.6",
     "codePoint": "263A FE0F",
     "group": "Smileys \u0026 Emotion",
     "subgroup": "face-affection"
	  },
	  {
     "character": "☢️",
     "name": "radioactive",
     "comment": "E1.0",
     "codePoint": "2622 FE0F",
     "group": "Symbols",
     "subgroup": "warning"
	  }
	]

func TransmitSingleUse

func TransmitSingleUse(_ 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 an error if the JSON cannot be unmarshalled.

func ValidForever added in v0.3.0

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

ValidForever returns the value to use for validUntil when you want a message to be available for the maximum amount of time.

Returns:

  • The maximum amount of time (int).

func ValidateReaction added in v0.3.0

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

ValidateReaction checks that the reaction only contains a single grapheme (one or more codepoints that appear as a single character to the user).

Parameters:

  • args[0] - The reaction to validate (string).

Returns:

  • If the reaction is valid, returns null.
  • If the reaction is invalid, returns a Javascript Error object containing emoji.InvalidReaction.

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 an error 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 an error 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 an error if stopping the backup fails.

type ChFilePartTracker added in v0.3.3

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

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

func (*ChFilePartTracker) GetNumParts added in v0.3.3

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

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

Returns:

  • Number of parts (int).

func (*ChFilePartTracker) GetPartStatus added in v0.3.3

func (fpt *ChFilePartTracker) 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 ChannelsFileTransfer added in v0.3.3

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

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

func (*ChannelsFileTransfer) CloseSend added in v0.3.3

func (cft *ChannelsFileTransfer) 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. If neither of those condition are met, an error is returned.

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

Parameters:

Returns a promise:

  • Resolves on success (void).
  • Rejected with an error if the file has not failed or completed or if closing failed.

func (*ChannelsFileTransfer) Download added in v0.3.3

func (cft *ChannelsFileTransfer) Download(_ js.Value, args []js.Value) any

Download begins the download of the file described in the marshalled channelsFileTransfer.FileInfo. The progress of the download is reported on the bindings.FtReceivedProgressCallback.

Once the download completes, the file will be stored in the event model with the given file ID and with the status channels.ReceptionProcessingComplete.

The bindings.FtReceivedProgressCallback only indicates the progress of the file download, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.

Parameters:

  • args[0] - The JSON of channelsFileTransfer.FileInfo received on a channel (Uint8Array).
  • args[1] - The progress callback, which is a callback that reports the progress of the file download. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error. It must be a Javascript object that implements the bindings.FtReceivedProgressCallback interface.
  • args[2] - Progress callback period. A progress callback will be limited from triggering only once per period, in milliseconds (int).

Returns:

Returns a promise:

  • Resolves to the marshalled bytes of fileTransfer.ID that uniquely identifies the file. (Uint8Array).
  • Rejected with an error if downloading fails.

func (*ChannelsFileTransfer) GetExtensionBuilderID added in v0.3.3

func (cft *ChannelsFileTransfer) GetExtensionBuilderID(js.Value, []js.Value) any

GetExtensionBuilderID returns the ID of the extension builder in the tracker. Pass this ID into the channel manager creator to use file transfer manager in conjunction with channels.

Returns:

  • Extension builder ID (int).

func (*ChannelsFileTransfer) MaxFileNameLen added in v0.3.3

func (cft *ChannelsFileTransfer) MaxFileNameLen(js.Value, []js.Value) any

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

Returns:

  • Max number of bytes (int).

func (*ChannelsFileTransfer) MaxFileSize added in v0.3.3

func (cft *ChannelsFileTransfer) MaxFileSize(js.Value, []js.Value) any

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

Returns:

  • Max number of bytes (int).

func (*ChannelsFileTransfer) MaxFileTypeLen added in v0.3.3

func (cft *ChannelsFileTransfer) MaxFileTypeLen(js.Value, []js.Value) any

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

Returns:

  • Max number of bytes (int).

func (*ChannelsFileTransfer) MaxPreviewSize added in v0.3.3

func (cft *ChannelsFileTransfer) MaxPreviewSize(js.Value, []js.Value) any

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

Returns:

  • Max number of bytes (int).

func (*ChannelsFileTransfer) RegisterReceivedProgressCallback added in v0.3.3

func (cft *ChannelsFileTransfer) RegisterReceivedProgressCallback(
	_ js.Value, args []js.Value) any

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

The callback will be called immediately when added to report the current progress of the transfer. It will then call every time a file part is received, the transfer completes, or a fatal error occurs. It is called at most once every period regardless of the number of progress updates.

In the event that the client is closed and resumed, this function must be used to re-register any callbacks previously registered.

Once the download completes, the file will be stored in the event model with the given file ID and with the status channelsFileTransfer.Complete.

The bindings.FtReceivedProgressCallback only indicates the progress of the file download, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.

Parameters:

  • args[0] - Marshalled bytes of the file's fileTransfer.ID (Uint8Array).
  • args[1] - The progress callback, which is a callback that reports the progress of the file download. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error. It must be a Javascript object that implements the bindings.FtReceivedProgressCallback interface.
  • args[2] - Progress callback period. A progress callback will be limited from triggering only once per period, in milliseconds (int).

Returns a promise:

  • Resolves on success (void).
  • Rejected with an error if registering the callback fails.

func (*ChannelsFileTransfer) RegisterSentProgressCallback added in v0.3.3

func (cft *ChannelsFileTransfer) RegisterSentProgressCallback(
	_ js.Value, args []js.Value) any

RegisterSentProgressCallback allows for the registration of a callback to track the progress of an individual file upload. A bindings.FtSentProgressCallback is auto-registered on ChannelsFileTransfer.Send; this function should be called when resuming clients or registering extra callbacks.

The callback will be called immediately when added to report the current progress of the transfer. It will then call every time a file part arrives, the transfer completes, or a fatal error occurs. It is called at most once every period regardless of the number of progress updates.

In the event that the client is closed and resumed, this function must be used to re-register any callbacks previously registered with this function or ChannelsFileTransfer.Send.

The bindings.FtSentProgressCallback only indicates the progress of the file upload, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.

Parameters:

  • args[0] - Marshalled bytes of the file's fileTransfer.ID (Uint8Array).
  • args[1] - The progress callback, which is a callback that reports the progress of the file upload. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error. It must be a Javascript object that implements the bindings.FtSentProgressCallback interface.
  • args[2] - Progress callback period. A progress callback will be limited from triggering only once per period, in milliseconds (int).

Returns a promise:

  • Resolves on success (void).
  • Rejected with an error if registering the callback fails.

func (*ChannelsFileTransfer) RetryUpload added in v0.3.3

func (cft *ChannelsFileTransfer) RetryUpload(_ js.Value, args []js.Value) any

RetryUpload retries uploading a failed file upload. Returns an error if the transfer has not failed.

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

A new progress callback must be registered on retry. Any previously registered callbacks are defunct when the upload fails.

Parameters:

  • args[0] - Marshalled bytes of the file's fileTransfer.ID (Uint8Array).
  • args[1] - The progress callback, which is a callback that reports the progress of the file upload. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error. It must be a Javascript object that implements the bindings.FtSentProgressCallback interface.
  • args[2] - Progress callback period. A progress callback will be limited from triggering only once per period, in milliseconds (int).

Returns a promise:

  • Resolves on success (void).
  • Rejected with an error if registering retrying the upload fails.

func (*ChannelsFileTransfer) Send added in v0.3.3

func (cft *ChannelsFileTransfer) Send(_ js.Value, args []js.Value) any

Send sends the specified file info to the channel. Once a file is uploaded via ChannelsFileTransfer.Upload, its file info (found in the event model) can be sent to any channel.

Parameters:

Returns a promise:

func (*ChannelsFileTransfer) Upload added in v0.3.3

func (cft *ChannelsFileTransfer) Upload(_ js.Value, args []js.Value) any

Upload starts uploading the file to a new ID that can be sent to the specified channel when complete. To get progress information about the upload, a bindings.FtSentProgressCallback must be registered. All errors returned on the callback are fatal and the user must take action to either ChannelsFileTransfer.RetryUpload or ChannelsFileTransfer.CloseSend.

The file is added to the event model at the returned file ID with the status channelsFileTransfer.Uploading. Once the upload is complete, the file link is added to the event model with the status channelsFileTransfer.Complete.

The bindings.FtSentProgressCallback only indicates the progress of the file upload, not the status of the file in the event model. You must rely on updates from the event model to know when it can be retrieved.

Parameters:

  • args[0] - File contents. Max size defined by ChannelsFileTransfer.MaxFileSize (Uint8Array).
  • args[1] - The number of sending retries allowed on send failure (e.g. a retry of 2.0 with 6 parts means 12 total possible sends) (float).
  • args[2] - The progress callback, which is a callback that reports the progress of the file upload. The callback is called once on initialization, on every progress update (or less if restricted by the period), or on fatal error. It must be a Javascript object that implements the bindings.FtSentProgressCallback interface.
  • args[3] - Progress callback period. A progress callback will be limited from triggering only once per period, in milliseconds (int).

Returns a promise:

  • Resolves to the marshalled bytes of fileTransfer.ID that uniquely identifies the file (Uint8Array).
  • Rejected with an error if initiating the upload 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) AreDMsEnabled added in v0.3.0

func (cm *ChannelsManager) AreDMsEnabled(_ js.Value, args []js.Value) any

AreDMsEnabled returns the status of direct messaging for a given channel.

Parameters:

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

Returns:

  • enabled (bool) - status of dms for passed in channel ID, true if enabled
  • Throws an error if unmarshalling the channel ID

func (*ChannelsManager) DeleteChannelAdminKey added in v0.3.0

func (cm *ChannelsManager) DeleteChannelAdminKey(_ js.Value, args []js.Value) any

DeleteChannelAdminKey deletes the private key for the given channel.

CAUTION: This will remove admin access. This cannot be undone. If the private key is deleted, it cannot be recovered and the channel can never have another admin.

Parameters:

  • args[0] - The marshalled bytes of the channel's id.ID (Uint8Array)

Returns:

  • Throws an error if the deletion fails.

func (*ChannelsManager) DeleteMessage added in v0.3.0

func (cm *ChannelsManager) DeleteMessage(_ js.Value, args []js.Value) any

DeleteMessage deletes the targeted message from user's view. Users may delete their own messages but only the channel admin can delete other user's messages. If the user is not an admin of the channel or if they are not the sender of the targetMessage, then the error channels.NotAnAdminErr is returned.

If undoAction is true, then the targeted message is un-deleted.

Clients will drop the deletion if they do not recognize the target message.

Parameters:

  • args[0] - Marshalled bytes of channel id.ID (Uint8Array).
  • args[1] - The marshalled [channel.MessageID] of the message you want to delete (Uint8Array).
  • args[2] - JSON of xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) DeleteNickname

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

DeleteNickname removes the nickname for a given channel. The name will revert back to the codename for this channel instead.

Parameters:

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

Returns:

  • Throws TypeError if deleting the nickname fails.

func (*ChannelsManager) DisableDirectMessages added in v0.3.0

func (cm *ChannelsManager) DisableDirectMessages(_ js.Value, args []js.Value) any

DisableDirectMessages removes the token for direct messaging for a given channel.

Parameters:

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

Returns:

  • Throws an error if saving the DM token fails

func (*ChannelsManager) EnableDirectMessages added in v0.3.0

func (cm *ChannelsManager) EnableDirectMessages(_ js.Value, args []js.Value) any

EnableDirectMessages enables the token for direct messaging for this channel.

Parameters:

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

Returns:

  • Throws an error if saving the DM token fails.

func (*ChannelsManager) ExportChannelAdminKey added in v0.3.0

func (cm *ChannelsManager) ExportChannelAdminKey(_ js.Value, args []js.Value) any

ExportChannelAdminKey gets the private key for the given channel ID, encrypts it with the provided encryptionPassword, and exports it into a portable format. Returns an error if the user is not an admin of the channel.

This key can be provided to other users in a channel to grant them admin access using ChannelsManager.ImportChannelAdminKey.

The private key is encrypted using a key generated from the password using Argon2. Each call to ExportChannelAdminKey produces a different encrypted packet regardless if the same password is used for the same channel. It cannot be determined which channel the payload is for nor that two payloads are for the same channel.

The passwords between each call are not related. They can be the same or different with no adverse impact on the security properties.

Parameters:

  • args[0] - Marshalled bytes of the channel's id.ID (Uint8Array).
  • args[1] - The password used to encrypt the private key (string). The passwords between each call are not related. They can be the same or different with no adverse impact on the security properties.

Returns:

  • Portable string of the channel private key encrypted with the password (Uint8Array).
  • Throws an error if the user is not an admin for the channel.

func (*ChannelsManager) ExportPrivateIdentity

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

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

Parameters:

  • password - The password used to encrypt the private identity (string).

Returns:

  • Encrypted portable private identity (Uint8Array).
  • Throws TypeError if exporting the identity fails.

func (*ChannelsManager) GenerateChannel added in v0.3.0

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

GenerateChannel creates a new channel with the user as the admin and returns the pretty print of the channel. This function only create a channel and does not join it.

The private key is saved to storage and can be accessed with ChannelsManager.ExportChannelAdminKey.

Parameters:

  • args[0] - 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[1] - 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[2] - The broadcast.PrivacyLevel of the channel (int). 0 = public, 1 = private, and 2 = secret. Refer to the comment below for more information.

Returns a promise:

  • Resolves to the pretty print of the channel (string).
  • Rejected with an error 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 (*ChannelsManager) GetChannels

func (cm *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 an error if getting the channels fails.

JSON Example:

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

func (*ChannelsManager) GetID

func (cm *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 (cm *ChannelsManager) GetIdentity(js.Value, []js.Value) any

GetIdentity returns the public identity ([channel.Identity]) of the user associated with this channel manager.

Returns:

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

func (*ChannelsManager) GetMutedUsers added in v0.3.0

func (cm *ChannelsManager) GetMutedUsers(_ js.Value, args []js.Value) any

GetMutedUsers returns the list of the public keys for each muted user in the channel. If there are no muted user or if the channel does not exist, an empty list is returned.

Parameters:

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

Returns:

  • JSON of an array of ed25519.PublicKey (Uint8Array). Look below for an example.
  • Throws an error if the channel ID cannot be unmarshalled.

Example return:

["k2IrybDXjJtqxjS6Tx/6m3bXvT/4zFYOJnACNWTvESE=","ocELv7KyeCskLz4cm0klLWhmFLYvQL2FMDco79GTXYw=","mmxoDgoTEYwaRyEzq5Npa24IIs+3B5LXhll/8K5yCv0="]

func (*ChannelsManager) GetNickname

func (cm *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 set for the channel (string).
  • Throws TypeError if the channel has no nickname set.

func (*ChannelsManager) GetNotificationLevel added in v0.3.4

func (cm *ChannelsManager) GetNotificationLevel(_ js.Value, args []js.Value) any

GetNotificationLevel returns the channels.NotificationLevel for the given channel.

Parameters:

  • args[0] - The marshalled bytes of the channel's id.ID (Uint8Array).

Returns:

  • The channels.NotificationLevel for the channel (int).
  • Throws an error if the channel ID cannot be unmarshalled or the channel cannot be found.

func (*ChannelsManager) GetNotificationStatus added in v0.3.4

func (cm *ChannelsManager) GetNotificationStatus(_ js.Value, args []js.Value) any

GetNotificationStatus returns the notification status for the given channel.

Parameters:

  • args[0] - The marshalled bytes of the channel's id.ID (Uint8Array).

Returns:

  • The [notifications.NotificationState] for the channel (int).
  • Throws an error if the channel ID cannot be unmarshalled or the channel cannot be found.

func (*ChannelsManager) GetShareURL

func (cm *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, it will be verified when calling DecodePublicURL and 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 an error if generating the URL fails.

func (*ChannelsManager) GetStorageTag

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

GetStorageTag returns the tag where this manager is stored. To be used when loading the manager. The storage tag is derived from the public key.

Returns:

  • Storage tag (string).

func (*ChannelsManager) ImportChannelAdminKey added in v0.3.0

func (cm *ChannelsManager) ImportChannelAdminKey(_ js.Value, args []js.Value) any

ImportChannelAdminKey decrypts and imports the given encrypted private key and grants the user admin access to the channel the private key belongs to. Returns an error if the private key cannot be decrypted or if the private key is for the wrong channel.

Parameters:

  • args[0] - Marshalled bytes of the channel's id.ID (Uint8Array).
  • args[1] - The password used to encrypt the private key (string)
  • args[2] - The encrypted channel private key packet (Uint8Array).

Returns:

func (*ChannelsManager) IsChannelAdmin added in v0.3.0

func (cm *ChannelsManager) IsChannelAdmin(_ js.Value, args []js.Value) any

IsChannelAdmin returns true if the user is an admin of the channel.

Parameters:

  • args[0] - The marshalled bytes of the channel's id.ID (Uint8Array)

Returns:

  • True if the user is an admin in the channel and false otherwise (boolean).
  • Throws an error if the channel ID cannot be unmarshalled.

func (*ChannelsManager) JoinChannel

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

JoinChannel joins the given channel. It will return the error channels.ChannelAlreadyExistsErr if the channel has already been joined.

Parameters:

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 a promise:

  • Resolves to the JSON of bindings.ChannelInfo, which describes all relevant channel information (Uint8Array).
  • Rejected with an error if joining the channel fails.

func (*ChannelsManager) LeaveChannel

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

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

Parameters:

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

Returns a promise:

  • Resolves on success (void).
  • Rejected with an error if the channel does not exist.

func (*ChannelsManager) MuteUser added in v0.3.0

func (cm *ChannelsManager) MuteUser(_ js.Value, args []js.Value) any

MuteUser is used to mute a user in a channel. Muting a user will cause all future messages from the user being dropped on reception. Muted users are also unable to send messages. Only the channel admin can mute a user; if the user is not an admin of the channel, then the error channels.NotAnAdminErr is returned.

If undoAction is true, then the targeted user will be unmuted.

Parameters:

  • args[0] - Marshalled bytes of channel id.ID (Uint8Array).
  • args[1] - The ed25519.PublicKey of the user you want to mute (Uint8Array).
  • args[2] - Set to true to unmute the message (boolean).
  • args[3] - The time, in milliseconds, that the user should be muted (int). To remain muted indefinitely, use ValidForever.
  • args[4] - JSON of xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) Muted added in v0.3.0

func (cm *ChannelsManager) Muted(_ js.Value, args []js.Value) any

Muted returns true if the user is currently muted in the given channel.

Parameters:

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

Returns:

  • Returns true if the user is muted in the channel and false otherwise (boolean).
  • Throws an error if the channel ID cannot be unmarshalled.

func (*ChannelsManager) PinMessage added in v0.3.0

func (cm *ChannelsManager) PinMessage(_ js.Value, args []js.Value) any

PinMessage pins the target message to the top of a channel view for all users in the specified channel. Only the channel admin can pin user messages; if the user is not an admin of the channel, then the error channels.NotAnAdminErr is returned.

If undoAction is true, then the targeted message is unpinned.

Clients will drop the pin if they do not recognize the target message.

Parameters:

  • args[0] - Marshalled bytes of channel id.ID (Uint8Array).
  • args[1] - The marshalled [channel.MessageID] of the message you want to pin (Uint8Array).
  • args[2] - Set to true to unpin the message (boolean).
  • args[3] - The time, in milliseconds, that the message should be pinned (int). To remain pinned indefinitely, use ValidForever.
  • args[4] - JSON of xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) RegisterReceiveHandler

func (cm *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.
  • args[2] - A name describing what type of messages the listener picks up. This is used for debugging and logging (string).
  • args[3] - Set to true if this listener can receive messages from normal users (boolean).
  • args[4] - Set to true if this listener can receive messages from admins (boolean).
  • args[5] - Set to true if this listener can receive messages from muted users (boolean).

Returns:

  • Throws an error if registering the handler fails.

func (*ChannelsManager) ReplayChannel

func (cm *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.

Returns the error channels.ChannelDoesNotExistsErr if the channel was not previously joined.

Parameters:

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

Returns:

  • Throws an error if the replay fails.

func (*ChannelsManager) SendAdminGeneric

func (cm *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.

If the user is not an admin of the channel (i.e. does not have a private key for the channel saved to storage), then the error channels.NotAnAdminErr is returned.

Parameters:

  • 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). The message should be at most 510 bytes.
  • args[3] - The lease of the message. This will be how long the message is available from the network, in milliseconds (int). As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here. Use ValidForever to last the max message life.
  • args[4] - Set tracked to true if the message should be tracked in the sendTracker, which allows messages to be shown locally before they are received on the network. In general, all messages that will be displayed to the user should be tracked while all actions should not be (boolean).
  • args[5] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SendGeneric

func (cm *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 that defines the wire protocol.

If the final message, before being sent over the wire, is too long, this will return an error. Due to the underlying encoding using compression, it is not possible to define the largest payload that can be sent, but it will always be possible to send a payload of 802 bytes at minimum.

Parameters:

  • 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 available from the network, in milliseconds (int). As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here. Use ValidForever to last the max message life.
  • args[4] - Set tracked to true if the message should be tracked in the sendTracker, which allows messages to be shown locally before they are received on the network. In general, all messages that will be displayed to the user should be tracked while all actions should not be (boolean).
  • args[5] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).
  • args[6] - JSON of a map of slices of ed25519.PublicKey of users that should receive mobile notifications for the message. Each slice keys on a channels.PingType that describes the type of notification it is (Uint8Array).

Example map of slices of public keys:

{
  "usrMention": [
    "CLdKxbe8D2WVOpx1mT63TZ5CP/nesmxHLT5DUUalpe0=",
    "S2c6NXjNqgR11SCOaiQUughWaLpWBKNufPt6cbTVHMA="
  ],
  "usrReply": [
    "aaMzSeA6Cu2Aix2MlOwzrAI+NnpKshzvZRT02PZPVec="
  ]
}

Returns a promise:

func (*ChannelsManager) SendInvite added in v0.3.4

func (cm *ChannelsManager) SendInvite(_ js.Value, args []js.Value) any

SendInvite is used to send to a channel (invited) an invitation to another channel (invitee).

If the channel ID for the invitee channel is not recognized by the Manager, then an error will be returned.

Parameters:

  • args[0] - Marshalled bytes of the invited channel id.ID (Uint8Array).
  • args[1] - JSON of the invitee channel id.ID. This can be retrieved from GetChannelJSON. (Uint8Array).
  • args[2] - The contents of the message (string).
  • args[3] - The URL to append the channel info to (string).
  • args[4] - The lease of the message. This will be how long the message is available from the network, in milliseconds (int). As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here. Use ValidForever to last the max message life.
  • args[5] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).
  • args[6] - JSON of a slice of public keys of users that should receive mobile notifications for the message.

Example slice of public keys:

[
  "FgJMvgSsY4rrKkS/jSe+vFOJOs5qSSyOUSW7UtF9/KU=",
  "fPqcHtrJ398PAC35QyWXEU9PHzz8Z4BKQTCxSvpSygw=",
  "JnjCgh7g/+hNiI9VPKW01aRSxGOFmNulNCymy3ImXAo="
]

Returns a promise:

func (*ChannelsManager) SendMessage

func (cm *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 available from the network, in milliseconds (int). As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here. Use ValidForever to last the max message life.
  • args[3] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).
  • args[4] - JSON of a slice of public keys of users that should receive mobile notifications for the message.

Example slice of public keys:

[
  "FgJMvgSsY4rrKkS/jSe+vFOJOs5qSSyOUSW7UtF9/KU=",
  "fPqcHtrJ398PAC35QyWXEU9PHzz8Z4BKQTCxSvpSygw=",
  "JnjCgh7g/+hNiI9VPKW01aRSxGOFmNulNCymy3ImXAo="
]

Returns a promise:

func (*ChannelsManager) SendReaction

func (cm *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.

Clients 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] - The lease of the message. This will be how long the message is available from the network, in milliseconds (int). As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here. Use ValidForever to last the max message life.
  • args[4] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SendReply

func (cm *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 is not possible to define the largest payload that can be sent, but it will always be possible to send a payload of 766 bytes at minimum.

If the message ID that the reply is sent to does not exist, then the other side will post the message as a normal message and not as a reply.

Parameters:

  • 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 available from the network, in milliseconds (int). As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here. Use ValidForever to last the max message life.
  • args[4] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).
  • args[5] - JSON of a slice of public keys of users that should receive mobile notifications for the message.

Example slice of public keys:

[
  "FgJMvgSsY4rrKkS/jSe+vFOJOs5qSSyOUSW7UtF9/KU=",
  "fPqcHtrJ398PAC35QyWXEU9PHzz8Z4BKQTCxSvpSygw=",
  "JnjCgh7g/+hNiI9VPKW01aRSxGOFmNulNCymy3ImXAo="
]

Returns a promise:

func (*ChannelsManager) SendSilent added in v0.3.4

func (cm *ChannelsManager) SendSilent(_ js.Value, args []js.Value) any

SendSilent is used to send to a channel a message with no notifications. Its primary purpose is to communicate new nicknames without calling [SendMessage].

It takes no payload intentionally as the message should be very lightweight.

Parameters:

  • args[0] - Marshalled bytes of the channel id.ID (Uint8Array).
  • args[1] - The lease of the message. This will be how long the message is available from the network, in milliseconds (int). As per the channels.Manager documentation, this has different meanings depending on the use case. These use cases may be generic enough that they will not be enumerated here. Use ValidForever to last the max message life.
  • args[2] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*ChannelsManager) SetMobileNotificationsLevel added in v0.3.4

func (cm *ChannelsManager) SetMobileNotificationsLevel(_ js.Value,
	args []js.Value) any

SetMobileNotificationsLevel sets the notification level for the given channel. The channels.NotificationLevel dictates the type of notifications received and the status controls weather the notification is push or in-app. If muted, both the level and status must be set to mute.

To use push notifications, a token must be registered with the notification manager. Note, when enabling push notifications, information may be shared with third parties (i.e., Firebase and Google's Palantir) and may represent a security risk to the user.

Parameters:

  • args[0] - The marshalled bytes of the channel's id.ID (Uint8Array).
  • args[1] - The channels.NotificationLevel to set for the channel (int).
  • args[2] - The [notifications.NotificationState] to set for the channel (int).

Returns a promise and throws an error if setting the notification level fails.

func (*ChannelsManager) SetNickname

func (cm *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.

func (*ChannelsManager) VerifyChannelAdminKey added in v0.3.0

func (cm *ChannelsManager) VerifyChannelAdminKey(_ js.Value, args []js.Value) any

VerifyChannelAdminKey verifies that the encrypted private key can be decrypted and that it matches the expected channel. Returns false if private key does not belong to the given channel.

Parameters:

  • args[0] - Marshalled bytes of the channel's id.ID (Uint8Array).
  • args[1] - The password used to encrypt the private key (string)
  • args[2] - The encrypted channel private key packet (Uint8Array).

Returns:

  • Returns false if private key does not belong to the given channel ID (boolean).
  • Throws an error if the password is invalid.

Returns:

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) EKVGet added in v0.3.4

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

EKVGet allows access to a value inside the secure encrypted key value store.

Parameters:

  • args[0] - Key (string).

Returns a promise:

  • Resolves to the value (Uint8Array)
  • Rejected with an error if accessing the KV fails.

func (*Cmix) EKVSet added in v0.3.4

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

EKVSet sets a value inside the secure encrypted key value store.

Parameters:

  • args[0] - Key (string).
  • args[1] - Value (Uint8Array).

Returns a promise:

  • Resolves on a successful save (void).
  • Rejected with an error if saving 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) GetReceptionID added in v0.3.4

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

GetReceptionID returns the default reception identity for this cMix instance.

Returns:

  • Marshalled bytes of id.ID (Uint8Array).

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) GetRemoteKV added in v0.3.4

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

GetRemoteKV returns the cMix RemoteKV

Returns a promise:

  • Resolves with the RemoteKV object.

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) SetTrackNetworkPeriod added in v0.3.0

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

SetTrackNetworkPeriod allows changing the frequency that follower threads are started.

Note that the frequency of the follower threads affect the power usage of the device following the network.

  • Low period -> Higher frequency of polling -> Higher battery usage
  • High period -> Lower frequency of polling -> Lower battery usage

This may be used to enable a low power (or battery optimization) mode for the end user.

Suggested values are provided, however there are no guarantees that these values will perfectly fit what the end user's device would require to match the user's expectations:

Parameters:

  • args[0] - The duration of the period, in milliseconds (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 an error 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 an error 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:

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 an error 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 an error 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 an error 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.

Parameters:

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

Returns a promise:

type DMClient added in v0.3.0

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

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

func (*DMClient) BlockPartner added in v0.3.4

func (dmc *DMClient) BlockPartner(_ js.Value, args []js.Value) any

BlockPartner prevents receiving messages and notifications from the partner.

Parameters:

Returns a promise that exits upon completion.

func (*DMClient) DeleteMessage added in v0.3.4

func (dmc *DMClient) DeleteMessage(_ js.Value, args []js.Value) any

DeleteMessage sends a message to the partner to delete a message this user sent. Also deletes it from the local database.

Parameters:

  • args[0] - The bytes of the public key of the partner's ED25519 signing key (Uint8Array).
  • args[1] - The token used to derive the reception ID for the partner (int).
  • args[2] -The bytes of the message.ID of the message to delete. This may be found in the bindings.ChannelSendReport (Uint8Array).
  • args[3] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*DMClient) ExportPrivateIdentity added in v0.3.0

func (dmc *DMClient) 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:

  • Encrypted private identity bytes (Uint8Array).
  • Throws TypeError if exporting the identity fails.

func (*DMClient) GetBlockedPartners added in v0.3.4

func (dmc *DMClient) GetBlockedPartners(js.Value, []js.Value) any

GetBlockedPartners returns all partners who are blocked by this user.

Returns:

Example return:

[
  "TYWuCfyGBjNWDtl/Roa6f/o206yYPpuB6sX2kJZTe98=",
  "4JLRzgtW1SZ9c5pE+v0WwrGPj1t19AuU6Gg5IND5ymA=",
  "CWDqF1bnhulW2pko+zgmbDZNaKkmNtFdUgY4bTm2DhA="
]

func (*DMClient) GetDatabaseName added in v0.3.0

func (dmc *DMClient) GetDatabaseName(js.Value, []js.Value) any

GetDatabaseName returns the storage tag, so users listening to the database can separately listen and read updates there.

Returns:

  • The storage tag (string).

func (*DMClient) GetID added in v0.3.0

func (dmc *DMClient) GetID(js.Value, []js.Value) any

GetID returns the ECDH Public Key for this DMClient in the DMClient tracker.

Returns:

  • Tracker ID (int).

func (*DMClient) GetIdentity added in v0.3.0

func (dmc *DMClient) GetIdentity(js.Value, []js.Value) any

GetIdentity returns the public identity associated with this client.

Returns:

func (*DMClient) GetNickname added in v0.3.0

func (dmc *DMClient) GetNickname(_ js.Value, _ []js.Value) any

GetNickname gets the nickname associated with this DM user. Throws an error if no nickname is set.

Returns:

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

func (*DMClient) GetNotificationLevel added in v0.3.4

func (dmc *DMClient) GetNotificationLevel(_ js.Value, args []js.Value) any

GetNotificationLevel gets the notification level for a given DM partner's public key

Parameters:

Returns:

Returns a promise:

  • Resolves to the dm.NotificationLevel of the DM conversation (int).
  • Rejected with an error if getting the notification level fails.

func (*DMClient) GetPublicKey added in v0.3.0

func (dmc *DMClient) GetPublicKey(js.Value, []js.Value) any

GetPublicKey returns the bytes of the public key for this client.

Returns:

  • Public key (Uint8Array).

func (*DMClient) GetShareURL added in v0.3.3

func (dmc *DMClient) GetShareURL(_ js.Value, args []js.Value) any

GetShareURL generates a URL that can be used to share a URL to initiate d direct messages with this user.

Parameters:

  • args[0] - The URL to append the DM info to (string).

Returns:

  • JSON of DMShareURL (Uint8Array).
  • Throws an exception on error.

func (*DMClient) GetToken added in v0.3.0

func (dmc *DMClient) GetToken(js.Value, []js.Value) any

GetToken returns the DM token of this client.

func (*DMClient) IsBlocked added in v0.3.3

func (dmc *DMClient) IsBlocked(_ js.Value, args []js.Value) any

IsBlocked indicates if the given partner is blocked.

Parameters:

Returns:

  • boolean

func (*DMClient) Send added in v0.3.0

func (dmc *DMClient) Send(_ js.Value, args []js.Value) any

Send is used to send a raw message. In general, it should be wrapped in a function that defines the wire protocol.

If the final message, before being sent over the wire, is too long, this will return an error. Due to the underlying encoding using compression, it is not possible to define the largest payload that can be sent, but it will always be possible to send a payload of 802 bytes at minimum.

The meaning of leaseTimeMS depends on the use case.

Parameters:

Returns a promise:

func (*DMClient) SendInvite added in v0.3.4

func (dmc *DMClient) SendInvite(_ js.Value, args []js.Value) any

SendInvite is used to send to a DM partner an invitation to another channel.

If the channel ID for the invitee channel is not recognized by the Manager, then an error will be returned.

Parameters:

  • args[0] - The bytes of the public key of the partner's ED25519 signing key (Uint8Array).
  • args[1] - The token used to derive the reception ID for the partner (int).
  • args[2] - JSON of the invitee channel id.ID. This can be retrieved from GetChannelJSON. (Uint8Array).
  • args[3] - 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.
  • args[4] - The URL to append the channel info to.
  • args[5] - A JSON marshalled xxdk.CMIXParams. This may be empty, and GetDefaultCMixParams will be used internally.

Returns a promise:

func (*DMClient) SendReaction added in v0.3.0

func (dmc *DMClient) 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:

Returns a promise:

func (*DMClient) SendReply added in v0.3.0

func (dmc *DMClient) SendReply(_ js.Value, args []js.Value) any

SendReply is used to send a formatted direct message reply.

If the message ID that the reply is sent to does not exist, then the other side will post the message as a normal message and not as a reply.

The message will auto delete leaseTime after the round it is sent in, lasting forever if bindings.ValidForever is used.

Parameters:

  • args[0] - The bytes of the public key of the partner's ED25519 signing key (Uint8Array).
  • args[1] - The token used to derive the reception ID for the partner (int).
  • args[2] - The contents of the reply message. The message should be at most 510 bytes. This is expected to be Unicode, and thus a string data type is expected (string).
  • args[3] - The bytes of the message.ID 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 ChannelsManager.RegisterReceiveHandler (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, then GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*DMClient) SendSilent added in v0.3.4

func (dmc *DMClient) SendSilent(_ js.Value, args []js.Value) any

SendSilent is used to send to a channel a message with no notifications. Its primary purpose is to communicate new nicknames without calling [Send].

It takes no payload intentionally as the message should be very lightweight.

Parameters:

  • args[0] - The bytes of the public key of the partner's ED25519 signing key (Uint8Array).
  • args[1] - The token used to derive the reception ID for the partner (int).
  • args[2] - JSON of xxdk.CMIXParams. If left empty bindings.GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*DMClient) SendText added in v0.3.0

func (dmc *DMClient) SendText(_ js.Value, args []js.Value) any

SendText is used to send a formatted direct message to a user.

Parameters:

  • args[0] - The bytes of the public key of the partner's ED25519 signing key (Uint8Array).
  • args[1] - The token used to derive the reception ID for the partner (int).
  • args[2] - 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[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[3] - JSON of [xxdk.CMIXParams.] If left empty, then GetDefaultCMixParams will be used internally (Uint8Array).

Returns a promise:

func (*DMClient) SetMobileNotificationsLevel added in v0.3.4

func (dmc *DMClient) SetMobileNotificationsLevel(_ js.Value,
	args []js.Value) any

SetMobileNotificationsLevel sets the notification level for the given DM conversation partner.

Parameters:

Returns a promise:

  • Resolves on success.
  • Rejected with an error if setting the notification level fails.

func (*DMClient) SetNickname added in v0.3.0

func (dmc *DMClient) SetNickname(_ js.Value, args []js.Value) any

SetNickname sets the nickname to use for this user.

Parameters:

  • args[0] - The nickname to set (string).

Returns:

  • Throws an error if setting the nickname fails.

func (*DMClient) UnblockPartner added in v0.3.4

func (dmc *DMClient) UnblockPartner(_ js.Value, args []js.Value) any

UnblockPartner unblocks a blocked partner to allow DM messages.

Parameters:

type DMShareURL added in v0.3.3

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

DMShareURL is returned from DMClient.GetShareURL. It includes the user's share URL.

JSON example for a user:

{
 "url": "https://internet.speakeasy.tech/?l=32&m=5&p=EfDzQDa4fQ5BoqNIMbECFDY9ckRr_fadd8F1jE49qJc%3D&t=4231817746&v=1",
 "password": "hunter2",
}

type DMUser added in v0.3.3

type DMUser struct {
	Token     int32  `json:"token"`
	PublicKey []byte `json:"publicKey"`
}

DMUser is returned from DecodeDMShareURL. It includes the token and public key of the user who created the URL.

JSON example for a user:

{
 "token": 4231817746,
 "publicKey": "EfDzQDa4fQ5BoqNIMbECFDY9ckRr/fadd8F1jE49qJc="
}

type DbCipher added in v0.3.4

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

DbCipher wraps the indexedDb.Cipher object so its methods can be wrapped to be Javascript compatible.

func (*DbCipher) Decrypt added in v0.3.4

func (c *DbCipher) 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 an error if it fails to encrypt the plaintext.

func (*DbCipher) Encrypt added in v0.3.4

func (c *DbCipher) 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 NewDatabaseCipher. If it is larger, this will return an error.

Returns:

  • The ciphertext of the plaintext passed in (String).
  • Throws an error if it fails to encrypt the plaintext.

func (*DbCipher) GetID added in v0.3.4

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

GetID returns the ID for this DbCipher in the DbCipherTracker.

Returns:

  • Tracker ID (int).

func (*DbCipher) MarshalJSON added in v0.3.4

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

MarshalJSON marshals the cipher into valid JSON.

Returns:

  • JSON of the cipher (Uint8Array).
  • Throws an error if marshalling fails.

func (*DbCipher) UnmarshalJSON added in v0.3.4

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

UnmarshalJSON unmarshalls JSON into the cipher.

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

Parameters:

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

Returns:

  • JSON of the cipher (Uint8Array).
  • Throws an error if marshalling fails.

type DbCipherTracker added in v0.3.4

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

DbCipherTracker is a singleton used to keep track of extant DbCipher objects, preventing race conditions created by passing it over the bindings.

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 the status returned here may lag behind a user's earlier call to pause the sending thread. This is a result of a small delay (see DummyTraffic.Pause for more details)

Returns:

  • Returns true ([dummy.Running]) if the sending thread is sending messages and false ([dummy.Paused]) if the sending thread is not sending messages.

func (*DummyTraffic) Pause added in v0.3.0

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

Pause will pause the DummyTraffic's sending thread, meaning messages will no longer be sent. After calling Pause, the sending thread may only be resumed by calling Resume.

There may be a small delay between this call and the pause taking effect. This is because Pause will not cancel the thread when it is in the process of sending messages, but will instead wait for that thread to complete. The thread will then be prevented from beginning another round of sending.

Returns:

  • Throws an error if it fails to send a pause signal to the sending thread.

func (*DummyTraffic) Start added in v0.3.0

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

Start will start up the DummyTraffic's sending thread, meaning messages will be sent. This should be called after calling NewDummyTrafficManager, by default the thread is paused. This may also be called after a call to DummyTraffic.Pause.

This will re-initialize the sending thread with a new randomly generated interval between sending dummy messages. This means that there is zero guarantee that the sending interval prior to pausing will be the same sending interval after a call to Start.

Returns:

  • Throws an error if it fails to send a start signal to the sending thread.

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 an error 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 an error 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 an error 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 an error 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 an error 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:

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 an error 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 an error 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 an error 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 an error 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 KeyChangedByRemoteCallback added in v0.3.4

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

KeyChangedByRemoteCallback wraps the passed javascript function and implements bindings.KeyChangedByRemoteCallback

func (*KeyChangedByRemoteCallback) Callback added in v0.3.4

func (k *KeyChangedByRemoteCallback) Callback(key string, old, new []byte,
	opType int8)

type MapChangedByRemoteCallback added in v0.3.4

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

MapChangedByRemoteCallback wraps the passed javascript function and implements bindings.KeyChangedByRemoteCallback

func (*MapChangedByRemoteCallback) Callback added in v0.3.4

func (m *MapChangedByRemoteCallback) Callback(mapName string,
	editsJSON []byte)

type MessageAndError added in v0.3.0

type MessageAndError struct {
	// MessageJSON should contain the JSON of channels.ModelMessage.
	ModelMessage channels.ModelMessage

	// Error should only be filled when an error occurs on message lookup.
	Error string
}

MessageAndError contains a message returned by eventModel.GetMessage or any possible error that occurs during lookup. Only one field should be present at a time; if an error occurs, ModelMessage should be empty.

Example JSON:

{
  "ModelMessage": {
    "UUID": 50,
    "Nickname": "Nickname",
    "MessageID": "ODg5goFIBvpvqPzuoYGqmvxFYBgj0MMiQxAB51Q2nPs=",
    "ChannelID": "R+xKJTH6m4YRS4f0JggK3fTu10sANmtahS0Qtc8yi/AD",
    "ParentMessageID": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
    "Timestamp": "1955-11-05T12:01:00-07:00",
    "Lease": 21600000000000,
    "Status": 2,
    "Hidden": false,
    "Pinned": false,
    "Content": "VGhpcyBpcyBzb21lIG1lc3NhZ2UgY29udGVudC4=",
    "Type": 1,
    "Round": 7,
    "PubKey": "QyTtpndOf3sDZehVpOBQzQNBe1R2Eae7qlAEDZJ2mLg=",
    "CodesetVersion": 0
  },
  "Error": ""
}

type Notifications added in v0.3.4

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

func (*Notifications) AddToken added in v0.3.4

func (n *Notifications) AddToken(_ js.Value, args []js.Value) any

AddToken implements bindings.Notifications.AddToken.

Parameters:

  • args[0] - newToken string
  • args[1] - app string

Returns nothing or an error (throwable)

func (*Notifications) GetID added in v0.3.4

func (n *Notifications) GetID(js.Value, []js.Value) any

GetID returns the bindings ID for the bindings.Notifications object

func (*Notifications) GetMaxState added in v0.3.4

func (n *Notifications) GetMaxState(_ js.Value, args []js.Value) any

GetMaxState implements bindings.Notifications.GetMaxState

Returns the current maxState integer

func (*Notifications) RemoveToken added in v0.3.4

func (n *Notifications) RemoveToken(_ js.Value, args []js.Value) any

RemoveToken implements bindings.Notifications.RemoveToken.

Returns nothing or throws an error.

func (*Notifications) SetMaxState added in v0.3.4

func (n *Notifications) SetMaxState(_ js.Value, args []js.Value) any

SetMaxState implements bindings.Notifications.SetMaxState

Parameters:

  • args[0] - maxState integer

Returns nothing or throws an error

type RemoteKV added in v0.3.4

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

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

func (*RemoteKV) Delete added in v0.3.4

func (r *RemoteKV) Delete(_ js.Value, args []js.Value) any

Delete removes a given key from the data store.

Parameters:

  • args[0] - key to access, a string
  • args[1] - version, an integer

Returns a promise:

  • Rejected with an access error. Note: File does not exist errors are returned whent key is not set.

func (*RemoteKV) DeleteMapElement added in v0.3.4

func (r *RemoteKV) DeleteMapElement(_ js.Value, args []js.Value) any

DeleteMapElement removes a versioned map element from the KV.

Parameters:

  • args[0] - the mapName string
  • args[1] - the elementKey string
  • args[2] - the version int

Returns a promise with an error if any or the json of the deleted [versioned.Object], e.g.:

{"Version":1,"Timestamp":"2023-05-13T00:50:03.889192694Z",
"Data":"bm90IHVwZ3JhZGVk"}

func (*RemoteKV) DeleteRemoteKeyListener added in v0.3.4

func (r *RemoteKV) DeleteRemoteKeyListener(_ js.Value, args []js.Value) any

DeleteRemoteKeyListener deletes a specific listener for a key.

Parameters:

  • args[0] - the key to delete for
  • args[1] - the id of the listener

func (*RemoteKV) DeleteRemoteMapListener added in v0.3.4

func (r *RemoteKV) DeleteRemoteMapListener(_ js.Value, args []js.Value) any

DeleteRemoteMapListener deletes a specific listener for a key.

Parameters:

  • args[0] - the mapName to delete for
  • args[1] - the id of the listener

func (*RemoteKV) Get added in v0.3.4

func (r *RemoteKV) Get(_ js.Value, args []js.Value) any

Get returns the object stored at the specified version. returns a json of [versioned.Object].

Parameters:

  • args[0] - key to access, a string
  • args[1] - version, an integer

Returns a promise:

  • Resolves to JSON of a [versioned.Object], e.g.: {"Version":1,"Timestamp":"2023-05-13T00:50:03.889192694Z","Data":"bm90IHVwZ3JhZGVk"}
  • Rejected with an access error. Note: File does not exist errors are returned whent key is not set.

func (*RemoteKV) GetAllRemoteKeyListeners added in v0.3.4

func (r *RemoteKV) GetAllRemoteKeyListeners(_ js.Value, args []js.Value) any

GetAllRemoteKeyListeners returns a JSON list of { key: [id, id, id, ...] }, where key is the key for the listener and the list is an list of integer ids of each listener.

func (*RemoteKV) GetAllRemoteMapListeners added in v0.3.4

func (r *RemoteKV) GetAllRemoteMapListeners(_ js.Value, args []js.Value) any

GetAllRemoteMapListeners returns a JSON list of { key: [id, id, id, ...] }, where key is the key for the listener and the list is an list of integer ids of each listener.

func (*RemoteKV) GetFullKey added in v0.3.4

func (r *RemoteKV) GetFullKey(_ js.Value, args []js.Value) any

GetFullKey returns the key with all prefixes appended

func (*RemoteKV) GetMap added in v0.3.4

func (r *RemoteKV) GetMap(_ js.Value, args []js.Value) any

GetMap loads a versioned map from the KV. This relies on the underlying remote [KV.GetMap] function to lock and control updates, but it uses [versioned.Object] values.

Parameters:

  • args[0] - the mapName string
  • args[1] - the version int

Returns a promise with an error if any or the the [map[string]versioned.Object] JSON value, e.g.:

{"elementKey": {"Version":1,"Timestamp":"2023-05-13T00:50:03.889192694Z",
"Data":"bm90IHVwZ3JhZGVk"}}

func (*RemoteKV) GetMapElement added in v0.3.4

func (r *RemoteKV) GetMapElement(_ js.Value, args []js.Value) any

GetMapElement loads a versioned map element from the KV. This relies on the underlying remote [KV.GetMapElement] function to lock and control updates, but it uses [versioned.Object] values. Parameters:

  • args[0] - the mapName string
  • args[1] - the elementKey string
  • args[2] - the version int

Returns a promise with an error if any or the json of the [versioned.Object], e.g.:

{"Version":1,"Timestamp":"2023-05-13T00:50:03.889192694Z",
"Data":"bm90IHVwZ3JhZGVk"}

func (*RemoteKV) GetPrefix added in v0.3.4

func (r *RemoteKV) GetPrefix(js.Value, []js.Value) any

GetPrefix returns the full prefix of the KV.

Returns a promise:

  • Resolves to the prefix (string).

func (*RemoteKV) GetRemoteKeyListeners added in v0.3.4

func (r *RemoteKV) GetRemoteKeyListeners(_ js.Value, args []js.Value) any

GeRemoteKeyListeners returns a JSON list of [id, id, id, ...], where the list is an list of integer ids of each listener.

Parameters:

  • args[0] - the key to look at

func (*RemoteKV) GetRemoteMapListeners added in v0.3.4

func (r *RemoteKV) GetRemoteMapListeners(_ js.Value, args []js.Value) any

GeRemoteMapListeners returns a JSON list of [id, id, id, ...], where the list is an list of integer ids of each listener.

Parameters:

  • args[0] - the key to look at

func (*RemoteKV) HasPrefix added in v0.3.4

func (r *RemoteKV) HasPrefix(_ js.Value, args []js.Value) any

HasPrefix returns whether this prefix exists in the KV

Parameters:

  • args[0] - the prefix string to check for.

Returns a bool via a promise.

func (*RemoteKV) IsMemStore added in v0.3.4

func (r *RemoteKV) IsMemStore(js.Value, []js.Value) any

IsMemStore returns true if the underlying KV is memory based.

Returns a promise:

  • Resolves to a boolean.
  • Rejected with an error.

func (*RemoteKV) ListenOnRemoteKey added in v0.3.4

func (r *RemoteKV) ListenOnRemoteKey(_ js.Value, args []js.Value) any

ListenOnRemoteKey sets up a callback listener for the object specified by the key and version. It returns the ID of the callback or -1. The version and "localEvents" flags are only respected on first call.

Parameters:

  • args[0] - The key (string).
  • args[1] - The version (int).
  • args[2] - The KeyChangedByRemoteCallback Javascript callback.
  • args[3] - Toggle local events (optional) (boolean).

Returns a promise:

  • Resolves to the callback ID (int).
  • Rejects with an error on failure.

func (*RemoteKV) ListenOnRemoteMap added in v0.3.4

func (r *RemoteKV) ListenOnRemoteMap(_ js.Value, args []js.Value) any

ListenOnRemoteMap allows the caller to receive updates when the map or map elements are updated. It returns the ID of the callback or -1 and an error. The version and "localEvents" flags are only respected on first call.

Parameters:

  • args[0] - The key (string).
  • args[1] - The version (int).
  • args[2] - the MapChangedByRemoteCallback javascript callback
  • args[3] - Toggle local events (optional) (boolean).

Returns a promise:

  • Resolves to the callback ID (int).
  • Rejects with an error on failure.

func (*RemoteKV) Prefix added in v0.3.4

func (r *RemoteKV) Prefix(_ js.Value, args []js.Value) any

Prefix returns a new KV with the new prefix appending

Parameters:

  • args[0] - the prefix to append to the list of prefixes

Returns a promise:

  • Resolves to a new RemoteKV.
  • Rejected with an error.

func (*RemoteKV) Root added in v0.3.4

func (r *RemoteKV) Root(js.Value, []js.Value) any

Root returns the KV with no prefixes.

Returns a promise:

  • Resolves to a new RemoteKV.
  • Rejected with an error on failure.

func (*RemoteKV) Set added in v0.3.4

func (r *RemoteKV) Set(_ js.Value, args []js.Value) any

Set upserts new data into the storage When calling this, you are responsible for prefixing the key with the correct type optionally unique id! Call GetFullKey() to do so. The [Object] should contain the versioning if you are maintaining such a functionality.

Parameters:

  • args[0] - the key string
  • args[1] - the [versioned.Object] JSON value, e.g.: {"Version":1,"Timestamp":"2023-05-13T00:50:03.889192694Z", "Data":"bm90IHVwZ3JhZGVk"}

Returns a promise:

  • Rejected with an access error.

func (*RemoteKV) StoreMap added in v0.3.4

func (r *RemoteKV) StoreMap(_ js.Value, args []js.Value) any

StoreMap saves a versioned map element into the KV. This relies on the underlying remote [KV.StoreMap] function to lock and control updates, but it uses [versioned.Object] values. All Map storage functions update the remote. valueJSON is a json of map[string]*versioned.Object

Parameters:

  • args[0] - the mapName string
  • args[1] - the [map[string]versioned.Object] JSON value, e.g.: {"elementKey": {"Version":1,"Timestamp":"2023-05-13T00:50:03.889192694Z", "Data":"bm90IHVwZ3JhZGVk"}}
  • args[2] - the version int

Returns a promise with an error if any

func (*RemoteKV) StoreMapElement added in v0.3.4

func (r *RemoteKV) StoreMapElement(_ js.Value, args []js.Value) any

StoreMapElement stores a versioned map element into the KV. This relies on the underlying remote [KV.StoreMapElement] function to lock and control updates, but it uses [versioned.Object] values. All Map storage functions update the remote. valueJSON is a json of a versioned.Object

Parameters:

  • args[0] - the mapName string
  • args[1] - the elementKey string
  • args[2] - the [versioned.Object] JSON value, e.g.: {"Version":1,"Timestamp":"2023-05-13T00:50:03.889192694Z", "Data":"bm90IHVwZ3JhZGVk"}
  • args[3] - the version int

Returns a promise with an error if any

type RemoteStore added in v0.3.4

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

RemoteStore wraps Javascript callbacks to adhere to the bindings.RemoteStore interface.

func (*RemoteStore) GetLastModified added in v0.3.4

func (rsCB *RemoteStore) GetLastModified(path string) (string, error)

GetLastModified implements bindings.RemoteStore.GetLastModified

Parameters:

  • path - The file path (string).

Returns:

func (*RemoteStore) GetLastWrite added in v0.3.4

func (rsCB *RemoteStore) GetLastWrite() (string, error)

GetLastWrite implements [bindings.RemoteStore.GetLastWrite()

Returns:

func (*RemoteStore) Read added in v0.3.4

func (rsCB *RemoteStore) Read(path string) ([]byte, error)

Read impelements bindings.RemoteStore.Read

Parameters:

  • path - The file path to read from (string).

Returns:

  • The file data (Uint8Array).
  • Catches any thrown errors (of type Error) and returns it as an error.

func (*RemoteStore) ReadDir added in v0.3.4

func (rsCB *RemoteStore) ReadDir(path string) ([]byte, error)

ReadDir implements bindings.RemoteStore.ReadDir

Parameters:

  • path - The file path (string).

Returns:

  • JSON of []string (Uint8Array).
  • Catches any thrown errors (of type Error) and returns it as an error.

func (*RemoteStore) Write added in v0.3.4

func (rsCB *RemoteStore) Write(path string, data []byte) error

Write implements bindings.RemoteStore.Write

Parameters:

  • path - The file path to write to (string).
  • data - The file data to write (Uint8Array).

Returns:

  • Catches any thrown errors (of type Error) and returns it as an error.

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.

type UuidAndError added in v0.3.3

type UuidAndError struct {
	UUID  int64  `json:"uuid,omitempty"`
	Error string `json:"error,omitempty"`
}

UuidAndError contains a UUID returned by an eventModel method or any possible error that occurs. Only one field should be present at a time.

Example JSON:

{ "uuid": 5, }

Or:

{ "error": "An error occurred." }

type VersionInfo added in v0.3.0

type VersionInfo struct {
	Current string `json:"current"`
	Updated bool   `json:"updated"`
	Old     string `json:"old"`
}

VersionInfo contains information about the current and old version of the API.

Jump to

Keyboard shortcuts

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