From d95902f293f123f94640d3c694a9f8ebe6f772d6 Mon Sep 17 00:00:00 2001 From: josh <josh@elixxir.io> Date: Mon, 18 Oct 2021 09:20:25 -0700 Subject: [PATCH] Reintegrate old unsafe Login --- api/client.go | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/api/client.go b/api/client.go index a6cf414bc..31933912c 100644 --- a/api/client.go +++ b/api/client.go @@ -306,7 +306,66 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie // LoginWithNewBaseNDF_UNSAFE initializes a client object from existing storage // while replacing the base NDF. This is designed for some specific deployment // procedures and is generally unsafe. -func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte, protoClientJSON []byte, +func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte, + newBaseNdf string, parameters params.Network) (*Client, error) { + jww.INFO.Printf("LoginWithNewBaseNDF_UNSAFE()") + + // Parse the NDF + def, err := parseNDF(newBaseNdf) + if err != nil { + return nil, err + } + + //Open the client + c, err := OpenClient(storageDir, password, parameters) + + if err != nil { + return nil, err + } + + //initialize comms + err = c.initComms() + if err != nil { + return nil, err + } + + //store the updated base NDF + c.storage.SetNDF(def) + + //initialize registration + if def.Registration.Address != "" { + err = c.initPermissioning(def) + if err != nil { + return nil, err + } + } else { + jww.WARN.Printf("Registration with permissioning skipped due to " + + "blank permissionign address. Client will not be able to register " + + "or track network.") + } + + // Initialize network and link it to context + c.network, err = network.NewManager(c.storage, c.switchboard, c.rng, + c.events, c.comms, parameters, def) + if err != nil { + return nil, err + } + + // initialize the auth tracker + c.auth = auth.NewManager(c.switchboard, c.storage, c.network) + + err = c.registerFollower() + if err != nil { + return nil, err + } + + return c, nil +} + +// LoginWithProtoClient creates a client object with a protoclient JSON containing the +// cryptographic primitives. This is designed for some specific deployment +//// procedures and is generally unsafe. +func LoginWithProtoClient(storageDir string, password []byte, protoClientJSON []byte, newBaseNdf string, parameters params.Network) (*Client, error) { jww.INFO.Printf("LoginWithNewBaseNDF_UNSAFE()") -- GitLab