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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
e78effdb
Commit
e78effdb
authored
3 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
added auth callbacks to bindings
parent
68ea9755
No related branches found
No related tags found
2 merge requests
!510
Release
,
!238
Hotfix/e2e client
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/e2e.go
+51
-3
51 additions, 3 deletions
bindings/e2e.go
with
51 additions
and
3 deletions
bindings/e2e.go
+
51
−
3
View file @
e78effdb
...
...
@@ -6,7 +6,12 @@
package
bindings
import
"gitlab.com/elixxir/client/xxdk"
import
(
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/xxdk"
"gitlab.com/elixxir/crypto/contact"
)
// e2eTrackerSingleton is used to track E2e objects so that
// they can be referenced by id back over the bindings
...
...
@@ -26,7 +31,7 @@ type E2e struct {
// and adds it to the e2eTrackerSingleton
// identity can be left nil such that a new
// TransmissionIdentity will be created automatically
func
(
e
*
E2e
)
Login
(
cmixId
int
,
identity
[]
byte
)
(
*
E2e
,
error
)
{
func
(
e
*
E2e
)
Login
(
cmixId
int
,
callbacks
AuthCallbacks
,
identity
[]
byte
)
(
*
E2e
,
error
)
{
cmix
,
err
:=
cmixTrackerSingleton
.
get
(
cmixId
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -42,9 +47,52 @@ func (e *E2e) Login(cmixId int, identity []byte) (*E2e, error) {
}
}
newE2e
,
err
:=
xxdk
.
Login
(
cmix
.
api
,
nil
,
newIdentity
)
authCallbacks
:=
authCallback
{
bindingsCbs
:
callbacks
}
newE2e
,
err
:=
xxdk
.
Login
(
cmix
.
api
,
authCallbacks
,
newIdentity
)
if
err
!=
nil
{
return
nil
,
err
}
return
e2eTrackerSingleton
.
make
(
newE2e
),
nil
}
// AuthCallbacks is the bindings-specific interface for auth.Callbacks methods.
type
AuthCallbacks
interface
{
Request
(
contact
,
receptionId
[]
byte
,
ephemeralId
,
roundId
uint64
)
Confirm
(
contact
,
receptionId
[]
byte
,
ephemeralId
,
roundId
uint64
)
Reset
(
contact
,
receptionId
[]
byte
,
ephemeralId
,
roundId
uint64
)
}
// authCallback implements AuthCallbacks
type
authCallback
struct
{
bindingsCbs
AuthCallbacks
}
// convertAuthCallbacks turns an auth.Callbacks into an AuthCallbacks
func
convertAuthCallbacks
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
(
contact
[]
byte
,
receptionId
[]
byte
,
ephemeralId
uint64
,
roundId
uint64
)
{
contact
=
requestor
.
Marshal
()
receptionId
=
receptionID
.
Source
.
Marshal
()
ephemeralId
=
receptionID
.
EphId
.
UInt64
()
roundId
=
uint64
(
round
.
ID
)
return
}
// 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
))
}
// 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
))
}
// Reset will be called when an auth Reset operation occurs.
func
(
a
authCallback
)
Reset
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
a
.
bindingsCbs
.
Reset
(
convertAuthCallbacks
(
requestor
,
receptionID
,
round
))
}
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