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
d2fe0add
Commit
d2fe0add
authored
Feb 25, 2022
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add ResetSession and associated callback to bindings
parent
496edd9f
No related branches found
No related tags found
2 merge requests
!231
Revert "Update store to print changes to the partners list"
,
!171
RestoreContactsFromBackup
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/authenticatedChannels.go
+31
-4
31 additions, 4 deletions
bindings/authenticatedChannels.go
bindings/callback.go
+6
-0
6 additions, 0 deletions
bindings/callback.go
with
37 additions
and
4 deletions
bindings/authenticatedChannels.go
+
31
−
4
View file @
d2fe0add
...
...
@@ -58,16 +58,44 @@ func (c *Client) RequestAuthenticatedChannel(recipientMarshaled,
return
int
(
rid
),
err
}
// RegisterAuthCallbacks registers both callbacks for authenticated channels.
// ResetSession resets an authenticated channel that already exists
func
(
c
*
Client
)
ResetSession
(
recipientMarshaled
,
meMarshaled
[]
byte
,
message
string
)
(
int
,
error
)
{
recipent
,
err
:=
contact
.
Unmarshal
(
recipientMarshaled
)
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"failed to "
+
"ResetSession: failed to Unmarshal Recipent: "
+
"%+v"
,
err
)
}
me
,
err
:=
contact
.
Unmarshal
(
meMarshaled
)
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"failed to "
+
"ResetSession: Failed to Unmarshal Me: %+v"
,
err
)
}
rid
,
err
:=
c
.
api
.
ResetSession
(
recipent
,
me
,
message
)
return
int
(
rid
),
err
}
// RegisterAuthCallbacks registers all callbacks for authenticated channels.
// This can only be called once
func
(
c
*
Client
)
RegisterAuthCallbacks
(
request
AuthRequestCallback
,
confirm
AuthConfirmCallback
)
{
confirm
AuthConfirmCallback
,
reset
AuthResetCallback
)
{
requestFunc
:=
func
(
requestor
contact
.
Contact
)
{
requestorBind
:=
&
Contact
{
c
:
&
requestor
}
request
.
Callback
(
requestorBind
)
}
resetFunc
:=
func
(
resetor
contact
.
Contact
)
{
resetorBind
:=
&
Contact
{
c
:
&
resetor
}
reset
.
Callback
(
resetorBind
)
}
confirmFunc
:=
func
(
partner
contact
.
Contact
)
{
partnerBind
:=
&
Contact
{
c
:
&
partner
}
confirm
.
Callback
(
partnerBind
)
...
...
@@ -75,8 +103,7 @@ func (c *Client) RegisterAuthCallbacks(request AuthRequestCallback,
c
.
api
.
GetAuthRegistrar
()
.
AddGeneralConfirmCallback
(
confirmFunc
)
c
.
api
.
GetAuthRegistrar
()
.
AddGeneralRequestCallback
(
requestFunc
)
return
c
.
api
.
GetAuthRegistrar
()
.
AddResetCallback
(
resetFunc
)
}
// ConfirmAuthenticatedChannel creates an authenticated channel out of a valid
...
...
This diff is collapsed.
Click to expand it.
bindings/callback.go
+
6
−
0
View file @
d2fe0add
...
...
@@ -60,6 +60,12 @@ type AuthConfirmCallback interface {
Callback
(
partner
*
Contact
)
}
// AuthRequestCallback notifies the register whenever they receive an auth
// request
type
AuthResetCallback
interface
{
Callback
(
requestor
*
Contact
)
}
// Generic Unregister - a generic return used for all callbacks which can be
// unregistered
// Interface which allows the un-registration of a listener
...
...
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