appium-ios-device 3.1.12 → 3.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/build/index.js +7 -8
- package/build/lib/afc/index.d.ts +3 -4
- package/build/lib/afc/index.d.ts.map +1 -1
- package/build/lib/afc/index.js +37 -25
- package/build/lib/afc/index.js.map +1 -1
- package/build/lib/afc/protocol.d.ts +12 -2
- package/build/lib/afc/protocol.d.ts.map +1 -1
- package/build/lib/afc/protocol.js +17 -12
- package/build/lib/afc/protocol.js.map +1 -1
- package/build/lib/afc/transformer/afcdecoder.d.ts +1 -1
- package/build/lib/afc/transformer/afcdecoder.d.ts.map +1 -1
- package/build/lib/afc/transformer/afcdecoder.js.map +1 -1
- package/build/lib/afc/transformer/afcencoder.d.ts +1 -1
- package/build/lib/afc/transformer/afcencoder.d.ts.map +1 -1
- package/build/lib/afc/transformer/afcencoder.js.map +1 -1
- package/build/lib/base-service.js.map +1 -1
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +2 -4
- package/build/lib/constants.js.map +1 -1
- package/build/lib/house-arrest/index.d.ts +3 -4
- package/build/lib/house-arrest/index.d.ts.map +1 -1
- package/build/lib/house-arrest/index.js +3 -8
- package/build/lib/house-arrest/index.js.map +1 -1
- package/build/lib/imagemounter/index.d.ts +1 -1
- package/build/lib/imagemounter/index.d.ts.map +1 -1
- package/build/lib/imagemounter/index.js +29 -34
- package/build/lib/imagemounter/index.js.map +1 -1
- package/build/lib/imagemounter/utils/list_developer_image.d.ts +10 -15
- package/build/lib/imagemounter/utils/list_developer_image.d.ts.map +1 -1
- package/build/lib/imagemounter/utils/list_developer_image.js +43 -43
- package/build/lib/imagemounter/utils/list_developer_image.js.map +1 -1
- package/build/lib/installation-proxy/index.d.ts +2 -2
- package/build/lib/installation-proxy/index.d.ts.map +1 -1
- package/build/lib/installation-proxy/index.js +2 -3
- package/build/lib/installation-proxy/index.js.map +1 -1
- package/build/lib/instrument/headers.d.ts +75 -100
- package/build/lib/instrument/headers.d.ts.map +1 -1
- package/build/lib/instrument/headers.js +78 -83
- package/build/lib/instrument/headers.js.map +1 -1
- package/build/lib/instrument/index.d.ts +7 -11
- package/build/lib/instrument/index.d.ts.map +1 -1
- package/build/lib/instrument/index.js +18 -20
- package/build/lib/instrument/index.js.map +1 -1
- package/build/lib/instrument/transformer/dtx-decode.js.map +1 -1
- package/build/lib/instrument/transformer/dtx-encode.js.map +1 -1
- package/build/lib/instrument/transformer/nskeyed.d.ts +30 -30
- package/build/lib/instrument/transformer/nskeyed.d.ts.map +1 -1
- package/build/lib/instrument/transformer/nskeyed.js +45 -45
- package/build/lib/instrument/transformer/nskeyed.js.map +1 -1
- package/build/lib/lockdown/index.d.ts +2 -2
- package/build/lib/lockdown/index.d.ts.map +1 -1
- package/build/lib/lockdown/index.js +2 -3
- package/build/lib/lockdown/index.js.map +1 -1
- package/build/lib/mcinstall/index.d.ts +2 -2
- package/build/lib/mcinstall/index.d.ts.map +1 -1
- package/build/lib/mcinstall/index.js +8 -9
- package/build/lib/mcinstall/index.js.map +1 -1
- package/build/lib/notification-proxy/index.d.ts +2 -2
- package/build/lib/notification-proxy/index.d.ts.map +1 -1
- package/build/lib/notification-proxy/index.js +2 -3
- package/build/lib/notification-proxy/index.js.map +1 -1
- package/build/lib/plist-service/index.d.ts +1 -1
- package/build/lib/plist-service/index.d.ts.map +1 -1
- package/build/lib/plist-service/index.js +26 -9
- package/build/lib/plist-service/index.js.map +1 -1
- package/build/lib/plist-service/transformer/plist-service-decoder.d.ts +1 -1
- package/build/lib/plist-service/transformer/plist-service-decoder.d.ts.map +1 -1
- package/build/lib/plist-service/transformer/plist-service-decoder.js.map +1 -1
- package/build/lib/plist-service/transformer/plist-service-encoder.d.ts +1 -1
- package/build/lib/plist-service/transformer/plist-service-encoder.d.ts.map +1 -1
- package/build/lib/plist-service/transformer/plist-service-encoder.js.map +1 -1
- package/build/lib/services.d.ts +94 -13
- package/build/lib/services.d.ts.map +1 -1
- package/build/lib/services.js +90 -1
- package/build/lib/services.js.map +1 -1
- package/build/lib/simulatelocation/index.d.ts +2 -2
- package/build/lib/simulatelocation/index.d.ts.map +1 -1
- package/build/lib/simulatelocation/index.js +2 -3
- package/build/lib/simulatelocation/index.js.map +1 -1
- package/build/lib/ssl-helper.d.ts +8 -2
- package/build/lib/ssl-helper.d.ts.map +1 -1
- package/build/lib/ssl-helper.js +40 -9
- package/build/lib/ssl-helper.js.map +1 -1
- package/build/lib/syslog/index.d.ts +2 -2
- package/build/lib/syslog/index.d.ts.map +1 -1
- package/build/lib/syslog/index.js +2 -3
- package/build/lib/syslog/index.js.map +1 -1
- package/build/lib/syslog/transformer/syslog-decoder.d.ts +8 -8
- package/build/lib/syslog/transformer/syslog-decoder.d.ts.map +1 -1
- package/build/lib/syslog/transformer/syslog-decoder.js +32 -32
- package/build/lib/syslog/transformer/syslog-decoder.js.map +1 -1
- package/build/lib/testmanagerd/index.d.ts +2 -2
- package/build/lib/testmanagerd/index.d.ts.map +1 -1
- package/build/lib/testmanagerd/index.js +4 -7
- package/build/lib/testmanagerd/index.js.map +1 -1
- package/build/lib/usbmux/index.d.ts +39 -40
- package/build/lib/usbmux/index.d.ts.map +1 -1
- package/build/lib/usbmux/index.js +132 -96
- package/build/lib/usbmux/index.js.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-decoder.d.ts +1 -1
- package/build/lib/usbmux/transformer/usbmux-decoder.d.ts.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-decoder.js.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-encoder.d.ts +1 -1
- package/build/lib/usbmux/transformer/usbmux-encoder.d.ts.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-encoder.js.map +1 -1
- package/build/lib/util/uuid/parse.d.ts +5 -0
- package/build/lib/util/uuid/parse.d.ts.map +1 -1
- package/build/lib/util/uuid/parse.js +5 -0
- package/build/lib/util/uuid/parse.js.map +1 -1
- package/build/lib/util/uuid/stringify.d.ts +6 -0
- package/build/lib/util/uuid/stringify.d.ts.map +1 -1
- package/build/lib/util/uuid/stringify.js +18 -12
- package/build/lib/util/uuid/stringify.js.map +1 -1
- package/build/lib/util/uuid/validate.d.ts +5 -0
- package/build/lib/util/uuid/validate.d.ts.map +1 -1
- package/build/lib/util/uuid/validate.js +5 -0
- package/build/lib/util/uuid/validate.js.map +1 -1
- package/build/lib/utilities.d.ts +58 -58
- package/build/lib/utilities.d.ts.map +1 -1
- package/build/lib/utilities.js +2 -2
- package/build/lib/utilities.js.map +1 -1
- package/build/lib/webinspector/index.d.ts +44 -39
- package/build/lib/webinspector/index.d.ts.map +1 -1
- package/build/lib/webinspector/index.js +39 -35
- package/build/lib/webinspector/index.js.map +1 -1
- package/build/lib/webinspector/transformer/webinspector-decoder.d.ts +1 -1
- package/build/lib/webinspector/transformer/webinspector-decoder.d.ts.map +1 -1
- package/build/lib/webinspector/transformer/webinspector-decoder.js.map +1 -1
- package/build/lib/webinspector/transformer/webinspector-encoder.d.ts +1 -1
- package/build/lib/webinspector/transformer/webinspector-encoder.d.ts.map +1 -1
- package/build/lib/webinspector/transformer/webinspector-encoder.js.map +1 -1
- package/build/lib/xctest.d.ts +17 -17
- package/build/lib/xctest.d.ts.map +1 -1
- package/build/lib/xctest.js +22 -7
- package/build/lib/xctest.js.map +1 -1
- package/index.js +7 -9
- package/lib/afc/index.js +40 -28
- package/lib/afc/protocol.js +17 -17
- package/lib/afc/transformer/afcdecoder.js +1 -2
- package/lib/afc/transformer/afcencoder.js +1 -2
- package/lib/base-service.js +2 -4
- package/lib/constants.js +2 -4
- package/lib/house-arrest/index.js +3 -5
- package/lib/imagemounter/index.js +30 -32
- package/lib/imagemounter/utils/list_developer_image.js +52 -54
- package/lib/installation-proxy/index.js +2 -3
- package/lib/instrument/headers.js +74 -87
- package/lib/instrument/index.js +19 -21
- package/lib/instrument/transformer/dtx-decode.js +1 -3
- package/lib/instrument/transformer/dtx-encode.js +1 -3
- package/lib/instrument/transformer/nskeyed.js +56 -67
- package/lib/lockdown/index.js +2 -3
- package/lib/mcinstall/index.js +9 -10
- package/lib/notification-proxy/index.js +2 -3
- package/lib/plist-service/index.js +27 -8
- package/lib/plist-service/transformer/plist-service-decoder.js +1 -2
- package/lib/plist-service/transformer/plist-service-encoder.js +1 -2
- package/lib/services.js +101 -26
- package/lib/simulatelocation/index.js +2 -3
- package/lib/ssl-helper.js +46 -13
- package/lib/syslog/index.js +2 -3
- package/lib/syslog/transformer/syslog-decoder.js +35 -36
- package/lib/testmanagerd/index.js +4 -11
- package/lib/usbmux/index.js +155 -118
- package/lib/usbmux/transformer/usbmux-decoder.js +1 -2
- package/lib/usbmux/transformer/usbmux-encoder.js +1 -2
- package/lib/util/uuid/parse.ts +5 -0
- package/lib/util/uuid/stringify.ts +21 -15
- package/lib/util/uuid/validate.ts +5 -0
- package/lib/utilities.js +10 -23
- package/lib/webinspector/index.js +47 -43
- package/lib/webinspector/transformer/webinspector-decoder.js +1 -2
- package/lib/webinspector/transformer/webinspector-encoder.js +1 -2
- package/lib/xctest.js +23 -6
- package/package.json +1 -3
package/lib/afc/index.js
CHANGED
|
@@ -4,19 +4,39 @@ import {AfcWritableFileStream, AfcReadableFileStream} from './streams';
|
|
|
4
4
|
import {AfcEncoder} from './transformer/afcencoder';
|
|
5
5
|
import {AfcDecoder} from './transformer/afcdecoder';
|
|
6
6
|
import {MB} from '../constants';
|
|
7
|
-
import B from 'bluebird';
|
|
8
7
|
import path from 'node:path';
|
|
9
8
|
import _ from 'lodash';
|
|
10
9
|
import {BaseServiceSocket} from '../base-service';
|
|
11
10
|
import {getMaxFrameLength} from '../utilities';
|
|
12
11
|
|
|
13
|
-
const AFC_SERVICE_NAME = 'com.apple.afc';
|
|
12
|
+
export const AFC_SERVICE_NAME = 'com.apple.afc';
|
|
14
13
|
const MAX_FRAME_SIZE = 1 * MB;
|
|
15
14
|
|
|
16
15
|
const NULL_DELIMITER_CODE = 0x00;
|
|
17
16
|
const IGNORED_PATHS = ['.', '..'];
|
|
18
17
|
|
|
19
|
-
class
|
|
18
|
+
class FileInfo {
|
|
19
|
+
constructor({st_size, st_blocks, st_nlink, st_ifmt, st_mtime, st_birthtime}) {
|
|
20
|
+
this.size = parseInt(st_size, 10);
|
|
21
|
+
this.blocks = parseInt(st_blocks, 10);
|
|
22
|
+
this.nlink = parseInt(st_nlink, 10);
|
|
23
|
+
this.ifmt = st_ifmt;
|
|
24
|
+
// ns to ms
|
|
25
|
+
this.mtimeMs = parseInt(st_mtime, 10) / 1000000;
|
|
26
|
+
// ns to ms
|
|
27
|
+
this.birthtimeMs = parseInt(st_birthtime, 10) / 1000000;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
isDirectory() {
|
|
31
|
+
return this.ifmt === 'S_IFDIR';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
isFile() {
|
|
35
|
+
return this.ifmt === 'S_IFREG';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class AfcService extends BaseServiceSocket {
|
|
20
40
|
constructor(socketClient) {
|
|
21
41
|
super(socketClient);
|
|
22
42
|
|
|
@@ -325,40 +345,32 @@ class AfcService extends BaseServiceSocket {
|
|
|
325
345
|
|
|
326
346
|
_createPacketPromise(message, timeout = 10000) {
|
|
327
347
|
const packetNumber = this._packetNumber++;
|
|
328
|
-
const response = new
|
|
329
|
-
|
|
330
|
-
setTimeout(
|
|
348
|
+
const response = new Promise((resolve, reject) => {
|
|
349
|
+
let isSettled = false;
|
|
350
|
+
const timeoutHandler = setTimeout(() => {
|
|
351
|
+
if (isSettled) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
isSettled = true;
|
|
355
|
+
delete this._responseCallbacks[packetNumber];
|
|
331
356
|
reject(
|
|
332
357
|
new Error(
|
|
333
358
|
`Could not finish the operation '${message}'. Failed to receive any data within the ${timeout}ms timeout`,
|
|
334
359
|
),
|
|
335
360
|
);
|
|
336
361
|
}, timeout);
|
|
362
|
+
this._responseCallbacks[packetNumber] = (data) => {
|
|
363
|
+
if (isSettled) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
isSettled = true;
|
|
367
|
+
clearTimeout(timeoutHandler);
|
|
368
|
+
delete this._responseCallbacks[packetNumber];
|
|
369
|
+
resolve(data);
|
|
370
|
+
};
|
|
337
371
|
});
|
|
338
372
|
return {packetNumber, response};
|
|
339
373
|
}
|
|
340
374
|
}
|
|
341
375
|
|
|
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
376
|
export default AfcService;
|
|
364
|
-
export {AfcService, AFC_SERVICE_NAME};
|
package/lib/afc/protocol.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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;
|
package/lib/base-service.js
CHANGED
|
@@ -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
|
@@ -3,14 +3,13 @@ import {PlistServiceEncoder} from '../plist-service/transformer/plist-service-en
|
|
|
3
3
|
import {LengthBasedSplitter} from '../util/transformer/length-based-splitter';
|
|
4
4
|
import {KB} from '../constants';
|
|
5
5
|
import {AfcService} from '../afc';
|
|
6
|
-
import B from 'bluebird';
|
|
7
6
|
import {BaseServiceSocket} from '../base-service';
|
|
8
7
|
import {getMaxFrameLength} from '../utilities';
|
|
9
8
|
|
|
10
|
-
const HOUSE_ARREST_SERVICE_NAME = 'com.apple.mobile.house_arrest';
|
|
9
|
+
export const HOUSE_ARREST_SERVICE_NAME = 'com.apple.mobile.house_arrest';
|
|
11
10
|
const MAX_FRAME_SIZE = 1 * KB;
|
|
12
11
|
|
|
13
|
-
class HouseArrestService extends BaseServiceSocket {
|
|
12
|
+
export class HouseArrestService extends BaseServiceSocket {
|
|
14
13
|
constructor(socketClient) {
|
|
15
14
|
super(socketClient);
|
|
16
15
|
|
|
@@ -73,7 +72,7 @@ class HouseArrestService extends BaseServiceSocket {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
_receivePlistPromise(timeout = 10000) {
|
|
76
|
-
return new
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
77
76
|
this._decoder.once('data', resolve);
|
|
78
77
|
setTimeout(
|
|
79
78
|
() => reject(new Error(`Failed to receive any data within the timeout: ${timeout}`)),
|
|
@@ -83,5 +82,4 @@ class HouseArrestService extends BaseServiceSocket {
|
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
export {HouseArrestService, HOUSE_ARREST_SERVICE_NAME};
|
|
87
85
|
export default HouseArrestService;
|
|
@@ -1,40 +1,13 @@
|
|
|
1
1
|
import {BaseServicePlist} from '../base-service';
|
|
2
2
|
import {fs} from '@appium/support';
|
|
3
|
-
import B from 'bluebird';
|
|
4
3
|
import {log} from '../logger';
|
|
5
4
|
const {lstat, readFile, createReadStream} = fs;
|
|
6
5
|
|
|
7
|
-
const MOBILE_IMAGE_MOUNTER_SERVICE_NAME = 'com.apple.mobile.mobile_image_mounter';
|
|
6
|
+
export const MOBILE_IMAGE_MOUNTER_SERVICE_NAME = 'com.apple.mobile.mobile_image_mounter';
|
|
8
7
|
const FILE_TYPE_IMAGE = 'image';
|
|
9
8
|
const FILE_TYPE_SIGNATURE = 'signature';
|
|
10
9
|
|
|
11
|
-
|
|
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 {
|
|
10
|
+
export class ImageMounter extends BaseServicePlist {
|
|
38
11
|
/**
|
|
39
12
|
* Lookup for mounted images.
|
|
40
13
|
* @param {string} imageType Type of image, `Developer` by default.
|
|
@@ -63,7 +36,7 @@ class ImageMounter extends BaseServicePlist {
|
|
|
63
36
|
*/
|
|
64
37
|
async mount(imageFilePath, imageSignatureFilePath, imageType = 'Developer') {
|
|
65
38
|
//check file stats
|
|
66
|
-
const [imageFileStat] = await
|
|
39
|
+
const [imageFileStat] = await Promise.all([
|
|
67
40
|
assertIsFile(imageFilePath, FILE_TYPE_IMAGE),
|
|
68
41
|
assertIsFile(imageSignatureFilePath, FILE_TYPE_SIGNATURE),
|
|
69
42
|
]);
|
|
@@ -91,7 +64,7 @@ class ImageMounter extends BaseServicePlist {
|
|
|
91
64
|
//push image to device
|
|
92
65
|
const stream = createReadStream(imageFilePath);
|
|
93
66
|
try {
|
|
94
|
-
await new
|
|
67
|
+
await new Promise((resolve, reject) => {
|
|
95
68
|
stream.on('end', resolve);
|
|
96
69
|
stream.on('error', reject);
|
|
97
70
|
stream.on('data', async (data) => {
|
|
@@ -124,4 +97,29 @@ class ImageMounter extends BaseServicePlist {
|
|
|
124
97
|
checkIfError(mountResult);
|
|
125
98
|
}
|
|
126
99
|
}
|
|
127
|
-
|
|
100
|
+
|
|
101
|
+
function checkIfError(ret) {
|
|
102
|
+
if (ret.Error) {
|
|
103
|
+
throw new Error(ret.Error);
|
|
104
|
+
}
|
|
105
|
+
return ret;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function assertIsFile(filePath, fileType) {
|
|
109
|
+
/** @type {import('fs').Stats | undefined} */
|
|
110
|
+
let fileStat;
|
|
111
|
+
try {
|
|
112
|
+
fileStat = await lstat(filePath);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
if (/** @type {NodeJS.ErrnoException} */ (err).code === 'ENOENT') {
|
|
115
|
+
throw new Error(`The provided ${fileType} path does not exist: ${filePath}`, {cause: err});
|
|
116
|
+
}
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
if (fileStat.isDirectory()) {
|
|
120
|
+
throw new Error(
|
|
121
|
+
`The provided ${fileType} path is expected to be a file, but a directory was given: ${filePath}`,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return fileStat;
|
|
125
|
+
}
|
|
@@ -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;
|