Skip to content

Commit

Permalink
Fix bugs, implement api v1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
stev3fvcks committed Aug 23, 2023
1 parent af04ded commit c512376
Show file tree
Hide file tree
Showing 19 changed files with 294 additions and 44 deletions.
8 changes: 8 additions & 0 deletions appdb.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@
81FC8B4522736CC1003788F3 /* MyAppstoreCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81FC8B4422736CC1003788F3 /* MyAppstoreCell.swift */; };
81FCAFCE226E1028004FAFD6 /* QueuedDownloadsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81FCAFCD226E1028004FAFD6 /* QueuedDownloadsCell.swift */; };
81FCAFD0226E1D0C004FAFD6 /* RequestedApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81FCAFCF226E1D0C004FAFD6 /* RequestedApp.swift */; };
C469E68A2A95B370001A24DC /* SigningCerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6892A95B370001A24DC /* SigningCerts.swift */; };
C469E6902A9671E8001A24DC /* API+UDID.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E68F2A9671E8001A24DC /* API+UDID.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -727,6 +729,8 @@
81FCAFCF226E1D0C004FAFD6 /* RequestedApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestedApp.swift; sourceTree = "<group>"; };
81FFE92125F3E1440074F8F1 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
88BEFFC722B3A24A008FD371 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
C469E6892A95B370001A24DC /* SigningCerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningCerts.swift; sourceTree = "<group>"; };
C469E68F2A9671E8001A24DC /* API+UDID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "API+UDID.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -1047,6 +1051,7 @@
813F01842A7C02C2008DCA2E /* Plus */ = {
isa = PBXGroup;
children = (
C469E6892A95B370001A24DC /* SigningCerts.swift */,
813F01852A7C02C2008DCA2E /* PlusPurchaseWeb.swift */,
813F01862A7C02C2008DCA2E /* PlusPurchase.swift */,
813F01872A7C02C2008DCA2E /* PlusPurchaseCell.swift */,
Expand Down Expand Up @@ -1682,6 +1687,7 @@
813F015D2A7C01ED008DCA2E /* API+AltStoreRepos.swift */,
813F015E2A7C01ED008DCA2E /* API+Dylibs.swift */,
813F015C2A7C01ED008DCA2E /* API+Plus.swift */,
C469E68F2A9671E8001A24DC /* API+UDID.swift */,
);
path = API;
sourceTree = "<group>";
Expand Down Expand Up @@ -2356,6 +2362,7 @@
81F1FE7F1E5AF12400C1CD44 /* DismissableModalNavController.swift in Sources */,
81876E2F227B192B00E27CB8 /* Library+Extension.swift in Sources */,
81324068205BD86000945CE9 /* Settings+StaticCells.swift in Sources */,
C469E6902A9671E8001A24DC /* API+UDID.swift in Sources */,
81F1FE831E5B123A00C1CD44 /* Details+Header.swift in Sources */,
813F016B2A7C0216008DCA2E /* AltStoreRepo.swift in Sources */,
817610EF21515A3200602FF2 /* API+SystemStatus.swift in Sources */,
Expand Down Expand Up @@ -2490,6 +2497,7 @@
817A40E41E5E2FB2003FD6F1 /* SnappableFlowLayout.swift in Sources */,
813F018B2A7C02C2008DCA2E /* AltStoreAppDetails.swift in Sources */,
811B570B227DDBED000B2866 /* LocalIPAUploadUtil.swift in Sources */,
C469E68A2A95B370001A24DC /* SigningCerts.swift in Sources */,
8189255A227CC9690096F661 /* AdaptiveUIAlertController.swift in Sources */,
81A1038E1F7FCA030011F4B3 /* DynamicFontSizeHelper.swift in Sources */,
811A824D2289D18C00969946 /* AdditionalInstallOptionsViewController.swift in Sources */,
Expand Down
12 changes: 5 additions & 7 deletions appdb/API/API+Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,19 @@ extension API {
Preferences.set(.deviceVersion, to: data["ios_version"].stringValue)

// Preferences.set(.isPlus, to: data["is_plus"].stringValue == "yes")
let plusUntil = data["plus_till"].stringValue
let formatter = DateFormatter()
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss Z" // RFC 2822
formatter.locale = Locale(identifier: "en_US")
if let plusUntilDate = formatter.date(from: plusUntil) {
Preferences.set(.isPlus, to: plusUntilDate.timeIntervalSince1970 > Date().timeIntervalSince1970)
}
let plusUntil = data["plus_till"].stringValue.unixToDate
Preferences.set(.isPlus, to: plusUntil.timeIntervalSince1970 > Date().timeIntervalSince1970)
Preferences.set(.plusUntil, to: data["plus_till"].stringValue)
Preferences.set(.enterpriseCertId, to: data["enterprise_cert_id"].stringValue)
Preferences.set(.signingWith, to: data["signing_with"].stringValue)
Preferences.set(.freeSignsLeft, to: data["free_signs_left"].stringValue)
Preferences.set(.freeSignsResetAt, to: data["free_signs_reset_at"].stringValue)
Preferences.set(.p12ValidationResult, to: data["p12_validation_result"].boolValue)

Preferences.set(.plusStatus, to: data["plus_account"]["status"].stringValue)
Preferences.set(.plusStatusTranslated, to: data["plus_account"]["status_translated"].stringValue)
Preferences.set(.plusProvider, to: data["plus_provider"].stringValue)
Preferences.set(.plusSupportUri, to: data["plus_support_uri"].stringValue)

Preferences.set(.disableRevocationChecks, to: data["disable_protection_checks"].stringValue == "yes")
Preferences.set(.forceDisablePRO, to: data["is_pro_disabled"].stringValue == "yes")
Expand Down
2 changes: 2 additions & 0 deletions appdb/API/API+DeviceLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ extension API {
} else {
// Save token
Preferences.set(.token, to: json["data"]["link_token"].stringValue)



// Update link code
API.getLinkCode(success: {
Expand Down
48 changes: 48 additions & 0 deletions appdb/API/API+UDID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// API+UDID.swift
// appdb
//
// Created by stev3fvcks on 23.08.23.
// Copyright © 2023 stev3fvcks. All rights reserved.
//

import Foundation
import Alamofire
import SwiftyJSON

extension API {

static func getUDID(success: @escaping (String) -> Void, fail: @escaping (String) -> Void) {

// Get UDID from managed configuration
guard let deviceUdid = UserDefaults.standard.dictionary(forKey: "com.apple.configuration.managed")?["dbservicesUDID"] as? String else {
AF.request(Global.signingCertsUdidApi + "&lt=\(Preferences.linkToken)", parameters: ["client": "appdb unofficial client"], headers: headers)
.responseJSON { response in
switch response.result {
case .success(let value):
let json = JSON(value)

if !json["success"].boolValue {
fail("Invalid device link")
} else {
let email = json["data"]["email"].stringValue
let udid = json["data"]["udid"].stringValue
Preferences.set(.email, to: email)
Preferences.set(.udid, to: udid)

// Update link code
API.getLinkCode(success: {
success(udid)
}, fail: { error in
fail(error)
})
}
case .failure(let error):
fail(error.localizedDescription)
}
}
return
}
success(deviceUdid)
}
}
1 change: 1 addition & 0 deletions appdb/API/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ enum Actions: String {
case editAltStoreRepo = "edit_altstore_repo"
case deleteAltStoreRepo = "delete_altstore_repo"
case getPlusPurchaseOptions = "get_plus_purchase_options"
case getSideloadingOptions = "get_sideloading_options"
case getFeatures = "get_features"
case getDylibs = "get_dylibs"
case addDylib = "add_dylib"
Expand Down
23 changes: 23 additions & 0 deletions appdb/Other/Images.xcassets/Info.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Info.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Info 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Info 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added appdb/Other/Images.xcassets/Info.imageset/Info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AdditionalInstallOptionsViewController: TableViewController {

var cancelled = true

private let placeholder: String = Global.randomString(length: 5).lowercased()
private var placeholder: String = Global.randomString(length: 5).lowercased()

private let rowHeight: CGFloat = 50
func getHeight() -> CGFloat {
Expand Down Expand Up @@ -106,9 +106,16 @@ class AdditionalInstallOptionsViewController: TableViewController {

navigationItem.rightBarButtonItem?.isEnabled = true

var rows: [StaticRow] = []
var rows: [StaticRow] = []
var addedRowTypes: [String] = []

for installationOption in installationOptions {
if addedRowTypes.contains(where: { _addedRowType in
return _addedRowType == installationOption.identifier.rawValue
}) {
continue;
}
addedRowTypes.append(installationOption.identifier.rawValue)
switch installationOption.identifier {
case .name:
rows.append(StaticRow(text: "New display name".localized(), cellClass: StaticTextFieldCell.self, context:
Expand All @@ -125,9 +132,10 @@ class AdditionalInstallOptionsViewController: TableViewController {
self.reloadTable()
}, "value": Preferences.duplicateApp]))
if Preferences.duplicateApp {
self.placeholder = Global.randomString(length: 5).lowercased()
self.newId = self.placeholder
rows.append(StaticRow(text: "New ID".localized(), cellClass: StaticTextFieldCell.self, context:
["placeholder": installationOption.placeholder /*placeholder*/, "callback": { [unowned self] (newId: String) in
["placeholder": installationOption.placeholder.isEmpty ? self.placeholder : installationOption.placeholder /*placeholder*/, "callback": { [unowned self] (newId: String) in
self.newId = newId.isEmpty ? /*installationOption.placeholder*/ self.placeholder : newId
self.setInstallButtonEnabled()
}, "forceLowercase": true, "characterLimit": 5]
Expand Down
3 changes: 3 additions & 0 deletions appdb/Startup/Global.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ enum Global {

static let githubSite: String = "https://github.com/n3d1117/appdb"
static let donateSite: String = "https://www.buymeacoffee.com/ne_do"
static let signingCertsEmbedUrl: String = "https://api.signingcerts.com/v1/products/?embed=html"
static let signingCertsUdidApi: String = "https://api.signingcerts.com/v1/appdb-udid/"
static let signingCertsBlogArticle: String = "https://signingcerts.com/blog/apple-signing-certificates-what-they-are-and-how-use-them"
// static let email: String = "[email protected]"
static let email: String = "[email protected]"
static let telegram: String = "https://t.me/stev3fvcks"
Expand Down
16 changes: 16 additions & 0 deletions appdb/Startup/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ enum SecureKeys: String, CaseIterable {
case isPlus
case plusUntil
case plusProvider
case plusSupportUri
case p12ValidationResult
case udid
}

enum Preferences {
Expand All @@ -62,6 +65,10 @@ enum Preferences {
static var email: String {
KeychainWrapper.standard.string(forKey: SecureKeys.email.rawValue) ?? ""
}

static var udid: String {
KeychainWrapper.standard.string(forKey: SecureKeys.udid.rawValue) ?? ""
}

static var deviceIsLinked: Bool {
!(KeychainWrapper.standard.string(forKey: SecureKeys.token.rawValue) ?? "").isEmpty
Expand All @@ -86,6 +93,10 @@ enum Preferences {
static var plusProvider: String {
KeychainWrapper.standard.string(forKey: SecureKeys.plusProvider.rawValue) ?? ""
}

static var plusSupportUri: String {
KeychainWrapper.standard.string(forKey: SecureKeys.plusSupportUri.rawValue) ?? ""
}

static var revoked: Bool {
KeychainWrapper.standard.bool(forKey: SecureKeys.revoked.rawValue) ?? false
Expand All @@ -106,6 +117,11 @@ enum Preferences {
static var linkToken: String {
KeychainWrapper.standard.string(forKey: SecureKeys.token.rawValue) ?? ""
}


static var p12ValidationResult: Bool {
KeychainWrapper.standard.bool(forKey: SecureKeys.p12ValidationResult.rawValue) ?? false
}

// Non sensitive data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class EnterpriseCertChooser: UITableViewController {
super.viewDidLoad()

title = "Choose Enterprise Certificate".localized()

navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "info"), style: .plain, target: self, action: #selector(openSigningInfoBlogArticle))

tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.rowHeight = 50
Expand Down Expand Up @@ -86,39 +88,64 @@ class EnterpriseCertChooser: UITableViewController {
self.tableView.reloadData()
}
}

@objc private func openSigningInfoBlogArticle() {
UIApplication.shared.open(URL(string: Global.signingCertsBlogArticle)!)
}

@objc private func dismissAnimated() { dismiss(animated: true) }

// MARK: - UITableViewDelegate

override func numberOfSections(in tableView: UITableView) -> Int {
1
Preferences.p12ValidationResult ? 1 : 2
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
availableCertificates.count
section == 0 ? availableCertificates.count : 1
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
let certificate = availableCertificates[indexPath.row]
cell.textLabel?.text = certificate.name

if indexPath.section == 0 {
let certificate = availableCertificates[indexPath.row]
cell.textLabel?.text = certificate.name
cell.accessoryType = certificate.id == currentCertificate?.id ? .checkmark : .none
} else {
cell.textLabel?.text = "Most Reliable Signing Certificate + Service guarantee for 1 year + Instant Activation!".localized()
cell.accessoryType = .disclosureIndicator
}
cell.textLabel?.textAlignment = .center
cell.textLabel?.numberOfLines = 3
cell.textLabel?.theme_textColor = Color.title
cell.textLabel?.makeDynamicFont()
cell.accessoryType = certificate.id == currentCertificate?.id ? .checkmark : .none
cell.setBackgroundColor(Color.veryVeryLightGray)
cell.theme_backgroundColor = Color.veryVeryLightGray
cell.selectedBackgroundView = bgColorView
return cell
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return section == 0 ? "Public Free Enterprise Certificates (frequent revokes and device blacklists)".localized() : "1-Year-Guaranteed signing certificates".localized()
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard availableCertificates.indices.contains(indexPath.row) else { return }
let certificate = availableCertificates[indexPath.row]
if currentCertificate?.id != certificate.id {
change(to: certificate)
tableView.deselectRow(at: indexPath, animated: true)
if indexPath.section == 0 {
guard availableCertificates.indices.contains(indexPath.row) else { return }
let certificate = availableCertificates[indexPath.row]
if currentCertificate?.id != certificate.id {
change(to: certificate)
}
} else {
present(SigningCerts(), animated: true)
}
}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return indexPath.section == 0 ? 75 : 85
}

fileprivate func change(to certificate: EnterpriseCertificate) {
Preferences.set(.enterpriseCertId, to: certificate.id)
Expand Down
2 changes: 2 additions & 0 deletions appdb/Tabs/Settings/Plus/PlusPurchase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import UIKit
import WebKit

/** not in use for now */

class PlusPurchase: LoadingTableView {

private var bgColorView: UIView = {
Expand Down
Loading

0 comments on commit c512376

Please sign in to comment.