diff --git a/backup/backup.go b/backup/backup.go index d4cc92a408a48cd809b30a93f25bb9ea93b02e59..b7fc57f5e3d46cb4e17277cc2d236b146cffd74f 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -93,6 +93,7 @@ type UpdateBackupFn func(encryptedBackup []byte) func InitializeBackup(backupPassphrase string, updateBackupCb UpdateBackupFn, container *xxdk.Container, e2e E2e, session Session, ud UserDiscovery, kv *versioned.KV, rng *fastRNG.StreamGenerator) (*Backup, error) { + b := &Backup{ updateBackupCb: updateBackupCb, container: container, diff --git a/backup/backupRestore.go b/backup/backupRestore.go index 6be4fd04620c011b8d3c318471e4aef04d86b700..2d408c173b49cd1a82d824b480bb3c2c47fcddce 100644 --- a/backup/backupRestore.go +++ b/backup/backupRestore.go @@ -92,6 +92,7 @@ func NewCmixFromBackup(ndfJSON, storageDir, backupPassphrase string, phone = f } } + err = ud.InitStoreFromBackup(storageSess.GetKV(), username, email, phone) return backUp.Contacts.Identities, backUp.JSONParams, err } diff --git a/bindings/ud.go b/bindings/ud.go index 976321c5b33b5fd964b37dfd4c3aa5e97be66cac..ee7774cbebf2ab4523aaa713c3e0d6912e94ac27 100644 --- a/bindings/ud.go +++ b/bindings/ud.go @@ -203,29 +203,23 @@ func NewOrLoadUd(e2eID int, follower UdNetworkStatus, username string, } // NewUdManagerFromBackup builds a new user discover manager from a backup. It -// will construct a manager that is already registered and restore already -// registered facts into store. +// will construct a manager that is already registered. Confirmed facts have +// already been restored via the call NewCmixFromBackup. // // Parameters: // - e2eID - e2e object ID in the tracker // - follower - network follower func wrapped in UdNetworkStatus -// - username - The username this user registered with initially. This should -// not be nullable, and be JSON marshalled as retrieved from -// UserDiscovery.GetFacts(). -// - emailFactJson - nullable JSON marshalled email [fact.Fact] -// - phoneFactJson - nullable JSON marshalled phone [fact.Fact] // - cert - the TLS certificate for the UD server this call will connect with. // You may use the UD server run by the xx network team by using -// E2e.GetUdCertFromNdf. -// - contactFile - the data within a marshalled contact.Contact. This +// [E2e.GetUdCertFromNdf]. +// - contactFile - the data within a marshalled [contact.Contact]. This // represents the contact file of the server this call will connect with. You // may use the UD server run by the xx network team by using -// E2e.GetUdContactFromNdf. +// [E2e.GetUdContactFromNdf]. // - address - the IP address of the UD server this call will connect with. You // may use the UD server run by the xx network team by using -// E2e.GetUdAddressFromNdf. +// [E2e.GetUdAddressFromNdf]. func NewUdManagerFromBackup(e2eID int, follower UdNetworkStatus, - usernameJson, emailFactJson, phoneFactJson, cert, contactFile []byte, address string) (*UserDiscovery, error) { // Get user from singleton @@ -234,38 +228,12 @@ func NewUdManagerFromBackup(e2eID int, follower UdNetworkStatus, return nil, err } - var email, phone, username fact.Fact - - // Parse email if non-nil - if emailFactJson != nil { - err = json.Unmarshal(emailFactJson, &email) - if err != nil { - return nil, err - } - } - - // Parse phone if non-nil - if phoneFactJson != nil { - err = json.Unmarshal(phoneFactJson, &phone) - if err != nil { - return nil, err - } - } - - // Parse username - err = json.Unmarshal(usernameJson, &username) - if err != nil { - return nil, err - } - UdNetworkStatusFn := func() xxdk.Status { return xxdk.Status(follower.UdNetworkStatus()) } - u, err := ud.NewManagerFromBackup( - user.api, user.api.GetComms(), UdNetworkStatusFn, - username, email, phone, - cert, contactFile, address) + u, err := ud.NewManagerFromBackup(user.api, user.api.GetComms(), + UdNetworkStatusFn, cert, contactFile, address) if err != nil { return nil, err } diff --git a/ud/manager.go b/ud/manager.go index 89edc765fa7820e761dd824b56dd4fb85cfdec4a..75604bd3ddee8848a23179c645742ea735ff3f16 100644 --- a/ud/manager.go +++ b/ud/manager.go @@ -125,12 +125,8 @@ func NewOrLoad(user udE2e, comms Comms, follower udNetworkStatus, // - user is an interface that adheres to the xxdk.E2e object. // - comms is an interface that adheres to client.Comms object. // - follower is a method off of xxdk.Cmix which returns the network follower's status. -// - username is the name of the user as it is registered with UD. This will be what the end user -// provides if through the bindings. // - networkValidationSig is a signature provided by the network (i.e. the client registrar). This may // be nil, however UD may return an error in some cases (e.g. in a production level environment). -// - email is a fact.Fact (type Email) which has been registered with UD already. -// - phone is a fact.Fact (type Phone) which has been registered with UD already. // - cert is the TLS certificate for the UD server this call will connect with. // - contactFile is the data within a marshalled contact.Contact. This represents the // contact file of the server this call will connect with. @@ -138,9 +134,9 @@ func NewOrLoad(user udE2e, comms Comms, follower udNetworkStatus, // // Returns // - A Manager object which is registered to the specified UD service. -func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus, - username, email, phone fact.Fact, - cert, contactFile []byte, address string) (*Manager, error) { +func NewManagerFromBackup(user udE2e, comms Comms, + follower udNetworkStatus, cert, contactFile []byte, + address string) (*Manager, error) { jww.INFO.Println("ud.NewManagerFromBackup()") if follower() != xxdk.Running { return nil, errors.New( @@ -161,13 +157,6 @@ func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus, return nil, err } - // Put any passed in missing facts into store - err = m.store.BackUpMissingFacts(username, email, phone) - if err != nil { - return nil, errors.WithMessage(err, "Failed to restore UD store "+ - "from backup") - } - // Set as registered. Since it's from a backup, // the user is already registered if err = setRegistered(m.getKv()); err != nil {