diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 86ed0982..9718c667 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -51,18 +51,6 @@ jobs: - name: Convert to IPA run: make ipa - - name: Upload SideStore.ipa Artifact - uses: actions/upload-artifact@v3.1.0 - with: - name: SideStore-${{ steps.version.outputs.version }}.ipa - path: SideStore.ipa - - - name: Upload *.dSYM Artifact - uses: actions/upload-artifact@v3.1.0 - with: - name: SideStore-dSYM - path: ./*.dSYM/ - - name: Get current date id: date run: echo "date=$(date -u +'%c')" >> $GITHUB_OUTPUT @@ -94,3 +82,18 @@ jobs: Built at (UTC date): `${{ steps.date_altstore.outputs.date }}` Commit SHA: `${{ github.sha }}` Version: `${{ steps.version.outputs.version }}` + + - name: Add version to IPA file name + run: mv SideStore.ipa SideStore-${{ steps.version.outputs.version }}.ipa + + - name: Upload SideStore.ipa Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: SideStore-${{ steps.version.outputs.version }}.ipa + path: SideStore-${{ steps.version.outputs.version }}.ipa + + - name: Upload *.dSYM Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: SideStore-${{ steps.version.outputs.version }}-dSYM + path: ./*.dSYM/ diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f7d43302..6091dbff 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -60,18 +60,6 @@ jobs: - name: Convert to IPA run: make ipa - - name: Upload SideStore.ipa Artifact - uses: actions/upload-artifact@v3.1.0 - with: - name: SideStore-${{ steps.version.outputs.version }}.ipa - path: SideStore.ipa - - - name: Upload *.dSYM Artifact - uses: actions/upload-artifact@v3.1.0 - with: - name: SideStore-dSYM - path: ./*.dSYM/ - - name: Get current date id: date run: echo "date=$(date -u +'%c')" >> $GITHUB_OUTPUT @@ -102,5 +90,20 @@ jobs: Commit SHA: `${{ github.sha }}` Version: `${{ steps.version.outputs.version }}` + - name: Add version to IPA file name + run: mv SideStore.ipa SideStore-${{ steps.version.outputs.version }}.ipa + + - name: Upload SideStore.ipa Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: SideStore-${{ steps.version.outputs.version }}.ipa + path: SideStore-${{ steps.version.outputs.version }}.ipa + + - name: Upload *.dSYM Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: SideStore-${{ steps.version.outputs.version }}-dSYM + path: ./*.dSYM/ + - name: Reset cache for apps.sidestore.io/nightly run: sleep 10 && curl https://apps.sidestore.io/reset-cache/nightly/${{ secrets.SIDESOURCE_KEY }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9e9fb876..6b2b7251 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -51,14 +51,17 @@ jobs: - name: Convert to IPA run: make ipa + - name: Add version to IPA file name + run: mv SideStore.ipa SideStore-${{ steps.version.outputs.version }}.ipa + - name: Upload SideStore.ipa Artifact uses: actions/upload-artifact@v3.1.0 with: name: SideStore-${{ steps.version.outputs.version }}.ipa - path: SideStore.ipa + path: SideStore-${{ steps.version.outputs.version }}.ipa - name: Upload *.dSYM Artifact uses: actions/upload-artifact@v3.1.0 with: - name: SideStore-dSYM + name: SideStore-${{ steps.version.outputs.version }}-dSYM path: ./*.dSYM/ diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml index 06a759ae..d1a6d1e5 100644 --- a/.github/workflows/stable.yml +++ b/.github/workflows/stable.yml @@ -48,18 +48,6 @@ jobs: - name: Convert to IPA run: make ipa - - name: Upload SideStore.ipa Artifact - uses: actions/upload-artifact@v3.1.0 - with: - name: SideStore-${{ steps.version.outputs.version }}.ipa - path: SideStore.ipa - - - name: Upload *.dSYM Artifact - uses: actions/upload-artifact@v3.1.0 - with: - name: SideStore-dSYM - path: ./*.dSYM/ - - name: Get current date id: date run: echo "date=$(date -u +'%c')" >> $GITHUB_OUTPUT @@ -88,3 +76,18 @@ jobs: Built at (UTC date): `${{ steps.date_altstore.outputs.date }}` Commit SHA: `${{ github.sha }}` Version: `${{ steps.version.outputs.version }}` + + - name: Add version to IPA file name + run: mv SideStore.ipa SideStore-${{ steps.version.outputs.version }}.ipa + + - name: Upload SideStore.ipa Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: SideStore-${{ steps.version.outputs.version }}.ipa + path: SideStore-${{ steps.version.outputs.version }}.ipa + + - name: Upload *.dSYM Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: SideStore-${{ steps.version.outputs.version }}-dSYM + path: ./*.dSYM/ diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index bebc2f4a..3059a000 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -63,6 +63,10 @@ 1F943C6F2927F90400ABE095 /* NewsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FAFC5B82927E0EE00B8D837 /* NewsView.swift */; }; 1F943C702927F90400ABE095 /* BrowseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FAFC5BA2927E0F800B8D837 /* BrowseView.swift */; }; 1F943C712927F90400ABE095 /* MyAppsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FAFC5BD2927E10D00B8D837 /* MyAppsView.swift */; }; + 1F981B1129AA0FAE0014950E /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F981B1029AA0FAE0014950E /* OnboardingView.swift */; }; + 1F981B1329AA101F0014950E /* OnboardingStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F981B1229AA101F0014950E /* OnboardingStepView.swift */; }; + 1F981B1529AA1E070014950E /* AppIconsShowcase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F981B1429AA1E070014950E /* AppIconsShowcase.swift */; }; + 1F981B1729AA34A70014950E /* AppStoreProductView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F981B1629AA34A70014950E /* AppStoreProductView.swift */; }; 1FA1C8CA294906890083119D /* MyAppsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FA1C8C9294906890083119D /* MyAppsViewModel.swift */; }; 1FA5A6CA298E8B2F007BA946 /* RefreshAttemptsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FA5A6C9298E8B2F007BA946 /* RefreshAttemptsView.swift */; }; 1FA5A6CC298E8FE4007BA946 /* MailComposeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FA5A6CB298E8FE4007BA946 /* MailComposeView.swift */; }; @@ -76,14 +80,17 @@ 1FB96FCF292BBBCA007E68D1 /* SiriShortcutSetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB96FCE292BBBC9007E68D1 /* SiriShortcutSetupView.swift */; }; 1FB96FEC292C171D007E68D1 /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB96FEB292C171D007E68D1 /* NotificationManager.swift */; }; 1FB96FF3292D0539007E68D1 /* PillButtonProgressViewStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB96FF2292D0539007E68D1 /* PillButtonProgressViewStyle.swift */; }; - 1FFA56C2299994390011B6F5 /* OutputCapturer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FFA56C1299994390011B6F5 /* OutputCapturer.swift */; }; - 1FFEF104298552DB0098374C /* AppVersionHistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FFEF103298552DB0098374C /* AppVersionHistoryView.swift */; }; - 4879A95F2861046500FC1BBD /* AltSign in Frameworks */ = {isa = PBXBuildFile; productRef = 4879A95E2861046500FC1BBD /* AltSign */; }; - 4879A9622861049C00FC1BBD /* OpenSSL in Frameworks */ = {isa = PBXBuildFile; productRef = 4879A9612861049C00FC1BBD /* OpenSSL */; }; 992C896029A6A56500FB3501 /* LocalConsole in Frameworks */ = {isa = PBXBuildFile; productRef = 992C895F29A6A56500FB3501 /* LocalConsole */; }; 994D6E9B29E326080045B3F7 /* minimuxer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99F87D1729D8E4C900B40039 /* minimuxer.swift */; }; 994D6EB529E35C130045B3F7 /* StoreApp+SideStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 994D6EB429E35C130045B3F7 /* StoreApp+SideStore.swift */; }; 99BCB7DF29A2AC050041D1A7 /* AdvancedSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99BCB7DE29A2AC050041D1A7 /* AdvancedSettingsView.swift */; }; + 1FF8C6182A1780C60041352C /* ActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FF8C6172A1780C60041352C /* ActivityView.swift */; }; + 1FF8C61B2A1782F10041352C /* Reachability in Frameworks */ = {isa = PBXBuildFile; productRef = 1FF8C61A2A1782F10041352C /* Reachability */; }; + 1FFA56C2299994390011B6F5 /* OutputCapturer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FFA56C1299994390011B6F5 /* OutputCapturer.swift */; }; + 1FFEF104298552DB0098374C /* AppVersionHistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FFEF103298552DB0098374C /* AppVersionHistoryView.swift */; }; + 4879A95F2861046500FC1BBD /* AltSign in Frameworks */ = {isa = PBXBuildFile; productRef = 4879A95E2861046500FC1BBD /* AltSign */; }; + 4879A9622861049C00FC1BBD /* OpenSSL in Frameworks */ = {isa = PBXBuildFile; productRef = 4879A9612861049C00FC1BBD /* OpenSSL */; }; + 9922FFEC29B501C50020F868 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = 9922FFEB29B501C50020F868 /* Starscream */; }; 99C4EF4D2979132100CB538D /* SemanticVersion in Frameworks */ = {isa = PBXBuildFile; productRef = 99C4EF4C2979132100CB538D /* SemanticVersion */; }; 99D87A60299F1B1100ED09A9 /* DevModeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99D87A5F299F1B1100ED09A9 /* DevModeView.swift */; }; 99D87A62299F3EC300ED09A9 /* FileExplorer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99D87A61299F3EC300ED09A9 /* FileExplorer.swift */; }; @@ -617,6 +624,10 @@ 1F943C632927EF4200ABE095 /* NewsItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsItemView.swift; sourceTree = ""; }; 1F943C652927F36600ABE095 /* NewsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsViewModel.swift; sourceTree = ""; }; 1F943C672927F39400ABE095 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = ""; }; + 1F981B1029AA0FAE0014950E /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = ""; }; + 1F981B1229AA101F0014950E /* OnboardingStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingStepView.swift; sourceTree = ""; }; + 1F981B1429AA1E070014950E /* AppIconsShowcase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconsShowcase.swift; sourceTree = ""; }; + 1F981B1629AA34A70014950E /* AppStoreProductView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreProductView.swift; sourceTree = ""; }; 1FA1C8C9294906890083119D /* MyAppsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyAppsViewModel.swift; sourceTree = ""; }; 1FA5A6C9298E8B2F007BA946 /* RefreshAttemptsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshAttemptsView.swift; sourceTree = ""; }; 1FA5A6CB298E8FE4007BA946 /* MailComposeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailComposeView.swift; sourceTree = ""; }; @@ -637,9 +648,10 @@ 1FB96FCE292BBBC9007E68D1 /* SiriShortcutSetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiriShortcutSetupView.swift; sourceTree = ""; }; 1FB96FEB292C171D007E68D1 /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = ""; }; 1FB96FF2292D0539007E68D1 /* PillButtonProgressViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillButtonProgressViewStyle.swift; sourceTree = ""; }; + 994D6EB429E35C130045B3F7 /* StoreApp+SideStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StoreApp+SideStore.swift"; sourceTree = ""; }; + 1FF8C6172A1780C60041352C /* ActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityView.swift; sourceTree = ""; }; 1FFA56C1299994390011B6F5 /* OutputCapturer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OutputCapturer.swift; sourceTree = ""; }; 1FFEF103298552DB0098374C /* AppVersionHistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppVersionHistoryView.swift; sourceTree = ""; }; - 994D6EB429E35C130045B3F7 /* StoreApp+SideStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StoreApp+SideStore.swift"; sourceTree = ""; }; 9961EC2D29BE9F2E00AF2C6F /* minimuxer-helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "minimuxer-helpers.swift"; path = "Dependencies/minimuxer/minimuxer-helpers.swift"; sourceTree = SOURCE_ROOT; }; 99BCB7DE29A2AC050041D1A7 /* AdvancedSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsView.swift; sourceTree = ""; }; 99D87A5F299F1B1100ED09A9 /* DevModeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevModeView.swift; sourceTree = ""; }; @@ -1061,6 +1073,8 @@ B3146ED2284F581E00BBC3FD /* Roxas.framework in Frameworks */, D533E8B72727841800A9B5DD /* libAppleArchive.tbd in Frameworks */, B3C395F9284F362400DA9E2F /* AppCenterCrashes in Frameworks */, + 9922FFEC29B501C50020F868 /* Starscream in Frameworks */, + 1FF8C61B2A1782F10041352C /* Reachability in Frameworks */, D533E8BE2727BBF800A9B5DD /* libcurl.a in Frameworks */, 4879A9622861049C00FC1BBD /* OpenSSL in Frameworks */, B3C395F4284F35DD00DA9E2F /* Nuke in Frameworks */, @@ -1142,15 +1156,28 @@ 1F6284D6295218980060AAD8 /* DocumentPicker.swift */, 1F545E84298D84CF00589F68 /* FilePreviewView.swift */, 1FA5A6CB298E8FE4007BA946 /* MailComposeView.swift */, + 1F981B1629AA34A70014950E /* AppStoreProductView.swift */, + 1FF8C6172A1780C60041352C /* ActivityView.swift */, ); path = "UIView Representables"; sourceTree = ""; }; + 1F981B0F29AA0F9B0014950E /* Onboarding */ = { + isa = PBXGroup; + children = ( + 1F981B1029AA0FAE0014950E /* OnboardingView.swift */, + 1F981B1229AA101F0014950E /* OnboardingStepView.swift */, + 1F981B1429AA1E070014950E /* AppIconsShowcase.swift */, + ); + path = Onboarding; + sourceTree = ""; + }; 1FAFC5B02927E01400B8D837 /* Views */ = { isa = PBXGroup; children = ( 1FAFC5B52927E06300B8D837 /* RootView.swift */, 1FAFC5B12927E02E00B8D837 /* Authentication */, + 1F981B0F29AA0F9B0014950E /* Onboarding */, 1FAFC5B22927E03300B8D837 /* News */, 1FAFC5B32927E03D00B8D837 /* Browse */, 1FAFC5BC2927E0FD00B8D837 /* My Apps */, @@ -1299,6 +1326,7 @@ 99F87D1729D8E4C900B40039 /* minimuxer.swift */, ); name = Generated; + path = minimuxer; sourceTree = ""; }; B3146EC7284F580500BBC3FD /* Products */ = { @@ -2329,12 +2357,14 @@ B3C395F6284F362400DA9E2F /* AppCenterAnalytics */, B3C395F8284F362400DA9E2F /* AppCenterCrashes */, 4879A9612861049C00FC1BBD /* OpenSSL */, - 1F74FF1D295263510047C051 /* AsyncImage */, - 1F07F5662955D16A00F7BE95 /* SFSafeSymbols */, - 1F1295802989B51F0048FCB9 /* ExpandableText */, 99D87A6429A04D5E00ED09A9 /* Inject */, 99DE640529A1753800B920BF /* ZIPFoundation */, 992C895F29A6A56500FB3501 /* LocalConsole */, + 9922FFEB29B501C50020F868 /* Starscream */, + 1F74FF1D295263510047C051 /* AsyncImage */, + 1F07F5662955D16A00F7BE95 /* SFSafeSymbols */, + 1F1295802989B51F0048FCB9 /* ExpandableText */, + 1FF8C61A2A1782F10041352C /* Reachability */, ); productName = AltStore; productReference = BFD2476A2284B9A500981D42 /* SideStore.app */; @@ -2407,12 +2437,14 @@ 4879A95D2861046500FC1BBD /* XCRemoteSwiftPackageReference "AltSign" */, 4879A9602861049C00FC1BBD /* XCRemoteSwiftPackageReference "OpenSSL" */, 99C4EF472978D52400CB538D /* XCRemoteSwiftPackageReference "SemanticVersion" */, - 1F74FF1C295263510047C051 /* XCRemoteSwiftPackageReference "AsyncImage" */, - 1F07F5652955D16A00F7BE95 /* XCRemoteSwiftPackageReference "SFSafeSymbols" */, - 1F12957F2989B51F0048FCB9 /* XCRemoteSwiftPackageReference "ExpandableText" */, 99D87A6329A04D5E00ED09A9 /* XCRemoteSwiftPackageReference "Inject" */, 99DE640429A1753800B920BF /* XCRemoteSwiftPackageReference "ZIPFoundation" */, 992C895E29A6A56500FB3501 /* XCRemoteSwiftPackageReference "LocalConsole" */, + 9922FFEA29B501C50020F868 /* XCRemoteSwiftPackageReference "Starscream" */, + 1F74FF1C295263510047C051 /* XCRemoteSwiftPackageReference "AsyncImage" */, + 1F07F5652955D16A00F7BE95 /* XCRemoteSwiftPackageReference "SFSafeSymbols" */, + 1F12957F2989B51F0048FCB9 /* XCRemoteSwiftPackageReference "ExpandableText" */, + 1FF8C6192A1782F10041352C /* XCRemoteSwiftPackageReference "Reachability" */, ); productRefGroup = BFD2476B2284B9A500981D42 /* Products */; projectDirPath = ""; @@ -2840,6 +2872,7 @@ BFC57A652416C72400EB891E /* DeactivateAppOperation.swift in Sources */, 1F943C712927F90400ABE095 /* MyAppsView.swift in Sources */, 1FA1C8CA294906890083119D /* MyAppsViewModel.swift in Sources */, + 1F981B1529AA1E070014950E /* AppIconsShowcase.swift in Sources */, BF3BEFC124086A1E00DE7D55 /* RefreshAppOperation.swift in Sources */, 1FFEF104298552DB0098374C /* AppVersionHistoryView.swift in Sources */, BFE60740231AFD2A002B0E8E /* InsetGroupTableViewCell.swift in Sources */, @@ -2867,10 +2900,13 @@ 1FB96FEC292C171D007E68D1 /* NotificationManager.swift in Sources */, BF770E6722BD57C4002A40FE /* BackgroundTaskManager.swift in Sources */, 1F07F56B2955F11500F7BE95 /* AppScreenshotsPreview.swift in Sources */, + 1F981B1329AA101F0014950E /* OnboardingStepView.swift in Sources */, BF44EEFC246B4550002A52F2 /* RemoveAppOperation.swift in Sources */, BF3D64B022E8D4B800E9056B /* AppContentViewControllerCells.swift in Sources */, + 1F981B1729AA34A70014950E /* AppStoreProductView.swift in Sources */, BFC57A6E2416FC5D00EB891E /* InstalledAppsCollectionHeaderView.swift in Sources */, B3EE16B62925E27D00B3B1F5 /* AnisetteManager.swift in Sources */, + 1FF8C6182A1780C60041352C /* ActivityView.swift in Sources */, 1F943C6E2927F90400ABE095 /* NewsItemView.swift in Sources */, BF88F97224F8727D00BB75DF /* AppManagerErrors.swift in Sources */, B39F16152918D7DA002E9404 /* Consts+Proxy.swift in Sources */, @@ -2912,9 +2948,9 @@ 1F6284D7295218980060AAD8 /* DocumentPicker.swift in Sources */, BFBE0007250AD0E70080826E /* ViewAppIntentHandler.swift in Sources */, 99E59E1D299BFE5D00FAF33D /* AppIconsView.swift in Sources */, + 99BCB7DF29A2AC050041D1A7 /* AdvancedSettingsView.swift in Sources */, 1F0DD83F29367F6C007608A4 /* ConnectAppleIDView.swift in Sources */, 1F07F56F2955FB2000F7BE95 /* AppIDsView.swift in Sources */, - 99BCB7DF29A2AC050041D1A7 /* AdvancedSettingsView.swift in Sources */, BFDB6A0822AAED73007EA6D6 /* ResignAppOperation.swift in Sources */, D593F1942717749A006E82DE /* PatchAppOperation.swift in Sources */, BF770E5122BB1CF6002A40FE /* InstallAppOperation.swift in Sources */, @@ -2948,6 +2984,7 @@ BF6C8FB02429599900125131 /* TextCollectionReusableView.swift in Sources */, BF663C4F2433ED8200DAA738 /* FileManager+DirectorySize.swift in Sources */, 1F943C702927F90400ABE095 /* BrowseView.swift in Sources */, + 1F981B1129AA0FAE0014950E /* OnboardingView.swift in Sources */, 1F943C692927F8F200ABE095 /* RootView.swift in Sources */, 1FB84BA62928DE08006A5CF4 /* AppDetailView.swift in Sources */, D57DF63F271E51E400677701 /* ALTAppPatcher.m in Sources */, @@ -3814,6 +3851,14 @@ kind = branch; }; }; + 1FF8C6192A1782F10041352C /* XCRemoteSwiftPackageReference "Reachability" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/ashleymills/Reachability.swift"; + requirement = { + branch = master; + kind = branch; + }; + }; 4879A95D2861046500FC1BBD /* XCRemoteSwiftPackageReference "AltSign" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SideStore/AltSign"; @@ -3838,6 +3883,14 @@ kind = branch; }; }; + 9922FFEA29B501C50020F868 /* XCRemoteSwiftPackageReference "Starscream" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/daltoniam/Starscream.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.0.0; + }; + }; 99C4EF472978D52400CB538D /* XCRemoteSwiftPackageReference "SemanticVersion" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SwiftPackageIndex/SemanticVersion.git"; @@ -3943,6 +3996,11 @@ package = 1F74FF1C295263510047C051 /* XCRemoteSwiftPackageReference "AsyncImage" */; productName = AsyncImage; }; + 1FF8C61A2A1782F10041352C /* Reachability */ = { + isa = XCSwiftPackageProductDependency; + package = 1FF8C6192A1782F10041352C /* XCRemoteSwiftPackageReference "Reachability" */; + productName = Reachability; + }; 4879A95E2861046500FC1BBD /* AltSign */ = { isa = XCSwiftPackageProductDependency; package = 4879A95D2861046500FC1BBD /* XCRemoteSwiftPackageReference "AltSign" */; @@ -3958,6 +4016,11 @@ package = 992C895E29A6A56500FB3501 /* XCRemoteSwiftPackageReference "LocalConsole" */; productName = LocalConsole; }; + 9922FFEB29B501C50020F868 /* Starscream */ = { + isa = XCSwiftPackageProductDependency; + package = 9922FFEA29B501C50020F868 /* XCRemoteSwiftPackageReference "Starscream" */; + productName = Starscream; + }; 99C4EF4C2979132100CB538D /* SemanticVersion */ = { isa = XCSwiftPackageProductDependency; package = 99C4EF472978D52400CB538D /* XCRemoteSwiftPackageReference "SemanticVersion" */; diff --git a/AltStore.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AltStore.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9bce58ec..049d888f 100644 --- a/AltStore.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AltStore.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -99,6 +99,15 @@ "version" : "1.10.1" } }, + { + "identity" : "reachability.swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ashleymills/Reachability.swift", + "state" : { + "branch" : "master", + "revision" : "a81b7367f2c46875f29577e03a60c39cdfad0c8d" + } + }, { "identity" : "semanticversion", "kind" : "remoteSourceControl", @@ -126,6 +135,15 @@ "version" : "2.1.0" } }, + { + "identity" : "starscream", + "kind" : "remoteSourceControl", + "location" : "https://github.com/daltoniam/Starscream.git", + "state" : { + "revision" : "df8d82047f6654d8e4b655d1b1525c64e1059d21", + "version" : "4.0.4" + } + }, { "identity" : "stprivilegedtask", "kind" : "remoteSourceControl", diff --git a/AltStore/LaunchViewController.swift b/AltStore/LaunchViewController.swift index d333f62b..74f9b088 100644 --- a/AltStore/LaunchViewController.swift +++ b/AltStore/LaunchViewController.swift @@ -54,15 +54,29 @@ final class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDeleg override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) #if !targetEnvironment(simulator) + if !UserDefaults.standard.onboardingComplete { + self.showOnboarding() + return + } + start_em_proxy(bind_addr: Consts.Proxy.serverURL) guard let pf = fetchPairingFile() else { - displayError("Device pairing file not found.") + self.showOnboarding(step: .pairing) return } start_minimuxer_threads(pf) #endif } + + func showOnboarding(step: OnboardingView.OnboardingStep = .welcome) { + let onboardingView = OnboardingView(onDismiss: { self.dismiss(animated: true) }, currentStep: step) + .environment(\.managedObjectContext, DatabaseManager.shared.viewContext) + let navigationController = UINavigationController(rootViewController: UIHostingController(rootView: onboardingView)) + navigationController.isNavigationBarHidden = true + navigationController.isModalInPresentation = true + self.present(navigationController, animated: true) + } func fetchPairingFile() -> String? { let filename = "ALTPairingFile.mobiledevicepairing" @@ -157,7 +171,7 @@ final class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDeleg try start(pairing_file, documentsDirectory) } catch { try! FileManager.default.removeItem(at: FileManager.default.documentsDirectory.appendingPathComponent("\(pairingFileName)")) - displayError("minimuxer failed to start, please restart SideStore. \(minimuxerToOperationError(error).failureReason ?? "UNKNOWN ERROR!!!!!! REPORT TO GITHUB ISSUES!")") + displayError("minimuxer failed to start, please restart SideStore. \((error as? LocalizedError)?.failureReason ?? "UNKNOWN ERROR!!!!!! REPORT TO GITHUB ISSUES!")") } set_debug(UserDefaults.shared.isDebugLoggingEnabled) start_auto_mounter(documentsDirectory) diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index f6fb71ce..fc28cfba 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -874,13 +874,11 @@ private extension AppManager // Check if backup app is installed in place of real app. let uti = UTTypeCopyDeclaration(app.installedBackupAppUTI as CFString)?.takeRetainedValue() as NSDictionary? - // for some reason, `app.certificateSerialNumber != group.context.certificate?.serialNumber` is true on first SideStore refresh - // in most cases, the first refresh gets stuck since it is a full reinstall, and to fix it you must exit to home screen - // which finishes it but removes all app data - // so we want to ensure we don't reinstall for SideStore if it's true (it will still reinstall if needsResign is true) - if (app.certificateSerialNumber != group.context.certificate?.serialNumber && app.bundleIdentifier != StoreApp.altstoreAppID) || + if app.certificateSerialNumber != group.context.certificate?.serialNumber || uti != nil || - app.needsResign + app.needsResign || + // We need to reinstall ourselves on refresh to ensure the new provisioning profile is used + app.bundleIdentifier == StoreApp.altstoreAppID { // Resign app instead of just refreshing profiles because either: // * Refreshing using different certificate diff --git a/AltStore/Operations/BackgroundRefreshAppsOperation.swift b/AltStore/Operations/BackgroundRefreshAppsOperation.swift index 0b3aa209..e38a9a1c 100644 --- a/AltStore/Operations/BackgroundRefreshAppsOperation.swift +++ b/AltStore/Operations/BackgroundRefreshAppsOperation.swift @@ -11,6 +11,7 @@ import CoreData import AltStoreCore import EmotionalDamage +import minimuxer enum RefreshError: LocalizedError { @@ -97,6 +98,14 @@ final class BackgroundRefreshAppsOperation: ResultOperation<[String: Result do { try remove_provisioning_profile(profile) } catch { - return self.finish(.failure(minimuxerToOperationError(error))) + return self.finish(.failure(error)) } } diff --git a/AltStore/Operations/EnableJITOperation.swift b/AltStore/Operations/EnableJITOperation.swift index 1848109b..36081af1 100644 --- a/AltStore/Operations/EnableJITOperation.swift +++ b/AltStore/Operations/EnableJITOperation.swift @@ -48,7 +48,7 @@ final class EnableJITOperation: ResultOperation do { try debug_app(installedApp.resignedBundleIdentifier) } catch { - return self.finish(.failure(minimuxerToOperationError(error))) + return self.finish(.failure(error)) } self.finish(.success(())) diff --git a/AltStore/Operations/FetchAnisetteDataOperation.swift b/AltStore/Operations/FetchAnisetteDataOperation.swift index 4a121751..a0b899c6 100644 --- a/AltStore/Operations/FetchAnisetteDataOperation.swift +++ b/AltStore/Operations/FetchAnisetteDataOperation.swift @@ -7,15 +7,28 @@ // import Foundation +import CommonCrypto +import Starscream import AltStoreCore import AltSign import Roxas @objc(FetchAnisetteDataOperation) -final class FetchAnisetteDataOperation: ResultOperation +final class FetchAnisetteDataOperation: ResultOperation, WebSocketDelegate { let context: OperationContext + var socket: WebSocket! + + var url: URL? + var startProvisioningURL: URL? + var endProvisioningURL: URL? + + var clientInfo: String? + var userAgent: String? + + var mdLu: String? + var deviceId: String? init(context: OperationContext) { @@ -32,32 +45,412 @@ final class FetchAnisetteDataOperation: ResultOperation return } - let url = AnisetteManager.currentURL - DLOG("Anisette URL: %@", url.absoluteString) + self.url = AnisetteManager.currentURL + print("Anisette URL: \(self.url!.absoluteString)") - let task = URLSession.shared.dataTask(with: url) { data, response, error in - guard let data = data, error == nil else { return } - - do { - // make sure this JSON is in the format we expect - // convert data to json - if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] { - // try to read out a dictionary - //for some reason serial number isn't needed but it doesn't work unless it has a value - let formattedJSON: [String: String] = ["machineID": json["X-Apple-I-MD-M"]!, "oneTimePassword": json["X-Apple-I-MD"]!, "localUserID": json["X-Apple-I-MD-LU"]!, "routingInfo": json["X-Apple-I-MD-RINFO"]!, "deviceUniqueIdentifier": json["X-Mme-Device-Id"]!, "deviceDescription": json["X-MMe-Client-Info"]!, "date": json["X-Apple-I-Client-Time"]!, "locale": json["X-Apple-Locale"]!, "timeZone": json["X-Apple-I-TimeZone"]!, "deviceSerialNumber": "1"] - - if let anisette = ALTAnisetteData(json: formattedJSON) { - DLOG("Anisette used: %@", formattedJSON) - self.finish(.success(anisette)) - } + if let identifier = Keychain.shared.identifier, + let adiPb = Keychain.shared.adiPb { + fetchAnisetteV3(identifier, adiPb) + } else { + provision() + } + } + + // MARK: - COMMON + + func extractAnisetteData(_ data: Data, _ response: HTTPURLResponse?, v3: Bool) throws { + // make sure this JSON is in the format we expect + // convert data to json + if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] { + if v3 { + if json["result"] == "GetHeadersError" { + let message = json["message"] + print("Error getting V3 headers: \(message ?? "no message")") + if let message = message, + message.contains("-45061") { + print("Error message contains -45061 (not provisioned), resetting adi.pb and retrying") + Keychain.shared.adiPb = nil + return provision() + } else { throw OperationError.anisetteV3Error(message: message ?? "Unknown error") } } + } + + // try to read out a dictionary + // for some reason serial number isn't needed but it doesn't work unless it has a value + var formattedJSON: [String: String] = ["deviceSerialNumber": "0"] + if let machineID = json["X-Apple-I-MD-M"] { formattedJSON["machineID"] = machineID } + if let oneTimePassword = json["X-Apple-I-MD"] { formattedJSON["oneTimePassword"] = oneTimePassword } + if let routingInfo = json["X-Apple-I-MD-RINFO"] { formattedJSON["routingInfo"] = routingInfo } + + if v3 { + formattedJSON["deviceDescription"] = self.clientInfo! + formattedJSON["localUserID"] = self.mdLu! + formattedJSON["deviceUniqueIdentifier"] = self.deviceId! + + // Generate date stuff on client + let formatter = DateFormatter() + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.calendar = Calendar(identifier: .gregorian) + formatter.timeZone = TimeZone.current + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'" + let dateString = formatter.string(from: Date()) + formattedJSON["date"] = dateString + formattedJSON["locale"] = Locale.current.identifier + formattedJSON["timeZone"] = TimeZone.current.abbreviation() + } else { + if let deviceDescription = json["X-MMe-Client-Info"] { formattedJSON["deviceDescription"] = deviceDescription } + if let localUserID = json["X-Apple-I-MD-LU"] { formattedJSON["localUserID"] = localUserID } + if let deviceUniqueIdentifier = json["X-Mme-Device-Id"] { formattedJSON["deviceUniqueIdentifier"] = deviceUniqueIdentifier } + + if let date = json["X-Apple-I-Client-Time"] { formattedJSON["date"] = date } + if let locale = json["X-Apple-Locale"] { formattedJSON["locale"] = locale } + if let timeZone = json["X-Apple-I-TimeZone"] { formattedJSON["timeZone"] = timeZone } + } + + if let response = response, + let version = response.value(forHTTPHeaderField: "Implementation-Version") { + print("Implementation-Version: \(version)") + } else { print("No Implementation-Version header") } + + print("Anisette used: \(formattedJSON)") + print("Original JSON: \(json)") + if let anisette = ALTAnisetteData(json: formattedJSON) { + print("Anisette is valid!") + self.finish(.success(anisette)) + } else { + print("Anisette is invalid!!!!") + if v3 { + throw OperationError.anisetteV3Error(message: "Invalid anisette (the returned data may not have all the required fields)") + } else { + throw OperationError.anisetteV1Error(message: "Invalid anisette (the returned data may not have all the required fields)") + } + } + } else { + if v3 { + throw OperationError.anisetteV3Error(message: "Invalid anisette (the returned data may not be in JSON)") + } else { + throw OperationError.anisetteV1Error(message: "Invalid anisette (the returned data may not be in JSON)") + } + } + } + + // MARK: - V1 + + func handleV1() { + print("Server is V1") + + if UserDefaults.shared.trustedServerURL == AnisetteManager.currentURLString { + print("Server has already been trusted, fetching anisette") + return self.fetchAnisetteV1() + } + + print("Alerting user about outdated server") + let alert = UIAlertController(title: "WARNING: Outdated anisette server", message: "We've detected you are using an older anisette server. Using this server has a higher likelihood of locking your account and causing other issues. Are you sure you want to continue?", preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Continue", style: UIAlertAction.Style.destructive, handler: { action in + print("Fetching anisette via V1") + UserDefaults.shared.trustedServerURL = AnisetteManager.currentURLString + self.fetchAnisetteV1() + })) + alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel, handler: { action in + print("Cancelled anisette operation") + self.finish(.failure(OperationError.cancelled)) + })) + + let keyWindow = UIApplication.shared.windows.filter { $0.isKeyWindow }.first + + DispatchQueue.main.async { + if let presentingController = keyWindow?.rootViewController?.presentedViewController { + presentingController.present(alert, animated: true) + } else { + keyWindow?.rootViewController?.present(alert, animated: true) + } + } + } + + func fetchAnisetteV1() { + print("Fetching anisette V1") + URLSession.shared.dataTask(with: self.url!) { data, response, error in + do { + guard let data = data, error == nil else { throw OperationError.anisetteV1Error(message: "Unable to fetch data\(error != nil ? " (\(error!.localizedDescription))" : "")") } + + try self.extractAnisetteData(data, response as? HTTPURLResponse, v3: false) } catch let error as NSError { print("Failed to load: \(error.localizedDescription)") self.finish(.failure(error)) } - + }.resume() + } + + // MARK: - V3: PROVISIONING + + func provision() { + fetchClientInfo { + print("Getting provisioning URLs") + var request = self.buildAppleRequest(url: URL(string: "https://gsa.apple.com/grandslam/GsService2/lookup")!) + request.httpMethod = "GET" + URLSession.shared.dataTask(with: request) { data, response, error in + if let data = data, + let plist = try? PropertyListSerialization.propertyList(from: data, format: nil) as? Dictionary>, + let startProvisioningString = plist["urls"]?["midStartProvisioning"] as? String, + let startProvisioningURL = URL(string: startProvisioningString), + let endProvisioningString = plist["urls"]?["midFinishProvisioning"] as? String, + let endProvisioningURL = URL(string: endProvisioningString) { + self.startProvisioningURL = startProvisioningURL + self.endProvisioningURL = endProvisioningURL + print("startProvisioningURL: \(self.startProvisioningURL!.absoluteString)") + print("endProvisioningURL: \(self.endProvisioningURL!.absoluteString)") + print("Starting a provisioning session") + self.startProvisioningSession() + } else { + print("Apple didn't give valid URLs! Got response: \(String(data: data ?? Data("nothing".utf8), encoding: .utf8) ?? "not utf8")") + self.finish(.failure(OperationError.provisioningError(result: "Apple didn't give valid URLs. Please try again later", message: nil))) + } + }.resume() + } + } + + func startProvisioningSession() { + let provisioningSessionURL = self.url!.appendingPathComponent("v3").appendingPathComponent("provisioning_session") + var wsRequest = URLRequest(url: provisioningSessionURL) + wsRequest.timeoutInterval = 5 + self.socket = WebSocket(request: wsRequest) + self.socket.delegate = self + self.socket.connect() + } + + func didReceive(event: WebSocketEvent, client: WebSocket) { + switch event { + case .text(let string): + do { + if let json = try JSONSerialization.jsonObject(with: string.data(using: .utf8)!, options: []) as? [String: Any] { + guard let result = json["result"] as? String else { + print("The server didn't give us a result") + client.disconnect(closeCode: 0) + self.finish(.failure(OperationError.provisioningError(result: "The server didn't give us a result", message: nil))) + return + } + print("Received result: \(result)") + switch result { + case "GiveIdentifier": + print("Giving identifier") + client.json(["identifier": Keychain.shared.identifier!]) + + case "GiveStartProvisioningData": + print("Getting start provisioning data") + let body = [ + "Header": [String: Any](), + "Request": [String: Any](), + ] + var request = self.buildAppleRequest(url: self.startProvisioningURL!) + request.httpMethod = "POST" + request.httpBody = try! PropertyListSerialization.data(fromPropertyList: body, format: .xml, options: 0) + URLSession.shared.dataTask(with: request) { data, response, error in + if let data = data, + let plist = try? PropertyListSerialization.propertyList(from: data, format: nil) as? Dictionary>, + let spim = plist["Response"]?["spim"] as? String { + print("Giving start provisioning data") + client.json(["spim": spim]) + } else { + print("Apple didn't give valid start provisioning data! Got response: \(String(data: data ?? Data("nothing".utf8), encoding: .utf8) ?? "not utf8")") + client.disconnect(closeCode: 0) + self.finish(.failure(OperationError.provisioningError(result: "Apple didn't give valid start provisioning data. Please try again later", message: nil))) + } + }.resume() + + case "GiveEndProvisioningData": + print("Getting end provisioning data") + guard let cpim = json["cpim"] as? String else { + print("The server didn't give us a cpim") + client.disconnect(closeCode: 0) + self.finish(.failure(OperationError.provisioningError(result: "The server didn't give us a cpim", message: nil))) + return + } + let body = [ + "Header": [String: Any](), + "Request": [ + "cpim": cpim, + ], + ] + var request = self.buildAppleRequest(url: self.endProvisioningURL!) + request.httpMethod = "POST" + request.httpBody = try! PropertyListSerialization.data(fromPropertyList: body, format: .xml, options: 0) + URLSession.shared.dataTask(with: request) { data, response, error in + if let data = data, + let plist = try? PropertyListSerialization.propertyList(from: data, format: nil) as? Dictionary>, + let ptm = plist["Response"]?["ptm"] as? String, + let tk = plist["Response"]?["tk"] as? String { + print("Giving end provisioning data") + client.json(["ptm": ptm, "tk": tk]) + } else { + print("Apple didn't give valid end provisioning data! Got response: \(String(data: data ?? Data("nothing".utf8), encoding: .utf8) ?? "not utf8")") + client.disconnect(closeCode: 0) + self.finish(.failure(OperationError.provisioningError(result: "Apple didn't give valid end provisioning data. Please try again later", message: nil))) + } + }.resume() + + case "ProvisioningSuccess": + print("Provisioning succeeded!") + client.disconnect(closeCode: 0) + guard let adiPb = json["adi_pb"] as? String else { + print("The server didn't give us an adi.pb file") + self.finish(.failure(OperationError.provisioningError(result: "The server didn't give us an adi.pb file", message: nil))) + return + } + Keychain.shared.adiPb = adiPb + self.fetchAnisetteV3(Keychain.shared.identifier!, Keychain.shared.adiPb!) + + default: + if result.contains("Error") || result.contains("Invalid") || result == "ClosingPerRequest" || result == "Timeout" || result == "TextOnly" { + print("Failing because of \(result)") + self.finish(.failure(OperationError.provisioningError(result: result, message: json["message"] as? String))) + } + } + } + } catch let error as NSError { + print("Failed to handle text: \(error.localizedDescription)") + self.finish(.failure(OperationError.provisioningError(result: error.localizedDescription, message: nil))) + } + + case .connected: + print("Connected") + + case .disconnected(let string, let code): + print("Disconnected: \(code); \(string)") + + case .error(let error): + print("Got error: \(String(describing: error))") + + default: + print("Unknown event: \(event)") + } + } + + func buildAppleRequest(url: URL) -> URLRequest { + var request = URLRequest(url: url) + request.setValue(self.clientInfo!, forHTTPHeaderField: "X-Mme-Client-Info") + request.setValue(self.userAgent!, forHTTPHeaderField: "User-Agent") + request.setValue("text/x-xml-plist", forHTTPHeaderField: "Content-Type") + request.setValue("*/*", forHTTPHeaderField: "Accept") + + request.setValue(self.mdLu!, forHTTPHeaderField: "X-Apple-I-MD-LU") + request.setValue(self.deviceId!, forHTTPHeaderField: "X-Mme-Device-Id") + + let formatter = DateFormatter() + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.calendar = Calendar(identifier: .gregorian) + formatter.timeZone = TimeZone(identifier: "UTC") + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'" + let dateString = formatter.string(from: Date()) + request.setValue(dateString, forHTTPHeaderField: "X-Apple-I-Client-Time") + request.setValue(Locale.current.identifier, forHTTPHeaderField: "X-Apple-Locale") + request.setValue(TimeZone.current.abbreviation(), forHTTPHeaderField: "X-Apple-I-TimeZone") + return request + } + + // MARK: - V3: FETCHING + + func fetchClientInfo(_ callback: @escaping () -> Void) { + if self.clientInfo != nil && + self.userAgent != nil && + self.mdLu != nil && + self.deviceId != nil && + Keychain.shared.identifier != nil { + print("Skipping client_info fetch since all the properties we need aren't nil") + return callback() + } + print("Trying to get client_info") + let clientInfoURL = self.url!.appendingPathComponent("v3").appendingPathComponent("client_info") + URLSession.shared.dataTask(with: clientInfoURL) { data, response, error in + do { + guard let data = data, error == nil else { + return self.finish(.failure(OperationError.anisetteV3Error(message: "Couldn't fetch client info. The server may be down\(error != nil ? " (\(error!.localizedDescription))" : "")"))) + } + + if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] { + if let clientInfo = json["client_info"] { + print("Server is V3") + + self.clientInfo = clientInfo + self.userAgent = json["user_agent"]! + print("Client-Info: \(self.clientInfo!)") + print("User-Agent: \(self.userAgent!)") + + if Keychain.shared.identifier == nil { + print("Generating identifier") + var bytes = [Int8](repeating: 0, count: 16) + let status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) + + if status != errSecSuccess { + print("ERROR GENERATING IDENTIFIER!!! \(status)") + return self.finish(.failure(OperationError.provisioningError(result: "Couldn't generate identifier", message: nil))) + } + + Keychain.shared.identifier = Data(bytes: &bytes, count: bytes.count).base64EncodedString() + } + + let decoded = Data(base64Encoded: Keychain.shared.identifier!)! + self.mdLu = decoded.sha256().hexEncodedString() + print("X-Apple-I-MD-LU: \(self.mdLu!)") + let uuid: UUID = decoded.object() + self.deviceId = uuid.uuidString.uppercased() + print("X-Mme-Device-Id: \(self.deviceId!)") + + callback() + } else { self.handleV1() } + } else { self.finish(.failure(OperationError.anisetteV3Error(message: "Couldn't fetch client info. The returned data may not be in JSON"))) } + } catch let error as NSError { + print("Failed to load: \(error.localizedDescription)") + self.handleV1() + } + }.resume() + } + + func fetchAnisetteV3(_ identifier: String, _ adiPb: String) { + fetchClientInfo { + print("Fetching anisette V3") + var request = URLRequest(url: self.url!.appendingPathComponent("v3").appendingPathComponent("get_headers")) + request.httpMethod = "POST" + request.httpBody = try! JSONSerialization.data(withJSONObject: [ + "identifier": identifier, + "adi_pb": adiPb + ], options: []) + request.setValue("application/json", forHTTPHeaderField: "Content-Type") + URLSession.shared.dataTask(with: request) { data, response, error in + do { + guard let data = data, error == nil else { throw OperationError.anisetteV3Error(message: "Couldn't fetch anisette") } + + try self.extractAnisetteData(data, response as? HTTPURLResponse, v3: true) + } catch let error as NSError { + print("Failed to load: \(error.localizedDescription)") + self.finish(.failure(error)) + } + }.resume() } - - task.resume() } } + +extension WebSocket { + func json(_ dictionary: [String: String]) { + let data = try! JSONSerialization.data(withJSONObject: dictionary, options: []) + self.write(string: String(data: data, encoding: .utf8)!) + } +} + +extension Data { + // https://stackoverflow.com/a/25391020 + func sha256() -> Data { + var hash = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH)) + self.withUnsafeBytes { + _ = CC_SHA256($0.baseAddress, CC_LONG(self.count), &hash) + } + return Data(hash) + } + + // https://stackoverflow.com/a/40089462 + func hexEncodedString() -> String { + return self.map { String(format: "%02hhX", $0) }.joined() + } + + // https://stackoverflow.com/a/59127761 + func object() -> T { self.withUnsafeBytes { $0.load(as: T.self) } } +} diff --git a/AltStore/Operations/FetchProvisioningProfilesOperation.swift b/AltStore/Operations/FetchProvisioningProfilesOperation.swift index 955282f4..89663226 100644 --- a/AltStore/Operations/FetchProvisioningProfilesOperation.swift +++ b/AltStore/Operations/FetchProvisioningProfilesOperation.swift @@ -268,8 +268,17 @@ extension FetchProvisioningProfilesOperation } } } + //App ID name must be ascii. If the name is not ascii, using bundleID instead + let appIDName: String + if !name.allSatisfy({ $0.isASCII }) { + //Contains non ASCII (Such as Chinese/Japanese...), using bundleID + appIDName = bundleIdentifier + }else { + //ASCII text, keep going as usual + appIDName = name + } - ALTAppleAPI.shared.addAppID(withName: name, bundleIdentifier: bundleIdentifier, team: team, session: session) { (appID, error) in + ALTAppleAPI.shared.addAppID(withName: appIDName, bundleIdentifier: bundleIdentifier, team: team, session: session) { (appID, error) in do { do @@ -394,17 +403,26 @@ extension FetchProvisioningProfilesOperation } } + // Make sure we add .AltWidget for the widget + var altStoreAppGroupID = Bundle.baseAltStoreAppGroupID + for (_, group) in applicationGroups.enumerated() { + if group.contains("AltWidget") { + altStoreAppGroupID += ".AltWidget" + break + } + } + // Potentially updating app groups for this specific AltStore. // Find the (unique) AltStore app group, then replace it // with the correct "base" app group ID. // Otherwise, we may append a duplicate team identifier to the end. if let index = applicationGroups.firstIndex(where: { $0.contains(Bundle.baseAltStoreAppGroupID) }) { - applicationGroups[index] = Bundle.baseAltStoreAppGroupID + applicationGroups[index] = altStoreAppGroupID } else { - applicationGroups.append(Bundle.baseAltStoreAppGroupID) + applicationGroups.append(altStoreAppGroupID) } } print("Application groups: \(applicationGroups)") diff --git a/AltStore/Operations/InstallAppOperation.swift b/AltStore/Operations/InstallAppOperation.swift index c9ef8d50..bc866498 100644 --- a/AltStore/Operations/InstallAppOperation.swift +++ b/AltStore/Operations/InstallAppOperation.swift @@ -149,10 +149,68 @@ final class InstallAppOperation: ResultOperation }) } + var installing = true + if installedApp.storeApp?.bundleIdentifier == Bundle.Info.appbundleIdentifier { + // Reinstalling ourself will hang until we leave the app, so we need to exit it without force closing + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { + if UIApplication.shared.applicationState != .active { + print("We are not in the foreground, let's not do anything") + return + } + if !installing { + print("Installing finished") + return + } + print("We are still installing after 3 seconds") + + UNUserNotificationCenter.current().getNotificationSettings { settings in + switch (settings.authorizationStatus) { + case .authorized, .ephemeral, .provisional: + print("Notifications are enabled") + + let content = UNMutableNotificationContent() + content.title = "Refreshing..." + content.body = "To finish refreshing, SideStore must be moved to the background, which it does by opening Safari. Please reopen SideStore after it is done refreshing!" + let notification = UNNotificationRequest(identifier: Bundle.Info.appbundleIdentifier + ".FinishRefreshNotification", content: content, trigger: UNTimeIntervalNotificationTrigger(timeInterval: 2, repeats: false)) + UNUserNotificationCenter.current().add(notification) + + DispatchQueue.main.async { UIApplication.shared.open(URL(string: "x-web-search://")!) } + + break + default: + print("Notifications are not enabled") + + let alert = UIAlertController(title: "Finish Refresh", message: "To finish refreshing, SideStore must be moved to the background. To do this, you can either go to the Home Screen or open Safari by pressing Continue. Please reopen SideStore after doing this.", preferredStyle: .alert) + alert.addAction(UIAlertAction(title: NSLocalizedString("Continue", comment: ""), style: .default, handler: { _ in + print("Opening Safari") + DispatchQueue.main.async { UIApplication.shared.open(URL(string: "x-web-search://")!) } + })) + + DispatchQueue.main.async { + let keyWindow = UIApplication.shared.windows.filter { $0.isKeyWindow }.first + if var topController = keyWindow?.rootViewController { + while let presentedViewController = topController.presentedViewController { + topController = presentedViewController + } + topController.present(alert, animated: true) + } else { + print("No key window? Let's just open Safari") + UIApplication.shared.open(URL(string: "x-web-search://")!) + } + } + + break + } + } + } + } + do { try install_ipa(installedApp.bundleIdentifier) + installing = false } catch { - return self.finish(.failure(minimuxerToOperationError(error))) + installing = false + return self.finish(.failure(error)) } installedApp.refreshedDate = Date() diff --git a/AltStore/Operations/OperationError.swift b/AltStore/Operations/OperationError.swift index fc124c0f..0398ce4d 100644 --- a/AltStore/Operations/OperationError.swift +++ b/AltStore/Operations/OperationError.swift @@ -34,20 +34,9 @@ enum OperationError: LocalizedError case openAppFailed(name: String) case missingAppGroup - case noDevice - case createService(name: String) - case getFromDevice(name: String) - case setArgument(name: String) - case afc - case install - case uninstall - case lookupApps - case detach - case attach - case functionArguments - case profileManage - case noConnection - case invalidPairingFile + case anisetteV1Error(message: String) + case provisioningError(result: String, message: String?) + case anisetteV3Error(message: String) var failureReason: String? { switch self { @@ -64,20 +53,9 @@ enum OperationError: LocalizedError case .openAppFailed(let name): return String(format: NSLocalizedString("SideStore was denied permission to launch %@.", comment: ""), name) case .missingAppGroup: return NSLocalizedString("SideStore's shared app group could not be found.", comment: "") case .maximumAppIDLimitReached: return NSLocalizedString("Cannot register more than 10 App IDs.", comment: "") - case .noDevice: return NSLocalizedString("Cannot fetch the device from the muxer", comment: "") - case .createService(let name): return String(format: NSLocalizedString("Cannot start a %@ server on the device.", comment: ""), name) - case .getFromDevice(let name): return String(format: NSLocalizedString("Cannot fetch %@ from the device.", comment: ""), name) - case .setArgument(let name): return String(format: NSLocalizedString("Cannot set %@ on the device.", comment: ""), name) - case .afc: return NSLocalizedString("AFC was unable to manage files on the device", comment: "") - case .install: return NSLocalizedString("Unable to install the app from the staging directory", comment: "") - case .uninstall: return NSLocalizedString("Unable to uninstall the app", comment: "") - case .lookupApps: return NSLocalizedString("Unable to fetch apps from the device", comment: "") - case .detach: return NSLocalizedString("Unable to detach from the app's process", comment: "") - case .attach: return NSLocalizedString("Unable to attach to the app's process", comment: "") - case .functionArguments: return NSLocalizedString("A function was passed invalid arguments", comment: "") - case .profileManage: return NSLocalizedString("Unable to manage profiles on the device", comment: "") - case .noConnection: return NSLocalizedString("Unable to connect to the device, make sure Wireguard is enabled and you're connected to WiFi", comment: "") - case .invalidPairingFile: return NSLocalizedString("Invalid pairing file. Your pairing file either didn't have a UDID, or it wasn't a valid plist. Please use jitterbugpair to generate it", comment: "") + case .anisetteV1Error(let message): return String(format: NSLocalizedString("An error occurred when getting anisette data from a V1 server: %@. Try using another anisette server.", comment: ""), message) + case .provisioningError(let result, let message): return String(format: NSLocalizedString("An error occurred when provisioning: %@%@. Please try again. If the issue persists, report it on GitHub Issues!", comment: ""), result, message != nil ? (" (" + message! + ")") : "") + case .anisetteV3Error(let message): return String(format: NSLocalizedString("An error occurred when getting anisette data from a V3 server: %@. Please try again. If the issue persists, report it on GitHub Issues!", comment: ""), message) } } @@ -123,53 +101,67 @@ enum OperationError: LocalizedError } } -/// crashes if error is not a MinimuxerError or OperationError -func minimuxerToOperationError(_ error: Error) -> OperationError { - if let error = error as? MinimuxerError { - switch error { +extension MinimuxerError: LocalizedError { + public var failureReason: String? { + switch self { case .NoDevice: - return OperationError.noDevice + return NSLocalizedString("Cannot fetch the device from the muxer", comment: "") case .NoConnection: - return OperationError.noConnection + return NSLocalizedString("Unable to connect to the device, make sure Wireguard is enabled and you're connected to WiFi", comment: "") case .PairingFile: - return OperationError.invalidPairingFile + return NSLocalizedString("Invalid pairing file. Your pairing file either didn't have a UDID, or it wasn't a valid plist. Please use jitterbugpair to generate it", comment: "") + case .CreateDebug: - return OperationError.createService(name: "debug") - case .CreateInstproxy: - return OperationError.createService(name: "instproxy") + return self.createService(name: "debug") case .LookupApps: - return OperationError.getFromDevice(name: "installed apps") + return self.getFromDevice(name: "installed apps") case .FindApp: - return OperationError.getFromDevice(name: "path to the app") + return self.getFromDevice(name: "path to the app") case .BundlePath: - return OperationError.getFromDevice(name: "bundle path") + return self.getFromDevice(name: "bundle path") case .MaxPacket: - return OperationError.setArgument(name: "max packet") + return self.setArgument(name: "max packet") case .WorkingDirectory: - return OperationError.setArgument(name: "working directory") + return self.setArgument(name: "working directory") case .Argv: - return OperationError.setArgument(name: "argv") + return self.setArgument(name: "argv") case .LaunchSuccess: - return OperationError.getFromDevice(name: "launch success") + return self.getFromDevice(name: "launch success") case .Detach: - return OperationError.detach + return NSLocalizedString("Unable to detach from the app's process", comment: "") case .Attach: - return OperationError.attach + return NSLocalizedString("Unable to attach to the app's process", comment: "") + + case .CreateInstproxy: + return self.createService(name: "instproxy") case .CreateAfc: - return OperationError.createService(name: "AFC") + return self.createService(name: "AFC") case .RwAfc: - return OperationError.afc + return NSLocalizedString("AFC was unable to manage files on the device", comment: "") case .InstallApp: - return OperationError.install + return NSLocalizedString("Unable to install the app from the staging directory", comment: "") case .UninstallApp: - return OperationError.uninstall + return NSLocalizedString("Unable to uninstall the app", comment: "") + case .CreateMisagent: - return OperationError.createService(name: "misagent") + return self.createService(name: "misagent") case .ProfileInstall: - return OperationError.profileManage + return NSLocalizedString("Unable to manage profiles on the device", comment: "") case .ProfileRemove: - return OperationError.profileManage + return NSLocalizedString("Unable to manage profiles on the device", comment: "") } } + + fileprivate func createService(name: String) -> String { + return String(format: NSLocalizedString("Cannot start a %@ server on the device.", comment: ""), name) + } + + fileprivate func getFromDevice(name: String) -> String { + return String(format: NSLocalizedString("Cannot fetch %@ from the device.", comment: ""), name) + } + + fileprivate func setArgument(name: String) -> String { + return String(format: NSLocalizedString("Cannot set %@ on the device.", comment: ""), name) + } return error as! OperationError } diff --git a/AltStore/Operations/RefreshAppOperation.swift b/AltStore/Operations/RefreshAppOperation.swift index 7747d237..edf6a9e5 100644 --- a/AltStore/Operations/RefreshAppOperation.swift +++ b/AltStore/Operations/RefreshAppOperation.swift @@ -52,7 +52,7 @@ final class RefreshAppOperation: ResultOperation let bytes = p.value.data.toRustByteSlice() try install_provisioning_profile(bytes.forRust()) } catch { - return self.finish(.failure(minimuxerToOperationError(error))) + return self.finish(.failure(error)) } self.progress.completedUnitCount += 1 diff --git a/AltStore/Operations/RemoveAppOperation.swift b/AltStore/Operations/RemoveAppOperation.swift index 042828ec..46400cfa 100644 --- a/AltStore/Operations/RemoveAppOperation.swift +++ b/AltStore/Operations/RemoveAppOperation.swift @@ -41,7 +41,7 @@ final class RemoveAppOperation: ResultOperation do { try remove_app(resignedBundleIdentifier) } catch { - return self.finish(.failure(minimuxerToOperationError(error))) + return self.finish(.failure(error)) } DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in diff --git a/AltStore/Operations/ResignAppOperation.swift b/AltStore/Operations/ResignAppOperation.swift index c7c5cf8f..a353594f 100644 --- a/AltStore/Operations/ResignAppOperation.swift +++ b/AltStore/Operations/ResignAppOperation.swift @@ -170,6 +170,14 @@ private extension ResignAppOperation infoDictionary[Bundle.Info.exportedUTIs] = exportedUTIs try (infoDictionary as NSDictionary).write(to: bundle.infoPlistURL) + + // Remove _CodeSignature folder (if it exists) because it will be added when resigning and it may have files that aren't overwritten when resigning + // These files might be the cause of some ApplicationVerificationFailed errors + let codeSignaturePath = bundle.bundleURL.appendingPathComponent("_CodeSignature").absoluteString.replacingOccurrences(of: "file://", with: "") + if FileManager.default.fileExists(atPath: codeSignaturePath) { + try FileManager.default.removeItem(atPath: codeSignaturePath) + print("Removed _CodeSignature folder at \(codeSignaturePath)") + } } DispatchQueue.global().async { diff --git a/AltStore/Operations/SendAppOperation.swift b/AltStore/Operations/SendAppOperation.swift index dd366968..afa5e57f 100644 --- a/AltStore/Operations/SendAppOperation.swift +++ b/AltStore/Operations/SendAppOperation.swift @@ -50,7 +50,7 @@ final class SendAppOperation: ResultOperation<()> let bytes = Data(data).toRustByteSlice() try yeet_app_afc(app.bundleIdentifier, bytes.forRust()) } catch { - return self.finish(.failure(minimuxerToOperationError(error))) + return self.finish(.failure(error)) } self.progress.completedUnitCount += 1 diff --git a/AltStore/Resources/tempEnt.plist b/AltStore/Resources/ReleaseEntitlements.plist similarity index 86% rename from AltStore/Resources/tempEnt.plist rename to AltStore/Resources/ReleaseEntitlements.plist index a7b3b7dc..8b3ff4bd 100644 --- a/AltStore/Resources/tempEnt.plist +++ b/AltStore/Resources/ReleaseEntitlements.plist @@ -3,13 +3,13 @@ application-identifier - A72ZC8AJ5X.com.SideStore.SideStore + XYZ0123456.com.SideStore.SideStore aps-environment development com.apple.developer.siri com.apple.developer.team-identifier - A72ZC8AJ5X + XYZ0123456 com.apple.security.application-groups group.com.SideStore.SideStore diff --git a/AltStore/Settings/Settings.storyboard b/AltStore/Settings/Settings.storyboard index ccf9515c..42ec9e33 100644 --- a/AltStore/Settings/Settings.storyboard +++ b/AltStore/Settings/Settings.storyboard @@ -21,7 +21,7 @@