developer-disk-image 0.2.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/.github/workflows/python-app.yml +7 -0
  2. developer_disk_image-0.3.1/.github/workflows/python-publish.yml +46 -0
  3. developer_disk_image-0.3.1/LICENSE +21 -0
  4. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/MANIFEST.in +1 -0
  5. developer_disk_image-0.3.1/PKG-INFO +177 -0
  6. developer_disk_image-0.3.1/README.md +151 -0
  7. developer_disk_image-0.3.1/developer_disk_image/_version.py +24 -0
  8. developer_disk_image-0.3.1/developer_disk_image/repo.py +125 -0
  9. developer_disk_image-0.3.1/developer_disk_image.egg-info/PKG-INFO +177 -0
  10. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/developer_disk_image.egg-info/SOURCES.txt +4 -1
  11. developer_disk_image-0.3.1/developer_disk_image.egg-info/scm_file_list.json +118 -0
  12. developer_disk_image-0.3.1/developer_disk_image.egg-info/scm_version.json +8 -0
  13. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/pyproject.toml +3 -6
  14. developer_disk_image-0.3.1/tests/test_repo.py +49 -0
  15. developer_disk_image-0.3.1/update_ddi.py +309 -0
  16. developer_disk_image-0.2.0/.github/workflows/python-publish.yml +0 -31
  17. developer_disk_image-0.2.0/PKG-INFO +0 -62
  18. developer_disk_image-0.2.0/README.md +0 -38
  19. developer_disk_image-0.2.0/developer_disk_image/_version.py +0 -21
  20. developer_disk_image-0.2.0/developer_disk_image/repo.py +0 -85
  21. developer_disk_image-0.2.0/developer_disk_image.egg-info/PKG-INFO +0 -62
  22. developer_disk_image-0.2.0/developer_disk_image.egg-info/entry_points.txt +0 -2
  23. developer_disk_image-0.2.0/tests/test_repo.py +0 -17
  24. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  25. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/.github/workflows/codeql.yml +0 -0
  26. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/.gitignore +0 -0
  27. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/developer_disk_image/__init__.py +0 -0
  28. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/developer_disk_image/exceptions.py +0 -0
  29. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/developer_disk_image.egg-info/dependency_links.txt +0 -0
  30. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/developer_disk_image.egg-info/requires.txt +0 -0
  31. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/developer_disk_image.egg-info/top_level.txt +0 -0
  32. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/requirements.txt +0 -0
  33. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/setup.cfg +0 -0
  34. {developer_disk_image-0.2.0 → developer_disk_image-0.3.1}/tests/__init__.py +0 -0
@@ -18,6 +18,13 @@ jobs:
18
18
  matrix:
19
19
  python-version: ["3.9", "3.10", "3.11", "3.12", "3.13" ]
20
20
  os: [ ubuntu-latest, macos-latest, windows-latest ]
21
+ # ubuntu-latest (26.04) has no prebuilt Python 3.9; keep covering it on 24.04.
22
+ exclude:
23
+ - python-version: "3.9"
24
+ os: ubuntu-latest
25
+ include:
26
+ - python-version: "3.9"
27
+ os: ubuntu-24.04
21
28
 
22
29
  steps:
23
30
  - uses: actions/checkout@v3
@@ -0,0 +1,46 @@
1
+ # Uploads a Python package to PyPI when a release is created.
2
+ #
3
+ # Authentication uses PyPI Trusted Publishing (OpenID Connect) rather than a stored API token:
4
+ # GitHub mints a short-lived credential for this workflow, so there is no long-lived secret to
5
+ # leak or to silently expire. The trusted publisher must be registered once on PyPI, under
6
+ # Manage project -> Publishing, matching owner/repository/workflow below.
7
+ # https://docs.pypi.org/trusted-publishers/
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [created]
14
+ # Allows re-publishing a tag whose release-triggered run failed, without cutting a new version.
15
+ workflow_dispatch:
16
+ inputs:
17
+ ref:
18
+ description: 'Tag to build and publish (e.g. v0.3.0)'
19
+ required: true
20
+
21
+ jobs:
22
+ deploy:
23
+
24
+ runs-on: ubuntu-latest
25
+
26
+ permissions:
27
+ # Required for Trusted Publishing; the job needs no repository secrets at all.
28
+ id-token: write
29
+
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ with:
33
+ # setuptools_scm derives the version from tags, so the full history must be present.
34
+ fetch-depth: 0
35
+ ref: ${{ inputs.ref || github.ref }}
36
+ - name: Set up Python
37
+ uses: actions/setup-python@v5
38
+ with:
39
+ python-version: '3.x'
40
+ - name: Build
41
+ run: |
42
+ python -m pip install --upgrade pip
43
+ pip install -U build
44
+ python -m build
45
+ - name: Publish
46
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-2026 doronz88
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,2 +1,3 @@
1
1
  prune DeveloperDiskImages/*
2
2
  prune PersonalizedImages/*
3
+ prune .claude
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: developer_disk_image
3
+ Version: 0.3.1
4
+ Summary: Download DeveloperDiskImage ans Personalized images from GitHub
5
+ Author-email: doronz88 <doron88@gmail.com>
6
+ Maintainer-email: doronz88 <doron88@gmail.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/doronz88/DeveloperDiskImage
9
+ Project-URL: Bug Reports, https://github.com/doronz88/DeveloperDiskImage/issues
10
+ Keywords: ios,DeveloperDiskImage
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ [![Pypi version](https://img.shields.io/pypi/v/developer_disk_image.svg)](https://pypi.org/project/developer_disk_image/ "PyPi package")
28
+
29
+ # Overview
30
+
31
+ Store both types of Apple's DeveloperDiskImage files:
32
+
33
+ - `DeveloperDiskImage.dmg` & `DeveloperDiskImage.dmg.signature`
34
+ - Used for each iOS version < 17.0
35
+ - The new Personalized images, but splitted to:
36
+ - APFS
37
+ - `BuildManifest.plist`
38
+ - Trustcache
39
+ - The Cryptex1 assets, for installing the same DDI through `cryptexd` instead of the image mounter:
40
+ - APFS
41
+ - `BuildManifest.plist`
42
+ - Trustcache
43
+ - Cryptex info plist
44
+ - Volume root hash
45
+
46
+ The split of the new format is requires for OS* other than macOS that will have trouble extracting the original APFS
47
+ image inside: `~/Library/Developer/DeveloperDiskImages`.
48
+
49
+ ## Layout
50
+
51
+ | Directory | Consumed by |
52
+ |---|---|
53
+ | `DeveloperDiskImages/<version>/` | iOS < 17.0 |
54
+ | `PersonalizedImages/Xcode_iOS_DDI_Personalized/` | the image mounter (`mounter auto-mount` on iOS 17.0 - 17.3.1 without an RSD tunnel, and released pymobiledevice3 versions) |
55
+ | `PersonalizedImages/Xcode_iOS_DDI_Cryptex/` | `cryptexd` (`mounter auto-mount` from iOS 17.4 or over an RSD tunnel, and `cryptex auto-install`) |
56
+
57
+ **Newer devices, such as the iPhone 18 series, can only use the Cryptex variant.** Every
58
+ `PersonalizedDMG` build identity is tied to an `ApChipID`/`ApBoardID` pair, so it only covers the
59
+ devices listed in the DDI's build manifest -- even Xcode 27.1's DDI stops at `iPhone18,5`. A device
60
+ outside that list has no identity to request a ticket for (pymobiledevice3 reports
61
+ `NoSuchBuildIdentityError`). The Cryptex1 identity names no device at all
62
+ (`Cryptex1,UseProductClass`, no chip or board), so the manifest doesn't limit which devices it can
63
+ be personalized for; Apple's signing server decides, as it does for Xcode.
64
+
65
+ This is why pymobiledevice3's `mounter auto-mount` installs the Cryptex variant through `cryptexd`
66
+ from iOS 17.4, setting up the RSD tunnel it needs by itself. The Personalized variant is kept for
67
+ backward compatibility: released pymobiledevice3 versions fetch exactly its paths, and iOS 17.0 -
68
+ 17.3.1 without a tunnel still mounts it.
69
+
70
+ Every payload is published under a fixed file name, so download URLs stay predictable across
71
+ releases:
72
+
73
+ | File | Personalized | Cryptex |
74
+ |---|---|---|
75
+ | `BuildManifest.plist` | yes | yes |
76
+ | `Image.dmg` | `PersonalizedDMG` | `Cryptex1,GenericDmg` |
77
+ | `Image.dmg.trustcache` | `LoadableTrustCache` | `Cryptex1,GenericTrustCache` |
78
+ | `Image.dmg.cryptex_info` | -- | `Cryptex1,CryptexInfoPlist` |
79
+ | `Image.dmg.root_hash` | -- | `Cryptex1,GenericVolume` |
80
+
81
+ Apple's own paths embed a build number (`022-22107-072.dmg`), so the published
82
+ `BuildManifest.plist` is rewritten to declare the fixed names instead. Only `Info.Path` is
83
+ adjusted -- the digests personalization depends on are untouched -- which keeps a downloaded
84
+ cryptex directory usable as a drop-in `Restore` directory.
85
+
86
+ ## Updating
87
+
88
+ `update_ddi.py` refreshes every variant from a local Xcode installation. macOS only, no
89
+ dependencies, run it with [uv](https://docs.astral.sh/uv/):
90
+
91
+ ```shell
92
+ uv run --script update_ddi.py # refresh every variant of the iOS DDI
93
+ uv run --script update_ddi.py --dry-run # report what would change, write nothing
94
+ uv run --script update_ddi.py --platform tvOS --variant cryptex
95
+ ```
96
+
97
+ Pass `--script` so uv runs it as a standalone script rather than treating this repository as a uv
98
+ project (which would leave a stray `uv.lock` and `.venv` behind).
99
+
100
+ It reads Xcode's bundle from `/Library/Developer` (falling back to attaching
101
+ `CoreDevice/CandidateDDIs/<platform>_DDI.dmg` when no expanded copy exists), verifies every payload
102
+ against the SHA-384 digests in the build manifest before publishing it, and removes stale files
103
+ left over from a previous build. Remember to bump `LATEST_DDI_BUILD_ID` in pymobiledevice3 to match
104
+ whatever build it reports.
105
+
106
+ # Python package
107
+
108
+ Additionally, this repo provides a python API for accessing this repository.
109
+ You can install it as follows:
110
+
111
+ ```shell
112
+ python3 -m pip install -U developer_disk_image
113
+ ```
114
+
115
+ ## Example usage
116
+
117
+ Payloads are fetched from `raw.githubusercontent.com`, which is not subject to the REST API's
118
+ 60-requests-per-hour anonymous quota, so no GitHub token is needed. `create()` accepts a `ref`
119
+ (branch, tag or commit) to read a revision other than `main`.
120
+
121
+ ```python
122
+ from developer_disk_image.repo import DeveloperDiskImageRepository
123
+
124
+ repo = DeveloperDiskImageRepository.create()
125
+
126
+ # will get both the APFS and the signature file
127
+ developer_disk_image = repo.get_developer_disk_image('16.4')
128
+
129
+ # will get all necessary files for mount
130
+ personalized_disk_image = repo.get_personalized_disk_image()
131
+
132
+ # will get all necessary files for installing the DDI as a cryptex
133
+ cryptex_disk_image = repo.get_cryptex_disk_image()
134
+ ```
135
+
136
+ Writing the cryptex assets back out under their published names produces a directory that
137
+ `cryptexd` clients accept as-is:
138
+
139
+ ```python
140
+ from pathlib import Path
141
+
142
+ from developer_disk_image.repo import CRYPTEX_IMAGE_PAYLOADS
143
+
144
+ restore = Path('Xcode_iOS_DDI_Cryptex')
145
+ restore.mkdir(parents=True, exist_ok=True)
146
+ (restore / 'BuildManifest.plist').write_bytes(cryptex_disk_image.build_manifest)
147
+ for field, name in CRYPTEX_IMAGE_PAYLOADS.items():
148
+ (restore / name).write_bytes(getattr(cryptex_disk_image, field))
149
+ ```
150
+
151
+ # License
152
+
153
+ The Python package and the scripts in this repository are released under the
154
+ [MIT License](LICENSE).
155
+
156
+ That license covers only this repository's own code. It does not cover, and grants no rights
157
+ in, the disk images and their accompanying files under `DeveloperDiskImages/` and
158
+ `PersonalizedImages/`: those are Apple's, see the legal notice below. They are not part of the
159
+ Python package, which only downloads them on request.
160
+
161
+ # Legal notice
162
+
163
+ This repository is not affiliated with or endorsed by Apple Inc. Apple, iOS and Xcode are
164
+ trademarks of Apple Inc.
165
+
166
+ The disk images and their accompanying files are Apple's property, as shipped with Xcode.
167
+ They are mirrored here solely for interoperability, mainly for Linux and Windows, where Xcode is
168
+ not available: so developers there can use the developer services of their own devices.
169
+
170
+ - The files are unmodified, except for the `Info.Path` key of the published
171
+ `BuildManifest.plist`, rewritten to match this repository's fixed file names.
172
+ - Nothing here bypasses Apple's protections: on iOS 17 and later, every image still requires a
173
+ per-device signature issued by Apple's signing server before a device will mount it.
174
+ - No fee is charged and nothing here is sold.
175
+
176
+ **Rights holders:** to request removal, please open an issue or contact the
177
+ [maintainer](https://github.com/doronz88). Valid requests will be honored promptly.
@@ -0,0 +1,151 @@
1
+ [![Pypi version](https://img.shields.io/pypi/v/developer_disk_image.svg)](https://pypi.org/project/developer_disk_image/ "PyPi package")
2
+
3
+ # Overview
4
+
5
+ Store both types of Apple's DeveloperDiskImage files:
6
+
7
+ - `DeveloperDiskImage.dmg` & `DeveloperDiskImage.dmg.signature`
8
+ - Used for each iOS version < 17.0
9
+ - The new Personalized images, but splitted to:
10
+ - APFS
11
+ - `BuildManifest.plist`
12
+ - Trustcache
13
+ - The Cryptex1 assets, for installing the same DDI through `cryptexd` instead of the image mounter:
14
+ - APFS
15
+ - `BuildManifest.plist`
16
+ - Trustcache
17
+ - Cryptex info plist
18
+ - Volume root hash
19
+
20
+ The split of the new format is requires for OS* other than macOS that will have trouble extracting the original APFS
21
+ image inside: `~/Library/Developer/DeveloperDiskImages`.
22
+
23
+ ## Layout
24
+
25
+ | Directory | Consumed by |
26
+ |---|---|
27
+ | `DeveloperDiskImages/<version>/` | iOS < 17.0 |
28
+ | `PersonalizedImages/Xcode_iOS_DDI_Personalized/` | the image mounter (`mounter auto-mount` on iOS 17.0 - 17.3.1 without an RSD tunnel, and released pymobiledevice3 versions) |
29
+ | `PersonalizedImages/Xcode_iOS_DDI_Cryptex/` | `cryptexd` (`mounter auto-mount` from iOS 17.4 or over an RSD tunnel, and `cryptex auto-install`) |
30
+
31
+ **Newer devices, such as the iPhone 18 series, can only use the Cryptex variant.** Every
32
+ `PersonalizedDMG` build identity is tied to an `ApChipID`/`ApBoardID` pair, so it only covers the
33
+ devices listed in the DDI's build manifest -- even Xcode 27.1's DDI stops at `iPhone18,5`. A device
34
+ outside that list has no identity to request a ticket for (pymobiledevice3 reports
35
+ `NoSuchBuildIdentityError`). The Cryptex1 identity names no device at all
36
+ (`Cryptex1,UseProductClass`, no chip or board), so the manifest doesn't limit which devices it can
37
+ be personalized for; Apple's signing server decides, as it does for Xcode.
38
+
39
+ This is why pymobiledevice3's `mounter auto-mount` installs the Cryptex variant through `cryptexd`
40
+ from iOS 17.4, setting up the RSD tunnel it needs by itself. The Personalized variant is kept for
41
+ backward compatibility: released pymobiledevice3 versions fetch exactly its paths, and iOS 17.0 -
42
+ 17.3.1 without a tunnel still mounts it.
43
+
44
+ Every payload is published under a fixed file name, so download URLs stay predictable across
45
+ releases:
46
+
47
+ | File | Personalized | Cryptex |
48
+ |---|---|---|
49
+ | `BuildManifest.plist` | yes | yes |
50
+ | `Image.dmg` | `PersonalizedDMG` | `Cryptex1,GenericDmg` |
51
+ | `Image.dmg.trustcache` | `LoadableTrustCache` | `Cryptex1,GenericTrustCache` |
52
+ | `Image.dmg.cryptex_info` | -- | `Cryptex1,CryptexInfoPlist` |
53
+ | `Image.dmg.root_hash` | -- | `Cryptex1,GenericVolume` |
54
+
55
+ Apple's own paths embed a build number (`022-22107-072.dmg`), so the published
56
+ `BuildManifest.plist` is rewritten to declare the fixed names instead. Only `Info.Path` is
57
+ adjusted -- the digests personalization depends on are untouched -- which keeps a downloaded
58
+ cryptex directory usable as a drop-in `Restore` directory.
59
+
60
+ ## Updating
61
+
62
+ `update_ddi.py` refreshes every variant from a local Xcode installation. macOS only, no
63
+ dependencies, run it with [uv](https://docs.astral.sh/uv/):
64
+
65
+ ```shell
66
+ uv run --script update_ddi.py # refresh every variant of the iOS DDI
67
+ uv run --script update_ddi.py --dry-run # report what would change, write nothing
68
+ uv run --script update_ddi.py --platform tvOS --variant cryptex
69
+ ```
70
+
71
+ Pass `--script` so uv runs it as a standalone script rather than treating this repository as a uv
72
+ project (which would leave a stray `uv.lock` and `.venv` behind).
73
+
74
+ It reads Xcode's bundle from `/Library/Developer` (falling back to attaching
75
+ `CoreDevice/CandidateDDIs/<platform>_DDI.dmg` when no expanded copy exists), verifies every payload
76
+ against the SHA-384 digests in the build manifest before publishing it, and removes stale files
77
+ left over from a previous build. Remember to bump `LATEST_DDI_BUILD_ID` in pymobiledevice3 to match
78
+ whatever build it reports.
79
+
80
+ # Python package
81
+
82
+ Additionally, this repo provides a python API for accessing this repository.
83
+ You can install it as follows:
84
+
85
+ ```shell
86
+ python3 -m pip install -U developer_disk_image
87
+ ```
88
+
89
+ ## Example usage
90
+
91
+ Payloads are fetched from `raw.githubusercontent.com`, which is not subject to the REST API's
92
+ 60-requests-per-hour anonymous quota, so no GitHub token is needed. `create()` accepts a `ref`
93
+ (branch, tag or commit) to read a revision other than `main`.
94
+
95
+ ```python
96
+ from developer_disk_image.repo import DeveloperDiskImageRepository
97
+
98
+ repo = DeveloperDiskImageRepository.create()
99
+
100
+ # will get both the APFS and the signature file
101
+ developer_disk_image = repo.get_developer_disk_image('16.4')
102
+
103
+ # will get all necessary files for mount
104
+ personalized_disk_image = repo.get_personalized_disk_image()
105
+
106
+ # will get all necessary files for installing the DDI as a cryptex
107
+ cryptex_disk_image = repo.get_cryptex_disk_image()
108
+ ```
109
+
110
+ Writing the cryptex assets back out under their published names produces a directory that
111
+ `cryptexd` clients accept as-is:
112
+
113
+ ```python
114
+ from pathlib import Path
115
+
116
+ from developer_disk_image.repo import CRYPTEX_IMAGE_PAYLOADS
117
+
118
+ restore = Path('Xcode_iOS_DDI_Cryptex')
119
+ restore.mkdir(parents=True, exist_ok=True)
120
+ (restore / 'BuildManifest.plist').write_bytes(cryptex_disk_image.build_manifest)
121
+ for field, name in CRYPTEX_IMAGE_PAYLOADS.items():
122
+ (restore / name).write_bytes(getattr(cryptex_disk_image, field))
123
+ ```
124
+
125
+ # License
126
+
127
+ The Python package and the scripts in this repository are released under the
128
+ [MIT License](LICENSE).
129
+
130
+ That license covers only this repository's own code. It does not cover, and grants no rights
131
+ in, the disk images and their accompanying files under `DeveloperDiskImages/` and
132
+ `PersonalizedImages/`: those are Apple's, see the legal notice below. They are not part of the
133
+ Python package, which only downloads them on request.
134
+
135
+ # Legal notice
136
+
137
+ This repository is not affiliated with or endorsed by Apple Inc. Apple, iOS and Xcode are
138
+ trademarks of Apple Inc.
139
+
140
+ The disk images and their accompanying files are Apple's property, as shipped with Xcode.
141
+ They are mirrored here solely for interoperability, mainly for Linux and Windows, where Xcode is
142
+ not available: so developers there can use the developer services of their own devices.
143
+
144
+ - The files are unmodified, except for the `Info.Path` key of the published
145
+ `BuildManifest.plist`, rewritten to match this repository's fixed file names.
146
+ - Nothing here bypasses Apple's protections: on iOS 17 and later, every image still requires a
147
+ per-device signature issued by Apple's signing server before a device will mount it.
148
+ - No fee is charged and nothing here is sold.
149
+
150
+ **Rights holders:** to request removal, please open an issue or contact the
151
+ [maintainer](https://github.com/doronz88). Valid requests will be honored promptly.
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.3.1'
22
+ __version_tuple__ = version_tuple = (0, 3, 1)
23
+
24
+ __commit_id__ = commit_id = 'ga9ae4c1c4'
@@ -0,0 +1,125 @@
1
+ import dataclasses
2
+ from datetime import datetime, timezone
3
+ from typing import Optional
4
+
5
+ import requests
6
+
7
+ from developer_disk_image.exceptions import DeveloperDiskImageException, GithubRateLimitExceededError
8
+
9
+ #: Payloads are served straight off raw.githubusercontent.com rather than through the REST API.
10
+ #: That host is not subject to the API's 60-requests-per-hour anonymous quota, so no token is
11
+ #: needed, and it saves downloading a recursive tree listing of a repository full of disk images
12
+ #: just to resolve a handful of known paths.
13
+ DEVELOPER_DISK_IMAGE_REPO_RAW_URL_FORMAT = \
14
+ 'https://raw.githubusercontent.com/doronz88/DeveloperDiskImage/{ref}/{path}'
15
+ DEFAULT_REF = 'main'
16
+
17
+
18
+ @dataclasses.dataclass
19
+ class DeveloperDiskImage:
20
+ image: bytes
21
+ signature: bytes
22
+
23
+
24
+ @dataclasses.dataclass
25
+ class PersonalizedImage:
26
+ image: bytes
27
+ build_manifest: bytes
28
+ trustcache: bytes
29
+
30
+
31
+ @dataclasses.dataclass
32
+ class CryptexImage:
33
+ """The Cryptex1 assets cryptexd needs in order to install a DeveloperDiskImage cryptex."""
34
+ image: bytes
35
+ build_manifest: bytes
36
+ trustcache: bytes
37
+ cryptex_info: bytes
38
+ root_hash: bytes
39
+
40
+
41
+ CRYPTEX_IMAGE_ROOT = 'PersonalizedImages/Xcode_iOS_DDI_Cryptex'
42
+
43
+ #: Field of `CryptexImage` -> its published file name. Fixed, so the URLs stay predictable across
44
+ #: releases; the published BuildManifest.plist is rewritten to declare these same names.
45
+ CRYPTEX_IMAGE_PAYLOADS = {
46
+ 'image': 'Image.dmg',
47
+ 'trustcache': 'Image.dmg.trustcache',
48
+ 'cryptex_info': 'Image.dmg.cryptex_info',
49
+ 'root_hash': 'Image.dmg.root_hash',
50
+ }
51
+
52
+
53
+ class DeveloperDiskImageRepository:
54
+ @classmethod
55
+ def create(cls, github_token: Optional[str] = None, ref: str = DEFAULT_REF) -> 'DeveloperDiskImageRepository':
56
+ """Create a repository client. Performs no request of its own.
57
+
58
+ :param github_token: optional token, forwarded on every request.
59
+ :param ref: branch, tag or commit to read. Defaults to `DEFAULT_REF`; pass a commit to read
60
+ a revision that is not merged yet, which is how CI checks a pull request against the
61
+ payloads that pull request adds.
62
+ """
63
+ return cls(github_token=github_token, ref=ref)
64
+
65
+ def __init__(self, github_token: Optional[str] = None, ref: str = DEFAULT_REF):
66
+ """
67
+ :param github_token: optional token, forwarded on every request.
68
+ :param ref: branch, tag or commit to read payloads from.
69
+ """
70
+ self.github_token = github_token
71
+ self.ref = ref
72
+
73
+ def get_developer_disk_image(self, version: str) -> Optional[DeveloperDiskImage]:
74
+ image = self._get_blob(f'DeveloperDiskImages/{version}/DeveloperDiskImage.dmg')
75
+ signature = self._get_blob(f'DeveloperDiskImages/{version}/DeveloperDiskImage.dmg.signature')
76
+
77
+ if image is None:
78
+ return None
79
+
80
+ return DeveloperDiskImage(image=image, signature=signature)
81
+
82
+ def get_personalized_disk_image(self) -> PersonalizedImage:
83
+ image = self._get_blob('PersonalizedImages/Xcode_iOS_DDI_Personalized/Image.dmg')
84
+ build_manifest = self._get_blob('PersonalizedImages/Xcode_iOS_DDI_Personalized/BuildManifest.plist')
85
+ trustcache = self._get_blob(
86
+ 'PersonalizedImages/Xcode_iOS_DDI_Personalized/Image.dmg.trustcache')
87
+ return PersonalizedImage(image=image, build_manifest=build_manifest, trustcache=trustcache)
88
+
89
+ def get_cryptex_disk_image(self) -> CryptexImage:
90
+ """Fetch the Cryptex1 DeveloperDiskImage assets, for installing the DDI over cryptexd.
91
+
92
+ Writing these out under their published names reproduces a directory that cryptexd clients
93
+ accept as-is, since the build manifest shipped alongside them declares those same names.
94
+ """
95
+ payloads = {'build_manifest': self._get_blob(f'{CRYPTEX_IMAGE_ROOT}/BuildManifest.plist')}
96
+ for field, name in CRYPTEX_IMAGE_PAYLOADS.items():
97
+ payloads[field] = self._get_blob(f'{CRYPTEX_IMAGE_ROOT}/{name}')
98
+
99
+ missing = sorted(field for field, blob in payloads.items() if blob is None)
100
+ if missing:
101
+ raise DeveloperDiskImageException(f'not published under {CRYPTEX_IMAGE_ROOT}: {", ".join(missing)}')
102
+ return CryptexImage(**payloads)
103
+
104
+ def _get_blob(self, path: str) -> Optional[bytes]:
105
+ """Fetch one payload, or ``None`` if this revision does not publish it."""
106
+ url = DEVELOPER_DISK_IMAGE_REPO_RAW_URL_FORMAT.format(ref=self.ref, path=path)
107
+ headers = {}
108
+ if self.github_token is not None:
109
+ headers['Authorization'] = 'Bearer ' + self.github_token
110
+
111
+ response = requests.get(url, headers=headers)
112
+ if response.status_code == 404:
113
+ return None
114
+ if response.status_code != 200:
115
+ # raw.githubusercontent.com is not under the REST API's hourly quota, but it can still
116
+ # throttle abusive traffic, and an authenticated request can still be limited.
117
+ # https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api
118
+ remaining = response.headers.get('x-ratelimit-remaining')
119
+ if response.status_code in (403, 429) and remaining is not None and int(remaining) == 0:
120
+ reset_utc = datetime.fromtimestamp(int(response.headers['x-ratelimit-reset']), timezone.utc)
121
+ raise GithubRateLimitExceededError(
122
+ f'GitHub: rate limit exceeded. Wait until {reset_utc.astimezone()} '
123
+ f'or use a custom GitHub access token')
124
+ raise DeveloperDiskImageException(f'GitHub: request for {path} failed: {response.status_code}')
125
+ return response.content