appium-ios-device 3.1.11 → 3.1.13

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 (174) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/index.js +7 -8
  3. package/build/lib/afc/index.d.ts +2 -2
  4. package/build/lib/afc/index.d.ts.map +1 -1
  5. package/build/lib/afc/index.js +20 -21
  6. package/build/lib/afc/index.js.map +1 -1
  7. package/build/lib/afc/protocol.d.ts +12 -2
  8. package/build/lib/afc/protocol.d.ts.map +1 -1
  9. package/build/lib/afc/protocol.js +17 -12
  10. package/build/lib/afc/protocol.js.map +1 -1
  11. package/build/lib/afc/transformer/afcdecoder.d.ts +1 -1
  12. package/build/lib/afc/transformer/afcdecoder.d.ts.map +1 -1
  13. package/build/lib/afc/transformer/afcdecoder.js.map +1 -1
  14. package/build/lib/afc/transformer/afcencoder.d.ts +1 -1
  15. package/build/lib/afc/transformer/afcencoder.d.ts.map +1 -1
  16. package/build/lib/afc/transformer/afcencoder.js.map +1 -1
  17. package/build/lib/base-service.js.map +1 -1
  18. package/build/lib/constants.d.ts.map +1 -1
  19. package/build/lib/constants.js +2 -4
  20. package/build/lib/constants.js.map +1 -1
  21. package/build/lib/house-arrest/index.d.ts +2 -2
  22. package/build/lib/house-arrest/index.d.ts.map +1 -1
  23. package/build/lib/house-arrest/index.js +2 -3
  24. package/build/lib/house-arrest/index.js.map +1 -1
  25. package/build/lib/imagemounter/index.d.ts +1 -1
  26. package/build/lib/imagemounter/index.d.ts.map +1 -1
  27. package/build/lib/imagemounter/index.js +27 -28
  28. package/build/lib/imagemounter/index.js.map +1 -1
  29. package/build/lib/imagemounter/utils/list_developer_image.d.ts +10 -15
  30. package/build/lib/imagemounter/utils/list_developer_image.d.ts.map +1 -1
  31. package/build/lib/imagemounter/utils/list_developer_image.js +43 -43
  32. package/build/lib/imagemounter/utils/list_developer_image.js.map +1 -1
  33. package/build/lib/installation-proxy/index.d.ts +2 -2
  34. package/build/lib/installation-proxy/index.d.ts.map +1 -1
  35. package/build/lib/installation-proxy/index.js +2 -3
  36. package/build/lib/installation-proxy/index.js.map +1 -1
  37. package/build/lib/instrument/headers.d.ts +75 -100
  38. package/build/lib/instrument/headers.d.ts.map +1 -1
  39. package/build/lib/instrument/headers.js +78 -83
  40. package/build/lib/instrument/headers.js.map +1 -1
  41. package/build/lib/instrument/index.d.ts +7 -11
  42. package/build/lib/instrument/index.d.ts.map +1 -1
  43. package/build/lib/instrument/index.js +18 -20
  44. package/build/lib/instrument/index.js.map +1 -1
  45. package/build/lib/instrument/transformer/dtx-decode.js.map +1 -1
  46. package/build/lib/instrument/transformer/dtx-encode.js.map +1 -1
  47. package/build/lib/instrument/transformer/nskeyed.d.ts +30 -30
  48. package/build/lib/instrument/transformer/nskeyed.d.ts.map +1 -1
  49. package/build/lib/instrument/transformer/nskeyed.js +45 -45
  50. package/build/lib/instrument/transformer/nskeyed.js.map +1 -1
  51. package/build/lib/lockdown/index.d.ts +2 -2
  52. package/build/lib/lockdown/index.d.ts.map +1 -1
  53. package/build/lib/lockdown/index.js +2 -3
  54. package/build/lib/lockdown/index.js.map +1 -1
  55. package/build/lib/mcinstall/index.d.ts +2 -2
  56. package/build/lib/mcinstall/index.d.ts.map +1 -1
  57. package/build/lib/mcinstall/index.js +8 -9
  58. package/build/lib/mcinstall/index.js.map +1 -1
  59. package/build/lib/notification-proxy/index.d.ts +2 -2
  60. package/build/lib/notification-proxy/index.d.ts.map +1 -1
  61. package/build/lib/notification-proxy/index.js +2 -3
  62. package/build/lib/notification-proxy/index.js.map +1 -1
  63. package/build/lib/plist-service/index.d.ts +1 -1
  64. package/build/lib/plist-service/index.d.ts.map +1 -1
  65. package/build/lib/plist-service/index.js.map +1 -1
  66. package/build/lib/plist-service/transformer/plist-service-decoder.d.ts +1 -1
  67. package/build/lib/plist-service/transformer/plist-service-decoder.d.ts.map +1 -1
  68. package/build/lib/plist-service/transformer/plist-service-decoder.js.map +1 -1
  69. package/build/lib/plist-service/transformer/plist-service-encoder.d.ts +1 -1
  70. package/build/lib/plist-service/transformer/plist-service-encoder.d.ts.map +1 -1
  71. package/build/lib/plist-service/transformer/plist-service-encoder.js.map +1 -1
  72. package/build/lib/services.d.ts +94 -13
  73. package/build/lib/services.d.ts.map +1 -1
  74. package/build/lib/services.js +90 -1
  75. package/build/lib/services.js.map +1 -1
  76. package/build/lib/simulatelocation/index.d.ts +2 -2
  77. package/build/lib/simulatelocation/index.d.ts.map +1 -1
  78. package/build/lib/simulatelocation/index.js +2 -3
  79. package/build/lib/simulatelocation/index.js.map +1 -1
  80. package/build/lib/ssl-helper.d.ts +8 -2
  81. package/build/lib/ssl-helper.d.ts.map +1 -1
  82. package/build/lib/ssl-helper.js +7 -0
  83. package/build/lib/ssl-helper.js.map +1 -1
  84. package/build/lib/syslog/index.d.ts +2 -2
  85. package/build/lib/syslog/index.d.ts.map +1 -1
  86. package/build/lib/syslog/index.js +2 -3
  87. package/build/lib/syslog/index.js.map +1 -1
  88. package/build/lib/syslog/transformer/syslog-decoder.d.ts +8 -8
  89. package/build/lib/syslog/transformer/syslog-decoder.d.ts.map +1 -1
  90. package/build/lib/syslog/transformer/syslog-decoder.js +32 -32
  91. package/build/lib/syslog/transformer/syslog-decoder.js.map +1 -1
  92. package/build/lib/testmanagerd/index.d.ts +2 -2
  93. package/build/lib/testmanagerd/index.d.ts.map +1 -1
  94. package/build/lib/testmanagerd/index.js +4 -7
  95. package/build/lib/testmanagerd/index.js.map +1 -1
  96. package/build/lib/usbmux/index.d.ts +38 -38
  97. package/build/lib/usbmux/index.d.ts.map +1 -1
  98. package/build/lib/usbmux/index.js +93 -93
  99. package/build/lib/usbmux/index.js.map +1 -1
  100. package/build/lib/usbmux/transformer/usbmux-decoder.d.ts +1 -1
  101. package/build/lib/usbmux/transformer/usbmux-decoder.d.ts.map +1 -1
  102. package/build/lib/usbmux/transformer/usbmux-decoder.js.map +1 -1
  103. package/build/lib/usbmux/transformer/usbmux-encoder.d.ts +1 -1
  104. package/build/lib/usbmux/transformer/usbmux-encoder.d.ts.map +1 -1
  105. package/build/lib/usbmux/transformer/usbmux-encoder.js.map +1 -1
  106. package/build/lib/util/uuid/parse.d.ts +5 -0
  107. package/build/lib/util/uuid/parse.d.ts.map +1 -1
  108. package/build/lib/util/uuid/parse.js +5 -0
  109. package/build/lib/util/uuid/parse.js.map +1 -1
  110. package/build/lib/util/uuid/stringify.d.ts +6 -0
  111. package/build/lib/util/uuid/stringify.d.ts.map +1 -1
  112. package/build/lib/util/uuid/stringify.js +18 -12
  113. package/build/lib/util/uuid/stringify.js.map +1 -1
  114. package/build/lib/util/uuid/validate.d.ts +5 -0
  115. package/build/lib/util/uuid/validate.d.ts.map +1 -1
  116. package/build/lib/util/uuid/validate.js +5 -0
  117. package/build/lib/util/uuid/validate.js.map +1 -1
  118. package/build/lib/utilities.d.ts +58 -58
  119. package/build/lib/utilities.d.ts.map +1 -1
  120. package/build/lib/utilities.js +2 -2
  121. package/build/lib/utilities.js.map +1 -1
  122. package/build/lib/webinspector/index.d.ts +44 -39
  123. package/build/lib/webinspector/index.d.ts.map +1 -1
  124. package/build/lib/webinspector/index.js +39 -35
  125. package/build/lib/webinspector/index.js.map +1 -1
  126. package/build/lib/webinspector/transformer/webinspector-decoder.d.ts +1 -1
  127. package/build/lib/webinspector/transformer/webinspector-decoder.d.ts.map +1 -1
  128. package/build/lib/webinspector/transformer/webinspector-decoder.js.map +1 -1
  129. package/build/lib/webinspector/transformer/webinspector-encoder.d.ts +1 -1
  130. package/build/lib/webinspector/transformer/webinspector-encoder.d.ts.map +1 -1
  131. package/build/lib/webinspector/transformer/webinspector-encoder.js.map +1 -1
  132. package/build/lib/xctest.d.ts +17 -17
  133. package/build/lib/xctest.d.ts.map +1 -1
  134. package/build/lib/xctest.js.map +1 -1
  135. package/index.js +7 -9
  136. package/lib/afc/index.js +23 -24
  137. package/lib/afc/protocol.js +17 -17
  138. package/lib/afc/transformer/afcdecoder.js +1 -2
  139. package/lib/afc/transformer/afcencoder.js +1 -2
  140. package/lib/base-service.js +2 -4
  141. package/lib/constants.js +2 -4
  142. package/lib/house-arrest/index.js +2 -3
  143. package/lib/imagemounter/index.js +28 -29
  144. package/lib/imagemounter/utils/list_developer_image.js +52 -54
  145. package/lib/installation-proxy/index.js +2 -3
  146. package/lib/instrument/headers.js +74 -87
  147. package/lib/instrument/index.js +19 -21
  148. package/lib/instrument/transformer/dtx-decode.js +1 -3
  149. package/lib/instrument/transformer/dtx-encode.js +1 -3
  150. package/lib/instrument/transformer/nskeyed.js +56 -67
  151. package/lib/lockdown/index.js +2 -3
  152. package/lib/mcinstall/index.js +9 -10
  153. package/lib/notification-proxy/index.js +2 -3
  154. package/lib/plist-service/index.js +1 -2
  155. package/lib/plist-service/transformer/plist-service-decoder.js +1 -2
  156. package/lib/plist-service/transformer/plist-service-encoder.js +1 -2
  157. package/lib/services.js +101 -26
  158. package/lib/simulatelocation/index.js +2 -3
  159. package/lib/ssl-helper.js +9 -4
  160. package/lib/syslog/index.js +2 -3
  161. package/lib/syslog/transformer/syslog-decoder.js +35 -36
  162. package/lib/testmanagerd/index.js +4 -11
  163. package/lib/usbmux/index.js +111 -112
  164. package/lib/usbmux/transformer/usbmux-decoder.js +1 -2
  165. package/lib/usbmux/transformer/usbmux-encoder.js +1 -2
  166. package/lib/util/uuid/parse.ts +5 -0
  167. package/lib/util/uuid/stringify.ts +21 -15
  168. package/lib/util/uuid/validate.ts +5 -0
  169. package/lib/utilities.js +10 -23
  170. package/lib/webinspector/index.js +47 -43
  171. package/lib/webinspector/transformer/webinspector-decoder.js +1 -2
  172. package/lib/webinspector/transformer/webinspector-encoder.js +1 -2
  173. package/lib/xctest.js +1 -2
  174. package/package.json +3 -3
@@ -13,9 +13,9 @@ const WAIT_REPLY_TIME_MS = 10000;
13
13
  const CHANNEL_CANCELED = '_channelCanceled';
14
14
  const CHANNEL_OFFSET = 2 ** 32;
15
15
 
16
- const INSTRUMENT_SERVICE_NAME_VERSION_14 =
16
+ export const INSTRUMENT_SERVICE_NAME_VERSION_14 =
17
17
  'com.apple.instruments.remoteserver.DVTSecureSocketProxy';
18
- const INSTRUMENT_SERVICE_NAME = 'com.apple.instruments.remoteserver';
18
+ export const INSTRUMENT_SERVICE_NAME = 'com.apple.instruments.remoteserver';
19
19
 
20
20
  export const INSTRUMENT_CHANNEL = Object.freeze({
21
21
  DEVICE_INFO: 'com.apple.instruments.server.services.deviceinfo',
@@ -28,23 +28,7 @@ export const INSTRUMENT_CHANNEL = Object.freeze({
28
28
  CONDITION_INDUCER: 'com.apple.instruments.server.services.ConditionInducer',
29
29
  });
30
30
 
31
- function defaultDict(createValue) {
32
- return Proxy.revocable(Object.create(null), {
33
- get(storage, property) {
34
- if (!(property in storage)) {
35
- storage[property] = createValue(property);
36
- }
37
- return storage[property];
38
- },
39
- });
40
- }
41
-
42
- /** The callback function which will be called during the data transmission in instrument serve
43
- * @callback DTXCallback
44
- * @param {DTXMessage} object
45
- */
46
-
47
- class InstrumentService extends BaseServiceSocket {
31
+ export class InstrumentService extends BaseServiceSocket {
48
32
  /**
49
33
  * @param {import('net').Socket} socketClient DTXMessage.selector
50
34
  * @param {DTXCallback?} event if empty will ignore any messages
@@ -167,7 +151,7 @@ class InstrumentService extends BaseServiceSocket {
167
151
  );
168
152
  } catch (err) {
169
153
  this.close();
170
- throw new Error(err);
154
+ throw new Error(String(err), {cause: err});
171
155
  }
172
156
  }
173
157
  }
@@ -223,4 +207,18 @@ class InstrumentService extends BaseServiceSocket {
223
207
  }
224
208
  }
225
209
 
226
- export {InstrumentService, INSTRUMENT_SERVICE_NAME_VERSION_14, INSTRUMENT_SERVICE_NAME};
210
+ /** The callback function which will be called during the data transmission in instrument serve
211
+ * @callback DTXCallback
212
+ * @param {DTXMessage} object
213
+ */
214
+
215
+ function defaultDict(createValue) {
216
+ return Proxy.revocable(Object.create(null), {
217
+ get(storage, property) {
218
+ if (!(property in storage)) {
219
+ storage[property] = createValue(property);
220
+ }
221
+ return storage[property];
222
+ },
223
+ });
224
+ }
@@ -8,7 +8,7 @@ import {
8
8
  } from '../headers';
9
9
  import {log} from '../../logger';
10
10
 
11
- class DTXDecoder extends Stream.Transform {
11
+ export class DTXDecoder extends Stream.Transform {
12
12
  constructor() {
13
13
  super({objectMode: true});
14
14
  this._dtxManager = {};
@@ -89,5 +89,3 @@ class DTXDecoder extends Stream.Transform {
89
89
  return buf;
90
90
  }
91
91
  }
92
-
93
- export {DTXDecoder};
@@ -1,7 +1,7 @@
1
1
  import Stream from 'node:stream';
2
2
  import {DTXMessage, DTXMessageAux} from '../headers';
3
3
 
4
- class DTXEncoder extends Stream.Transform {
4
+ export class DTXEncoder extends Stream.Transform {
5
5
  constructor() {
6
6
  super({objectMode: true});
7
7
  }
@@ -27,5 +27,3 @@ class DTXEncoder extends Stream.Transform {
27
27
  return dtx.build();
28
28
  }
29
29
  }
30
-
31
- export {DTXEncoder};
@@ -59,7 +59,7 @@ class ArchivingObject {
59
59
  * This class must be inherited when creating an archive/unarchive subclass
60
60
  * And you need to call `updateNSKeyedArchiveClass` add subclass to archive/unarchive object
61
61
  */
62
- class BaseArchiveHandler {
62
+ export class BaseArchiveHandler {
63
63
  /**
64
64
  * some of the classes may have to add 'NSObject' or maybe more in $classes while encoding.
65
65
  */
@@ -136,7 +136,55 @@ class NSException extends BaseArchiveHandler {
136
136
  }
137
137
  }
138
138
 
139
- class NSURL extends BaseArchiveHandler {
139
+ class NSMutableString extends BaseArchiveHandler {
140
+ decodeArchive(archive) {
141
+ return archive.decode('NS.string');
142
+ }
143
+ }
144
+
145
+ class NSMutableData extends BaseArchiveHandler {
146
+ decodeArchive(archive) {
147
+ return archive.decode('NS.data');
148
+ }
149
+ }
150
+
151
+ class XCTCapabilities extends BaseArchiveHandler {
152
+ decodeArchive(archive) {
153
+ return archive.decode('capabilities-dictionary');
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Some of the plist classes may not be included and should not be cared.
159
+ * Using this as a default decoder for unknown entities to avoid interrupting decode process.
160
+ */
161
+ class NSIgnore extends BaseArchiveHandler {
162
+ decodeArchive() {
163
+ return null;
164
+ }
165
+ }
166
+
167
+ class NSNull extends BaseArchiveHandler {
168
+ constructor() {
169
+ super();
170
+ this.additionClasses = [NS_OBJECT];
171
+ }
172
+ decodeArchive() {
173
+ return null;
174
+ }
175
+ }
176
+
177
+ class XCActivityRecord extends BaseArchiveHandler {
178
+ static _keys = ['activityType', 'attachments', 'finish', 'start', 'title', 'uuid'];
179
+ decodeArchive(archive) {
180
+ return XCActivityRecord._keys.reduce((acc, key) => {
181
+ acc[key] = archive.decode(key);
182
+ return acc;
183
+ }, {});
184
+ }
185
+ }
186
+
187
+ export class NSURL extends BaseArchiveHandler {
140
188
  /**
141
189
  * @param {*} base
142
190
  * @param {string} relative usually ios device relative path e.g: file://xx/
@@ -162,7 +210,7 @@ class NSURL extends BaseArchiveHandler {
162
210
  }
163
211
  }
164
212
 
165
- class NSDate extends BaseArchiveHandler {
213
+ export class NSDate extends BaseArchiveHandler {
166
214
  /**
167
215
  * @param {number} data timestamp in seconds
168
216
  */
@@ -180,19 +228,7 @@ class NSDate extends BaseArchiveHandler {
180
228
  }
181
229
  }
182
230
 
183
- class NSMutableString extends BaseArchiveHandler {
184
- decodeArchive(archive) {
185
- return archive.decode('NS.string');
186
- }
187
- }
188
-
189
- class NSMutableData extends BaseArchiveHandler {
190
- decodeArchive(archive) {
191
- return archive.decode('NS.data');
192
- }
193
- }
194
-
195
- class NSUUID extends BaseArchiveHandler {
231
+ export class NSUUID extends BaseArchiveHandler {
196
232
  /**
197
233
  * @param {string} data uuid format data e.g:00000000-0000-0000-0000-000000000000
198
234
  */
@@ -211,32 +247,6 @@ class NSUUID extends BaseArchiveHandler {
211
247
  }
212
248
  }
213
249
 
214
- class XCTCapabilities extends BaseArchiveHandler {
215
- decodeArchive(archive) {
216
- return archive.decode('capabilities-dictionary');
217
- }
218
- }
219
-
220
- /**
221
- * Some of the plist classes may not be included and should not be cared.
222
- * Using this as a default decoder for unknown entities to avoid interrupting decode process.
223
- */
224
- class NSIgnore extends BaseArchiveHandler {
225
- decodeArchive() {
226
- return null;
227
- }
228
- }
229
-
230
- class NSNull extends BaseArchiveHandler {
231
- constructor() {
232
- super();
233
- this.additionClasses = [NS_OBJECT];
234
- }
235
- decodeArchive() {
236
- return null;
237
- }
238
- }
239
-
240
250
  /**
241
251
  * @typedef {Object} XCTestConfigurationPlist
242
252
  * @property {string | NSURL} testBundleURL
@@ -247,7 +257,7 @@ class NSNull extends BaseArchiveHandler {
247
257
  * @property {string[]?} testsToRun
248
258
  * @property {string[]?} testsToSkip
249
259
  */
250
- class XCTestConfiguration extends BaseArchiveHandler {
260
+ export class XCTestConfiguration extends BaseArchiveHandler {
251
261
  static _default = {
252
262
  aggregateStatisticsBeforeCrash: {
253
263
  XCSuiteRecordsKey: {},
@@ -321,16 +331,6 @@ class XCTestConfiguration extends BaseArchiveHandler {
321
331
  }
322
332
  }
323
333
 
324
- class XCActivityRecord extends BaseArchiveHandler {
325
- static _keys = ['activityType', 'attachments', 'finish', 'start', 'title', 'uuid'];
326
- decodeArchive(archive) {
327
- return XCActivityRecord._keys.reduce((acc, key) => {
328
- acc[key] = archive.decode(key);
329
- return acc;
330
- }, {});
331
- }
332
- }
333
-
334
334
  /**
335
335
  * decode and encode Archive of currently known data formats
336
336
  */
@@ -559,7 +559,7 @@ class Archive {
559
559
  * @param {Object} inputObject
560
560
  * @returns {Buffer} NSKeyed Buffer
561
561
  */
562
- function archive(inputObject) {
562
+ export function archive(inputObject) {
563
563
  return new Archive(inputObject).toBytes();
564
564
  }
565
565
 
@@ -568,7 +568,7 @@ function archive(inputObject) {
568
568
  * @param {Buffer} inputBytes NSKeyed Buffer
569
569
  * @returns {Object} JS Object
570
570
  */
571
- function unarchive(inputBytes) {
571
+ export function unarchive(inputBytes) {
572
572
  return new Unarchive(inputBytes).toObject();
573
573
  }
574
574
 
@@ -577,7 +577,7 @@ function unarchive(inputBytes) {
577
577
  * @param {String} name packing/unpacking key name
578
578
  * @param {BaseArchiveHandler} subClass inherit from BaseArchiveHandler class
579
579
  */
580
- function updateNSKeyedArchiveClass(name, subClass) {
580
+ export function updateNSKeyedArchiveClass(name, subClass) {
581
581
  if (
582
582
  // @ts-ignore prototype always exists
583
583
  !_.isFunction(subClass.prototype?.decodeArchive) &&
@@ -590,14 +590,3 @@ function updateNSKeyedArchiveClass(name, subClass) {
590
590
  UNARCHIVE_CLASS_MAP[name] = subClass;
591
591
  }
592
592
  }
593
-
594
- export {
595
- updateNSKeyedArchiveClass,
596
- BaseArchiveHandler,
597
- NSURL,
598
- NSUUID,
599
- NSDate,
600
- XCTestConfiguration,
601
- unarchive,
602
- archive,
603
- };
@@ -1,11 +1,11 @@
1
1
  import _ from 'lodash';
2
2
  import {BaseServicePlist} from '../base-service';
3
3
 
4
- const LOCKDOWN_PORT = 62078;
4
+ export const LOCKDOWN_PORT = 62078;
5
5
  const LABEL = 'usbmuxd';
6
6
  const PROTOCOL_VERSION = 2;
7
7
 
8
- class Lockdown extends BaseServicePlist {
8
+ export class Lockdown extends BaseServicePlist {
9
9
  /**
10
10
  * Makes a query type request to lockdown
11
11
  * @param {number} [timeout=5000] the timeout of receiving a response from lockdownd
@@ -118,5 +118,4 @@ class Lockdown extends BaseServicePlist {
118
118
  }
119
119
  }
120
120
 
121
- export {Lockdown, LOCKDOWN_PORT};
122
121
  export default Lockdown;
@@ -1,17 +1,10 @@
1
1
  import {BaseServicePlist} from '../base-service';
2
2
  import {fs, plist} from '@appium/support';
3
3
 
4
- const MC_INSTALL_SERVICE_NAME = 'com.apple.mobile.MCInstall';
4
+ export const MC_INSTALL_SERVICE_NAME = 'com.apple.mobile.MCInstall';
5
5
  const ACKNOWLEDGED = 'Acknowledged';
6
6
 
7
- function checkACK(res, name) {
8
- if (res.Status !== ACKNOWLEDGED) {
9
- throw new Error(`${name} error: ${JSON.stringify(res)}`);
10
- }
11
- return res;
12
- }
13
-
14
- class MCInstallProxyService extends BaseServicePlist {
7
+ export class MCInstallProxyService extends BaseServicePlist {
15
8
  constructor(socketClient) {
16
9
  super(socketClient);
17
10
  }
@@ -92,5 +85,11 @@ class MCInstallProxyService extends BaseServicePlist {
92
85
  }
93
86
  }
94
87
 
95
- export {MCInstallProxyService, MC_INSTALL_SERVICE_NAME};
88
+ function checkACK(res, name) {
89
+ if (res.Status !== ACKNOWLEDGED) {
90
+ throw new Error(`${name} error: ${JSON.stringify(res)}`);
91
+ }
92
+ return res;
93
+ }
94
+
96
95
  export default MCInstallProxyService;
@@ -6,13 +6,13 @@ import _ from 'lodash';
6
6
  import {BaseServiceSocket} from '../base-service';
7
7
  import {getMaxFrameLength} from '../utilities';
8
8
 
9
- const NOTIFICATION_PROXY_SERVICE_NAME = 'com.apple.mobile.notification_proxy';
9
+ export const NOTIFICATION_PROXY_SERVICE_NAME = 'com.apple.mobile.notification_proxy';
10
10
  const MAX_FRAME_SIZE = 16 * KB;
11
11
 
12
12
  const RELAY_NOTIFICATION = 'RelayNotification';
13
13
  const PROXY_DEATH = 'ProxyDeath';
14
14
 
15
- class NotificationProxyService extends BaseServiceSocket {
15
+ export class NotificationProxyService extends BaseServiceSocket {
16
16
  constructor(socketClient) {
17
17
  super(socketClient);
18
18
 
@@ -108,4 +108,3 @@ class NotificationProxyService extends BaseServiceSocket {
108
108
  }
109
109
 
110
110
  export default NotificationProxyService;
111
- export {NotificationProxyService, NOTIFICATION_PROXY_SERVICE_NAME};
@@ -11,7 +11,7 @@ const MAX_FRAME_SIZE = 1 * MB;
11
11
 
12
12
  const CHECK_FREQ_MS = 50;
13
13
 
14
- class PlistService extends BaseServiceSocket {
14
+ export class PlistService extends BaseServiceSocket {
15
15
  constructor(socketClient) {
16
16
  super(socketClient);
17
17
 
@@ -78,5 +78,4 @@ class PlistService extends BaseServiceSocket {
78
78
  }
79
79
  }
80
80
 
81
- export {PlistService};
82
81
  export default PlistService;
@@ -4,7 +4,7 @@ import {plist} from '@appium/support';
4
4
 
5
5
  const HEADER_LENGTH = 4;
6
6
 
7
- class PlistServiceDecoder extends Stream.Transform {
7
+ export class PlistServiceDecoder extends Stream.Transform {
8
8
  constructor() {
9
9
  super({objectMode: true});
10
10
  }
@@ -27,5 +27,4 @@ class PlistServiceDecoder extends Stream.Transform {
27
27
  }
28
28
  }
29
29
 
30
- export {PlistServiceDecoder};
31
30
  export default PlistServiceDecoder;
@@ -3,7 +3,7 @@ import {plist} from '@appium/support';
3
3
 
4
4
  const HEADER_LENGTH = 4;
5
5
 
6
- class PlistServiceEncoder extends Stream.Transform {
6
+ export class PlistServiceEncoder extends Stream.Transform {
7
7
  constructor() {
8
8
  super({objectMode: true});
9
9
  }
@@ -21,5 +21,4 @@ class PlistServiceEncoder extends Stream.Transform {
21
21
  }
22
22
  }
23
23
 
24
- export {PlistServiceEncoder};
25
24
  export default PlistServiceEncoder;
package/lib/services.js CHANGED
@@ -25,17 +25,35 @@ const CRASH_LOG_SERVICE_NAME = 'com.apple.crashreportcopymobile';
25
25
  const INSTRUMENT_HANDSHAKE_VERSION = 14;
26
26
  const TESTMANAGERD_HANDSHAKE_VERSION = 14;
27
27
 
28
- async function startSyslogService(udid, opts = {}) {
28
+ /**
29
+ * Starts the syslog service.
30
+ * @param {string} udid
31
+ * @param {ServiceOpts=} opts
32
+ * @returns {Promise<SyslogService>}
33
+ */
34
+ export async function startSyslogService(udid, opts = {}) {
29
35
  const socket = await startService(udid, SYSLOG_SERVICE_NAME, opts.socket);
30
36
  return new SyslogService(socket);
31
37
  }
32
38
 
33
- async function startSimulateLocationService(udid, opts = {}) {
39
+ /**
40
+ * Starts the simulate-location service.
41
+ * @param {string} udid
42
+ * @param {ServiceOpts=} opts
43
+ * @returns {Promise<SimulateLocationService>}
44
+ */
45
+ export async function startSimulateLocationService(udid, opts = {}) {
34
46
  const socket = await startService(udid, SIMULATE_LOCATION_SERVICE_NAME, opts.socket);
35
47
  return new SimulateLocationService(socket);
36
48
  }
37
49
 
38
- async function startWebInspectorService(udid, opts = {}) {
50
+ /**
51
+ * Starts the web inspector service.
52
+ * @param {string} udid
53
+ * @param {ServiceOpts=} opts
54
+ * @returns {Promise<WebInspectorService>}
55
+ */
56
+ export async function startWebInspectorService(udid, opts = {}) {
39
57
  const osVersion = opts.osVersion || (await getOSVersion(udid, opts.socket));
40
58
  const isSimulator = !!opts.isSimulator;
41
59
  const verbose = !!opts.verbose;
@@ -69,32 +87,68 @@ async function startWebInspectorService(udid, opts = {}) {
69
87
  });
70
88
  }
71
89
 
72
- async function startInstallationProxyService(udid, opts = {}) {
90
+ /**
91
+ * Starts the installation proxy service.
92
+ * @param {string} udid
93
+ * @param {ServiceOpts=} opts
94
+ * @returns {Promise<InstallationProxyService>}
95
+ */
96
+ export async function startInstallationProxyService(udid, opts = {}) {
73
97
  const socket = await startService(udid, INSTALLATION_PROXY_SERVICE_NAME, opts.socket);
74
98
  return new InstallationProxyService(new PlistService(socket));
75
99
  }
76
100
 
77
- async function startAfcService(udid, opts = {}) {
101
+ /**
102
+ * Starts the AFC service.
103
+ * @param {string} udid
104
+ * @param {ServiceOpts=} opts
105
+ * @returns {Promise<AfcService>}
106
+ */
107
+ export async function startAfcService(udid, opts = {}) {
78
108
  const socket = await startService(udid, AFC_SERVICE_NAME, opts.socket);
79
109
  return new AfcService(socket);
80
110
  }
81
111
 
82
- async function startCrashLogService(udid, opts = {}) {
112
+ /**
113
+ * Starts the crash log service.
114
+ * @param {string} udid
115
+ * @param {ServiceOpts=} opts
116
+ * @returns {Promise<AfcService>}
117
+ */
118
+ export async function startCrashLogService(udid, opts = {}) {
83
119
  const socket = await startService(udid, CRASH_LOG_SERVICE_NAME, opts.socket);
84
120
  return new AfcService(socket);
85
121
  }
86
122
 
87
- async function startNotificationProxyService(udid, opts = {}) {
123
+ /**
124
+ * Starts the notification proxy service.
125
+ * @param {string} udid
126
+ * @param {ServiceOpts=} opts
127
+ * @returns {Promise<NotificationProxyService>}
128
+ */
129
+ export async function startNotificationProxyService(udid, opts = {}) {
88
130
  const socket = await startService(udid, NOTIFICATION_PROXY_SERVICE_NAME, opts.socket);
89
131
  return new NotificationProxyService(socket);
90
132
  }
91
133
 
92
- async function startHouseArrestService(udid, opts = {}) {
134
+ /**
135
+ * Starts the house arrest service.
136
+ * @param {string} udid
137
+ * @param {ServiceOpts=} opts
138
+ * @returns {Promise<HouseArrestService>}
139
+ */
140
+ export async function startHouseArrestService(udid, opts = {}) {
93
141
  const socket = await startService(udid, HOUSE_ARREST_SERVICE_NAME, opts.socket);
94
142
  return new HouseArrestService(socket);
95
143
  }
96
144
 
97
- async function startInstrumentService(udid, opts = {}) {
145
+ /**
146
+ * Starts the instrument service.
147
+ * @param {string} udid
148
+ * @param {ServiceOpts=} opts
149
+ * @returns {Promise<InstrumentService>}
150
+ */
151
+ export async function startInstrumentService(udid, opts = {}) {
98
152
  const osVersion = opts.osVersion || (await getOSVersion(udid, opts.socket));
99
153
  return new InstrumentService(
100
154
  parseInt(osVersion.split('.')[0], 10) < INSTRUMENT_HANDSHAKE_VERSION
@@ -103,7 +157,13 @@ async function startInstrumentService(udid, opts = {}) {
103
157
  );
104
158
  }
105
159
 
106
- async function startTestmanagerdService(udid, opts = {}) {
160
+ /**
161
+ * Starts the testmanagerd service.
162
+ * @param {string} udid
163
+ * @param {ServiceOpts=} opts
164
+ * @returns {Promise<TestmanagerdService>}
165
+ */
166
+ export async function startTestmanagerdService(udid, opts = {}) {
107
167
  const osVersion = opts.osVersion || (await getOSVersion(udid, opts.socket));
108
168
  return new TestmanagerdService(
109
169
  parseInt(osVersion.split('.')[0], 10) < TESTMANAGERD_HANDSHAKE_VERSION
@@ -112,16 +172,35 @@ async function startTestmanagerdService(udid, opts = {}) {
112
172
  );
113
173
  }
114
174
 
115
- async function startMCInstallService(udid, opts = {}) {
175
+ /**
176
+ * Starts the MCInstall proxy service.
177
+ * @param {string} udid
178
+ * @param {ServiceOpts=} opts
179
+ * @returns {Promise<MCInstallProxyService>}
180
+ */
181
+ export async function startMCInstallService(udid, opts = {}) {
116
182
  const socket = await startService(udid, MC_INSTALL_SERVICE_NAME, opts.socket);
117
183
  return new MCInstallProxyService(new PlistService(socket));
118
184
  }
119
185
 
120
- async function startImageMounterService(udid, opts = {}) {
186
+ /**
187
+ * Starts the image mounter service.
188
+ * @param {string} udid
189
+ * @param {ServiceOpts=} opts
190
+ * @returns {Promise<ImageMounter>}
191
+ */
192
+ export async function startImageMounterService(udid, opts = {}) {
121
193
  const socket = await startService(udid, MOBILE_IMAGE_MOUNTER_SERVICE_NAME, opts.socket, false);
122
194
  return new ImageMounter(new PlistService(socket));
123
195
  }
124
196
 
197
+ /**
198
+ * @param {string} udid
199
+ * @param {string} serviceName
200
+ * @param {import('net').Socket=} socket
201
+ * @param {boolean=} handshakeOnly
202
+ * @returns {Promise<import('net').Socket>}
203
+ */
125
204
  async function startService(udid, serviceName, socket, handshakeOnly = false) {
126
205
  const lockdown = await startLockdownSession(udid, socket);
127
206
  try {
@@ -136,17 +215,13 @@ async function startService(udid, serviceName, socket, handshakeOnly = false) {
136
215
  }
137
216
  }
138
217
 
139
- export {
140
- startSyslogService,
141
- startWebInspectorService,
142
- startInstallationProxyService,
143
- startSimulateLocationService,
144
- startAfcService,
145
- startCrashLogService,
146
- startNotificationProxyService,
147
- startHouseArrestService,
148
- startInstrumentService,
149
- startTestmanagerdService,
150
- startMCInstallService,
151
- startImageMounterService,
152
- };
218
+ /**
219
+ * @typedef {Object} ServiceOpts
220
+ * @property {import('net').Socket=} socket
221
+ * @property {string=} osVersion
222
+ * @property {boolean=} isSimulator
223
+ * @property {boolean=} verbose
224
+ * @property {boolean=} verboseHexDump
225
+ * @property {number=} socketChunkSize
226
+ * @property {number=} maxFrameLength
227
+ */
@@ -1,11 +1,11 @@
1
1
  import {BaseServiceSocket} from '../base-service';
2
2
 
3
- const SIMULATE_LOCATION_SERVICE_NAME = 'com.apple.dt.simulatelocation';
3
+ export const SIMULATE_LOCATION_SERVICE_NAME = 'com.apple.dt.simulatelocation';
4
4
 
5
5
  const RESET_MESSAGE = Buffer.from([0, 0, 0, 1]);
6
6
  const SET_LOCATION_MESSAGE = Buffer.from([0, 0, 0, 0]);
7
7
 
8
- class SimulateLocationService extends BaseServiceSocket {
8
+ export class SimulateLocationService extends BaseServiceSocket {
9
9
  /**
10
10
  * Reset the mock location to the phones original settings
11
11
  */
@@ -38,5 +38,4 @@ class SimulateLocationService extends BaseServiceSocket {
38
38
  }
39
39
  }
40
40
 
41
- export {SimulateLocationService, SIMULATE_LOCATION_SERVICE_NAME};
42
41
  export default SimulateLocationService;
package/lib/ssl-helper.js CHANGED
@@ -4,7 +4,14 @@ import B from 'bluebird';
4
4
 
5
5
  const HANDSHAKE_TIMEOUT_MS = 10000;
6
6
 
7
- function upgradeToSSL(socket, key, cert) {
7
+ /**
8
+ * Wraps an existing socket in a TLS socket.
9
+ * @param {import('net').Socket} socket
10
+ * @param {Buffer|string} key
11
+ * @param {Buffer|string} cert
12
+ * @returns {import('node:tls').TLSSocket}
13
+ */
14
+ export function upgradeToSSL(socket, key, cert) {
8
15
  return new tls.TLSSocket(socket, {
9
16
  rejectUnauthorized: false,
10
17
  secureContext: tls.createSecureContext({
@@ -21,7 +28,7 @@ function upgradeToSSL(socket, key, cert) {
21
28
  * @param cert
22
29
  * @returns {Promise<NodeJS.Socket>} Duplicate the input socket
23
30
  */
24
- async function enableSSLHandshakeOnly(socket, key, cert) {
31
+ export async function enableSSLHandshakeOnly(socket, key, cert) {
25
32
  const sslSocket = tls.connect({
26
33
  socket,
27
34
  secureContext: tls.createSecureContext({
@@ -50,5 +57,3 @@ async function enableSSLHandshakeOnly(socket, key, cert) {
50
57
  // Duplicate the socket. Return a new socket object connected to the same system resource
51
58
  return new net.Socket({fd: socket._handle.fd});
52
59
  }
53
-
54
- export {upgradeToSSL, enableSSLHandshakeOnly};
@@ -3,10 +3,10 @@ import {KB} from '../constants';
3
3
  import {BaseServiceSocket} from '../base-service';
4
4
 
5
5
  //We just need to write any data to the client. It doesn't matter what we send
6
- const SYSLOG_SERVICE_NAME = 'com.apple.syslog_relay';
6
+ export const SYSLOG_SERVICE_NAME = 'com.apple.syslog_relay';
7
7
  const START_MESSAGE = 'start';
8
8
 
9
- class SyslogService extends BaseServiceSocket {
9
+ export class SyslogService extends BaseServiceSocket {
10
10
  constructor(socketClient) {
11
11
  super(socketClient);
12
12
 
@@ -29,5 +29,4 @@ class SyslogService extends BaseServiceSocket {
29
29
  }
30
30
  }
31
31
 
32
- export {SyslogService, SYSLOG_SERVICE_NAME};
33
32
  export default SyslogService;