diff --git a/utils/array.go b/utils/array.go index 3b7032377f252bc75d9da16fe8ce5b942b1615f3..5eda91f5d332c091cb6cd93397e21dd42d567b67 100644 --- a/utils/array.go +++ b/utils/array.go @@ -18,7 +18,7 @@ import ( // Uint8ArrayToBase64 encodes an uint8 array to a base 64 string. // // Parameters: -// - args[0] - uint8 array (Uint8Array) +// - args[0] - Javascript 8-bit unsigned integer array (Uint8Array). // // Returns: // - Base 64 encoded string (string). @@ -29,10 +29,10 @@ func Uint8ArrayToBase64(_ js.Value, args []js.Value) interface{} { // Base64ToUint8Array decodes a base 64 encoded string to a Uint8Array. // // Parameters: -// - args[0] - base 64 encoded string (string) +// - args[0] - Base 64 encoded string (string). // // Returns: -// - Decoded uint8 array (Uint8Array). +// - Javascript 8-bit unsigned integer array (Uint8Array). // - Throws TypeError if decoding the string fails. func Base64ToUint8Array(_ js.Value, args []js.Value) interface{} { b, err := base64ToUint8Array(args[0]) @@ -58,8 +58,8 @@ func base64ToUint8Array(base64String js.Value) (js.Value, error) { // otherwise. // // Parameters: -// - args[0] - array A (Uint8Array) -// - args[1] - array B (Uint8Array) +// - args[0] - Array A (Uint8Array). +// - args[1] - Array B (Uint8Array). // // Returns: // - If the two arrays are equal (boolean). diff --git a/utils/errors.go b/utils/errors.go index d8de2b0a1fd8c7c67def0ce17773c4e4ba11cca1..2e1cbacbce3b7c70a67f52e1217a76ef63f887b5 100644 --- a/utils/errors.go +++ b/utils/errors.go @@ -59,7 +59,6 @@ const ( // not exclusively) when a value is not of the expected type. // // A TypeError may be thrown when: - // // - an operand or argument passed to a function is incompatible with the // type expected by that operator or function; or // - when attempting to modify a value that cannot be changed; or diff --git a/wasm/authenticatedConnection.go b/wasm/authenticatedConnection.go index b8aae809d4318211ed8291c23323de681f5a7e11..8b2d03f263b1d60277ee5709d7437c6d5c4b5583 100644 --- a/wasm/authenticatedConnection.go +++ b/wasm/authenticatedConnection.go @@ -22,7 +22,8 @@ type AuthenticatedConnection struct { } // newAuthenticatedConnectionJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the AuthenticatedConnection structure. +// (map[string]interface{}) that matches the [AuthenticatedConnection] +// structure. func newAuthenticatedConnectionJS( api *bindings.AuthenticatedConnection) map[string]interface{} { ac := AuthenticatedConnection{api} @@ -41,7 +42,7 @@ func newAuthenticatedConnectionJS( // IsAuthenticated returns true. // // Returns: -// - true (boolean). +// - True (boolean). func (ac *AuthenticatedConnection) IsAuthenticated(js.Value, []js.Value) interface{} { return ac.api.IsAuthenticated() } @@ -50,21 +51,21 @@ func (ac *AuthenticatedConnection) IsAuthenticated(js.Value, []js.Value) interfa // authenticatedConnectionTracker. // // Returns: -// - int of the ID +// - Tracker ID (int). func (ac *AuthenticatedConnection) GetId(js.Value, []js.Value) interface{} { return ac.api.GetId() } // SendE2E is a wrapper for sending specifically to the -// AuthenticatedConnection's [partner.Manager]. +// [AuthenticatedConnection]'s [partner.Manager]. // // Parameters: -// - args[0] - message type from [catalog.MessageType] (int) -// - args[1] - message payload (Uint8Array) +// - args[0] - Message type from [catalog.MessageType] (int). +// - args[1] - Message payload (Uint8Array). // // Returns a promise: // - Resolves to the JSON of [bindings.E2ESendReport], which can be passed into -// cmix.WaitForRoundResult to see if the send succeeded (Uint8Array). +// [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // - Rejected with an error if sending fails. func (ac *AuthenticatedConnection) SendE2E(_ js.Value, args []js.Value) interface{} { payload := utils.CopyBytesToGo(args[2]) @@ -81,33 +82,33 @@ func (ac *AuthenticatedConnection) SendE2E(_ js.Value, args []js.Value) interfac return utils.CreatePromise(promiseFn) } -// Close deletes this AuthenticatedConnection's partner.Manager and releases +// Close deletes this [AuthenticatedConnection]'s [partner.Manager] and releases // resources. // // Returns: -// - throws a TypeError if closing fails +// - Throws a TypeError if closing fails. func (ac *AuthenticatedConnection) Close(js.Value, []js.Value) interface{} { return ac.api.Close() } -// GetPartner returns the partner.Manager for this AuthenticatedConnection. +// GetPartner returns the [partner.Manager] for this [AuthenticatedConnection]. // // Returns: -// - bytes of the partner's [id.ID] (Uint8Array) +// - Marshalled bytes of the partner's [id.ID] (Uint8Array). func (ac *AuthenticatedConnection) GetPartner(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(ac.api.GetPartner()) } // RegisterListener is used for E2E reception and allows for reading data sent -// from the partner.Manager. +// from the [partner.Manager]. // // Parameters: -// - args[0] - message type from [catalog.MessageType] (int) +// - args[0] - Message type from [catalog.MessageType] (int). // - args[1] - Javascript object that has functions that implement the -// [bindings.Listener] interface +// [bindings.Listener] interface. // // Returns: -// - throws a TypeError is registering the listener fails +// - Throws a TypeError is registering the listener fails. func (ac *AuthenticatedConnection) RegisterListener( _ js.Value, args []js.Value) interface{} { err := ac.api.RegisterListener(args[0].Int(), @@ -121,16 +122,17 @@ func (ac *AuthenticatedConnection) RegisterListener( } // ConnectWithAuthentication is called by the client (i.e., the one establishing -// connection with the server). Once a connect.Connection has been established +// 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 recipient [contact.Contact] (Uint8Array). +// - 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. +// - Resolves to a Javascript representation of the [Connection] object. // - Rejected with an error if loading the parameters or connecting fails. func (c *Cmix) ConnectWithAuthentication(_ js.Value, args []js.Value) interface{} { recipientContact := utils.CopyBytesToGo(args[1]) diff --git a/wasm/backup.go b/wasm/backup.go index cd4200b5dc2a25a61d68a38cdcc8f2d672a8406e..cd5f2f57e2892277c12343de7eeff38ef6c09bbe 100644 --- a/wasm/backup.go +++ b/wasm/backup.go @@ -26,7 +26,7 @@ type Backup struct { } // newBackupJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the Backup structure. +// (map[string]interface{}) that matches the [Backup] structure. func newBackupJS(api *bindings.Backup) map[string]interface{} { b := Backup{api} backupMap := map[string]interface{}{ @@ -47,7 +47,7 @@ type updateBackupFunc struct { // UpdateBackup is a function callback that returns new backups. // // Parameters: -// - encryptedBackup - returns the bytes of the encrypted backup (Uint8Array). +// - encryptedBackup - Returns the bytes of the encrypted backup (Uint8Array). func (ubf *updateBackupFunc) UpdateBackup(encryptedBackup []byte) { ubf.updateBackup(utils.CopyBytesToJS(encryptedBackup)) } @@ -61,15 +61,15 @@ func (ubf *updateBackupFunc) UpdateBackup(encryptedBackup []byte) { // this function should call LoadCmix as normal once this call succeeds. // // Parameters: -// - args[0] - JSON of the NDF (string). -// - args[1] - storage directory (string). -// - args[2] - backup passphrase (string). -// - args[3] - session password (Uint8Array). -// - args[4] - backup file contents (Uint8Array). +// - 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: // - JSON of [bindings.BackupReport] (Uint8Array). -// - throws a TypeError if creating Cmix from backup fails. +// - Throws a TypeError if creating [Cmix] from backup fails. func NewCmixFromBackup(_ js.Value, args []js.Value) interface{} { ndfJSON := args[0].String() storageDir := args[1].String() @@ -91,20 +91,20 @@ func NewCmixFromBackup(_ js.Value, args []js.Value) interface{} { // Backup functions // //////////////////////////////////////////////////////////////////////////////// -// InitializeBackup creates a bindings-layer Backup object. +// 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 -// backup. -// - args[3] - the callback to be called when a backup is triggered. Must be +// - args[0] - ID of [E2e] object in tracker (int). +// - args[1] - ID of [UserDiscovery] object in tracker (int). +// - args[2] - [Backup] passphrase provided by the user (string). Used to +// decrypt the backup. +// - args[3] - The callback to be called when a backup is triggered. Must be // Javascript object that has functions that implement the // [bindings.UpdateBackupFunc] interface. // // Returns: -// - Javascript representation of the Backup object -// - Throws a TypeError if initializing the Backup fails. +// - Javascript representation of the [Backup] object. +// - Throws a TypeError if initializing the [Backup] fails. func InitializeBackup(_ js.Value, args []js.Value) interface{} { cb := &updateBackupFunc{utils.WrapCB(args[3], "UpdateBackup")} api, err := bindings.InitializeBackup( @@ -121,19 +121,19 @@ func InitializeBackup(_ js.Value, args []js.Value) interface{} { // 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. +// [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 +// - 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. +// has been passed into [InitializeBackup]. // // Returns: -// - Javascript representation of the Backup object -// - Throws a TypeError if initializing the Backup fails. +// - Javascript representation of the [Backup] object. +// - Throws a TypeError if initializing the [Backup] fails. func ResumeBackup(_ js.Value, args []js.Value) interface{} { cb := &updateBackupFunc{utils.WrapCB(args[2], "UpdateBackup")} api, err := bindings.ResumeBackup(args[0].Int(), args[1].Int(), cb) @@ -146,7 +146,7 @@ func ResumeBackup(_ js.Value, args []js.Value) interface{} { } // StopBackup stops the backup processes and deletes the user's password from -// storage. To enable backups again, call InitializeBackup. +// storage. To enable backups again, call [InitializeBackup]. // // Returns: // - Throws a TypeError if stopping the backup fails. @@ -164,12 +164,12 @@ func (b *Backup) StopBackup(js.Value, []js.Value) interface{} { // running. Returns false if it has been stopped. // // Returns: -// - boolean +// - If the backup is running (boolean). func (b *Backup) IsBackupRunning(js.Value, []js.Value) interface{} { return b.api.IsBackupRunning() } -// AddJson stores the argument within the Backup structure. +// AddJson stores the argument within the [Backup] structure. // // Parameters: // - args[0] - JSON to store (string). diff --git a/wasm/channels.go b/wasm/channels.go index af7c8180c9157774703e412c213d40f3705e80d4..54ce1d8e3d469573a35cf0b1947090195334fbe6 100644 --- a/wasm/channels.go +++ b/wasm/channels.go @@ -13,12 +13,9 @@ import ( "gitlab.com/elixxir/client/bindings" "gitlab.com/elixxir/xxdk-wasm/indexedDb" "gitlab.com/elixxir/xxdk-wasm/utils" - "gitlab.com/xx_network/primitives/id" "syscall/js" ) -var _ = &id.ID{} - //////////////////////////////////////////////////////////////////////////////// // Basic Channel API // //////////////////////////////////////////////////////////////////////////////// @@ -30,7 +27,7 @@ type ChannelsManager struct { } // newChannelsManagerJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the ChannelsManager structure. +// (map[string]interface{}) that matches the [ChannelsManager] structure. func newChannelsManagerJS(api *bindings.ChannelsManager) map[string]interface{} { cm := ChannelsManager{api} channelsManagerMap := map[string]interface{}{ @@ -55,15 +52,16 @@ func newChannelsManagerJS(api *bindings.ChannelsManager) map[string]interface{} return channelsManagerMap } -// GetID returns the ID for this ChannelsManager in the ChannelsManager tracker. +// GetID returns the ID for this [ChannelsManager] in the [ChannelsManager] +// tracker. // // Returns: -// - int +// - Tracker ID (int). func (ch *ChannelsManager) GetID(js.Value, []js.Value) interface{} { return ch.api.GetID() } -// NewChannelsManager constructs a ChannelsManager. +// NewChannelsManager constructs a [ChannelsManager]. // // Parameters: // - args[0] - ID of [E2e] object in tracker (int). This can be retrieved using @@ -84,13 +82,13 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} { return newChannelsManagerJS(cm) } -// NewChannelsManagerWithIndexedDb constructs a ChannelsManager using an +// NewChannelsManagerWithIndexedDb constructs a [ChannelsManager] using an // indexedDb backend. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). This can be retrieved using +// - args[0] - ID of [E2e] object in tracker (int). This can be retrieved using // [E2e.GetID]. -// - args[1] - ID of UserDiscovery object in tracker (int). This can be +// - args[1] - ID of [UserDiscovery] object in tracker (int). This can be // retrieved using [UserDiscovery.GetID]. // - args[2] - username (string). // @@ -115,13 +113,14 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} { return newChannelsManagerJS(cm) } -// NewChannelsManagerWithIndexedDbDummyNameService constructs a ChannelsManager -// using an indexedDb backend and a dummy name server instead of UD. +// NewChannelsManagerWithIndexedDbDummyNameService constructs a +// [ChannelsManager] using an indexedDb backend and a dummy name server instead +// of UD. // // Parameters: -// - args[0] - ID of Cmix object in tracker (int). This can be retrieved using -// [Cmix.GetID]. -// - args[1] - username (string). +// - args[0] - ID of [Cmix] object in tracker (int). This can be retrieved +// using [Cmix.GetID]. +// - args[1] - Username (string). // // Returns: // - Javascript representation of the [bindings.ChannelsManager] object. @@ -144,12 +143,12 @@ func NewChannelsManagerWithIndexedDbDummyNameService(_ js.Value, args []js.Value return newChannelsManagerJS(cm) } -// NewChannelsManagerDummyNameService constructs a ChannelsManager +// NewChannelsManagerDummyNameService constructs a [ChannelsManager] // using a Javascript event model backend and a dummy name server instead of UD. // // Parameters: -// - args[0] - ID of Cmix object in tracker (int). This can be retrieved using -// [Cmix.GetID]. +// - args[0] - ID of [Cmix] object in tracker (int). This can be retrieved +// using [Cmix.GetID]. // - args[1] - Username (string). // - args[2] - Javascript object that matches the [bindings.EventModel] // interface. @@ -189,7 +188,7 @@ func NewChannelsManagerDummyNameService(_ js.Value, args []js.Value) interface{} // The description cannot be longer than ___ and can only use ______ characters. // // Parameters: -// - args[0] - ID of Cmix object in tracker (int). +// - args[0] - ID of [Cmix] object in tracker (int). // - args[1] - The name of the new channel. The name cannot be longer than __ // characters and must contain only __ characters. It cannot be changed once // a channel is created (string). @@ -284,7 +283,7 @@ func (ch *ChannelsManager) GetChannels(js.Value, []js.Value) interface{} { // was not previously joined. // // Parameters: -// - args[0] - JSON of the channel [id.ID] (Uint8Array). +// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array). // // Returns: // - Throws a TypeError if the channel does not exist. @@ -304,7 +303,7 @@ func (ch *ChannelsManager) LeaveChannel(_ js.Value, args []js.Value) interface{} // memory (~3 weeks) over the event model. // // Parameters: -// - args[0] - JSON of the channel [id.ID] (Uint8Array). +// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array). // // Returns: // - Throws a TypeError if the replay fails. @@ -333,7 +332,7 @@ func (ch *ChannelsManager) ReplayChannel(_ js.Value, args []js.Value) interface{ // on the use case. // // Parameters: -// - args[0] - JSON of the channel [id.ID] (Uint8Array). +// - 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). @@ -375,7 +374,7 @@ func (ch *ChannelsManager) SendGeneric(_ js.Value, args []js.Value) interface{} // // Parameters: // - args[0] - The PEM-encode admin RSA private key (Uint8Array). -// - args[1] - JSON of the channel [id.ID] (Uint8Array). +// - args[1] - Marshalled bytes of the channel [id.ID] (Uint8Array). // - args[2] - The message type of the message. This will be a valid // [channels.MessageType] (int). // - args[3] - The contents of the message (Uint8Array). @@ -419,7 +418,7 @@ func (ch *ChannelsManager) SendAdminGeneric(_ js.Value, args []js.Value) interfa // lasting forever if [channels.ValidForever] is used. // // Parameters: -// - args[0] - JSON of the channel [id.ID] (Uint8Array). +// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array). // - args[1] - The contents of the message (string). // - args[2] - The lease of the message. This will be how long the message is // valid until, in milliseconds. As per the [channels.Manager] documentation, @@ -461,7 +460,7 @@ func (ch *ChannelsManager) SendMessage(_ js.Value, args []js.Value) interface{} // lasting forever if ValidForever is used. // // Parameters: -// - args[0] - JSON of the channel [id.ID] (Uint8Array). +// - 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). @@ -506,7 +505,7 @@ func (ch *ChannelsManager) SendReply(_ js.Value, args []js.Value) interface{} { // Users will drop the reaction if they do not recognize the reactTo message. // // Parameters: -// - args[0] - JSON of the channel [id.ID] (Uint8Array). +// - 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. @@ -552,9 +551,9 @@ type channelMessageReceptionCallback struct { // Callback returns the context for a channel message. // // Parameters: -// - receivedChannelMessageReport - returns the JSON of +// - receivedChannelMessageReport - Returns the JSON of // [bindings.ReceivedChannelMessageReport] (Uint8Array). -// - err - returns an error on failure (Error). +// - err - Returns an error on failure (Error). func (cmrCB *channelMessageReceptionCallback) Callback( receivedChannelMessageReport []byte, err error) { cmrCB.callback(utils.CopyBytesToJS(receivedChannelMessageReport), @@ -617,7 +616,7 @@ func (em *eventModel) JoinChannel(channel string) { // LeaveChannel is called whenever a channel is left locally. // // Parameters: -// - ChannelId - The marshalled channel [id.ID] (Uint8Array). +// - ChannelId - Marshalled bytes of the channel [id.ID] (Uint8Array). func (em *eventModel) LeaveChannel(channelID []byte) { em.leaveChannel(utils.CopyBytesToJS(channelID)) } @@ -627,7 +626,7 @@ func (em *eventModel) LeaveChannel(channelID []byte) { // user of the API to filter such called by message ID. // // Parameters: -// - channelID - The marshalled channel [id.ID] (Uint8Array). +// - channelID - Marshalled bytes of the channel [id.ID] (Uint8Array). // - messageID - The bytes of the [channel.MessageID] of the received message // (Uint8Array). // - senderUsername - The username of the sender of the message (string). @@ -636,7 +635,7 @@ func (em *eventModel) LeaveChannel(channelID []byte) { // since unix epoch (int). // - lease - The number of nanoseconds that the message is valid for (int). // - roundId - The ID of the round that the message was received on (int). -// - status - the [channels.SentStatus] of the message (int). +// - status - The [channels.SentStatus] of the message (int). // // Statuses will be enumerated as such: // Sent = 0 @@ -657,7 +656,7 @@ func (em *eventModel) ReceiveMessage(channelID, messageID []byte, // initial message. As a result, it may be important to buffer replies. // // Parameters: -// - channelID - The marshalled channel [id.ID] (Uint8Array). +// - channelID - Marshalled bytes of the channel [id.ID] (Uint8Array). // - messageID - The bytes of the [channel.MessageID] of the received message // (Uint8Array). // - reactionTo - The [channel.MessageID] for the message that received a reply @@ -668,7 +667,7 @@ func (em *eventModel) ReceiveMessage(channelID, messageID []byte, // since unix epoch (int). // - lease - The number of nanoseconds that the message is valid for (int). // - roundId - The ID of the round that the message was received on (int). -// - status - the [channels.SentStatus] of the message (int). +// - status - The [channels.SentStatus] of the message (int). // // Statuses will be enumerated as such: // Sent = 0 @@ -689,7 +688,7 @@ func (em *eventModel) ReceiveReply(channelID, messageID, reactionTo []byte, // initial message. As a result, it may be important to buffer reactions. // // Parameters: -// - channelID - The marshalled channel [id.ID] (Uint8Array). +// - channelID - Marshalled bytes of the channel [id.ID] (Uint8Array). // - messageID - The bytes of the [channel.MessageID] of the received message // (Uint8Array). // - reactionTo - The [channel.MessageID] for the message that received a reply @@ -700,7 +699,7 @@ func (em *eventModel) ReceiveReply(channelID, messageID, reactionTo []byte, // since unix epoch (int). // - lease - The number of nanoseconds that the message is valid for (int). // - roundId - The ID of the round that the message was received on (int). -// - status - the [channels.SentStatus] of the message (int). +// - status - The [channels.SentStatus] of the message (int). // // Statuses will be enumerated as such: // Sent = 0 @@ -719,7 +718,7 @@ func (em *eventModel) ReceiveReaction(channelID, messageID, reactionTo []byte, // Parameters: // - messageID - The bytes of the [channel.MessageID] of the received message // (Uint8Array). -// - status - the [channels.SentStatus] of the message (int). +// - status - The [channels.SentStatus] of the message (int). // // Statuses will be enumerated as such: // Sent = 0 diff --git a/wasm/cmix.go b/wasm/cmix.go index 14b33853465bbaa5201797a228b3a8244f0587e7..4779e557c2d977ded765acd628046bca11f5c3a9 100644 --- a/wasm/cmix.go +++ b/wasm/cmix.go @@ -22,7 +22,7 @@ type Cmix struct { } // newCmixJS creates a new Javascript compatible object (map[string]interface{}) -// that matches the Cmix structure. +// that matches the [Cmix] structure. func newCmixJS(api *bindings.Cmix) map[string]interface{} { c := Cmix{api} cmix := map[string]interface{}{ @@ -72,13 +72,13 @@ func newCmixJS(api *bindings.Cmix) map[string]interface{} { // Users of this function should delete the storage directory on error. // // Parameters: -// - args[0] - NDF JSON (string). -// - args[1] - storage directory path (string). -// - args[2] - password used for storage (Uint8Array). -// - args[3] - registration code (string). +// - args[0] - NDF JSON ([ndf.NetworkDefinition]) (string). +// - args[1] - Storage directory path (string). +// - args[2] - Password used for storage (Uint8Array). +// - args[3] - Registration code (string). // // Returns: -// - throws a TypeError if creating new Cmix fails. +// - Throws a TypeError if creating new [Cmix] fails. func NewCmix(_ js.Value, args []js.Value) interface{} { password := utils.CopyBytesToGo(args[2]) @@ -103,13 +103,13 @@ func NewCmix(_ js.Value, args []js.Value) interface{} { // 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) +// - 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. +// - Resolves to a Javascript representation of the [Cmix] object. +// - Rejected with an error if loading [Cmix] fails. func LoadCmix(_ js.Value, args []js.Value) interface{} { storageDir := args[0].String() password := utils.CopyBytesToGo(args[1]) @@ -130,7 +130,7 @@ func LoadCmix(_ js.Value, args []js.Value) interface{} { // GetID returns the ID for this [bindings.Cmix] in the cmixTracker. // // Returns: -// - int of the ID +// - Tracker ID (int). func (c *Cmix) GetID(js.Value, []js.Value) interface{} { return c.api.GetID() } diff --git a/wasm/connect.go b/wasm/connect.go index 5e005925b03a2f22be831499464113e5d0817488..e3bc13313df46d53856c2cb0f1468f4369cec013 100644 --- a/wasm/connect.go +++ b/wasm/connect.go @@ -22,7 +22,7 @@ type Connection struct { } // newConnectJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the Connection structure. +// (map[string]interface{}) that matches the [Connection] structure. func newConnectJS(api *bindings.Connection) map[string]interface{} { c := Connection{api} connectionMap := map[string]interface{}{ @@ -40,24 +40,25 @@ func newConnectJS(api *bindings.Connection) map[string]interface{} { // GetId returns the ID for this [bindings.Connection] in the connectionTracker. // // Returns: -// - int of the ID +// - Tracker ID (int). func (c *Connection) GetId(js.Value, []js.Value) interface{} { return c.api.GetId() } // Connect performs auth key negotiation with the given recipient and returns a -// Connection object for the newly created [partner.Manager]. +// [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 the E2E object in the E2E tracker (int). -// - args[1] - marshalled recipient [contact.Contact] (Uint8Array). +// - 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. +// - Resolves to a Javascript representation of the [Connection] object. // - Rejected with an error if loading the parameters or connecting fails. func (c *Cmix) Connect(_ js.Value, args []js.Value) interface{} { recipientContact := utils.CopyBytesToGo(args[1]) @@ -75,20 +76,20 @@ func (c *Cmix) Connect(_ js.Value, args []js.Value) interface{} { return utils.CreatePromise(promiseFn) } -// SendE2E is a wrapper for sending specifically to the Connection's +// SendE2E is a wrapper for sending specifically to the [Connection]'s // [partner.Manager]. // // Returns: // - []byte - the JSON marshalled bytes of the E2ESendReport object, which can -// be passed into WaitForRoundResult to see if the send succeeded. +// be passed into [Cmix.WaitForRoundResult] to see if the send succeeded. // // Parameters: -// - args[0] - message type from [catalog.MessageType] (int) -// - args[1] - message payload (Uint8Array) +// - args[0] - Message type from [catalog.MessageType] (int). +// - args[1] - Message payload (Uint8Array). // // Returns a promise: // - Resolves to the JSON of the [bindings.E2ESendReport], which can be passed -// into Cmix.WaitForRoundResult to see if the send succeeded (Uint8Array). +// into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // - Rejected with an error if sending fails. func (c *Connection) SendE2E(_ js.Value, args []js.Value) interface{} { payload := utils.CopyBytesToGo(args[1]) @@ -105,10 +106,10 @@ func (c *Connection) SendE2E(_ js.Value, args []js.Value) interface{} { return utils.CreatePromise(promiseFn) } -// Close deletes this Connection's partner.Manager and releases resources. +// Close deletes this [Connection]'s [partner.Manager] and releases resources. // // Returns: -// - throws a TypeError if closing fails +// - Throws a TypeError if closing fails. func (c *Connection) Close(js.Value, []js.Value) interface{} { err := c.api.Close() if err != nil { @@ -119,10 +120,10 @@ func (c *Connection) Close(js.Value, []js.Value) interface{} { return nil } -// GetPartner returns the partner.Manager for this Connection. +// GetPartner returns the [partner.Manager] for this [Connection]. // // Returns: -// - bytes of the partner's [id.ID] (Uint8Array) +// - Marshalled bytes of the partner's [id.ID] (Uint8Array). func (c *Connection) GetPartner(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(c.api.GetPartner()) } @@ -136,25 +137,25 @@ type listener struct { // Hear is called to receive a message in the UI. // // Parameters: -// - item - returns the JSON of [bindings.Message] (Uint8Array). +// - item - Returns the JSON of [bindings.Message] (Uint8Array). func (l *listener) Hear(item []byte) { l.hear(utils.CopyBytesToJS(item)) } // Name returns a name; used for debugging. // // Returns: -// - string +// - Name (string). func (l *listener) Name() string { return l.name().String() } // RegisterListener is used for E2E reception and allows for reading data sent -// from the partner.Manager. +// from the [partner.Manager]. // // Parameters: -// - args[0] - message type from [catalog.MessageType] (int) +// - args[0] - message type from [catalog.MessageType] (int). // - args[1] - Javascript object that has functions that implement the -// [bindings.Listener] interface +// [bindings.Listener] interface. // // Returns: -// - throws a TypeError is registering the listener fails +// - Throws a TypeError is registering the listener fails. func (c *Connection) RegisterListener(_ js.Value, args []js.Value) interface{} { err := c.api.RegisterListener(args[0].Int(), &listener{utils.WrapCB(args[1], "Hear"), utils.WrapCB(args[1], "Name")}) diff --git a/wasm/delivery.go b/wasm/delivery.go index 25f9a7b77fb79b8640e9f564e97df14f262a9bd0..74cbf0386667332555856dcc1f44060cf12cf575 100644 --- a/wasm/delivery.go +++ b/wasm/delivery.go @@ -75,7 +75,7 @@ func (mdc *messageDeliveryCallback) EventCallback( // inherits a [bindings.RoundsList] object (Uint8Array). // - args[1] - Javascript object that has functions that implement the // [bindings.MessageDeliveryCallback] interface. -// - args[2] - timeout when the callback will return if no state update occurs, +// - args[2] - Timeout when the callback will return if no state update occurs, // in milliseconds (int). // // Returns: diff --git a/wasm/docs.go b/wasm/docs.go new file mode 100644 index 0000000000000000000000000000000000000000..d748c5eebf364307a077a8787ec10df313cee50c --- /dev/null +++ b/wasm/docs.go @@ -0,0 +1,54 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2022 xx foundation // +// // +// Use of this source code is governed by a license that can be found in the // +// LICENSE file. // +//////////////////////////////////////////////////////////////////////////////// + +package wasm + +import ( + "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/client/catalog" + "gitlab.com/elixxir/client/channels" + "gitlab.com/elixxir/client/cmix/message" + "gitlab.com/elixxir/client/connect" + "gitlab.com/elixxir/client/e2e/ratchet/partner" + ftE2e "gitlab.com/elixxir/client/fileTransfer/e2e" + "gitlab.com/elixxir/client/groupChat/groupStore" + "gitlab.com/elixxir/client/single" + "gitlab.com/elixxir/crypto/channel" + "gitlab.com/elixxir/crypto/contact" + "gitlab.com/elixxir/crypto/cyclic" + "gitlab.com/elixxir/crypto/fileTransfer" + "gitlab.com/elixxir/crypto/group" + "gitlab.com/elixxir/primitives/fact" + "gitlab.com/xx_network/primitives/id" + "gitlab.com/xx_network/primitives/id/ephemeral" + "gitlab.com/xx_network/primitives/ndf" +) + +// These objects are imported so that doc linking on pkg.go.dev does not require +// the entire package URL. +var ( + _ = id.ID{} + _ = ephemeral.Id{} + _ = contact.Contact{} + _ = single.RequestParams{} + _ = channels.Manager(nil) + _ = catalog.MessageType(0) + _ = connect.Callback(nil) + _ = partner.Manager(nil) + _ = ndf.NetworkDefinition{} + _ = channel.MessageID{} + _ = channels.SentStatus(0) + _ = ftE2e.Params{} + _ = fileTransfer.TransferID{} + _ = message.ServiceList{} + _ = group.Membership{} + _ = groupStore.Group{} + _ = cyclic.Int{} + _ = fact.FactList{} + _ = fact.Fact{} + _ = jwalterweatherman.LogListener(nil) +) diff --git a/wasm/dummy.go b/wasm/dummy.go index a8400f356be09045da9dcfe3da2234bbd5838fe9..f9e1d586c40fde3ddbd04407355f0636b8b2d707 100644 --- a/wasm/dummy.go +++ b/wasm/dummy.go @@ -22,7 +22,7 @@ type DummyTraffic struct { } // newDummyTrafficJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the DummyTraffic structure. +// (map[string]interface{}) that matches the [DummyTraffic] structure. func newDummyTrafficJS(newDT *bindings.DummyTraffic) map[string]interface{} { dt := DummyTraffic{newDT} dtMap := map[string]interface{}{ @@ -33,20 +33,20 @@ func newDummyTrafficJS(newDT *bindings.DummyTraffic) map[string]interface{} { return dtMap } -// NewDummyTrafficManager creates a DummyTraffic manager and initialises the +// NewDummyTrafficManager creates a [DummyTraffic] manager and initialises the // dummy traffic sending thread. Note that the manager does not start sending -// dummy traffic until true is passed into DummyTraffic.SetStatus. The time +// dummy traffic until true is passed into [DummyTraffic.SetStatus]. The time // duration between each sending operation and the amount of messages sent each // interval are randomly generated values with bounds defined by the given // parameters below. // // Parameters: -// - args[0] - a Cmix object ID in the tracker (int). -// - args[1] - the maximum number of the random number of messages sent each +// - 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 +// - args[2] - The average duration, in milliseconds, to wait between sends // (int). -// - args[3] - the upper bound of the interval between sending cycles, in +// - 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). // @@ -64,20 +64,20 @@ func NewDummyTrafficManager(_ js.Value, args []js.Value) interface{} { return newDummyTrafficJS(dt) } -// SetStatus sets the state of the DummyTraffic manager's send thread by passing -// in a boolean parameter. There may be a small delay in between this call and -// the status of the sending thread to change accordingly. For example, passing -// false into this call while the sending thread is currently sending messages -// will not cancel nor halt the sending operation, but will pause the thread -// once that operation has completed. +// SetStatus sets the state of the [DummyTraffic] manager's send thread by +// passing in a boolean parameter. There may be a small delay in between this +// call and the status of the sending thread to change accordingly. For example, +// passing false into this call while the sending thread is currently sending +// messages will not cancel nor halt the sending operation, but will pause the +// thread once that operation has completed. // // Parameters: // - args[0] - Input should be true if you want to send dummy messages and // false if you want to pause dummy messages (boolean). // // Returns: -// - Throws a TypeError if the DummyTraffic.SetStatus is called too frequently, -// causing the internal status channel to fill. +// - Throws a TypeError if the [DummyTraffic.SetStatus] is called too +// frequently, causing the internal status channel to fill. func (dt *DummyTraffic) SetStatus(_ js.Value, args []js.Value) interface{} { err := dt.api.SetStatus(args[0].Bool()) if err != nil { @@ -88,11 +88,11 @@ func (dt *DummyTraffic) SetStatus(_ js.Value, args []js.Value) interface{} { return nil } -// GetStatus returns the current state of the DummyTraffic manager's sending +// GetStatus returns the current state of the [DummyTraffic] manager's sending // thread. Note that this function does not return the status set by the most -// recent call to SetStatus. Instead, this call returns the current status of +// recent call to [SetStatus]. Instead, this call returns the current status of // the sending thread. This is due to the small delay that may occur between -// calling SetStatus and the sending thread taking into effect that status +// calling [SetStatus] and the sending thread taking into effect that status // change. // // Returns: diff --git a/wasm/e2e.go b/wasm/e2e.go index 08c0ac9e4086cd34b1361297c01cfb6e079d7729..4da247f9f5fcccca74baf49e5c614c3f99912d70 100644 --- a/wasm/e2e.go +++ b/wasm/e2e.go @@ -22,7 +22,7 @@ type E2e struct { } // newE2eJS creates a new Javascript compatible object (map[string]interface{}) -// that matches the E2e structure. +// that matches the [E2e] structure. func newE2eJS(api *bindings.E2e) map[string]interface{} { e := E2e{api} e2eMap := map[string]interface{}{ @@ -68,28 +68,28 @@ func newE2eJS(api *bindings.E2e) map[string]interface{} { return e2eMap } -// GetID returns the ID for this E2e in the E2e tracker. +// GetID returns the ID for this [E2e] in the [E2e] tracker. // // Returns: -// - int +// - Tracker ID (int). func (e *E2e) GetID(js.Value, []js.Value) interface{} { return e.api.GetID() } -// Login creates and returns a new E2e object and adds it to the +// 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: -// - args[0] - ID of Cmix object in tracker (int). +// - args[0] - ID of [Cmix] object in tracker (int). // - args[1] - Javascript object that has functions that implement the // [bindings.AuthCallbacks] interface. // - args[2] - JSON of the [xxdk.ReceptionIdentity] (Uint8Array). // - args[3] - JSON of [xxdk.E2EParams] (Uint8Array). // // Returns: -// - Javascript representation of the E2e object. +// - Javascript representation of the [E2e] object. // - Throws a TypeError if logging in fails. func Login(_ js.Value, args []js.Value) interface{} { callbacks := newAuthCallbacks(args[1]) @@ -106,20 +106,20 @@ func Login(_ js.Value, args []js.Value) interface{} { return newE2eJS(newE2E) } -// LoginEphemeral creates and returns a new ephemeral E2e object and adds it to -// the e2eTrackerSingleton. Identity should be created via +// 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: -// - args[0] - ID of Cmix object in tracker (int). +// - args[0] - ID of [Cmix] object in tracker (int). // - args[1] - Javascript object that has functions that implement the // [bindings.AuthCallbacks] interface. // - args[2] - JSON of the [xxdk.ReceptionIdentity] object (Uint8Array). // - args[3] - JSON of [xxdk.E2EParams] (Uint8Array). // // Returns: -// - Javascript representation of the E2e object. +// - Javascript representation of the [E2e] object. // - Throws a TypeError if logging in fails. func LoginEphemeral(_ js.Value, args []js.Value) interface{} { callbacks := newAuthCallbacks(args[1]) @@ -136,10 +136,11 @@ func LoginEphemeral(_ js.Value, args []js.Value) interface{} { return newE2eJS(newE2E) } -// GetContact returns a [contact.Contact] object for the E2e ReceptionIdentity. +// GetContact returns a [contact.Contact] object for the [E2e] +// [bindings.ReceptionIdentity]. // // Returns: -// - Marshalled [contact.Contact] (Uint8Array) +// - Marshalled bytes of [contact.Contact] (Uint8Array). func (e *E2e) GetContact(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(e.api.GetContact()) } @@ -148,7 +149,7 @@ func (e *E2e) GetContact(js.Value, []js.Value) interface{} { // NDF. // // Returns: -// - User Discovery's address (string) +// - User Discovery's address (string). func (e *E2e) GetUdAddressFromNdf(js.Value, []js.Value) interface{} { return e.api.GetUdAddressFromNdf() } @@ -156,7 +157,7 @@ func (e *E2e) GetUdAddressFromNdf(js.Value, []js.Value) interface{} { // GetUdCertFromNdf retrieves the User Discovery's TLS certificate from the NDF. // // Returns: -// - Public certificate in PEM format (Uint8Array) +// - Public certificate in PEM format (Uint8Array). func (e *E2e) GetUdCertFromNdf(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(e.api.GetUdCertFromNdf()) } @@ -165,8 +166,8 @@ func (e *E2e) GetUdCertFromNdf(js.Value, []js.Value) interface{} { // within the NDF. // // Returns -// - Marshalled [contact.Contact] (Uint8Array) -// - Throws a TypeError if the contact file cannot be loaded +// - Marshalled bytes of [contact.Contact] (Uint8Array). +// - Throws a TypeError if the contact file cannot be loaded. func (e *E2e) GetUdContactFromNdf(js.Value, []js.Value) interface{} { b, err := e.api.GetUdContactFromNdf() if err != nil { @@ -201,11 +202,12 @@ func newAuthCallbacks(value js.Value) *authCallbacks { // Request will be called when an auth Request message is processed. // // Parameters: -// - contact - returns the contact file of the sender. JSON of -// [contact.Contact] (Uint8Array). -// - receptionId - returns the ID of the sender. JSON of [id.ID] (Uint8Array). -// - ephemeralId - returns the ephemeral ID of the sender (int). -// - roundId - returns the ID of the round the request was sent on (int). +// - contact - Returns the marshalled bytes of the [contact.Contact] of the +// sender (Uint8Array). +// - receptionId - Returns the marshalled bytes of the sender's [id.ID] +// (Uint8Array). +// - ephemeralId - Returns the ephemeral ID of the sender (int). +// - roundId - Returns the ID of the round the request was sent on (int). func (a *authCallbacks) Request( contact, receptionId []byte, ephemeralId, roundId int64) { if a.request != nil { @@ -217,11 +219,12 @@ func (a *authCallbacks) Request( // Confirm will be called when an auth Confirm message is processed. // // Parameters: -// - contact - returns the contact file of the sender. JSON of -// [contact.Contact] (Uint8Array). -// - receptionId - returns the ID of the sender. JSON of [id.ID] (Uint8Array). -// - ephemeralId - returns the ephemeral ID of the sender (int). -// - roundId - returns the ID of the round the confirmation was sent on (int). +// - contact - Returns the marshalled bytes of the [contact.Contact] of the +// sender (Uint8Array). +// - receptionId - Returns the marshalled bytes of the sender's [id.ID] +// (Uint8Array). +// - ephemeralId - Returns the ephemeral ID of the sender (int). +// - roundId - Returns the ID of the round the confirmation was sent on (int). func (a *authCallbacks) Confirm( contact, receptionId []byte, ephemeralId, roundId int64) { if a.confirm != nil { @@ -233,11 +236,12 @@ func (a *authCallbacks) Confirm( // Reset will be called when an auth Reset operation occurs. // // Parameters: -// - contact - returns the contact file of the sender. JSON of -// [contact.Contact] (Uint8Array). -// - receptionId - returns the ID of the sender. JSON of [id.ID] (Uint8Array). -// - ephemeralId - returns the ephemeral ID of the sender (int). -// - roundId - returns the ID of the round the reset was sent on (int). +// - contact - Returns the marshalled bytes of the [contact.Contact] of the +// sender (Uint8Array). +// - receptionId - Returns the marshalled bytes of the sender's [id.ID] +// (Uint8Array). +// - ephemeralId - Returns the ephemeral ID of the sender (int). +// - roundId - Returns the ID of the round the reset was sent on (int). func (a *authCallbacks) Reset( contact, receptionId []byte, ephemeralId, roundId int64) { if a.reset != nil { diff --git a/wasm/e2eAuth.go b/wasm/e2eAuth.go index 45b3b9450e2317e9da79c1b356d1abd50790a6fe..391d348ebe2dd36bce7ed2c0041b2263b8b722e8 100644 --- a/wasm/e2eAuth.go +++ b/wasm/e2eAuth.go @@ -14,13 +14,13 @@ import ( "syscall/js" ) -// Request sends a contact request from the user identity in the imported E2e +// Request sends a contact request from the user identity in the imported [E2e] // structure to the passed contact, as well as the passed facts (it will error // if they are too long). // -// The other party must accept the request by calling Confirm to be able to send -// messages using E2e.SendE2E. When the other party does so, the "confirm" -// callback will get called. +// The other party must accept the request by calling [Confirm] to be able to +// send messages using [E2e.SendE2E]. When the other party does so, the +// "confirm" callback will get called. // // The round the request is initially sent on will be returned, but the request // will be listed as a critical message, so the underlying cMix client will auto @@ -33,7 +33,7 @@ import ( // will be auto resent by the cMix client. // // Parameters: -// - args[0] - marshalled bytes of the partner [contact.Contact] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [contact.Contact] (Uint8Array). // - args[1] - JSON of [fact.FactList] (Uint8Array). // // Returns a promise: @@ -58,7 +58,7 @@ func (e *E2e) Request(_ js.Value, args []js.Value) interface{} { // 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. +// 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 @@ -69,10 +69,10 @@ func (e *E2e) Request(_ js.Value, args []js.Value) interface{} { // The confirmation sends as a critical message; if the round it sends on fails, // it will be auto resent by the cMix client. // -// If the confirmation must be resent, use ReplayConfirm. +// If the confirmation must be resent, use [ReplayConfirm]. // // Parameters: -// - args[0] - marshalled bytes of the partner [contact.Contact] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [contact.Contact] (Uint8Array). // // Returns a promise: // - Resolves to the ID of the round (int). @@ -107,7 +107,7 @@ func (e *E2e) Confirm(_ js.Value, args []js.Value) interface{} { // who is already a partner. // // Parameters: -// - args[0] - marshalled bytes of the partner [contact.Contact] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [contact.Contact] (Uint8Array). // // Returns a promise: // - Resolves to the ID of the round (int). @@ -136,7 +136,7 @@ func (e *E2e) Reset(_ js.Value, args []js.Value) interface{} { // This will not be useful if either side has ratcheted. // // Parameters: -// - args[0] - marshalled bytes of the partner [contact.Contact] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [contact.Contact] (Uint8Array). // // Returns a promise: // - Resolves to the ID of the round (int). @@ -166,7 +166,7 @@ func (e *E2e) CallAllReceivedRequests(js.Value, []js.Value) interface{} { // DeleteRequest deletes sent or received requests for a specific partner ID. // // Parameters: -// - args[0] - marshalled bytes of the partner [contact.Contact] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [contact.Contact] (Uint8Array). // // Returns: // - Throws TypeError if the deletion fails. @@ -226,10 +226,10 @@ func (e *E2e) DeleteReceiveRequests(js.Value, []js.Value) interface{} { // GetReceivedRequest returns a contact if there is a received request for it. // // Parameters: -// - args[0] - marshalled bytes of the partner [contact.Contact] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [contact.Contact] (Uint8Array). // // Returns: -// - The marshalled bytes of [contact.Contact] (Uint8Array). +// - Marshalled bytes of [contact.Contact] (Uint8Array). // - Throws TypeError if getting the received request fails. func (e *E2e) GetReceivedRequest(_ js.Value, args []js.Value) interface{} { partnerContact := utils.CopyBytesToGo(args[0]) @@ -245,12 +245,12 @@ func (e *E2e) GetReceivedRequest(_ js.Value, args []js.Value) interface{} { // 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) +// - 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) +// - Returns true if the ownership is valid (boolean). // - Throws TypeError if loading the parameters fails. func (e *E2e) VerifyOwnership(_ js.Value, args []js.Value) interface{} { receivedContact := utils.CopyBytesToGo(args[0]) @@ -269,9 +269,9 @@ func (e *E2e) VerifyOwnership(_ js.Value, args []js.Value) interface{} { // callback for the given partner ID. // // Parameters: -// - args[0] - marshalled bytes of the partner [id.ID] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [id.ID] (Uint8Array). // - args[1] - Javascript object that has functions that implement the -// [bindings.AuthCallbacks] interface +// [bindings.AuthCallbacks] interface. // // Returns: // - Throws TypeError if the [id.ID] cannot be unmarshalled. @@ -291,7 +291,7 @@ func (e *E2e) AddPartnerCallback(_ js.Value, args []js.Value) interface{} { // auth callback for the given partner ID. // // Parameters: -// - args[0] - marshalled bytes of the partner [id.ID] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [id.ID] (Uint8Array). // // Returns: // - Throws TypeError if the [id.ID] cannot be unmarshalled. diff --git a/wasm/e2eHandler.go b/wasm/e2eHandler.go index 44e4cebec9931697d5000dd2ddb183bbfcd5e045..5f63de183d0490b7e40337e50fe6f0b110800434 100644 --- a/wasm/e2eHandler.go +++ b/wasm/e2eHandler.go @@ -17,15 +17,15 @@ import ( // GetReceptionID returns the marshalled default IDs. // // Returns: -// - The marshalled bytes of the [id.ID] object (Uint8Array) +// - Marshalled bytes of [id.ID] (Uint8Array). func (e *E2e) GetReceptionID(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(e.api.GetReceptionID()) } -// DeleteContact removes a partner from E2e's storage. +// DeleteContact removes a partner from [E2e]'s storage. // // Parameters: -// - args[0] - marshalled bytes of the partner [id.ID] (Uint8Array). +// - args[0] - Marshalled bytes of the partner [id.ID] (Uint8Array). // // Returns: // - Throws utils.TypeError if deleting the partner fails. @@ -42,8 +42,8 @@ func (e *E2e) DeleteContact(_ js.Value, args []js.Value) interface{} { // relationship with. // // Returns: -// - JSON of array of [id.ID] (Uint8Array) -// - Throws TypeError if getting partner IDs fails +// - JSON of array of [id.ID] (Uint8Array). +// - Throws TypeError if getting partner IDs fails. func (e *E2e) GetAllPartnerIDs(js.Value, []js.Value) interface{} { partnerIDs, err := e.api.GetAllPartnerIDs() if err != nil { @@ -56,7 +56,7 @@ func (e *E2e) GetAllPartnerIDs(js.Value, []js.Value) interface{} { // PayloadSize returns the max payload size for a partitionable E2E message. // // Returns: -// - Max payload size (int) +// - Max payload size (int). func (e *E2e) PayloadSize(js.Value, []js.Value) interface{} { return e.api.PayloadSize() } @@ -65,7 +65,7 @@ func (e *E2e) PayloadSize(js.Value, []js.Value) interface{} { // after the first payload. // // Returns: -// - Max payload size (int) +// - Max payload size (int). func (e *E2e) SecondPartitionSize(js.Value, []js.Value) interface{} { return e.api.SecondPartitionSize() } @@ -74,10 +74,10 @@ func (e *E2e) SecondPartitionSize(js.Value, []js.Value) interface{} { // The first payload is index 0. // // Parameters: -// - args[0] - payload index (int) +// - args[0] - Payload index (int). // // Returns: -// - Partition payload size (int) +// - Partition payload size (int). func (e *E2e) PartitionSize(_ js.Value, args []js.Value) interface{} { return e.api.PartitionSize(args[0].Int()) } @@ -86,7 +86,7 @@ func (e *E2e) PartitionSize(_ js.Value, args []js.Value) interface{} { // payload. // // Returns: -// - Max partition payload size (int) +// - Max partition payload size (int). func (e *E2e) FirstPartitionSize(js.Value, []js.Value) interface{} { return e.api.FirstPartitionSize() } @@ -95,8 +95,8 @@ func (e *E2e) FirstPartitionSize(js.Value, []js.Value) interface{} { // key. // // Returns: -// - JSON of [cyclic.Int] (Uint8Array) -// - Throws TypeError if getting the key fails +// - JSON of [cyclic.Int] (Uint8Array). +// - Throws TypeError if getting the key fails. func (e *E2e) GetHistoricalDHPrivkey(js.Value, []js.Value) interface{} { privKey, err := e.api.GetHistoricalDHPrivkey() if err != nil { @@ -110,8 +110,8 @@ func (e *E2e) GetHistoricalDHPrivkey(js.Value, []js.Value) interface{} { // key. // // Returns: -// - JSON of [cyclic.Int] (Uint8Array) -// - Throws TypeError if getting the key fails +// - JSON of [cyclic.Int] (Uint8Array). +// - Throws TypeError if getting the key fails. func (e *E2e) GetHistoricalDHPubkey(js.Value, []js.Value) interface{} { pubKey, err := e.api.GetHistoricalDHPubkey() if err != nil { @@ -125,11 +125,11 @@ func (e *E2e) GetHistoricalDHPubkey(js.Value, []js.Value) interface{} { // partner exists, otherwise returns false. // // Parameters: -// - args[0] - JSON of [id.ID] (Uint8Array) +// - 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 +// - Existence of authenticated channel (boolean). +// - Throws TypeError if unmarshalling the ID or getting the channel fails. func (e *E2e) HasAuthenticatedChannel(_ js.Value, args []js.Value) interface{} { exists, err := e.api.HasAuthenticatedChannel(utils.CopyBytesToGo(args[0])) if err != nil { @@ -142,10 +142,10 @@ func (e *E2e) HasAuthenticatedChannel(_ js.Value, args []js.Value) interface{} { // RemoveService removes all services for the given tag. // // Parameters: -// - args[0] - tag of services to remove (string) +// - args[0] - Tag of services to remove (string). // // Returns: -// - Throws TypeError if removing the services fails +// - Throws TypeError if removing the services fails. func (e *E2e) RemoveService(_ js.Value, args []js.Value) interface{} { err := e.api.RemoveService(args[0].String()) if err != nil { @@ -160,14 +160,14 @@ func (e *E2e) RemoveService(_ js.Value, args []js.Value) interface{} { // message type, per the given parameters--encrypted with end-to-end encryption. // // Parameters: -// - args[0] - message type from [catalog.MessageType] (int). -// - args[1] - JSON of [id.ID] (Uint8Array). -// - args[2] - message payload (Uint8Array). -// - args[3] - JSON [e2e.Params] (Uint8Array). +// - 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: // - Resolves to the JSON of the [bindings.E2ESendReport], which can be passed -// into Cmix.WaitForRoundResult to see if the send succeeded (Uint8Array). +// into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // - Rejected with an error if sending fails. func (e *E2e) SendE2E(_ js.Value, args []js.Value) interface{} { recipientId := utils.CopyBytesToGo(args[1]) @@ -198,10 +198,11 @@ type processor struct { // message processing system. // // Parameters: -// - message - returns the message contents (Uint8Array). -// - receptionId - returns the ID of the sender. JSON of [id.ID] (Uint8Array). -// - ephemeralId - returns the ephemeral ID of the sender (int). -// - roundId - returns the ID of the round sent on (int). +// - message - Returns the message contents (Uint8Array). +// - receptionId - Returns the marshalled bytes of the sender's [id.ID] +// (Uint8Array). +// - ephemeralId - Returns the ephemeral ID of the sender (int). +// - roundId - Returns the ID of the round sent on (int). func (p *processor) Process( message, receptionId []byte, ephemeralId, roundId int64) { p.process(utils.CopyBytesToJS(message), utils.CopyBytesToJS(receptionId), @@ -223,12 +224,12 @@ func (p *processor) String() string { // that piggyback on e2e relationships to start communication. // // Parameters: -// - args[0] - tag for the service (string) +// - args[0] - tag for the service (string). // - args[1] - Javascript object that has functions that implement the -// [bindings.Processor] interface +// [bindings.Processor] interface. // // Returns: -// - Throws TypeError if registering the service fails +// - Throws TypeError if registering the service fails. func (e *E2e) AddService(_ js.Value, args []js.Value) interface{} { p := &processor{ utils.WrapCB(args[1], "Process"), utils.WrapCB(args[1], "String")} @@ -245,15 +246,15 @@ func (e *E2e) AddService(_ js.Value, args []js.Value) interface{} { // RegisterListener registers a new listener. // // Parameters: -// - args[0] - JSON of the user ID [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[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 +// [bindings.Listener] interface; do not pass nil as the listener. // // Returns: -// - Throws TypeError if registering the service fails +// - Throws TypeError if registering the service fails. func (e *E2e) RegisterListener(_ js.Value, args []js.Value) interface{} { recipientId := utils.CopyBytesToGo(args[0]) l := &listener{utils.WrapCB(args[2], "Hear"), utils.WrapCB(args[2], "Name")} diff --git a/wasm/errors.go b/wasm/errors.go index a22cdb4cd6422f309ccc45732df86174667e7ea2..1c45a71e3e86dc2d344005b438376b99d31c6331 100644 --- a/wasm/errors.go +++ b/wasm/errors.go @@ -37,7 +37,7 @@ func CreateUserFriendlyErrorMessage(_ js.Value, args []js.Value) interface{} { // messages. // // Parameters: -// - args[0] - contents of a JSON file whose format conforms to the example +// - args[0] - Contents of a JSON file whose format conforms to the example // below (string). // // Example Input: @@ -48,7 +48,7 @@ func CreateUserFriendlyErrorMessage(_ js.Value, args []js.Value) interface{} { // } // // Returns: -// - throws a TypeError if the JSON cannot be unmarshalled. +// - Throws a TypeError if the JSON cannot be unmarshalled. func UpdateCommonErrors(_ js.Value, args []js.Value) interface{} { err := bindings.UpdateCommonErrors(args[0].String()) if err != nil { diff --git a/wasm/fileTransfer.go b/wasm/fileTransfer.go index 2c2320f8d38f23eea1bfd9c54dd6583513f69c9e..77201c52b11fed4e39ab91a0f75f922a63993f80 100644 --- a/wasm/fileTransfer.go +++ b/wasm/fileTransfer.go @@ -26,7 +26,7 @@ type FileTransfer struct { } // newFileTransferJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the FileTransfer structure. +// (map[string]interface{}) that matches the [FileTransfer] structure. func newFileTransferJS(api *bindings.FileTransfer) map[string]interface{} { ft := FileTransfer{api} ftMap := map[string]interface{}{ @@ -60,9 +60,9 @@ type receiveFileCallback struct { // Callback is called when a new file transfer is received. // // Parameters: -// - payload - returns the contents of the message. JSON of +// - payload - Returns the contents of the message. JSON of // [bindings.ReceivedFile] (Uint8Array). -// - err - returns an error on failure (Error). +// - err - Returns an error on failure (Error). func (rfc *receiveFileCallback) Callback(payload []byte, err error) { rfc.callback(utils.CopyBytesToJS(payload), utils.JsTrace(err)) } @@ -76,12 +76,12 @@ type fileTransferSentProgressCallback struct { // Callback is called when a new file transfer is received. // // Parameters: -// - payload - returns the contents of the message. JSON of [bindings.Progress] +// - payload - Returns the contents of the message. JSON of [bindings.Progress] // (Uint8Array). -// - t - returns a tracker that allows the lookup of the status of any file +// - t - Returns a tracker that allows the lookup of the status of any file // part. It is a Javascript object that matches the functions on -// FilePartTracker. -// - err - returns an error on failure (Error). +// [FilePartTracker]. +// - err - Returns an error on failure (Error). func (spc *fileTransferSentProgressCallback) Callback( payload []byte, t *bindings.FilePartTracker, err error) { spc.callback(utils.CopyBytesToJS(payload), newFilePartTrackerJS(t), @@ -97,12 +97,12 @@ type fileTransferReceiveProgressCallback struct { // Callback is called when a file part is sent or an error occurs. // // Parameters: -// - payload - returns the contents of the message. JSON of [bindings.Progress] +// - payload - Returns the contents of the message. JSON of [bindings.Progress] // (Uint8Array). -// - t - returns a tracker that allows the lookup of the status of any file +// - t - Returns a tracker that allows the lookup of the status of any file // part. It is a Javascript object that matches the functions on -// FilePartTracker. -// - err - returns an error on failure (Error). +// [FilePartTracker]. +// - err - Returns an error on failure (Error). func (rpc *fileTransferReceiveProgressCallback) Callback( payload []byte, t *bindings.FilePartTracker, err error) { rpc.callback(utils.CopyBytesToJS(payload), newFilePartTrackerJS(t), @@ -116,14 +116,15 @@ func (rpc *fileTransferReceiveProgressCallback) Callback( // InitFileTransfer creates a bindings-level file transfer manager. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). +// - args[0] - ID of [E2e] object in tracker (int). // - args[1] - Javascript object that has functions that implement the // [bindings.ReceiveFileCallback] interface. -// - args[2] - JSON of [fileTransfer.e2e.Params] (Uint8Array). +// - args[2] - JSON of [gitlab.com/elixxir/client/fileTransfer/e2e.Params] +// (Uint8Array). // - args[3] - JSON of [fileTransfer.Params] (Uint8Array). // // Returns: -// - Javascript representation of the FileTransfer object. +// - Javascript representation of the [FileTransfer] object. // - Throws a TypeError initialising the file transfer manager fails. func InitFileTransfer(_ js.Value, args []js.Value) interface{} { rfc := &receiveFileCallback{utils.WrapCB(args[1], "Callback")} @@ -144,8 +145,8 @@ func InitFileTransfer(_ js.Value, args []js.Value) interface{} { // // Parameters: // - args[0] - JSON of [bindings.FileSend] (Uint8Array). -// - args[1] - marshalled recipient [id.ID] (Uint8Array). -// - args[2] - number of retries allowed (float) +// - 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 @@ -181,7 +182,7 @@ func (f *FileTransfer) Send(_ js.Value, args []js.Value) interface{} { // file transfer is complete. // // Parameters: -// - args[0] - file transfer ID (Uint8Array). +// - args[0] - File transfer [fileTransfer.TransferID] (Uint8Array). // // Returns: // - File contents (Uint8Array). @@ -205,7 +206,7 @@ func (f *FileTransfer) Receive(_ js.Value, args []js.Value) interface{} { // reported by the progress callback). // // Parameters: -// - args[0] - file transfer ID (Uint8Array). +// - args[0] - File transfer [fileTransfer.TransferID] (Uint8Array). // // Returns: // - Throws a TypeError if the file transfer is incomplete. @@ -230,7 +231,7 @@ func (f *FileTransfer) CloseSend(_ js.Value, args []js.Value) interface{} { // called when resuming clients or registering extra callbacks. // // Parameters: -// - args[0] - file transfer ID (Uint8Array). +// - args[0] - File transfer [fileTransfer.TransferID] (Uint8Array). // - args[1] - Javascript object that has functions that implement the // [bindings.FileTransferSentProgressCallback] interface. // - args[2] - Duration, in milliseconds, to wait between progress callbacks @@ -258,7 +259,7 @@ func (f *FileTransfer) RegisterSentProgressCallback( // This should be done when a new transfer is received on the ReceiveCallback. // // Parameters: -// - args[0] - file transfer ID (Uint8Array). +// - args[0] - File transfer [fileTransfer.TransferID] (Uint8Array). // - args[1] - Javascript object that has functions that implement the // [bindings.FileTransferReceiveProgressCallback] interface. // - args[2] - Duration, in milliseconds, to wait between progress callbacks @@ -288,7 +289,7 @@ func (f *FileTransfer) RegisterReceivedProgressCallback( // MaxFileNameLen returns the max number of bytes allowed for a file name. // // Returns: -// - int +// - Max file name length (int). func (f *FileTransfer) MaxFileNameLen(js.Value, []js.Value) interface{} { return f.api.MaxFileNameLen() } @@ -296,7 +297,7 @@ func (f *FileTransfer) MaxFileNameLen(js.Value, []js.Value) interface{} { // MaxFileTypeLen returns the max number of bytes allowed for a file type. // // Returns: -// - int +// - Max file type length (int). func (f *FileTransfer) MaxFileTypeLen(js.Value, []js.Value) interface{} { return f.api.MaxFileTypeLen() } @@ -304,7 +305,7 @@ func (f *FileTransfer) MaxFileTypeLen(js.Value, []js.Value) interface{} { // MaxFileSize returns the max number of bytes allowed for a file. // // Returns: -// - int +// - Max file size (int). func (f *FileTransfer) MaxFileSize(js.Value, []js.Value) interface{} { return f.api.MaxFileSize() } @@ -312,7 +313,7 @@ func (f *FileTransfer) MaxFileSize(js.Value, []js.Value) interface{} { // MaxPreviewSize returns the max number of bytes allowed for a file preview. // // Returns: -// - int +// - Max preview size (int). func (f *FileTransfer) MaxPreviewSize(js.Value, []js.Value) interface{} { return f.api.MaxPreviewSize() } @@ -328,7 +329,8 @@ type FilePartTracker struct { } // newFilePartTrackerJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the filePartTracker structure. +// (map[string]interface{}) that matches the [FilePartTracker] +// structure. func newFilePartTrackerJS(api *bindings.FilePartTracker) map[string]interface{} { fpt := FilePartTracker{api} ftMap := map[string]interface{}{ @@ -348,7 +350,7 @@ func newFilePartTrackerJS(api *bindings.FilePartTracker) map[string]interface{} // - 2 = received (receiver has received a part) // // Parameters: -// - args[0] - index of part (int). +// - args[0] - Index of part (int). // // Returns: // - Part status (int). @@ -359,7 +361,7 @@ func (fpt *FilePartTracker) GetPartStatus(_ js.Value, args []js.Value) interface // GetNumParts returns the total number of file parts in the transfer. // // Returns: -// - int +// - Number of parts (int). func (fpt *FilePartTracker) GetNumParts(js.Value, []js.Value) interface{} { return fpt.api.GetNumParts() } diff --git a/wasm/follow.go b/wasm/follow.go index 2543466ed7ab87779c043b55a1f8ad463cd274dd..27c9f90bca22ec998dca55531721cff16be83e5d 100644 --- a/wasm/follow.go +++ b/wasm/follow.go @@ -49,10 +49,10 @@ import ( // handles both auth confirm and requests. // // Parameters: -// - args[0] - timeout when stopping threads in milliseconds (int) +// - args[0] - Timeout when stopping threads in milliseconds (int). // // Returns: -// - throws a TypeError if starting the network follower fails +// - Throws a TypeError if starting the network follower fails. func (c *Cmix) StartNetworkFollower(_ js.Value, args []js.Value) interface{} { err := c.api.StartNetworkFollower(args[0].Int()) if err != nil { @@ -65,12 +65,12 @@ func (c *Cmix) StartNetworkFollower(_ js.Value, args []js.Value) interface{} { // StopNetworkFollower stops the network follower if it is running. // -// If the network follower is running and this fails, the Cmix object will +// If the network follower is running and this fails, the [Cmix] object will // most likely be in an unrecoverable state and need to be trashed. // // Returns: -// - throws a TypeError if the follower is in the wrong state to stop or if it -// fails to stop +// - Throws a TypeError if the follower is in the wrong state to stop or if it +// fails to stop. func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} { err := c.api.StopNetworkFollower() if err != nil { @@ -85,7 +85,7 @@ func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} { // timeout is reached. It will return true if the network is healthy. // // Parameters: -// - args[0] - timeout when stopping threads in milliseconds (int) +// - 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 @@ -109,7 +109,7 @@ func (c *Cmix) WaitForNetwork(_ js.Value, args []js.Value) interface{} { // Stopping - 3000 // // Returns: -// - returns network status code (int) +// - Network status code (int). func (c *Cmix) NetworkFollowerStatus(js.Value, []js.Value) interface{} { return c.api.NetworkFollowerStatus() } @@ -117,9 +117,9 @@ func (c *Cmix) NetworkFollowerStatus(js.Value, []js.Value) interface{} { // GetNodeRegistrationStatus returns the current state of node registration. // // Returns: -// - []byte - JSON of [bindings.NodeRegistrationReport] containing the number -// of nodes the user is registered with and the number of nodes present in -// the NDF. +// - 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 (c *Cmix) GetNodeRegistrationStatus(js.Value, []js.Value) interface{} { @@ -135,12 +135,12 @@ func (c *Cmix) GetNodeRegistrationStatus(js.Value, []js.Value) interface{} { // HasRunningProcessies checks if any background threads are running and returns // true if one or more are. // -// This is meant to be used when NetworkFollowerStatus returns 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. +// This is meant to be used when [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: -// - boolean +// - True if there are running processes (boolean). func (c *Cmix) HasRunningProcessies(js.Value, []js.Value) interface{} { return c.api.HasRunningProcessies() } @@ -149,7 +149,7 @@ func (c *Cmix) HasRunningProcessies(js.Value, []js.Value) interface{} { // messages can be sent. // // Returns: -// - boolean +// - True if the network is healthy (boolean). func (c *Cmix) IsHealthy(js.Value, []js.Value) interface{} { return c.api.IsHealthy() } @@ -185,7 +185,7 @@ type networkHealthCallback struct { // Callback receives notification if network health changes. // // Parameters: -// - health - returns true if the network is healthy and false otherwise +// - health - Returns true if the network is healthy and false otherwise // (boolean). func (nhc *networkHealthCallback) Callback(health bool) { nhc.callback(health) } @@ -194,10 +194,10 @@ func (nhc *networkHealthCallback) Callback(health bool) { nhc.callback(health) } // // Parameters: // - args[0] - Javascript object that has functions that implement the -// [bindings.NetworkHealthCallback] interface +// [bindings.NetworkHealthCallback] interface. // // Returns: -// - Returns a registration ID that can be used to unregister (int) +// - A registration ID that can be used to unregister the callback (int). func (c *Cmix) AddHealthCallback(_ js.Value, args []js.Value) interface{} { return c.api.AddHealthCallback( &networkHealthCallback{utils.WrapCB(args[0], "Callback")}) @@ -206,7 +206,7 @@ func (c *Cmix) AddHealthCallback(_ js.Value, args []js.Value) interface{} { // RemoveHealthCallback removes a health callback using its registration ID. // // Parameters: -// - args[0] - registration ID (int) +// - args[0] - Callback registration ID (int). func (c *Cmix) RemoveHealthCallback(_ js.Value, args []js.Value) interface{} { c.api.RemoveHealthCallback(int64(args[0].Int())) return nil @@ -247,8 +247,8 @@ type trackServicesCallback struct { // which will be non-null. // // Parameters: -// - marshalData - returns the JSON of [message.ServiceList] (Uint8Array). -// - err - returns an error on failure (Error). +// - marshalData - Returns the JSON of [message.ServiceList] (Uint8Array). +// - err - Returns an error on failure (Error). // // Example JSON: // [ diff --git a/wasm/group.go b/wasm/group.go index 69bda8549f16a93356ee15ce52270db413793ac0..31c031af2f42160e03f8cd4f9349d9f10b12a430 100644 --- a/wasm/group.go +++ b/wasm/group.go @@ -26,7 +26,7 @@ type GroupChat struct { } // newGroupChatJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the GroupChat structure. +// (map[string]interface{}) that matches the [GroupChat] structure. func newGroupChatJS(api *bindings.GroupChat) map[string]interface{} { gc := GroupChat{api} gcMap := map[string]interface{}{ @@ -46,15 +46,15 @@ func newGroupChatJS(api *bindings.GroupChat) map[string]interface{} { // NewGroupChat creates a bindings-layer group chat manager. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). +// - args[0] - ID of [E2e] object in tracker (int). // - args[1] - Javascript object that has functions that implement the // [bindings.GroupRequest] interface. // - args[2] - Javascript object that has functions that implement the // [bindings.GroupChatProcessor] interface. // // Returns: -// - Javascript representation of the GroupChat object. -// - Throws a TypeError if creating the GroupChat fails. +// - Javascript representation of the [GroupChat] object. +// - Throws a TypeError if creating the [GroupChat] fails. func NewGroupChat(_ js.Value, args []js.Value) interface{} { requestFunc := &groupRequest{utils.WrapCB(args[1], "Callback")} p := &groupChatProcessor{ @@ -69,24 +69,23 @@ func NewGroupChat(_ js.Value, args []js.Value) interface{} { return newGroupChatJS(api) } -// MakeGroup creates a new Group and sends a group request to all members in the +// 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 +// - 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 +// - 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: // - Resolves to the JSON of the [bindings.GroupReport], which can be passed -// into Cmix.WaitForRoundResult to see if the send succeeded (Uint8Array). +// into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // - Rejected with an error if making the group fails. func (g *GroupChat) MakeGroup(_ js.Value, args []js.Value) interface{} { - // (membershipBytes, message, name []byte) ([]byte, error) membershipBytes := utils.CopyBytesToGo(args[0]) message := utils.CopyBytesToGo(args[1]) name := utils.CopyBytesToGo(args[2]) @@ -106,12 +105,12 @@ func (g *GroupChat) MakeGroup(_ js.Value, args []js.Value) interface{} { // ResendRequest resends a group request to all members in the group. // // Parameters: -// - args[0] - group's ID (Uint8Array). This can be found in the report -// returned by GroupChat.MakeGroup. +// - 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: // - Resolves to the JSON of the [bindings.GroupReport], which can be passed -// into Cmix.WaitForRoundResult to see if the send succeeded (Uint8Array). +// into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // - Rejected with an error if resending the request fails. func (g *GroupChat) ResendRequest(_ js.Value, args []js.Value) interface{} { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { @@ -131,7 +130,7 @@ func (g *GroupChat) ResendRequest(_ js.Value, args []js.Value) interface{} { // with the same trackedGroupId. // // Parameters: -// - args[0] - The result of calling Group.Serialize on any [bindings.Group] +// - args[0] - The result of calling [Group.Serialize] on any [bindings.Group] // object returned over the bindings (Uint8Array). // // Returns: @@ -149,8 +148,8 @@ func (g *GroupChat) JoinGroup(_ js.Value, args []js.Value) interface{} { // LeaveGroup deletes a group so a user no longer has access. // // Parameters: -// - args[0] - group's ID (Uint8Array). This can be found in the report -// returned by GroupChat.MakeGroup. +// - args[0] - The marshalled bytes of the group [id.ID] (Uint8Array). This can +// be found in the report returned by [GroupChat.MakeGroup]. // // Returns: // - Throws a TypeError if leaving the group fails. @@ -167,16 +166,16 @@ func (g *GroupChat) LeaveGroup(_ js.Value, args []js.Value) interface{} { // Send is the bindings-level function for sending to a group. // // Parameters: -// - args[0] - group's 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 +// - 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 +// - args[2] - The tag associated with the message (string). This tag may be // empty. // // Returns a promise: // - Resolves to the JSON of the [bindings.GroupSendReport], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). // - Rejected with an error if sending the message to the group fails. func (g *GroupChat) Send(_ js.Value, args []js.Value) interface{} { @@ -201,7 +200,6 @@ func (g *GroupChat) Send(_ js.Value, args []js.Value) interface{} { // - JSON of array of [id.ID] representing all group ID's (Uint8Array). // - Throws a TypeError if getting the groups fails. func (g *GroupChat) GetGroups(js.Value, []js.Value) interface{} { - // () ([]byte, error) groups, err := g.api.GetGroups() if err != nil { utils.Throw(utils.TypeError, err) @@ -215,12 +213,12 @@ func (g *GroupChat) GetGroups(js.Value, []js.Value) interface{} { // error "failed to find group" is returned. // // Parameters: -// - args[0] - group's ID (Uint8Array). This can be found in the report -// returned by GroupChat.MakeGroup. +// - args[0] - The marshalled bytes of the group [id.ID] (Uint8Array). This can +// be found in the report returned by [GroupChat.MakeGroup]. // // Returns: -// - Javascript representation of the GroupChat object. -// - Throws a TypeError if getting the group fails +// - Javascript representation of the [GroupChat] object. +// - Throws a TypeError if getting the group fails. func (g *GroupChat) GetGroup(_ js.Value, args []js.Value) interface{} { grp, err := g.api.GetGroup(utils.CopyBytesToGo(args[0])) if err != nil { @@ -234,7 +232,7 @@ func (g *GroupChat) GetGroup(_ js.Value, args []js.Value) interface{} { // NumGroups returns the number of groups the user is a part of. // // Returns: -// - int +// - Number of groups (int). func (g *GroupChat) NumGroups(js.Value, []js.Value) interface{} { return g.api.NumGroups() } @@ -250,7 +248,7 @@ type Group struct { } // newGroupJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the Group structure. +// (map[string]interface{}) that matches the [Group] structure. func newGroupJS(api *bindings.Group) map[string]interface{} { g := Group{api} gMap := map[string]interface{}{ @@ -269,15 +267,15 @@ func newGroupJS(api *bindings.Group) map[string]interface{} { // GetName returns the name set by the user for the group. // // Returns: -// - Uint8Array +// - Group name (Uint8Array). func (g *Group) GetName(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(g.api.GetName()) } -// GetID return the 33-byte unique group ID. This represents the id.ID object. +// GetID return the 33-byte unique group ID. This represents the [id.ID] object. // // Returns: -// - Uint8Array +// - Marshalled bytes of the group [id.ID] (Uint8Array). func (g *Group) GetID(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(g.api.GetID()) } @@ -285,7 +283,7 @@ func (g *Group) GetID(js.Value, []js.Value) interface{} { // GetInitMessage returns initial message sent with the group request. // // Returns: -// - Uint8Array +// - Initial group message contents (Uint8Array). func (g *Group) GetInitMessage(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(g.api.GetInitMessage()) } @@ -294,7 +292,7 @@ func (g *Group) GetInitMessage(js.Value, []js.Value) interface{} { // also the time the group requests were sent. // // Returns: -// - int +// - The time the group was created, in nanoseconds (int). func (g *Group) GetCreatedNano(js.Value, []js.Value) interface{} { return g.api.GetCreatedNano() } @@ -303,7 +301,7 @@ func (g *Group) GetCreatedNano(js.Value, []js.Value) interface{} { // also the time the group requests were sent. // // Returns: -// - int +// - The time the group was created, in milliseconds (int). func (g *Group) GetCreatedMS(js.Value, []js.Value) interface{} { return g.api.GetCreatedMS() } @@ -325,23 +323,23 @@ func (g *Group) GetMembership(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(membership) } -// Serialize serializes the Group. +// Serialize serializes the [Group]. // // Returns: -// - Byte representation of the Group (Uint8Array). +// - Byte representation of the [Group] (Uint8Array). func (g *Group) Serialize(js.Value, []js.Value) interface{} { return utils.CopyBytesToJS(g.api.Serialize()) } -// DeserializeGroup converts the results of Group.Serialize into a +// DeserializeGroup converts the results of [Group.Serialize] into a // [bindings.Group] so that its methods can be called. // // Parameters: -// - args[0] - Byte representation of the Group (Uint8Array). +// - args[0] - Byte representation of the [bindings.Group] (Uint8Array). // // Returns: -// - Javascript representation of the GroupChat object. -// - Throws a TypeError if getting the group fails +// - Javascript representation of the [GroupChat] object. +// - Throws a TypeError if getting the group fails. func DeserializeGroup(_ js.Value, args []js.Value) interface{} { grp, err := bindings.DeserializeGroup(utils.CopyBytesToGo(args[0])) if err != nil { @@ -365,7 +363,7 @@ type groupRequest struct { // Callback is called when a group request is received. // // Parameters: -// - g - returns the JSON of [bindings.Group] (Uint8Array) +// - g - Returns the JSON of [bindings.Group] (Uint8Array). func (gr *groupRequest) Callback(g *bindings.Group) { gr.callback(newGroupJS(g)) } @@ -381,13 +379,14 @@ type groupChatProcessor struct { // message processing system. // // Parameters: -// - decryptedMessage - returns the JSON of [bindings.GroupChatMessage] +// - decryptedMessage - Returns the JSON of [bindings.GroupChatMessage] // (Uint8Array). -// - msg - returns the marshalled bytes of [format.Message] (Uint8Array). -// - receptionId - returns the ID of the sender. JSON of [id.ID] (Uint8Array). -// - ephemeralId - returns the ephemeral ID of the sender (int). -// - roundId - returns the ID of the round sent on (int). -// - err - returns an error on failure (Error). +// - msg - Returns the marshalled bytes of [format.Message] (Uint8Array). +// - receptionId - Returns the marshalled bytes of the sender's [id.ID] +// (Uint8Array). +// - ephemeralId - Returns the [ephemeral.Id] of the sender (int). +// - roundId - Returns the ID of the round sent on (int). +// - err - Returns an error on failure (Error). func (gcp *groupChatProcessor) Process(decryptedMessage, msg, receptionId []byte, ephemeralId, roundId int64, err error) { gcp.process(utils.CopyBytesToJS(decryptedMessage), diff --git a/wasm/identity.go b/wasm/identity.go index 2b0f2d392217bdc789da0be953c10b443e0fe818..2f2576e4bafba7f95ad513217971ddc0b7b43449 100644 --- a/wasm/identity.go +++ b/wasm/identity.go @@ -20,18 +20,18 @@ import ( // ReceptionIdentity // //////////////////////////////////////////////////////////////////////////////// -// StoreReceptionIdentity stores the given identity in Cmix storage with the +// 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) +// - args[0] - Storage key (string). +// - args[1] - JSON of the [xxdk.ReceptionIdentity] object (Uint8Array). +// - args[2] - ID of [Cmix] object in tracker (int). // // Returns: -// - throws a TypeError if the identity cannot be stored in storage +// - Throws a TypeError if the identity cannot be stored in storage. func StoreReceptionIdentity(_ js.Value, args []js.Value) interface{} { identity := utils.CopyBytesToGo(args[1]) err := bindings.StoreReceptionIdentity( @@ -45,16 +45,16 @@ func StoreReceptionIdentity(_ js.Value, args []js.Value) interface{} { return nil } -// LoadReceptionIdentity loads the given identity in Cmix storage with the given -// key. +// 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) +// - args[0] - Storage key (string). +// - args[1] - ID of [Cmix] object in tracker (int). // // Returns: -// - JSON of the stored [xxdk.ReceptionIdentity] object (Uint8Array) -// - throws a TypeError if the identity cannot be retrieved from storage +// - JSON of the stored [xxdk.ReceptionIdentity] object (Uint8Array). +// - Throws a TypeError if the identity cannot be retrieved from storage. func LoadReceptionIdentity(_ js.Value, args []js.Value) interface{} { ri, err := bindings.LoadReceptionIdentity(args[0].String(), args[1].Int()) if err != nil { @@ -107,7 +107,7 @@ func (c *Cmix) MakeLegacyReceptionIdentity(js.Value, []js.Value) interface{} { // the xx network. // // Returns: -// - signature (Uint8Array) +// - Reception registration validation signature (Uint8Array). func (c *Cmix) GetReceptionRegistrationValidationSignature( js.Value, []js.Value) interface{} { return utils.CopyBytesToJS( @@ -122,11 +122,11 @@ func (c *Cmix) GetReceptionRegistrationValidationSignature( // [xxdk.ReceptionIdentity]. // // Parameters: -// - args[0] - JSON of [xxdk.ReceptionIdentity] (Uint8Array) +// - args[0] - JSON of [xxdk.ReceptionIdentity] (Uint8Array). // // Returns: -// - Marshalled bytes of [contact.Contact] (string) -// - Throws a TypeError if unmarshalling the identity fails +// - Marshalled bytes of [contact.Contact] (string). +// - Throws a TypeError if unmarshalling the identity fails. func GetContactFromReceptionIdentity(_ js.Value, args []js.Value) interface{} { // Note that this function does not appear in normal bindings identityJSON := utils.CopyBytesToGo(args[0]) @@ -142,11 +142,11 @@ func GetContactFromReceptionIdentity(_ js.Value, args []js.Value) interface{} { // GetIDFromContact returns the ID in the [contact.Contact] object. // // Parameters: -// - args[0] - marshalled bytes of [contact.Contact] (Uint8Array) +// - args[0] - Marshalled bytes of [contact.Contact] (Uint8Array). // // Returns: -// - marshalled [id.ID] object (Uint8Array) -// - throws a TypeError if loading the ID from the contact file fails +// - Marshalled bytes of [id.ID] (Uint8Array). +// - Throws a TypeError if loading the ID from the contact file fails. func GetIDFromContact(_ js.Value, args []js.Value) interface{} { cID, err := bindings.GetIDFromContact(utils.CopyBytesToGo(args[0])) if err != nil { @@ -161,11 +161,11 @@ func GetIDFromContact(_ js.Value, args []js.Value) interface{} { // object. // // Parameters: -// - args[0] - JSON of [contact.Contact] (string) +// - args[0] - Marshalled [contact.Contact] (string). // // Returns: -// - bytes of the [cyclic.Int] object (Uint8Array) -// - throws a TypeError if loading the public key from the contact file fails +// - Bytes of the [cyclic.Int] object (Uint8Array). +// - Throws a TypeError if loading the public key from the contact file fails. func GetPubkeyFromContact(_ js.Value, args []js.Value) interface{} { key, err := bindings.GetPubkeyFromContact([]byte(args[0].String())) if err != nil { @@ -184,12 +184,12 @@ func GetPubkeyFromContact(_ js.Value, args []js.Value) interface{} { // pass in empty facts in order to clear the facts. // // Parameters: -// - args[0] - JSON of [contact.Contact] (Uint8Array) -// - args[1] - JSON of [fact.FactList] (Uint8Array) +// - args[0] - Marshalled bytes of [contact.Contact] (Uint8Array). +// - args[1] - JSON of [fact.FactList] (Uint8Array). // // Returns: -// - marshalled bytes of the modified [contact.Contact] (string) -// - throws a TypeError if loading or modifying the contact fails +// - Marshalled bytes of the modified [contact.Contact] (string). +// - Throws a TypeError if loading or modifying the contact fails. func SetFactsOnContact(_ js.Value, args []js.Value) interface{} { marshaledContact := utils.CopyBytesToGo(args[0]) factListJSON := utils.CopyBytesToGo(args[1]) @@ -205,11 +205,11 @@ func SetFactsOnContact(_ js.Value, args []js.Value) interface{} { // GetFactsFromContact returns the fact list in the [contact.Contact] object. // // Parameters: -// - args[0] - JSON of [contact.Contact] (Uint8Array) +// - args[0] - Marshalled bytes of [contact.Contact] (Uint8Array). // // Returns: -// - JSON of [fact.FactList] (Uint8Array) -// - throws a TypeError if loading the contact fails +// - JSON of [fact.FactList] (Uint8Array). +// - Throws a TypeError if loading the contact fails. func GetFactsFromContact(_ js.Value, args []js.Value) interface{} { fl, err := bindings.GetFactsFromContact(utils.CopyBytesToGo(args[0])) if err != nil { diff --git a/wasm/logging.go b/wasm/logging.go index 504c2a618910edb7c5c657195798699fbf5debf3..950281c2399c8c922f89ca42f2c0f794d0084834 100644 --- a/wasm/logging.go +++ b/wasm/logging.go @@ -41,7 +41,7 @@ var logListeners []jww.LogListener // The default log level without updates is INFO. // // Parameters: -// - args[0] - log level (int). +// - args[0] - Log level (int). // // Returns: // - Throws TypeError if the log level is invalid. @@ -85,13 +85,13 @@ func LogLevel(_ js.Value, args []js.Value) interface{} { // LogToFile enables logging to a file that can be downloaded. // // Parameters: -// - args[0] - log level (int). -// - args[1] - log file name (string). -// - args[2] - max log file size, in bytes (int). +// - args[0] - Log level (int). +// - args[1] - Log file name (string). +// - args[2] - Max log file size, in bytes (int). // // Returns: -// - A Javascript representation of the LogFile object, which allows accessing -// the contents of the log file and other metadata. +// - A Javascript representation of the [LogFile] object, which allows +// accessing the contents of the log file and other metadata. func LogToFile(_ js.Value, args []js.Value) interface{} { threshold := jww.Threshold(args[0].Int()) if threshold < jww.LevelTrace || threshold > jww.LevelFatal { @@ -141,7 +141,7 @@ type logWriter struct { // Log returns a log message to pass to the log writer. // // Parameters: -// - s - log message (string). +// - s - Log message (string). func (lw *logWriter) Log(s string) { lw.log(s) } // RegisterLogWriter registers a callback on which logs are written. @@ -255,7 +255,7 @@ type LogFile struct { b *circbuf.Buffer } -// NewLogFile initialises a new LogFile for log writing. +// NewLogFile initialises a new [LogFile] for log writing. func NewLogFile( name string, threshold jww.Threshold, maxSize int) (*LogFile, error) { // Create new buffer of the specified size @@ -272,7 +272,7 @@ func NewLogFile( } // newLogFileJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the LogFile structure. +// (map[string]interface{}) that matches the [LogFile] structure. func newLogFileJS(lf *LogFile) map[string]interface{} { logFile := map[string]interface{}{ "Name": js.FuncOf(lf.Name), @@ -303,7 +303,7 @@ func (lf *LogFile) Name(js.Value, []js.Value) interface{} { return lf.name } -// Threshold returns the log level threshold used in the file +// Threshold returns the log level threshold used in the file. // // Returns: // - Log level (string). diff --git a/wasm/params.go b/wasm/params.go index 71c7331642a6411dfb56cacaa1bccfabb3259ddf..d3211cf5130716342b1d657251f494ae3831fd4f 100644 --- a/wasm/params.go +++ b/wasm/params.go @@ -60,7 +60,7 @@ func GetDefaultSingleUseParams(js.Value, []js.Value) interface{} { // modify the JSON to change single use settings. // // Returns: -// - JSON of [fileTransfer.e2e.Params] (Uint8Array). +// - JSON of [gitlab.com/elixxir/client/fileTransfer/e2e.Params] (Uint8Array). func GetDefaultE2eFileTransferParams(js.Value, []js.Value) interface{} { - return utils.CopyBytesToJS(bindings.GetDefaultSingleUseParams()) + return utils.CopyBytesToJS(bindings.GetDefaultE2eFileTransferParams()) } diff --git a/wasm/restlike.go b/wasm/restlike.go index 94c789b1a8a6852363d0e0afaf277264d7dff52b..1062c53755e04131ad5e6bb42de5fbdbe03ac5e0 100644 --- a/wasm/restlike.go +++ b/wasm/restlike.go @@ -18,14 +18,14 @@ import ( // RestlikeRequest performs a normal restlike request. // // Parameters: -// - args[0] - ID of Cmix object in tracker (int). -// - args[1] - ID of Connection object in tracker (int). +// - args[0] - ID of [Cmix] object in tracker (int). +// - args[1] - ID of [Connection] object in tracker (int). // - args[2] - JSON of [bindings.RestlikeMessage] (Uint8Array). // - args[3] - JSON of [xxdk.E2EParams] (Uint8Array). // // Returns a promise: // - Resolves to the JSON of the [bindings.RestlikeMessage], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). // - Rejected with an error if parsing the parameters or making the request // fails. @@ -51,14 +51,14 @@ func RestlikeRequest(_ js.Value, args []js.Value) interface{} { // RestlikeRequestAuth performs an authenticated restlike request. // // Parameters: -// - args[0] - ID of Cmix object in tracker (int). -// - args[1] - ID of AuthenticatedConnection object in tracker (int). +// - args[0] - ID of [Cmix] object in tracker (int). +// - args[1] - ID of [AuthenticatedConnection] object in tracker (int). // - args[2] - JSON of [bindings.RestlikeMessage] (Uint8Array). // - args[3] - JSON of [xxdk.E2EParams] (Uint8Array). // // Returns a promise: // - Resolves to the JSON of the [bindings.RestlikeMessage], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). // - Rejected with an error if parsing the parameters or making the request // fails. diff --git a/wasm/restlikeSingle.go b/wasm/restlikeSingle.go index 4c4c0584883424c3a751325863636af1443c14b5..643650454df6343523ad6be9a754a3c8fd80e95c 100644 --- a/wasm/restlikeSingle.go +++ b/wasm/restlikeSingle.go @@ -25,7 +25,7 @@ type restlikeCallback struct { // // Parameters: // - payload - JSON of [restlike.Message] (Uint8Array). -// - err - returns an error on failure (Error). +// - err - Returns an error on failure (Error). func (rlc *restlikeCallback) Callback(payload []byte, err error) { rlc.callback(utils.CopyBytesToJS(payload), utils.JsTrace(err)) } @@ -33,14 +33,15 @@ func (rlc *restlikeCallback) Callback(payload []byte, err error) { // RequestRestLike sends a restlike request to a given contact. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). -// - args[1] - marshalled recipient [contact.Contact] (Uint8Array). +// - args[0] - ID of [E2e] object in tracker (int). +// - args[1] - Marshalled bytes of the recipient [contact.Contact] +// (Uint8Array). // - args[2] - JSON of [bindings.RestlikeMessage] (Uint8Array). // - args[3] - JSON of [single.RequestParams] (Uint8Array). // // 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). +// [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // - Rejected with an error if parsing the parameters or making the request // fails. func RequestRestLike(_ js.Value, args []js.Value) interface{} { @@ -69,8 +70,9 @@ func RequestRestLike(_ js.Value, args []js.Value) interface{} { // response when received. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). -// - args[1] - marshalled recipient [contact.Contact] (Uint8Array). +// - args[0] - ID of [E2e] object in tracker (int). +// - args[1] - Marshalled bytes of the recipient [contact.Contact] +// (Uint8Array). // - args[2] - JSON of [bindings.RestlikeMessage] (Uint8Array). // - args[3] - JSON of [single.RequestParams] (Uint8Array). // - args[4] - Javascript object that has functions that implement the diff --git a/wasm/secrets.go b/wasm/secrets.go index cf7275efaa2dc01b26257868c60f27d05779317e..8f427b7193cbf9074ffbed266da4feb072a4c276 100644 --- a/wasm/secrets.go +++ b/wasm/secrets.go @@ -23,7 +23,7 @@ import ( // higher in certain cases, but not lower (int). // // Returns: -// - secret password (Uint8Array). +// - Secret password (Uint8Array). func GenerateSecret(_ js.Value, args []js.Value) interface{} { secret := bindings.GenerateSecret(args[0].Int()) return utils.CopyBytesToJS(secret) diff --git a/wasm/single.go b/wasm/single.go index dc10f071e4b0d6ca847dadfc5ff8bdb0bd3fd7b7..7ea91ec3b6bacf249410032dffbbdfe3285e96f6 100644 --- a/wasm/single.go +++ b/wasm/single.go @@ -22,18 +22,19 @@ import ( // TransmitSingleUse transmits payload to recipient via single-use. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). -// - args[1] - JSON of recipient [contact.Contact] (Uint8Array). -// - args[2] - tag that identifies the single-use message (string). -// - args[3] - message contents (Uint8Array). +// - 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 +// - 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: // - Resolves to the JSON of the [bindings.SingleUseSendReport], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). // - Rejected with an error if transmission fails. func TransmitSingleUse(_ js.Value, args []js.Value) interface{} { @@ -57,19 +58,19 @@ func TransmitSingleUse(_ js.Value, args []js.Value) interface{} { return utils.CreatePromise(promiseFn) } -// Listen starts a single-use listener on a given tag using the passed in E2e +// 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 +// - 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. +// - Javascript representation of the [Stopper] object, an interface containing +// a function used to stop the listener. // - Throws a TypeError if listening fails. func Listen(_ js.Value, args []js.Value) interface{} { cb := &singleUseCallback{utils.WrapCB(args[2], "Callback")} @@ -93,7 +94,7 @@ type Stopper struct { } // newStopperJS creates a new Javascript compatible object -// (map[string]interface{}) that matches the Stopper structure. +// (map[string]interface{}) that matches the [Stopper] structure. func newStopperJS(api bindings.Stopper) map[string]interface{} { s := Stopper{api} stopperMap := map[string]interface{}{ @@ -123,9 +124,9 @@ type singleUseCallback struct { // // Parameters: // - callbackReport - JSON of [bindings.SingleUseCallbackReport], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). -// - err - returns an error on failure (Error). +// - err - Returns an error on failure (Error). func (suc *singleUseCallback) Callback(callbackReport []byte, err error) { suc.callback(utils.CopyBytesToJS(callbackReport), utils.JsTrace(err)) } @@ -140,9 +141,9 @@ type singleUseResponse struct { // // Parameters: // - callbackReport - JSON of [bindings.SingleUseCallbackReport], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). -// - err - returns an error on failure (Error). +// - err - Returns an error on failure (Error). func (sur *singleUseResponse) Callback(responseReport []byte, err error) { sur.callback(utils.CopyBytesToJS(responseReport), utils.JsTrace(err)) } diff --git a/wasm/ud.go b/wasm/ud.go index d9fe247d5ca5d5f0f44489071fc47905072392b6..9a373d7656850d18d6f40743615c4f8ede90dc71 100644 --- a/wasm/ud.go +++ b/wasm/ud.go @@ -26,7 +26,7 @@ type UserDiscovery struct { } // newE2eJS creates a new Javascript compatible object (map[string]interface{}) -// that matches the E2e structure. +// that matches the [E2e] structure. func newUserDiscoveryJS(api *bindings.UserDiscovery) map[string]interface{} { ud := UserDiscovery{api} udMap := map[string]interface{}{ @@ -42,10 +42,10 @@ func newUserDiscoveryJS(api *bindings.UserDiscovery) map[string]interface{} { return udMap } -// GetID returns the ID for this UserDiscovery in the UserDiscovery tracker. +// GetID returns the ID for this [UserDiscovery] in the [UserDiscovery] tracker. // // Returns: -// - int +// - Tracker ID (int). func (ud *UserDiscovery) GetID(js.Value, []js.Value) interface{} { return ud.api.GetID() } @@ -76,28 +76,28 @@ func (uns *udNetworkStatus) UdNetworkStatus() int { // be pulled from the NDF using the bindings. // // Params -// - args[0] - ID of E2e object in tracker (int). +// - 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 +// - 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 +// - 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 +// - 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 [contact.Contact]. This represents the contact file -// of the server this call will connect with. You may use the UD server run -// by the xx network team by using E2e.GetUdContactFromNdf (Uint8Array). +// [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). +// [E2e.GetUdAddressFromNdf] (string). // // Returns: -// - Javascript representation of the UserDiscovery object that is registered +// - Javascript representation of the [UserDiscovery] object that is registered // to the specified UD service. // - Throws a TypeError if creating or loading fails. func NewOrLoadUd(_ js.Value, args []js.Value) interface{} { @@ -128,7 +128,7 @@ func NewOrLoadUd(_ js.Value, args []js.Value) interface{} { // an error. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). +// - 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]. @@ -138,19 +138,19 @@ func NewOrLoadUd(_ js.Value, args []js.Value) interface{} { // (Uint8Array). // - args[4] - JSON of [fact.Fact] phone number that is registered with UD // (Uint8Array). -// - args[5] - the TLS certificate for the UD server this call will connect +// - args[5] - 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[6] - marshalled [contact.Contact]. This represents the contact file -// of the server this call will connect with. You may use the UD server run -// by the xx network team by using E2e.GetUdContactFromNdf (Uint8Array). -// - args[7] - the IP address of the UD server this call will connect with. You +// [E2e.GetUdCertFromNdf] (Uint8Array). +// - args[6] - 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[7] - 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). +// [E2e.GetUdAddressFromNdf] (string). // // Returns: -// - Javascript representation of the UserDiscovery object that is loaded from -// backup. +// - Javascript representation of the [UserDiscovery] object that is loaded +// from backup. // - Throws a TypeError if getting UD from backup fails. func NewUdManagerFromBackup(_ js.Value, args []js.Value) interface{} { e2eID := args[0].Int() @@ -186,7 +186,7 @@ func (ud *UserDiscovery) GetFacts(js.Value, []js.Value) interface{} { // retrieved from the NDF. // // Returns: -// - JSON of [contact.Contact] (Uint8Array). +// - Marshalled bytes of [contact.Contact] (Uint8Array). // - Throws TypeError if getting the contact fails. func (ud *UserDiscovery) GetContact(js.Value, []js.Value) interface{} { c, err := ud.api.GetContact() @@ -203,8 +203,8 @@ func (ud *UserDiscovery) GetContact(js.Value, []js.Value) interface{} { // associated communications system. // // Parameters: -// - args[0] - confirmation ID (string). -// - args[1] - code (string). +// - args[0] - Confirmation ID (string). +// - args[1] - Code (string). // // Returns: // - Throws TypeError if confirming the fact fails. @@ -294,9 +294,9 @@ type udLookupCallback struct { // in ID. // // Parameters: -// - contactBytes - JSON of [contact.Contact] returned from the lookup, or nil -// if an error occurs (Uint8Array). -// - err - returns an error on failure (Error). +// - contactBytes - Marshalled bytes of the [contact.Contact] returned from the +// lookup, or nil if an error occurs (Uint8Array). +// - err - Returns an error on failure (Error). func (ulc *udLookupCallback) Callback(contactBytes []byte, err error) { ulc.callback(utils.CopyBytesToJS(contactBytes), utils.JsTrace(err)) } @@ -305,16 +305,18 @@ func (ulc *udLookupCallback) Callback(contactBytes []byte, err error) { // discovery system or returns by the timeout. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). -// - args[1] - JSON of User Discovery's [contact.Contact] (Uint8Array). +// - 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] - JSON of [id.ID] for the user to look up (Uint8Array). +// - 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: // - Resolves to the JSON of the [bindings.SingleUseSendReport], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). // - Rejected with an error if the lookup fails. func LookupUD(_ js.Value, args []js.Value) interface{} { @@ -353,7 +355,7 @@ type udSearchCallback struct { // Parameters: // - contactListJSON - JSON of an array of [contact.Contact], or nil if an // error occurs (Uint8Array). -// - err - returns any error that occurred in the search (Error). +// - err - Returns any error that occurred in the search (Error). // // JSON Example: // { @@ -372,14 +374,15 @@ func (usc *udSearchCallback) Callback(contactListJSON []byte, err error) { // where multiple pieces of information is known. // // Parameters: -// - args[0] - ID of E2e object in tracker (int). -// - args[1] - JSON of User Discovery's [contact.Contact] (Uint8Array). +// - args[0] - ID of [E2e] object in tracker (int). +// - args[1] - Marshalled bytes of the User Discovery's [contact.Contact] +// (Uint8Array). // - args[2] - JSON of [fact.FactList] (Uint8Array). // - args[4] - JSON of [single.RequestParams] (Uint8Array). // // Returns a promise: // - Resolves to the JSON of the [bindings.SingleUseSendReport], which can be -// passed into Cmix.WaitForRoundResult to see if the send succeeded +// passed into [Cmix.WaitForRoundResult] to see if the send succeeded // (Uint8Array). // - Rejected with an error if the search fails. func SearchUD(_ js.Value, args []js.Value) interface{} { diff --git a/wasm/version.go b/wasm/version.go index affd9d9419d4b861595cd70dfb98bde243b4c46c..3ae5b522e96a268f6a0d110998e4f41c331ebbbb 100644 --- a/wasm/version.go +++ b/wasm/version.go @@ -17,7 +17,7 @@ import ( // GetVersion returns the [xxdk.SEMVER]. // // Returns: -// - string +// - Version (string). func GetVersion(js.Value, []js.Value) interface{} { return bindings.GetVersion() } @@ -25,7 +25,7 @@ func GetVersion(js.Value, []js.Value) interface{} { // GetGitVersion returns the [xxdk.GITVERSION]. // // Returns: -// - string +// - Git version (string). func GetGitVersion(js.Value, []js.Value) interface{} { return bindings.GetGitVersion() } @@ -33,7 +33,7 @@ func GetGitVersion(js.Value, []js.Value) interface{} { // GetDependencies returns the [xxdk.DEPENDENCIES]. // // Returns: -// - string +// - Git dependencies (string). func GetDependencies(js.Value, []js.Value) interface{} { return bindings.GetDependencies() }