diff --git a/CHANGELOG.md b/CHANGELOG.md index 636d1f5..f8b824b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 4.12.0 +- Disabled DeviceCheck for lab test +- Updated UI + ## 4.11.0 - Updated UI diff --git a/README.md b/README.md index 7273626..f04097f 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,10 @@ For convenience, there's a `rebuild.sh` script which performs actions mentioned To launch it, type `sh rebuild.sh` in your console. ## ChangeLog +**4.12.0** +- Disabled DeviceCheck for lab test +- Updated UI + **4.11.0** - Updated UI diff --git a/project.yml b/project.yml index 727173c..09beeab 100644 --- a/project.yml +++ b/project.yml @@ -42,7 +42,7 @@ targets: PushMutableContent: settings: CODE_SIGN_STYLE: Manual - MARKETING_VERSION: "4.11.0" + MARKETING_VERSION: "4.12.0" CURRENT_PROJECT_VERSION: 746 TARGETED_DEVICE_FAMILY: 1,2 type: app-extension @@ -77,7 +77,7 @@ targets: deploymentTarget: "12.1" settings: CODE_SIGN_STYLE: Manual - MARKETING_VERSION: "4.11.0" + MARKETING_VERSION: "4.12.0" CURRENT_PROJECT_VERSION: 746 TARGETED_DEVICE_FAMILY: 1 SWIFT_OBJC_BRIDGING_HEADER: $(PROJECT_DIR)/safesafe/App/safesafe-Bridging-Header.h diff --git a/safesafe/Services/Free test/FreeTestService.swift b/safesafe/Services/Free test/FreeTestService.swift index c15cbf4..8e4c9be 100644 --- a/safesafe/Services/Free test/FreeTestService.swift +++ b/safesafe/Services/Free test/FreeTestService.swift @@ -9,8 +9,10 @@ import Foundation import PromiseKit import Moya -class FreeTestService { - +final class FreeTestService { + + // MARK: - Properties + private let localStorage: RealmLocalStorage? private let deviceCheckService: DeviceCheckServiceProtocol private let apiProvider: MoyaProvider @@ -18,37 +20,35 @@ class FreeTestService { private let renewableRequest: RenewableRequest private var jsOnSubscriptionInfoClosure: ((FreeTestSubscriptionInfoResponse) -> ())? - + + // MARK: - Initialization + init( with localStorage: RealmLocalStorage?, deviceCheckService: DeviceCheckServiceProtocol, apiProvider: MoyaProvider, - configuration: RemoteConfigProtocol) { - + configuration: RemoteConfigProtocol + ) { self.localStorage = localStorage self.deviceCheckService = deviceCheckService self.apiProvider = apiProvider - self.renewableRequest = .init(provider: apiProvider, alertManager: NetworkingAlertManager(), notRenewableErrorCodes: [400]) + self.renewableRequest = .init( + provider: apiProvider, + alertManager: NetworkingAlertManager(), + notRenewableErrorCodes: [400] + ) self.configuration = configuration } func uploadPIN(jsRequest: FreeTestUploadPinRequest) -> Promise { - deviceCheckService.generatePayload() - .then { deviceCheckToken -> Promise<(String, DeviceGUIDModel)> in - console("📗 Device Check Token (1/3)\n:\(deviceCheckToken)") - return self.generateGUIDIfNeeded().map { (deviceCheckToken, $0) } - } - .then { deviceCheckToken, guidModel -> Promise in - console("📗 Generate GUID (2/3)\n:\(guidModel)") - let headers = FreeTestRequestHeader(deviceCheckToken: deviceCheckToken) - let request = FreeTestCreateSubscriptionRequestModel(code: jsRequest.pin, guid: guidModel.uuid) - - return self.createSubscription(headers: headers, request: request) - } - .then { apiResponse -> Promise in - console("📗 API Response (3/3)\n:\(apiResponse)") - return .value(.init(result: .success)) - } + return generateGUIDIfNeeded() + .then { guid -> Promise in + let request = FreeTestCreateSubscriptionRequestModel(code: jsRequest.pin, guid: guid.uuid) + return self.createSubscription(request: request) + }.then { apiResponse -> Promise in + console("📗 API Response \n:\(apiResponse)") + return .value(.init(result: .success)) + } } func subscriptionInfo() -> Promise { @@ -142,7 +142,7 @@ class FreeTestService { let nowTimestamp = Int(Date().timeIntervalSince1970) guard (nowTimestamp - guid.update) > config.interval else { return } - let headers = FreeTestRequestHeader(deviceCheckToken: deviceCheckToken, accessToken: guid.token) + let headers = FreeTestRequestHeader(accessToken: guid.token) let target: FreeTestTarget = .getSubscription(header: headers, request: FreeTestGetSubscriptionRequestModel(guid: guid.uuid)) self?.apiProvider.request(target) { result in switch result { @@ -205,11 +205,14 @@ class FreeTestService { } } -// Cloud API -// +// MARK: - CloudAPI + private extension FreeTestService { - func createSubscription(headers: FreeTestRequestHeader, request: FreeTestCreateSubscriptionRequestModel) -> Promise { - let target: FreeTestTarget = .createSubscription(header: headers, request: request) + func createSubscription( + header: FreeTestRequestHeader = .init(), + request: FreeTestCreateSubscriptionRequestModel + ) -> Promise { + let target: FreeTestTarget = .createSubscription(header: header, request: request) return renewableRequest.make(target: target) .recover { error -> Promise in if (error as? InternalError) == nil { @@ -230,6 +233,5 @@ private extension FreeTestService { throw error } } - } } diff --git a/safesafe/Services/Free test/Model/Networking/FreeTestRequestHeader.swift b/safesafe/Services/Free test/Model/Networking/FreeTestRequestHeader.swift index 391492e..71c1ba7 100644 --- a/safesafe/Services/Free test/Model/Networking/FreeTestRequestHeader.swift +++ b/safesafe/Services/Free test/Model/Networking/FreeTestRequestHeader.swift @@ -8,19 +8,20 @@ import Foundation struct FreeTestRequestHeader: Codable, RequestHeader { - + + // MARK: - Properties + enum CodingKeys: String, CodingKey { - case deviceCheckToken = "Safety-Token" case userAgent = "User-Agent" case accessToken = "Authorization" } - let deviceCheckToken: String let userAgent = "ios" let accessToken: String? - - init(deviceCheckToken: String, accessToken: String? = nil) { - self.deviceCheckToken = deviceCheckToken + + // MARK: - Initialization + + init(accessToken: String? = nil) { if let accessToken = accessToken { self.accessToken = "Bearer \(accessToken)" } else {