diff --git a/go.mod b/go.mod index 9f0fa8826937a5ffa41bf934cbb6ab8c398064c3..24f71d5f7a4a7c6d79ac846c000543fabfee1719 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/hack-pad/go-indexeddb v0.2.0 github.com/pkg/errors v0.9.1 github.com/spf13/jwalterweatherman v1.1.0 - gitlab.com/elixxir/client v1.5.1-0.20221022003714-8980452f25e5 + gitlab.com/elixxir/client v1.5.1-0.20221022020343-af368242bb1e gitlab.com/elixxir/crypto v0.0.7-0.20221022003355-d8a6158b32a7 gitlab.com/elixxir/primitives v0.0.3-0.20221017172918-6176818d1aba gitlab.com/xx_network/crypto v0.0.5-0.20221017172404-b384a8d8b171 diff --git a/go.sum b/go.sum index 9ac20560b7d4e69c4029a5a9b2627379b5d6c9e0..1ab9e902391102d9cbac2c86292ca3dc6bebbcb2 100644 --- a/go.sum +++ b/go.sum @@ -616,8 +616,8 @@ github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f h1:yXGvNBqzZwAhDYlSnxPRbgor6JWoOt1Z7s3z1O9JR40= gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k= -gitlab.com/elixxir/client v1.5.1-0.20221022003714-8980452f25e5 h1:8SsC+GZYTZBDMn47OpSBc1kRVvFpx0IYZG6B8sL9BzU= -gitlab.com/elixxir/client v1.5.1-0.20221022003714-8980452f25e5/go.mod h1:a5pLHWVKdwacbyL9yGlV/xP5xHbhC2ycqTbEsDyzjo4= +gitlab.com/elixxir/client v1.5.1-0.20221022020343-af368242bb1e h1:30XqsYQCvNarkq9GT3wm9UL/o00VPcPzi5hKvha5e4M= +gitlab.com/elixxir/client v1.5.1-0.20221022020343-af368242bb1e/go.mod h1:a5pLHWVKdwacbyL9yGlV/xP5xHbhC2ycqTbEsDyzjo4= gitlab.com/elixxir/comms v0.0.4-0.20221017173926-4eaa6061dfaa h1:/FEpu0N0rAyq74FkvO3uY8BcQoWLSbVPhj/s5QfscZw= gitlab.com/elixxir/comms v0.0.4-0.20221017173926-4eaa6061dfaa/go.mod h1:rW7xdbHntP2MoF3q+2+f+IR8OHol94MRyviotfR5rXg= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= diff --git a/wasm/channels.go b/wasm/channels.go index 8391e2fcbd45b61d3e27da78dc33506965041d06..6b0f3fb200af867fbd3474cce7d4ba5ef74011fd 100644 --- a/wasm/channels.go +++ b/wasm/channels.go @@ -1290,6 +1290,7 @@ type ChannelDbCipher struct { func newChannelDbCipherJS(api *bindings.ChannelDbCipher) map[string]interface{} { c := ChannelDbCipher{api} channelDbCipherMap := map[string]interface{}{ + "GetID": js.FuncOf(c.GetID), "Encrypt": js.FuncOf(c.Encrypt), "Decrypt": js.FuncOf(c.Decrypt), } @@ -1303,12 +1304,12 @@ func newChannelDbCipherJS(api *bindings.ChannelDbCipher) map[string]interface{} // - args[0] - The tracked [Cmix] object ID (int). // - args[1] - The password for storage. This should be the same password // passed into [NewCmix] (Uint8Array). -// - args[2] - The maximum size of a payload to be encrypted. -// A payload passed into [ChannelDbCipher.Encrypt] that is larger than -// this value will result in an error (int). +// - args[2] - The maximum size of a payload to be encrypted. A payload passed +// into [ChannelDbCipher.Encrypt] that is larger than this value will result +// in an error (int). // // Returns: -// - A JavaScript representation of the [ChannelDbCipher]. +// - JavaScript representation of the [ChannelDbCipher] object. // - Throws a TypeError if creating the cipher fails. func NewChannelsDatabaseCipher(_ js.Value, args []js.Value) interface{} { cmixId := args[0].Int() @@ -1325,13 +1326,22 @@ func NewChannelsDatabaseCipher(_ js.Value, args []js.Value) interface{} { return newChannelDbCipherJS(cipher) } +// GetID returns the ID for this [bindings.ChannelDbCipher] in the +// channelDbCipherTracker. +// +// Returns: +// - Tracker ID (int). +func (c *ChannelDbCipher) GetID(js.Value, []js.Value) interface{} { + return c.api.GetID() +} + // Encrypt will encrypt the raw data. It will return a ciphertext. Padding is // done on the plaintext so all encrypted data looks uniform at rest. // // Parameters: -// - args[0] - The data to be encrypted (Uint8Array). This must be smaller than the block -// size passed into [NewChannelsDatabaseCipher]. If it is larger, this will -// return an error. +// - args[0] - The data to be encrypted (Uint8Array). This must be smaller than +// the block size passed into [NewChannelsDatabaseCipher]. If it is larger, +// this will return an error. // // Returns: // - The ciphertext of the plaintext passed in (Uint8Array). @@ -1348,9 +1358,9 @@ func (c *ChannelDbCipher) Encrypt(_ js.Value, args []js.Value) interface{} { } -// Decrypt will decrypt the passed in encrypted value. The plaintext will -// be returned by this function. Any padding will be discarded within -// this function. +// Decrypt will decrypt the passed in encrypted value. The plaintext will be +// returned by this function. Any padding will be discarded within this +// function. // // Parameters: // - args[0] - the encrypted data returned by [ChannelDbCipher.Encrypt] diff --git a/wasm_test.go b/wasm_test.go index 1b25d22270e75984c19ee41beeaf0e9a455df33e..55a5e6b5081f4d011657b3c94e23a047b1e265f1 100644 --- a/wasm_test.go +++ b/wasm_test.go @@ -25,9 +25,10 @@ func TestPublicFunctions(t *testing.T) { // not implemented. excludeList := map[string]struct{}{ // Notifications are not available in the browser - "GetNotificationsReport": {}, - "RegisterForNotifications": {}, - "UnregisterForNotifications": {}, + "GetNotificationsReport": {}, + "RegisterForNotifications": {}, + "UnregisterForNotifications": {}, + "GetChannelDbCipherTrackerFromID": {}, // UD not available in the browser "IsRegisteredWithUD": {},