Skip to content

Commit

Permalink
Finish tan claiming and add swiftlint (eu-digital-green-certificates#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen authored May 9, 2021
1 parent 8f3a481 commit b1cc74d
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 72 deletions.
25 changes: 23 additions & 2 deletions DGCAWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
isa = PBXNativeTarget;
buildConfigurationList = CEA6D712261F8D2900715333 /* Build configuration list for PBXNativeTarget "DGCAWallet" */;
buildPhases = (
CE17E3342645A0C100029D95 /* ShellScript */,
CEA6D6E4261F8D2700715333 /* Sources */,
CEA6D6E5261F8D2700715333 /* Frameworks */,
CEA6D6E6261F8D2700715333 /* Resources */,
Expand Down Expand Up @@ -420,6 +421,26 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
CE17E3342645A0C100029D95 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nif which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
CEA6D6E4261F8D2700715333 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -634,7 +655,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.t-systems.DGCAWallet.dev";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
};
Expand All @@ -654,7 +675,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.t-systems.DGCAWallet.dev";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion DGCAWallet/Components/FullFloatingPanelLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FullFloatingPanelLayout: FloatingPanelLayout {
var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
let top = FloatingPanelLayoutAnchor(absoluteInset: 16.0, edge: .top, referenceGuide: .safeArea)
return [
.full: top,
.full: top
]
}
}
4 changes: 2 additions & 2 deletions DGCAWallet/Components/RoundedButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import UIKit

@IBDesignable
class RoundedButton: UIButton {
@IBInspectable var radius: CGFloat = 6.0 { didSet(v) { initialize() } }
@IBInspectable var padding: CGFloat = 4.0 { didSet(v) { initialize() } }
@IBInspectable var radius: CGFloat = 6.0 { didSet(value) { initialize() } }
@IBInspectable var padding: CGFloat = 4.0 { didSet(value) { initialize() } }

override init(frame: CGRect) {
super.init(frame: frame)
Expand Down
1 change: 0 additions & 1 deletion DGCAWallet/Extensions/UIColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//
// Created by Yannick Spreen on 4/29/21.
//


import UIKit

Expand Down
1 change: 0 additions & 1 deletion DGCAWallet/Extensions/UIFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import UIKit


extension UIFont {
public var weight: UIFont.Weight {
guard let weightNumber = traits[.weight] as? NSNumber else { return .regular }
Expand Down
9 changes: 4 additions & 5 deletions DGCAWallet/Extensions/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
// Created by Yannick Spreen on 5/3/21.
//


import UIKit
import SwiftDGC

Expand All @@ -40,12 +39,12 @@ extension UIViewController {
handler: ((_ text: String?) -> Void)? = nil
) {
let alert = UIAlertController(title: title, message: subtitle, preferredStyle: .alert)
alert.addTextField { (textField:UITextField) in
alert.addTextField { (textField: UITextField) in
textField.placeholder = inputPlaceholder
textField.keyboardType = inputKeyboardType
}
alert.addAction(UIAlertAction(title: actionTitle, style: .default) { action in
guard let textField = alert.textFields?.first else {
alert.addAction(UIAlertAction(title: actionTitle, style: .default) { _ in
guard let textField = alert.textFields?.first else {
handler?(nil)
return
}
Expand All @@ -65,7 +64,7 @@ extension UIViewController {
handler: ((Bool) -> Void)? = nil
) {
let alert = UIAlertController(title: title, message: subtitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: actionTitle, style: .default) { action in
alert.addAction(UIAlertAction(title: actionTitle, style: .default) { _ in
handler?(true)
})
if let cancelTitle = cancelTitle {
Expand Down
5 changes: 2 additions & 3 deletions DGCAWallet/Models/LocalData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
// DGCAWallet
//
// Created by Yannick Spreen on 4/25/21.
//

//

import Foundation
import SwiftDGC

struct DatedCertString: Codable {
var date: Date
var certString: String
var storedTAN : String?
var storedTAN: String?
var cert: HCert? {
HCert(from: certString)
}
Expand Down
2 changes: 1 addition & 1 deletion DGCAWallet/Protocols/CertViewerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@

import Foundation

protocol CertViewerDelegate {
protocol CertViewerDelegate: AnyObject {
func childDismissed(_ newCertAdded: Bool)
}
2 changes: 1 addition & 1 deletion DGCAWallet/Protocols/ChildDismissedDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import Foundation

protocol CertViewerDelegate {
protocol CertViewerDelegate: class {
func childDismissed()
func openSettings()
}
1 change: 0 additions & 1 deletion DGCAWallet/Services/Brightness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//
// Created by Yannick Spreen on 4/30/21.
//


import Foundation
import UIKit
Expand Down
21 changes: 13 additions & 8 deletions DGCAWallet/Services/GatewayConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct GatewayConnection {
return
}
// Replace dashes, spaces, etc. and turn into uppercase.
let set = CharacterSet(charactersIn: "0123456789").union(.capitalizedLetters)
let set = CharacterSet(charactersIn: "0123456789").union(.uppercaseLetters)
tan = tan.uppercased().components(separatedBy: set.inverted).joined()

let tanHash = SHA256.stringDigest(input: Data(tan.data(using: .utf8) ?? .init()))
Expand All @@ -53,23 +53,28 @@ struct GatewayConnection {
return
}

let keyParam: [String: Any] = [
"type": "EC",
"value": pubKey,
]
let keyParam: [String: Any] = [ "type": "EC", "value": pubKey ]
let param: [String: Any] = [
"DGCI": cert.uvci,
"TANHash": tanHash,
"certhash": certHash,
"publicKey": keyParam,
"signature": sign.base64EncodedString(),
"sigAlg": "SHA256withECDSA",
"sigAlg": "SHA256withECDSA"
]
AF.request(serverURI + claimEndpoint, method: .post, parameters: param, encoding: JSONEncoding.default, headers: nil, interceptor: nil, requestModifier: nil).response {
AF.request(
serverURI + claimEndpoint,
method: .post,
parameters: param,
encoding: JSONEncoding.default,
headers: nil,
interceptor: nil,
requestModifier: nil
).response {
guard
case .success(_) = $0.result,
let status = $0.response?.statusCode,
status == 204
status / 100 == 2
else {
completion?(false, nil)
return
Expand Down
7 changes: 4 additions & 3 deletions DGCAWallet/Services/SecureBackground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
// Created by Yannick Spreen on 4/27/21.
//


import Foundation
import UIKit
import LocalAuthentication
Expand All @@ -52,7 +51,9 @@ struct SecureBackground {
public static func disable() {
if imageView != nil {
if activation.timeIntervalSinceNow < -1 {
(UIApplication.shared.windows[0].rootViewController as? UINavigationController)?.popToRootViewController(animated: false)
(
UIApplication.shared.windows[0].rootViewController as? UINavigationController
)?.popToRootViewController(animated: false)
}
imageView?.removeFromSuperview()
imageView = nil
Expand All @@ -75,7 +76,7 @@ struct SecureBackground {
completion?(true)
return
}
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, error in
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, _ in
if success {
// Move to the main thread because a state update triggers UI changes.
DispatchQueue.main.async {
Expand Down
6 changes: 4 additions & 2 deletions DGCAWallet/SupportingFiles/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Override point for customization after application launch.
return true
}
Expand All @@ -43,4 +46,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

}

1 change: 0 additions & 1 deletion DGCAWallet/SupportingFiles/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}

}

17 changes: 11 additions & 6 deletions DGCAWallet/ViewControllers/CertPages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//
// Created by Yannick Spreen on 4/30/21.
//


import UIKit

Expand All @@ -34,7 +33,7 @@ class CertPagesVC: UIPageViewController {
var index = 0
let vcs: [UIViewController] = [
UIStoryboard(name: "CertificateViewer", bundle: .main).instantiateViewController(withIdentifier: "code"),
UIStoryboard(name: "CertificateViewer", bundle: .main).instantiateViewController(withIdentifier: "infoTable"),
UIStoryboard(name: "CertificateViewer", bundle: .main).instantiateViewController(withIdentifier: "infoTable")
]

override func viewDidLoad() {
Expand Down Expand Up @@ -65,12 +64,18 @@ class CertPagesVC: UIPageViewController {
}

extension CertPagesVC: UIPageViewControllerDataSource {
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
func pageViewController(
_ pageViewController: UIPageViewController,
viewControllerBefore viewController: UIViewController
) -> UIViewController? {
let index = vcs.firstIndex(of: viewController) ?? 0
return index == 0 ? nil : vcs[index - 1]
}

func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
func pageViewController(
_ pageViewController: UIPageViewController,
viewControllerAfter viewController: UIViewController
) -> UIViewController? {
let index = vcs.firstIndex(of: viewController) ?? vcs.count - 1
return index == vcs.count - 1 ? nil : vcs[index + 1]
}
Expand All @@ -93,11 +98,11 @@ extension CertPagesVC: UIPageViewControllerDelegate {
) {
guard
completed,
let vc = pageViewController.viewControllers?.first
let controller = pageViewController.viewControllers?.first
else {
return
}
index = vcs.firstIndex(of: vc) ?? 0
index = vcs.firstIndex(of: controller) ?? 0
setBrightness()
}
}
3 changes: 1 addition & 2 deletions DGCAWallet/ViewControllers/CertTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//
// Created by Yannick Spreen on 4/30/21.
//

import SwiftDGC
import UIKit

Expand All @@ -44,7 +44,6 @@ class CertTableVC: UIViewController {
}
}


extension CertTableVC: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return hCert.info.count
Expand Down
2 changes: 1 addition & 1 deletion DGCAWallet/ViewControllers/CertificateViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CertificateViewerVC: UIViewController {

var hCert: HCert!
var tan: String?
var childDismissedDelegate: CertViewerDelegate?
weak var childDismissedDelegate: CertViewerDelegate?
public var isSaved = true

func draw() {
Expand Down
3 changes: 1 addition & 2 deletions DGCAWallet/ViewControllers/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//
// Created by Yannick Spreen on 4/25/21.
//


import Foundation
import UIKit
Expand All @@ -34,7 +33,7 @@ class HomeVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

HCert.PREFETCH_ALL_CODES = true
HCert.prefetchAllCodes = true
LocalData.initialize {
DispatchQueue.main.async { [weak self] in
guard let self = self else {
Expand Down
7 changes: 5 additions & 2 deletions DGCAWallet/ViewControllers/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//
// Created by Yannick Spreen on 4/25/21.
//


import Foundation
import UIKit
Expand Down Expand Up @@ -158,7 +157,11 @@ extension ListVC: UITableViewDelegate {
}

extension ListVC: FloatingPanelControllerDelegate {
func floatingPanel(_ fpc: FloatingPanelController, shouldRemoveAt location: CGPoint, with velocity: CGVector) -> Bool {
func floatingPanel(
_ fpc: FloatingPanelController,
shouldRemoveAt location: CGPoint,
with velocity: CGVector
) -> Bool {
let pos = location.y / view.bounds.height
if pos >= 0.33 {
return true
Expand Down
Loading

0 comments on commit b1cc74d

Please sign in to comment.