@appium/coresim 1.0.0
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.
- package/LICENSE +201 -0
- package/README.md +66 -0
- package/binding.gyp +53 -0
- package/lib/src/commands/app.d.ts +88 -0
- package/lib/src/commands/app.d.ts.map +1 -0
- package/lib/src/commands/app.js +133 -0
- package/lib/src/commands/app.js.map +1 -0
- package/lib/src/commands/biometric.d.ts +33 -0
- package/lib/src/commands/biometric.d.ts.map +1 -0
- package/lib/src/commands/biometric.js +44 -0
- package/lib/src/commands/biometric.js.map +1 -0
- package/lib/src/commands/darwin-notification.d.ts +36 -0
- package/lib/src/commands/darwin-notification.d.ts.map +1 -0
- package/lib/src/commands/darwin-notification.js +35 -0
- package/lib/src/commands/darwin-notification.js.map +1 -0
- package/lib/src/commands/interaction.d.ts +48 -0
- package/lib/src/commands/interaction.d.ts.map +1 -0
- package/lib/src/commands/interaction.js +48 -0
- package/lib/src/commands/interaction.js.map +1 -0
- package/lib/src/commands/keychain.d.ts +25 -0
- package/lib/src/commands/keychain.d.ts.map +1 -0
- package/lib/src/commands/keychain.js +52 -0
- package/lib/src/commands/keychain.js.map +1 -0
- package/lib/src/commands/lifecycle.d.ts +101 -0
- package/lib/src/commands/lifecycle.d.ts.map +1 -0
- package/lib/src/commands/lifecycle.js +165 -0
- package/lib/src/commands/lifecycle.js.map +1 -0
- package/lib/src/commands/media.d.ts +28 -0
- package/lib/src/commands/media.d.ts.map +1 -0
- package/lib/src/commands/media.js +27 -0
- package/lib/src/commands/media.js.map +1 -0
- package/lib/src/commands/misc.d.ts +15 -0
- package/lib/src/commands/misc.d.ts.map +1 -0
- package/lib/src/commands/misc.js +12 -0
- package/lib/src/commands/misc.js.map +1 -0
- package/lib/src/commands/pasteboard.d.ts +24 -0
- package/lib/src/commands/pasteboard.d.ts.map +1 -0
- package/lib/src/commands/pasteboard.js +22 -0
- package/lib/src/commands/pasteboard.js.map +1 -0
- package/lib/src/commands/permissions.d.ts +48 -0
- package/lib/src/commands/permissions.d.ts.map +1 -0
- package/lib/src/commands/permissions.js +84 -0
- package/lib/src/commands/permissions.js.map +1 -0
- package/lib/src/commands/process.d.ts +16 -0
- package/lib/src/commands/process.d.ts.map +1 -0
- package/lib/src/commands/process.js +68 -0
- package/lib/src/commands/process.js.map +1 -0
- package/lib/src/commands/screenshot.d.ts +29 -0
- package/lib/src/commands/screenshot.d.ts.map +1 -0
- package/lib/src/commands/screenshot.js +30 -0
- package/lib/src/commands/screenshot.js.map +1 -0
- package/lib/src/commands/spawn.d.ts +48 -0
- package/lib/src/commands/spawn.d.ts.map +1 -0
- package/lib/src/commands/spawn.js +108 -0
- package/lib/src/commands/spawn.js.map +1 -0
- package/lib/src/commands/ui.d.ts +42 -0
- package/lib/src/commands/ui.d.ts.map +1 -0
- package/lib/src/commands/ui.js +44 -0
- package/lib/src/commands/ui.js.map +1 -0
- package/lib/src/commands/webinspector.d.ts +19 -0
- package/lib/src/commands/webinspector.d.ts.map +1 -0
- package/lib/src/commands/webinspector.js +16 -0
- package/lib/src/commands/webinspector.js.map +1 -0
- package/lib/src/errors.d.ts +51 -0
- package/lib/src/errors.d.ts.map +1 -0
- package/lib/src/errors.js +82 -0
- package/lib/src/errors.js.map +1 -0
- package/lib/src/index.d.ts +7 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/src/index.js +5 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/native-simctl.d.ts +62 -0
- package/lib/src/native-simctl.d.ts.map +1 -0
- package/lib/src/native-simctl.js +221 -0
- package/lib/src/native-simctl.js.map +1 -0
- package/lib/src/types.d.ts +267 -0
- package/lib/src/types.d.ts.map +1 -0
- package/lib/src/types.js +29 -0
- package/lib/src/types.js.map +1 -0
- package/lib/src/utils/index.d.ts +3 -0
- package/lib/src/utils/index.d.ts.map +1 -0
- package/lib/src/utils/index.js +3 -0
- package/lib/src/utils/index.js.map +1 -0
- package/lib/src/utils/pkg-root.d.ts +6 -0
- package/lib/src/utils/pkg-root.d.ts.map +1 -0
- package/lib/src/utils/pkg-root.js +12 -0
- package/lib/src/utils/pkg-root.js.map +1 -0
- package/lib/src/utils/run-catching.d.ts +3 -0
- package/lib/src/utils/run-catching.d.ts.map +1 -0
- package/lib/src/utils/run-catching.js +11 -0
- package/lib/src/utils/run-catching.js.map +1 -0
- package/package.json +73 -0
- package/scripts/install.mjs +22 -0
- package/src/commands/app.ts +186 -0
- package/src/commands/biometric.ts +69 -0
- package/src/commands/darwin-notification.ts +51 -0
- package/src/commands/interaction.ts +74 -0
- package/src/commands/keychain.ts +63 -0
- package/src/commands/lifecycle.ts +210 -0
- package/src/commands/media.ts +38 -0
- package/src/commands/misc.ts +20 -0
- package/src/commands/pasteboard.ts +31 -0
- package/src/commands/permissions.ts +122 -0
- package/src/commands/process.ts +80 -0
- package/src/commands/screenshot.ts +46 -0
- package/src/commands/spawn.ts +133 -0
- package/src/commands/ui.ts +61 -0
- package/src/commands/webinspector.ts +23 -0
- package/src/coresim.mm +1066 -0
- package/src/errors.ts +93 -0
- package/src/index.ts +23 -0
- package/src/native/async_bridge.h +164 -0
- package/src/native/nserror_bridge.h +64 -0
- package/src/native/nserror_bridge.mm +30 -0
- package/src/native/objc_runtime.h +45 -0
- package/src/native/objc_runtime.mm +76 -0
- package/src/native/safe_dispatch.h +38 -0
- package/src/native/sim_device.h +143 -0
- package/src/native/sim_device.mm +355 -0
- package/src/native/sim_device_set.h +16 -0
- package/src/native/sim_device_set.mm +40 -0
- package/src/native/sim_pasteboard.h +16 -0
- package/src/native/sim_pasteboard.mm +295 -0
- package/src/native/sim_process.h +13 -0
- package/src/native/sim_process.mm +139 -0
- package/src/native/sim_screenshot.h +28 -0
- package/src/native/sim_screenshot.mm +226 -0
- package/src/native/sim_service_context.h +42 -0
- package/src/native/sim_service_context.mm +92 -0
- package/src/native/tcc_privacy.h +35 -0
- package/src/native/tcc_privacy.mm +256 -0
- package/src/native/value_bridge.h +18 -0
- package/src/native/value_bridge.mm +111 -0
- package/src/native-simctl.ts +288 -0
- package/src/types.ts +302 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/pkg-root.ts +14 -0
- package/src/utils/run-catching.ts +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @appium/coresim
|
|
2
|
+
|
|
3
|
+
Fast, native control of the iOS/tvOS/watchOS/visionOS Simulator from Node.js — no `simctl`
|
|
4
|
+
subprocess, no CLI output to parse.
|
|
5
|
+
|
|
6
|
+
## Why
|
|
7
|
+
|
|
8
|
+
Most tools drive the Simulator by shelling out to `simctl` and parsing its text output.
|
|
9
|
+
`@appium/coresim` talks to the same underlying system directly, in-process. That means:
|
|
10
|
+
|
|
11
|
+
- **Faster** — no process spawn per call.
|
|
12
|
+
- **More reliable** — real errors instead of scraped stderr strings.
|
|
13
|
+
- **Async by design** — every call returns a `Promise` and never blocks your app.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @appium/coresim
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Works on any platform to install, but simulator control requires **macOS**. On other platforms
|
|
22
|
+
(or when the Simulator isn't available), calls reject with a clear `NativeSimUnavailableError`
|
|
23
|
+
instead of crashing.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import {NativeSimctl} from '@appium/coresim';
|
|
29
|
+
|
|
30
|
+
const sim = new NativeSimctl();
|
|
31
|
+
|
|
32
|
+
const devices = await sim.getDevices();
|
|
33
|
+
console.log(devices.map((d) => `${d.name} (${d.state})`));
|
|
34
|
+
|
|
35
|
+
const device = await sim.createDevice(
|
|
36
|
+
'My Test Device',
|
|
37
|
+
'com.apple.CoreSimulator.SimDeviceType.iPhone-15',
|
|
38
|
+
'com.apple.CoreSimulator.SimRuntime.iOS-17-4',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
await sim.bootDevice(device.udid);
|
|
42
|
+
await sim.waitForBoot(device.udid); // waits until the simulator is fully ready, not just "booted"
|
|
43
|
+
|
|
44
|
+
await sim.installApp(device.udid, '/path/to/MyApp.app');
|
|
45
|
+
await sim.launchApp(device.udid, 'com.example.MyApp');
|
|
46
|
+
|
|
47
|
+
await sim.shutdownDevice(device.udid);
|
|
48
|
+
await sim.deleteDevice(device.udid);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## What it can do
|
|
52
|
+
|
|
53
|
+
- **Devices** — list, create, delete, boot, shut down, and erase simulators; check real boot
|
|
54
|
+
readiness with `getBootStatus()`/`waitForBoot()`.
|
|
55
|
+
- **Apps** — install, remove, launch, terminate, and inspect apps.
|
|
56
|
+
- **Processes** — spawn a process on the simulator and stream its stdout/stderr live.
|
|
57
|
+
- **Simulator settings** — appearance (light/dark), accessibility (increase contrast, content
|
|
58
|
+
size), location, and permissions.
|
|
59
|
+
- **Extras** — keychain certificates, push notifications, and Darwin notifications.
|
|
60
|
+
|
|
61
|
+
## Status
|
|
62
|
+
|
|
63
|
+
Early stage: core device and app lifecycle is implemented and tested; broader coverage is in
|
|
64
|
+
progress.
|
|
65
|
+
|
|
66
|
+
See [`CLAUDE.md`](./CLAUDE.md) for architecture details.
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "coresim",
|
|
5
|
+
"sources": [
|
|
6
|
+
"src/coresim.mm",
|
|
7
|
+
"src/native/objc_runtime.mm",
|
|
8
|
+
"src/native/nserror_bridge.mm",
|
|
9
|
+
"src/native/value_bridge.mm",
|
|
10
|
+
"src/native/sim_service_context.mm",
|
|
11
|
+
"src/native/sim_device_set.mm",
|
|
12
|
+
"src/native/sim_device.mm",
|
|
13
|
+
"src/native/tcc_privacy.mm",
|
|
14
|
+
"src/native/sim_pasteboard.mm",
|
|
15
|
+
"src/native/sim_process.mm",
|
|
16
|
+
"src/native/sim_screenshot.mm"
|
|
17
|
+
],
|
|
18
|
+
"include_dirs": [
|
|
19
|
+
"<!@(node -p \"require('node-addon-api').include\")"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": [
|
|
22
|
+
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
23
|
+
],
|
|
24
|
+
"cflags!": ["-fno-exceptions"],
|
|
25
|
+
"cflags_cc!": ["-fno-exceptions"],
|
|
26
|
+
"defines": ["NAPI_CPP_EXCEPTIONS", "NAPI_VERSION=8"],
|
|
27
|
+
"xcode_settings": {
|
|
28
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
29
|
+
"GCC_ENABLE_OBJC_EXCEPTIONS": "YES",
|
|
30
|
+
"CLANG_ENABLE_OBJC_ARC": "YES",
|
|
31
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
32
|
+
"CLANG_CXX_LANGUAGE_STANDARD": "c++17",
|
|
33
|
+
"MACOSX_DEPLOYMENT_TARGET": "12.0",
|
|
34
|
+
"GCC_OPTIMIZATION_LEVEL": "3",
|
|
35
|
+
"GCC_TREAT_WARNINGS_AS_ERRORS": "YES",
|
|
36
|
+
"WARNING_CFLAGS": [
|
|
37
|
+
"-Wall",
|
|
38
|
+
"-Wextra",
|
|
39
|
+
"-Wno-unused-parameter"
|
|
40
|
+
],
|
|
41
|
+
"OTHER_CPLUSPLUSFLAGS": ["-O3", "-fPIC", "-fobjc-arc"],
|
|
42
|
+
"OTHER_LDFLAGS": [
|
|
43
|
+
"-framework", "Foundation",
|
|
44
|
+
"-framework", "AppKit",
|
|
45
|
+
"-framework", "CoreImage",
|
|
46
|
+
"-framework", "ImageIO",
|
|
47
|
+
"-framework", "IOSurface",
|
|
48
|
+
"-lsqlite3"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { NativeSimctl } from '../native-simctl.js';
|
|
2
|
+
declare module '../native-simctl.js' {
|
|
3
|
+
interface NativeSimctl {
|
|
4
|
+
installApp(udid: string, appPath: string, options?: Record<string, unknown>): Promise<void>;
|
|
5
|
+
removeApp(udid: string, bundleId: string, options?: Record<string, unknown>): Promise<void>;
|
|
6
|
+
launchApp(udid: string, bundleId: string, options?: Record<string, unknown>): Promise<number>;
|
|
7
|
+
terminateApp(udid: string, bundleId: string): Promise<void>;
|
|
8
|
+
isAppInstalled(udid: string, bundleId: string): Promise<boolean>;
|
|
9
|
+
appInfo(udid: string, bundleId: string): Promise<Record<string, unknown>>;
|
|
10
|
+
installedApps(udid: string): Promise<Record<string, unknown>>;
|
|
11
|
+
getAppContainer(udid: string, bundleId: string, containerType?: AppContainerType | string): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Which of an app's on-disk containers {@link getAppContainer} should resolve — `'app'` (the
|
|
16
|
+
* `.app` bundle itself), `'data'` (its data container), `'groups'` (its sole App Group container,
|
|
17
|
+
* if it has exactly one), or any other string naming a specific App Group identifier.
|
|
18
|
+
*/
|
|
19
|
+
export type AppContainerType = 'app' | 'data' | 'groups';
|
|
20
|
+
/**
|
|
21
|
+
* Installs an `.app` bundle onto the given device.
|
|
22
|
+
*
|
|
23
|
+
* @param udid — UDID of the target device
|
|
24
|
+
* @param appPath — path to the `.app` bundle on disk
|
|
25
|
+
* @param options — passed through to `installApplication:withOptions:error:`
|
|
26
|
+
*/
|
|
27
|
+
export declare function installApp(this: NativeSimctl, udid: string, appPath: string, options?: Record<string, unknown>): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Uninstalls an app from the given device.
|
|
30
|
+
*
|
|
31
|
+
* @param udid — UDID of the target device
|
|
32
|
+
* @param bundleId — bundle identifier of the app to remove
|
|
33
|
+
* @param options — passed through to `uninstallApplication:withOptions:error:`
|
|
34
|
+
*/
|
|
35
|
+
export declare function removeApp(this: NativeSimctl, udid: string, bundleId: string, options?: Record<string, unknown>): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Launches an installed app on the given device.
|
|
38
|
+
*
|
|
39
|
+
* @param udid — UDID of the target device
|
|
40
|
+
* @param bundleId — bundle identifier of the app to launch
|
|
41
|
+
* @param options — passed through to `launchApplicationWithID:options:error:`
|
|
42
|
+
* @returns the launched process's pid
|
|
43
|
+
*/
|
|
44
|
+
export declare function launchApp(this: NativeSimctl, udid: string, bundleId: string, options?: Record<string, unknown>): Promise<number>;
|
|
45
|
+
/**
|
|
46
|
+
* @param udid — UDID of the target device
|
|
47
|
+
* @param bundleId — bundle identifier of the app to terminate
|
|
48
|
+
*/
|
|
49
|
+
export declare function terminateApp(this: NativeSimctl, udid: string, bundleId: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* @param udid — UDID of the device to check
|
|
52
|
+
* @param bundleId — bundle identifier to look up
|
|
53
|
+
* @returns whether an app with that bundle identifier is installed
|
|
54
|
+
*/
|
|
55
|
+
export declare function isAppInstalled(this: NativeSimctl, udid: string, bundleId: string): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* @param udid — UDID of the device to read from
|
|
58
|
+
* @param bundleId — bundle identifier of the installed app
|
|
59
|
+
* @returns the app's properties, as reported by `propertiesOfApplication:`
|
|
60
|
+
*/
|
|
61
|
+
export declare function appInfo(this: NativeSimctl, udid: string, bundleId: string): Promise<Record<string, unknown>>;
|
|
62
|
+
/**
|
|
63
|
+
* @param udid — UDID of the device to read from
|
|
64
|
+
* @returns every installed app's properties, keyed by bundle identifier
|
|
65
|
+
*/
|
|
66
|
+
export declare function installedApps(this: NativeSimctl, udid: string): Promise<Record<string, unknown>>;
|
|
67
|
+
/**
|
|
68
|
+
* Resolves the full filesystem path to one of an installed app's on-disk containers — the same
|
|
69
|
+
* paths {@link appInfo}'s `Path`/`DataContainer`/`GroupContainers` fields already carry, just
|
|
70
|
+
* picked out and normalized to a plain path (no new native call).
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Resolve a specific App Group container by its identifier (see appInfo's GroupContainers
|
|
74
|
+
* // field, or catch the error thrown below, to discover which identifiers an app has)
|
|
75
|
+
* const groupPath = await sim.getAppContainer(udid, bundleId, 'group.com.example.myapp');
|
|
76
|
+
*
|
|
77
|
+
* @param udid — UDID of the (booted) device to read from
|
|
78
|
+
* @param bundleId — bundle identifier of the installed app
|
|
79
|
+
* @param containerType — see {@link AppContainerType}; defaults to `'app'`
|
|
80
|
+
* @returns the resolved container's path
|
|
81
|
+
* @throws if the requested container doesn't exist (e.g. `'data'` before the device has booted
|
|
82
|
+
* once with the app installed), if `'groups'` is ambiguous (more than one App Group container —
|
|
83
|
+
* pass the specific group identifier instead), or if a given group identifier doesn't match any
|
|
84
|
+
* of the app's App Group containers — in both of the latter cases, the error message lists the
|
|
85
|
+
* app's actual App Group identifiers
|
|
86
|
+
*/
|
|
87
|
+
export declare function getAppContainer(this: NativeSimctl, udid: string, bundleId: string, containerType?: AppContainerType | string): Promise<string>;
|
|
88
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/commands/app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAGtD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EA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,OAAO,CAAC,MAAM,CAAC,CA4CjB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Installs an `.app` bundle onto the given device.
|
|
5
|
+
*
|
|
6
|
+
* @param udid — UDID of the target device
|
|
7
|
+
* @param appPath — path to the `.app` bundle on disk
|
|
8
|
+
* @param options — passed through to `installApplication:withOptions:error:`
|
|
9
|
+
*/
|
|
10
|
+
export async function installApp(udid, appPath, options = {}) {
|
|
11
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).installApp(appPath, options));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Uninstalls an app from the given device.
|
|
15
|
+
*
|
|
16
|
+
* @param udid — UDID of the target device
|
|
17
|
+
* @param bundleId — bundle identifier of the app to remove
|
|
18
|
+
* @param options — passed through to `uninstallApplication:withOptions:error:`
|
|
19
|
+
*/
|
|
20
|
+
export async function removeApp(udid, bundleId, options = {}) {
|
|
21
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).uninstallApp(bundleId, options));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Launches an installed app on the given device.
|
|
25
|
+
*
|
|
26
|
+
* @param udid — UDID of the target device
|
|
27
|
+
* @param bundleId — bundle identifier of the app to launch
|
|
28
|
+
* @param options — passed through to `launchApplicationWithID:options:error:`
|
|
29
|
+
* @returns the launched process's pid
|
|
30
|
+
*/
|
|
31
|
+
export async function launchApp(udid, bundleId, options = {}) {
|
|
32
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).launchApp(bundleId, options));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @param udid — UDID of the target device
|
|
36
|
+
* @param bundleId — bundle identifier of the app to terminate
|
|
37
|
+
*/
|
|
38
|
+
export async function terminateApp(udid, bundleId) {
|
|
39
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).terminateApp(bundleId));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @param udid — UDID of the device to check
|
|
43
|
+
* @param bundleId — bundle identifier to look up
|
|
44
|
+
* @returns whether an app with that bundle identifier is installed
|
|
45
|
+
*/
|
|
46
|
+
export async function isAppInstalled(udid, bundleId) {
|
|
47
|
+
return runCatchingAsync(async () => bundleId in (await (await this._findDevice(udid)).installedApps()));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @param udid — UDID of the device to read from
|
|
51
|
+
* @param bundleId — bundle identifier of the installed app
|
|
52
|
+
* @returns the app's properties, as reported by `propertiesOfApplication:`
|
|
53
|
+
*/
|
|
54
|
+
export async function appInfo(udid, bundleId) {
|
|
55
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).propertiesOfApplication(bundleId));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @param udid — UDID of the device to read from
|
|
59
|
+
* @returns every installed app's properties, keyed by bundle identifier
|
|
60
|
+
*/
|
|
61
|
+
export async function installedApps(udid) {
|
|
62
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).installedApps());
|
|
63
|
+
}
|
|
64
|
+
/** Converts a `file://` URL string (as `appInfo`'s container fields report) to a plain fs path. */
|
|
65
|
+
function toFsPath(fileUrl) {
|
|
66
|
+
if (typeof fileUrl !== 'string') {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return fileURLToPath(fileUrl).replace(/\/$/, '');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolves the full filesystem path to one of an installed app's on-disk containers — the same
|
|
73
|
+
* paths {@link appInfo}'s `Path`/`DataContainer`/`GroupContainers` fields already carry, just
|
|
74
|
+
* picked out and normalized to a plain path (no new native call).
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // Resolve a specific App Group container by its identifier (see appInfo's GroupContainers
|
|
78
|
+
* // field, or catch the error thrown below, to discover which identifiers an app has)
|
|
79
|
+
* const groupPath = await sim.getAppContainer(udid, bundleId, 'group.com.example.myapp');
|
|
80
|
+
*
|
|
81
|
+
* @param udid — UDID of the (booted) device to read from
|
|
82
|
+
* @param bundleId — bundle identifier of the installed app
|
|
83
|
+
* @param containerType — see {@link AppContainerType}; defaults to `'app'`
|
|
84
|
+
* @returns the resolved container's path
|
|
85
|
+
* @throws if the requested container doesn't exist (e.g. `'data'` before the device has booted
|
|
86
|
+
* once with the app installed), if `'groups'` is ambiguous (more than one App Group container —
|
|
87
|
+
* pass the specific group identifier instead), or if a given group identifier doesn't match any
|
|
88
|
+
* of the app's App Group containers — in both of the latter cases, the error message lists the
|
|
89
|
+
* app's actual App Group identifiers
|
|
90
|
+
*/
|
|
91
|
+
export async function getAppContainer(udid, bundleId, containerType = 'app') {
|
|
92
|
+
return runCatchingAsync(async () => {
|
|
93
|
+
const info = await this.appInfo(udid, bundleId);
|
|
94
|
+
if (containerType === 'app') {
|
|
95
|
+
const path = info.Path;
|
|
96
|
+
if (typeof path !== 'string') {
|
|
97
|
+
throw new Error(`No app bundle path was reported for '${bundleId}'`);
|
|
98
|
+
}
|
|
99
|
+
return path;
|
|
100
|
+
}
|
|
101
|
+
if (containerType === 'data') {
|
|
102
|
+
const path = toFsPath(info.DataContainer);
|
|
103
|
+
if (!path) {
|
|
104
|
+
throw new Error(`No data container was found for '${bundleId}' — has the device been booted since install?`);
|
|
105
|
+
}
|
|
106
|
+
return path;
|
|
107
|
+
}
|
|
108
|
+
const groupContainers = (info.GroupContainers ?? {});
|
|
109
|
+
if (containerType === 'groups') {
|
|
110
|
+
const entries = Object.entries(groupContainers);
|
|
111
|
+
if (entries.length === 0) {
|
|
112
|
+
throw new Error(`'${bundleId}' has no App Group containers`);
|
|
113
|
+
}
|
|
114
|
+
if (entries.length > 1) {
|
|
115
|
+
throw new Error(`'${bundleId}' has multiple App Group containers (${Object.keys(groupContainers).join(', ')}) — ` +
|
|
116
|
+
`specify one by its group identifier instead of 'groups'`);
|
|
117
|
+
}
|
|
118
|
+
const path = toFsPath(entries[0][1]);
|
|
119
|
+
if (!path) {
|
|
120
|
+
throw new Error(`'${bundleId}''s App Group container has no reported path`);
|
|
121
|
+
}
|
|
122
|
+
return path;
|
|
123
|
+
}
|
|
124
|
+
const path = toFsPath(groupContainers[containerType]);
|
|
125
|
+
if (!path) {
|
|
126
|
+
const available = Object.keys(groupContainers);
|
|
127
|
+
const availability = available.length > 0 ? `available: ${available.join(', ')}` : 'it has no App Group containers at all';
|
|
128
|
+
throw new Error(`'${bundleId}' has no App Group container with identifier '${containerType}' — ${availability}`);
|
|
129
|
+
}
|
|
130
|
+
return path;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/commands/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAsBnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAE9B,IAAY,EACZ,OAAe,EACf,UAAmC,EAAE;IAErC,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACnG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAE7B,IAAY,EACZ,QAAgB,EAChB,UAAmC,EAAE;IAErC,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AACtG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,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C/D,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CACb,IAAI,QAAQ,wCAAwC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;oBAC/F,yDAAyD,CAC5D,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,IAAI,QAAQ,8CAA8C,CAAC,CAAC;YAC9E,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC/C,MAAM,YAAY,GAChB,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,uCAAuC,CAAC;YACxG,MAAM,IAAI,KAAK,CAAC,IAAI,QAAQ,iDAAiD,aAAa,OAAO,YAAY,EAAE,CAAC,CAAC;QACnH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { NativeSimctl } from '../native-simctl.js';
|
|
2
|
+
declare module '../native-simctl.js' {
|
|
3
|
+
interface NativeSimctl {
|
|
4
|
+
isBiometricEnrolled(udid: string): Promise<boolean>;
|
|
5
|
+
enrollBiometric(udid: string, isEnabled?: boolean): Promise<void>;
|
|
6
|
+
sendBiometricMatch(udid: string, shouldMatch?: boolean, biometricName?: BiometricName): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** A simulated biometric sensor — Face ID is only available since iOS 11. */
|
|
10
|
+
export type BiometricName = 'touchId' | 'faceId';
|
|
11
|
+
/**
|
|
12
|
+
* @param udid — UDID of the device to read from
|
|
13
|
+
* @returns whether a biometric sensor is currently simulated as enrolled
|
|
14
|
+
*/
|
|
15
|
+
export declare function isBiometricEnrolled(this: NativeSimctl, udid: string): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Simulates enrolling (or un-enrolling) a biometric sensor — the prerequisite for
|
|
18
|
+
* {@link sendBiometricMatch} to have any effect.
|
|
19
|
+
*
|
|
20
|
+
* @param udid — UDID of the target device
|
|
21
|
+
* @param isEnabled — whether the device should report a biometric sensor as enrolled; defaults to `true`
|
|
22
|
+
*/
|
|
23
|
+
export declare function enrollBiometric(this: NativeSimctl, udid: string, isEnabled?: boolean): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Simulates a successful or failed biometric match attempt — only takes effect once
|
|
26
|
+
* {@link enrollBiometric} has enrolled the corresponding sensor.
|
|
27
|
+
*
|
|
28
|
+
* @param udid — UDID of the target device
|
|
29
|
+
* @param shouldMatch — whether the simulated attempt should succeed; defaults to `true`
|
|
30
|
+
* @param biometricName — which sensor to simulate; defaults to `'touchId'`
|
|
31
|
+
*/
|
|
32
|
+
export declare function sendBiometricMatch(this: NativeSimctl, udid: string, shouldMatch?: boolean, biometricName?: BiometricName): Promise<void>;
|
|
33
|
+
//# sourceMappingURL=biometric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"biometric.d.ts","sourceRoot":"","sources":["../../../src/commands/biometric.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAEtD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QACpD,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAClE,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACvG;CACF;AAED,6EAA6E;AAC7E,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,CAAC;AAUjD;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5F;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvG;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,UAAO,EAClB,aAAa,GAAE,aAAyB,GACvC,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Simulator.app's own Features > Face ID/Touch ID menu drives the same two Darwin notifications
|
|
2
|
+
// (see darwin-notification.ts) rather than any dedicated CoreSimulator API — no native call needed.
|
|
3
|
+
const ENROLLMENT_NOTIFICATION_NAME = 'com.apple.BiometricKit.enrollmentChanged';
|
|
4
|
+
const BIOMETRIC_DOMAIN_COMPONENTS = {
|
|
5
|
+
touchId: 'fingerTouch',
|
|
6
|
+
faceId: 'pearl',
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @param udid — UDID of the device to read from
|
|
10
|
+
* @returns whether a biometric sensor is currently simulated as enrolled
|
|
11
|
+
*/
|
|
12
|
+
export async function isBiometricEnrolled(udid) {
|
|
13
|
+
return (await this.getDarwinNotificationState(udid, ENROLLMENT_NOTIFICATION_NAME)) === 1n;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Simulates enrolling (or un-enrolling) a biometric sensor — the prerequisite for
|
|
17
|
+
* {@link sendBiometricMatch} to have any effect.
|
|
18
|
+
*
|
|
19
|
+
* @param udid — UDID of the target device
|
|
20
|
+
* @param isEnabled — whether the device should report a biometric sensor as enrolled; defaults to `true`
|
|
21
|
+
*/
|
|
22
|
+
export async function enrollBiometric(udid, isEnabled = true) {
|
|
23
|
+
await this.setDarwinNotificationState(udid, ENROLLMENT_NOTIFICATION_NAME, isEnabled ? 1n : 0n);
|
|
24
|
+
await this.postDarwinNotification(udid, ENROLLMENT_NOTIFICATION_NAME);
|
|
25
|
+
if ((await isBiometricEnrolled.call(this, udid)) !== isEnabled) {
|
|
26
|
+
throw new Error(`Failed to set biometric enrolled state for '${udid}' to '${isEnabled}'`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Simulates a successful or failed biometric match attempt — only takes effect once
|
|
31
|
+
* {@link enrollBiometric} has enrolled the corresponding sensor.
|
|
32
|
+
*
|
|
33
|
+
* @param udid — UDID of the target device
|
|
34
|
+
* @param shouldMatch — whether the simulated attempt should succeed; defaults to `true`
|
|
35
|
+
* @param biometricName — which sensor to simulate; defaults to `'touchId'`
|
|
36
|
+
*/
|
|
37
|
+
export async function sendBiometricMatch(udid, shouldMatch = true, biometricName = 'touchId') {
|
|
38
|
+
if (!Object.hasOwn(BIOMETRIC_DOMAIN_COMPONENTS, biometricName)) {
|
|
39
|
+
throw new Error(`'${biometricName}' is not a valid biometric — use one of: ${Object.keys(BIOMETRIC_DOMAIN_COMPONENTS).join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
const domainComponent = BIOMETRIC_DOMAIN_COMPONENTS[biometricName];
|
|
42
|
+
await this.postDarwinNotification(udid, `com.apple.BiometricKit_Sim.${domainComponent}.${shouldMatch ? '' : 'no'}match`);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=biometric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"biometric.js","sourceRoot":"","sources":["../../../src/commands/biometric.ts"],"names":[],"mappings":"AAaA,gGAAgG;AAChG,oGAAoG;AACpG,MAAM,4BAA4B,GAAG,0CAA0C,CAAC;AAChF,MAAM,2BAA2B,GAAkC;IACjE,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAqB,IAAY;IACxE,OAAO,CAAC,MAAM,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,4BAA4B,CAAC,CAAC,KAAK,EAAE,CAAC;AAC5F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAqB,IAAY,EAAE,SAAS,GAAG,IAAI;IACtF,MAAM,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,4BAA4B,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/F,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,4BAA4B,CAAC,CAAC;IACtE,IAAI,CAAC,MAAM,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,+CAA+C,IAAI,SAAS,SAAS,GAAG,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAEtC,IAAY,EACZ,WAAW,GAAG,IAAI,EAClB,gBAA+B,SAAS;IAExC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,aAAa,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CACb,IAAI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