Skip to content
Snippets Groups Projects
Commit 4db6edd7 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add NewSynchronizedCmix

parent 28b30a5f
No related branches found
No related tags found
1 merge request!109Project/haven beta
......@@ -9,7 +9,7 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/jwalterweatherman v1.1.0
github.com/stretchr/testify v1.8.2
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530170051-243baab3da48
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530182422-d12ab437257f
gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235
gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c
gitlab.com/elixxir/wasm-utils v0.0.0-20230522231408-a43b2c1481b2
......
......@@ -521,6 +521,8 @@ gitlab.com/elixxir/client/v4 v4.6.4-0.20230530165750-f6ea41bc69e4 h1:dgq4fwLdVzs
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530165750-f6ea41bc69e4/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530170051-243baab3da48 h1:2HP8w4HOlqjg0FcvSnhMmpwUa1pcU0WbvWMOUNiy/hE=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530170051-243baab3da48/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530182422-d12ab437257f h1:8TJwqKjeD0eZSvWIlPwjgIwfgdzcHhTzGwaiUJCwwuI=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530182422-d12ab437257f/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938 h1:f27+QUFiGWrprKm+fstOg3ABkYLpWcZi3+8Lf5eDnqY=
gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938/go.mod h1:z+qW0D9VpY5QKTd7wRlb5SK4kBNqLYsa4DXBcUXue9Q=
gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235 h1:0BySdXTzRWxzH8k5RiNNMmmn2lpuQWLVcDDA/7ehyqc=
......
......@@ -156,6 +156,8 @@ func setGlobals() {
// wasm/cmix.go
js.Global().Set("NewCmix", js.FuncOf(wasm.NewCmix))
js.Global().Set("NewSynchronizedCmix",
js.FuncOf(wasm.NewSynchronizedCmix))
js.Global().Set("LoadCmix", js.FuncOf(wasm.LoadCmix))
js.Global().Set("LoadSynchronizedCmix",
js.FuncOf(wasm.LoadSynchronizedCmix))
......
......@@ -110,6 +110,38 @@ func NewCmix(_ js.Value, args []js.Value) any {
return utils.CreatePromise(promiseFn)
}
// NewSynchronizedCmix clones a cMix from remote storage.
//
// Users of this function should delete the storage directory on error.
//
// Parameters:
// - args[0] - NDF JSON ([ndf.NetworkDefinition]) (string).
// - args[1] - Storage directory path (string).
// - args[2] - Password used for storage (Uint8Array).
// - args[3] - Javascript [RemoteStore] implementation.
//
// Returns a promise:
// - Resolves on success.
// - Rejected with an error if creating a new cMix client fails.
func NewSynchronizedCmix(_ js.Value, args []js.Value) any {
ndfJSON := args[0].String()
storageDir := args[1].String()
password := utils.CopyBytesToGo(args[2])
rs := newRemoteStore(args[3])
promiseFn := func(resolve, reject func(args ...any) js.Value) {
err := bindings.NewSynchronizedCmix(ndfJSON, storageDir,
password, rs)
if err != nil {
reject(exception.NewTrace(err))
} else {
resolve()
}
}
return utils.CreatePromise(promiseFn)
}
// LoadCmix will load an existing user storage from the storageDir using the
// password. This will fail if the user storage does not exist or the password
// is incorrect.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment