appium-ios-device 3.1.9 → 3.1.11

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 (152) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/afc/index.d.ts +1 -1
  3. package/build/lib/afc/index.d.ts.map +1 -1
  4. package/build/lib/afc/index.js +9 -9
  5. package/build/lib/afc/index.js.map +1 -1
  6. package/build/lib/afc/protocol.d.ts.map +1 -1
  7. package/build/lib/afc/protocol.js +16 -16
  8. package/build/lib/afc/protocol.js.map +1 -1
  9. package/build/lib/afc/streams.d.ts.map +1 -1
  10. package/build/lib/afc/streams.js.map +1 -1
  11. package/build/lib/afc/transformer/afcdecoder.d.ts.map +1 -1
  12. package/build/lib/afc/transformer/afcdecoder.js.map +1 -1
  13. package/build/lib/afc/transformer/afcencoder.d.ts.map +1 -1
  14. package/build/lib/afc/transformer/afcencoder.js.map +1 -1
  15. package/build/lib/base-service.d.ts.map +1 -1
  16. package/build/lib/base-service.js.map +1 -1
  17. package/build/lib/house-arrest/index.d.ts.map +1 -1
  18. package/build/lib/house-arrest/index.js.map +1 -1
  19. package/build/lib/imagemounter/index.d.ts.map +1 -1
  20. package/build/lib/imagemounter/index.js +4 -4
  21. package/build/lib/imagemounter/index.js.map +1 -1
  22. package/build/lib/imagemounter/utils/list_developer_image.d.ts.map +1 -1
  23. package/build/lib/imagemounter/utils/list_developer_image.js +3 -3
  24. package/build/lib/imagemounter/utils/list_developer_image.js.map +1 -1
  25. package/build/lib/installation-proxy/index.d.ts +11 -11
  26. package/build/lib/installation-proxy/index.d.ts.map +1 -1
  27. package/build/lib/installation-proxy/index.js +19 -17
  28. package/build/lib/installation-proxy/index.js.map +1 -1
  29. package/build/lib/instrument/headers.d.ts.map +1 -1
  30. package/build/lib/instrument/headers.js +7 -7
  31. package/build/lib/instrument/headers.js.map +1 -1
  32. package/build/lib/instrument/index.d.ts +1 -1
  33. package/build/lib/instrument/index.d.ts.map +1 -1
  34. package/build/lib/instrument/index.js +13 -7
  35. package/build/lib/instrument/index.js.map +1 -1
  36. package/build/lib/instrument/transformer/dtx-decode.d.ts.map +1 -1
  37. package/build/lib/instrument/transformer/dtx-decode.js +9 -3
  38. package/build/lib/instrument/transformer/dtx-decode.js.map +1 -1
  39. package/build/lib/instrument/transformer/dtx-encode.d.ts.map +1 -1
  40. package/build/lib/instrument/transformer/dtx-encode.js +1 -1
  41. package/build/lib/instrument/transformer/dtx-encode.js.map +1 -1
  42. package/build/lib/instrument/transformer/nskeyed.d.ts.map +1 -1
  43. package/build/lib/instrument/transformer/nskeyed.js +16 -9
  44. package/build/lib/instrument/transformer/nskeyed.js.map +1 -1
  45. package/build/lib/lockdown/index.d.ts +5 -5
  46. package/build/lib/lockdown/index.d.ts.map +1 -1
  47. package/build/lib/lockdown/index.js +9 -10
  48. package/build/lib/lockdown/index.js.map +1 -1
  49. package/build/lib/logger.js.map +1 -1
  50. package/build/lib/mcinstall/index.d.ts.map +1 -1
  51. package/build/lib/mcinstall/index.js +14 -6
  52. package/build/lib/mcinstall/index.js.map +1 -1
  53. package/build/lib/notification-proxy/index.d.ts.map +1 -1
  54. package/build/lib/notification-proxy/index.js +2 -2
  55. package/build/lib/notification-proxy/index.js.map +1 -1
  56. package/build/lib/plist-service/index.d.ts.map +1 -1
  57. package/build/lib/plist-service/index.js.map +1 -1
  58. package/build/lib/plist-service/transformer/plist-service-decoder.d.ts.map +1 -1
  59. package/build/lib/plist-service/transformer/plist-service-decoder.js.map +1 -1
  60. package/build/lib/plist-service/transformer/plist-service-encoder.d.ts.map +1 -1
  61. package/build/lib/plist-service/transformer/plist-service-encoder.js.map +1 -1
  62. package/build/lib/services.d.ts.map +1 -1
  63. package/build/lib/services.js +3 -3
  64. package/build/lib/services.js.map +1 -1
  65. package/build/lib/simulatelocation/index.d.ts.map +1 -1
  66. package/build/lib/simulatelocation/index.js.map +1 -1
  67. package/build/lib/ssl-helper.js +3 -3
  68. package/build/lib/ssl-helper.js.map +1 -1
  69. package/build/lib/syslog/index.d.ts +1 -1
  70. package/build/lib/syslog/index.d.ts.map +1 -1
  71. package/build/lib/syslog/index.js +1 -1
  72. package/build/lib/syslog/index.js.map +1 -1
  73. package/build/lib/syslog/transformer/syslog-decoder.d.ts.map +1 -1
  74. package/build/lib/syslog/transformer/syslog-decoder.js +4 -2
  75. package/build/lib/syslog/transformer/syslog-decoder.js.map +1 -1
  76. package/build/lib/testmanagerd/index.d.ts.map +1 -1
  77. package/build/lib/testmanagerd/index.js.map +1 -1
  78. package/build/lib/usbmux/index.d.ts.map +1 -1
  79. package/build/lib/usbmux/index.js +16 -13
  80. package/build/lib/usbmux/index.js.map +1 -1
  81. package/build/lib/usbmux/transformer/usbmux-decoder.d.ts.map +1 -1
  82. package/build/lib/usbmux/transformer/usbmux-decoder.js +1 -1
  83. package/build/lib/usbmux/transformer/usbmux-decoder.js.map +1 -1
  84. package/build/lib/usbmux/transformer/usbmux-encoder.d.ts.map +1 -1
  85. package/build/lib/usbmux/transformer/usbmux-encoder.js +1 -1
  86. package/build/lib/usbmux/transformer/usbmux-encoder.js.map +1 -1
  87. package/build/lib/util/transformer/length-based-splitter.d.ts.map +1 -1
  88. package/build/lib/util/transformer/length-based-splitter.js +9 -4
  89. package/build/lib/util/transformer/length-based-splitter.js.map +1 -1
  90. package/build/lib/util/transformer/stream-logger.d.ts.map +1 -1
  91. package/build/lib/util/transformer/stream-logger.js +4 -3
  92. package/build/lib/util/transformer/stream-logger.js.map +1 -1
  93. package/build/lib/util/uuid/parse.js.map +1 -1
  94. package/build/lib/util/uuid/stringify.js.map +1 -1
  95. package/build/lib/util/uuid/validate.d.ts.map +1 -1
  96. package/build/lib/util/uuid/validate.js.map +1 -1
  97. package/build/lib/utilities.d.ts.map +1 -1
  98. package/build/lib/utilities.js +12 -12
  99. package/build/lib/utilities.js.map +1 -1
  100. package/build/lib/webinspector/index.d.ts.map +1 -1
  101. package/build/lib/webinspector/index.js +11 -9
  102. package/build/lib/webinspector/index.js.map +1 -1
  103. package/build/lib/webinspector/transformer/webinspector-decoder.d.ts.map +1 -1
  104. package/build/lib/webinspector/transformer/webinspector-decoder.js.map +1 -1
  105. package/build/lib/webinspector/transformer/webinspector-encoder.d.ts.map +1 -1
  106. package/build/lib/webinspector/transformer/webinspector-encoder.js.map +1 -1
  107. package/build/lib/xctest.d.ts.map +1 -1
  108. package/build/lib/xctest.js +3 -6
  109. package/build/lib/xctest.js.map +1 -1
  110. package/lib/afc/index.js +49 -43
  111. package/lib/afc/protocol.js +53 -50
  112. package/lib/afc/streams.js +7 -9
  113. package/lib/afc/transformer/afcdecoder.js +8 -10
  114. package/lib/afc/transformer/afcencoder.js +7 -10
  115. package/lib/base-service.js +2 -4
  116. package/lib/constants.js +1 -1
  117. package/lib/house-arrest/index.js +16 -14
  118. package/lib/imagemounter/index.js +107 -104
  119. package/lib/imagemounter/utils/list_developer_image.js +115 -100
  120. package/lib/installation-proxy/index.js +31 -27
  121. package/lib/instrument/headers.js +51 -40
  122. package/lib/instrument/index.js +32 -21
  123. package/lib/instrument/transformer/dtx-decode.js +30 -16
  124. package/lib/instrument/transformer/dtx-encode.js +6 -8
  125. package/lib/instrument/transformer/nskeyed.js +40 -21
  126. package/lib/lockdown/index.js +44 -35
  127. package/lib/logger.js +1 -1
  128. package/lib/mcinstall/index.js +20 -13
  129. package/lib/notification-proxy/index.js +18 -17
  130. package/lib/plist-service/index.js +13 -14
  131. package/lib/plist-service/transformer/plist-service-decoder.js +6 -7
  132. package/lib/plist-service/transformer/plist-service-encoder.js +6 -7
  133. package/lib/services.js +45 -29
  134. package/lib/simulatelocation/index.js +4 -5
  135. package/lib/ssl-helper.js +6 -7
  136. package/lib/syslog/index.js +7 -8
  137. package/lib/syslog/transformer/syslog-decoder.js +11 -10
  138. package/lib/testmanagerd/index.js +10 -7
  139. package/lib/usbmux/index.js +52 -41
  140. package/lib/usbmux/transformer/usbmux-decoder.js +8 -10
  141. package/lib/usbmux/transformer/usbmux-encoder.js +10 -8
  142. package/lib/util/transformer/length-based-splitter.js +62 -24
  143. package/lib/util/transformer/stream-logger.js +14 -11
  144. package/lib/util/uuid/parse.ts +2 -2
  145. package/lib/util/uuid/stringify.ts +1 -1
  146. package/lib/util/uuid/validate.ts +2 -1
  147. package/lib/utilities.js +39 -28
  148. package/lib/webinspector/index.js +59 -46
  149. package/lib/webinspector/transformer/webinspector-decoder.js +22 -11
  150. package/lib/webinspector/transformer/webinspector-encoder.js +6 -8
  151. package/lib/xctest.js +284 -245
  152. package/package.json +4 -2
package/lib/afc/index.js CHANGED
@@ -1,16 +1,14 @@
1
-
2
- import { LengthBasedSplitter } from '../util/transformer/length-based-splitter';
3
- import { Operations, operationCode, Errors, errorCode, FileModes } from './protocol';
4
- import { AfcWritableFileStream, AfcReadableFileStream } from './streams';
5
- import { AfcEncoder } from './transformer/afcencoder';
6
- import { AfcDecoder } from './transformer/afcdecoder';
7
- import { MB } from '../constants';
1
+ import {LengthBasedSplitter} from '../util/transformer/length-based-splitter';
2
+ import {Operations, operationCode, Errors, errorCode, FileModes} from './protocol';
3
+ import {AfcWritableFileStream, AfcReadableFileStream} from './streams';
4
+ import {AfcEncoder} from './transformer/afcencoder';
5
+ import {AfcDecoder} from './transformer/afcdecoder';
6
+ import {MB} from '../constants';
8
7
  import B from 'bluebird';
9
8
  import path from 'node:path';
10
9
  import _ from 'lodash';
11
- import { BaseServiceSocket } from '../base-service';
12
- import { getMaxFrameLength } from '../utilities';
13
-
10
+ import {BaseServiceSocket} from '../base-service';
11
+ import {getMaxFrameLength} from '../utilities';
14
12
 
15
13
  const AFC_SERVICE_NAME = 'com.apple.afc';
16
14
  const MAX_FRAME_SIZE = 1 * MB;
@@ -19,7 +17,7 @@ const NULL_DELIMITER_CODE = 0x00;
19
17
  const IGNORED_PATHS = ['.', '..'];
20
18
 
21
19
  class AfcService extends BaseServiceSocket {
22
- constructor (socketClient) {
20
+ constructor(socketClient) {
23
21
  super(socketClient);
24
22
 
25
23
  this._splitter = new LengthBasedSplitter({
@@ -43,7 +41,7 @@ class AfcService extends BaseServiceSocket {
43
41
  this._decoder.on('data', this._handleData.bind(this));
44
42
  }
45
43
 
46
- _handleData (data) {
44
+ _handleData(data) {
47
45
  const cb = this._responseCallbacks[data.packetNumber] || _.noop;
48
46
  cb(data); // eslint-disable-line promise/prefer-await-to-callbacks
49
47
  }
@@ -52,13 +50,13 @@ class AfcService extends BaseServiceSocket {
52
50
  * Creates a directory relative to an already existing directory
53
51
  * @param {string} path The path in unix format
54
52
  */
55
- async createDirectory (path) {
53
+ async createDirectory(path) {
56
54
  const {packetNumber, response} = this._createPacketPromise(`Create directory '${path}'`);
57
55
 
58
56
  const data = {
59
57
  opCode: Operations.MAKE_DIR,
60
58
  packetNumber,
61
- headerPayload: Buffer.from(path)
59
+ headerPayload: Buffer.from(path),
62
60
  };
63
61
  this._encoder.write(data);
64
62
  const res = await response;
@@ -69,13 +67,13 @@ class AfcService extends BaseServiceSocket {
69
67
  * Deletes are directory completely even it has content inside. This is an implementation of 'rm -r {path}'
70
68
  * @param {string} path The path in unix format
71
69
  */
72
- async deleteDirectory (path) {
70
+ async deleteDirectory(path) {
73
71
  const {packetNumber, response} = this._createPacketPromise(`Delete directory '${path}'`);
74
72
 
75
73
  const data = {
76
74
  opCode: Operations.REMOVE_PATH_AND_CONTENTS,
77
75
  packetNumber,
78
- headerPayload: Buffer.from(path)
76
+ headerPayload: Buffer.from(path),
79
77
  };
80
78
  this._encoder.write(data);
81
79
  const res = await response;
@@ -87,13 +85,13 @@ class AfcService extends BaseServiceSocket {
87
85
  * @param {string} path The path in unix format
88
86
  * @return {Promise<string[]>}
89
87
  */
90
- async listDirectory (path) {
88
+ async listDirectory(path) {
91
89
  const {packetNumber, response} = this._createPacketPromise(`List directory '${path}'`);
92
90
 
93
91
  const data = {
94
92
  opCode: Operations.READ_DIR,
95
93
  packetNumber,
96
- headerPayload: Buffer.from(path)
94
+ headerPayload: Buffer.from(path),
97
95
  };
98
96
  this._encoder.write(data);
99
97
  const res = await response;
@@ -110,7 +108,7 @@ class AfcService extends BaseServiceSocket {
110
108
  * @param {number} mode The file mode that will be used
111
109
  * @return {Promise<number>}
112
110
  */
113
- async openFile (path, mode) {
111
+ async openFile(path, mode) {
114
112
  const {packetNumber, response} = this._createPacketPromise(`Open file '${path}'`);
115
113
 
116
114
  const pathPayload = Buffer.from(path);
@@ -120,7 +118,7 @@ class AfcService extends BaseServiceSocket {
120
118
  const data = {
121
119
  opCode: Operations.FILE_OPEN,
122
120
  packetNumber,
123
- headerPayload: Buffer.concat([fileModePayload, pathPayload])
121
+ headerPayload: Buffer.concat([fileModePayload, pathPayload]),
124
122
  };
125
123
  this._encoder.write(data);
126
124
  const res = await response;
@@ -137,7 +135,7 @@ class AfcService extends BaseServiceSocket {
137
135
  * @param {Object} opts The regular options that are passed to a Stream.Writable
138
136
  * @return {Promise<AfcWritableFileStream>}
139
137
  */
140
- async createWriteStream (filePath, opts) {
138
+ async createWriteStream(filePath, opts) {
141
139
  const fileHandle = await this.openFile(filePath, FileModes.w);
142
140
  return new AfcWritableFileStream(fileHandle, this, opts);
143
141
  }
@@ -148,7 +146,7 @@ class AfcService extends BaseServiceSocket {
148
146
  * @param {Object} options The regular options that are passed to a Stream.Readable
149
147
  * @return {Promise<AfcReadableFileStream>}
150
148
  */
151
- async createReadStream (filePath, options) {
149
+ async createReadStream(filePath, options) {
152
150
  const fileHandle = await this.openFile(filePath, FileModes.r);
153
151
  return new AfcReadableFileStream(fileHandle, this, options);
154
152
  }
@@ -157,7 +155,7 @@ class AfcService extends BaseServiceSocket {
157
155
  * Closes the file handle
158
156
  * @param {number} fileHandle the file handle to be closed
159
157
  */
160
- async closeFileHandle (fileHandle) {
158
+ async closeFileHandle(fileHandle) {
161
159
  const {packetNumber, response} = this._createPacketPromise(`Close file handle '${fileHandle}'`);
162
160
 
163
161
  const fileModePayload = Buffer.alloc(8);
@@ -166,7 +164,7 @@ class AfcService extends BaseServiceSocket {
166
164
  const data = {
167
165
  opCode: Operations.FILE_CLOSE,
168
166
  packetNumber,
169
- headerPayload: fileModePayload
167
+ headerPayload: fileModePayload,
170
168
  };
171
169
  this._encoder.write(data);
172
170
  const res = await response;
@@ -178,8 +176,10 @@ class AfcService extends BaseServiceSocket {
178
176
  * @param {number} fileHandle The file handle to be used
179
177
  * @param {Buffer} buffer The buffer that will be written
180
178
  */
181
- async writeFile (fileHandle, buffer) {
182
- const {packetNumber, response} = this._createPacketPromise(`Write to file handle '${fileHandle}'`);
179
+ async writeFile(fileHandle, buffer) {
180
+ const {packetNumber, response} = this._createPacketPromise(
181
+ `Write to file handle '${fileHandle}'`,
182
+ );
183
183
 
184
184
  const headerPayload = Buffer.alloc(8);
185
185
  headerPayload.writeUInt32LE(fileHandle, 0);
@@ -188,7 +188,7 @@ class AfcService extends BaseServiceSocket {
188
188
  opCode: Operations.FILE_WRITE,
189
189
  packetNumber,
190
190
  headerPayload,
191
- content: buffer
191
+ content: buffer,
192
192
  };
193
193
  this._encoder.write(data);
194
194
  const res = await response;
@@ -201,8 +201,10 @@ class AfcService extends BaseServiceSocket {
201
201
  * @param {number} length The length that wants to be read from the file handle
202
202
  * @return {Promise<Buffer>}
203
203
  */
204
- async readFile (fileHandle, length) {
205
- const {packetNumber, response} = this._createPacketPromise(`Read from file handle '${fileHandle}'`);
204
+ async readFile(fileHandle, length) {
205
+ const {packetNumber, response} = this._createPacketPromise(
206
+ `Read from file handle '${fileHandle}'`,
207
+ );
206
208
 
207
209
  const headerPayload = Buffer.alloc(16);
208
210
  headerPayload.writeUInt32LE(fileHandle, 0);
@@ -211,7 +213,7 @@ class AfcService extends BaseServiceSocket {
211
213
  const data = {
212
214
  opCode: Operations.FILE_READ,
213
215
  packetNumber,
214
- headerPayload
216
+ headerPayload,
215
217
  };
216
218
  this._encoder.write(data);
217
219
  const res = await response;
@@ -226,13 +228,13 @@ class AfcService extends BaseServiceSocket {
226
228
  * @param {string} path The path in unix format
227
229
  * @return {Promise<FileInfo>}
228
230
  */
229
- async getFileInfo (path) {
231
+ async getFileInfo(path) {
230
232
  const {packetNumber, response} = this._createPacketPromise(`Get file info '${path}'`);
231
233
 
232
234
  const data = {
233
235
  opCode: Operations.GET_FILE_INFO,
234
236
  packetNumber,
235
- headerPayload: Buffer.from(path)
237
+ headerPayload: Buffer.from(path),
236
238
  };
237
239
  this._encoder.write(data);
238
240
  const res = await response;
@@ -247,7 +249,7 @@ class AfcService extends BaseServiceSocket {
247
249
  * @callback WalkDirCallback
248
250
  * @param {string} itemPath The path of the file or folder
249
251
  * @param {boolean} isDirectory Shows if it is a directory or a file
250
- */
252
+ */
251
253
 
252
254
  /**
253
255
  *
@@ -255,7 +257,7 @@ class AfcService extends BaseServiceSocket {
255
257
  * @param {boolean} recursive Sets whether to follow sub directories or not
256
258
  * @param {WalkDirCallback} onPath The callback to be called when a new path is found
257
259
  */
258
- async walkDir (dir, recursive, onPath) {
260
+ async walkDir(dir, recursive, onPath) {
259
261
  for (const file of await this.listDirectory(dir)) {
260
262
  if (IGNORED_PATHS.includes(file)) {
261
263
  continue;
@@ -270,7 +272,7 @@ class AfcService extends BaseServiceSocket {
270
272
  }
271
273
  }
272
274
 
273
- _checkStatus (res) {
275
+ _checkStatus(res) {
274
276
  if (res.opCode !== Operations.STATUS) {
275
277
  throw new Error(`Unexpected response ${operationCode(res.opCode)}`);
276
278
  }
@@ -282,7 +284,7 @@ class AfcService extends BaseServiceSocket {
282
284
  }
283
285
  }
284
286
 
285
- _parseArray (buffer) {
287
+ _parseArray(buffer) {
286
288
  const items = [];
287
289
  let start = 0;
288
290
  for (let end = 0; end < buffer.length; end++) {
@@ -297,7 +299,7 @@ class AfcService extends BaseServiceSocket {
297
299
  return items;
298
300
  }
299
301
 
300
- _parseObject (buffer) {
302
+ _parseObject(buffer) {
301
303
  const items = {};
302
304
  let start = 0;
303
305
  let currentKey;
@@ -321,12 +323,16 @@ class AfcService extends BaseServiceSocket {
321
323
  return items;
322
324
  }
323
325
 
324
- _createPacketPromise (message, timeout = 10000) {
326
+ _createPacketPromise(message, timeout = 10000) {
325
327
  const packetNumber = this._packetNumber++;
326
328
  const response = new B((resolve, reject) => {
327
329
  this._responseCallbacks[packetNumber] = resolve;
328
330
  setTimeout(function () {
329
- reject(new Error(`Could not finish the operation '${message}'. Failed to receive any data within the ${timeout}ms timeout`));
331
+ reject(
332
+ new Error(
333
+ `Could not finish the operation '${message}'. Failed to receive any data within the ${timeout}ms timeout`,
334
+ ),
335
+ );
330
336
  }, timeout);
331
337
  });
332
338
  return {packetNumber, response};
@@ -334,7 +340,7 @@ class AfcService extends BaseServiceSocket {
334
340
  }
335
341
 
336
342
  class FileInfo {
337
- constructor ({st_size, st_blocks, st_nlink, st_ifmt, st_mtime, st_birthtime}) {
343
+ constructor({st_size, st_blocks, st_nlink, st_ifmt, st_mtime, st_birthtime}) {
338
344
  this.size = parseInt(st_size, 10);
339
345
  this.blocks = parseInt(st_blocks, 10);
340
346
  this.nlink = parseInt(st_nlink, 10);
@@ -345,14 +351,14 @@ class FileInfo {
345
351
  this.birthtimeMs = parseInt(st_birthtime, 10) / 1000000;
346
352
  }
347
353
 
348
- isDirectory () {
354
+ isDirectory() {
349
355
  return this.ifmt === 'S_IFDIR';
350
356
  }
351
357
 
352
- isFile () {
358
+ isFile() {
353
359
  return this.ifmt === 'S_IFREG';
354
360
  }
355
361
  }
356
362
 
357
363
  export default AfcService;
358
- export { AfcService, AFC_SERVICE_NAME };
364
+ export {AfcService, AFC_SERVICE_NAME};
@@ -5,52 +5,52 @@ const MAGIC_NUMBER = Buffer.from('CFA6LPAA');
5
5
  const AFC_PACKET_HEADER_SIZE = 40;
6
6
 
7
7
  const Operations = {
8
- INVALID: 0x00000000, // Invalid
9
- STATUS: 0x00000001, // Status
10
- DATA: 0x00000002, // Data
11
- READ_DIR: 0x00000003, // ReadDir
12
- READ_FILE: 0x00000004, // ReadFile
13
- WRITE_FILE: 0x00000005, // WriteFile
14
- WRITE_PART: 0x00000006, // WritePart
15
- TRUNCATE: 0x00000007, // TruncateFile
16
- REMOVE_PATH: 0x00000008, // RemovePath
17
- MAKE_DIR: 0x00000009, // MakeDir
18
- GET_FILE_INFO: 0x0000000A, // GetFileInfo
19
- GET_DEVINFO: 0x0000000B, // GetDeviceInfo
20
- WRITE_FILE_ATOM: 0x0000000C, // WriteFileAtomic (tmp file+rename)
21
- FILE_OPEN: 0x0000000D, // FileRefOpen
22
- FILE_OPEN_RES: 0x0000000E, // FileRefOpenResult
23
- FILE_READ: 0x0000000F, // FileRefRead
24
- FILE_WRITE: 0x00000010, // FileRefWrite
25
- FILE_SEEK: 0x00000011, // FileRefSeek
26
- FILE_TELL: 0x00000012, // FileRefTell
27
- FILE_TELL_RES: 0x00000013, // FileRefTellResult
28
- FILE_CLOSE: 0x00000014, // FileRefClose
29
- FILE_SET_SIZE: 0x00000015, // FileRefSetFileSize (ftruncate)
30
- GET_CON_INFO: 0x00000016, // GetConnectionInfo
31
- SET_CON_OPTIONS: 0x00000017, // SetConnectionOptions
32
- RENAME_PATH: 0x00000018, // RenamePath
33
- SET_FS_BS: 0x00000019, // SetFSBlockSize (0x800000)
34
- SET_SOCKET_BS: 0x0000001A, // SetSocketBlockSize (0x800000)
35
- FILE_LOCK: 0x0000001B, // FileRefLock
36
- MAKE_LINK: 0x0000001C, // MakeLink
37
- GET_FILE_HASH: 0x0000001D, // GetFileHash
38
- SET_FILE_MOD_TIME: 0x0000001E, // SetModTime
39
- GET_FILE_HASH_RANGE: 0x0000001F, // GetFileHashWithRange
40
- FILE_SET_IMMUTABLE_HINT: 0x00000020, // FileRefSetImmutableHint
41
- GET_SIZE_OF_PATH_CONTENTS: 0x00000021, // GetSizeOfPathContents
42
- REMOVE_PATH_AND_CONTENTS: 0x00000022, // RemovePathAndContents
43
- DIR_OPEN: 0x00000023, // DirectoryEnumeratorRefOpen
44
- DIR_OPEN_RESULT: 0x00000024, // DirectoryEnumeratorRefOpenResult
45
- DIR_READ: 0x00000025, // DirectoryEnumeratorRefRead
46
- DIR_CLOSE: 0x00000026, // DirectoryEnumeratorRefClose
47
- FILE_READ_OFFSET: 0x00000027, // FileRefReadWithOffset
48
- FILE_WRITE_OFFSET: 0x00000028 // FileRefWriteWithOffset
8
+ INVALID: 0x00000000, // Invalid
9
+ STATUS: 0x00000001, // Status
10
+ DATA: 0x00000002, // Data
11
+ READ_DIR: 0x00000003, // ReadDir
12
+ READ_FILE: 0x00000004, // ReadFile
13
+ WRITE_FILE: 0x00000005, // WriteFile
14
+ WRITE_PART: 0x00000006, // WritePart
15
+ TRUNCATE: 0x00000007, // TruncateFile
16
+ REMOVE_PATH: 0x00000008, // RemovePath
17
+ MAKE_DIR: 0x00000009, // MakeDir
18
+ GET_FILE_INFO: 0x0000000a, // GetFileInfo
19
+ GET_DEVINFO: 0x0000000b, // GetDeviceInfo
20
+ WRITE_FILE_ATOM: 0x0000000c, // WriteFileAtomic (tmp file+rename)
21
+ FILE_OPEN: 0x0000000d, // FileRefOpen
22
+ FILE_OPEN_RES: 0x0000000e, // FileRefOpenResult
23
+ FILE_READ: 0x0000000f, // FileRefRead
24
+ FILE_WRITE: 0x00000010, // FileRefWrite
25
+ FILE_SEEK: 0x00000011, // FileRefSeek
26
+ FILE_TELL: 0x00000012, // FileRefTell
27
+ FILE_TELL_RES: 0x00000013, // FileRefTellResult
28
+ FILE_CLOSE: 0x00000014, // FileRefClose
29
+ FILE_SET_SIZE: 0x00000015, // FileRefSetFileSize (ftruncate)
30
+ GET_CON_INFO: 0x00000016, // GetConnectionInfo
31
+ SET_CON_OPTIONS: 0x00000017, // SetConnectionOptions
32
+ RENAME_PATH: 0x00000018, // RenamePath
33
+ SET_FS_BS: 0x00000019, // SetFSBlockSize (0x800000)
34
+ SET_SOCKET_BS: 0x0000001a, // SetSocketBlockSize (0x800000)
35
+ FILE_LOCK: 0x0000001b, // FileRefLock
36
+ MAKE_LINK: 0x0000001c, // MakeLink
37
+ GET_FILE_HASH: 0x0000001d, // GetFileHash
38
+ SET_FILE_MOD_TIME: 0x0000001e, // SetModTime
39
+ GET_FILE_HASH_RANGE: 0x0000001f, // GetFileHashWithRange
40
+ FILE_SET_IMMUTABLE_HINT: 0x00000020, // FileRefSetImmutableHint
41
+ GET_SIZE_OF_PATH_CONTENTS: 0x00000021, // GetSizeOfPathContents
42
+ REMOVE_PATH_AND_CONTENTS: 0x00000022, // RemovePathAndContents
43
+ DIR_OPEN: 0x00000023, // DirectoryEnumeratorRefOpen
44
+ DIR_OPEN_RESULT: 0x00000024, // DirectoryEnumeratorRefOpenResult
45
+ DIR_READ: 0x00000025, // DirectoryEnumeratorRefRead
46
+ DIR_CLOSE: 0x00000026, // DirectoryEnumeratorRefClose
47
+ FILE_READ_OFFSET: 0x00000027, // FileRefReadWithOffset
48
+ FILE_WRITE_OFFSET: 0x00000028, // FileRefWriteWithOffset
49
49
  };
50
50
 
51
51
  const Operations_Code = _.invert(Operations);
52
52
 
53
- function operationCode (code) {
53
+ function operationCode(code) {
54
54
  return Operations_Code[code];
55
55
  }
56
56
 
@@ -83,22 +83,25 @@ const Errors = {
83
83
 
84
84
  const Errors_Code = _.invert(Errors);
85
85
 
86
- function errorCode (code) {
86
+ function errorCode(code) {
87
87
  return Errors_Code[code];
88
88
  }
89
89
 
90
-
91
90
  const FileModes = {
92
- 'r': 0x00000001, // O_RDONLY
91
+ r: 0x00000001, // O_RDONLY
93
92
  'r+': 0x00000002, // O_RDWR | O_CREAT
94
- 'w': 0x00000003, // O_WRONLY | O_CREAT | O_TRUNC
93
+ w: 0x00000003, // O_WRONLY | O_CREAT | O_TRUNC
95
94
  'w+': 0x00000004, // O_RDWR | O_CREAT | O_TRUNC
96
- 'a': 0x00000005, // O_WRONLY | O_APPEND | O_CREAT
95
+ a: 0x00000005, // O_WRONLY | O_APPEND | O_CREAT
97
96
  'a+': 0x00000006, // O_RDWR | O_APPEND | O_CREAT
98
97
  };
99
98
 
100
99
  export {
101
- MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE,
102
- Operations, operationCode,
103
- Errors, errorCode, FileModes,
100
+ MAGIC_NUMBER,
101
+ AFC_PACKET_HEADER_SIZE,
102
+ Operations,
103
+ operationCode,
104
+ Errors,
105
+ errorCode,
106
+ FileModes,
104
107
  };
@@ -1,10 +1,9 @@
1
1
  import stream from 'node:stream';
2
2
  import _ from 'lodash';
3
- import { log } from '../logger';
3
+ import {log} from '../logger';
4
4
 
5
5
  export class AfcReadableFileStream extends stream.Readable {
6
-
7
- constructor (fileHandle, afcService, options) {
6
+ constructor(fileHandle, afcService, options) {
8
7
  super(options);
9
8
  this._fileHandle = fileHandle;
10
9
  this._afcService = afcService;
@@ -12,7 +11,7 @@ export class AfcReadableFileStream extends stream.Readable {
12
11
  this._destroyed = false;
13
12
  }
14
13
 
15
- _read (size) {
14
+ _read(size) {
16
15
  (async () => {
17
16
  try {
18
17
  const data = await this._afcService.readFile(this._fileHandle, size);
@@ -29,7 +28,7 @@ export class AfcReadableFileStream extends stream.Readable {
29
28
  })();
30
29
  }
31
30
 
32
- _destroy (err, done) {
31
+ _destroy(err, done) {
33
32
  if (this._destroyed) {
34
33
  return;
35
34
  }
@@ -52,8 +51,7 @@ export class AfcReadableFileStream extends stream.Readable {
52
51
  }
53
52
 
54
53
  export class AfcWritableFileStream extends stream.Writable {
55
-
56
- constructor (fileHandle, afcService, options) {
54
+ constructor(fileHandle, afcService, options) {
57
55
  super(options);
58
56
  this._fileHandle = fileHandle;
59
57
  this._afcService = afcService;
@@ -61,7 +59,7 @@ export class AfcWritableFileStream extends stream.Writable {
61
59
  this._destroyed = false;
62
60
  }
63
61
 
64
- _write (chunk, encoding, next) {
62
+ _write(chunk, encoding, next) {
65
63
  (async () => {
66
64
  try {
67
65
  await this._afcService.writeFile(this._fileHandle, chunk);
@@ -75,7 +73,7 @@ export class AfcWritableFileStream extends stream.Writable {
75
73
  })();
76
74
  }
77
75
 
78
- _destroy (err, done) {
76
+ _destroy(err, done) {
79
77
  if (this._destroyed) {
80
78
  return;
81
79
  }
@@ -1,19 +1,17 @@
1
1
  import Stream from 'node:stream';
2
- import { MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE } from '../protocol';
3
-
2
+ import {MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE} from '../protocol';
4
3
 
5
4
  class AfcDecoder extends Stream.Transform {
6
-
7
- constructor () {
8
- super({ objectMode: true });
5
+ constructor() {
6
+ super({objectMode: true});
9
7
  }
10
8
 
11
- _transform (data, encoding, onData) {
9
+ _transform(data, encoding, onData) {
12
10
  this._decode(data);
13
11
  onData();
14
12
  }
15
13
 
16
- _decode (data) {
14
+ _decode(data) {
17
15
  const magicNumber = data.slice(0, 8);
18
16
  if (magicNumber.compare(MAGIC_NUMBER) !== 0) {
19
17
  throw new Error(`Unexpected magic number: ${magicNumber}`);
@@ -26,14 +24,14 @@ class AfcDecoder extends Stream.Transform {
26
24
  const headerPayload = data.slice(AFC_PACKET_HEADER_SIZE, thisLength);
27
25
  const content = data.slice(thisLength, messageLength);
28
26
 
29
- this.push({ messageLength, packetNumber, opCode, headerPayload, content });
27
+ this.push({messageLength, packetNumber, opCode, headerPayload, content});
30
28
  }
31
29
 
32
- readUInt64LE (buffer, index) {
30
+ readUInt64LE(buffer, index) {
33
31
  // Ignore the first 4 bytes since we don't do anything with longs
34
32
  return buffer.readUInt32LE(index);
35
33
  }
36
34
  }
37
35
 
38
- export { AfcDecoder };
36
+ export {AfcDecoder};
39
37
  export default AfcDecoder;
@@ -1,18 +1,16 @@
1
1
  import Stream from 'node:stream';
2
- import { MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE } from '../protocol';
3
-
2
+ import {MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE} from '../protocol';
4
3
 
5
4
  class AfcEncoder extends Stream.Transform {
6
-
7
- constructor () {
8
- super({ objectMode: true });
5
+ constructor() {
6
+ super({objectMode: true});
9
7
  }
10
8
 
11
- _transform (data, encoding, onData) {
9
+ _transform(data, encoding, onData) {
12
10
  onData(null, this._encode(data));
13
11
  }
14
12
 
15
- _encode (data) {
13
+ _encode(data) {
16
14
  data.content = data.content ? data.content : Buffer.alloc(0);
17
15
 
18
16
  const thisLength = AFC_PACKET_HEADER_SIZE + data.headerPayload.length;
@@ -29,13 +27,12 @@ class AfcEncoder extends Stream.Transform {
29
27
  return buffer;
30
28
  }
31
29
 
32
- writeUInt64LE (buffer, index, content) {
30
+ writeUInt64LE(buffer, index, content) {
33
31
  // Ignore the first 4 bytes since we don't do anything with longs
34
32
  buffer.writeUInt32LE(content, index);
35
33
  buffer.writeUInt32LE(0, index + 4);
36
34
  }
37
-
38
35
  }
39
36
 
40
- export { AfcEncoder };
37
+ export {AfcEncoder};
41
38
  export default AfcEncoder;
@@ -8,8 +8,7 @@ class BaseServiceSocket {
8
8
 
9
9
  _assignClientFailureHandlers(...sourceStreams) {
10
10
  for (const evt of ['close', 'end']) {
11
- this._socketClient.once(evt,
12
- () => sourceStreams.map((s) => s.unpipe(this._socketClient)));
11
+ this._socketClient.once(evt, () => sourceStreams.map((s) => s.unpipe(this._socketClient)));
13
12
  }
14
13
  }
15
14
 
@@ -39,5 +38,4 @@ class BaseServicePlist {
39
38
  }
40
39
  }
41
40
 
42
-
43
- export { BaseServiceSocket, BaseServicePlist };
41
+ export {BaseServiceSocket, BaseServicePlist};
package/lib/constants.js CHANGED
@@ -1,4 +1,4 @@
1
1
  const KB = 1024;
2
2
  const MB = KB * KB;
3
3
 
4
- export {KB, MB};
4
+ export {KB, MB};
@@ -1,18 +1,17 @@
1
- import { PlistServiceDecoder } from '../plist-service/transformer/plist-service-decoder';
2
- import { PlistServiceEncoder } from '../plist-service/transformer/plist-service-encoder';
3
- import { LengthBasedSplitter } from '../util/transformer/length-based-splitter';
4
- import { KB } from '../constants';
5
- import { AfcService } from '../afc';
1
+ import {PlistServiceDecoder} from '../plist-service/transformer/plist-service-decoder';
2
+ import {PlistServiceEncoder} from '../plist-service/transformer/plist-service-encoder';
3
+ import {LengthBasedSplitter} from '../util/transformer/length-based-splitter';
4
+ import {KB} from '../constants';
5
+ import {AfcService} from '../afc';
6
6
  import B from 'bluebird';
7
- import { BaseServiceSocket } from '../base-service';
8
- import { getMaxFrameLength } from '../utilities';
9
-
7
+ import {BaseServiceSocket} from '../base-service';
8
+ import {getMaxFrameLength} from '../utilities';
10
9
 
11
10
  const HOUSE_ARREST_SERVICE_NAME = 'com.apple.mobile.house_arrest';
12
11
  const MAX_FRAME_SIZE = 1 * KB;
13
12
 
14
13
  class HouseArrestService extends BaseServiceSocket {
15
- constructor (socketClient) {
14
+ constructor(socketClient) {
16
15
  super(socketClient);
17
16
 
18
17
  this._decoder = new PlistServiceDecoder();
@@ -37,7 +36,7 @@ class HouseArrestService extends BaseServiceSocket {
37
36
  * @throws Will throw an error if house arrest fails to access the application's container
38
37
  * @returns {Promise<AfcService>}
39
38
  */
40
- async vendContainer (bundleId) {
39
+ async vendContainer(bundleId) {
41
40
  const responsePromise = this._receivePlistPromise();
42
41
  this._encoder.write({
43
42
  Command: 'VendContainer',
@@ -58,7 +57,7 @@ class HouseArrestService extends BaseServiceSocket {
58
57
  * @throws Will throw an error if house arrest fails to access the application's documents
59
58
  * @returns {Promise<AfcService>}
60
59
  */
61
- async vendDocuments (bundleId) {
60
+ async vendDocuments(bundleId) {
62
61
  const responsePromise = this._receivePlistPromise();
63
62
  this._encoder.write({
64
63
  Command: 'VendDocuments',
@@ -73,13 +72,16 @@ class HouseArrestService extends BaseServiceSocket {
73
72
  return new AfcService(this._socketClient);
74
73
  }
75
74
 
76
- _receivePlistPromise (timeout = 10000) {
75
+ _receivePlistPromise(timeout = 10000) {
77
76
  return new B((resolve, reject) => {
78
77
  this._decoder.once('data', resolve);
79
- setTimeout(() => reject(new Error(`Failed to receive any data within the timeout: ${timeout}`)), timeout);
78
+ setTimeout(
79
+ () => reject(new Error(`Failed to receive any data within the timeout: ${timeout}`)),
80
+ timeout,
81
+ );
80
82
  });
81
83
  }
82
84
  }
83
85
 
84
- export { HouseArrestService, HOUSE_ARREST_SERVICE_NAME };
86
+ export {HouseArrestService, HOUSE_ARREST_SERVICE_NAME};
85
87
  export default HouseArrestService;