mirror of
https://github.com/majd/ipatool
synced 2026-11-28 02:07:52 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cffa279e31 | ||
|
|
034a0978ab | ||
|
|
9657750fc1 | ||
|
|
9969c18cef | ||
|
|
f09439ecde | ||
|
|
55ef41fc20 | ||
|
|
b4bd8d6580 | ||
|
|
79250ae2a3 | ||
|
|
a3212e0fd2 | ||
|
|
805678138e | ||
|
|
3a537e7571 | ||
|
|
e686248270 | ||
|
|
ac081fa19d | ||
|
|
7136f81fd1 | ||
|
|
34866f5833 | ||
|
|
46f3369de0 | ||
|
|
0bb134e9d7 | ||
|
|
bbf3717456 | ||
|
|
e1eda9f776 | ||
|
|
c406c36819 | ||
|
|
e5291ba16b | ||
|
|
37af8f8468 | ||
|
|
21cbd596bc | ||
|
|
f3c9076ff0 | ||
|
|
d147788501 | ||
|
|
8a23d6fadd | ||
|
|
63ee6fc6a4 | ||
|
|
5b547457f1 | ||
|
|
169af4b2ea | ||
|
|
f68a119963 | ||
|
|
58e9a18778 | ||
|
|
c8624b26d5 | ||
|
|
3199afc494 | ||
|
|
6597f5ac77 | ||
|
|
6ccb4a7f0b | ||
|
|
64c5cc9843 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# github: [majd]
|
||||
patreon: majd_dev
|
||||
@@ -12,12 +12,12 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
arch: [arm64, amd64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go build -o ipatool-$GOOS-$GOARCH.exe
|
||||
env:
|
||||
@@ -29,12 +29,12 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
arch: [arm64, amd64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go build -o ipatool-$GOOS-$GOARCH
|
||||
env:
|
||||
@@ -46,16 +46,16 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
arch: [arm64, amd64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go build -o ipatool-$GOOS-$GOARCH
|
||||
env:
|
||||
GOOS: darwin
|
||||
GOARCH: ${{ matrix.arch }}
|
||||
CGO_CFLAGS: -mmacosx-version-min=10.15
|
||||
CGO_LDFLAGS: -mmacosx-version-min=10.15
|
||||
CGO_LDFLAGS: -mmacosx-version-min=10.15
|
||||
@@ -9,19 +9,17 @@ jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go build -o ipatool
|
||||
env:
|
||||
CGO_CFLAGS: -mmacosx-version-min=10.15
|
||||
CGO_LDFLAGS: -mmacosx-version-min=10.15
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ipatool
|
||||
path: ipatool
|
||||
@@ -35,9 +33,9 @@ jobs:
|
||||
matrix:
|
||||
command: [auth, download, purchase, search]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ipatool
|
||||
path: build
|
||||
- run: chmod +x ./build/ipatool
|
||||
- run: ./build/ipatool ${{ matrix.command }} --help
|
||||
- run: ./build/ipatool ${{ matrix.command }} --help
|
||||
@@ -1,18 +0,0 @@
|
||||
name: Issues Cleanup
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
schedule:
|
||||
- cron: "0 * * * *" # Every hour, every day
|
||||
|
||||
jobs:
|
||||
scan-issues:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: lee-dohm/no-response@v0.5.0
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
daysUntilClose: 7
|
||||
closeComment: This issue has been automatically closed because there has been no response from the original author.
|
||||
responseRequiredLabel: auto-close
|
||||
@@ -13,9 +13,9 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go generate github.com/majd/ipatool/...
|
||||
- uses: golangci/golangci-lint-action@v3
|
||||
- uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
version: v1.52.2
|
||||
version: v2.1
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go generate github.com/majd/ipatool/...
|
||||
- run: go test -v github.com/majd/ipatool/...
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go build -ldflags="-X github.com/majd/ipatool/v2/cmd.version=$VERSION" -o ipatool-$VERSION-windows-arm64.exe
|
||||
env:
|
||||
@@ -71,32 +71,32 @@ jobs:
|
||||
CGO_CFLAGS: -mmacosx-version-min=10.15
|
||||
CGO_LDFLAGS: -mmacosx-version-min=10.15
|
||||
CGO_ENABLED: 1
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe
|
||||
if-no-files-found: error
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe
|
||||
if-no-files-found: error
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-linux-arm64
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-linux-arm64
|
||||
if-no-files-found: error
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-linux-amd64
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-linux-amd64
|
||||
if-no-files-found: error
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
|
||||
if-no-files-found: error
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
@@ -108,10 +108,10 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
arch: [arm64, amd64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.exe
|
||||
path: bin
|
||||
@@ -135,10 +135,10 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
arch: [arm64, amd64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}
|
||||
path: bin
|
||||
@@ -163,14 +163,14 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: ./ipatool
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
|
||||
path: bin
|
||||
- run: tar -czvf $BIN.tar.gz bin/$BIN && rm -rf bin/
|
||||
env:
|
||||
BIN: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
path: bin
|
||||
@@ -214,4 +214,4 @@ jobs:
|
||||
git push "https://${{ secrets.GH_TOKEN }}@github.com/${{ secrets.HOMEBREW_REPO }}.git" --set-upstream "main"
|
||||
env:
|
||||
SHA256_ARM64: ${{ steps.sha256.outputs.sha256_arm64 }}
|
||||
SHA256_AMD64: ${{ steps.sha256.outputs.sha256_amd64 }}
|
||||
SHA256_AMD64: ${{ steps.sha256.outputs.sha256_amd64 }}
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
go-version: "1.23.0"
|
||||
cache: true
|
||||
- run: go generate github.com/majd/ipatool/...
|
||||
- run: go test -v github.com/majd/ipatool/...
|
||||
+22
-6
@@ -1,10 +1,6 @@
|
||||
version: "2"
|
||||
linters:
|
||||
enable:
|
||||
- errcheck
|
||||
- govet
|
||||
- goimports
|
||||
- gofmt
|
||||
- unused
|
||||
- ginkgolinter
|
||||
- godot
|
||||
- godox
|
||||
@@ -13,10 +9,30 @@ linters:
|
||||
- nonamedreturns
|
||||
- prealloc
|
||||
- predeclared
|
||||
- tenv
|
||||
- unconvert
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
- wastedassign
|
||||
- wrapcheck
|
||||
- wsl
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
formatters:
|
||||
enable:
|
||||
- gofmt
|
||||
- goimports
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
-132
@@ -1,132 +0,0 @@
|
||||
## Changelog
|
||||
|
||||
### Version [2.1.3](https://github.com/majd/ipatool/releases/tag/v2.1.3)
|
||||
|
||||
- Fixed a bug where temporary files were not removed after downloading the app package.
|
||||
- Fixed a bug where the `--keychain-passphrase` flag was marked as invalid.
|
||||
|
||||
### Version [2.1.2](https://github.com/majd/ipatool/releases/tag/v2.1.2)
|
||||
|
||||
- `FileBackend` keyring is now used when other options are not available.
|
||||
|
||||
### Version [2.1.1](https://github.com/majd/ipatool/releases/tag/v2.1.1)
|
||||
|
||||
- Fixed an issue when creating the config directory for the tool.
|
||||
|
||||
### Version [2.1.0](https://github.com/majd/ipatool/releases/tag/v2.1.0)
|
||||
|
||||
- Implemented `Lookup` API.
|
||||
- Implemented `AccountInfo` API.
|
||||
- Implemented `ReplicateSinf` API.
|
||||
- Added storefront code for Georgia (GE).
|
||||
- Build version is now set using linker flags.
|
||||
- Refactored API interfaces.
|
||||
- Improved tests for http package.
|
||||
- Integrated `golangci-lint` linter.
|
||||
- Added v2 suffix to module path.
|
||||
|
||||
### Version [2.0.3](https://github.com/majd/ipatool/releases/tag/v2.0.3)
|
||||
|
||||
- Added support for downloading Apple Arcade games.
|
||||
- Fixed windows builds not having exe extension.
|
||||
|
||||
|
||||
### Version [2.0.2](https://github.com/majd/ipatool/releases/tag/v2.0.2)
|
||||
|
||||
- Fixed Sinf patches when the app contains an Apple Watch app.
|
||||
- Added storefront code for Albania.
|
||||
- Fixed default output path to be current working directory.
|
||||
|
||||
### Version [2.0.1](https://github.com/majd/ipatool/releases/tag/v2.0.1)
|
||||
|
||||
- Linux & Windows releases now include the sha256 hash.
|
||||
- Added storefront code for Mongolia.
|
||||
|
||||
### Version [2.0.0](https://github.com/majd/ipatool/releases/tag/v2.0.0)
|
||||
|
||||
- Added support for Windows.
|
||||
- Added support for Linux.
|
||||
- Added support for generating autocompletion script using the `completion` command.
|
||||
- Implemented new `auth info` command.
|
||||
- Implemented `--verbose` flag that replaces the `--debug-level` flag to enable verbose logging.
|
||||
- Implemented `--format` which allows specifying logs output format to either text or json (default: text).
|
||||
- Implemented `--non-interactive` flag to disable running the tool in an interactive session.
|
||||
- The relevant command (i.e. purchase) will now automatically determine the country and the device family from the authenticated account. The following flags have been deprecated.
|
||||
- `--country`
|
||||
- `--device-family`
|
||||
- Improved structured logging.
|
||||
- Improved error handling.
|
||||
- Improved support for automated systems.
|
||||
- Added unit tests to cover the majority of the private App Store API logic.
|
||||
|
||||
### Version [1.1.4](https://github.com/majd/ipatool/releases/tag/v1.1.4)
|
||||
|
||||
- Add support for patching old code signature revisions as a fallback mechanism.
|
||||
|
||||
### Version [1.1.3](https://github.com/majd/ipatool/releases/tag/v1.1.3)
|
||||
|
||||
- Fixed keychain access on iOS.
|
||||
|
||||
### Version [1.1.2](https://github.com/majd/ipatool/releases/tag/v1.1.2)
|
||||
|
||||
- Improved error message for expired token.
|
||||
- Disabled print buffering and output errors to stderr.
|
||||
- Added linter.
|
||||
- Add support for running on iOS.
|
||||
|
||||
### Version [1.1.1](https://github.com/majd/ipatool/releases/tag/v1.1.1)
|
||||
|
||||
- Update swift-argument-parser dependency.
|
||||
- Remove usage of Swift concurrency.
|
||||
- Add backward-compatibility for macOS 10.11+.
|
||||
|
||||
### Version [1.1.0](https://github.com/majd/ipatool/releases/tag/v1.1.0)
|
||||
|
||||
- Added support for purchasing apps.
|
||||
- Implemented auth command.
|
||||
- Implemented purchase command.
|
||||
- Implemented --purchase flag in download command.
|
||||
- Added price checks for purchase flow.
|
||||
|
||||
|
||||
### Version [1.0.9](https://github.com/majd/ipatool/releases/tag/v1.0.9)
|
||||
|
||||
- Fixed building for older macOS versions.
|
||||
- Fixed 2FA code not being requested.
|
||||
|
||||
|
||||
### Version [1.0.8](https://github.com/majd/ipatool/releases/tag/v1.0.8)
|
||||
|
||||
- Added --output option to the download command for specifying the destination path for the downloaded app package.
|
||||
|
||||
### Version [1.0.7](https://github.com/majd/ipatool/releases/tag/v1.0.7)
|
||||
|
||||
- Fixed login requests to the store API when the 2FA code is required.
|
||||
|
||||
### Version [1.0.6](https://github.com/majd/ipatool/releases/tag/v1.0.6)
|
||||
|
||||
- Added support for supplying 2FA code in non-interactive sessions.
|
||||
|
||||
### Version [1.0.5](https://github.com/majd/ipatool/releases/tag/v1.0.5)
|
||||
|
||||
- Added support for specifying device family.
|
||||
|
||||
### Version [1.0.4](https://github.com/majd/ipatool/releases/tag/v1.0.4)
|
||||
|
||||
- Added support for specifying the iTunes Store region.
|
||||
|
||||
### Version [1.0.3](https://github.com/majd/ipatool/releases/tag/v1.0.3)
|
||||
|
||||
- Improved console logging.
|
||||
|
||||
### Version [1.0.2](https://github.com/majd/ipatool/releases/tag/v1.0.2)
|
||||
|
||||
- Improved error messages.
|
||||
|
||||
### Version [1.0.1](https://github.com/majd/ipatool/releases/tag/v1.0.1)
|
||||
|
||||
- Grammatical fixes.
|
||||
|
||||
### Version [1.0.0](https://github.com/majd/ipatool/releases/tag/v1.0.0)
|
||||
|
||||
- Initial release.
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
`ipatool` is a command line tool that allows you to search for iOS apps on the [App Store](https://apps.apple.com) and download a copy of the app package, known as an _ipa_ file.
|
||||
|
||||

|
||||

|
||||
|
||||
- [Requirements](#requirements)
|
||||
- [Installation](#installation)
|
||||
@@ -14,10 +14,11 @@
|
||||
- [Usage](#usage)
|
||||
- [Compiling](#compiling)
|
||||
- [License](#license)
|
||||
- [Changelog](https://github.com/majd/ipatool/blob/main/CHANGELOG.md)
|
||||
- [Releases](https://github.com/majd/ipatool/releases)
|
||||
- [FAQ](https://github.com/majd/ipatool/wiki/FAQ)
|
||||
|
||||
## Requirements
|
||||
|
||||
- Supported operating system (Windows, Linux or macOS).
|
||||
- Apple ID set up to use the App Store.
|
||||
|
||||
@@ -32,7 +33,6 @@ You can grab the latest version of `ipatool` from [GitHub releases](https://gith
|
||||
You can install `ipatool` using [Homebrew](https://brew.sh).
|
||||
|
||||
```shell
|
||||
$ brew tap majd/repo
|
||||
$ brew install ipatool
|
||||
```
|
||||
|
||||
@@ -98,6 +98,26 @@ Global Flags:
|
||||
--verbose enables verbose logs
|
||||
```
|
||||
|
||||
To obtain a list of availble app versions to download, use the `list-versions` command.
|
||||
|
||||
```
|
||||
List the available versions of an iOS app
|
||||
|
||||
Usage:
|
||||
ipatool list-versions [flags]
|
||||
|
||||
Flags:
|
||||
-i, --app-id int ID of the target iOS app (required)
|
||||
-b, --bundle-identifier string The bundle identifier of the target iOS app (overrides the app ID)
|
||||
-h, --help help for list-versions
|
||||
|
||||
Global Flags:
|
||||
--format format sets output format for command; can be 'text', 'json' (default text)
|
||||
--keychain-passphrase string passphrase for unlocking keychain
|
||||
--non-interactive run in non-interactive session
|
||||
--verbose enables verbose logs
|
||||
```
|
||||
|
||||
To download a copy of the ipa file, use the `download` command.
|
||||
|
||||
```
|
||||
@@ -107,15 +127,39 @@ Usage:
|
||||
ipatool download [flags]
|
||||
|
||||
Flags:
|
||||
-b, --bundle-identifier string The bundle identifier of the target iOS app (required)
|
||||
-h, --help help for download
|
||||
-o, --output string The destination path of the downloaded app package
|
||||
--purchase Obtain a license for the app if needed
|
||||
-i, --app-id int ID of the target iOS app (required)
|
||||
-b, --bundle-identifier string The bundle identifier of the target iOS app (overrides the app ID)
|
||||
--external-version-id string External version identifier of the target iOS app (defaults to latest version when not specified)
|
||||
-h, --help help for download
|
||||
-o, --output string The destination path of the downloaded app package
|
||||
--purchase Obtain a license for the app if needed
|
||||
|
||||
Global Flags:
|
||||
--format format sets output format for command; can be 'text', 'json' (default text)
|
||||
--non-interactive run in non-interactive session
|
||||
--verbose enables verbose logs
|
||||
--format format sets output format for command; can be 'text', 'json' (default text)
|
||||
--keychain-passphrase string passphrase for unlocking keychain
|
||||
--non-interactive run in non-interactive session
|
||||
--verbose enables verbose logs
|
||||
```
|
||||
|
||||
To resolve an external version identifier, returned by the `list-versions` command, use the `get-version-metadata` command.
|
||||
|
||||
```
|
||||
Retrieves the metadata for a specific version of an app
|
||||
|
||||
Usage:
|
||||
ipatool get-version-metadata [flags]
|
||||
|
||||
Flags:
|
||||
-i, --app-id int ID of the target iOS app (required)
|
||||
-b, --bundle-identifier string The bundle identifier of the target iOS app (overrides the app ID)
|
||||
--external-version-id string External version identifier of the target iOS app (required)
|
||||
-h, --help help for get-version-metadata
|
||||
|
||||
Global Flags:
|
||||
--format format sets output format for command; can be 'text', 'json' (default text)
|
||||
--keychain-passphrase string passphrase for unlocking keychain
|
||||
--non-interactive run in non-interactive session
|
||||
--verbose enables verbose logs
|
||||
```
|
||||
|
||||
**Note:** the tool runs in interactive mode by default. Use the `--non-interactive` flag
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ func loginCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&email, "email", "e", "", "email address for the Apple ID (required)")
|
||||
cmd.Flags().StringVarP(&password, "password", "p", "", "password for the Apple ID (required")
|
||||
cmd.Flags().StringVarP(&password, "password", "p", "", "password for the Apple ID (required)")
|
||||
cmd.Flags().StringVar(&authCode, "auth-code", "", "2FA code for the Apple ID")
|
||||
|
||||
_ = cmd.MarkFlagRequired("email")
|
||||
|
||||
+50
-27
@@ -14,17 +14,24 @@ import (
|
||||
// nolint:wrapcheck
|
||||
func downloadCmd() *cobra.Command {
|
||||
var (
|
||||
acquireLicense bool
|
||||
outputPath string
|
||||
bundleID string
|
||||
acquireLicense bool
|
||||
outputPath string
|
||||
appID int64
|
||||
bundleID string
|
||||
externalVersionID string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "download",
|
||||
Short: "Download (encrypted) iOS app packages from the App Store",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if appID == 0 && bundleID == "" {
|
||||
return errors.New("either the app ID or the bundle identifier must be specified")
|
||||
}
|
||||
|
||||
var lastErr error
|
||||
var acc appstore.Account
|
||||
purchased := false
|
||||
|
||||
return retry.Do(func() error {
|
||||
infoResult, err := dependencies.AppStore.AccountInfo()
|
||||
@@ -43,34 +50,48 @@ func downloadCmd() *cobra.Command {
|
||||
acc = loginResult.Account
|
||||
}
|
||||
|
||||
lookupResult, err := dependencies.AppStore.Lookup(appstore.LookupInput{Account: acc, BundleID: bundleID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if errors.Is(lastErr, appstore.ErrLicenseRequired) {
|
||||
err := dependencies.AppStore.Purchase(appstore.PurchaseInput{Account: acc, App: lookupResult.App})
|
||||
app := appstore.App{ID: appID}
|
||||
if bundleID != "" {
|
||||
lookupResult, err := dependencies.AppStore.Lookup(appstore.LookupInput{Account: acc, BundleID: bundleID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
app = lookupResult.App
|
||||
}
|
||||
|
||||
progress := progressbar.NewOptions64(1,
|
||||
progressbar.OptionSetDescription("downloading"),
|
||||
progressbar.OptionSetWriter(os.Stdout),
|
||||
progressbar.OptionShowBytes(true),
|
||||
progressbar.OptionSetWidth(20),
|
||||
progressbar.OptionFullWidth(),
|
||||
progressbar.OptionThrottle(65*time.Millisecond),
|
||||
progressbar.OptionShowCount(),
|
||||
progressbar.OptionClearOnFinish(),
|
||||
progressbar.OptionSpinnerType(14),
|
||||
progressbar.OptionSetRenderBlankState(true),
|
||||
progressbar.OptionSetElapsedTime(false),
|
||||
progressbar.OptionSetPredictTime(false),
|
||||
)
|
||||
if errors.Is(lastErr, appstore.ErrLicenseRequired) {
|
||||
err := dependencies.AppStore.Purchase(appstore.PurchaseInput{Account: acc, App: app})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
purchased = true
|
||||
dependencies.Logger.Verbose().
|
||||
Bool("success", true).
|
||||
Msg("purchase")
|
||||
}
|
||||
|
||||
out, err := dependencies.AppStore.Download(appstore.DownloadInput{Account: acc, App: lookupResult.App, OutputPath: outputPath, Progress: progress})
|
||||
interactive, _ := cmd.Context().Value("interactive").(bool)
|
||||
var progress *progressbar.ProgressBar
|
||||
if interactive {
|
||||
progress = progressbar.NewOptions64(1,
|
||||
progressbar.OptionSetDescription("downloading"),
|
||||
progressbar.OptionSetWriter(os.Stdout),
|
||||
progressbar.OptionShowBytes(true),
|
||||
progressbar.OptionSetWidth(20),
|
||||
progressbar.OptionFullWidth(),
|
||||
progressbar.OptionThrottle(65*time.Millisecond),
|
||||
progressbar.OptionShowCount(),
|
||||
progressbar.OptionClearOnFinish(),
|
||||
progressbar.OptionSpinnerType(14),
|
||||
progressbar.OptionSetRenderBlankState(true),
|
||||
progressbar.OptionSetElapsedTime(false),
|
||||
progressbar.OptionSetPredictTime(false),
|
||||
)
|
||||
}
|
||||
|
||||
out, err := dependencies.AppStore.Download(appstore.DownloadInput{
|
||||
Account: acc, App: app, OutputPath: outputPath, Progress: progress, ExternalVersionID: externalVersionID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -82,6 +103,7 @@ func downloadCmd() *cobra.Command {
|
||||
|
||||
dependencies.Logger.Log().
|
||||
Str("output", out.DestinationPath).
|
||||
Bool("purchased", purchased).
|
||||
Bool("success", true).
|
||||
Send()
|
||||
|
||||
@@ -108,10 +130,11 @@ func downloadCmd() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&bundleID, "bundle-identifier", "b", "", "The bundle identifier of the target iOS app (required)")
|
||||
cmd.Flags().Int64VarP(&appID, "app-id", "i", 0, "ID of the target iOS app (required)")
|
||||
cmd.Flags().StringVarP(&bundleID, "bundle-identifier", "b", "", "The bundle identifier of the target iOS app (overrides the app ID)")
|
||||
cmd.Flags().StringVarP(&outputPath, "output", "o", "", "The destination path of the downloaded app package")
|
||||
cmd.Flags().StringVar(&externalVersionID, "external-version-id", "", "External version identifier of the target iOS app (defaults to latest version when not specified)")
|
||||
cmd.Flags().BoolVar(&acquireLicense, "purchase", false, "Obtain a license for the app if needed")
|
||||
_ = cmd.MarkFlagRequired("bundle-identifier")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/avast/retry-go"
|
||||
"github.com/majd/ipatool/v2/pkg/appstore"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// nolint:wrapcheck
|
||||
func getVersionMetadataCmd() *cobra.Command {
|
||||
var (
|
||||
appID int64
|
||||
bundleID string
|
||||
externalVersionID string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "get-version-metadata",
|
||||
Short: "Retrieves the metadata for a specific version of an app",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if appID == 0 && bundleID == "" {
|
||||
return errors.New("either the app ID or the bundle identifier must be specified")
|
||||
}
|
||||
|
||||
var lastErr error
|
||||
var acc appstore.Account
|
||||
|
||||
return retry.Do(func() error {
|
||||
infoResult, err := dependencies.AppStore.AccountInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
acc = infoResult.Account
|
||||
|
||||
if errors.Is(lastErr, appstore.ErrPasswordTokenExpired) {
|
||||
loginResult, err := dependencies.AppStore.Login(appstore.LoginInput{Email: acc.Email, Password: acc.Password})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
acc = loginResult.Account
|
||||
}
|
||||
|
||||
app := appstore.App{ID: appID}
|
||||
if bundleID != "" {
|
||||
lookupResult, err := dependencies.AppStore.Lookup(appstore.LookupInput{Account: acc, BundleID: bundleID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
app = lookupResult.App
|
||||
}
|
||||
|
||||
out, err := dependencies.AppStore.GetVersionMetadata(appstore.GetVersionMetadataInput{
|
||||
Account: acc,
|
||||
App: app,
|
||||
VersionID: externalVersionID,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dependencies.Logger.Log().
|
||||
Str("externalVersionID", externalVersionID).
|
||||
Str("displayVersion", out.DisplayVersion).
|
||||
Time("releaseDate", out.ReleaseDate).
|
||||
Bool("success", true).
|
||||
Send()
|
||||
|
||||
return nil
|
||||
},
|
||||
retry.LastErrorOnly(true),
|
||||
retry.DelayType(retry.FixedDelay),
|
||||
retry.Delay(time.Millisecond),
|
||||
retry.Attempts(2),
|
||||
retry.RetryIf(func(err error) bool {
|
||||
lastErr = err
|
||||
|
||||
return errors.Is(err, appstore.ErrPasswordTokenExpired)
|
||||
}),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Int64VarP(&appID, "app-id", "i", 0, "ID of the target iOS app (required)")
|
||||
cmd.Flags().StringVarP(&bundleID, "bundle-identifier", "b", "", "The bundle identifier of the target iOS app (overrides the app ID)")
|
||||
cmd.Flags().StringVar(&externalVersionID, "external-version-id", "", "External version identifier of the target iOS app (required)")
|
||||
|
||||
_ = cmd.MarkFlagRequired("external-version-id")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/avast/retry-go"
|
||||
"github.com/majd/ipatool/v2/pkg/appstore"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// nolint:wrapcheck
|
||||
func ListVersionsCmd() *cobra.Command {
|
||||
var (
|
||||
appID int64
|
||||
bundleID string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "list-versions",
|
||||
Short: "List the available versions of an iOS app",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if appID == 0 && bundleID == "" {
|
||||
return errors.New("either the app ID or the bundle identifier must be specified")
|
||||
}
|
||||
|
||||
var lastErr error
|
||||
var acc appstore.Account
|
||||
|
||||
return retry.Do(func() error {
|
||||
infoResult, err := dependencies.AppStore.AccountInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
acc = infoResult.Account
|
||||
|
||||
if errors.Is(lastErr, appstore.ErrPasswordTokenExpired) {
|
||||
loginResult, err := dependencies.AppStore.Login(appstore.LoginInput{Email: acc.Email, Password: acc.Password})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
acc = loginResult.Account
|
||||
}
|
||||
|
||||
app := appstore.App{ID: appID}
|
||||
if bundleID != "" {
|
||||
lookupResult, err := dependencies.AppStore.Lookup(appstore.LookupInput{Account: acc, BundleID: bundleID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
app = lookupResult.App
|
||||
}
|
||||
|
||||
out, err := dependencies.AppStore.ListVersions(appstore.ListVersionsInput{Account: acc, App: app})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dependencies.Logger.Log().
|
||||
Interface("externalVersionIdentifiers", out.ExternalVersionIdentifiers).
|
||||
Str("bundleID", app.BundleID).
|
||||
Bool("success", true).
|
||||
Send()
|
||||
|
||||
return nil
|
||||
},
|
||||
retry.LastErrorOnly(true),
|
||||
retry.DelayType(retry.FixedDelay),
|
||||
retry.Delay(time.Millisecond),
|
||||
retry.Attempts(2),
|
||||
retry.RetryIf(func(err error) bool {
|
||||
lastErr = err
|
||||
|
||||
return errors.Is(err, appstore.ErrPasswordTokenExpired)
|
||||
}),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Int64VarP(&appID, "app-id", "i", 0, "ID of the target iOS app (required)")
|
||||
cmd.Flags().StringVarP(&bundleID, "bundle-identifier", "b", "", "The bundle identifier of the target iOS app (overrides the app ID)")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -45,6 +45,8 @@ func rootCmd() *cobra.Command {
|
||||
cmd.AddCommand(downloadCmd())
|
||||
cmd.AddCommand(purchaseCmd())
|
||||
cmd.AddCommand(searchCmd())
|
||||
cmd.AddCommand(ListVersionsCmd())
|
||||
cmd.AddCommand(getVersionMetadataCmd())
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
module github.com/majd/ipatool/v2
|
||||
|
||||
go 1.19
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.23.2
|
||||
|
||||
require (
|
||||
github.com/99designs/keyring v1.2.1
|
||||
github.com/avast/retry-go v3.0.0+incompatible
|
||||
github.com/golang/mock v1.7.0-rc.1
|
||||
github.com/juju/persistent-cookiejar v1.0.0
|
||||
github.com/onsi/ginkgo/v2 v2.5.0
|
||||
github.com/onsi/gomega v1.24.0
|
||||
@@ -13,19 +14,19 @@ require (
|
||||
github.com/schollz/progressbar/v3 v3.13.1
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/thediveo/enumflag/v2 v2.0.1
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
|
||||
golang.org/x/net v0.8.0
|
||||
golang.org/x/term v0.6.0
|
||||
go.uber.org/mock v0.4.0
|
||||
golang.org/x/net v0.38.0
|
||||
golang.org/x/term v0.30.0
|
||||
howett.net/plist v1.0.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/juju/go4 v0.0.0-20160222163258-40d72ab9641a // indirect
|
||||
@@ -37,10 +38,11 @@ require (
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
golang.org/x/mod v0.8.0 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.8.0 // indirect
|
||||
golang.org/x/tools v0.6.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||
gopkg.in/errgo.v1 v1.0.1 // indirect
|
||||
gopkg.in/retry.v1 v1.0.3 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@@ -11,8 +11,8 @@ github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnG
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM=
|
||||
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY=
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
|
||||
github.com/frankban/quicktest v1.2.2 h1:xfmOhhoH5fGPgbEAlhLpJH9p0z/0Qizio9osmvn9IUY=
|
||||
github.com/frankban/quicktest v1.2.2/go.mod h1:Qh/WofXFeiAFII1aEBu529AtJo6Zg2VHscnEsbBnJ20=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
@@ -20,12 +20,10 @@ github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV
|
||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0=
|
||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U=
|
||||
github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
|
||||
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
|
||||
@@ -86,48 +84,29 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/thediveo/enumflag/v2 v2.0.1 h1:2bmWZPD2uSARDsOjXIdLRlNcYBFNF9xX0RNUNF2vKic=
|
||||
github.com/thediveo/enumflag/v2 v2.0.1/go.mod h1:SyxyCNvv0QeRtZ7fjuaUz4FRLC3cWuDiD7QdORU0MGg=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
|
||||
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
|
||||
|
||||
@@ -12,6 +12,19 @@ type App struct {
|
||||
Price float64 `json:"price,omitempty"`
|
||||
}
|
||||
|
||||
type VersionHistoryInfo struct {
|
||||
App App
|
||||
LatestVersion string
|
||||
VersionIdentifiers []string
|
||||
}
|
||||
|
||||
type VersionDetails struct {
|
||||
VersionID string
|
||||
VersionString string
|
||||
Success bool
|
||||
Error string
|
||||
}
|
||||
|
||||
type Apps []App
|
||||
|
||||
func (apps Apps) MarshalZerologArray(a *zerolog.Array) {
|
||||
|
||||
@@ -74,6 +74,6 @@ var _ = Describe("App", func() {
|
||||
Price: 0,
|
||||
}
|
||||
|
||||
Expect(fileName(app)).To(Equal("app.bundle-id1_42_1.0.ipa"))
|
||||
Expect(fileName(app, "1.0")).To(Equal("app.bundle-id1_42_1.0.ipa"))
|
||||
})
|
||||
})
|
||||
@@ -25,6 +25,10 @@ type AppStore interface {
|
||||
Download(input DownloadInput) (DownloadOutput, error)
|
||||
// ReplicateSinf replicates the sinf for the IPA package.
|
||||
ReplicateSinf(input ReplicateSinfInput) error
|
||||
// VersionHistory lists the available versions of the specified app.
|
||||
ListVersions(input ListVersionsInput) (ListVersionsOutput, error)
|
||||
// GetVersionMetadata returns the metadata for the specified version.
|
||||
GetVersionMetadata(input GetVersionMetadataInput) (GetVersionMetadataOutput, error)
|
||||
}
|
||||
|
||||
type appstore struct {
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/keychain"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (AccountInfo)", func() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
@@ -18,10 +19,11 @@ var (
|
||||
)
|
||||
|
||||
type DownloadInput struct {
|
||||
Account Account
|
||||
App App
|
||||
OutputPath string
|
||||
Progress *progressbar.ProgressBar
|
||||
Account Account
|
||||
App App
|
||||
OutputPath string
|
||||
Progress *progressbar.ProgressBar
|
||||
ExternalVersionID string
|
||||
}
|
||||
|
||||
type DownloadOutput struct {
|
||||
@@ -30,11 +32,6 @@ type DownloadOutput struct {
|
||||
}
|
||||
|
||||
func (t *appstore) Download(input DownloadInput) (DownloadOutput, error) {
|
||||
destination, err := t.resolveDestinationPath(input.App, input.OutputPath)
|
||||
if err != nil {
|
||||
return DownloadOutput{}, fmt.Errorf("failed to resolve destination path: %w", err)
|
||||
}
|
||||
|
||||
macAddr, err := t.machine.MacAddress()
|
||||
if err != nil {
|
||||
return DownloadOutput{}, fmt.Errorf("failed to get mac address: %w", err)
|
||||
@@ -42,7 +39,7 @@ func (t *appstore) Download(input DownloadInput) (DownloadOutput, error) {
|
||||
|
||||
guid := strings.ReplaceAll(strings.ToUpper(macAddr), ":", "")
|
||||
|
||||
req := t.downloadRequest(input.Account, input.App, guid)
|
||||
req := t.downloadRequest(input.Account, input.App, guid, input.ExternalVersionID)
|
||||
|
||||
res, err := t.downloadClient.Send(req)
|
||||
if err != nil {
|
||||
@@ -71,6 +68,18 @@ func (t *appstore) Download(input DownloadInput) (DownloadOutput, error) {
|
||||
|
||||
item := res.Data.Items[0]
|
||||
|
||||
version := "unknown"
|
||||
|
||||
// Read the version from the item metadata
|
||||
if itemVersion, ok := item.Metadata["bundleShortVersionString"]; ok {
|
||||
version = fmt.Sprintf("%v", itemVersion)
|
||||
}
|
||||
|
||||
destination, err := t.resolveDestinationPath(input.App, version, input.OutputPath)
|
||||
if err != nil {
|
||||
return DownloadOutput{}, fmt.Errorf("failed to resolve destination path: %w", err)
|
||||
}
|
||||
|
||||
err = t.downloadFile(item.URL, fmt.Sprintf("%s.tmp", destination), input.Progress)
|
||||
if err != nil {
|
||||
return DownloadOutput{}, fmt.Errorf("failed to download file: %w", err)
|
||||
@@ -138,9 +147,19 @@ func (t *appstore) downloadFile(src, dst string, progress *progressbar.ProgressB
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*appstore) downloadRequest(acc Account, app App, guid string) http.Request {
|
||||
func (*appstore) downloadRequest(acc Account, app App, guid string, externalVersionID string) http.Request {
|
||||
host := fmt.Sprintf("%s-%s", PrivateAppStoreAPIDomainPrefixWithoutAuthCode, PrivateAppStoreAPIDomain)
|
||||
|
||||
payload := map[string]interface{}{
|
||||
"creditDisplay": "",
|
||||
"guid": guid,
|
||||
"salableAdamId": app.ID,
|
||||
}
|
||||
|
||||
if externalVersionID != "" {
|
||||
payload["externalVersionId"] = externalVersionID
|
||||
}
|
||||
|
||||
return http.Request{
|
||||
URL: fmt.Sprintf("https://%s%s?guid=%s", host, PrivateAppStoreAPIPathDownload, guid),
|
||||
Method: http.MethodPOST,
|
||||
@@ -151,24 +170,31 @@ func (*appstore) downloadRequest(acc Account, app App, guid string) http.Request
|
||||
"X-Dsid": acc.DirectoryServicesID,
|
||||
},
|
||||
Payload: &http.XMLPayload{
|
||||
Content: map[string]interface{}{
|
||||
"creditDisplay": "",
|
||||
"guid": guid,
|
||||
"salableAdamId": app.ID,
|
||||
},
|
||||
Content: payload,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func fileName(app App) string {
|
||||
return fmt.Sprintf("%s_%d_%s.ipa",
|
||||
app.BundleID,
|
||||
app.ID,
|
||||
app.Version)
|
||||
func fileName(app App, version string) string {
|
||||
var parts []string
|
||||
|
||||
if app.BundleID != "" {
|
||||
parts = append(parts, app.BundleID)
|
||||
}
|
||||
|
||||
if app.ID != 0 {
|
||||
parts = append(parts, strconv.FormatInt(app.ID, 10))
|
||||
}
|
||||
|
||||
if version != "" {
|
||||
parts = append(parts, version)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s.ipa", strings.Join(parts, "_"))
|
||||
}
|
||||
|
||||
func (t *appstore) resolveDestinationPath(app App, path string) (string, error) {
|
||||
file := fileName(app)
|
||||
func (t *appstore) resolveDestinationPath(app App, version string, path string) (string, error) {
|
||||
file := fileName(app, version)
|
||||
|
||||
if path == "" {
|
||||
workdir, err := t.os.Getwd()
|
||||
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
"github.com/majd/ipatool/v2/pkg/keychain"
|
||||
"github.com/majd/ipatool/v2/pkg/util/machine"
|
||||
"github.com/majd/ipatool/v2/pkg/util/operatingsystem"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
"howett.net/plist"
|
||||
)
|
||||
|
||||
@@ -56,27 +56,8 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
ctrl.Finish()
|
||||
})
|
||||
|
||||
When("fails to resolve output path", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
Stat(gomock.Any()).
|
||||
Return(nil, errors.New(""))
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.Download(DownloadInput{
|
||||
OutputPath: "test-out",
|
||||
})
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
When("fails to read MAC address", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
Getwd().
|
||||
Return("", nil)
|
||||
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", errors.New(""))
|
||||
@@ -90,10 +71,6 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
|
||||
When("request fails", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
Getwd().
|
||||
Return("", nil)
|
||||
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", nil)
|
||||
@@ -111,10 +88,6 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
|
||||
When("password token is expired", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
Getwd().
|
||||
Return("", nil)
|
||||
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", nil)
|
||||
@@ -136,10 +109,6 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
|
||||
When("license is missing", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
Getwd().
|
||||
Return("", nil)
|
||||
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", nil)
|
||||
@@ -161,10 +130,6 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
|
||||
When("store API returns error", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
Getwd().
|
||||
Return("", nil)
|
||||
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", nil)
|
||||
@@ -208,10 +173,6 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
|
||||
When("store API returns no items", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
Getwd().
|
||||
Return("", nil)
|
||||
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", nil)
|
||||
@@ -231,6 +192,33 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
})
|
||||
})
|
||||
|
||||
When("fails to resolve output path", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{{}},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
mockOS.EXPECT().
|
||||
Stat(gomock.Any()).
|
||||
Return(nil, errors.New(""))
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.Download(DownloadInput{
|
||||
OutputPath: "test-out",
|
||||
})
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
When("fails to download file", func() {
|
||||
BeforeEach(func() {
|
||||
mockOS.EXPECT().
|
||||
@@ -345,7 +333,9 @@ var _ = Describe("AppStore (Download)", func() {
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{
|
||||
{
|
||||
Metadata: map[string]interface{}{},
|
||||
Metadata: map[string]interface{}{
|
||||
"bundleShortVersionString": "xyz",
|
||||
},
|
||||
Sinfs: []Sinf{
|
||||
{
|
||||
ID: 0,
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package appstore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
)
|
||||
|
||||
type GetVersionMetadataInput struct {
|
||||
Account Account
|
||||
App App
|
||||
VersionID string
|
||||
}
|
||||
|
||||
type GetVersionMetadataOutput struct {
|
||||
DisplayVersion string
|
||||
ReleaseDate time.Time
|
||||
}
|
||||
|
||||
func (t *appstore) GetVersionMetadata(input GetVersionMetadataInput) (GetVersionMetadataOutput, error) {
|
||||
macAddr, err := t.machine.MacAddress()
|
||||
if err != nil {
|
||||
return GetVersionMetadataOutput{}, fmt.Errorf("failed to get mac address: %w", err)
|
||||
}
|
||||
|
||||
guid := strings.ReplaceAll(strings.ToUpper(macAddr), ":", "")
|
||||
|
||||
req := t.getVersionMetadataRequest(input.Account, input.App, guid, input.VersionID)
|
||||
res, err := t.downloadClient.Send(req)
|
||||
|
||||
if err != nil {
|
||||
return GetVersionMetadataOutput{}, fmt.Errorf("failed to send http request: %w", err)
|
||||
}
|
||||
|
||||
if res.Data.FailureType == FailureTypePasswordTokenExpired {
|
||||
return GetVersionMetadataOutput{}, ErrPasswordTokenExpired
|
||||
}
|
||||
|
||||
if res.Data.FailureType == FailureTypeLicenseNotFound {
|
||||
return GetVersionMetadataOutput{}, ErrLicenseRequired
|
||||
}
|
||||
|
||||
if res.Data.FailureType != "" && res.Data.CustomerMessage != "" {
|
||||
return GetVersionMetadataOutput{}, NewErrorWithMetadata(fmt.Errorf("received error: %s", res.Data.CustomerMessage), res)
|
||||
}
|
||||
|
||||
if res.Data.FailureType != "" {
|
||||
return GetVersionMetadataOutput{}, NewErrorWithMetadata(fmt.Errorf("received error: %s", res.Data.FailureType), res)
|
||||
}
|
||||
|
||||
if len(res.Data.Items) == 0 {
|
||||
return GetVersionMetadataOutput{}, NewErrorWithMetadata(errors.New("invalid response"), res)
|
||||
}
|
||||
|
||||
item := res.Data.Items[0]
|
||||
|
||||
releaseDate, err := time.Parse(time.RFC3339, fmt.Sprintf("%v", item.Metadata["releaseDate"]))
|
||||
if err != nil {
|
||||
return GetVersionMetadataOutput{}, fmt.Errorf("failed to parse release date: %w", err)
|
||||
}
|
||||
|
||||
return GetVersionMetadataOutput{
|
||||
DisplayVersion: fmt.Sprintf("%v", item.Metadata["bundleShortVersionString"]),
|
||||
ReleaseDate: releaseDate,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (t *appstore) getVersionMetadataRequest(acc Account, app App, guid string, version string) http.Request {
|
||||
host := fmt.Sprintf("%s-%s", PrivateAppStoreAPIDomainPrefixWithoutAuthCode, PrivateAppStoreAPIDomain)
|
||||
|
||||
payload := map[string]interface{}{
|
||||
"creditDisplay": "",
|
||||
"guid": guid,
|
||||
"salableAdamId": app.ID,
|
||||
"externalVersionId": version,
|
||||
}
|
||||
|
||||
return http.Request{
|
||||
URL: fmt.Sprintf("https://%s%s?guid=%s", host, PrivateAppStoreAPIPathDownload, guid),
|
||||
Method: http.MethodPOST,
|
||||
ResponseFormat: http.ResponseFormatXML,
|
||||
Headers: map[string]string{
|
||||
"Content-Type": "application/x-apple-plist",
|
||||
"iCloud-DSID": acc.DirectoryServicesID,
|
||||
"X-Dsid": acc.DirectoryServicesID,
|
||||
},
|
||||
Payload: &http.XMLPayload{
|
||||
Content: payload,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package appstore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
"github.com/majd/ipatool/v2/pkg/util/machine"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (GetVersionMetadata)", func() {
|
||||
var (
|
||||
ctrl *gomock.Controller
|
||||
mockMachine *machine.MockMachine
|
||||
mockDownloadClient *http.MockClient[downloadResult]
|
||||
as AppStore
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
ctrl = gomock.NewController(GinkgoT())
|
||||
mockMachine = machine.NewMockMachine(ctrl)
|
||||
mockDownloadClient = http.NewMockClient[downloadResult](ctrl)
|
||||
as = &appstore{
|
||||
machine: mockMachine,
|
||||
downloadClient: mockDownloadClient,
|
||||
}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
ctrl.Finish()
|
||||
})
|
||||
|
||||
When("fails to get MAC address", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", errors.New("mac error"))
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("failed to get mac address"))
|
||||
})
|
||||
})
|
||||
|
||||
When("request fails", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:11:22:33:44:55", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{}, errors.New("request error"))
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("failed to send http request"))
|
||||
})
|
||||
})
|
||||
|
||||
When("password token is expired", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:11:22:33:44:55", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: FailureTypePasswordTokenExpired,
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(Equal(ErrPasswordTokenExpired))
|
||||
})
|
||||
})
|
||||
|
||||
When("license is missing", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:11:22:33:44:55", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: FailureTypeLicenseNotFound,
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(Equal(ErrLicenseRequired))
|
||||
})
|
||||
})
|
||||
|
||||
When("store API returns error", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:11:22:33:44:55", nil)
|
||||
})
|
||||
|
||||
When("response contains customer message", func() {
|
||||
BeforeEach(func() {
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: "SOME_ERROR",
|
||||
CustomerMessage: "Customer error message",
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns customer message as error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("Customer error message"))
|
||||
})
|
||||
})
|
||||
|
||||
When("response does not contain customer message", func() {
|
||||
BeforeEach(func() {
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: "SOME_ERROR",
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns generic error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("SOME_ERROR"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
When("store API returns no items", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:11:22:33:44:55", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{},
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("invalid response"))
|
||||
})
|
||||
})
|
||||
|
||||
When("fails to parse release date", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:11:22:33:44:55", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{
|
||||
{
|
||||
Metadata: map[string]interface{}{
|
||||
"releaseDate": "invalid-date",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.GetVersionMetadata(GetVersionMetadataInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("failed to parse release date"))
|
||||
})
|
||||
})
|
||||
|
||||
When("successfully gets version metadata", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:11:22:33:44:55", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{
|
||||
{
|
||||
Metadata: map[string]interface{}{
|
||||
"releaseDate": "2024-03-20T12:00:00Z",
|
||||
"bundleShortVersionString": "1.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns version metadata", func() {
|
||||
output, err := as.GetVersionMetadata(GetVersionMetadataInput{
|
||||
Account: Account{
|
||||
DirectoryServicesID: "test-dsid",
|
||||
},
|
||||
App: App{
|
||||
ID: 1234567890,
|
||||
},
|
||||
VersionID: "test-version",
|
||||
})
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(output.DisplayVersion).To(Equal("1.0.0"))
|
||||
Expect(output.ReleaseDate).To(Equal(time.Date(2024, 3, 20, 12, 0, 0, 0, time.UTC)))
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,101 @@
|
||||
package appstore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
)
|
||||
|
||||
type ListVersionsInput struct {
|
||||
Account Account
|
||||
App App
|
||||
}
|
||||
|
||||
type ListVersionsOutput struct {
|
||||
ExternalVersionIdentifiers []string
|
||||
LatestExternalVersionID string
|
||||
}
|
||||
|
||||
func (t *appstore) ListVersions(input ListVersionsInput) (ListVersionsOutput, error) {
|
||||
macAddr, err := t.machine.MacAddress()
|
||||
if err != nil {
|
||||
return ListVersionsOutput{}, fmt.Errorf("failed to get mac address: %w", err)
|
||||
}
|
||||
|
||||
guid := strings.ReplaceAll(strings.ToUpper(macAddr), ":", "")
|
||||
|
||||
req := t.listVersionsRequest(input.Account, input.App, guid)
|
||||
res, err := t.downloadClient.Send(req)
|
||||
|
||||
if err != nil {
|
||||
return ListVersionsOutput{}, fmt.Errorf("failed to send http request: %w", err)
|
||||
}
|
||||
|
||||
if res.Data.FailureType == FailureTypePasswordTokenExpired {
|
||||
return ListVersionsOutput{}, ErrPasswordTokenExpired
|
||||
}
|
||||
|
||||
if res.Data.FailureType == FailureTypeLicenseNotFound {
|
||||
return ListVersionsOutput{}, ErrLicenseRequired
|
||||
}
|
||||
|
||||
if res.Data.FailureType != "" && res.Data.CustomerMessage != "" {
|
||||
return ListVersionsOutput{}, NewErrorWithMetadata(fmt.Errorf("received error: %s", res.Data.CustomerMessage), res)
|
||||
}
|
||||
|
||||
if res.Data.FailureType != "" {
|
||||
return ListVersionsOutput{}, NewErrorWithMetadata(fmt.Errorf("received error: %s", res.Data.FailureType), res)
|
||||
}
|
||||
|
||||
if len(res.Data.Items) == 0 {
|
||||
return ListVersionsOutput{}, NewErrorWithMetadata(errors.New("invalid response"), res)
|
||||
}
|
||||
|
||||
item := res.Data.Items[0]
|
||||
|
||||
rawIdentifiers, ok := item.Metadata["softwareVersionExternalIdentifiers"].([]interface{})
|
||||
if !ok {
|
||||
return ListVersionsOutput{}, NewErrorWithMetadata(fmt.Errorf("failed to get version identifiers from item metadata"), item.Metadata)
|
||||
}
|
||||
|
||||
externalVersionIdentifiers := make([]string, len(rawIdentifiers))
|
||||
for i, val := range rawIdentifiers {
|
||||
externalVersionIdentifiers[i] = fmt.Sprintf("%v", val)
|
||||
}
|
||||
|
||||
latestExternalVersionID := item.Metadata["softwareVersionExternalIdentifier"]
|
||||
if latestExternalVersionID == nil {
|
||||
return ListVersionsOutput{}, NewErrorWithMetadata(fmt.Errorf("failed to get latest version from item metadata"), item.Metadata)
|
||||
}
|
||||
|
||||
return ListVersionsOutput{
|
||||
ExternalVersionIdentifiers: externalVersionIdentifiers,
|
||||
LatestExternalVersionID: fmt.Sprintf("%v", latestExternalVersionID),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (t *appstore) listVersionsRequest(acc Account, app App, guid string) http.Request {
|
||||
host := fmt.Sprintf("%s-%s", PrivateAppStoreAPIDomainPrefixWithoutAuthCode, PrivateAppStoreAPIDomain)
|
||||
|
||||
payload := map[string]interface{}{
|
||||
"creditDisplay": "",
|
||||
"guid": guid,
|
||||
"salableAdamId": app.ID,
|
||||
}
|
||||
|
||||
return http.Request{
|
||||
URL: fmt.Sprintf("https://%s%s?guid=%s", host, PrivateAppStoreAPIPathDownload, guid),
|
||||
Method: http.MethodPOST,
|
||||
ResponseFormat: http.ResponseFormatXML,
|
||||
Headers: map[string]string{
|
||||
"Content-Type": "application/x-apple-plist",
|
||||
"iCloud-DSID": acc.DirectoryServicesID,
|
||||
"X-Dsid": acc.DirectoryServicesID,
|
||||
},
|
||||
Payload: &http.XMLPayload{
|
||||
Content: payload,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
package appstore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
"github.com/majd/ipatool/v2/pkg/util/machine"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (ListVersions)", func() {
|
||||
var (
|
||||
ctrl *gomock.Controller
|
||||
mockDownloadClient *http.MockClient[downloadResult]
|
||||
mockMachine *machine.MockMachine
|
||||
as AppStore
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
ctrl = gomock.NewController(GinkgoT())
|
||||
mockDownloadClient = http.NewMockClient[downloadResult](ctrl)
|
||||
mockMachine = machine.NewMockMachine(ctrl)
|
||||
as = &appstore{
|
||||
downloadClient: mockDownloadClient,
|
||||
machine: mockMachine,
|
||||
}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
ctrl.Finish()
|
||||
})
|
||||
|
||||
When("fails to get MAC address", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("", errors.New(""))
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
When("request fails", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{}, errors.New(""))
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
When("password token is expired", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: FailureTypePasswordTokenExpired,
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
When("license is required", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: FailureTypeLicenseNotFound,
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
When("store API returns error with customer message", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: "test-failure",
|
||||
CustomerMessage: "test error message",
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error with customer message", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("test error message"))
|
||||
})
|
||||
})
|
||||
|
||||
When("store API returns error without customer message", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
FailureType: "test-failure",
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error with failure type", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("test-failure"))
|
||||
})
|
||||
})
|
||||
|
||||
When("store API returns no items", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{},
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
When("version identifiers not found in metadata", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{
|
||||
{
|
||||
Metadata: map[string]interface{}{
|
||||
"someOtherKey": "someValue",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("failed to get version identifiers from item metadata"))
|
||||
})
|
||||
})
|
||||
|
||||
When("latest version not found in metadata", func() {
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{
|
||||
{
|
||||
Metadata: map[string]interface{}{
|
||||
"softwareVersionExternalIdentifiers": []interface{}{"12345678", "87654321"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
_, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("failed to get latest version from item metadata"))
|
||||
})
|
||||
})
|
||||
|
||||
When("successfully lists versions", func() {
|
||||
const (
|
||||
testVersion1 = "12345678"
|
||||
testVersion2 = "87654321"
|
||||
testLatest = "87654321"
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockDownloadClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[downloadResult]{
|
||||
Data: downloadResult{
|
||||
Items: []downloadItemResult{
|
||||
{
|
||||
Metadata: map[string]interface{}{
|
||||
"softwareVersionExternalIdentifiers": []interface{}{testVersion1, testVersion2},
|
||||
"softwareVersionExternalIdentifier": testLatest,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns versions", func() {
|
||||
out, err := as.ListVersions(ListVersionsInput{})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(out.ExternalVersionIdentifiers).To(Equal([]string{testVersion1, testVersion2}))
|
||||
Expect(out.LatestExternalVersionID).To(Equal(testLatest))
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -4,9 +4,12 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
gohttp "net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
"github.com/majd/ipatool/v2/pkg/util"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -31,7 +34,7 @@ func (t *appstore) Login(input LoginInput) (LoginOutput, error) {
|
||||
|
||||
guid := strings.ReplaceAll(strings.ToUpper(macAddr), ":", "")
|
||||
|
||||
acc, err := t.login(input.Email, input.Password, input.AuthCode, guid, 0)
|
||||
acc, err := t.login(input.Email, input.Password, input.AuthCode, guid)
|
||||
if err != nil {
|
||||
return LoginOutput{}, err
|
||||
}
|
||||
@@ -59,28 +62,37 @@ type loginResult struct {
|
||||
PasswordToken string `plist:"passwordToken,omitempty"`
|
||||
}
|
||||
|
||||
func (t *appstore) login(email, password, authCode, guid string, attempt int) (Account, error) {
|
||||
request := t.loginRequest(email, password, authCode, guid)
|
||||
res, err := t.loginClient.Send(request)
|
||||
func (t *appstore) login(email, password, authCode, guid string) (Account, error) {
|
||||
redirect := ""
|
||||
|
||||
var (
|
||||
err error
|
||||
res http.Result[loginResult]
|
||||
)
|
||||
|
||||
retry := true
|
||||
|
||||
for attempt := 1; retry && attempt <= 4; attempt++ {
|
||||
request := t.loginRequest(email, password, authCode, guid, attempt)
|
||||
request.URL, _ = util.IfEmpty(redirect, request.URL), ""
|
||||
res, err = t.loginClient.Send(request)
|
||||
|
||||
if err != nil {
|
||||
return Account{}, fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
|
||||
if retry, redirect, err = t.parseLoginResponse(&res, attempt, authCode); err != nil {
|
||||
return Account{}, err
|
||||
}
|
||||
}
|
||||
|
||||
if retry {
|
||||
return Account{}, NewErrorWithMetadata(errors.New("too many attempts"), res)
|
||||
}
|
||||
|
||||
sf, err := res.GetHeader(HTTPHeaderStoreFront)
|
||||
if err != nil {
|
||||
return Account{}, fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
|
||||
if attempt == 0 && res.Data.FailureType == FailureTypeInvalidCredentials {
|
||||
return t.login(email, password, authCode, guid, 1)
|
||||
}
|
||||
|
||||
if res.Data.FailureType != "" && res.Data.CustomerMessage != "" {
|
||||
return Account{}, NewErrorWithMetadata(errors.New(res.Data.CustomerMessage), res)
|
||||
}
|
||||
|
||||
if res.Data.FailureType != "" {
|
||||
return Account{}, NewErrorWithMetadata(errors.New("something went wrong"), res)
|
||||
}
|
||||
|
||||
if res.Data.FailureType == "" && authCode == "" && res.Data.CustomerMessage == CustomerMessageBadLogin {
|
||||
return Account{}, ErrAuthCodeRequired
|
||||
return Account{}, NewErrorWithMetadata(fmt.Errorf("failed to get storefront header: %w", err), res)
|
||||
}
|
||||
|
||||
addr := res.Data.Account.Address
|
||||
@@ -89,7 +101,7 @@ func (t *appstore) login(email, password, authCode, guid string, attempt int) (A
|
||||
Email: res.Data.Account.Email,
|
||||
PasswordToken: res.Data.PasswordToken,
|
||||
DirectoryServicesID: res.Data.DirectoryServicesID,
|
||||
StoreFront: res.Headers[HTTPHeaderStoreFront],
|
||||
StoreFront: sf,
|
||||
Password: password,
|
||||
}
|
||||
|
||||
@@ -106,39 +118,55 @@ func (t *appstore) login(email, password, authCode, guid string, attempt int) (A
|
||||
return acc, nil
|
||||
}
|
||||
|
||||
func (t *appstore) loginRequest(email, password, authCode, guid string) http.Request {
|
||||
attempt := "4"
|
||||
if authCode != "" {
|
||||
attempt = "2"
|
||||
func (t *appstore) parseLoginResponse(res *http.Result[loginResult], attempt int, authCode string) (bool, string, error) {
|
||||
var (
|
||||
retry bool
|
||||
redirect string
|
||||
err error
|
||||
)
|
||||
|
||||
if res.StatusCode == gohttp.StatusFound {
|
||||
if redirect, err = res.GetHeader("location"); err != nil {
|
||||
err = fmt.Errorf("failed to retrieve redirect location: %w", err)
|
||||
} else {
|
||||
retry = true
|
||||
}
|
||||
} else if attempt == 1 && res.Data.FailureType == FailureTypeInvalidCredentials {
|
||||
retry = true
|
||||
} else if res.Data.FailureType == "" && authCode == "" && res.Data.CustomerMessage == CustomerMessageBadLogin {
|
||||
err = ErrAuthCodeRequired
|
||||
} else if res.Data.FailureType == "" && res.Data.CustomerMessage == CustomerMessageAccountDisabled {
|
||||
err = NewErrorWithMetadata(errors.New("account is disabled"), res)
|
||||
} else if res.Data.FailureType != "" {
|
||||
if res.Data.CustomerMessage != "" {
|
||||
err = NewErrorWithMetadata(errors.New(res.Data.CustomerMessage), res)
|
||||
} else {
|
||||
err = NewErrorWithMetadata(errors.New("something went wrong"), res)
|
||||
}
|
||||
} else if res.StatusCode != gohttp.StatusOK || res.Data.PasswordToken == "" || res.Data.DirectoryServicesID == "" {
|
||||
err = NewErrorWithMetadata(errors.New("something went wrong"), res)
|
||||
}
|
||||
|
||||
return retry, redirect, err
|
||||
}
|
||||
|
||||
func (t *appstore) loginRequest(email, password, authCode, guid string, attempt int) http.Request {
|
||||
return http.Request{
|
||||
Method: http.MethodPOST,
|
||||
URL: t.authDomain(authCode, guid),
|
||||
URL: fmt.Sprintf("https://%s%s", PrivateAppStoreAPIDomain, PrivateAppStoreAPIPathAuthenticate),
|
||||
ResponseFormat: http.ResponseFormatXML,
|
||||
Headers: map[string]string{
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
Payload: &http.XMLPayload{
|
||||
Content: map[string]interface{}{
|
||||
"appleId": email,
|
||||
"attempt": attempt,
|
||||
"createSession": "true",
|
||||
"guid": guid,
|
||||
"password": fmt.Sprintf("%s%s", password, authCode),
|
||||
"rmp": "0",
|
||||
"why": "signIn",
|
||||
"appleId": email,
|
||||
"attempt": strconv.Itoa(attempt),
|
||||
"guid": guid,
|
||||
"password": fmt.Sprintf("%s%s", password, strings.ReplaceAll(authCode, " ", "")),
|
||||
"rmp": "0",
|
||||
"why": "signIn",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (*appstore) authDomain(authCode, guid string) string {
|
||||
prefix := PrivateAppStoreAPIDomainPrefixWithoutAuthCode
|
||||
if authCode != "" {
|
||||
prefix = PrivateAppStoreAPIDomainPrefixWithAuthCode
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"https://%s-%s%s?guid=%s", prefix, PrivateAppStoreAPIDomain, PrivateAppStoreAPIPathAuthenticate, guid)
|
||||
}
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
"github.com/majd/ipatool/v2/pkg/keychain"
|
||||
"github.com/majd/ipatool/v2/pkg/util/machine"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (Login)", func() {
|
||||
@@ -123,6 +123,26 @@ var _ = Describe("AppStore (Login)", func() {
|
||||
})
|
||||
})
|
||||
|
||||
When("store API indicates account is disabled", func() {
|
||||
BeforeEach(func() {
|
||||
mockClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[loginResult]{
|
||||
Data: loginResult{
|
||||
CustomerMessage: CustomerMessageAccountDisabled,
|
||||
},
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns account disabled error", func() {
|
||||
_, err := as.Login(LoginInput{
|
||||
Password: testPassword,
|
||||
})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("account is disabled"))
|
||||
})
|
||||
})
|
||||
|
||||
When("store API requires 2FA code", func() {
|
||||
BeforeEach(func() {
|
||||
mockClient.EXPECT().
|
||||
@@ -135,11 +155,66 @@ var _ = Describe("AppStore (Login)", func() {
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
It("returns ErrAuthCodeRequired error", func() {
|
||||
_, err := as.Login(LoginInput{
|
||||
Password: testPassword,
|
||||
})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(Equal(ErrAuthCodeRequired))
|
||||
})
|
||||
})
|
||||
|
||||
When("store API redirects", func() {
|
||||
const (
|
||||
testRedirectLocation = "https://" + PrivateAppStoreAPIDomain + PrivateAppStoreAPIPathAuthenticate + "?PRH=31&Pod=31"
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
firstCall := mockClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Do(func(req http.Request) {
|
||||
Expect(req.Payload).To(BeAssignableToTypeOf(&http.XMLPayload{}))
|
||||
x := req.Payload.(*http.XMLPayload)
|
||||
Expect(x.Content).To(HaveKeyWithValue("attempt", "1"))
|
||||
}).
|
||||
Return(http.Result[loginResult]{
|
||||
StatusCode: 302,
|
||||
Headers: map[string]string{"Location": testRedirectLocation},
|
||||
}, nil)
|
||||
secondCall := mockClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Do(func(req http.Request) {
|
||||
Expect(req.URL).To(Equal(testRedirectLocation))
|
||||
Expect(req.Payload).To(BeAssignableToTypeOf(&http.XMLPayload{}))
|
||||
x := req.Payload.(*http.XMLPayload)
|
||||
Expect(x.Content).To(HaveKeyWithValue("attempt", "2"))
|
||||
}).
|
||||
Return(http.Result[loginResult]{}, errors.New("test complete"))
|
||||
gomock.InOrder(firstCall, secondCall)
|
||||
})
|
||||
|
||||
It("follows the redirect and increments attempt", func() {
|
||||
_, err := as.Login(LoginInput{
|
||||
Password: testPassword,
|
||||
})
|
||||
Expect(err).To(MatchError("request failed: test complete"))
|
||||
})
|
||||
})
|
||||
|
||||
When("store API redirects too much", func() {
|
||||
BeforeEach(func() {
|
||||
mockClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[loginResult]{
|
||||
StatusCode: 302,
|
||||
Headers: map[string]string{"Location": "hello"},
|
||||
}, nil).
|
||||
Times(4)
|
||||
})
|
||||
It("bails out", func() {
|
||||
_, err := as.Login(LoginInput{
|
||||
Password: testPassword,
|
||||
})
|
||||
Expect(err).To(MatchError("too many attempts"))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -147,12 +222,15 @@ var _ = Describe("AppStore (Login)", func() {
|
||||
const (
|
||||
testPasswordToken = "test-password-token"
|
||||
testDirectoryServicesID = "directory-services-id"
|
||||
testStoreFront = "test-storefront"
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
mockClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[loginResult]{
|
||||
StatusCode: 200,
|
||||
Headers: map[string]string{HTTPHeaderStoreFront: testStoreFront},
|
||||
Data: loginResult{
|
||||
PasswordToken: testPasswordToken,
|
||||
DirectoryServicesID: testDirectoryServicesID,
|
||||
@@ -178,6 +256,7 @@ var _ = Describe("AppStore (Login)", func() {
|
||||
PasswordToken: testPasswordToken,
|
||||
Password: testPassword,
|
||||
DirectoryServicesID: testDirectoryServicesID,
|
||||
StoreFront: testStoreFront,
|
||||
}
|
||||
|
||||
var got Account
|
||||
@@ -196,7 +275,7 @@ var _ = Describe("AppStore (Login)", func() {
|
||||
})
|
||||
})
|
||||
|
||||
When("sucessfully saves account in keychain", func() {
|
||||
When("successfully saves account in keychain", func() {
|
||||
BeforeEach(func() {
|
||||
mockKeychain.EXPECT().
|
||||
Set("account", gomock.Any()).
|
||||
@@ -207,6 +286,7 @@ var _ = Describe("AppStore (Login)", func() {
|
||||
PasswordToken: testPasswordToken,
|
||||
Password: testPassword,
|
||||
DirectoryServicesID: testDirectoryServicesID,
|
||||
StoreFront: testStoreFront,
|
||||
}
|
||||
|
||||
var got Account
|
||||
|
||||
@@ -21,7 +21,7 @@ type LookupOutput struct {
|
||||
func (t *appstore) Lookup(input LookupInput) (LookupOutput, error) {
|
||||
countryCode, err := countryCodeFromStoreFront(input.Account.StoreFront)
|
||||
if err != nil {
|
||||
return LookupOutput{}, fmt.Errorf("failed to reoslve the country code: %w", err)
|
||||
return LookupOutput{}, fmt.Errorf("failed to resolve the country code: %w", err)
|
||||
}
|
||||
|
||||
request := t.lookupRequest(input.BundleID, countryCode)
|
||||
|
||||
@@ -3,10 +3,10 @@ package appstore
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (Lookup)", func() {
|
||||
|
||||
@@ -3,12 +3,12 @@ package appstore
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
"github.com/majd/ipatool/v2/pkg/keychain"
|
||||
"github.com/majd/ipatool/v2/pkg/util/machine"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (Purchase)", func() {
|
||||
|
||||
@@ -38,7 +38,6 @@ func (t *appstore) ReplicateSinf(input ReplicateSinfInput) error {
|
||||
}
|
||||
|
||||
zipWriter := zip.NewWriter(tmpFile)
|
||||
defer zipWriter.Close()
|
||||
|
||||
err = t.replicateZip(zipReader, zipWriter)
|
||||
if err != nil {
|
||||
@@ -71,6 +70,8 @@ func (t *appstore) ReplicateSinf(input ReplicateSinfInput) error {
|
||||
}
|
||||
|
||||
zipReader.Close()
|
||||
zipWriter.Close()
|
||||
tmpFile.Close()
|
||||
|
||||
err = t.os.Remove(input.PackagePath)
|
||||
if err != nil {
|
||||
|
||||
@@ -6,13 +6,13 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
"github.com/majd/ipatool/v2/pkg/keychain"
|
||||
"github.com/majd/ipatool/v2/pkg/util/machine"
|
||||
"github.com/majd/ipatool/v2/pkg/util/operatingsystem"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
"howett.net/plist"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package appstore
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/keychain"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (Revoke)", func() {
|
||||
|
||||
@@ -3,10 +3,10 @@ package appstore
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/http"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("AppStore (Search)", func() {
|
||||
|
||||
@@ -7,6 +7,7 @@ const (
|
||||
FailureTypeTemporarilyUnavailable = "2059"
|
||||
|
||||
CustomerMessageBadLogin = "MZFinance.BadLogin.Configurator_message"
|
||||
CustomerMessageAccountDisabled = "Your account is disabled."
|
||||
CustomerMessageSubscriptionRequired = "Subscription Required"
|
||||
|
||||
iTunesAPIDomain = "itunes.apple.com"
|
||||
@@ -17,7 +18,7 @@ const (
|
||||
PrivateAppStoreAPIDomainPrefixWithAuthCode = "p71"
|
||||
PrivateAppStoreAPIDomain = "buy." + iTunesAPIDomain
|
||||
PrivateAppStoreAPIPathAuthenticate = "/WebObjects/MZFinance.woa/wa/authenticate"
|
||||
PrivateAppStoreAPIPathPurchase = "/WebObjects/MZBuy.woa/wa/buyProduct"
|
||||
PrivateAppStoreAPIPathPurchase = "/WebObjects/MZFinance.woa/wa/buyProduct"
|
||||
PrivateAppStoreAPIPathDownload = "/WebObjects/MZFinance.woa/wa/volumeStoreDownloadProduct"
|
||||
|
||||
HTTPHeaderStoreFront = "X-Set-Apple-Store-Front"
|
||||
|
||||
+15
-3
@@ -11,7 +11,11 @@ import (
|
||||
"howett.net/plist"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=client.go -destination=client_mock.go -package=http
|
||||
const (
|
||||
appStoreAuthURL = "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate"
|
||||
)
|
||||
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=client.go -destination=client_mock.go -package=http
|
||||
type Client[R interface{}] interface {
|
||||
Send(request Request) (Result[R], error)
|
||||
Do(req *http.Request) (*http.Response, error)
|
||||
@@ -47,8 +51,15 @@ func (t *AddHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error
|
||||
func NewClient[R interface{}](args Args) Client[R] {
|
||||
return &client[R]{
|
||||
internalClient: http.Client{
|
||||
Timeout: 0,
|
||||
Jar: args.CookieJar,
|
||||
Timeout: 0,
|
||||
Jar: args.CookieJar,
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
if req.Referer() == appStoreAuthURL {
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
Transport: &AddHeaderTransport{http.DefaultTransport},
|
||||
},
|
||||
cookieJar: args.CookieJar,
|
||||
@@ -81,6 +92,7 @@ func (c *client[R]) Send(req Request) (Result[R], error) {
|
||||
if err != nil {
|
||||
return Result[R]{}, fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
err = c.cookieJar.Save()
|
||||
if err != nil {
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("Client", Ordered, func() {
|
||||
|
||||
@@ -8,5 +8,5 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultUserAgent = "Configurator/2.15 (Macintosh; OS X 11.0.0; 16G29) AppleWebKit/2603.3.8"
|
||||
DefaultUserAgent = "Configurator/2.17 (Macintosh; OS X 15.2; 24C5089c) AppleWebKit/0620.1.16.11.6"
|
||||
)
|
||||
@@ -2,7 +2,7 @@ package http
|
||||
|
||||
import "net/http"
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=cookiejar.go -destination=cookiejar_mock.go -package=http
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=cookiejar.go -destination=cookiejar_mock.go -package=http
|
||||
type CookieJar interface {
|
||||
http.CookieJar
|
||||
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrHeaderNotFound = errors.New("header not found")
|
||||
)
|
||||
|
||||
type Result[R interface{}] struct {
|
||||
StatusCode int
|
||||
Headers map[string]string
|
||||
Data R
|
||||
}
|
||||
|
||||
func (c *Result[R]) GetHeader(key string) (string, error) {
|
||||
key = strings.ToLower(key)
|
||||
for k, v := range c.Headers {
|
||||
if strings.ToLower(k) == key {
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", ErrHeaderNotFound
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package keychain
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=keychain.go -destination=keychain_mock.go -package keychain
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=keychain.go -destination=keychain_mock.go -package keychain
|
||||
type Keychain interface {
|
||||
Get(key string) ([]byte, error)
|
||||
Set(key string, data []byte) error
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/99designs/keyring"
|
||||
"github.com/golang/mock/gomock"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("Keychain (Get)", func() {
|
||||
|
||||
@@ -3,9 +3,9 @@ package keychain
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("Keychain (Remove)", func() {
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/99designs/keyring"
|
||||
"github.com/golang/mock/gomock"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("Keychain (Set)", func() {
|
||||
|
||||
@@ -2,7 +2,7 @@ package keychain
|
||||
|
||||
import "github.com/99designs/keyring"
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=keyring.go -destination=keyring_mock.go -package keychain
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=keyring.go -destination=keyring_mock.go -package keychain
|
||||
type Keyring interface {
|
||||
Get(key string) (keyring.Item, error)
|
||||
Set(item keyring.Item) error
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/rs/zerolog/pkgerrors"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=logger.go -destination=logger_mock.go -package log
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=logger.go -destination=logger_mock.go -package log
|
||||
type Logger interface {
|
||||
Verbose() *zerolog.Event
|
||||
Log() *zerolog.Event
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/rs/zerolog"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("Logger", func() {
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=writer.go -destination=writer_mock.go -package log
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=writer.go -destination=writer_mock.go -package log
|
||||
type Writer interface {
|
||||
Write(p []byte) (n int, err error)
|
||||
WriteLevel(level zerolog.Level, p []byte) (n int, err error)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/golang/mock/gomock"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/rs/zerolog"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var _ = Describe("Writer", func() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=machine.go -destination=machine_mock.go -package machine
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=machine.go -destination=machine_mock.go -package machine
|
||||
type Machine interface {
|
||||
MacAddress() (string, error)
|
||||
HomeDirectory() string
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/majd/ipatool/v2/pkg/util/operatingsystem"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
func TestMachine(t *testing.T) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -source=operatingsystem.go -destination=operatingsystem_mock.go -package operatingsystem
|
||||
//go:generate go run go.uber.org/mock/mockgen -source=operatingsystem.go -destination=operatingsystem_mock.go -package operatingsystem
|
||||
type OperatingSystem interface {
|
||||
Getenv(key string) string
|
||||
Stat(name string) (os.FileInfo, error)
|
||||
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 588 KiB |
Reference in new issue
Block a user