mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-16 02:03:32 +01:00
[AltServer] Removes explicit AltStore download URL
This commit is contained in:
@@ -14,14 +14,6 @@ import AltSign
|
|||||||
import LaunchAtLogin
|
import LaunchAtLogin
|
||||||
import Sparkle
|
import Sparkle
|
||||||
|
|
||||||
#if STAGING
|
|
||||||
private let altstoreAppURL = URL(string: "https://f000.backblazeb2.com/file/altstore-staging/altstore.ipa")!
|
|
||||||
#elseif BETA
|
|
||||||
private let altstoreAppURL = URL(string: "https://cdn.altstore.io/file/altstore/altstore-beta.ipa")!
|
|
||||||
#else
|
|
||||||
private let altstoreAppURL = URL(string: "https://cdn.altstore.io/file/altstore/altstore.ipa")!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extension ALTDevice: MenuDisplayable {}
|
extension ALTDevice: MenuDisplayable {}
|
||||||
|
|
||||||
@NSApplicationMain
|
@NSApplicationMain
|
||||||
@@ -139,7 +131,7 @@ private extension AppDelegate
|
|||||||
{
|
{
|
||||||
@objc func installAltStore(to device: ALTDevice)
|
@objc func installAltStore(to device: ALTDevice)
|
||||||
{
|
{
|
||||||
self.installApplication(at: altstoreAppURL, to: device)
|
self.installApplication(at: nil, to: device)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func sideloadIPA(to device: ALTDevice)
|
@objc func sideloadIPA(to device: ALTDevice)
|
||||||
@@ -198,7 +190,7 @@ private extension AppDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func installApplication(at url: URL, to device: ALTDevice)
|
func installApplication(at fileURL: URL?, to device: ALTDevice)
|
||||||
{
|
{
|
||||||
let alert = NSAlert()
|
let alert = NSAlert()
|
||||||
alert.messageText = NSLocalizedString("Please enter your Apple ID and password.", comment: "")
|
alert.messageText = NSLocalizedString("Please enter your Apple ID and password.", comment: "")
|
||||||
@@ -268,7 +260,7 @@ private extension AppDelegate
|
|||||||
|
|
||||||
func install()
|
func install()
|
||||||
{
|
{
|
||||||
ALTDeviceManager.shared.installApplication(at: url, to: device, appleID: username, password: password, completion: finish(_:))
|
ALTDeviceManager.shared.installApplication(at: fileURL, to: device, appleID: username, password: password, completion: finish(_:))
|
||||||
}
|
}
|
||||||
|
|
||||||
AnisetteDataManager.shared.isXPCAvailable { isAvailable in
|
AnisetteDataManager.shared.isXPCAvailable { isAvailable in
|
||||||
|
|||||||
@@ -111,11 +111,11 @@ private extension ALTDeviceManager
|
|||||||
|
|
||||||
extension ALTDeviceManager
|
extension ALTDeviceManager
|
||||||
{
|
{
|
||||||
func installApplication(at url: URL, to altDevice: ALTDevice, appleID: String, password: String, completion: @escaping (Result<ALTApplication, Error>) -> Void)
|
func installApplication(at ipaFileURL: URL?, to altDevice: ALTDevice, appleID: String, password: String, completion: @escaping (Result<ALTApplication, Error>) -> Void)
|
||||||
{
|
{
|
||||||
let destinationDirectoryURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
let destinationDirectoryURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||||
|
|
||||||
var appName = (url.isFileURL) ? url.deletingPathExtension().lastPathComponent : NSLocalizedString("AltStore", comment: "")
|
var appName = ipaFileURL?.deletingPathExtension().lastPathComponent ?? NSLocalizedString("AltStore", comment: "")
|
||||||
|
|
||||||
func finish(_ result: Result<ALTApplication, Error>, failure: String? = nil)
|
func finish(_ result: Result<ALTApplication, Error>, failure: String? = nil)
|
||||||
{
|
{
|
||||||
@@ -164,7 +164,7 @@ extension ALTDeviceManager
|
|||||||
{
|
{
|
||||||
let certificate = try result.get()
|
let certificate = try result.get()
|
||||||
|
|
||||||
if !url.isFileURL
|
if ipaFileURL == nil
|
||||||
{
|
{
|
||||||
// Show alert before downloading remote .ipa.
|
// Show alert before downloading remote .ipa.
|
||||||
self.showInstallationAlert(appName: NSLocalizedString("AltStore", comment: ""), deviceName: device.name)
|
self.showInstallationAlert(appName: NSLocalizedString("AltStore", comment: ""), deviceName: device.name)
|
||||||
@@ -178,7 +178,7 @@ extension ALTDeviceManager
|
|||||||
fallthrough // Continue installing app even if we couldn't install Developer disk image.
|
fallthrough // Continue installing app even if we couldn't install Developer disk image.
|
||||||
|
|
||||||
case .success:
|
case .success:
|
||||||
self.downloadApp(from: url, for: altDevice) { (result) in
|
self.downloadApp(from: ipaFileURL, for: altDevice) { (result) in
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
let fileURL = try result.get()
|
let fileURL = try result.get()
|
||||||
@@ -188,7 +188,7 @@ extension ALTDeviceManager
|
|||||||
let appBundleURL = try FileManager.default.unzipAppBundle(at: fileURL, toDirectory: destinationDirectoryURL)
|
let appBundleURL = try FileManager.default.unzipAppBundle(at: fileURL, toDirectory: destinationDirectoryURL)
|
||||||
guard let application = ALTApplication(fileURL: appBundleURL) else { throw ALTError(.invalidApp) }
|
guard let application = ALTApplication(fileURL: appBundleURL) else { throw ALTError(.invalidApp) }
|
||||||
|
|
||||||
if url.isFileURL
|
if ipaFileURL != nil
|
||||||
{
|
{
|
||||||
// Show alert after "downloading" local .ipa.
|
// Show alert after "downloading" local .ipa.
|
||||||
self.showInstallationAlert(appName: application.name, deviceName: device.name)
|
self.showInstallationAlert(appName: application.name, deviceName: device.name)
|
||||||
@@ -305,9 +305,12 @@ extension ALTDeviceManager
|
|||||||
|
|
||||||
private extension ALTDeviceManager
|
private extension ALTDeviceManager
|
||||||
{
|
{
|
||||||
func downloadApp(from url: URL, for device: ALTDevice, completionHandler: @escaping (Result<URL, Error>) -> Void)
|
func downloadApp(from url: URL?, for device: ALTDevice, completionHandler: @escaping (Result<URL, Error>) -> Void)
|
||||||
{
|
{
|
||||||
guard !url.isFileURL else { return completionHandler(.success(url)) }
|
if let url, url.isFileURL
|
||||||
|
{
|
||||||
|
return completionHandler(.success(url))
|
||||||
|
}
|
||||||
|
|
||||||
self.fetchAltStoreDownloadURL(for: device) { result in
|
self.fetchAltStoreDownloadURL(for: device) { result in
|
||||||
switch result
|
switch result
|
||||||
|
|||||||
Reference in New Issue
Block a user