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

Make NewChannelsManagerWithIndexedDb use the public key as its codename

parent cbe512fe
No related branches found
No related tags found
2 merge requests!60Revert "Fail a test to be sure it works",!8Updates to match the client fullyDecentrilizedChannels branch
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
package wasm package wasm
import ( import (
"encoding/base64"
"gitlab.com/elixxir/crypto/channel"
"syscall/js" "syscall/js"
"gitlab.com/elixxir/client/bindings" "gitlab.com/elixxir/client/bindings"
...@@ -184,7 +186,6 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} { ...@@ -184,7 +186,6 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} {
// using [Cmix.GetID]. // using [Cmix.GetID].
// - args[1] - Bytes of a private identity ([channel.PrivateIdentity]) that is // - args[1] - Bytes of a private identity ([channel.PrivateIdentity]) that is
// generated by [GenerateChannelIdentity] (Uint8Array). // generated by [GenerateChannelIdentity] (Uint8Array).
// - args[2] - Username (string).
// //
// Returns: // Returns:
// - Javascript representation of the [ChannelsManager] object. // - Javascript representation of the [ChannelsManager] object.
...@@ -192,7 +193,16 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} { ...@@ -192,7 +193,16 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} {
// manager fails. // manager fails.
func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} { func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
privateIdentity := utils.CopyBytesToGo(args[1]) privateIdentity := utils.CopyBytesToGo(args[1])
em, err := indexedDb.NewWasmEventModel(args[2].String())
// Get the public key to use as a key for indexedDb
pi, err := channel.UnmarshalPrivateIdentity(privateIdentity)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
key := base64.StdEncoding.EncodeToString(pi.Identity.PubKey)
em, err := indexedDb.NewWasmEventModel(key)
if err != nil { if err != nil {
utils.Throw(utils.TypeError, err) 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