diff --git a/CHANGELOG.md b/CHANGELOG.md index 1de73ea..818dc8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +### 0.2.8 +- **Update**: `validationResult` of `BasePassCodeViewModel` renamed to `validationResultDriver` and becomes public. +- **Remove**: `MaskFieldTextProxy`. +- **Remove**: `InputMask` dependency +- **Replace**: `IDZSwiftCommonCrypto` with `CryptoSwift` + ### 0.2.7 - **Fix**: Build with new LeadKit 0.7.9 diff --git a/LeadKitAdditions.podspec b/LeadKitAdditions.podspec index 71453ba..ed51da2 100644 --- a/LeadKitAdditions.podspec +++ b/LeadKitAdditions.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKitAdditions" - s.version = "0.2.7" + s.version = "0.2.8" s.summary = "iOS framework with a bunch of tools for rapid development" s.homepage = "https://github.com/TouchInstinct/LeadKitAdditions" s.license = "Apache License, Version 2.0" @@ -18,8 +18,7 @@ Pod::Spec.new do |s| ss.dependency "LeadKit", '~> 0.7.0' ss.dependency "KeychainAccess", '3.1.0' - ss.dependency "IDZSwiftCommonCrypto", '0.9.1' - ss.dependency "InputMask", '3.0.0' + ss.dependency "CryptoSwift", '~> 0.9.0' ss.dependency "SwiftValidator", '5.0.0' ss.dependency "PinLayout", '~> 1.6' end @@ -36,8 +35,7 @@ Pod::Spec.new do |s| ss.dependency "LeadKit/Core-iOS-Extension", '~> 0.7.0' ss.dependency "KeychainAccess", '3.1.0' - ss.dependency "IDZSwiftCommonCrypto", '0.9.1' - ss.dependency "InputMask", '3.0.0' + ss.dependency "CryptoSwift", '~> 0.9.0' ss.dependency "SwiftValidator", '5.0.0' ss.dependency "PinLayout", '~> 1.6' end diff --git a/LeadKitAdditions.xcodeproj/project.pbxproj b/LeadKitAdditions.xcodeproj/project.pbxproj index cfc6b2e..5f18317 100644 --- a/LeadKitAdditions.xcodeproj/project.pbxproj +++ b/LeadKitAdditions.xcodeproj/project.pbxproj @@ -62,8 +62,6 @@ ED0C342E1F2906EC00FAE9FD /* BasePassCodeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F11F2906EC00FAE9FD /* BasePassCodeService.swift */; }; ED0C342F1F2906EC00FAE9FD /* BaseUserService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */; }; ED0C34301F2906EC00FAE9FD /* BaseUserService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */; }; - ED0C34331F2906EC00FAE9FD /* MaskFieldTextProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F41F2906EC00FAE9FD /* MaskFieldTextProxy.swift */; }; - ED0C34341F2906EC00FAE9FD /* MaskFieldTextProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F41F2906EC00FAE9FD /* MaskFieldTextProxy.swift */; }; ED0C34351F2906EC00FAE9FD /* ApiNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F61F2906EC00FAE9FD /* ApiNetworkService.swift */; }; ED0C34361F2906EC00FAE9FD /* ApiNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F61F2906EC00FAE9FD /* ApiNetworkService.swift */; }; ED0C34381F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F71F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift */; }; @@ -122,7 +120,6 @@ ED0C33E91F2906EC00FAE9FD /* UserDefaults+UserService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UserDefaults+UserService.swift"; sourceTree = ""; }; ED0C33F11F2906EC00FAE9FD /* BasePassCodeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasePassCodeService.swift; sourceTree = ""; }; ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseUserService.swift; sourceTree = ""; }; - ED0C33F41F2906EC00FAE9FD /* MaskFieldTextProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaskFieldTextProxy.swift; sourceTree = ""; }; ED0C33F61F2906EC00FAE9FD /* ApiNetworkService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiNetworkService.swift; sourceTree = ""; }; ED0C33F71F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DefaultNetworkService+ActivityIndicator+Extension.swift"; sourceTree = ""; }; ED0C33F81F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DefaultNetworkService+ActivityIndicator.swift"; sourceTree = ""; }; @@ -351,7 +348,6 @@ ED0C33FB1F2906EC00FAE9FD /* ValidationService */, ED0C33F11F2906EC00FAE9FD /* BasePassCodeService.swift */, ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */, - ED0C33F41F2906EC00FAE9FD /* MaskFieldTextProxy.swift */, 678D26A9206935B900B05B93 /* BiometricsService.swift */, ); path = Services; @@ -644,7 +640,6 @@ ED0C34111F2906EC00FAE9FD /* PassCodeValidationResult.swift in Sources */, ED0C34051F2906EC00FAE9FD /* BaseDateFormatter.swift in Sources */, ED0C34431F2906EC00FAE9FD /* ValidationService.swift in Sources */, - ED0C34331F2906EC00FAE9FD /* MaskFieldTextProxy.swift in Sources */, ED0C340B1F2906EC00FAE9FD /* PassCodeError.swift in Sources */, 67B4E6F6206945DD00E233EA /* OnlineValidationResult.swift in Sources */, 67C2A41B20724F40000A5682 /* LabelCellViewModel.swift in Sources */, @@ -683,7 +678,6 @@ ED0C34061F2906EC00FAE9FD /* BaseDateFormatter.swift in Sources */, ED0C34441F2906EC00FAE9FD /* ValidationService.swift in Sources */, EF5A43B2206E7A67003CED07 /* PassCodeDelayedDescription.swift in Sources */, - ED0C34341F2906EC00FAE9FD /* MaskFieldTextProxy.swift in Sources */, ED0C340C1F2906EC00FAE9FD /* PassCodeError.swift in Sources */, ED0C34161F2906EC00FAE9FD /* BasePassCodeViewModel.swift in Sources */, ); diff --git a/Podfile b/Podfile index 045cb90..e8c3fc9 100644 --- a/Podfile +++ b/Podfile @@ -3,8 +3,7 @@ source "https://github.com/TouchInstinct/Podspecs.git" abstract_target 'LeadKitAdditions' do pod "KeychainAccess", '3.1.0' - pod "IDZSwiftCommonCrypto" - pod "InputMask", '3.0.0' + pod "CryptoSwift", "~> 0.9.0" pod "SwiftValidator", '5.0.0' pod "SwiftLint", '~> 0.25' pod "PinLayout", '~> 1.6' diff --git a/Podfile.lock b/Podfile.lock index 8058640..f816c6a 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,11 +1,10 @@ PODS: - - Alamofire (4.7.1) - - IDZSwiftCommonCrypto (0.10.0) - - InputMask (3.0.0) + - Alamofire (4.7.2) + - CryptoSwift (0.9.0) - KeychainAccess (3.1.0) - - LeadKit (0.7.9): - - LeadKit/Core (= 0.7.9) - - LeadKit/Core (0.7.9): + - LeadKit (0.7.12): + - LeadKit/Core (= 0.7.12) + - LeadKit/Core (0.7.12): - ObjectMapper (~> 3.1) - RxAlamofire (~> 4.1) - RxCocoa (~> 4.1) @@ -13,7 +12,7 @@ PODS: - SwiftDate (~> 4.5) - TableKit (~> 2.6) - UIScrollView-InfiniteScroll (~> 1.0.0) - - LeadKit/Core-iOS-Extension (0.7.9): + - LeadKit/Core-iOS-Extension (0.7.12): - ObjectMapper (~> 3.1) - RxAlamofire (~> 4.1) - RxCocoa (~> 4.1) @@ -30,14 +29,13 @@ PODS: - RxSwift (~> 4.0) - RxSwift (4.1.2) - SwiftDate (4.5.1) - - SwiftLint (0.25.0) + - SwiftLint (0.25.1) - SwiftValidator (5.0.0) - TableKit (2.6.0) - UIScrollView-InfiniteScroll (1.0.2) DEPENDENCIES: - - IDZSwiftCommonCrypto - - InputMask (= 3.0.0) + - CryptoSwift (~> 0.9.0) - KeychainAccess (= 3.1.0) - LeadKit (~> 0.7.0) - LeadKit/Core-iOS-Extension (~> 0.7.0) @@ -46,22 +44,21 @@ DEPENDENCIES: - SwiftValidator (= 5.0.0) SPEC CHECKSUMS: - Alamofire: 68d7d521118d49c615a8d2214d87cdf525599d30 - IDZSwiftCommonCrypto: 4eef2c46e262dfbcbc1fd76365e066336680ad7d - InputMask: 8b5c42acac19cd48fe664b739f30995103b75e75 + Alamofire: e4fa87002c137ba2d8d634d2c51fabcda0d5c223 + CryptoSwift: bca8c5b653dcc2d9734409242a070ff53bafac86 KeychainAccess: 94c5540b32eabf7bc32bfb976a268e8ea05fd6da - LeadKit: 1b74c4f9a4736a39b90119363e85468eca5c1b77 + LeadKit: e6628cfa16f5bab6fc001d4fcba9608f60fb6fd3 ObjectMapper: 20505058f54e5c3ca69e1d6de9897d152a5369a6 PinLayout: a2bbe9057d49a1e326b13dc4fe8c14751f8c8844 RxAlamofire: 87a9c588541210cc3e4a1f843ccc3ecf3eb98b31 RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a RxSwift: e49536837d9901277638493ea537394d4b55f570 SwiftDate: 7b56d42a221f582047287deb256b23fc5ed49a60 - SwiftLint: e14651157288e9e01d6e1a71db7014fb5744a8ea + SwiftLint: ce933681be10c3266e82576dad676fa815a602e9 SwiftValidator: 46cdd2061962df3ee8bab3c536dea9b34191d459 TableKit: 61880e4c13ac0ba396a308fcb1ae48f6dec8b458 UIScrollView-InfiniteScroll: c132d6d5851daff229ab4a1060ccf70a05a051c9 -PODFILE CHECKSUM: 73e5e2c6d2eafde7ff0ee904b88ce1a1ff2669b2 +PODFILE CHECKSUM: 18dadbe1461045569b8c35d705ed56bcac3325c6 COCOAPODS: 1.4.0 diff --git a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift index 209d080..a24be3a 100644 --- a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift +++ b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift @@ -253,7 +253,7 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController }) .disposed(by: disposeBag) - viewModel.validationResult + viewModel.validationResultDriver .drive(onNext: { [weak self] validationResult in guard let validationResult = validationResult else { return diff --git a/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift b/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift index d0a1d29..de5533b 100644 --- a/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift +++ b/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift @@ -44,7 +44,7 @@ open class BasePassCodeViewModel: BaseViewModel { public let passCodeConfiguration: PassCodeConfiguration private let validationResultHolder = Variable(nil) - var validationResult: Driver { + public var validationResultDriver: Driver { return validationResultHolder.asDriver() } diff --git a/Sources/Services/BasePassCodeService.swift b/Sources/Services/BasePassCodeService.swift index 9277d98..b494d5d 100644 --- a/Sources/Services/BasePassCodeService.swift +++ b/Sources/Services/BasePassCodeService.swift @@ -21,7 +21,7 @@ // import KeychainAccess -import IDZSwiftCommonCrypto +import CryptoSwift private enum Keys { static let passCodeHash = "passCodeHashKey" @@ -80,7 +80,7 @@ public extension BasePassCodeService { /// Saves new pass code func save(passCode: String?) { if let passCode = passCode { - keychain[Keys.passCodeHash] = sha256(passCode) + keychain[Keys.passCodeHash] = passCode.sha256() } else { keychain[Keys.passCodeHash] = nil } @@ -88,7 +88,7 @@ public extension BasePassCodeService { /// Check if pass code is correct func check(passCode: String) -> Bool { - return sha256(passCode) == passCodeHash + return passCode.sha256() == passCodeHash } /// Reset pass code settings @@ -98,14 +98,3 @@ public extension BasePassCodeService { } } - -private extension BasePassCodeService { - - func sha256(_ str: String) -> String? { - guard let digests = Digest(algorithm: .sha256).update(string: str)?.final() else { - return nil - } - return hexString(fromArray: digests) - } - -} diff --git a/Sources/Services/MaskFieldTextProxy.swift b/Sources/Services/MaskFieldTextProxy.swift deleted file mode 100644 index 660f6e0..0000000 --- a/Sources/Services/MaskFieldTextProxy.swift +++ /dev/null @@ -1,60 +0,0 @@ -import InputMask -import RxCocoa -import RxSwift - -class MaskFieldTextProxy: NSObject { - - private var disposeBag = DisposeBag() - - fileprivate let text = Variable("") - - fileprivate let isCompleteHolder = Variable(false) - var isComplete: Bool { - return isCompleteHolder.value - } - var isCompleteObservable: Observable { - return isCompleteHolder.asObservable() - } - - private(set) var field: UITextField? - - private let maskedProxy: PolyMaskTextFieldDelegate - - init(primaryFormat: String, affineFormats: [String] = []) { - maskedProxy = PolyMaskTextFieldDelegate(primaryFormat: primaryFormat, affineFormats: affineFormats) - - super.init() - - maskedProxy.listener = self - } - - func configure(with field: UITextField) { - self.field = field - field.delegate = maskedProxy - } - - private func bindData() { - disposeBag = DisposeBag() - - text.asDriver() - .distinctUntilChanged() - .drive(onNext: { [weak self] value in - guard let textField = self?.field else { - return - } - - self?.maskedProxy.put(text: value, into: textField) - }) - .disposed(by: disposeBag) - } - -} - -extension MaskFieldTextProxy: MaskedTextFieldDelegateListener { - - func textField(_ textField: UITextField, didFillMandatoryCharacters complete: Bool, didExtractValue value: String) { - text.value = value - isCompleteHolder.value = complete - } - -}