Skip to content
Snippets Groups Projects
Commit 2c455bae authored by Jono Wenger's avatar Jono Wenger
Browse files

Merge remote-tracking branch 'origin/release' into project/adminCommands

# Conflicts:
#	go.mod
#	go.sum
parents 314d902b ce9b0758
No related branches found
No related tags found
2 merge requests!60Revert "Fail a test to be sure it works",!32Admin Commands
......@@ -7,8 +7,8 @@ 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/v4 v4.3.9-0.20221201224548-883cf51c4d60
gitlab.com/elixxir/crypto v0.0.7-0.20221121233335-83f145891bc7
gitlab.com/elixxir/client/v4 v4.3.9-0.20221202021328-118de4434344
gitlab.com/elixxir/crypto v0.0.7-0.20221202020255-46eeab272a7f
gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af
gitlab.com/xx_network/crypto v0.0.5-0.20221121220724-8eefdbb0eb46
gitlab.com/xx_network/primitives v0.0.4-0.20221110180011-fd6ea3058225
......
......@@ -369,12 +369,12 @@ 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/v4 v4.3.9-0.20221201224548-883cf51c4d60 h1:fZLbgqE4Lskkao4MQzxCBGVN+GuJfBy7/BtxG/xkaTw=
gitlab.com/elixxir/client/v4 v4.3.9-0.20221201224548-883cf51c4d60/go.mod h1:e2EC5b3ucHaVeR9DjGcoKNnDBbVPPPG2dHtpPGDrFhM=
gitlab.com/elixxir/client/v4 v4.3.9-0.20221202021328-118de4434344 h1:iUAwK+Ti3VObJy5mXG5/CfMoOs05oMi30XUMJIG1XTI=
gitlab.com/elixxir/client/v4 v4.3.9-0.20221202021328-118de4434344/go.mod h1:6zBHVEOwB42N3Ba3879GW0huu595RLSar04KlNsa7QE=
gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4 h1:bLRjVCyMVde4n2hTVgoyyIAWrKI4CevpChchkPeb6A0=
gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4/go.mod h1:XhI2/CMng+xcH3mAs+1aPz29PSNu1079XMJ8V+xxihw=
gitlab.com/elixxir/crypto v0.0.7-0.20221121233335-83f145891bc7 h1:yhc8jQ27JKypdRE41NpfJPaYRS0sNkOwugaIyoscDiU=
gitlab.com/elixxir/crypto v0.0.7-0.20221121233335-83f145891bc7/go.mod h1:oRh3AwveOEvpk9E3kRcMGK8fImcEnN0PY4jr9HDgQE8=
gitlab.com/elixxir/crypto v0.0.7-0.20221202020255-46eeab272a7f h1:e7h3InxgzRnYOqgUgHrTfK6CW8qNM2SiYRj9tOvsFjA=
gitlab.com/elixxir/crypto v0.0.7-0.20221202020255-46eeab272a7f/go.mod h1:oRh3AwveOEvpk9E3kRcMGK8fImcEnN0PY4jr9HDgQE8=
gitlab.com/elixxir/ekv v0.2.1 h1:dtwbt6KmAXG2Tik5d60iDz2fLhoFBgWwST03p7T+9Is=
gitlab.com/elixxir/ekv v0.2.1/go.mod h1:USLD7xeDnuZEavygdrgzNEwZXeLQJK/w1a+htpN+JEU=
gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af h1:xcPqknK1ehNb9xwcutTdoR0YgD7DC/ySh9z49tIpSxQ=
......
......@@ -1708,6 +1708,8 @@ func newChannelDbCipherJS(api *bindings.ChannelDbCipher) map[string]any {
"GetID": js.FuncOf(c.GetID),
"Encrypt": js.FuncOf(c.Encrypt),
"Decrypt": js.FuncOf(c.Decrypt),
"MarshalJSON": js.FuncOf(c.MarshalJSON),
"UnmarshalJSON": js.FuncOf(c.UnmarshalJSON),
}
return channelDbCipherMap
......@@ -1762,7 +1764,6 @@ func (c *ChannelDbCipher) GetID(js.Value, []js.Value) any {
// - The ciphertext of the plaintext passed in (Uint8Array).
// - Throws a TypeError if it fails to encrypt the plaintext.
func (c *ChannelDbCipher) Encrypt(_ js.Value, args []js.Value) any {
ciphertext, err := c.api.Encrypt(utils.CopyBytesToGo(args[0]))
if err != nil {
utils.Throw(utils.TypeError, err)
......@@ -1770,7 +1771,6 @@ func (c *ChannelDbCipher) Encrypt(_ js.Value, args []js.Value) any {
}
return utils.CopyBytesToJS(ciphertext)
}
// Decrypt will decrypt the passed in encrypted value. The plaintext will be
......@@ -1792,5 +1792,40 @@ func (c *ChannelDbCipher) Decrypt(_ js.Value, args []js.Value) any {
}
return utils.CopyBytesToJS(plaintext)
}
// MarshalJSON marshals the cipher into valid JSON.
//
// Returns:
// - JSON of the cipher (Uint8Array).
// - Throws a TypeError if marshalling fails.
func (c *ChannelDbCipher) MarshalJSON(js.Value, []js.Value) any {
data, err := c.api.MarshalJSON()
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
return utils.CopyBytesToJS(data)
}
// UnmarshalJSON unmarshalls JSON into the cipher. This function adheres to the
// json.Unmarshaler interface.
//
// Note that this function does not transfer the internal RNG. Use
// [channel.NewCipherFromJSON] to properly reconstruct a cipher from JSON.
//
// Parameters:
// - args[0] - JSON data to unmarshal (Uint8Array).
//
// Returns:
// - JSON of the cipher (Uint8Array).
// - Throws a TypeError if marshalling fails.
func (c *ChannelDbCipher) UnmarshalJSON(_ js.Value, args []js.Value) any {
err := c.api.UnmarshalJSON(utils.CopyBytesToGo(args[0]))
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment