Skip to content

Commit

Permalink
Completely remove PRO and make Enterprise Certificate choosing always…
Browse files Browse the repository at this point in the history
… available
  • Loading branch information
iSecNew10 committed Mar 26, 2023
1 parent 3b07ef5 commit 0717cac
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 99 deletions.
19 changes: 3 additions & 16 deletions appdb/API/API+Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion appdb/Startup/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 6 additions & 22 deletions appdb/Startup/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ extension Defaults.Keys {
static let duplicateApp = Key<Bool>("duplicateApp", default: true)
static let plusStatus = Key<String>("plus_account_status", default: "")
static let plusStatusTranslated = Key<String>("plus_account_status_translated", default: "")
static let usesEnterpriseCert = Key<Bool>("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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -231,10 +220,6 @@ enum Preferences {
static var duplicateApp: Bool {
defaults[.duplicateApp]
}

static var usesEnterpriseCert: Bool {
defaults[.usesEnterpriseCert]
}
}

extension Preferences {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions appdb/Tabs/Settings/Settings+Sections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
69 changes: 18 additions & 51 deletions appdb/Tabs/Settings/Settings+StaticCells.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions appdb/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions appdb/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 0717cac

Please sign in to comment.