mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 03:33:36 +01:00
[AltServer] Removes unnecessary #available checks
This commit is contained in:
@@ -53,31 +53,22 @@ class AnisetteDataManager: NSObject
|
|||||||
|
|
||||||
func requestAnisetteData(_ completion: @escaping (Result<ALTAnisetteData, Error>) -> Void)
|
func requestAnisetteData(_ completion: @escaping (Result<ALTAnisetteData, Error>) -> Void)
|
||||||
{
|
{
|
||||||
if #available(macOS 10.15, *)
|
self.requestAnisetteDataFromXPCService { (result) in
|
||||||
{
|
do
|
||||||
self.requestAnisetteDataFromXPCService { (result) in
|
{
|
||||||
do
|
let anisetteData = try result.get()
|
||||||
{
|
completion(.success(anisetteData))
|
||||||
let anisetteData = try result.get()
|
}
|
||||||
completion(.success(anisetteData))
|
catch CocoaError.xpcConnectionInterrupted
|
||||||
}
|
{
|
||||||
catch CocoaError.xpcConnectionInterrupted
|
// SIP and/or AMFI are not disabled, so fall back to Mail plug-in.
|
||||||
{
|
self.requestAnisetteDataFromPlugin { (result) in
|
||||||
// SIP and/or AMFI are not disabled, so fall back to Mail plug-in.
|
completion(result)
|
||||||
self.requestAnisetteDataFromPlugin { (result) in
|
|
||||||
completion(result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
completion(.failure(error))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch
|
||||||
else
|
{
|
||||||
{
|
completion(.failure(error))
|
||||||
self.requestAnisetteDataFromPlugin { (result) in
|
|
||||||
completion(result)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +87,6 @@ class AnisetteDataManager: NSObject
|
|||||||
|
|
||||||
private extension AnisetteDataManager
|
private extension AnisetteDataManager
|
||||||
{
|
{
|
||||||
@available(macOS 10.15, *)
|
|
||||||
func requestAnisetteDataFromXPCService(completion: @escaping (Result<ALTAnisetteData, Error>) -> Void)
|
func requestAnisetteDataFromXPCService(completion: @escaping (Result<ALTAnisetteData, Error>) -> Void)
|
||||||
{
|
{
|
||||||
guard let proxy = self.xpcConnection.remoteObjectProxyWithErrorHandler({ (error) in
|
guard let proxy = self.xpcConnection.remoteObjectProxyWithErrorHandler({ (error) in
|
||||||
|
|||||||
@@ -272,12 +272,6 @@ private extension PluginManager
|
|||||||
return completionHandler(.success(pluginVersion))
|
return completionHandler(.success(pluginVersion))
|
||||||
}
|
}
|
||||||
|
|
||||||
guard #available(macOS 11, *) else {
|
|
||||||
// macOS versions prior to 11.0 require Mail plug-ins be *unsigned*,
|
|
||||||
// so we hardcode these versions to use the unsigned AltPlugin v1.0.
|
|
||||||
return completionHandler(.success(.v1_0))
|
|
||||||
}
|
|
||||||
|
|
||||||
let dataTask = self.session.dataTask(with: .altPluginUpdateURL) { (data, response, error) in
|
let dataTask = self.session.dataTask(with: .altPluginUpdateURL) { (data, response, error) in
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -313,16 +307,12 @@ private extension PluginManager
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
let fileURL = try result.get()
|
let fileURL = try result.get()
|
||||||
|
let data = try Data(contentsOf: fileURL)
|
||||||
|
let sha256Hash = SHA256.hash(data: data)
|
||||||
|
let hashString = sha256Hash.compactMap { String(format: "%02x", $0) }.joined()
|
||||||
|
|
||||||
if #available(OSX 10.15, *)
|
print("Comparing Mail plug-in hash (\(hashString)) against expected hash (\(pluginVersion.sha256Hash))...")
|
||||||
{
|
guard hashString == pluginVersion.sha256Hash else { throw PluginError.mismatchedHash(hash: hashString, expectedHash: pluginVersion.sha256Hash) }
|
||||||
let data = try Data(contentsOf: fileURL)
|
|
||||||
let sha256Hash = SHA256.hash(data: data)
|
|
||||||
let hashString = sha256Hash.compactMap { String(format: "%02x", $0) }.joined()
|
|
||||||
|
|
||||||
print("Comparing Mail plug-in hash (\(hashString)) against expected hash (\(pluginVersion.sha256Hash))...")
|
|
||||||
guard hashString == pluginVersion.sha256Hash else { throw PluginError.mismatchedHash(hash: hashString, expectedHash: pluginVersion.sha256Hash) }
|
|
||||||
}
|
|
||||||
|
|
||||||
completion(.success(fileURL))
|
completion(.success(fileURL))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ struct PluginVersion: Decodable
|
|||||||
var sha256Hash: String
|
var sha256Hash: String
|
||||||
var version: String
|
var version: String
|
||||||
|
|
||||||
static let v1_0 = PluginVersion(url: URL(string: "https://f000.backblazeb2.com/file/altstore/altserver/altplugin/1_0.zip")!,
|
|
||||||
sha256Hash: "070e9b7e1f74e7a6474d36253ab5a3623ff93892acc9e1043c3581f2ded12200",
|
|
||||||
version: "1.0")
|
|
||||||
|
|
||||||
static let v1_9 = PluginVersion(url: Bundle.main.url(forResource: "AltPlugin", withExtension: "zip")!,
|
static let v1_9 = PluginVersion(url: Bundle.main.url(forResource: "AltPlugin", withExtension: "zip")!,
|
||||||
sha256Hash: "83ead26d8776ef6850e06fe3d1c5c5559aca284718b1cf3cc49785ba6b1e2849",
|
sha256Hash: "83ead26d8776ef6850e06fe3d1c5c5559aca284718b1cf3cc49785ba6b1e2849",
|
||||||
version: "1.9")
|
version: "1.9")
|
||||||
|
|||||||
Reference in New Issue
Block a user