From e1df30dadb1950ada8e5ae43675c49cd95791388 Mon Sep 17 00:00:00 2001 From: Andy Boedo Date: Wed, 8 May 2024 18:46:14 -0300 Subject: [PATCH] updated the checks for the receipt signature so that they only run if we can't verify the environment from the receipt itself --- Sources/Misc/SandboxEnvironmentDetector.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/Misc/SandboxEnvironmentDetector.swift b/Sources/Misc/SandboxEnvironmentDetector.swift index d96345e335..b228e51cf2 100644 --- a/Sources/Misc/SandboxEnvironmentDetector.swift +++ b/Sources/Misc/SandboxEnvironmentDetector.swift @@ -50,7 +50,14 @@ final class BundleSandboxEnvironmentDetector: SandboxEnvironmentDetector { } #if os(macOS) || targetEnvironment(macCatalyst) - return !self.isProductionReceipt || !self.isMacAppStore + // this relies on an undocumented field in the receipt that provides the Environment. + // if it's not present, we go to a secondary check. + if let isProductionReceipt = self.isProductionReceipt { + return !isProductionReceipt + } else { + return !self.isMacAppStore + } + #else return path.contains("sandboxReceipt") #endif @@ -73,12 +80,12 @@ extension BundleSandboxEnvironmentDetector: Sendable {} private extension BundleSandboxEnvironmentDetector { - var isProductionReceipt: Bool { + var isProductionReceipt: Bool? { do { return try self.receiptFetcher.fetchAndParseLocalReceipt().environment == .production } catch { Logger.error(Strings.receipt.parse_receipt_locally_error(error: error)) - return false + return nil } }