appium-ios-device 3.1.12 → 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 +6 -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 +1 -1
package/index.js CHANGED
@@ -1,9 +1,7 @@
1
- import { default as Usbmux } from './lib/usbmux';
2
- import * as utilities from './lib/utilities';
3
- import * as services from './lib/services';
4
-
5
- export { Usbmux, utilities, services };
6
- export { INSTRUMENT_CHANNEL } from './lib/instrument';
7
- export { TESTMANAGERD_CHANNEL } from './lib/testmanagerd';
8
- export { Xctest } from './lib/xctest';
9
- export default Usbmux;
1
+ export {default as Usbmux} from './lib/usbmux';
2
+ export * as utilities from './lib/utilities';
3
+ export * as services from './lib/services';
4
+ export {INSTRUMENT_CHANNEL} from './lib/instrument';
5
+ export {TESTMANAGERD_CHANNEL} from './lib/testmanagerd';
6
+ export {Xctest} from './lib/xctest';
7
+ export {default} from './lib/usbmux';
package/lib/afc/index.js CHANGED
@@ -10,13 +10,34 @@ import _ from 'lodash';
10
10
  import {BaseServiceSocket} from '../base-service';
11
11
  import {getMaxFrameLength} from '../utilities';
12
12
 
13
- const AFC_SERVICE_NAME = 'com.apple.afc';
13
+ export const AFC_SERVICE_NAME = 'com.apple.afc';
14
14
  const MAX_FRAME_SIZE = 1 * MB;
15
15
 
16
16
  const NULL_DELIMITER_CODE = 0x00;
17
17
  const IGNORED_PATHS = ['.', '..'];
18
18
 
19
- class AfcService extends BaseServiceSocket {
19
+ class FileInfo {
20
+ constructor({st_size, st_blocks, st_nlink, st_ifmt, st_mtime, st_birthtime}) {
21
+ this.size = parseInt(st_size, 10);
22
+ this.blocks = parseInt(st_blocks, 10);
23
+ this.nlink = parseInt(st_nlink, 10);
24
+ this.ifmt = st_ifmt;
25
+ // ns to ms
26
+ this.mtimeMs = parseInt(st_mtime, 10) / 1000000;
27
+ // ns to ms
28
+ this.birthtimeMs = parseInt(st_birthtime, 10) / 1000000;
29
+ }
30
+
31
+ isDirectory() {
32
+ return this.ifmt === 'S_IFDIR';
33
+ }
34
+
35
+ isFile() {
36
+ return this.ifmt === 'S_IFREG';
37
+ }
38
+ }
39
+
40
+ export class AfcService extends BaseServiceSocket {
20
41
  constructor(socketClient) {
21
42
  super(socketClient);
22
43
 
@@ -339,26 +360,4 @@ class AfcService extends BaseServiceSocket {
339
360
  }
340
361
  }
341
362
 
342
- class FileInfo {
343
- constructor({st_size, st_blocks, st_nlink, st_ifmt, st_mtime, st_birthtime}) {
344
- this.size = parseInt(st_size, 10);
345
- this.blocks = parseInt(st_blocks, 10);
346
- this.nlink = parseInt(st_nlink, 10);
347
- this.ifmt = st_ifmt;
348
- // ns to ms
349
- this.mtimeMs = parseInt(st_mtime, 10) / 1000000;
350
- // ns to ms
351
- this.birthtimeMs = parseInt(st_birthtime, 10) / 1000000;
352
- }
353
-
354
- isDirectory() {
355
- return this.ifmt === 'S_IFDIR';
356
- }
357
-
358
- isFile() {
359
- return this.ifmt === 'S_IFREG';
360
- }
361
- }
362
-
363
363
  export default AfcService;
364
- export {AfcService, AFC_SERVICE_NAME};
@@ -1,10 +1,10 @@
1
1
  import _ from 'lodash';
2
2
 
3
- const MAGIC_NUMBER = Buffer.from('CFA6LPAA');
3
+ export const MAGIC_NUMBER = Buffer.from('CFA6LPAA');
4
4
 
5
- const AFC_PACKET_HEADER_SIZE = 40;
5
+ export const AFC_PACKET_HEADER_SIZE = 40;
6
6
 
7
- const Operations = {
7
+ export const Operations = {
8
8
  INVALID: 0x00000000, // Invalid
9
9
  STATUS: 0x00000001, // Status
10
10
  DATA: 0x00000002, // Data
@@ -50,11 +50,16 @@ const Operations = {
50
50
 
51
51
  const Operations_Code = _.invert(Operations);
52
52
 
53
- function operationCode(code) {
53
+ /**
54
+ * Resolves an AFC operation code to its symbolic name.
55
+ * @param {number} code
56
+ * @returns {string | undefined}
57
+ */
58
+ export function operationCode(code) {
54
59
  return Operations_Code[code];
55
60
  }
56
61
 
57
- const Errors = {
62
+ export const Errors = {
58
63
  SUCCESS: 0,
59
64
  UNKNOWN: 1,
60
65
  INVALID_HEADER: 2,
@@ -83,11 +88,16 @@ const Errors = {
83
88
 
84
89
  const Errors_Code = _.invert(Errors);
85
90
 
86
- function errorCode(code) {
91
+ /**
92
+ * Resolves an AFC error code to its symbolic name.
93
+ * @param {number} code
94
+ * @returns {string | undefined}
95
+ */
96
+ export function errorCode(code) {
87
97
  return Errors_Code[code];
88
98
  }
89
99
 
90
- const FileModes = {
100
+ export const FileModes = {
91
101
  r: 0x00000001, // O_RDONLY
92
102
  'r+': 0x00000002, // O_RDWR | O_CREAT
93
103
  w: 0x00000003, // O_WRONLY | O_CREAT | O_TRUNC
@@ -95,13 +105,3 @@ const FileModes = {
95
105
  a: 0x00000005, // O_WRONLY | O_APPEND | O_CREAT
96
106
  'a+': 0x00000006, // O_RDWR | O_APPEND | O_CREAT
97
107
  };
98
-
99
- export {
100
- MAGIC_NUMBER,
101
- AFC_PACKET_HEADER_SIZE,
102
- Operations,
103
- operationCode,
104
- Errors,
105
- errorCode,
106
- FileModes,
107
- };
@@ -1,7 +1,7 @@
1
1
  import Stream from 'node:stream';
2
2
  import {MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE} from '../protocol';
3
3
 
4
- class AfcDecoder extends Stream.Transform {
4
+ export class AfcDecoder extends Stream.Transform {
5
5
  constructor() {
6
6
  super({objectMode: true});
7
7
  }
@@ -33,5 +33,4 @@ class AfcDecoder extends Stream.Transform {
33
33
  }
34
34
  }
35
35
 
36
- export {AfcDecoder};
37
36
  export default AfcDecoder;
@@ -1,7 +1,7 @@
1
1
  import Stream from 'node:stream';
2
2
  import {MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE} from '../protocol';
3
3
 
4
- class AfcEncoder extends Stream.Transform {
4
+ export class AfcEncoder extends Stream.Transform {
5
5
  constructor() {
6
6
  super({objectMode: true});
7
7
  }
@@ -34,5 +34,4 @@ class AfcEncoder extends Stream.Transform {
34
34
  }
35
35
  }
36
36
 
37
- export {AfcEncoder};
38
37
  export default AfcEncoder;
@@ -1,4 +1,4 @@
1
- class BaseServiceSocket {
1
+ export class BaseServiceSocket {
2
2
  /**
3
3
  * @param {import('net').Socket} socketClient
4
4
  */
@@ -22,7 +22,7 @@ class BaseServiceSocket {
22
22
  }
23
23
  }
24
24
 
25
- class BaseServicePlist {
25
+ export class BaseServicePlist {
26
26
  /**
27
27
  * @param {import('./plist-service').PlistService} plistService
28
28
  */
@@ -37,5 +37,3 @@ class BaseServicePlist {
37
37
  this._plistService.close();
38
38
  }
39
39
  }
40
-
41
- export {BaseServiceSocket, BaseServicePlist};
package/lib/constants.js CHANGED
@@ -1,4 +1,2 @@
1
- const KB = 1024;
2
- const MB = KB * KB;
3
-
4
- export {KB, MB};
1
+ export const KB = 1024;
2
+ export const MB = KB * KB;
@@ -7,10 +7,10 @@ import B from 'bluebird';
7
7
  import {BaseServiceSocket} from '../base-service';
8
8
  import {getMaxFrameLength} from '../utilities';
9
9
 
10
- const HOUSE_ARREST_SERVICE_NAME = 'com.apple.mobile.house_arrest';
10
+ export const HOUSE_ARREST_SERVICE_NAME = 'com.apple.mobile.house_arrest';
11
11
  const MAX_FRAME_SIZE = 1 * KB;
12
12
 
13
- class HouseArrestService extends BaseServiceSocket {
13
+ export class HouseArrestService extends BaseServiceSocket {
14
14
  constructor(socketClient) {
15
15
  super(socketClient);
16
16
 
@@ -83,5 +83,4 @@ class HouseArrestService extends BaseServiceSocket {
83
83
  }
84
84
  }
85
85
 
86
- export {HouseArrestService, HOUSE_ARREST_SERVICE_NAME};
87
86
  export default HouseArrestService;
@@ -4,37 +4,11 @@ import B from 'bluebird';
4
4
  import {log} from '../logger';
5
5
  const {lstat, readFile, createReadStream} = fs;
6
6
 
7
- const MOBILE_IMAGE_MOUNTER_SERVICE_NAME = 'com.apple.mobile.mobile_image_mounter';
7
+ export const MOBILE_IMAGE_MOUNTER_SERVICE_NAME = 'com.apple.mobile.mobile_image_mounter';
8
8
  const FILE_TYPE_IMAGE = 'image';
9
9
  const FILE_TYPE_SIGNATURE = 'signature';
10
10
 
11
- function checkIfError(ret) {
12
- if (ret.Error) {
13
- throw new Error(ret.Error);
14
- }
15
- return ret;
16
- }
17
-
18
- async function assertIsFile(filePath, fileType) {
19
- /** @type {import('fs').Stats | undefined} */
20
- let fileStat;
21
- try {
22
- fileStat = await lstat(filePath);
23
- } catch (err) {
24
- if (/** @type {NodeJS.ErrnoException} */ (err).code === 'ENOENT') {
25
- throw new Error(`The provided ${fileType} path does not exist: ${filePath}`);
26
- }
27
- throw err;
28
- }
29
- if (fileStat.isDirectory()) {
30
- throw new Error(
31
- `The provided ${fileType} path is expected to be a file, but a directory was given: ${filePath}`,
32
- );
33
- }
34
- return fileStat;
35
- }
36
-
37
- class ImageMounter extends BaseServicePlist {
11
+ export class ImageMounter extends BaseServicePlist {
38
12
  /**
39
13
  * Lookup for mounted images.
40
14
  * @param {string} imageType Type of image, `Developer` by default.
@@ -124,4 +98,29 @@ class ImageMounter extends BaseServicePlist {
124
98
  checkIfError(mountResult);
125
99
  }
126
100
  }
127
- export {ImageMounter, MOBILE_IMAGE_MOUNTER_SERVICE_NAME};
101
+
102
+ function checkIfError(ret) {
103
+ if (ret.Error) {
104
+ throw new Error(ret.Error);
105
+ }
106
+ return ret;
107
+ }
108
+
109
+ async function assertIsFile(filePath, fileType) {
110
+ /** @type {import('fs').Stats | undefined} */
111
+ let fileStat;
112
+ try {
113
+ fileStat = await lstat(filePath);
114
+ } catch (err) {
115
+ if (/** @type {NodeJS.ErrnoException} */ (err).code === 'ENOENT') {
116
+ throw new Error(`The provided ${fileType} path does not exist: ${filePath}`, {cause: err});
117
+ }
118
+ throw err;
119
+ }
120
+ if (fileStat.isDirectory()) {
121
+ throw new Error(
122
+ `The provided ${fileType} path is expected to be a file, but a directory was given: ${filePath}`,
123
+ );
124
+ }
125
+ return fileStat;
126
+ }
@@ -40,6 +40,52 @@ const DEFAULT_IMAGE_DIR_NAME = 'iOSDeviceSupport';
40
40
  const DEVELOPER_IMAGE_FILE_NAME = 'DeveloperDiskImage.dmg';
41
41
  const DEVELOPER_IMAGE_SIGNATURE_FILE_NAME = 'DeveloperDiskImage.dmg.signature';
42
42
 
43
+ /**
44
+ * Find developer image for certain version. If developer image does not exists,
45
+ * this will try to find and download developer image, unzip to `${APPIUM_HOME}/iOSSupport/`
46
+ * @param {string} version full version of iOS device. The first two parts of version
47
+ * will be preserved when sending the request, e.g. `14.7.1` will be changed to `14.7`
48
+ * @param {ImageFromGithubRepo} githubImageOption
49
+ * @returns {Promise<ImagePath>}
50
+ * @throws If developer image is not found, or error while downloading or unzipping.
51
+ */
52
+ export async function findDeveloperImage(version, githubImageOption) {
53
+ const finalVersion = version.split('.').splice(0, 2).join('.');
54
+ const fileName = `${finalVersion}.zip`;
55
+ const DEFAULT_IMAGE_DIR = joinPath(await env.resolveAppiumHome(), DEFAULT_IMAGE_DIR_NAME);
56
+ const fullDownloadPath = joinPath(DEFAULT_IMAGE_DIR, fileName);
57
+ if (!(await exists(DEFAULT_IMAGE_DIR))) {
58
+ await mkdir(DEFAULT_IMAGE_DIR, {recursive: true});
59
+ }
60
+ if (!(await exists(fullDownloadPath))) {
61
+ await searchAndDownloadDeveloperImageFromGithub(
62
+ finalVersion,
63
+ fullDownloadPath,
64
+ githubImageOption,
65
+ );
66
+ }
67
+ const decompressPath = joinPath(DEFAULT_IMAGE_DIR, finalVersion);
68
+ /** @type {string | undefined} */
69
+ let developerImageParentFolder;
70
+ if (await exists(decompressPath)) {
71
+ developerImageParentFolder = await findDeveloperImageFromDirectory(decompressPath);
72
+ }
73
+ if (!developerImageParentFolder) {
74
+ await zip.extractAllTo(fullDownloadPath, decompressPath);
75
+ developerImageParentFolder = await findDeveloperImageFromDirectory(decompressPath);
76
+ }
77
+ if (!developerImageParentFolder) {
78
+ throw new Error(`Unable to find unzipped developer image in ${decompressPath}`);
79
+ }
80
+ return {
81
+ developerImage: joinPath(developerImageParentFolder, DEVELOPER_IMAGE_FILE_NAME),
82
+ developerImageSignature: joinPath(
83
+ developerImageParentFolder,
84
+ DEVELOPER_IMAGE_SIGNATURE_FILE_NAME,
85
+ ),
86
+ };
87
+ }
88
+
43
89
  /**
44
90
  * Use list api to return the file list of folder.
45
91
  * @param {ImageFromGithubRepo} githubImageOption
@@ -84,6 +130,12 @@ async function listGithubImageList(githubImageOption) {
84
130
  }
85
131
  }
86
132
 
133
+ /**
134
+ * @typedef {Object} ImagePath
135
+ * @property {string} developerImage
136
+ * @property {string} developerImageSignature
137
+ */
138
+
87
139
  /**
88
140
  * Find `DeveloperDiskImage.dmg` recursively under folder and subfolder.
89
141
  * @param {string} entry current folder
@@ -106,58 +158,6 @@ async function findDeveloperImageFromDirectory(entry) {
106
158
  }
107
159
  }
108
160
 
109
- /**
110
- * @typedef {Object} ImagePath
111
- * @property {string} developerImage
112
- * @property {string} developerImageSignature
113
- */
114
-
115
- /**
116
- * Find developer image for certain version. If developer image does not exists,
117
- * this will try to find and download developer image, unzip to `${APPIUM_HOME}/iOSSupport/`
118
- * @param {string} version full version of iOS device. The first two parts of version
119
- * will be preserved when sending the request, e.g. `14.7.1` will be changed to `14.7`
120
- * @param {ImageFromGithubRepo} githubImageOption
121
- * @returns {Promise<ImagePath>}
122
- * @throws If developer image is not found, or error while downloading or unzipping.
123
- */
124
- async function findDeveloperImage(version, githubImageOption) {
125
- const finalVersion = version.split('.').splice(0, 2).join('.');
126
- const fileName = `${finalVersion}.zip`;
127
- const DEFAULT_IMAGE_DIR = joinPath(await env.resolveAppiumHome(), DEFAULT_IMAGE_DIR_NAME);
128
- const fullDownloadPath = joinPath(DEFAULT_IMAGE_DIR, fileName);
129
- if (!(await exists(DEFAULT_IMAGE_DIR))) {
130
- await mkdir(DEFAULT_IMAGE_DIR, {recursive: true});
131
- }
132
- if (!(await exists(fullDownloadPath))) {
133
- await searchAndDownloadDeveloperImageFromGithub(
134
- finalVersion,
135
- fullDownloadPath,
136
- githubImageOption,
137
- );
138
- }
139
- const decompressPath = joinPath(DEFAULT_IMAGE_DIR, finalVersion);
140
- /** @type {string | undefined} */
141
- let developerImageParentFolder;
142
- if (await exists(decompressPath)) {
143
- developerImageParentFolder = await findDeveloperImageFromDirectory(decompressPath);
144
- }
145
- if (!developerImageParentFolder) {
146
- await zip.extractAllTo(fullDownloadPath, decompressPath);
147
- developerImageParentFolder = await findDeveloperImageFromDirectory(decompressPath);
148
- }
149
- if (!developerImageParentFolder) {
150
- throw new Error(`Unable to find unzipped developer image in ${decompressPath}`);
151
- }
152
- return {
153
- developerImage: joinPath(developerImageParentFolder, DEVELOPER_IMAGE_FILE_NAME),
154
- developerImageSignature: joinPath(
155
- developerImageParentFolder,
156
- DEVELOPER_IMAGE_SIGNATURE_FILE_NAME,
157
- ),
158
- };
159
- }
160
-
161
161
  /**
162
162
  *
163
163
  * @param {string} finalVersion
@@ -196,5 +196,3 @@ async function searchAndDownloadDeveloperImageFromGithub(
196
196
  throw e;
197
197
  }
198
198
  }
199
-
200
- export {findDeveloperImage};
@@ -5,9 +5,9 @@ import {BaseServicePlist} from '../base-service';
5
5
  * https://github.com/tmothy20013/libimobiledevice-master/blob/ecd89b42021cf6f7efe9ad271b3bddc7dd4b281e/src/installation_proxy.c
6
6
  */
7
7
 
8
- const INSTALLATION_PROXY_SERVICE_NAME = 'com.apple.mobile.installation_proxy';
8
+ export const INSTALLATION_PROXY_SERVICE_NAME = 'com.apple.mobile.installation_proxy';
9
9
 
10
- class InstallationProxyService extends BaseServicePlist {
10
+ export class InstallationProxyService extends BaseServicePlist {
11
11
  /**
12
12
  * Install the application on the relative path on the phone
13
13
  * @param {string} path The path where the .app and .ipa is located at on the phone
@@ -165,5 +165,4 @@ class InstallationProxyService extends BaseServicePlist {
165
165
  }
166
166
  }
167
167
 
168
- export {InstallationProxyService, INSTALLATION_PROXY_SERVICE_NAME};
169
168
  export default InstallationProxyService;
@@ -2,14 +2,14 @@ import {archive, unarchive} from './transformer/nskeyed';
2
2
  import {parseBuffer} from 'bplist-parser';
3
3
  import _ from 'lodash';
4
4
 
5
- const DTX_MESSAGE_PAYLOAD_HEADER_LENGTH = 16;
6
- const DTX_MESSAGE_HEADER_LENGTH = 32;
7
- const DTX_MESSAGE_HEADER_MAGIC = 0x1f3d5b79;
8
- const DTX_MESSAGE_HEADER_MAGIC_LEN = 4;
5
+ export const DTX_MESSAGE_PAYLOAD_HEADER_LENGTH = 16;
6
+ export const DTX_MESSAGE_HEADER_LENGTH = 32;
7
+ export const DTX_MESSAGE_HEADER_MAGIC = 0x1f3d5b79;
8
+ export const DTX_MESSAGE_HEADER_MAGIC_LEN = 4;
9
9
  const DTX_MESSAGE_AUX_HEADER = 0x01f0;
10
10
  const DTX_AUXILIARY_MAGIC = 0xa;
11
11
 
12
- const FLAG_TYPES = Object.freeze({
12
+ export const FLAG_TYPES = Object.freeze({
13
13
  push: 0,
14
14
  recv: 1,
15
15
  send: 2,
@@ -51,7 +51,22 @@ const AUX_TYPES = Object.freeze({
51
51
  * @property {number} flags message status
52
52
  */
53
53
 
54
- class DTXMessageHeader {
54
+ class InstrumentRPCParseError {
55
+ constructor(data) {
56
+ this.data = data;
57
+ }
58
+ }
59
+
60
+ /**
61
+ * DTXMessagePayloadHeader length 16
62
+ * struct DTXMessageHeader {
63
+ * u32 flags FLAG_TYPES
64
+ * u32 auxLength
65
+ * u64 totalLength
66
+ * }
67
+ */
68
+
69
+ export class DTXMessageHeader {
55
70
  /**
56
71
  * @param {Partial<DTXMessageOptions>} data
57
72
  * @returns {Buffer} DTXMessageHeaderBuffer
@@ -89,22 +104,13 @@ class DTXMessageHeader {
89
104
  }
90
105
  }
91
106
 
92
- /**
93
- * DTXMessagePayloadHeader length 16
94
- * struct DTXMessageHeader {
95
- * u32 flags FLAG_TYPES
96
- * u32 auxLength
97
- * u64 totalLength
98
- * }
99
- */
100
-
101
107
  /**
102
108
  * @typedef {Object} DTXMessagePayloadHeaderObject
103
109
  * @property {number} flags message status
104
110
  * @property {number} auxLength DTXMessageAuxBuffer.length(nullable)
105
111
  * @property {bigint} totalLength DTXMessageAuxBuffer.length(nullable) + selectorBuffer.length
106
112
  */
107
- class DTXMessagePayloadHeader {
113
+ export class DTXMessagePayloadHeader {
108
114
  /**
109
115
  * @param data {DTXMessagePayloadHeaderObject}
110
116
  * @returns {Buffer} DTXMessagePayloadHeaderBuffer
@@ -130,7 +136,7 @@ class DTXMessagePayloadHeader {
130
136
  }
131
137
  }
132
138
 
133
- class DTXMessageAux {
139
+ export class DTXMessageAux {
134
140
  /**
135
141
  * @param {any[] | DTXMessageAuxBuffer} data
136
142
  */
@@ -138,30 +144,6 @@ class DTXMessageAux {
138
144
  this.data = data;
139
145
  }
140
146
 
141
- /**
142
- * JS Array to Apple NSKeyed Buffer
143
- * @returns {Buffer}
144
- */
145
- build() {
146
- if (this.data instanceof DTXMessageAuxBuffer) {
147
- return this.data.getBytes();
148
- }
149
- const messageAux = new DTXMessageAuxBuffer();
150
- let buf = Buffer.alloc(0);
151
- for (const arg of this.data) {
152
- if (arg instanceof DTXMessageAuxBuffer) {
153
- buf = Buffer.concat([buf, arg.getBytes()]);
154
- } else if (_.isNumber(arg)) {
155
- messageAux.appendInt(arg);
156
- } else if (typeof arg == 'bigint') {
157
- messageAux.appendLong(arg);
158
- } else {
159
- messageAux.appendObject(arg);
160
- }
161
- }
162
- return Buffer.concat([buf, messageAux.getBytes()]);
163
- }
164
-
165
147
  /**
166
148
  * Parses nskeyed Buffer into js array
167
149
  * @param {Buffer} headerBuffer
@@ -217,15 +199,33 @@ class DTXMessageAux {
217
199
  }
218
200
  return data;
219
201
  }
220
- }
221
202
 
222
- class InstrumentRPCParseError {
223
- constructor(data) {
224
- this.data = data;
203
+ /**
204
+ * JS Array to Apple NSKeyed Buffer
205
+ * @returns {Buffer}
206
+ */
207
+ build() {
208
+ if (this.data instanceof DTXMessageAuxBuffer) {
209
+ return this.data.getBytes();
210
+ }
211
+ const messageAux = new DTXMessageAuxBuffer();
212
+ let buf = Buffer.alloc(0);
213
+ for (const arg of this.data) {
214
+ if (arg instanceof DTXMessageAuxBuffer) {
215
+ buf = Buffer.concat([buf, arg.getBytes()]);
216
+ } else if (_.isNumber(arg)) {
217
+ messageAux.appendInt(arg);
218
+ } else if (typeof arg == 'bigint') {
219
+ messageAux.appendLong(arg);
220
+ } else {
221
+ messageAux.appendObject(arg);
222
+ }
223
+ }
224
+ return Buffer.concat([buf, messageAux.getBytes()]);
225
225
  }
226
226
  }
227
227
 
228
- class DTXMessageAuxBuffer {
228
+ export class DTXMessageAuxBuffer {
229
229
  constructor() {
230
230
  this._buf = Buffer.alloc(0);
231
231
  }
@@ -294,7 +294,7 @@ class DTXMessageAuxBuffer {
294
294
  }
295
295
  }
296
296
 
297
- class DTXMessage {
297
+ export class DTXMessage {
298
298
  /**
299
299
  * @param {Partial<DTXMessageOptions>} opts
300
300
  */
@@ -353,13 +353,6 @@ class DTXMessage {
353
353
  return this._selector;
354
354
  }
355
355
 
356
- /**
357
- * @param data
358
- */
359
- set selector(data) {
360
- this._selector = data;
361
- }
362
-
363
356
  /**
364
357
  * get DTXMessageHeader conversationIndex
365
358
  * @returns {number}
@@ -369,27 +362,10 @@ class DTXMessage {
369
362
  }
370
363
 
371
364
  /**
372
- * DTXMessage Buffer: DTXMessageHeader + PayloadHeader + DTXMessageAuxBuffer(nullable) + selector(nullable)
373
- * @returns {Buffer}
365
+ * @param data
374
366
  */
375
- build() {
376
- const sel = this._selector ? archive(this._selector) : Buffer.alloc(0);
377
- const aux = this.auxiliaries.build();
378
- const payloadHeader = DTXMessagePayloadHeader.build({
379
- flags: this._flags,
380
- auxLength: aux.length,
381
- // need to convert to bigint in any case
382
- totalLength: BigInt(aux.length + sel.length),
383
- });
384
-
385
- const messageHeader = DTXMessageHeader.build({
386
- payloadLength: DTX_MESSAGE_PAYLOAD_HEADER_LENGTH + aux.length + sel.length,
387
- identifier: this._identifier,
388
- conversationIndex: this._conversationIndex,
389
- channelCode: this._channelCode,
390
- expectsReply: this._expectsReply,
391
- });
392
- return Buffer.concat([messageHeader, payloadHeader, aux, sel]);
367
+ set selector(data) {
368
+ this._selector = data;
393
369
  }
394
370
 
395
371
  /**
@@ -436,17 +412,28 @@ class DTXMessage {
436
412
  }
437
413
  return ret;
438
414
  }
439
- }
440
415
 
441
- export {
442
- DTXMessageHeader,
443
- DTXMessagePayloadHeader,
444
- DTXMessageAuxBuffer,
445
- DTXMessageAux,
446
- DTXMessage,
447
- DTX_MESSAGE_PAYLOAD_HEADER_LENGTH,
448
- DTX_MESSAGE_HEADER_LENGTH,
449
- DTX_MESSAGE_HEADER_MAGIC,
450
- DTX_MESSAGE_HEADER_MAGIC_LEN,
451
- FLAG_TYPES,
452
- };
416
+ /**
417
+ * DTXMessage Buffer: DTXMessageHeader + PayloadHeader + DTXMessageAuxBuffer(nullable) + selector(nullable)
418
+ * @returns {Buffer}
419
+ */
420
+ build() {
421
+ const sel = this._selector ? archive(this._selector) : Buffer.alloc(0);
422
+ const aux = this.auxiliaries.build();
423
+ const payloadHeader = DTXMessagePayloadHeader.build({
424
+ flags: this._flags,
425
+ auxLength: aux.length,
426
+ // need to convert to bigint in any case
427
+ totalLength: BigInt(aux.length + sel.length),
428
+ });
429
+
430
+ const messageHeader = DTXMessageHeader.build({
431
+ payloadLength: DTX_MESSAGE_PAYLOAD_HEADER_LENGTH + aux.length + sel.length,
432
+ identifier: this._identifier,
433
+ conversationIndex: this._conversationIndex,
434
+ channelCode: this._channelCode,
435
+ expectsReply: this._expectsReply,
436
+ });
437
+ return Buffer.concat([messageHeader, payloadHeader, aux, sel]);
438
+ }
439
+ }