Skip to content

Commit

Permalink
Merge branch 'develop' into feature/hide-sensitive-ui-when-entering-b…
Browse files Browse the repository at this point in the history
…ackground
  • Loading branch information
jurajhilje committed Mar 29, 2022
2 parents 605de93 + 268a179 commit 1ee1b27
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 95 deletions.
52 changes: 25 additions & 27 deletions IVPNClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ class AppDelegate: UIResponder {

// MARK: - Methods -

private func evaluateFirstRun() {
if UserDefaults.standard.object(forKey: UserDefaults.Key.firstInstall) == nil {
KeyChain.clearAll()
UserDefaults.clearSession()
UserDefaults.standard.set(false, forKey: UserDefaults.Key.firstInstall)
UserDefaults.standard.synchronize()
}
}

private func evaluateUITests() {
// When running the application for UI Testing we need to remove all the stored data so we can start testing the clear app
// It is impossible to access the KeyChain from the UI test itself as the test runs in different process
Expand Down Expand Up @@ -148,28 +139,32 @@ class AppDelegate: UIResponder {
})
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
guard let endpoint = url.host else {
return false
private func handleURLEndpoint(_ endpoint: String) {
guard let viewController = UIApplication.topViewController() else {
return
}

switch endpoint {
case Config.urlTypeConnect:
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndConnectShortcut(closeApp: true, actionType: .connect)
return
viewController.showActionAlert(title: "Please confirm", message: "Do you want to connect to VPN?", action: "Connect", actionHandler: { _ in
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndConnectShortcut(closeApp: true, actionType: .connect)
return
}
Application.shared.connectionManager.connectShortcut(closeApp: true, actionType: .connect)
}
Application.shared.connectionManager.connectShortcut(closeApp: true, actionType: .connect)
}
})
case Config.urlTypeDisconnect:
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndDisconnectShortcut(closeApp: true, actionType: .disconnect)
return
viewController.showActionAlert(title: "Please confirm", message: "Do you want to disconnect from VPN?", action: "Disconnect", actionHandler: { _ in
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndDisconnectShortcut(closeApp: true, actionType: .disconnect)
return
}
Application.shared.connectionManager.disconnectShortcut(closeApp: true, actionType: .disconnect)
}
Application.shared.connectionManager.disconnectShortcut(closeApp: true, actionType: .disconnect)
}
})
case Config.urlTypeLogin:
if let topViewController = UIApplication.topViewController() {
if #available(iOS 13.0, *) {
Expand All @@ -181,8 +176,6 @@ class AppDelegate: UIResponder {
default:
break
}

return true
}

}
Expand All @@ -193,7 +186,6 @@ extension AppDelegate: UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
evaluateUITests()
evaluateFirstRun()
registerUserDefaults()
finishIncompletePurchases()
createLogFiles()
Expand Down Expand Up @@ -269,6 +261,12 @@ extension AppDelegate: UIApplicationDelegate {
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let url = userActivity.webpageURL {
let endpoint = url.lastPathComponent
handleURLEndpoint(endpoint)
return false
}

guard Application.shared.authentication.isLoggedIn, Application.shared.serviceStatus.isActive else {
return false
}
Expand Down
4 changes: 4 additions & 0 deletions IVPNClient/IVPNClient.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:www.ivpn.net</string>
</array>
<key>com.apple.developer.default-data-protection</key>
<string>NSFileProtectionComplete</string>
<key>com.apple.developer.networking.networkextension</key>
Expand Down
33 changes: 0 additions & 33 deletions IVPNClient/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,6 @@
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>login</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ivpn</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>connect</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ivpn</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>disconnect</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ivpn</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>Debug</key>
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Managers/KeyChain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class KeyChain {
private static let vpnPasswordKey = "vpn_password"

static let bundle: Keychain = {
return Keychain(service: "net.ivpn.clients.ios", accessGroup: "WQXXM75BYN.net.ivpn.IVPN-Client")
return Keychain(service: "net.ivpn.clients.ios", accessGroup: "WQXXM75BYN.net.ivpn.IVPN-Client").accessibility(.whenPasscodeSetThisDeviceOnly)
}()

class var username: String? {
Expand Down
19 changes: 19 additions & 0 deletions IVPNClient/Managers/NavigationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
//

import UIKit
import WebKit
import SnapKit

class NavigationManager {

Expand Down Expand Up @@ -162,4 +164,21 @@ class NavigationManager {
return navController!
}

static func getWebkitViewController(webView: WKWebView) -> UIViewController {
let storyBoard = UIStoryboard(name: "Signup", bundle: nil)
let navController = storyBoard.instantiateViewController(withIdentifier: "webkitView") as? UINavigationController
navController?.modalPresentationStyle = .formSheet

if let viewController = navController?.topViewController {
viewController.view.addSubview(webView)
viewController.navigationController?.navigationBar.prefersLargeTitles = false
webView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.top.equalToSuperview()
}
}

return navController!
}

}
62 changes: 53 additions & 9 deletions IVPNClient/Scenes/Signup.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="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
Expand Down Expand Up @@ -334,7 +334,7 @@
<tableViewSection id="Lj8-rs-5LY">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="226" id="88p-3D-F4q">
<rect key="frame" x="0.0" y="93" width="414" height="226"/>
<rect key="frame" x="0.0" y="109.5" width="414" height="226"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="88p-3D-F4q" id="Grr-60-n61">
<rect key="frame" x="0.0" y="0.0" width="414" height="226"/>
Expand Down Expand Up @@ -483,7 +483,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="286" id="GrT-ru-LnQ">
<rect key="frame" x="0.0" y="319" width="414" height="286"/>
<rect key="frame" x="0.0" y="335.5" width="414" height="286"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="GrT-ru-LnQ" id="Uc3-Xd-uPE">
<rect key="frame" x="0.0" y="0.0" width="414" height="286"/>
Expand Down Expand Up @@ -743,7 +743,7 @@
</constraints>
</view>
<view key="tableFooterView" contentMode="scaleToFill" id="3fw-Yl-V8z">
<rect key="frame" x="0.0" y="224" width="414" height="60"/>
<rect key="frame" x="0.0" y="235" width="414" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YLD-yW-M4d" customClass="PaymentComponentView" customModule="IVPNClient" customModuleProvider="target">
Expand Down Expand Up @@ -788,7 +788,7 @@
</view>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="ServiceTitleTableViewCell" rowHeight="64" id="yp4-DA-nL9" customClass="ServiceTitleTableViewCell" customModule="IVPNClient" customModuleProvider="target">
<rect key="frame" x="0.0" y="68" width="414" height="64"/>
<rect key="frame" x="0.0" y="84.5" width="414" height="64"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="yp4-DA-nL9" id="81z-wZ-CTY">
<rect key="frame" x="0.0" y="0.0" width="414" height="64"/>
Expand Down Expand Up @@ -842,7 +842,7 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ServiceTableViewCell" rowHeight="64" id="4VZ-0C-Lig" customClass="ServiceTableViewCell" customModule="IVPNClient" customModuleProvider="target">
<rect key="frame" x="0.0" y="132" width="414" height="64"/>
<rect key="frame" x="0.0" y="148.5" width="414" height="64"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="4VZ-0C-Lig" id="1CO-CW-g3H">
<rect key="frame" x="0.0" y="0.0" width="414" height="64"/>
Expand Down Expand Up @@ -1011,7 +1011,7 @@
<navigationItem key="navigationItem" title="Scan QR code" id="46Q-1E-UBo">
<barButtonItem key="leftBarButtonItem" title="Close" id="Fls-Ak-HAz">
<connections>
<action selector="dismissViewController:" destination="YcU-dg-mBO" id="xco-NT-yrE"/>
<action selector="dismissViewController:" destination="YcU-dg-mBO" id="vhT-OJ-8qe"/>
</connections>
</barButtonItem>
</navigationItem>
Expand All @@ -1026,7 +1026,7 @@
<!--Navigation Controller-->
<scene sceneID="Ec5-yl-wa5">
<objects>
<navigationController storyboardIdentifier="scannerView" automaticallyAdjustsScrollViewInsets="NO" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Pfo-b9-U3n" customClass="NavigationController" customModule="IVPNClient" customModuleProvider="target" sceneMemberID="viewController">
<navigationController storyboardIdentifier="scannerView" automaticallyAdjustsScrollViewInsets="NO" modalPresentationStyle="formSheet" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Pfo-b9-U3n" sceneMemberID="viewController">
<toolbarItems/>
<value key="contentSizeForViewInPopover" type="size" width="540" height="700"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="2DR-73-ZHo">
Expand Down Expand Up @@ -1353,6 +1353,28 @@
</objects>
<point key="canvasLocation" x="1287" y="2028"/>
</scene>
<!--View Controller-->
<scene sceneID="ZdE-ru-5NW">
<objects>
<viewController id="QMX-SL-DXP" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="mHz-rd-gKm">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="q0B-Tm-iCJ"/>
<color key="backgroundColor" name="ivpnBackgroundBase"/>
</view>
<navigationItem key="navigationItem" largeTitleDisplayMode="never" id="uCM-XV-9G2">
<barButtonItem key="leftBarButtonItem" title="Close" id="cML-TU-6BB">
<connections>
<action selector="dismissViewController:" destination="QMX-SL-DXP" id="DQJ-4G-Bie"/>
</connections>
</barButtonItem>
</navigationItem>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="p1F-23-PRD" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1287" y="2790"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="aIw-ln-iUM">
<objects>
Expand Down Expand Up @@ -1391,6 +1413,25 @@
</objects>
<point key="canvasLocation" x="364" y="2028"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="JNl-ew-SPn">
<objects>
<navigationController storyboardIdentifier="webkitView" automaticallyAdjustsScrollViewInsets="NO" modalPresentationStyle="formSheet" useStoryboardIdentifierAsRestorationIdentifier="YES" id="NFL-54-hlZ" customClass="NavigationController" customModule="IVPNClient" customModuleProvider="target" sceneMemberID="viewController">
<toolbarItems/>
<value key="contentSizeForViewInPopover" type="size" width="540" height="700"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="l9l-K7-EBj">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="QMX-SL-DXP" kind="relationship" relationship="rootViewController" id="naR-Aq-xSy"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ejK-Py-ciw" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="364" y="2790"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="uYX-O5-UET"/>
Expand All @@ -1403,6 +1444,9 @@
<image name="icon-step-1" width="48" height="8"/>
<image name="icon-step-2" width="48" height="8"/>
<image name="icon-step-3" width="48" height="8"/>
<namedColor name="ivpnBackgroundBase">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="ivpnBackgroundPrimary">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
Expand Down
13 changes: 9 additions & 4 deletions IVPNClient/Utilities/Extensions/UIViewController+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//

import UIKit
import SafariServices
import WebKit
import MessageUI

extension UIDevice {
Expand Down Expand Up @@ -114,10 +114,15 @@ extension UIViewController {
return
}

guard let url = URL(string: stringURL) else { return }
guard let url = URL(string: stringURL) else {
return
}

let safariVC = SFSafariViewController(url: url)
present(safariVC, animated: true, completion: nil)
let request = URLRequest(url: url)
let webView = WKWebView()
present(NavigationManager.getWebkitViewController(webView: webView), animated: true) {
webView.load(request)
}
}

func showSubscriptionActivatedAlert(serviceStatus: ServiceStatus, completion: (() -> Void)? = nil) {
Expand Down
1 change: 0 additions & 1 deletion IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ extension UserDefaults {
static let selectedExitServerRandom = "SelectedExitServerRandom"
static let fastestServerPreferred = "FastestServerPreferred"
static let fastestServerConfigured = "FastestServerConfiguredForOpenVPN"
static let firstInstall = "FirstInstall"
static let secureDNS = "SecureDNS"
static let serviceStatus = "ServiceStatus"
static let isIPv6 = "isIPv6"
Expand Down
Loading

0 comments on commit 1ee1b27

Please sign in to comment.