mirror of
https://github.com/majd/ipatool
synced 2026-11-28 02:07:52 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f3115d60f | ||
|
|
0e38e43d8b | ||
|
|
73e9bd90d1 | ||
|
|
e76dbf044e | ||
|
|
d82e819d4e | ||
|
|
19ac47d098 | ||
|
|
fece9ea79c | ||
|
|
1b31ee6556 | ||
|
|
fbd9d74729 | ||
|
|
8d2467491e | ||
|
|
4eba914bff |
No files matched your search
@@ -6,13 +6,12 @@ on:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
build_windows:
|
||||
name: Build for Windows
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ darwin, linux, windows ]
|
||||
arch: [ arm64, amd64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -21,9 +20,45 @@ jobs:
|
||||
go-version: '1.19.3'
|
||||
cache: true
|
||||
- run: ./tools/version.sh
|
||||
- run: go build -o ipatool-${{ matrix.os }}-${{ matrix.arch }}
|
||||
- run: go build -o ipatool-$GOOS-$GOARCH.exe
|
||||
env:
|
||||
GOOS: ${{ matrix.os }}
|
||||
GOOS: windows
|
||||
GOARCH: ${{ matrix.arch }}
|
||||
build_linux:
|
||||
name: Build for Linux
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
cache: true
|
||||
- run: ./tools/version.sh
|
||||
- run: go build -o ipatool-$GOOS-$GOARCH
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: ${{ matrix.arch }}
|
||||
build_macos:
|
||||
name: Build for macOS
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.3'
|
||||
cache: true
|
||||
- run: ./tools/version.sh
|
||||
- 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
|
||||
@@ -11,8 +11,6 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ darwin, linux, windows ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v3
|
||||
@@ -20,18 +18,17 @@ jobs:
|
||||
go-version: '1.19.3'
|
||||
cache: true
|
||||
- run: ./tools/version.sh
|
||||
- run: go build -o ipatool-${{ matrix.os }}
|
||||
- run: go build -o ipatool
|
||||
env:
|
||||
GOOS: ${{ matrix.os }}
|
||||
CGO_CFLAGS: -mmacosx-version-min=10.15
|
||||
CGO_LDFLAGS: -mmacosx-version-min=10.15
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ipatool-${{ matrix.os }}
|
||||
path: ipatool-${{ matrix.os }}
|
||||
name: ipatool
|
||||
path: ipatool
|
||||
if-no-files-found: error
|
||||
test_macos:
|
||||
name: Test (macOS)
|
||||
test:
|
||||
name: Test
|
||||
runs-on: macos-latest
|
||||
needs: [build]
|
||||
strategy:
|
||||
@@ -41,37 +38,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ipatool-darwin
|
||||
name: ipatool
|
||||
path: build
|
||||
- run: chmod +x ./build/ipatool-darwin
|
||||
- run: ./build/ipatool-darwin ${{ matrix.command }} --help
|
||||
test_linux:
|
||||
name: Test (Linux)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
command: [auth, download, purchase, search]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ipatool-linux
|
||||
path: build
|
||||
- run: chmod +x ./build/ipatool-linux
|
||||
- run: ./build/ipatool-linux ${{ matrix.command }} --help
|
||||
test_windows:
|
||||
name: Test (Windows)
|
||||
runs-on: windows-latest
|
||||
needs: [build]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
command: [auth, download, purchase, search]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ipatool-windows
|
||||
path: build
|
||||
- run: chmod +x ./build/ipatool-windows
|
||||
- run: ./build/ipatool-windows ${{ matrix.command }} --help
|
||||
- run: chmod +x ./build/ipatool
|
||||
- run: ./build/ipatool ${{ matrix.command }} --help
|
||||
@@ -36,11 +36,11 @@ jobs:
|
||||
go-version: '1.19.3'
|
||||
cache: true
|
||||
- run: ./tools/version.sh
|
||||
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-arm64
|
||||
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe
|
||||
env:
|
||||
GOOS: windows
|
||||
GOARCH: arm64
|
||||
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-amd64
|
||||
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe
|
||||
env:
|
||||
GOOS: windows
|
||||
GOARCH: amd64
|
||||
@@ -68,13 +68,13 @@ jobs:
|
||||
CGO_ENABLED: 1
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64
|
||||
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
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64
|
||||
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
|
||||
with:
|
||||
@@ -96,40 +96,68 @@ jobs:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
path: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
if-no-files-found: error
|
||||
release_windows_linux:
|
||||
name: Release (Windows & Linux)
|
||||
release_windows:
|
||||
name: Release for Windows
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_version, build]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ linux, windows ]
|
||||
arch: [ arm64, amd64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }}
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.exe
|
||||
path: bin
|
||||
- run: tar -czvf $BIN.tar.gz bin/$BIN
|
||||
- run: tar -czvf $FILE.tar.gz bin/$FILE.exe
|
||||
env:
|
||||
BIN: ipatool-${{ needs.get_version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }}
|
||||
FILE: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}
|
||||
- run: ./tools/sha256sum.sh $TARBALL > $TARBALL.sha256sum
|
||||
env:
|
||||
TARBALL: ipatool-${{ needs.get_version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
|
||||
TARBALL: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.tar.gz
|
||||
- uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: ipatool-${{ needs.get_version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }}.*
|
||||
file: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.*
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: false
|
||||
file_glob: true
|
||||
release_linux:
|
||||
name: Release for Linux
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_version, build, release_windows]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}
|
||||
path: bin
|
||||
- run: tar -czvf $FILE.tar.gz bin/$FILE
|
||||
env:
|
||||
FILE: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}
|
||||
- run: ./tools/sha256sum.sh $TARBALL > $TARBALL.sha256sum
|
||||
env:
|
||||
TARBALL: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}.tar.gz
|
||||
- uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}.*
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: false
|
||||
file_glob: true
|
||||
release_macos:
|
||||
name: Release (macOS)
|
||||
name: Release for macOS
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_version, build, release_windows_linux]
|
||||
needs: [get_version, build, release_windows, release_linux]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: ./ipatool
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
|
||||
@@ -141,13 +169,13 @@ jobs:
|
||||
with:
|
||||
name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
path: bin
|
||||
- run: tar -czvf $BIN.tar.gz bin/$BIN && rm -rf bin/
|
||||
- run: tar -czvf $FILE.tar.gz bin/$FILE && rm -rf bin/
|
||||
env:
|
||||
BIN: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
FILE: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
|
||||
- id: sha256
|
||||
run: |
|
||||
SHA256_ARM64=$(./tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz)
|
||||
SHA256_AMD64=$(./tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz)
|
||||
SHA256_ARM64=$(./ipatool/tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz)
|
||||
SHA256_AMD64=$(./ipatool/tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz)
|
||||
echo $SHA256_ARM64 > ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz.sha256sum
|
||||
echo $SHA256_AMD64 > ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz.sha256sum
|
||||
echo ::set-output name=sha256_arm64::$SHA256_ARM64
|
||||
@@ -159,24 +187,18 @@ jobs:
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: false
|
||||
file_glob: true
|
||||
outputs:
|
||||
sha256_arm64: ${{ steps.sha256.outputs.sha256_arm64 }}
|
||||
sha256_amd64: ${{ steps.sha256.outputs.sha256_amd64 }}
|
||||
update_cask:
|
||||
name: Update cask
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_version, release_macos]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ secrets.HOMEBREW_REPO }}
|
||||
ref: main
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
path: homebrew-repo
|
||||
- run: |
|
||||
sed -i "3s/.*/ sha256 \"${{ needs.release_macos.outputs.sha256_arm64 }}\"/" Casks/ipatool.rb
|
||||
cd homebrew-repo
|
||||
sed -i "3s/.*/ sha256 \"$SHA256_ARM64\"/" Casks/ipatool.rb
|
||||
sed -i "4s/.*/ url \"https:\/\/github.com\/majd\/ipatool\/releases\/download\/v${{ needs.get_version.outputs.version }}\/ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz\"/" Casks/ipatool.rb
|
||||
sed -i "5s/.*/ binary \"bin\/ipatool-${{ needs.get_version.outputs.version }}-macos-arm64\", target: \"ipatool\"/" Casks/ipatool.rb
|
||||
sed -i "7s/.*/ sha256 \"${{ needs.release_macos.outputs.sha256_amd64 }}\"/" Casks/ipatool.rb
|
||||
sed -i "7s/.*/ sha256 \"$SHA256_AMD64\"/" Casks/ipatool.rb
|
||||
sed -i "8s/.*/ url \"https:\/\/github.com\/majd\/ipatool\/releases\/download\/v${{ needs.get_version.outputs.version }}\/ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz\"/" Casks/ipatool.rb
|
||||
sed -i "9s/.*/ binary \"bin\/ipatool-${{ needs.get_version.outputs.version }}-macos-amd64\", target: \"ipatool\"/" Casks/ipatool.rb
|
||||
sed -i "12s/.*/ version \"${{ needs.get_version.outputs.version }}\"/" Casks/ipatool.rb
|
||||
@@ -184,4 +206,7 @@ jobs:
|
||||
git config --local user.email ${{ secrets.GH_EMAIL }}
|
||||
git add Casks/ipatool.rb
|
||||
git commit -m "Update ipatool to v${{ needs.get_version.outputs.version }}"
|
||||
git push "https://${{ secrets.GH_TOKEN }}@github.com/${{ secrets.HOMEBREW_REPO }}.git" --set-upstream "main"
|
||||
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 }}
|
||||
+18
-1
@@ -1,5 +1,22 @@
|
||||
## Changelog
|
||||
|
||||
### 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.
|
||||
@@ -8,7 +25,7 @@
|
||||
- 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 flag `--non-interactive` flag to disable running the tool in an interactive session.
|
||||
- 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`
|
||||
|
||||
@@ -129,7 +129,7 @@ The tool can be compiled using the Go toolchain.
|
||||
$ go build -o ipatool
|
||||
```
|
||||
|
||||
Unit tests can be executing with the following command.
|
||||
Unit tests can be executed with the following command.
|
||||
|
||||
```shell
|
||||
$ go test -v github.com/majd/ipatool/...
|
||||
|
||||
@@ -13,8 +13,8 @@ require (
|
||||
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.1.0
|
||||
golang.org/x/term v0.2.0
|
||||
golang.org/x/net v0.8.0
|
||||
golang.org/x/term v0.6.0
|
||||
howett.net/plist v1.0.0
|
||||
)
|
||||
|
||||
@@ -36,8 +36,8 @@ require (
|
||||
github.com/rivo/uniseg v0.4.3 // indirect
|
||||
github.com/schollz/progressbar/v3 v3.12.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
golang.org/x/sys v0.3.0 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.8.0 // 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
|
||||
|
||||
@@ -96,6 +96,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
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=
|
||||
@@ -113,14 +115,20 @@ golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||
golang.org/x/sys v0.3.0/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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
|
||||
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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
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.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package appstore
|
||||
|
||||
import "github.com/rs/zerolog"
|
||||
import (
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
ID int64 `json:"trackId,omitempty"`
|
||||
|
||||
@@ -63,4 +63,16 @@ var _ = Describe("App", func() {
|
||||
Expect(out["version"]).To(Equal("1.0"))
|
||||
Expect(out["price"]).To(Equal(float64(0)))
|
||||
})
|
||||
|
||||
It("formats ipa name correctly", func() {
|
||||
app := App{
|
||||
ID: 42,
|
||||
BundleID: "app.bundle-id1",
|
||||
Name: " some app&symb.ols2 !!!",
|
||||
Version: "1.0",
|
||||
Price: 0,
|
||||
}
|
||||
|
||||
Expect(fileName(app)).To(Equal("app.bundle-id1_42_1.0.ipa"))
|
||||
})
|
||||
})
|
||||
@@ -218,7 +218,6 @@ func (*appstore) downloadRequest(acc Account, app App, guid string) http.Request
|
||||
Method: http.MethodPOST,
|
||||
ResponseFormat: http.ResponseFormatXML,
|
||||
Headers: map[string]string{
|
||||
"User-Agent": "Configurator/2.15 (Macintosh; OperatingSystem X 11.0.0; 16G29) AppleWebKit/2603.3.8",
|
||||
"Content-Type": "application/x-apple-plist",
|
||||
"iCloud-DSID": acc.DirectoryServicesID,
|
||||
"X-Dsid": acc.DirectoryServicesID,
|
||||
@@ -233,8 +232,15 @@ func (*appstore) downloadRequest(acc Account, app App, guid string) http.Request
|
||||
}
|
||||
}
|
||||
|
||||
func fileName(app App) string {
|
||||
return fmt.Sprintf("%s_%d_%s.ipa",
|
||||
app.BundleID,
|
||||
app.ID,
|
||||
app.Version)
|
||||
}
|
||||
|
||||
func (a *appstore) resolveDestinationPath(app App, path string) (string, error) {
|
||||
file := fmt.Sprintf("/%s_%d_v%s_%d.ipa", app.BundleID, app.ID, app.Version, util.RandInt(100, 999))
|
||||
file := fileName(app)
|
||||
|
||||
if path == "" {
|
||||
workdir, err := a.os.Getwd()
|
||||
@@ -242,7 +248,7 @@ func (a *appstore) resolveDestinationPath(app App, path string) (string, error)
|
||||
return "", errors.Wrap(err, ErrGetCurrentDirectory.Error())
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s%s", workdir, file), nil
|
||||
return fmt.Sprintf("%s/%s", workdir, file), nil
|
||||
}
|
||||
|
||||
isDir, err := a.isDirectory(path)
|
||||
@@ -251,7 +257,7 @@ func (a *appstore) resolveDestinationPath(app App, path string) (string, error)
|
||||
}
|
||||
|
||||
if isDir {
|
||||
return fmt.Sprintf("%s%s", path, file), nil
|
||||
return fmt.Sprintf("%s/%s", path, file), nil
|
||||
}
|
||||
|
||||
return path, nil
|
||||
|
||||
@@ -147,7 +147,6 @@ func (a *appstore) loginRequest(email, password, authCode, guid string) http.Req
|
||||
URL: a.authDomain(authCode, guid),
|
||||
ResponseFormat: http.ResponseFormatXML,
|
||||
Headers: map[string]string{
|
||||
"User-Agent": "Configurator/2.15 (Macintosh; OperatingSystem X 11.0.0; 16G29) AppleWebKit/2603.3.8",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
Payload: &http.XMLPayload{
|
||||
|
||||
@@ -52,12 +52,37 @@ func (a *appstore) purchase(bundleID string, guid string, attemptToRenewCredenti
|
||||
return ErrPaidApp
|
||||
}
|
||||
|
||||
req := a.purchaseRequest(acc, app, acc.StoreFront, guid)
|
||||
err = a.purchaseWithParams(acc, app, bundleID, guid, attemptToRenewCredentials, PricingParameterAppStore)
|
||||
if err != nil {
|
||||
if err == ErrTemporarilyUnavailable {
|
||||
err = a.purchaseWithParams(acc, app, bundleID, guid, attemptToRenewCredentials, PricingParameterAppleArcade)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to purchase item with param '%s'", PricingParameterAppleArcade)
|
||||
}
|
||||
}
|
||||
|
||||
return errors.Wrapf(err, "failed to purchase item with param '%s'", PricingParameterAppStore)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *appstore) purchaseWithParams(acc Account, app App, bundleID string, guid string, attemptToRenewCredentials bool, pricingParameters string) error {
|
||||
req := a.purchaseRequest(acc, app, acc.StoreFront, guid, pricingParameters)
|
||||
res, err := a.purchaseClient.Send(req)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, ErrRequest.Error())
|
||||
}
|
||||
|
||||
if res.Data.FailureType == FailureTypeTemporarilyUnavailable {
|
||||
return ErrTemporarilyUnavailable
|
||||
}
|
||||
|
||||
if res.Data.CustomerMessage == CustomerMessageSubscriptionRequired {
|
||||
a.logger.Verbose().Interface("response", res).Send()
|
||||
return ErrSubscriptionRequired
|
||||
}
|
||||
|
||||
if res.Data.FailureType == FailureTypePasswordTokenExpired {
|
||||
if attemptToRenewCredentials {
|
||||
a.logger.Verbose().Msg("retrieving new password token")
|
||||
@@ -66,7 +91,7 @@ func (a *appstore) purchase(bundleID string, guid string, attemptToRenewCredenti
|
||||
return errors.Wrap(err, ErrPasswordTokenExpired.Error())
|
||||
}
|
||||
|
||||
return a.purchase(bundleID, guid, false)
|
||||
return a.purchaseWithParams(acc, app, bundleID, guid, false, pricingParameters)
|
||||
}
|
||||
|
||||
return ErrPasswordTokenExpired
|
||||
@@ -106,13 +131,12 @@ func (*appstore) countryCodeFromStoreFront(storeFront string) (string, error) {
|
||||
return "", errors.New(ErrInvalidStoreFront.Error())
|
||||
}
|
||||
|
||||
func (a *appstore) purchaseRequest(acc Account, app App, storeFront, guid string) http.Request {
|
||||
func (a *appstore) purchaseRequest(acc Account, app App, storeFront, guid string, pricingParameters string) http.Request {
|
||||
return http.Request{
|
||||
URL: fmt.Sprintf("https://%s%s", PrivateAppStoreAPIDomain, PrivateAppStoreAPIPathPurchase),
|
||||
Method: http.MethodPOST,
|
||||
ResponseFormat: http.ResponseFormatXML,
|
||||
Headers: map[string]string{
|
||||
"User-Agent": "Configurator/2.15 (Macintosh; OperatingSystem X 11.0.0; 16G29) AppleWebKit/2603.3.8",
|
||||
"Content-Type": "application/x-apple-plist",
|
||||
"iCloud-DSID": acc.DirectoryServicesID,
|
||||
"X-Dsid": acc.DirectoryServicesID,
|
||||
@@ -130,7 +154,7 @@ func (a *appstore) purchaseRequest(acc Account, app App, storeFront, guid string
|
||||
"origPage": fmt.Sprintf("Software-%d", app.ID),
|
||||
"origPageLocation": "Buy",
|
||||
"price": "0",
|
||||
"pricingParameters": "STDQ",
|
||||
"pricingParameters": pricingParameters,
|
||||
"productType": "C",
|
||||
"salableAdamId": app.ID,
|
||||
},
|
||||
|
||||
@@ -276,28 +276,6 @@ var _ = Describe("AppStore (Purchase)", func() {
|
||||
Data: LoginResult{},
|
||||
}, nil)
|
||||
|
||||
mockKeychain.EXPECT().
|
||||
Get("account").
|
||||
Return([]byte("{\"storeFront\":\"143441\"}"), nil)
|
||||
|
||||
mockSearchClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[SearchResult]{
|
||||
StatusCode: 200,
|
||||
Data: SearchResult{
|
||||
Count: 1,
|
||||
Results: []App{
|
||||
{
|
||||
ID: 0,
|
||||
BundleID: "",
|
||||
Name: "",
|
||||
Version: "",
|
||||
Price: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
mockLogger.EXPECT().
|
||||
Verbose().
|
||||
Return(nil).
|
||||
@@ -316,7 +294,7 @@ var _ = Describe("AppStore (Purchase)", func() {
|
||||
}, nil)
|
||||
})
|
||||
|
||||
It("attempts to purcahse app", func() {
|
||||
It("attempts to purchase app", func() {
|
||||
err := as.Purchase("")
|
||||
Expect(err).To(MatchError(ContainSubstring(ErrPasswordTokenExpired.Error())))
|
||||
})
|
||||
@@ -466,7 +444,7 @@ var _ = Describe("AppStore (Purchase)", func() {
|
||||
})
|
||||
})
|
||||
|
||||
When("sucessfully purchases the app", func() {
|
||||
When("subscription is required", func() {
|
||||
BeforeEach(func() {
|
||||
mockKeychain.EXPECT().
|
||||
Get("account").
|
||||
@@ -495,7 +473,76 @@ var _ = Describe("AppStore (Purchase)", func() {
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockPurchaseClient.EXPECT().
|
||||
Send(pricingParametersMatcher{"STDQ"}).
|
||||
Return(http.Result[PurchaseResult]{
|
||||
StatusCode: 200,
|
||||
Data: PurchaseResult{
|
||||
CustomerMessage: "This item is temporarily unavailable.",
|
||||
FailureType: FailureTypeTemporarilyUnavailable,
|
||||
},
|
||||
}, nil)
|
||||
|
||||
mockPurchaseClient.EXPECT().
|
||||
Send(pricingParametersMatcher{"GAME"}).
|
||||
Return(http.Result[PurchaseResult]{
|
||||
StatusCode: 200,
|
||||
Data: PurchaseResult{
|
||||
CustomerMessage: CustomerMessageSubscriptionRequired,
|
||||
},
|
||||
}, nil)
|
||||
|
||||
mockLogger.EXPECT().
|
||||
Verbose().
|
||||
Return(nil).
|
||||
Times(2)
|
||||
})
|
||||
|
||||
It("returns error", func() {
|
||||
err := as.Purchase("")
|
||||
Expect(err).To(MatchError(ContainSubstring(ErrSubscriptionRequired.Error())))
|
||||
})
|
||||
})
|
||||
|
||||
When("successfully purchases the app", func() {
|
||||
BeforeEach(func() {
|
||||
mockKeychain.EXPECT().
|
||||
Get("account").
|
||||
Return([]byte("{\"storeFront\":\"143441\"}"), nil)
|
||||
|
||||
mockSearchClient.EXPECT().
|
||||
Send(gomock.Any()).
|
||||
Return(http.Result[SearchResult]{
|
||||
StatusCode: 200,
|
||||
Data: SearchResult{
|
||||
Count: 1,
|
||||
Results: []App{
|
||||
{
|
||||
ID: 0,
|
||||
BundleID: "",
|
||||
Name: "",
|
||||
Version: "",
|
||||
Price: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
mockMachine.EXPECT().
|
||||
MacAddress().
|
||||
Return("00:00:00:00:00:00", nil)
|
||||
|
||||
mockPurchaseClient.EXPECT().
|
||||
Send(pricingParametersMatcher{"STDQ"}).
|
||||
Return(http.Result[PurchaseResult]{
|
||||
StatusCode: 200,
|
||||
Data: PurchaseResult{
|
||||
CustomerMessage: "This item is temporarily unavailable.",
|
||||
FailureType: FailureTypeTemporarilyUnavailable,
|
||||
},
|
||||
}, nil)
|
||||
|
||||
mockPurchaseClient.EXPECT().
|
||||
Send(pricingParametersMatcher{"GAME"}).
|
||||
Return(http.Result[PurchaseResult]{
|
||||
StatusCode: 200,
|
||||
Data: PurchaseResult{
|
||||
@@ -569,3 +616,16 @@ var _ = Describe("AppStore (Purchase)", func() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
type pricingParametersMatcher struct {
|
||||
pricingParameters string
|
||||
}
|
||||
|
||||
func (p pricingParametersMatcher) Matches(in interface{}) bool {
|
||||
request := in.(http.Request)
|
||||
return request.Payload.(*http.XMLPayload).Content["pricingParameters"] == p.pricingParameters
|
||||
}
|
||||
|
||||
func (p pricingParametersMatcher) String() string {
|
||||
return "payload pricingParameters is " + p.pricingParameters
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package appstore
|
||||
|
||||
const (
|
||||
FailureTypeInvalidCredentials = "-5000"
|
||||
FailureTypePasswordTokenExpired = "2034"
|
||||
FailureTypeLicenseNotFound = "9610"
|
||||
FailureTypeInvalidCredentials = "-5000"
|
||||
FailureTypePasswordTokenExpired = "2034"
|
||||
FailureTypeLicenseNotFound = "9610"
|
||||
FailureTypeTemporarilyUnavailable = "2059"
|
||||
|
||||
CustomerMessageBadLogin = "MZFinance.BadLogin.Configurator_message"
|
||||
CustomerMessageBadLogin = "MZFinance.BadLogin.Configurator_message"
|
||||
CustomerMessageSubscriptionRequired = "Subscription Required"
|
||||
|
||||
iTunesAPIDomain = "itunes.apple.com"
|
||||
iTunesAPIPathSearch = "/search"
|
||||
@@ -19,4 +21,7 @@ const (
|
||||
PrivateAppStoreAPIPathDownload = "/WebObjects/MZFinance.woa/wa/volumeStoreDownloadProduct"
|
||||
|
||||
HTTPHeaderStoreFront = "X-Set-Apple-Store-Front"
|
||||
|
||||
PricingParameterAppStore = "STDQ"
|
||||
PricingParameterAppleArcade = "GAME"
|
||||
)
|
||||
@@ -49,6 +49,8 @@ var (
|
||||
ErrRequest = errors.New("failed to send request")
|
||||
ErrResolveDestinationPath = errors.New("failed to resolve destination path")
|
||||
ErrSetKeychainItem = errors.New("failed to save item in keychain")
|
||||
ErrSubscriptionRequired = errors.New("subscription required")
|
||||
ErrTemporarilyUnavailable = errors.New("item is temporarily unavailable")
|
||||
ErrUnmarshal = errors.New("failed to unmarshal data")
|
||||
ErrWriteMetadataFile = errors.New("failed to write metadata")
|
||||
ErrWriteSinfData = errors.New("failed to write sinf data")
|
||||
|
||||
+15
-4
@@ -8,7 +8,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//go:generate mockgen -source=client.go -destination=client_mock.go -package=http
|
||||
@@ -27,11 +26,23 @@ type ClientArgs struct {
|
||||
CookieJar CookieJar
|
||||
}
|
||||
|
||||
type AddHeaderTransport struct {
|
||||
T http.RoundTripper
|
||||
}
|
||||
|
||||
func (adt *AddHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
if req.Header.Get("User-Agent") == "" {
|
||||
req.Header.Set("User-Agent", DefaultUserAgent)
|
||||
}
|
||||
return adt.T.RoundTrip(req)
|
||||
}
|
||||
|
||||
func NewClient[R interface{}](args ClientArgs) Client[R] {
|
||||
return &client[R]{
|
||||
internalClient: http.Client{
|
||||
Timeout: time.Second * 15,
|
||||
Jar: args.CookieJar,
|
||||
Timeout: 0,
|
||||
Jar: args.CookieJar,
|
||||
Transport: &AddHeaderTransport{http.DefaultTransport},
|
||||
},
|
||||
cookieJar: args.CookieJar,
|
||||
}
|
||||
@@ -78,7 +89,7 @@ func (c *client[R]) Send(req Request) (Result[R], error) {
|
||||
}
|
||||
|
||||
func (c *client[R]) Do(req *http.Request) (*http.Response, error) {
|
||||
return http.DefaultClient.Do(req)
|
||||
return c.internalClient.Do(req)
|
||||
}
|
||||
|
||||
func (*client[R]) NewRequest(method, url string, body io.Reader) (*http.Request, error) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/golang/mock/gomock"
|
||||
@@ -52,6 +53,11 @@ var _ = Describe("Client", Ordered, func() {
|
||||
w.Header().Add("Content-Type", "application/random-type")
|
||||
})
|
||||
|
||||
http.HandleFunc("/headers", func(w http.ResponseWriter, r *http.Request) {
|
||||
err := json.NewEncoder(w).Encode(r.Header)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
go func() {
|
||||
err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -191,4 +197,21 @@ var _ = Describe("Client", Ordered, func() {
|
||||
Expect(err).To(MatchError(ContainSubstring(ErrGetPayloadData.Error())))
|
||||
})
|
||||
})
|
||||
|
||||
It("uses default headers", func() {
|
||||
sut := NewClient[XMLResult](ClientArgs{})
|
||||
|
||||
req, err := sut.NewRequest("GET", fmt.Sprintf("http://localhost:%d/headers", port), nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(req).ToNot(BeNil())
|
||||
|
||||
res, err := sut.Do(req)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(res).ToNot(BeNil())
|
||||
|
||||
headers := http.Header{}
|
||||
err = json.NewDecoder(res.Body).Decode(&headers)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(headers.Get("User-Agent")).To(Equal(DefaultUserAgent))
|
||||
})
|
||||
})
|
||||
@@ -5,4 +5,5 @@ type ResponseFormat string
|
||||
const (
|
||||
ResponseFormatJSON ResponseFormat = "json"
|
||||
ResponseFormatXML ResponseFormat = "xml"
|
||||
DefaultUserAgent = "Configurator/2.15 (Macintosh; OperatingSystem X 11.0.0; 16G29) AppleWebKit/2603.3.8"
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func RandInt(min, max int) int {
|
||||
return rand.Intn(max-min) + min
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Rand", func() {
|
||||
It("returns random integer in range", func() {
|
||||
res := RandInt(1, 3)
|
||||
Expect(res).To(BeNumerically(">=", 1))
|
||||
Expect(res).To(BeNumerically("<=", 3))
|
||||
})
|
||||
})
|
||||
+1
-1
@@ -6,4 +6,4 @@ func IfEmpty(value, fallback string) string {
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user