Compare commits

...
10 Commits
Author SHA1 Message Date
Majd Alfhaily f3a54098ea Align version (1.0.7) 2021-11-05 22:48:08 +01:00
Majd Alfhaily 69c07d0062 Fix login requests to the store API 2021-11-05 22:46:38 +01:00
Majd Alfhaily f0922b303e Align version (1.0.6) 2021-06-27 12:48:15 +02:00
Majd Alfhaily 5a4d2f5e8d Add support for supplying 2FA code in non-interactive sessions 2021-06-27 12:47:41 +02:00
Majd Alfhaily 972f0b2cd0 Align version (1.0.5) 2021-06-11 23:23:45 +02:00
Majd Alfhaily 03993b2b93 Add support for specifying device family 2021-06-11 23:23:19 +02:00
Majd Alfhaily 5009048d44 Align version (1.0.4) 2021-06-08 09:39:41 +02:00
Nicolas Thumann 59fb28cee0 Add support for specifying the iTunes Store region
* Add support for specifying country
* Update README to add support to specifying country
2021-06-08 09:28:59 +02:00
Majd Alfhaily 5f1fb02a12 Merge pull request #8 from zntfdr/patch-1
Fix readme typo
2021-06-02 16:21:41 +02:00
Federico Zanetello 32c6012918 Update README.md 2021-06-02 14:49:44 +07:00
9 changed files with 125 additions and 47 deletions

No files matched your search

+18 -8
View File
@@ -34,14 +34,20 @@ To search for apps on the App Store, use the `search` command.
```
OVERVIEW: Search for iOS apps available on the App Store.
USAGE: ipatool search [--limit <limit>] <term> [--log-level <log-level>]
USAGE: ipatool search <term> [--limit <limit>] [--country <country>] [--device-family <device-family>] [--log-level <log-level>]
ARGUMENTS:
<term> The term to search for.
OPTIONS:
--limit <limit> (default: 5)
--log-level <log-level> (default: info)
-l, --limit <limit> The maximum amount of search results to retrieve.
(default: 5)
-c, --country <country> The two-letter (ISO 3166-1 alpha-2) country code for
the iTunes Store. (default: US)
-d, --device-family <device-family>
The device family to limit the search query to.
(default: iPhone)
--log-level <log-level> The log level. (default: info)
--version Show the version.
-h, --help Show help information.
```
@@ -51,7 +57,7 @@ To download a copy of the ipa file, use the `download` command.
```
OVERVIEW: Download (encrypted) iOS app packages from the App Store.
USAGE: ipatool download --bundle-identifier <bundle-identifier> [--email <email>] [--password <password>] [--log-level <log-level>]
USAGE: ipatool download --bundle-identifier <bundle-identifier> [--email <email>] [--password <password>] [--auth-code <auth-code>] [--country <country>] [--device-family <device-family>] [--log-level <log-level>]
OPTIONS:
-b, --bundle-identifier <bundle-identifier>
@@ -59,12 +65,16 @@ OPTIONS:
-e, --email <email> The email address for the Apple ID.
-p, --password <password>
The password for the Apple ID.
--log-level <log-level> (default: info)
--auth-code <auth-code> The 2FA code for the Apple ID.
-c, --country <country> The two-letter (ISO 3166-1 alpha-2) country code for the iTunes Store. (default: US)
-d, --device-family <device-family>
The device family to limit the search query to. (default: iPhone)
--log-level <log-level> The log level. (default: info)
--version Show the version.
-h, --help Show help information.
```
**Note:** You can specify the Apple ID email address and username as arguments when using the tool or by setting them as environment variables (`IPATOOL_EMAIL` and `IPATOOL_PASSWORD`). If you do not specify this information using either of those methods, the tool will prompt for user input in an interactive session.
**Note:** You can specify the Apple ID email address and username as arguments when using the tool or by setting them as environment variables (`IPATOOL_EMAIL` and `IPATOOL_PASSWORD`). If you do not specify this information using either of those methods, the tool will prompt for user input in an interactive session. Similarly, you can supply the 2FA code interactively or using the environment variable `IPATOOL_2FA_CODE`.
## Common Knowledge
@@ -80,6 +90,6 @@ Maybe, but probably not. While this tool communicates with iTunes and the App St
**No**. This is is not a piracy tool; you can only download apps that you have previously installed on your iOS device. This limitation applies to free apps as well. Essentially, your account must already have a license for the app you are trying to download.
**Can I use this tool to sideload unuspported iOS apps on Apple Silicon Macs?**
**Can I use this tool to sideload unsupported iOS apps on Apple Silicon Macs?**
While it was previously possible to download ipa files using this tool and install them on Macs running on Apple Silicon, this is no longer the case as of recently. Apple stopped serving macOS compatible `sinf` data for the app package. You could, however, use this tool to get a copy of the iOS app and use a jailbroken iOS device to strip any codesigning requirements then codesign the app again using an adhoc signature to run on Apple Silicon.
While it was previously possible to download ipa files using this tool and install them on Macs running on Apple Silicon, this is no longer the case as of recently. Apple stopped serving macOS compatible `sinf` data for the app package. You could, however, use this tool to get a copy of the iOS app and use a jailbroken iOS device to strip any codesigning requirements then codesign the app again using an adhoc signature to run on Apple Silicon.
+30 -10
View File
@@ -22,14 +22,23 @@ struct Download: ParsableCommand {
@Option(name: [.short, .customLong("password")], help: "The password for the Apple ID.")
private var passwordArgument: String?
@Option
@Option(name: [.customLong("auth-code")], help: "The 2FA code for the Apple ID.")
private var authCodeArgument: String?
@Option(name: [.short, .long], help: "The two-letter (ISO 3166-1 alpha-2) country code for the iTunes Store.")
private var country: String = "US"
@Option(name: [.short, .long], help: "The device family to limit the search query to.")
private var deviceFamily: iTunesRequest.DeviceFamily = .phone
@Option(name: [.long], help: "The log level.")
private var logLevel: LogLevel = .info
lazy var logger = ConsoleLogger(level: logLevel)
}
extension Download {
mutating func app(with bundleIdentifier: String) -> iTunesResponse.Result {
mutating func app(with bundleIdentifier: String, country: String) -> iTunesResponse.Result {
logger.log("Creating HTTP client...", level: .debug)
let httpClient = HTTPClient(urlSession: URLSession.shared)
@@ -37,8 +46,8 @@ extension Download {
let itunesClient = iTunesClient(httpClient: httpClient)
do {
logger.log("Querying the iTunes Store for '\(bundleIdentifier)'...", level: .info)
return try itunesClient.lookup(bundleIdentifier: bundleIdentifier)
logger.log("Querying the iTunes Store for '\(bundleIdentifier)' in country '\(country)'...", level: .info)
return try itunesClient.lookup(bundleIdentifier: bundleIdentifier, country: country, deviceFamily: deviceFamily)
} catch {
logger.log("\(error)", level: .debug)
@@ -78,7 +87,20 @@ extension Download {
_exit(1)
}
}
mutating func authCode() -> String {
if let authCode = authCodeArgument {
return authCode
} else if let authCode = ProcessInfo.processInfo.environment["IPATOOL_2FA_CODE"] {
return authCode
} else if let authCode = String(validatingUTF8: UnsafePointer<CChar>(getpass(logger.compile("Enter 2FA code: ", level: .warning)))) {
return authCode
} else {
logger.log("A 2FA auth-code is required.", level: .error)
_exit(1)
}
}
mutating func authenticate(email: String, password: String) -> StoreResponse.Account {
logger.log("Creating HTTP client...", level: .debug)
let httpClient = HTTPClient(urlSession: URLSession.shared)
@@ -92,10 +114,8 @@ extension Download {
} catch {
switch error {
case StoreResponse.Error.codeRequired:
let code = String(validatingUTF8: UnsafePointer<CChar>(getpass(logger.compile("Enter 2FA code: ", level: .warning))))
do {
return try storeClient.authenticate(email: email, password: password, code: code)
return try storeClient.authenticate(email: email, password: password, code: authCode())
} catch {
logger.log("\(error)", level: .debug)
@@ -199,7 +219,7 @@ extension Download {
mutating func run() throws {
// Query for app
let app: iTunesResponse.Result = app(with: bundleIdentifier)
let app: iTunesResponse.Result = app(with: bundleIdentifier, country: country)
logger.log("Found app: \(app.name) (\(app.version)).", level: .debug)
// Get Apple ID email
+1 -1
View File
@@ -11,7 +11,7 @@ struct IPATool: ParsableCommand {
static var configuration: CommandConfiguration {
return .init(commandName: "ipatool",
abstract: "A cli tool for interacting with Apple's ipa files.",
version: "1.0.3",
version: "1.0.7",
subcommands: [Download.self, Search.self])
}
}
+14 -8
View File
@@ -13,20 +13,26 @@ struct Search: ParsableCommand {
return .init(abstract: "Search for iOS apps available on the App Store.")
}
@Option
@Argument(help: "The term to search for.")
private var term: String
@Option(name: [.short, .long], help: "The maximum amount of search results to retrieve.")
private var limit: Int = 5
@Argument(help: "The term to search for.")
var term: String
@Option(name: [.short, .long], help: "The two-letter (ISO 3166-1 alpha-2) country code for the iTunes Store.")
private var country: String = "US"
@Option
@Option(name: [.short, .long], help: "The device family to limit the search query to.")
private var deviceFamily: iTunesRequest.DeviceFamily = .phone
@Option(name: [.long], help: "The log level.")
private var logLevel: LogLevel = .info
lazy var logger = ConsoleLogger(level: logLevel)
}
extension Search {
mutating func results(with term: String) -> [iTunesResponse.Result] {
mutating func results(with term: String, country: String) -> [iTunesResponse.Result] {
logger.log("Creating HTTP client...", level: .debug)
let httpClient = HTTPClient(urlSession: URLSession.shared)
@@ -34,8 +40,8 @@ extension Search {
let itunesClient = iTunesClient(httpClient: httpClient)
do {
logger.log("Searching for '\(term)'...", level: .info)
let results = try itunesClient.search(term: term, limit: limit)
logger.log("Searching for '\(term)' using the '\(country)' store front...", level: .info)
let results = try itunesClient.search(term: term, limit: limit, country: country, deviceFamily: deviceFamily)
guard !results.isEmpty else {
logger.log("No results found.", level: .error)
@@ -52,7 +58,7 @@ extension Search {
mutating func run() throws {
// Search the iTunes store
let results = results(with: term)
let results = results(with: term, country: country)
// Compile output
let output = results
+1 -1
View File
@@ -28,7 +28,7 @@ extension StoreRequest: HTTPRequest {
var headers: [String: String] {
var headers: [String: String] = [
"User-Agent": "Configurator/2.0 (Macintosh; OS X 10.12.6; 16G29) AppleWebKit/2603.3.8",
"User-Agent": "Configurator/2.15 (Macintosh; OS X 11.0.0; 16G29) AppleWebKit/2603.3.8",
"Content-Type": "application/x-www-form-urlencoded"
]
+24 -10
View File
@@ -8,16 +8,23 @@
import Foundation
protocol iTunesClientInterface {
func lookup(bundleIdentifier: String, completion: @escaping (Result<iTunesResponse.Result, Error>) -> Void)
func search(term: String, limit: Int, completion: @escaping (Result<[iTunesResponse.Result], Error>) -> Void)
func lookup(bundleIdentifier: String,
country: String,
deviceFamily: iTunesRequest.DeviceFamily,
completion: @escaping (Result<iTunesResponse.Result, Error>) -> Void)
func search(term: String,
limit: Int,
country: String,
deviceFamily: iTunesRequest.DeviceFamily,
completion: @escaping (Result<[iTunesResponse.Result], Error>) -> Void)
}
extension iTunesClientInterface {
func lookup(bundleIdentifier: String) throws -> iTunesResponse.Result {
func lookup(bundleIdentifier: String, country: String, deviceFamily: iTunesRequest.DeviceFamily) throws -> iTunesResponse.Result {
let semaphore = DispatchSemaphore(value: 0)
var result: Result<iTunesResponse.Result, Error>?
lookup(bundleIdentifier: bundleIdentifier) {
lookup(bundleIdentifier: bundleIdentifier, country: country, deviceFamily: deviceFamily) {
result = $0
semaphore.signal()
}
@@ -34,11 +41,11 @@ extension iTunesClientInterface {
}
}
func search(term: String, limit: Int) throws -> [iTunesResponse.Result] {
func search(term: String, limit: Int, country: String, deviceFamily: iTunesRequest.DeviceFamily) throws -> [iTunesResponse.Result] {
let semaphore = DispatchSemaphore(value: 0)
var result: Result<[iTunesResponse.Result], Error>?
search(term: term, limit: limit) {
search(term: term, limit: limit, country: country, deviceFamily: deviceFamily) {
result = $0
semaphore.signal()
}
@@ -63,8 +70,11 @@ final class iTunesClient: iTunesClientInterface {
self.httpClient = httpClient
}
func lookup(bundleIdentifier: String, completion: @escaping (Result<iTunesResponse.Result, Swift.Error>) -> Void) {
let request = iTunesRequest.lookup(bundleIdentifier: bundleIdentifier)
func lookup(bundleIdentifier: String,
country: String,
deviceFamily: iTunesRequest.DeviceFamily,
completion: @escaping (Result<iTunesResponse.Result, Swift.Error>) -> Void) {
let request = iTunesRequest.lookup(bundleIdentifier: bundleIdentifier, country: country, deviceFamily: deviceFamily)
httpClient.send(request) { result in
switch result {
@@ -82,8 +92,12 @@ final class iTunesClient: iTunesClientInterface {
}
}
func search(term: String, limit: Int, completion: @escaping (Result<[iTunesResponse.Result], Swift.Error>) -> Void) {
let request = iTunesRequest.search(term: term, limit: limit)
func search(term: String,
limit: Int,
country: String,
deviceFamily: iTunesRequest.DeviceFamily,
completion: @escaping (Result<[iTunesResponse.Result], Swift.Error>) -> Void) {
let request = iTunesRequest.search(term: term, limit: limit, country: country, deviceFamily: deviceFamily)
httpClient.send(request) { result in
switch result {
+27 -7
View File
@@ -5,11 +5,31 @@
// Created by Majd Alfhaily on 22.05.21.
//
import Foundation
import ArgumentParser
enum iTunesRequest {
case search(term: String, limit: Int)
case lookup(bundleIdentifier: String)
case search(term: String, limit: Int, country: String, deviceFamily: DeviceFamily = .phone)
case lookup(bundleIdentifier: String, country: String, deviceFamily: DeviceFamily = .phone)
}
extension iTunesRequest {
enum DeviceFamily: String, ExpressibleByArgument {
case phone = "iPhone"
case pad = "iPad"
var defaultValueDescription: String {
return rawValue
}
var entity: String {
switch self {
case .phone:
return "software"
case .pad:
return "iPadSoftware"
}
}
}
}
extension iTunesRequest: HTTPRequest {
@@ -28,10 +48,10 @@ extension iTunesRequest: HTTPRequest {
var payload: HTTPPayload? {
switch self {
case let .lookup(bundleIdentifier):
return .urlEncoding(["media": "software", "bundleId": bundleIdentifier, "limit": "1"])
case let .search(term, limit):
return .urlEncoding(["media": "software", "term": term, "limit": "\(limit)"])
case let .lookup(bundleIdentifier, country, deviceFamily):
return .urlEncoding(["media": "software", "bundleId": bundleIdentifier, "limit": "1", "country": country, "entity": deviceFamily.entity])
case let .search(term, limit, country, deviceFamily):
return .urlEncoding(["media": "software", "term": term, "limit": "\(limit)", "country": country, "entity": deviceFamily.entity])
}
}
}
+1 -1
View File
@@ -122,8 +122,8 @@
isa = PBXGroup;
children = (
A9CA48CC2658FBF700BC09D5 /* Download.swift */,
A9CA49022659627A00BC09D5 /* Search.swift */,
A9CA48CE2658FC7400BC09D5 /* IPATool.swift */,
A9CA49022659627A00BC09D5 /* Search.swift */,
);
path = Commands;
sourceTree = "<group>";
@@ -55,6 +55,14 @@
argument = "download --help"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "search &quot;Swift Playgrounds&quot; --device-family iPhone"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "search &quot;Swift Playgrounds&quot; --device-family iPad"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "download -b com.apple.TestFlight"
isEnabled = "NO">
@@ -65,7 +73,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "search TestFlight --limit 5"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>