From f38ed3f4fa3d0f73eb098c43c71d6608b6c19d6f Mon Sep 17 00:00:00 2001 From: Pavel Tikhonenko Date: Wed, 3 Jul 2019 03:28:19 +0300 Subject: [PATCH] Minor verification improvements --- TPInAppReceipt.xcodeproj/project.pbxproj | 4 ++-- TPInAppReceipt/Source/Validation.swift | 13 ++++++------- iOS Example/ViewController.swift | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/TPInAppReceipt.xcodeproj/project.pbxproj b/TPInAppReceipt.xcodeproj/project.pbxproj index 877bb2d..ccea104 100644 --- a/TPInAppReceipt.xcodeproj/project.pbxproj +++ b/TPInAppReceipt.xcodeproj/project.pbxproj @@ -768,7 +768,7 @@ DEVELOPMENT_TEAM = Y357EKMWLB; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "iOS Example/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -792,7 +792,7 @@ DEVELOPMENT_TEAM = Y357EKMWLB; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "iOS Example/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.tikhop.InAppReceipt.iOS-Example"; diff --git a/TPInAppReceipt/Source/Validation.swift b/TPInAppReceipt/Source/Validation.swift index a37883b..cd5b5d0 100644 --- a/TPInAppReceipt/Source/Validation.swift +++ b/TPInAppReceipt/Source/Validation.swift @@ -54,13 +54,13 @@ public extension InAppReceipt } #if os(iOS) || os(watchOS) || os(tvOS) - guard let v = Bundle.main.infoDictionary?["CFBundleVersion"] as? String, + guard let v = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String, v == originalAppVersion else { throw IARError.validationFailed(reason: .bundleVersionVefirication) } #elseif os(macOS) - guard let v = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String, + guard let v = Bundle.main.infoDictionary?["CFBundleVersion"] as? String, v == originalAppVersion else { throw IARError.validationFailed(reason: .bundleVersionVefirication) @@ -104,13 +104,12 @@ public extension InAppReceipt let opaqueData = opaqueValue let bundleIdData = bundleIdentifierData - var hash: Array = Array.init(repeating: 0, count: 20) var sha1 = SHA1() - hash = try! sha1.update(withBytes: uuidData.bytes) - hash = try! sha1.update(withBytes: opaqueData.bytes) - hash = sha1.calculate(for: bundleIdData.bytes) + try! sha1.update(withBytes: uuidData.bytes) + try! sha1.update(withBytes: opaqueData.bytes) + let hash = sha1.calculate(for: bundleIdData.bytes) - return Data(bytes: hash, count: hash.count) + return Data(hash) } } diff --git a/iOS Example/ViewController.swift b/iOS Example/ViewController.swift index b5dbc77..1c211f4 100644 --- a/iOS Example/ViewController.swift +++ b/iOS Example/ViewController.swift @@ -9,7 +9,7 @@ import UIKit import TPInAppReceipt -var rBase64 = "You Receupt" +var rBase64 = "Your Receipt" class ViewController: UIViewController {