diff --git a/bindings/cmix.go b/bindings/cmix.go index 2003f7c2fa876a091325fdd5b1f04a3bc710de98..bed5669b14e912f635aed5e494975661e05ef2f1 100644 --- a/bindings/cmix.go +++ b/bindings/cmix.go @@ -2,6 +2,7 @@ package bindings import ( "fmt" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/xxdk" @@ -50,7 +51,7 @@ func NewKeystore(network, storageDir string, password []byte, regCode string) er // starts subprocesses to perform network operations. // TODO: add in custom parameters instead of the default func Login(storageDir string, password []byte) (*Cmix, error) { - client, err := xxdk.LoadCmix(storageDir, password, xxdk.GetDefaultParams()) + client, err := xxdk.LoadCmix(storageDir, password, xxdk.GetDefaultCMixParams()) if err != nil { return nil, errors.New(fmt.Sprintf("Failed to login: %+v", err)) } diff --git a/bindings/e2e.go b/bindings/e2e.go index 289de4218cad4a4fd485b3524826e0f702e05f3c..55ee801ad44d087a07ad95fa4112389bb7c5ebd5 100644 --- a/bindings/e2e.go +++ b/bindings/e2e.go @@ -8,6 +8,7 @@ package bindings import ( "encoding/json" + "gitlab.com/elixxir/client/auth" "gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/rounds" @@ -51,12 +52,7 @@ func LoginE2e(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error return nil, err } - var authCallbacks auth.Callbacks - if callbacks == nil { - authCallbacks = auth.DefaultAuthCallbacks{} - } else { - authCallbacks = &authCallback{bindingsCbs: callbacks} - } + authCallbacks := &authCallback{bindingsCbs: callbacks} newE2e, err := xxdk.Login(cmix.api, authCallbacks, newIdentity) if err != nil { @@ -79,12 +75,7 @@ func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity []byte) (*E return nil, err } - var authCallbacks auth.Callbacks - if callbacks == nil { - authCallbacks = auth.DefaultAuthCallbacks{} - } else { - authCallbacks = &authCallback{bindingsCbs: callbacks} - } + authCallbacks := &authCallback{bindingsCbs: callbacks} newE2e, err := xxdk.LoginEphemeral(cmix.api, authCallbacks, newIdentity) if err != nil { @@ -104,12 +95,7 @@ func LoginE2eLegacy(cmixId int, callbacks AuthCallbacks) (*E2e, error) { return nil, err } - var authCallbacks auth.Callbacks - if callbacks == nil { - authCallbacks = auth.DefaultAuthCallbacks{} - } else { - authCallbacks = &authCallback{bindingsCbs: callbacks} - } + authCallbacks := &authCallback{bindingsCbs: callbacks} newE2e, err := xxdk.LoginLegacy(cmix.api, authCallbacks) if err != nil { @@ -181,18 +167,38 @@ func convertAuthCallbacks(requestor contact.Contact, // Confirm will be called when an auth Confirm message is processed. func (a *authCallback) Confirm(requestor contact.Contact, - receptionID receptionID.EphemeralIdentity, round rounds.Round) { - a.bindingsCbs.Confirm(convertAuthCallbacks(requestor, receptionID, round)) + receptionID receptionID.EphemeralIdentity, round rounds.Round, + e2e *xxdk.E2e) { + if a.bindingsCbs == nil { + auth.DefaultAuthCallbacks{}.Confirm(requestor, receptionID, + round) + return + } + a.bindingsCbs.Confirm(convertAuthCallbacks(requestor, receptionID, + round)) } // Request will be called when an auth Request message is processed. func (a *authCallback) Request(requestor contact.Contact, - receptionID receptionID.EphemeralIdentity, round rounds.Round) { - a.bindingsCbs.Request(convertAuthCallbacks(requestor, receptionID, round)) + receptionID receptionID.EphemeralIdentity, round rounds.Round, + e2e *xxdk.E2e) { + if a.bindingsCbs == nil { + auth.DefaultAuthCallbacks{}.Request(requestor, receptionID, + round) + return + } + a.bindingsCbs.Request(convertAuthCallbacks(requestor, receptionID, + round)) } // Reset will be called when an auth Reset operation occurs. func (a *authCallback) Reset(requestor contact.Contact, - receptionID receptionID.EphemeralIdentity, round rounds.Round) { + receptionID receptionID.EphemeralIdentity, round rounds.Round, + e2e *xxdk.E2e) { + if a.bindingsCbs == nil { + auth.DefaultAuthCallbacks{}.Reset(requestor, receptionID, + round) + return + } a.bindingsCbs.Reset(convertAuthCallbacks(requestor, receptionID, round)) } diff --git a/bindings/e2eAuth.go b/bindings/e2eAuth.go index b483671d90d3deb616bc0bd2e13018882e859ec1..fb21ad2d0f7de4345479b0681e6c56ee2d641598 100644 --- a/bindings/e2eAuth.go +++ b/bindings/e2eAuth.go @@ -8,6 +8,7 @@ package bindings import ( + "gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/primitives/fact" "gitlab.com/xx_network/primitives/id" @@ -215,7 +216,9 @@ func (e *E2e) AddPartnerCallback(partnerID []byte, cb AuthCallbacks) error { return err } - e.api.GetAuth().AddPartnerCallback(partnerId, &authCallback{bindingsCbs: cb}) + acw := xxdk.MakeAuthCB(e.api, &authCallback{bindingsCbs: cb}) + + e.api.GetAuth().AddPartnerCallback(partnerId, acw) return nil }