Newer
Older
////////////////////////////////////////////////////////////////////////////////
// //
// Use of this source code is governed by a license that can be found in the //
////////////////////////////////////////////////////////////////////////////////
//go:build js && wasm

Richard T. Carback III
committed
"gitlab.com/elixxir/client/v4/bindings"
"syscall/js"
)
// DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL.
// The NDF is processed into a protobuf containing a signature that is verified
// using the cert string passed in. The NDF is returned as marshaled byte data
// that may be used to start a client.
//
// Parameters:
// - args[0] - The URL to download from (string).
// - args[1] - The NDF certificate (string).
// - Resolves to the JSON of the NDF ([ndf.NetworkDefinition]) (Uint8Array).
// - Rejected with an error if downloading fails.
func DownloadAndVerifySignedNdfWithUrl(_ js.Value, args []js.Value) any {
promiseFn := func(resolve, reject func(args ...any) js.Value) {
ndf, err := bindings.DownloadAndVerifySignedNdfWithUrl(url, cert)
if err != nil {
reject(utils.JsTrace(err))
} else {
resolve(utils.CopyBytesToJS(ndf))
}