Skip to content

Commit

Permalink
Merge pull request #239 from saltedge/v2
Browse files Browse the repository at this point in the history
V2 -> Master
  • Loading branch information
baller784 authored Nov 25, 2022
2 parents fc406b2 + 04bcbf4 commit 398c3af
Show file tree
Hide file tree
Showing 192 changed files with 6,868 additions and 1,282 deletions.
3 changes: 1 addition & 2 deletions .clabot
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"ConstantinKV",
"baller784",
"gorceagolga",
"mnewlive",
"alisnic"
"mnewlive"
],
"message": "Thank you for your pull request and welcome to our [Salt Edge](https://www.saltedge.com/) community. We require contributors to [sign our Contributor License Agreement](https://forms.gle/nX4mFP8eg78NVgrVA), and we don't seem to have the users {{usersWithoutCLA}} on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added, in case you have already signed CLA and not been added yet.",
"label": "CLA-signed"
Expand Down
212 changes: 188 additions & 24 deletions Example/Authenticator.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.180",
"green" : "0.750",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.729",
"green" : "0.635",
"red" : "0.506"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 3 additions & 3 deletions Example/Authenticator/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -21,7 +21,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchGroup" translatesAutoresizingMaskIntoConstraints="NO" id="Npg-97-4j3">
<rect key="frame" x="40" y="164" width="295" height="213"/>
<rect key="frame" x="40" y="167" width="295" height="213"/>
<constraints>
<constraint firstAttribute="height" constant="213" id="gIo-1s-0Tz"/>
</constraints>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import SEAuthenticator

final class AuthorizationsCoordinator: Coordinator {
let rootViewController = AuthorizationsViewController()
private let dataSource = AuthorizationsDataSource(locationManagement: LocationManager.shared)
private let dataSource = AuthorizationsDataSource()
private let viewModel = AuthorizationsViewModel()

private var qrCoordinator: QRCodeCoordinator?
Expand Down Expand Up @@ -70,7 +70,12 @@ extension AuthorizationsCoordinator: AuthorizationsViewControllerDelegate {
return
}

stop() // Stop pollling when presenting contollers

qrCoordinator = QRCodeCoordinator(rootViewController: rootViewController)
qrCoordinator?.shouldDismissController = {
self.viewModel.setupPolling()
}
qrCoordinator?.start()
}

Expand All @@ -95,4 +100,8 @@ extension AuthorizationsCoordinator: AuthorizationsViewControllerDelegate {

rootViewController.present(actionSheet, animated: true)
}

func requestLocation() {
LocationManager.shared.requestLocationAuthorization()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@

import UIKit
import SEAuthenticator
import SEAuthenticatorCore

final class InstantActionCoordinator: Coordinator {
private var rootViewController: UIViewController
private var connectViewController: ConnectViewController
private var instantActionHandler: InstantActionHandler
private var qrCodeCoordinator: QRCodeCoordinator?

init(rootViewController: UIViewController, qrUrl: URL, actionGuid: GUID, connectUrl: URL) {
var shouldDismissController: (() -> ())?

init(rootViewController: UIViewController, qrUrl: URL) {
self.rootViewController = rootViewController
self.connectViewController = ConnectViewController()
self.instantActionHandler = InstantActionHandler(qrUrl: qrUrl, actionGuid: actionGuid, connectUrl: connectUrl)
self.instantActionHandler = InstantActionHandler(qrUrl: qrUrl)
if #available(iOS 13.0, *) {
connectViewController.isModalInPresentation = true
}
}

func start() {
connectViewController.title = l10n(.newAction)
connectViewController.shouldDismiss = shouldDismissController
rootViewController.present(
UINavigationController(rootViewController: connectViewController),
animated: true
Expand All @@ -64,10 +68,10 @@ extension InstantActionCoordinator: InstantActionEventsDelegate {
}
connectViewController.add(pickerViewController)

pickerViewModel.selectedConnectionClosure = { guid, accessToken in
pickerViewModel.selectedConnectionClosure = { actionData in
pickerViewController.remove()
self.connectViewController.title = l10n(.newAction)
self.instantActionHandler.submitAction(for: guid, accessToken: accessToken)
self.instantActionHandler.submitAction(for: actionData)
}
}

Expand All @@ -83,13 +87,14 @@ extension InstantActionCoordinator: InstantActionEventsDelegate {
}

func shouldDismiss() {
connectViewController.dismiss(animated: true)
connectViewController.dismiss(animated: true, completion: shouldDismissController)
}

func shouldDismiss(with error: String) {
connectViewController.dismiss(
animated: true,
completion: {
self.shouldDismissController?()
self.rootViewController.present(message: error)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@
//

import UIKit
import SEAuthenticator
import SEAuthenticatorCore

final class QRCodeCoordinator: Coordinator {
private var rootViewController: UIViewController
private var qrCodeViewController: QRCodeViewController
private var connectViewCoordinator: ConnectViewCoordinator?
private var instantActionCoordinator: InstantActionCoordinator?
private var instantActionCoordinator: InstantActionCoordinator?

var dismissClosure: (() -> ())?
var shouldDismissController: (() -> ())?

init(rootViewController: UIViewController) {
self.rootViewController = rootViewController
self.qrCodeViewController = QRCodeViewController()
}

func start() {
dismissClosure = qrCodeViewController.shouldDismissClosure
qrCodeViewController.delegate = self
qrCodeViewController.shouldDismissClosure = shouldDismissController

if let navController = rootViewController.navigationController {
navController.present(qrCodeViewController, animated: true)
} else {
Expand All @@ -55,20 +56,19 @@ extension QRCodeCoordinator: QRCodeViewControllerDelegate {
guard let url = URL(string: data),
SEConnectHelper.isValid(deepLinkUrl: url) else { return }

if let actionGuid = SEConnectHelper.actionGuid(from: url),
let connectUrl = SEConnectHelper.connectUrl(from: url) {
if SEConnectHelper.shouldStartInstantActionFlow(url: url) {
instantActionCoordinator = InstantActionCoordinator(
rootViewController: rootViewController,
qrUrl: url,
actionGuid: actionGuid,
connectUrl: connectUrl
qrUrl: url
)
instantActionCoordinator?.shouldDismissController = shouldDismissController
instantActionCoordinator?.start()
} else {
connectViewCoordinator = ConnectViewCoordinator(
rootViewController: rootViewController,
connectionType: .newConnection(data)
)
connectViewCoordinator?.shouldDismissController = shouldDismissController
connectViewCoordinator?.start()
}
}
Expand Down
23 changes: 18 additions & 5 deletions Example/Authenticator/Coordinators/ConnectViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import UIKit
import SEAuthenticator
import SEAuthenticatorCore

enum ConnectionType: Equatable {
case newConnection(String)
Expand All @@ -42,13 +43,15 @@ final class ConnectViewCoordinator: Coordinator {
private let rootViewController: UIViewController

private lazy var webViewController = ConnectorWebViewController()
private var connectViewController = ConnectViewController()
private lazy var connectViewController = ConnectViewController()
private var qrCodeCoordinator: QRCodeCoordinator?
private var connectHandler: ConnectHandler?

private var connection: Connection?
private let connectionType: ConnectionType

var shouldDismissController: (() -> ())?

init(rootViewController: UIViewController, connectionType: ConnectionType) {
self.rootViewController = rootViewController
self.connectionType = connectionType
Expand All @@ -58,6 +61,7 @@ final class ConnectViewCoordinator: Coordinator {
func start() {
connectHandler?.delegate = self
connectHandler?.startHandling()
connectViewController.shouldDismiss = shouldDismissController

rootViewController.present(
UINavigationController(rootViewController: connectViewController),
Expand Down Expand Up @@ -85,10 +89,19 @@ extension ConnectViewCoordinator: ConnectEventsDelegate {
connectViewController.showCompleteView(with: .success, title: "", attributedTitle: attributedMessage)
}

// NOTE: Temporarily inactive due to legal restrictions
// func requestLocationAuthorization() {
// LocationManager.shared.requestLocationAuthorization()
// }
func requestLocationAuthorization() {
if LocationManager.shared.notDeterminedAuthorization {
LocationManager.shared.requestLocationAuthorization()
} else {
connectViewController.showInfoAlert(
withTitle: l10n(.turnOnLocationServices),
message: l10n(.turnOnPhoneLocationServicesDescription),
completion: {
LocationManager.shared.requestLocationAuthorization()
}
)
}
}

func startWebViewLoading(with connectUrlString: String) {
webViewController.startLoading(with: connectUrlString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
//

import UIKit
import SEAuthenticator
import SEAuthenticatorCore

final class ConnectionsCoordinator: Coordinator {
private var rootViewController: UIViewController
private var currentViewController: ConnectionsViewController
private var connectViewCoordinator: ConnectViewCoordinator?
private var qrCodeCoordinator: QRCodeCoordinator?
private var consentsCoordinator: ConsentsCoordinator?
private var viewModel = ConnectionsViewModel()
private var viewModel = ConnectionsViewModel(reachabilityManager: ConnectivityManager.shared)

init(rootViewController: UIViewController) {
self.rootViewController = rootViewController
Expand All @@ -48,9 +48,29 @@ final class ConnectionsCoordinator: Coordinator {

// MARK: - ConnectionsListEventsDelegate
extension ConnectionsCoordinator: ConnectionsEventsDelegate {
func showNoInternetConnectionAlert(completion: @escaping () -> Void) {
currentViewController.showConfirmationAlert(
withTitle: l10n(.noInternetConnection),
message: l10n(.pleaseCheckAndTryAgain),
confirmActionTitle: l10n(.retry),
confirmAction: { _ in completion() }
)
}

func showDeleteConfirmationAlert(completion: @escaping () -> Void) {
currentViewController.showConfirmationAlert(
withTitle: l10n(.deleteConnection),
message: l10n(.deleteConnectionDescription),
confirmActionTitle: l10n(.delete),
confirmActionStyle: .destructive,
cancelTitle: l10n(.cancel),
confirmAction: { _ in completion() }
)
}

func addPressed() {
guard AVCaptureHelper.cameraIsAuthorized() else {
self.currentViewController.showConfirmationAlert(
currentViewController.showConfirmationAlert(
withTitle: l10n(.deniedCamera),
message: l10n(.deniedCameraDescription),
confirmActionTitle: l10n(.goToSettings),
Expand Down Expand Up @@ -112,4 +132,8 @@ extension ConnectionsCoordinator: ConnectionsEventsDelegate {
connectViewCoordinator = ConnectViewCoordinator(rootViewController: currentViewController, connectionType: .reconnect(id))
connectViewCoordinator?.start()
}

func presentError(_ error: String) {
currentViewController.present(message: error)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//

import UIKit
import SEAuthenticator
import SEAuthenticatorCore

final class ConsentDetailCoordinator: Coordinator {
private var rootViewController: UIViewController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//

import UIKit
import SEAuthenticator
import SEAuthenticatorCore

final class ApplicationCoordinator: Coordinator {
private let window: UIWindow?
Expand Down Expand Up @@ -236,13 +236,12 @@ final class ApplicationCoordinator: Coordinator {
}

private func startConnect(url: URL, controller: UIViewController) {
if let actionGuid = SEConnectHelper.actionGuid(from: url),
let connectUrl = SEConnectHelper.connectUrl(from: url) {
authorizationsCoordinator.stop()

if SEConnectHelper.shouldStartInstantActionFlow(url: url) {
instantActionCoordinator = InstantActionCoordinator(
rootViewController: controller,
qrUrl: url,
actionGuid: actionGuid,
connectUrl: connectUrl
qrUrl: url
)
instantActionCoordinator?.start()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ final class LanguagePickerCoordinator: Coordinator {
// MARK: - LanguagePickerEventsDelegate
extension LanguagePickerCoordinator: LanguagePickerEventsDelegate {
func languageSelected() {
rootViewController?.navigationController?.popToRootViewController(animated: true)
rootViewController?.navigationController?.popViewController(animated: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ final class PasscodeCoordinator: Coordinator {
viewModel.delegate = self

currentViewController.onCompleteClosure = { (_ completeType: CompleteType) -> () in
// NOTE: Temporarily inactive due to legal restrictions
// PasscodeCoordinator.lastAppUnlockCompleteType = completeType
PasscodeCoordinator.lastAppUnlockCompleteType = completeType
self.onCompleteClosure?()
}

Expand Down
Loading

0 comments on commit 398c3af

Please sign in to comment.