diff --git a/AltServer/Connections/ALTWiredConnection.mm b/AltServer/Connections/ALTWiredConnection.mm index aa674063..6ad1f3f8 100644 --- a/AltServer/Connections/ALTWiredConnection.mm +++ b/AltServer/Connections/ALTWiredConnection.mm @@ -20,6 +20,8 @@ { _device = [device copy]; _connection = connection; + + self.connected = YES; } return self; diff --git a/AltServer/Connections/WirelessConnectionHandler.swift b/AltServer/Connections/WirelessConnectionHandler.swift index 9efb1d23..1db96c54 100644 --- a/AltServer/Connections/WirelessConnectionHandler.swift +++ b/AltServer/Connections/WirelessConnectionHandler.swift @@ -144,5 +144,10 @@ private extension WirelessConnectionHandler connection.disconnect() self.disconnectionHandler?(connection) + + if let networkConnection = connection as? NetworkConnection + { + networkConnection.nwConnection.stateUpdateHandler = nil + } } } diff --git a/AltServer/Devices/ALTDeviceManager.mm b/AltServer/Devices/ALTDeviceManager.mm index ef6bedc7..a7d6aff7 100644 --- a/AltServer/Devices/ALTDeviceManager.mm +++ b/AltServer/Devices/ALTDeviceManager.mm @@ -1198,29 +1198,36 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT { return finish([NSError errorWithMobileImageMounterError:err device:altDevice]); } - - if (result) + + plist_t errorDescriptionNode = plist_dict_get_item(result, "DetailedError"); + if (errorDescriptionNode != NULL) { - plist_free(result); - } - - // Verify the installed developer disk is compatible with altDevice's operating system version. - ALTDebugConnection *testConnection = [[ALTDebugConnection alloc] initWithDevice:altDevice]; - [testConnection connectWithCompletionHandler:^(BOOL success, NSError * _Nullable error) { - [testConnection disconnect]; + char *errorDescription = NULL; + plist_get_string_val(errorDescriptionNode, &errorDescription); - if (success) + NSString *nsErrorDescription = @(errorDescription); + plist_free(result); + + NSError *returnError = nil; + + if ([nsErrorDescription containsString:@"Failed to verify"]) { - // Connection succeeded, so we assume the developer disk is compatible. - finish(nil); + // iOS device needs to be rebooted in order to mount disk to /Developer. + NSString *recoverySuggestion = [NSString stringWithFormat:NSLocalizedString(@"Please reboot %@ and try again.", @""), altDevice.name]; + + // ALTServerErrorUnderlyingError uses its underlying error's failure reason as its error description (if one exists), + // so assign our recovery suggestion to NSLocalizedFailureReasonErrorKey to make sure it's always displayed on client. + NSError *underlyingError = [NSError errorWithDomain:AltServerConnectionErrorDomain code:ALTServerConnectionErrorUnknown userInfo:@{NSLocalizedFailureReasonErrorKey: recoverySuggestion}]; + + returnError = [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorUnderlyingError userInfo:@{NSUnderlyingErrorKey: underlyingError}]; } - else if ([error.domain isEqualToString:AltServerConnectionErrorDomain] && error.code == ALTServerConnectionErrorUnknown) + else { - // Connection failed with .unknown error code, so we assume the developer disk is NOT compatible. + // Installation failed, so we assume the developer disk is NOT compatible with this iOS version. + NSMutableDictionary *userInfo = [@{ ALTOperatingSystemVersionErrorKey: NSStringFromOperatingSystemVersion(altDevice.osVersion), NSFilePathErrorKey: diskURL.path, - NSUnderlyingErrorKey: error, } mutableCopy]; NSString *osName = ALTOperatingSystemNameForDeviceType(altDevice.type); @@ -1229,8 +1236,22 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT userInfo[ALTOperatingSystemNameErrorKey] = osName; } - NSError *returnError = [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorIncompatibleDeveloperDisk userInfo:userInfo]; - finish(returnError); + returnError = [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorIncompatibleDeveloperDisk userInfo:userInfo]; + } + + return finish(returnError); + } + + plist_free(result); + + // Verify that the developer disk has been successfully installed. + ALTDebugConnection *testConnection = [[ALTDebugConnection alloc] initWithDevice:altDevice]; + [testConnection connectWithCompletionHandler:^(BOOL success, NSError * _Nullable error) { + [testConnection disconnect]; + + if (success) + { + finish(nil); } else { diff --git a/AltServer/Plugin/PluginManager.swift b/AltServer/Plugin/PluginManager.swift index bb0d99e4..fb2e9c09 100644 --- a/AltServer/Plugin/PluginManager.swift +++ b/AltServer/Plugin/PluginManager.swift @@ -66,10 +66,11 @@ class PluginManager do { // If Mail plug-in is not yet installed, then there is no update available. - guard let bundle = Bundle(url: pluginURL) else { return completionHandler(.success(false)) } + var isDirectory: ObjCBool = false + guard FileManager.default.fileExists(atPath: pluginURL.path, isDirectory: &isDirectory), isDirectory.boolValue else { return completionHandler(.success(false)) } // Load Info.plist from disk because Bundle.infoDictionary is cached by system. - let infoDictionaryURL = bundle.bundleURL.appendingPathComponent("Contents/Info.plist") + let infoDictionaryURL = pluginURL.appendingPathComponent("Contents/Info.plist") guard let infoDictionary = NSDictionary(contentsOf: infoDictionaryURL) as? [String: Any], let localVersion = infoDictionary["CFBundleShortVersionString"] as? String else { throw CocoaError(.fileReadCorruptFile, userInfo: [NSURLErrorKey: infoDictionaryURL]) } diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index 60d3a944..8cb680fb 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -2814,7 +2814,7 @@ CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEVELOPMENT_TEAM = 6XVY5G3U44; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -2847,7 +2847,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14.4; - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 1.5.1b; PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltServer; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -2867,7 +2867,7 @@ CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 65; + CURRENT_PROJECT_VERSION = 66; DEVELOPMENT_TEAM = 6XVY5G3U44; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -2900,7 +2900,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14.4; - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 1.5.1b; PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltServer; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -3371,8 +3371,8 @@ "$(PROJECT_DIR)/Dependencies/fragmentzip", "$(PROJECT_DIR)/Dependencies/libcurl", ); - MARKETING_VERSION = 1.5; PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltStore; + MARKETING_VERSION = 1.5.1b; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "AltStore/AltStore-Bridging-Header.h"; @@ -3405,8 +3405,8 @@ "$(PROJECT_DIR)/Dependencies/fragmentzip", "$(PROJECT_DIR)/Dependencies/libcurl", ); - MARKETING_VERSION = 1.5; PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltStore; + MARKETING_VERSION = 1.5.1b; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "AltStore/AltStore-Bridging-Header.h"; diff --git a/AltStore/Info.plist b/AltStore/Info.plist index a3c66dea..8b17b705 100644 --- a/AltStore/Info.plist +++ b/AltStore/Info.plist @@ -9,7 +9,7 @@ ALTDeviceID 00008110-000A68390A82801E ALTServerID - 1AAAB6FD-E8CE-4B70-8F26-4073215C03B0 + 1F7D5B55-79CE-4546-A029-D4DDC4AF3B6D CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDocumentTypes diff --git a/AltStore/Operations/AuthenticationOperation.swift b/AltStore/Operations/AuthenticationOperation.swift index 6c717ea9..1aaf81bd 100644 --- a/AltStore/Operations/AuthenticationOperation.swift +++ b/AltStore/Operations/AuthenticationOperation.swift @@ -49,6 +49,7 @@ class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, ALTAppl private lazy var storyboard = UIStoryboard(name: "Authentication", bundle: nil) + private var appleIDEmailAddress: String? private var appleIDPassword: String? private var shouldShowInstructions = false @@ -174,6 +175,13 @@ class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, ALTAppl } account.update(account: altTeam.account) + + if let providedEmailAddress = self.appleIDEmailAddress + { + // Save the user's provided email address instead of the one associated with their account (which may be outdated). + account.appleID = providedEmailAddress + } + team.update(team: altTeam) try context.save() @@ -242,7 +250,7 @@ class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, ALTAppl try context.save() // Update keychain - Keychain.shared.appleIDEmailAddress = altTeam.account.appleID + Keychain.shared.appleIDEmailAddress = self.appleIDEmailAddress ?? altTeam.account.appleID // Prefer the user's provided email address over the one associated with their account (which may be outdated). Keychain.shared.appleIDPassword = self.appleIDPassword Keychain.shared.signingCertificate = altCertificate.p12Data() @@ -359,6 +367,8 @@ private extension AuthenticationOperation func authenticate(appleID: String, password: String, completionHandler: @escaping (Result<(ALTAccount, ALTAppleAPISession), Swift.Error>) -> Void) { + self.appleIDEmailAddress = appleID + let fetchAnisetteDataOperation = FetchAnisetteDataOperation(context: self.context) fetchAnisetteDataOperation.resultHandler = { (result) in switch result diff --git a/AltStore/Resources/apps.json b/AltStore/Resources/apps.json index 92c1e930..a321c16d 100644 --- a/AltStore/Resources/apps.json +++ b/AltStore/Resources/apps.json @@ -36,14 +36,14 @@ "bundleIdentifier": "com.rileytestut.AltStore.Beta", "developerName": "Riley Testut", "subtitle": "An alternative App Store for iOS.", - "version": "1.5rc", - "versionDate": "2022-04-19T13:00:00-07:00", - "versionDescription": "**AltStore 1.5 Release Candidate**\n\nTRUSTED SOURCES*\nTrusted Sources are sources that we've personally reviewed to make sure they meet our safety standards. You can view all Trusted Sources from the Sources page and add them with a single tap.\n\nIMPROVEMENTS\n• Loads “Friend Tier” Patrons much faster on Patreon screen.\n\n*Adding “untrusted” sources via the + button is still supported.", - "downloadURL": "https://cdn.altstore.io/file/altstore/apps/altstore/1_5_rc.ipa", + "version": "1.5.1b", + "versionDate": "2022-05-27T12:00:00-07:00", + "versionDescription": "This beta fixes the following issues:\n\n• Using Apple IDs that contain capital letters\n• Using Apple IDs with 2FA enabled without any trusted devices\n• Repeatedly asking some users to sign in every refresh\n• \"Incorrect Apple ID or password\" error after changing Apple ID email address\n• “Application is missing application-identifier” error when sideloading or (de-)activating certain apps", + "downloadURL": "https://cdn.altstore.io/file/altstore/apps/altstore/1_5_1_b.ipa", "localizedDescription": "AltStore is an alternative app store for non-jailbroken devices. \n\nThis beta release of AltStore adds support for 3rd party sources, allowing you to download apps from other developers directly through AltStore.", "iconURL": "https://user-images.githubusercontent.com/705880/65270980-1eb96f80-dad1-11e9-9367-78ccd25ceb02.png", "tintColor": "018084", - "size": 5458029, + "size": 5464776, "beta": true, "screenshotURLs": [ "https://user-images.githubusercontent.com/705880/78942028-acf54300-7a6d-11ea-821c-5bb7a9b3e73a.PNG", diff --git a/Dependencies/AltSign b/Dependencies/AltSign index b1116d5d..3d6fbeac 160000 --- a/Dependencies/AltSign +++ b/Dependencies/AltSign @@ -1 +1 @@ -Subproject commit b1116d5dc631e95dc51a512c8262f3a669bceb3a +Subproject commit 3d6fbeac25cf3cc3302ede5cee2888733eded399 diff --git a/Shared/Categories/NSError+ALTServerError.m b/Shared/Categories/NSError+ALTServerError.m index 381250bb..dfb5a1ba 100644 --- a/Shared/Categories/NSError+ALTServerError.m +++ b/Shared/Categories/NSError+ALTServerError.m @@ -145,6 +145,8 @@ NSErrorUserInfoKey const ALTOperatingSystemVersionErrorKey = @"ALTOperatingSyste return failureReason; } } + + return nil; } - (nullable NSString *)altserver_localizedRecoverySuggestion