Skip to content

Commit d127d76

Browse files
authored
Merge pull request #4 from jawshoeadan/develop
2 parents 1742e69 + e02b9bc commit d127d76

File tree

13 files changed

+342
-163
lines changed

13 files changed

+342
-163
lines changed

AltPlugin/Info.plist

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,41 @@
167167
<string>A4B49485-0377-4FAB-8D8E-E3B8018CFC21</string>
168168
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
169169
</array>
170+
<key>Supported13.1PluginCompatibilityUUIDs</key>
171+
<array>
172+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
173+
</array>
174+
<key>Supported13.2PluginCompatibilityUUIDs</key>
175+
<array>
176+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
177+
</array>
178+
<key>Supported13.3PluginCompatibilityUUIDs</key>
179+
<array>
180+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
181+
</array>
182+
<key>Supported13.4PluginCompatibilityUUIDs</key>
183+
<array>
184+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
185+
</array>
186+
<key>Supported13.5PluginCompatibilityUUIDs</key>
187+
<array>
188+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
189+
</array>
190+
<key>Supported13.6PluginCompatibilityUUIDs</key>
191+
<array>
192+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
193+
</array>
194+
<key>Supported13.7PluginCompatibilityUUIDs</key>
195+
<array>
196+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
197+
</array>
198+
<key>Supported13.8PluginCompatibilityUUIDs</key>
199+
<array>
200+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
201+
</array>
202+
<key>Supported13.9PluginCompatibilityUUIDs</key>
203+
<array>
204+
<string>890E3F5B-9490-4828-8F3F-B6561E513FCC</string>
205+
</array>
170206
</dict>
171207
</plist>

AltServer/AltPlugin.zip

-15.9 KB
Binary file not shown.

AltServer/AltServer.entitlements

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict/>
4+
<dict>
5+
<key>com.apple.security.application-groups</key>
6+
<array>
7+
<string>$(TeamIdentifierPrefix)group.com.rileytestut.AltServer</string>
8+
</array>
9+
<key>keychain-access-groups</key>
10+
<array>
11+
<string>$(AppIdentifierPrefix)group.com.rileytestut.AltServer</string>
12+
</array>
13+
</dict>
514
</plist>

AltServer/AppDelegate.swift

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ import AltSign
1414
import LaunchAtLogin
1515
import Sparkle
1616

17-
#if STAGING
18-
private let altstoreAppURL = URL(string: "https://f000.backblazeb2.com/file/altstore-staging/altstore.ipa")!
19-
#elseif BETA
20-
private let altstoreAppURL = URL(string: "https://cdn.altstore.io/file/altstore/altstore-beta.ipa")!
21-
#else
22-
private let altstoreAppURL = URL(string: "https://cdn.altstore.io/file/altstore/altstore.ipa")!
23-
#endif
17+
private let altstoreAppURL = URL(string: "https://github.com/SideStore/SideStore/releases/download/0.1.1/SideStore.ipa")!
2418

2519
extension ALTDevice: MenuDisplayable {}
2620

@@ -44,9 +38,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
4438
@IBOutlet private var installMailPluginMenuItem: NSMenuItem!
4539
@IBOutlet private var installAltStoreMenuItem: NSMenuItem!
4640
@IBOutlet private var sideloadAppMenuItem: NSMenuItem!
47-
48-
private weak var authenticationAppleIDTextField: NSTextField?
49-
private weak var authenticationPasswordTextField: NSSecureTextField?
41+
@IBOutlet private var logInMenuItem: NSMenuItem!
5042

5143
private var connectedDevicesMenuController: MenuController<ALTDevice>!
5244
private var sideloadIPAConnectedDevicesMenuController: MenuController<ALTDevice>!
@@ -125,6 +117,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
125117
self.installMailPlugin()
126118
}
127119
}
120+
121+
setupLoginMenuItem()
128122
}
129123

130124
func applicationWillTerminate(_ aNotification: Notification)
@@ -197,48 +191,32 @@ private extension AppDelegate
197191

198192
func installApplication(at url: URL, to device: ALTDevice)
199193
{
200-
let alert = NSAlert()
201-
alert.messageText = NSLocalizedString("Please enter your Apple ID and password.", comment: "")
202-
alert.informativeText = NSLocalizedString("Your Apple ID and password are not saved and are only sent to Apple for authentication.", comment: "")
203-
204-
let textFieldSize = NSSize(width: 300, height: 22)
205-
206-
let appleIDTextField = NSTextField(frame: NSRect(x: 0, y: 0, width: textFieldSize.width, height: textFieldSize.height))
207-
appleIDTextField.delegate = self
208-
appleIDTextField.translatesAutoresizingMaskIntoConstraints = false
209-
appleIDTextField.placeholderString = NSLocalizedString("Apple ID", comment: "")
210-
alert.window.initialFirstResponder = appleIDTextField
211-
self.authenticationAppleIDTextField = appleIDTextField
212-
213-
let passwordTextField = NSSecureTextField(frame: NSRect(x: 0, y: 0, width: textFieldSize.width, height: textFieldSize.height))
214-
passwordTextField.delegate = self
215-
passwordTextField.translatesAutoresizingMaskIntoConstraints = false
216-
passwordTextField.placeholderString = NSLocalizedString("Password", comment: "")
217-
self.authenticationPasswordTextField = passwordTextField
218-
219-
appleIDTextField.nextKeyView = passwordTextField
220-
221-
let stackView = NSStackView(frame: NSRect(x: 0, y: 0, width: textFieldSize.width, height: textFieldSize.height * 2))
222-
stackView.orientation = .vertical
223-
stackView.distribution = .equalSpacing
224-
stackView.spacing = 0
225-
stackView.addArrangedSubview(appleIDTextField)
226-
stackView.addArrangedSubview(passwordTextField)
227-
alert.accessoryView = stackView
228-
229-
alert.addButton(withTitle: NSLocalizedString("Install", comment: ""))
230-
alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
231-
232-
self.authenticationAlert = alert
233-
self.validate()
234-
235-
NSRunningApplication.current.activate(options: .activateIgnoringOtherApps)
236-
237-
let response = alert.runModal()
238-
guard response == .alertFirstButtonReturn else { return }
239-
240-
let username = appleIDTextField.stringValue
241-
let password = passwordTextField.stringValue
194+
let username: String
195+
let password: String
196+
197+
if let _username = try? Keychain.shared.getValue(for: .appleIDEmail),
198+
let _password = try? Keychain.shared.getValue(for: .appleIDPassword) {
199+
username = _username
200+
password = _password
201+
} else {
202+
let alert = AppleIDAuthenticationAlert()
203+
self.authenticationAlert = alert
204+
205+
NSRunningApplication.current.activate(options: .activateIgnoringOtherApps)
206+
207+
let didTapContinue = alert.display()
208+
guard didTapContinue else { return }
209+
210+
username = alert.appleIDValue.trimmingCharacters(in: .whitespacesAndNewlines)
211+
password = alert.passwordValue.trimmingCharacters(in: .whitespacesAndNewlines)
212+
213+
do {
214+
try Keychain.shared.setValue(username.isEmpty ? nil : username, for: .appleIDEmail)
215+
try Keychain.shared.setValue(password.isEmpty ? nil : password, for: .appleIDPassword)
216+
} catch {
217+
print("AppleID Auth: Error saving credentials: \(error)")
218+
}
219+
}
242220

243221
func finish(_ result: Result<ALTApplication, Error>)
244222
{
@@ -453,6 +431,58 @@ private extension AppDelegate
453431
}
454432
}
455433

434+
// MARK: - AppDelegate+loginMenuItem
435+
436+
private extension AppDelegate {
437+
private func setupLoginMenuItem() {
438+
do {
439+
let email = try Keychain.shared.getValue(for: .appleIDEmail)
440+
logInMenuItem.title = "Log out (\(email))"
441+
logInMenuItem.action = #selector(logoutFromAppleID)
442+
} catch {
443+
print("Error getting stored AppleID credentials: \(error)")
444+
logInMenuItem.title = "Log in..."
445+
logInMenuItem.action = #selector(loginToAppleID)
446+
}
447+
}
448+
449+
@objc private func loginToAppleID() {
450+
let alert = AppleIDAuthenticationAlert()
451+
452+
NSRunningApplication.current.activate(options: .activateIgnoringOtherApps)
453+
let didTapContinue = alert.display()
454+
guard didTapContinue else { return }
455+
456+
let username = alert.appleIDValue.trimmingCharacters(in: .whitespacesAndNewlines)
457+
let password = alert.passwordValue.trimmingCharacters(in: .whitespacesAndNewlines)
458+
459+
guard !username.isEmpty && !password.isEmpty else {
460+
print("AppleID Auth: Username and/or password was empty.")
461+
return
462+
}
463+
464+
do {
465+
try Keychain.shared.setValue(username, for: .appleIDEmail)
466+
try Keychain.shared.setValue(password, for: .appleIDPassword)
467+
} catch {
468+
let errorAlert = NSAlert(error: error)
469+
NSRunningApplication.current.activate(options: .activateIgnoringOtherApps)
470+
errorAlert.runModal()
471+
472+
print("AppleID Auth: Error saving credentials: \(error)")
473+
}
474+
475+
setupLoginMenuItem()
476+
}
477+
478+
@objc private func logoutFromAppleID() {
479+
print("Removing AppleID credentials!")
480+
try? Keychain.shared.setValue(nil, for: .appleIDEmail)
481+
try? Keychain.shared.setValue(nil, for: .appleIDPassword)
482+
setupLoginMenuItem()
483+
}
484+
}
485+
456486
extension AppDelegate: NSMenuDelegate
457487
{
458488
func menuWillOpen(_ menu: NSMenu)
@@ -571,38 +601,6 @@ extension AppDelegate: NSMenuDelegate
571601
}
572602
}
573603

574-
extension AppDelegate: NSTextFieldDelegate
575-
{
576-
func controlTextDidChange(_ obj: Notification)
577-
{
578-
self.validate()
579-
}
580-
581-
func controlTextDidEndEditing(_ obj: Notification)
582-
{
583-
self.validate()
584-
}
585-
586-
private func validate()
587-
{
588-
guard
589-
let appleID = self.authenticationAppleIDTextField?.stringValue.trimmingCharacters(in: .whitespacesAndNewlines),
590-
let password = self.authenticationPasswordTextField?.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
591-
else { return }
592-
593-
if appleID.isEmpty || password.isEmpty
594-
{
595-
self.authenticationAlert?.buttons.first?.isEnabled = false
596-
}
597-
else
598-
{
599-
self.authenticationAlert?.buttons.first?.isEnabled = true
600-
}
601-
602-
self.authenticationAlert?.layout()
603-
}
604-
}
605-
606604
extension AppDelegate: UNUserNotificationCenterDelegate
607605
{
608606
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)

AltServer/Base.lproj/Main.storyboard

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
6-
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
76
</dependencies>
87
<scenes>
98
<!--Application-->
109
<scene sceneID="JPo-4y-FX3">
1110
<objects>
1211
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
13-
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="4" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" id="urc-xw-Dhc">
14-
<rect key="frame" x="0.0" y="0.0" width="300" height="46"/>
15-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
16-
<subviews>
17-
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zLd-d8-ghZ">
18-
<rect key="frame" x="0.0" y="25" width="300" height="21"/>
19-
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="Apple ID" drawsBackground="YES" id="BXa-Re-rs3">
20-
<font key="font" metaFont="system"/>
21-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
22-
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
23-
</textFieldCell>
24-
<connections>
25-
<outlet property="delegate" destination="Voe-Tx-rLC" id="QtW-r2-Vuh"/>
26-
<outlet property="nextKeyView" destination="9rp-Vx-rvB" id="bQY-qj-Sej"/>
27-
</connections>
28-
</textField>
29-
<secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9rp-Vx-rvB">
30-
<rect key="frame" x="0.0" y="0.0" width="300" height="21"/>
31-
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="Password" drawsBackground="YES" usesSingleLineMode="YES" id="xqJ-wt-DlP">
32-
<font key="font" metaFont="system"/>
33-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
34-
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
35-
<allowedInputSourceLocales>
36-
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
37-
</allowedInputSourceLocales>
38-
</secureTextFieldCell>
39-
<connections>
40-
<outlet property="delegate" destination="Voe-Tx-rLC" id="qav-xj-izy"/>
41-
</connections>
42-
</secureTextField>
43-
</subviews>
44-
<constraints>
45-
<constraint firstItem="9rp-Vx-rvB" firstAttribute="width" secondItem="urc-xw-Dhc" secondAttribute="width" id="Eht-pU-Gyh"/>
46-
<constraint firstItem="zLd-d8-ghZ" firstAttribute="width" secondItem="urc-xw-Dhc" secondAttribute="width" id="mg7-Kq-abL"/>
47-
<constraint firstAttribute="width" constant="300" id="zqf-x6-BET"/>
48-
</constraints>
49-
<visibilityPriorities>
50-
<integer value="1000"/>
51-
<integer value="1000"/>
52-
</visibilityPriorities>
53-
<customSpacing>
54-
<real value="3.4028234663852886e+38"/>
55-
<real value="3.4028234663852886e+38"/>
56-
</customSpacing>
57-
</stackView>
5812
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
5913
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="AltServer" customModuleProvider="target">
6014
<connections>
6115
<outlet property="appMenu" destination="uQy-DD-JDr" id="7cY-Ov-AOW"/>
62-
<outlet property="authenticationAppleIDTextField" destination="zLd-d8-ghZ" id="wW5-0J-zdq"/>
63-
<outlet property="authenticationPasswordTextField" destination="9rp-Vx-rvB" id="ZoC-DI-jzQ"/>
6416
<outlet property="connectedDevicesMenu" destination="KJ9-WY-pW1" id="Mcv-64-iFU"/>
6517
<outlet property="enableJITMenu" destination="la4-Sa-L3C" id="YrW-hR-uA7"/>
6618
<outlet property="installAltStoreMenuItem" destination="MJ8-Lt-SSV" id="KYp-c5-8Ru"/>
6719
<outlet property="installMailPluginMenuItem" destination="3CM-gV-X2G" id="lio-ha-z0S"/>
6820
<outlet property="launchAtLoginMenuItem" destination="IyR-FQ-upe" id="Fxn-EP-hwH"/>
21+
<outlet property="logInMenuItem" destination="k7w-cA-c4B" id="Wta-2g-pGI"/>
6922
<outlet property="sideloadAppMenuItem" destination="x0e-zI-0A2" id="GJo-FY-1GO"/>
7023
<outlet property="sideloadIPAConnectedDevicesMenu" destination="IuI-bV-fTY" id="QQw-St-HfG"/>
7124
</connections>
@@ -85,9 +38,9 @@
8538
</connections>
8639
</menuItem>
8740
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
88-
<menuItem title="Install AltStore" id="MJ8-Lt-SSV">
41+
<menuItem title="Install SideStore" id="MJ8-Lt-SSV">
8942
<modifierMask key="keyEquivalentModifierMask"/>
90-
<menu key="submenu" title="Install AltStore" systemMenu="recentDocuments" id="KJ9-WY-pW1">
43+
<menu key="submenu" title="Install SideStore" systemMenu="recentDocuments" id="KJ9-WY-pW1">
9144
<items>
9245
<menuItem title="No Connected Devices" id="N5N-3K-XuR">
9346
<modifierMask key="keyEquivalentModifierMask"/>
@@ -129,6 +82,10 @@
12982
<modifierMask key="keyEquivalentModifierMask"/>
13083
</menuItem>
13184
<menuItem isSeparatorItem="YES" id="mVM-Nm-Zi9"/>
85+
<menuItem title="Log in" id="k7w-cA-c4B">
86+
<modifierMask key="keyEquivalentModifierMask"/>
87+
</menuItem>
88+
<menuItem isSeparatorItem="YES" id="mhj-D5-Ycy"/>
13289
<menuItem title="Check for Updates..." id="Tnq-gD-Eic" userLabel="Check for Updates">
13390
<modifierMask key="keyEquivalentModifierMask"/>
13491
<connections>

AltServer/Devices/ALTDeviceManager+Installation.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ private extension ALTDeviceManager
322322
{
323323
return completionHandler(.success(team))
324324
}
325+
else if let team = teams.first(where: { $0.type == .organization })
326+
{
327+
return completionHandler(.success(team))
328+
}
325329
else if let team = teams.first(where: { $0.type == .free })
326330
{
327331
return completionHandler(.success(team))
@@ -532,15 +536,15 @@ private extension ALTDeviceManager
532536
let parentBundleID = parentApp?.bundleIdentifier ?? application.bundleIdentifier
533537
let updatedParentBundleID: String
534538

535-
if application.isAltStoreApp
536-
{
537-
// Use legacy bundle ID format for AltStore (and its extensions).
538-
updatedParentBundleID = "com.\(team.identifier).\(parentBundleID)"
539-
}
540-
else
541-
{
539+
// if application.isAltStoreApp
540+
// {
541+
// // Use legacy bundle ID format for AltStore (and its extensions).
542+
// updatedParentBundleID = "com.\(team.identifier).\(parentBundleID)"
543+
// }
544+
// else
545+
// {
542546
updatedParentBundleID = parentBundleID + "." + team.identifier // Append just team identifier to make it harder to track.
543-
}
547+
// }
544548

545549
let bundleID = application.bundleIdentifier.replacingOccurrences(of: parentBundleID, with: updatedParentBundleID)
546550

0 commit comments

Comments
 (0)