diff --git a/KeePassiumLib/KeePassiumLib.xcodeproj/project.pbxproj b/KeePassiumLib/KeePassiumLib.xcodeproj/project.pbxproj index 386c8bf22..bea6fa1ba 100755 --- a/KeePassiumLib/KeePassiumLib.xcodeproj/project.pbxproj +++ b/KeePassiumLib/KeePassiumLib.xcodeproj/project.pbxproj @@ -433,10 +433,10 @@ }; 7544570225CAE2D50011386C /* XCRemoteSwiftPackageReference "TPInAppReceipt" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/keepassium/TPInAppReceipt"; + repositoryURL = "https://github.com/tikhop/TPInAppReceipt"; requirement = { - branch = keepassium; - kind = branch; + kind = upToNextMajorVersion; + minimumVersion = 4.0.2; }; }; 757C51CD29F17D3C008986F4 /* XCRemoteSwiftPackageReference "SwiftDomainParser" */ = { diff --git a/KeePassiumLib/KeePassiumLib.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/KeePassiumLib/KeePassiumLib.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 241f60f6a..aeddcfc25 100644 --- a/KeePassiumLib/KeePassiumLib.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/KeePassiumLib/KeePassiumLib.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,13 +1,31 @@ { - "originHash" : "2de0205983087a32442cab968f3ec78a4daeee33028d87ab915ddf1f4904ac7d", + "originHash" : "2b51243d2440f95856b4528312c6d157d05f16ef894bb58f258659ba75e9139b", "pins" : [ { - "identity" : "asn1swift", + "identity" : "swift-asn1", "kind" : "remoteSourceControl", - "location" : "https://github.com/keepassium/ASN1Swift", + "location" : "https://github.com/apple/swift-asn1", "state" : { - "revision" : "b53bee03a942623db25afc5bfb80227b2cb3b425", - "version" : "1.2.4" + "revision" : "810496cf121e525d660cd0ea89a758740476b85f", + "version" : "1.5.1" + } + }, + { + "identity" : "swift-certificates", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-certificates.git", + "state" : { + "revision" : "7d5f6124c91a2d06fb63a811695a3400d15a100e", + "version" : "1.17.1" + } + }, + { + "identity" : "swift-crypto", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-crypto.git", + "state" : { + "revision" : "6f70fa9eab24c1fd982af18c281c4525d05e3095", + "version" : "4.2.0" } }, { @@ -31,10 +49,10 @@ { "identity" : "tpinappreceipt", "kind" : "remoteSourceControl", - "location" : "https://github.com/keepassium/TPInAppReceipt", + "location" : "https://github.com/tikhop/TPInAppReceipt", "state" : { - "branch" : "keepassium", - "revision" : "6630e3858f0d0a5803cede6f82afeaed5f5de7b6" + "revision" : "3ec500058c3cb62d0e736bf83c22b93b60279bd0", + "version" : "4.0.2" } } ], diff --git a/KeePassiumLib/KeePassiumLib/premium/IARError+description.swift b/KeePassiumLib/KeePassiumLib/premium/IARError+description.swift index f99f5add3..377b36780 100644 --- a/KeePassiumLib/KeePassiumLib/premium/IARError+description.swift +++ b/KeePassiumLib/KeePassiumLib/premium/IARError+description.swift @@ -8,82 +8,65 @@ import TPInAppReceipt -extension IARError: @retroactive LocalizedError { - +extension AppReceiptError: @retroactive LocalizedError { public var errorDescription: String? { switch self { - case .initializationFailed(reason: let reason): - return "Initialization failed. \(reason.localizedDescription)" - case .validationFailed(reason: let reason): - return "Validation failed. \(reason.localizedDescription)" - case .purchaseExpired: - return "Purchase expired." - case .receiptRefreshingInProgress: - return "Receipt refreshing in progress." + case .appStoreReceiptNotFound: + return "App Store receipt not found." + case .receiptContentInvalid(let error): + return "Receipt content invalid. \(error.localizedDescription)" + case .receiptPayloadMissingOrInvalid: + return "Receipt payload missing or invalid." + case .decodingFailed(let error): + return "Receipt decoding failed. \(error.localizedDescription)" } } } -extension IARError.ReceiptInitializationFailureReason: @retroactive LocalizedError { - +extension ChainVerificationError: @retroactive LocalizedError { public var errorDescription: String? { switch self { - case .appStoreReceiptNotFound: - return "App Store receipt not found." - case .pkcs7ParsingError: - return "PKCS7 parsing error." - case .dataIsInvalid: - return "Receipt data is invalid." + case .invalidCertificateData: + return "Invalid certificate data." + case .chainValidationFailed: + return "Certificate chain validation failed." + case .revocationCheckFailed: + return "Certificate revocation check failed." } } } -extension IARError.ValidationFailureReason: @retroactive LocalizedError { - +extension SignatureVerificationError: @retroactive LocalizedError { public var errorDescription: String? { switch self { - case .hashValidation: - return "Hash validation." - case .signatureValidation(reason: let reason): - return "Signature validation. \(reason.localizedDescription)" - case .bundleIdentifierVerification: - return "Bundle identifier verification." - case .bundleVersionVerification: - return "Bundle version verification." + case .invalidKey: + return "Invalid signature key." + case .invalidSignature: + return "Invalid signature." } } } -extension IARError.SignatureValidationFailureReason: @retroactive LocalizedError { +extension HashVerificationError: @retroactive LocalizedError { + public var errorDescription: String? { + switch self { + case .missingDeviceIdentifier: + return "Missing device identifier." + case .hashMismatch: + return "Receipt hash mismatch." + } + } +} +extension MetaVerificationError: @retroactive LocalizedError { public var errorDescription: String? { switch self { - case .appleIncRootCertificateNotFound: - return "Apple Inc root certificate not found." - case .unableToLoadAppleIncRootCertificate: - return "Unable to load Apple Inc root certificate." - case .unableToLoadAppleIncPublicKey: - return "Unable to load Apple Inc public key." - case .unableToLoadiTunesCertificate: - return "Unable to load iTunes certificate." - case .unableToLoadiTunesPublicKey: - return "Unable to load iTunes public key." - case .unableToLoadWorldwideDeveloperCertificate: - return "Unable to load WWDC certificate." - case .unableToLoadAppleIncPublicSecKey: - return "Unable to load Apple Inc public sec key." - case .receiptIsNotSigned: - return "Receipt is not signed." - case .receiptSignedDataNotFound: - return "Receipt signed data not found." - case .receiptDataNotFound: - return "Receipt data not found." - case .signatureNotFound: - return "Signature not found." - case .invalidSignature: - return "Invalid signature." - case .invalidCertificateChainOfTrust: - return "Invalid certificate chain of trust." + case .bundleIdentifierMismatch: + return "Bundle identifier mismatch." + case .versionIdentifierMismatch: + return "Bundle version mismatch." + case .bundleInfoUnavailable: + return "Bundle info unavailable." } } } diff --git a/KeePassiumLib/KeePassiumLib/premium/ReceiptAnalyzer.swift b/KeePassiumLib/KeePassiumLib/premium/ReceiptAnalyzer.swift index 15dc6e4b6..bf46bbfe0 100644 --- a/KeePassiumLib/KeePassiumLib/premium/ReceiptAnalyzer.swift +++ b/KeePassiumLib/KeePassiumLib/premium/ReceiptAnalyzer.swift @@ -6,7 +6,7 @@ // by the Free Software Foundation: https://www.gnu.org/licenses/). // For commercial licensing, please contact the author. -import TPInAppReceipt +@_spi(Blocking) import TPInAppReceipt private let dateFormatter: DateFormatter = { let dateFormatter = DateFormatter() @@ -158,7 +158,7 @@ class ReceiptAnalyzer { static func logPurchaseHistory() { do { - let receipt = try InAppReceipt.localReceipt() + let receipt = try AppReceipt.local_blocking guard receipt.hasPurchases else { Diag.debug("No previous purchases found.") return @@ -201,7 +201,7 @@ class ReceiptAnalyzer { } do { - let receipt = try InAppReceipt.localReceipt() + let receipt = try AppReceipt.local_blocking guard receipt.hasPurchases else { return PurchaseHistory.empty } @@ -223,7 +223,7 @@ class ReceiptAnalyzer { private func processLifetimePurchases( - _ receipt: InAppReceipt, + _ receipt: AppReceipt, _ purchaseHistory: inout PurchaseHistory ) { for lifetimeProduct in InAppProduct.allForever { @@ -246,7 +246,7 @@ class ReceiptAnalyzer { private func processVersionPurchases( - _ receipt: InAppReceipt, + _ receipt: AppReceipt, _ purchaseHistory: inout PurchaseHistory ) { guard let purchasedVersion = getLatestPurchasedVersion(receipt) else { @@ -293,7 +293,7 @@ class ReceiptAnalyzer { } } - private func getLatestPurchasedVersion(_ receipt: InAppReceipt) -> InAppPurchase? { + private func getLatestPurchasedVersion(_ receipt: AppReceipt) -> InAppPurchase? { let versionPurchases = receipt.purchases.filter { purchase in guard purchase.cancellationDate == nil else { return false } guard let product = InAppProduct(rawValue: purchase.productIdentifier) else { @@ -310,7 +310,7 @@ class ReceiptAnalyzer { private func processSubscriptionPurchases( - _ receipt: InAppReceipt, + _ receipt: AppReceipt, _ purchaseHistory: inout PurchaseHistory ) { purchaseHistory.containsTrial = receipt.autoRenewablePurchases.contains {