From 0717cace94677b563572fae048c472327f8efdeb Mon Sep 17 00:00:00 2001 From: iSecNew10 Date: Sun, 26 Mar 2023 20:43:12 +0200 Subject: [PATCH] Completely remove PRO and make Enterprise Certificate choosing always available --- appdb/API/API+Configuration.swift | 19 +---- appdb/Startup/AppDelegate.swift | 2 +- appdb/Startup/Preferences.swift | 28 ++------ .../EnterpriseCertChooser.swift | 2 +- appdb/Tabs/Settings/Settings+Sections.swift | 12 ++-- .../Tabs/Settings/Settings+StaticCells.swift | 69 +++++-------------- appdb/de.lproj/Localizable.strings | 2 + appdb/en.lproj/Localizable.strings | 1 + 8 files changed, 36 insertions(+), 99 deletions(-) diff --git a/appdb/API/API+Configuration.swift b/appdb/API/API+Configuration.swift index d9fa7c3e..aa74d248 100644 --- a/appdb/API/API+Configuration.swift +++ b/appdb/API/API+Configuration.swift @@ -40,21 +40,11 @@ extension API { Preferences.set(.ignoreCompatibility, to: data["ignore_compatibility"].stringValue == "yes") Preferences.set(.askForInstallationOptions, to: data["ask_for_installation_options"].stringValue == "yes") - Preferences.set(.proRevoked, to: isRevoked) - Preferences.set(.proRevokedOn, to: revokedOn) - if Preferences.proRevoked { - Preferences.set(.pro, to: false) - } else { - Preferences.set(.pro, to: data["is_pro"].stringValue == "yes") - } - Preferences.set(.proUntil, to: data["pro_till"].stringValue) + Preferences.set(.revoked, to: isRevoked) + Preferences.set(.revokedOn, to: revokedOn) if !data["p12_password"].stringValue.isEmpty, !data["p12"].stringValue.isEmpty, !data["provision"].stringValue.isEmpty { - if Preferences.pro { - Preferences.set(.usesCustomDeveloperIdentity, to: data["is_pro_disabled"].stringValue == "yes") - } else { - Preferences.set(.usesCustomDeveloperIdentity, to: true) - } + Preferences.set(.usesCustomDeveloperIdentity, to: true) } else { Preferences.set(.usesCustomDeveloperIdentity, to: false) } @@ -77,9 +67,6 @@ extension API { Preferences.set(.freeSignsLeft, to: data["free_signs_left"].stringValue) Preferences.set(.freeSignsResetAt, to: data["free_signs_reset_at"].stringValue) - // @todo update as soon as there is a specific field for it in API response - Preferences.set(.usesEnterpriseCert, to: data["signing_with"].stringValue == "Sideloading with 3rd party certificate") - Preferences.set(.plusStatus, to: data["plus_account"]["status"].stringValue) Preferences.set(.plusStatusTranslated, to: data["plus_account"]["status_translated"].stringValue) diff --git a/appdb/Startup/AppDelegate.swift b/appdb/Startup/AppDelegate.swift index 9af6025b..7286d188 100644 --- a/appdb/Startup/AppDelegate.swift +++ b/appdb/Startup/AppDelegate.swift @@ -81,7 +81,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UITabBarControllerDelegat TelemetryManager.initialize(with: configuration) TelemetryManager.send(Global.Telemetry.launched.rawValue, with: [ "isLinked": Preferences.deviceIsLinked.description, - "isPro": Preferences.pro.description + "isPlus": Preferences.isPlus.description ]) return true diff --git a/appdb/Startup/Preferences.swift b/appdb/Startup/Preferences.swift index 52a780c0..64ee3337 100644 --- a/appdb/Startup/Preferences.swift +++ b/appdb/Startup/Preferences.swift @@ -38,17 +38,14 @@ extension Defaults.Keys { static let duplicateApp = Key("duplicateApp", default: true) static let plusStatus = Key("plus_account_status", default: "") static let plusStatusTranslated = Key("plus_account_status_translated", default: "") - static let usesEnterpriseCert = Key("uses_enterprise_cert", default: false) } // Sensitive data is stored in Keychain enum SecureKeys: String, CaseIterable { case token case linkCode - case pro - case proUntil - case proRevoked - case proRevokedOn + case revoked + case revokedOn case usesCustomDeveloperIdentity case freeSignsLeft case freeSignsResetAt @@ -90,20 +87,12 @@ enum Preferences { KeychainWrapper.standard.string(forKey: SecureKeys.plusProvider.rawValue) ?? "" } - static var pro: Bool { - KeychainWrapper.standard.bool(forKey: SecureKeys.pro.rawValue) ?? false + static var revoked: Bool { + KeychainWrapper.standard.bool(forKey: SecureKeys.revoked.rawValue) ?? false } - static var proUntil: String { - KeychainWrapper.standard.string(forKey: SecureKeys.proUntil.rawValue) ?? "" - } - - static var proRevoked: Bool { - KeychainWrapper.standard.bool(forKey: SecureKeys.proRevoked.rawValue) ?? false - } - - static var proRevokedOn: String { - KeychainWrapper.standard.string(forKey: SecureKeys.proRevokedOn.rawValue) ?? "" + static var revokedOn: String { + KeychainWrapper.standard.string(forKey: SecureKeys.revokedOn.rawValue) ?? "" } static var usesCustomDeveloperIdentity: Bool { @@ -231,10 +220,6 @@ enum Preferences { static var duplicateApp: Bool { defaults[.duplicateApp] } - - static var usesEnterpriseCert: Bool { - defaults[.usesEnterpriseCert] - } } extension Preferences { @@ -289,7 +274,6 @@ extension Preferences { UserDefaults.standard.removeObject(forKey: Defaults.Keys.duplicateApp.name) UserDefaults.standard.removeObject(forKey: Defaults.Keys.isAppleSilicon.name) UserDefaults.standard.removeObject(forKey: Defaults.Keys.signingWith.name) - UserDefaults.standard.removeObject(forKey: Defaults.Keys.usesEnterpriseCert.name) } // Remove secure keys diff --git a/appdb/Tabs/Settings/Enterprise Cert Chooser/EnterpriseCertChooser.swift b/appdb/Tabs/Settings/Enterprise Cert Chooser/EnterpriseCertChooser.swift index cb501ae0..4b9ee2a0 100644 --- a/appdb/Tabs/Settings/Enterprise Cert Chooser/EnterpriseCertChooser.swift +++ b/appdb/Tabs/Settings/Enterprise Cert Chooser/EnterpriseCertChooser.swift @@ -38,7 +38,7 @@ class EnterpriseCertChooser: UITableViewController { override func viewDidLoad() { super.viewDidLoad() - title = "Enterprise Certificate".localized() + title = "Choose Enterprise Certificate".localized() tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") tableView.rowHeight = 50 diff --git a/appdb/Tabs/Settings/Settings+Sections.swift b/appdb/Tabs/Settings/Settings+Sections.swift index 5cdd89ae..019f2bc8 100644 --- a/appdb/Tabs/Settings/Settings+Sections.swift +++ b/appdb/Tabs/Settings/Settings+Sections.swift @@ -114,14 +114,10 @@ extension Settings { }, accessory: .disclosureIndicator, cellClass: SimpleStaticCell.self), Row(text: "Signing".localized(), selection: { [unowned self] _ in - if !Preferences.usesCustomDeveloperIdentity && (Preferences.proRevoked || !Preferences.pro && Preferences.enterpriseCertId.isEmpty) { - self.openInSafari(self.proSite) - } else if Preferences.usesEnterpriseCert { - let certificateChooser = EnterpriseCertChooser() - certificateChooser.changedCertDelegate = self - self.push(certificateChooser) - } - }, cellClass: SimpleStaticSigningCertificateCell.self, context: ["active": Preferences.pro, "signingWith": Preferences.signingWith, "isPlus": Preferences.isPlus, "plusUntil": Preferences.plusUntil, "plusAccountStatus": Preferences.plusAccountStatusTranslated, "enterpriseCertId": Preferences.enterpriseCertId, "freeSignsLeft": Preferences.freeSignsLeft, "freeSignsResetAt": Preferences.freeSignsResetAt, "expire": Preferences.proUntil, "revoked": Preferences.proRevoked, "revokedOn": Preferences.proRevokedOn, "usesCustomDevIdentity": Preferences.usesCustomDeveloperIdentity, "usesEnterpriseCert": Preferences.usesEnterpriseCert]), + let certificateChooser = EnterpriseCertChooser() + certificateChooser.changedCertDelegate = self + self.push(certificateChooser) + }, cellClass: SimpleStaticSigningCertificateCell.self, context: ["signingWith": Preferences.signingWith, "isPlus": Preferences.isPlus, "plusUntil": Preferences.plusUntil, "plusAccountStatus": Preferences.plusAccountStatusTranslated, "enterpriseCertId": Preferences.enterpriseCertId, "freeSignsLeft": Preferences.freeSignsLeft, "freeSignsResetAt": Preferences.freeSignsResetAt, "revoked": Preferences.revoked, "revokedOn": Preferences.revokedOn, "usesCustomDevIdentity": Preferences.usesCustomDeveloperIdentity]), Row(text: "PLUS Status".localized(), selection: { [unowned self] _ in if !Preferences.isPlus { diff --git a/appdb/Tabs/Settings/Settings+StaticCells.swift b/appdb/Tabs/Settings/Settings+StaticCells.swift index b92f94f8..0c0dde80 100644 --- a/appdb/Tabs/Settings/Settings+StaticCells.swift +++ b/appdb/Tabs/Settings/Settings+StaticCells.swift @@ -173,72 +173,39 @@ final class SimpleStaticSigningCertificateCell: UITableViewCell, Cell { guard let plus = row.context?["isPlus"] as? Bool else { return } guard let plusUntil = (row.context?["plusUntil"] as? String)?.rfc2822decodedShort else { return } guard let plusAccountStatus = row.context?["plusAccountStatus"] as? String else { return } - guard let pro = row.context?["active"] as? Bool else { return } - guard let proExpirationDate = (row.context?["expire"] as? String)?.rfc2822decodedShort else { return } - guard let proRevoked = row.context?["revoked"] as? Bool else { return } - guard let proRevokedOn = (row.context?["revokedOn"] as? String)?.revokedDateDecoded else { return } + guard let revoked = row.context?["revoked"] as? Bool else { return } + guard let revokedOn = (row.context?["revokedOn"] as? String)?.revokedDateDecoded else { return } guard let usesCustomDeveloperIdentity = row.context?["usesCustomDevIdentity"] as? Bool else { return } - guard let usesEnterpriseCert = row.context?["usesEnterpriseCert"] as? Bool else { return } - if usesCustomDeveloperIdentity { activeLabel.theme_textColor = Color.softGreen activeLabel.text = "Custom Developer Identity".localized() - selectionStyle = .none - accessoryType = .none - if proRevoked { - expirationLabel.text = "Revoked on %@".localizedFormat(proRevokedOn) + if revoked { + expirationLabel.text = "Revoked on %@".localizedFormat(revokedOn) } } else if !plusAccountStatus.isEmpty { activeLabel.theme_textColor = Color.softGreen activeLabel.text = "Custom Developer Account".localized() - selectionStyle = .none - accessoryType = .none - } else if proRevoked { + } else if revoked { activeLabel.theme_textColor = Color.softRed - expirationLabel.text = "Revoked on %@".localizedFormat(proRevokedOn) + expirationLabel.text = "Revoked on %@".localizedFormat(revokedOn) activeLabel.text = "Revoked".localized() - accessoryType = .disclosureIndicator - let bgColorView = UIView() - bgColorView.theme_backgroundColor = Color.cellSelectionColor - selectedBackgroundView = bgColorView + } else if plus { + activeLabel.theme_textColor = Color.softGreen + expirationLabel.text = "Expires on %@".localizedFormat(plusUntil) + activeLabel.text = "Unlimited signs left".localized() } else { - if plus { - activeLabel.theme_textColor = Color.softGreen - expirationLabel.text = "Expires on %@".localizedFormat(plusUntil) - activeLabel.text = "Unlimited signs left".localized() - selectionStyle = .none - accessoryType = .none - } else if pro { - activeLabel.theme_textColor = Color.softGreen - expirationLabel.text = "Expires on %@".localizedFormat(proExpirationDate) - activeLabel.text = "Active".localized() - selectionStyle = .none - accessoryType = .none - } else if signingWith.isEmpty && enterpriseCertId.isEmpty { - activeLabel.theme_textColor = Color.softRed - expirationLabel.text = "Tap to know more".localized() - activeLabel.text = "Inactive".localized() - accessoryType = .disclosureIndicator - let bgColorView = UIView() - bgColorView.theme_backgroundColor = Color.cellSelectionColor - selectedBackgroundView = bgColorView - } else { - activeLabel.theme_textColor = freeSignsLeftNumber > 0 ? Color.softGreen : Color.softRed - expirationLabel.text = signingWith - activeLabel.text = "%@ signs left until %@".localizedFormat(freeSignsLeft, freeSignsResetAt.rfc2822decoded) - selectionStyle = .none - accessoryType = .none - if usesEnterpriseCert { - selectionStyle = .default - accessoryType = .disclosureIndicator - } - } + activeLabel.theme_textColor = freeSignsLeftNumber > 0 ? Color.softGreen : Color.softRed + expirationLabel.text = signingWith + activeLabel.text = "%@ signs left until %@".localizedFormat(freeSignsLeft, freeSignsResetAt.rfc2822decoded) } + + selectionStyle = .default + accessoryType = .disclosureIndicator - expirationLabel.isHidden = usesCustomDeveloperIdentity && !proRevoked + expirationLabel.isHidden = usesCustomDeveloperIdentity && !revoked - if usesCustomDeveloperIdentity && !proRevoked { + if usesCustomDeveloperIdentity && !revoked { constrain(activeLabel, replace: constraintGroup) { active in active.centerY ~== active.superview!.centerY active.trailing ~== active.superview!.trailingMargin diff --git a/appdb/de.lproj/Localizable.strings b/appdb/de.lproj/Localizable.strings index cf4bde4d..18d8c660 100644 --- a/appdb/de.lproj/Localizable.strings +++ b/appdb/de.lproj/Localizable.strings @@ -235,6 +235,8 @@ "Authorize app with link code from appdb website and enjoy unlimited app installs!" = "Autorisiere die App mit deinem Verknüpfungs/Linkcode von der Appdb Webseite und genieße unendlich viele App Installationen!"; "PLUS Status" = "PLUS Status"; "Signing" = "Signieren"; +"Choose Enterprise Certificate" = "Enterprise Zertifikat wählen +"; "%@ signs left until %@" = "%@ Signierungen übrig bis %@"; "Use this code if you want to link new devices to appdb. Press and hold the cell to copy it, or tap it to generate a new one." = "Nutze diesen Code, wenn du ein neues Gerät mit Appdb verknüpfen möchtest. Halte die Spalte gedrückt um den Code zu kopieren, oder tippe einmal darauf um einen neuen zu generieren."; "Device Status" = "Gerätestatus"; diff --git a/appdb/en.lproj/Localizable.strings b/appdb/en.lproj/Localizable.strings index b08085f9..6530853d 100644 --- a/appdb/en.lproj/Localizable.strings +++ b/appdb/en.lproj/Localizable.strings @@ -235,6 +235,7 @@ "Authorize app with link code from appdb website and enjoy unlimited app installs!" = "Authorize app with link code from appdb website and enjoy unlimited app installs!"; "PLUS Status" = "PLUS Status"; "Signing" = "Signing"; +"Choose Enterprise Certificate" = "Choose Enterprise Certificate"; "%@ signs left until %@" = "%@ signs left until %@"; "Use this code if you want to link new devices to appdb. Press and hold the cell to copy it, or tap it to generate a new one." = "Use this code if you want to link new devices to appdb. Press and hold the cell to copy it, or tap it to generate a new one."; "Device Status" = "Device Status";