Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
mobile
iOS
Elixxir dApps SDK Swift
Commits
6830f3ef
Commit
6830f3ef
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add AuthCallbacks wrapper
parent
e51043da
No related branches found
No related tags found
2 merge requests
!102
Release 1.0.0
,
!18
Update Bindings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/AuthCallbacks.swift
+81
-0
81 additions, 0 deletions
Sources/ElixxirDAppsSDK/AuthCallbacks.swift
Sources/ElixxirDAppsSDK/Login.swift
+5
-4
5 additions, 4 deletions
Sources/ElixxirDAppsSDK/Login.swift
with
86 additions
and
4 deletions
Sources/ElixxirDAppsSDK/AuthCallbacks.swift
0 → 100644
+
81
−
0
View file @
6830f3ef
import
Bindings
import
XCTestDynamicOverlay
public
enum
AuthCallback
{
case
confirm
(
contact
:
Data
,
receptionId
:
Data
,
ephemeralId
:
Int64
,
roundId
:
Int64
)
case
request
(
contact
:
Data
,
receptionId
:
Data
,
ephemeralId
:
Int64
,
roundId
:
Int64
)
case
reset
(
contact
:
Data
,
receptionId
:
Data
,
ephemeralId
:
Int64
,
roundId
:
Int64
)
}
public
struct
AuthCallbacks
{
public
init
(
handle
:
@escaping
(
AuthCallback
)
->
Void
)
{
self
.
handle
=
handle
}
public
var
handle
:
(
AuthCallback
)
->
Void
}
extension
AuthCallbacks
{
public
static
let
unimplemented
=
AuthCallbacks
(
handle
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
extension
AuthCallbacks
{
func
makeBindingsAuthCallbacks
()
->
BindingsAuthCallbacksProtocol
{
class
Handler
:
NSObject
,
BindingsAuthCallbacksProtocol
{
init
(
_
callbacks
:
AuthCallbacks
)
{
self
.
callbacks
=
callbacks
}
let
callbacks
:
AuthCallbacks
func
confirm
(
_
contact
:
Data
?,
receptionId
:
Data
?,
ephemeralId
:
Int64
,
roundId
:
Int64
)
{
guard
let
contact
=
contact
else
{
fatalError
(
"BindingsAuthCallbacks.confirm received `nil` contact"
)
}
guard
let
receptionId
=
receptionId
else
{
fatalError
(
"BindingsAuthCallbacks.confirm received `nil` receptionId"
)
}
callbacks
.
handle
(
.
confirm
(
contact
:
contact
,
receptionId
:
receptionId
,
ephemeralId
:
ephemeralId
,
roundId
:
roundId
))
}
func
request
(
_
contact
:
Data
?,
receptionId
:
Data
?,
ephemeralId
:
Int64
,
roundId
:
Int64
)
{
guard
let
contact
=
contact
else
{
fatalError
(
"BindingsAuthCallbacks.request received `nil` contact"
)
}
guard
let
receptionId
=
receptionId
else
{
fatalError
(
"BindingsAuthCallbacks.request received `nil` receptionId"
)
}
callbacks
.
handle
(
.
request
(
contact
:
contact
,
receptionId
:
receptionId
,
ephemeralId
:
ephemeralId
,
roundId
:
roundId
))
}
func
reset
(
_
contact
:
Data
?,
receptionId
:
Data
?,
ephemeralId
:
Int64
,
roundId
:
Int64
)
{
guard
let
contact
=
contact
else
{
fatalError
(
"BindingsAuthCallbacks.reset received `nil` contact"
)
}
guard
let
receptionId
=
receptionId
else
{
fatalError
(
"BindingsAuthCallbacks.reset received `nil` receptionId"
)
}
callbacks
.
handle
(
.
reset
(
contact
:
contact
,
receptionId
:
receptionId
,
ephemeralId
:
ephemeralId
,
roundId
:
roundId
))
}
}
return
Handler
(
self
)
}
}
This diff is collapsed.
Click to expand it.
Sources/ElixxirDAppsSDK/Login.swift
+
5
−
4
View file @
6830f3ef
...
@@ -2,23 +2,24 @@ import Bindings
...
@@ -2,23 +2,24 @@ import Bindings
import
XCTestDynamicOverlay
import
XCTestDynamicOverlay
public
struct
Login
{
public
struct
Login
{
public
var
run
:
(
Int
,
Data
,
Data
)
throws
->
E2E
public
var
run
:
(
Int
,
AuthCallbacks
?,
Data
,
Data
)
throws
->
E2E
public
func
callAsFunction
(
public
func
callAsFunction
(
cmixId
:
Int
,
cmixId
:
Int
,
authCallbacks
:
AuthCallbacks
?
=
nil
,
identity
:
Data
,
identity
:
Data
,
e2eParamsJSON
:
Data
e2eParamsJSON
:
Data
)
throws
->
E2E
{
)
throws
->
E2E
{
try
run
(
cmixId
,
identity
,
e2eParamsJSON
)
try
run
(
cmixId
,
authCallbacks
,
identity
,
e2eParamsJSON
)
}
}
}
}
extension
Login
{
extension
Login
{
public
static
let
live
=
Login
{
cmixId
,
identity
,
e2eParamsJSON
in
public
static
let
live
=
Login
{
cmixId
,
authCallbacks
,
identity
,
e2eParamsJSON
in
var
error
:
NSError
?
var
error
:
NSError
?
let
bindingsE2E
=
BindingsLogin
(
let
bindingsE2E
=
BindingsLogin
(
cmixId
,
cmixId
,
nil
,
// TODO: pass c
allbacks
authCallbacks
?
.
makeBindingsAuthC
allbacks
(),
identity
,
identity
,
e2eParamsJSON
,
e2eParamsJSON
,
&
error
&
error
...
...
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