Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
dfd866e6
Commit
dfd866e6
authored
Jun 28, 2022
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Update bindings to use new auth callback interface
parent
6c766e22
No related branches found
No related tags found
2 merge requests
!510
Release
,
!253
General Cleanup
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bindings/cmix.go
+2
-1
2 additions, 1 deletion
bindings/cmix.go
bindings/e2e.go
+29
-23
29 additions, 23 deletions
bindings/e2e.go
bindings/e2eAuth.go
+4
-1
4 additions, 1 deletion
bindings/e2eAuth.go
with
35 additions
and
25 deletions
bindings/cmix.go
+
2
−
1
View file @
dfd866e6
...
...
@@ -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
.
GetDefault
CMix
Params
())
if
err
!=
nil
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"Failed to login: %+v"
,
err
))
}
...
...
This diff is collapsed.
Click to expand it.
bindings/e2e.go
+
29
−
23
View file @
dfd866e6
...
...
@@ -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
))
}
This diff is collapsed.
Click to expand it.
bindings/e2eAuth.go
+
4
−
1
View file @
dfd866e6
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment