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.
- package/CHANGELOG.md +12 -0
- package/build/lib/afc/index.d.ts +1 -1
- package/build/lib/afc/index.d.ts.map +1 -1
- package/build/lib/afc/index.js +9 -9
- package/build/lib/afc/index.js.map +1 -1
- package/build/lib/afc/protocol.d.ts.map +1 -1
- package/build/lib/afc/protocol.js +16 -16
- package/build/lib/afc/protocol.js.map +1 -1
- package/build/lib/afc/streams.d.ts.map +1 -1
- package/build/lib/afc/streams.js.map +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.map +1 -1
- package/build/lib/afc/transformer/afcencoder.js.map +1 -1
- package/build/lib/base-service.d.ts.map +1 -1
- package/build/lib/base-service.js.map +1 -1
- package/build/lib/house-arrest/index.d.ts.map +1 -1
- package/build/lib/house-arrest/index.js.map +1 -1
- package/build/lib/imagemounter/index.d.ts.map +1 -1
- package/build/lib/imagemounter/index.js +4 -4
- package/build/lib/imagemounter/index.js.map +1 -1
- package/build/lib/imagemounter/utils/list_developer_image.d.ts.map +1 -1
- package/build/lib/imagemounter/utils/list_developer_image.js +3 -3
- package/build/lib/imagemounter/utils/list_developer_image.js.map +1 -1
- package/build/lib/installation-proxy/index.d.ts +11 -11
- package/build/lib/installation-proxy/index.d.ts.map +1 -1
- package/build/lib/installation-proxy/index.js +19 -17
- package/build/lib/installation-proxy/index.js.map +1 -1
- package/build/lib/instrument/headers.d.ts.map +1 -1
- package/build/lib/instrument/headers.js +7 -7
- package/build/lib/instrument/headers.js.map +1 -1
- package/build/lib/instrument/index.d.ts +1 -1
- package/build/lib/instrument/index.d.ts.map +1 -1
- package/build/lib/instrument/index.js +13 -7
- package/build/lib/instrument/index.js.map +1 -1
- package/build/lib/instrument/transformer/dtx-decode.d.ts.map +1 -1
- package/build/lib/instrument/transformer/dtx-decode.js +9 -3
- package/build/lib/instrument/transformer/dtx-decode.js.map +1 -1
- package/build/lib/instrument/transformer/dtx-encode.d.ts.map +1 -1
- package/build/lib/instrument/transformer/dtx-encode.js +1 -1
- package/build/lib/instrument/transformer/dtx-encode.js.map +1 -1
- package/build/lib/instrument/transformer/nskeyed.d.ts.map +1 -1
- package/build/lib/instrument/transformer/nskeyed.js +16 -9
- package/build/lib/instrument/transformer/nskeyed.js.map +1 -1
- package/build/lib/lockdown/index.d.ts +5 -5
- package/build/lib/lockdown/index.d.ts.map +1 -1
- package/build/lib/lockdown/index.js +9 -10
- package/build/lib/lockdown/index.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/mcinstall/index.d.ts.map +1 -1
- package/build/lib/mcinstall/index.js +14 -6
- package/build/lib/mcinstall/index.js.map +1 -1
- package/build/lib/notification-proxy/index.d.ts.map +1 -1
- package/build/lib/notification-proxy/index.js +2 -2
- package/build/lib/notification-proxy/index.js.map +1 -1
- package/build/lib/plist-service/index.d.ts.map +1 -1
- package/build/lib/plist-service/index.js.map +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.map +1 -1
- package/build/lib/plist-service/transformer/plist-service-encoder.js.map +1 -1
- package/build/lib/services.d.ts.map +1 -1
- package/build/lib/services.js +3 -3
- package/build/lib/services.js.map +1 -1
- package/build/lib/simulatelocation/index.d.ts.map +1 -1
- package/build/lib/simulatelocation/index.js.map +1 -1
- package/build/lib/ssl-helper.js +3 -3
- package/build/lib/ssl-helper.js.map +1 -1
- package/build/lib/syslog/index.d.ts +1 -1
- package/build/lib/syslog/index.d.ts.map +1 -1
- package/build/lib/syslog/index.js +1 -1
- package/build/lib/syslog/index.js.map +1 -1
- package/build/lib/syslog/transformer/syslog-decoder.d.ts.map +1 -1
- package/build/lib/syslog/transformer/syslog-decoder.js +4 -2
- package/build/lib/syslog/transformer/syslog-decoder.js.map +1 -1
- package/build/lib/testmanagerd/index.d.ts.map +1 -1
- package/build/lib/testmanagerd/index.js.map +1 -1
- package/build/lib/usbmux/index.d.ts.map +1 -1
- package/build/lib/usbmux/index.js +16 -13
- package/build/lib/usbmux/index.js.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-decoder.d.ts.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-decoder.js +1 -1
- package/build/lib/usbmux/transformer/usbmux-decoder.js.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-encoder.d.ts.map +1 -1
- package/build/lib/usbmux/transformer/usbmux-encoder.js +1 -1
- package/build/lib/usbmux/transformer/usbmux-encoder.js.map +1 -1
- package/build/lib/util/transformer/length-based-splitter.d.ts.map +1 -1
- package/build/lib/util/transformer/length-based-splitter.js +9 -4
- package/build/lib/util/transformer/length-based-splitter.js.map +1 -1
- package/build/lib/util/transformer/stream-logger.d.ts.map +1 -1
- package/build/lib/util/transformer/stream-logger.js +4 -3
- package/build/lib/util/transformer/stream-logger.js.map +1 -1
- package/build/lib/util/uuid/parse.js.map +1 -1
- package/build/lib/util/uuid/stringify.js.map +1 -1
- package/build/lib/util/uuid/validate.d.ts.map +1 -1
- package/build/lib/util/uuid/validate.js.map +1 -1
- package/build/lib/utilities.d.ts.map +1 -1
- package/build/lib/utilities.js +12 -12
- package/build/lib/utilities.js.map +1 -1
- package/build/lib/webinspector/index.d.ts.map +1 -1
- package/build/lib/webinspector/index.js +11 -9
- package/build/lib/webinspector/index.js.map +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.map +1 -1
- package/build/lib/webinspector/transformer/webinspector-encoder.js.map +1 -1
- package/build/lib/xctest.d.ts.map +1 -1
- package/build/lib/xctest.js +3 -6
- package/build/lib/xctest.js.map +1 -1
- package/lib/afc/index.js +49 -43
- package/lib/afc/protocol.js +53 -50
- package/lib/afc/streams.js +7 -9
- package/lib/afc/transformer/afcdecoder.js +8 -10
- package/lib/afc/transformer/afcencoder.js +7 -10
- package/lib/base-service.js +2 -4
- package/lib/constants.js +1 -1
- package/lib/house-arrest/index.js +16 -14
- package/lib/imagemounter/index.js +107 -104
- package/lib/imagemounter/utils/list_developer_image.js +115 -100
- package/lib/installation-proxy/index.js +31 -27
- package/lib/instrument/headers.js +51 -40
- package/lib/instrument/index.js +32 -21
- package/lib/instrument/transformer/dtx-decode.js +30 -16
- package/lib/instrument/transformer/dtx-encode.js +6 -8
- package/lib/instrument/transformer/nskeyed.js +40 -21
- package/lib/lockdown/index.js +44 -35
- package/lib/logger.js +1 -1
- package/lib/mcinstall/index.js +20 -13
- package/lib/notification-proxy/index.js +18 -17
- package/lib/plist-service/index.js +13 -14
- package/lib/plist-service/transformer/plist-service-decoder.js +6 -7
- package/lib/plist-service/transformer/plist-service-encoder.js +6 -7
- package/lib/services.js +45 -29
- package/lib/simulatelocation/index.js +4 -5
- package/lib/ssl-helper.js +6 -7
- package/lib/syslog/index.js +7 -8
- package/lib/syslog/transformer/syslog-decoder.js +11 -10
- package/lib/testmanagerd/index.js +10 -7
- package/lib/usbmux/index.js +52 -41
- package/lib/usbmux/transformer/usbmux-decoder.js +8 -10
- package/lib/usbmux/transformer/usbmux-encoder.js +10 -8
- package/lib/util/transformer/length-based-splitter.js +62 -24
- package/lib/util/transformer/stream-logger.js +14 -11
- package/lib/util/uuid/parse.ts +2 -2
- package/lib/util/uuid/stringify.ts +1 -1
- package/lib/util/uuid/validate.ts +2 -1
- package/lib/utilities.js +39 -28
- package/lib/webinspector/index.js +59 -46
- package/lib/webinspector/transformer/webinspector-decoder.js +22 -11
- package/lib/webinspector/transformer/webinspector-encoder.js +6 -8
- package/lib/xctest.js +284 -245
- package/package.json +4 -2
package/lib/services.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import {connectPort, connectPortSSL, startLockdownSession, getOSVersion} from './utilities';
|
|
2
|
+
import {SyslogService, SYSLOG_SERVICE_NAME} from './syslog';
|
|
3
|
+
import {SimulateLocationService, SIMULATE_LOCATION_SERVICE_NAME} from './simulatelocation';
|
|
4
|
+
import {WebInspectorService, WEB_INSPECTOR_SERVICE_NAME} from './webinspector';
|
|
5
|
+
import {InstallationProxyService, INSTALLATION_PROXY_SERVICE_NAME} from './installation-proxy';
|
|
6
|
+
import {AfcService, AFC_SERVICE_NAME} from './afc';
|
|
7
|
+
import {NotificationProxyService, NOTIFICATION_PROXY_SERVICE_NAME} from './notification-proxy';
|
|
8
|
+
import {HouseArrestService, HOUSE_ARREST_SERVICE_NAME} from './house-arrest';
|
|
9
|
+
import {
|
|
10
|
+
InstrumentService,
|
|
11
|
+
INSTRUMENT_SERVICE_NAME_VERSION_14,
|
|
12
|
+
INSTRUMENT_SERVICE_NAME,
|
|
13
|
+
} from './instrument';
|
|
14
|
+
import {
|
|
15
|
+
TestmanagerdService,
|
|
16
|
+
TESTMANAGERD_SERVICE_NAME_VERSION_14,
|
|
17
|
+
TESTMANAGERD_SERVICE_NAME,
|
|
18
|
+
} from './testmanagerd';
|
|
19
|
+
import {MCInstallProxyService, MC_INSTALL_SERVICE_NAME} from './mcinstall';
|
|
20
|
+
import {ImageMounter, MOBILE_IMAGE_MOUNTER_SERVICE_NAME} from './imagemounter';
|
|
21
|
+
import {PlistService} from './plist-service';
|
|
14
22
|
import * as semver from 'semver';
|
|
15
23
|
|
|
16
|
-
|
|
17
24
|
const CRASH_LOG_SERVICE_NAME = 'com.apple.crashreportcopymobile';
|
|
18
25
|
const INSTRUMENT_HANDSHAKE_VERSION = 14;
|
|
19
26
|
const TESTMANAGERD_HANDSHAKE_VERSION = 14;
|
|
@@ -29,7 +36,7 @@ async function startSimulateLocationService(udid, opts = {}) {
|
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
async function startWebInspectorService(udid, opts = {}) {
|
|
32
|
-
const osVersion = opts.osVersion || await getOSVersion(udid, opts.socket);
|
|
39
|
+
const osVersion = opts.osVersion || (await getOSVersion(udid, opts.socket));
|
|
33
40
|
const isSimulator = !!opts.isSimulator;
|
|
34
41
|
const verbose = !!opts.verbose;
|
|
35
42
|
const verboseHexDump = !!opts.verboseHexDump;
|
|
@@ -88,18 +95,20 @@ async function startHouseArrestService(udid, opts = {}) {
|
|
|
88
95
|
}
|
|
89
96
|
|
|
90
97
|
async function startInstrumentService(udid, opts = {}) {
|
|
91
|
-
const osVersion = opts.osVersion || await getOSVersion(udid, opts.socket);
|
|
92
|
-
return new InstrumentService(
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
const osVersion = opts.osVersion || (await getOSVersion(udid, opts.socket));
|
|
99
|
+
return new InstrumentService(
|
|
100
|
+
parseInt(osVersion.split('.')[0], 10) < INSTRUMENT_HANDSHAKE_VERSION
|
|
101
|
+
? await startService(udid, INSTRUMENT_SERVICE_NAME, opts.socket, true)
|
|
102
|
+
: await startService(udid, INSTRUMENT_SERVICE_NAME_VERSION_14, opts.socket),
|
|
95
103
|
);
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
async function startTestmanagerdService(udid, opts = {}) {
|
|
99
|
-
const osVersion = opts.osVersion || await getOSVersion(udid, opts.socket);
|
|
100
|
-
return new TestmanagerdService(
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
const osVersion = opts.osVersion || (await getOSVersion(udid, opts.socket));
|
|
108
|
+
return new TestmanagerdService(
|
|
109
|
+
parseInt(osVersion.split('.')[0], 10) < TESTMANAGERD_HANDSHAKE_VERSION
|
|
110
|
+
? await startService(udid, TESTMANAGERD_SERVICE_NAME, opts.socket, true)
|
|
111
|
+
: await startService(udid, TESTMANAGERD_SERVICE_NAME_VERSION_14, opts.socket),
|
|
103
112
|
);
|
|
104
113
|
}
|
|
105
114
|
|
|
@@ -128,9 +137,16 @@ async function startService(udid, serviceName, socket, handshakeOnly = false) {
|
|
|
128
137
|
}
|
|
129
138
|
|
|
130
139
|
export {
|
|
131
|
-
startSyslogService,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
startSyslogService,
|
|
141
|
+
startWebInspectorService,
|
|
142
|
+
startInstallationProxyService,
|
|
143
|
+
startSimulateLocationService,
|
|
144
|
+
startAfcService,
|
|
145
|
+
startCrashLogService,
|
|
146
|
+
startNotificationProxyService,
|
|
147
|
+
startHouseArrestService,
|
|
148
|
+
startInstrumentService,
|
|
149
|
+
startTestmanagerdService,
|
|
150
|
+
startMCInstallService,
|
|
151
|
+
startImageMounterService,
|
|
152
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {BaseServiceSocket} from '../base-service';
|
|
3
2
|
|
|
4
3
|
const SIMULATE_LOCATION_SERVICE_NAME = 'com.apple.dt.simulatelocation';
|
|
5
4
|
|
|
@@ -10,7 +9,7 @@ class SimulateLocationService extends BaseServiceSocket {
|
|
|
10
9
|
/**
|
|
11
10
|
* Reset the mock location to the phones original settings
|
|
12
11
|
*/
|
|
13
|
-
resetLocation
|
|
12
|
+
resetLocation() {
|
|
14
13
|
this._socketClient.write(RESET_MESSAGE);
|
|
15
14
|
}
|
|
16
15
|
|
|
@@ -19,7 +18,7 @@ class SimulateLocationService extends BaseServiceSocket {
|
|
|
19
18
|
* @param {string|number} lat The latitude that wants to be set on the device
|
|
20
19
|
* @param {string|number} long The longitude that wants to be set on the device
|
|
21
20
|
*/
|
|
22
|
-
setLocation
|
|
21
|
+
setLocation(lat, long) {
|
|
23
22
|
lat = `${lat}`;
|
|
24
23
|
long = `${long}`;
|
|
25
24
|
|
|
@@ -39,5 +38,5 @@ class SimulateLocationService extends BaseServiceSocket {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
export {
|
|
41
|
+
export {SimulateLocationService, SIMULATE_LOCATION_SERVICE_NAME};
|
|
43
42
|
export default SimulateLocationService;
|
package/lib/ssl-helper.js
CHANGED
|
@@ -4,13 +4,13 @@ import B from 'bluebird';
|
|
|
4
4
|
|
|
5
5
|
const HANDSHAKE_TIMEOUT_MS = 10000;
|
|
6
6
|
|
|
7
|
-
function upgradeToSSL
|
|
7
|
+
function upgradeToSSL(socket, key, cert) {
|
|
8
8
|
return new tls.TLSSocket(socket, {
|
|
9
9
|
rejectUnauthorized: false,
|
|
10
10
|
secureContext: tls.createSecureContext({
|
|
11
11
|
key,
|
|
12
|
-
cert
|
|
13
|
-
})
|
|
12
|
+
cert,
|
|
13
|
+
}),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -21,12 +21,12 @@ function upgradeToSSL (socket, key, cert) {
|
|
|
21
21
|
* @param cert
|
|
22
22
|
* @returns {Promise<NodeJS.Socket>} Duplicate the input socket
|
|
23
23
|
*/
|
|
24
|
-
async function enableSSLHandshakeOnly
|
|
24
|
+
async function enableSSLHandshakeOnly(socket, key, cert) {
|
|
25
25
|
const sslSocket = tls.connect({
|
|
26
26
|
socket,
|
|
27
27
|
secureContext: tls.createSecureContext({
|
|
28
28
|
key,
|
|
29
|
-
cert
|
|
29
|
+
cert,
|
|
30
30
|
}),
|
|
31
31
|
rejectUnauthorized: false,
|
|
32
32
|
});
|
|
@@ -51,5 +51,4 @@ async function enableSSLHandshakeOnly (socket, key, cert) {
|
|
|
51
51
|
return new net.Socket({fd: socket._handle.fd});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
export { upgradeToSSL, enableSSLHandshakeOnly };
|
|
54
|
+
export {upgradeToSSL, enableSSLHandshakeOnly};
|
package/lib/syslog/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import {SyslogDecoder} from './transformer/syslog-decoder';
|
|
2
|
+
import {KB} from '../constants';
|
|
3
|
+
import {BaseServiceSocket} from '../base-service';
|
|
5
4
|
|
|
6
5
|
//We just need to write any data to the client. It doesn't matter what we send
|
|
7
6
|
const SYSLOG_SERVICE_NAME = 'com.apple.syslog_relay';
|
|
8
7
|
const START_MESSAGE = 'start';
|
|
9
8
|
|
|
10
9
|
class SyslogService extends BaseServiceSocket {
|
|
11
|
-
constructor
|
|
10
|
+
constructor(socketClient) {
|
|
12
11
|
super(socketClient);
|
|
13
12
|
|
|
14
13
|
this._decoder = new SyslogDecoder(5 * KB);
|
|
@@ -18,17 +17,17 @@ class SyslogService extends BaseServiceSocket {
|
|
|
18
17
|
/** The callback function which will be called during log listening
|
|
19
18
|
* @callback LogCallback
|
|
20
19
|
* @param {string} log The log that is sent from the phone
|
|
21
|
-
|
|
20
|
+
*/
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* Start receiving logs from the phone. The callback when a log is received
|
|
25
24
|
* @param {LogCallback} onData
|
|
26
25
|
*/
|
|
27
|
-
start
|
|
26
|
+
start(onData) {
|
|
28
27
|
this._decoder.on('data', onData);
|
|
29
28
|
this._socketClient.write(START_MESSAGE);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export {
|
|
32
|
+
export {SyslogService, SYSLOG_SERVICE_NAME};
|
|
34
33
|
export default SyslogService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Stream from 'node:stream';
|
|
2
2
|
|
|
3
|
-
const NEW_LINE_CODE =
|
|
3
|
+
const NEW_LINE_CODE = 0x0a;
|
|
4
4
|
const NULL_DELIMITER_CODE = 0x00;
|
|
5
5
|
const BACKSLASH_CODE = '\\'.codePointAt(0);
|
|
6
6
|
const M_CODE = 'M'.charCodeAt(0);
|
|
@@ -10,7 +10,6 @@ const ARROW_CODE = '^'.charCodeAt(0);
|
|
|
10
10
|
const ARROW_SHIFT = 0x40;
|
|
11
11
|
const ESCAPE_TOKEN_LEN = 4;
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* Unescapes utf8-encoded characters, so the output looks
|
|
16
15
|
* like a valid string. See https://github.com/appium/appium/issues/14476
|
|
@@ -27,7 +26,11 @@ function toUtf8String(logBuffer) {
|
|
|
27
26
|
const utf8CharsAsBytes = [];
|
|
28
27
|
while (cursor <= logBuffer.length - ESCAPE_TOKEN_LEN) {
|
|
29
28
|
logBuffer.copy(token, 0, cursor, cursor + ESCAPE_TOKEN_LEN);
|
|
30
|
-
if (
|
|
29
|
+
if (
|
|
30
|
+
token[0] !== BACKSLASH_CODE &&
|
|
31
|
+
token[1] !== M_CODE &&
|
|
32
|
+
![DASH_CODE, ARROW_CODE].includes(token[2])
|
|
33
|
+
) {
|
|
31
34
|
return [cursor, utf8CharsAsBytes];
|
|
32
35
|
}
|
|
33
36
|
const nextByte = token[3] + (token[2] === DASH_CODE ? DASH_SHIFT : ARROW_SHIFT);
|
|
@@ -54,21 +57,19 @@ function toUtf8String(logBuffer) {
|
|
|
54
57
|
return Buffer.from(utf8Codes).toString('utf8');
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
58
60
|
class SyslogDecoder extends Stream.Transform {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
super({ objectMode: true });
|
|
61
|
+
constructor(bufferLength) {
|
|
62
|
+
super({objectMode: true});
|
|
62
63
|
this.bufferIndex = 0;
|
|
63
64
|
this.buffer = Buffer.allocUnsafe(bufferLength);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
_transform
|
|
67
|
+
_transform(data, encoding, onData) {
|
|
67
68
|
this._decode(data);
|
|
68
69
|
onData();
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
_decode
|
|
72
|
+
_decode(data) {
|
|
72
73
|
for (const byte of data) {
|
|
73
74
|
// Don't store the null delimiter messages
|
|
74
75
|
if (byte === NULL_DELIMITER_CODE) {
|
|
@@ -90,5 +91,5 @@ class SyslogDecoder extends Stream.Transform {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
export {
|
|
94
|
+
export {SyslogDecoder, toUtf8String};
|
|
94
95
|
export default SyslogDecoder;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {InstrumentService} from '../instrument';
|
|
2
2
|
|
|
3
3
|
const TESTMANAGERD_SERVICE_NAME_VERSION_14 = 'com.apple.testmanagerd.lockdown.secure';
|
|
4
4
|
const TESTMANAGERD_SERVICE_NAME = 'com.apple.testmanagerd.lockdown';
|
|
5
5
|
|
|
6
6
|
const TESTMANAGERD_CHANNEL = Object.freeze({
|
|
7
|
-
|
|
7
|
+
DAEMON_CONNECTION_INTERFACE:
|
|
8
|
+
'dtxproxy:XCTestManager_IDEInterface:XCTestManager_DaemonConnectionInterface',
|
|
8
9
|
});
|
|
9
10
|
|
|
11
|
+
class TestmanagerdService extends InstrumentService {}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export {
|
|
14
|
+
TestmanagerdService,
|
|
15
|
+
TESTMANAGERD_SERVICE_NAME_VERSION_14,
|
|
16
|
+
TESTMANAGERD_SERVICE_NAME,
|
|
17
|
+
TESTMANAGERD_CHANNEL,
|
|
18
|
+
};
|
package/lib/usbmux/index.js
CHANGED
|
@@ -2,17 +2,17 @@ import net from 'node:net';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import B from 'bluebird';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import {plist, fs} from '@appium/support';
|
|
6
|
+
import {LengthBasedSplitter} from '../util/transformer/length-based-splitter';
|
|
7
|
+
import {UsbmuxDecoder} from './transformer/usbmux-decoder.js';
|
|
8
|
+
import {UsbmuxEncoder} from './transformer/usbmux-encoder.js';
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
10
|
+
import {PlistService} from '../plist-service';
|
|
11
|
+
import {Lockdown, LOCKDOWN_PORT} from '../lockdown';
|
|
12
|
+
import {BaseServiceSocket} from '../base-service';
|
|
13
|
+
import {getMaxFrameLength} from '../utilities';
|
|
14
|
+
import {MB} from '../constants';
|
|
15
|
+
import {log} from '../logger';
|
|
16
16
|
|
|
17
17
|
const MAX_FRAME_SIZE = 1 * MB;
|
|
18
18
|
|
|
@@ -26,10 +26,10 @@ const USBMUX_RESULT = {
|
|
|
26
26
|
let name, version;
|
|
27
27
|
try {
|
|
28
28
|
// first try assuming this is in the `build` folder
|
|
29
|
-
({
|
|
29
|
+
({name, version} = require(path.resolve(__dirname, '..', '..', '..', 'package.json')));
|
|
30
30
|
} catch {
|
|
31
31
|
// then try assuming it is not
|
|
32
|
-
({
|
|
32
|
+
({name, version} = require(path.resolve(__dirname, '..', '..', 'package.json')));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const DEFAULT_USBMUXD_SOCKET = '/var/run/usbmuxd';
|
|
@@ -38,8 +38,8 @@ const DEFAULT_USBMUXD_HOST = '127.0.0.1';
|
|
|
38
38
|
const PROG_NAME = name;
|
|
39
39
|
const CLIENT_VERSION_STRING = `${name}-${version}`;
|
|
40
40
|
|
|
41
|
-
function swap16
|
|
42
|
-
return ((val &
|
|
41
|
+
function swap16(val) {
|
|
42
|
+
return ((val & 0xff) << 8) | ((val >> 8) & 0xff);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -65,7 +65,7 @@ async function getDefaultSocket(opts = {}) {
|
|
|
65
65
|
socketPath: DEFAULT_USBMUXD_SOCKET,
|
|
66
66
|
socketPort: DEFAULT_USBMUXD_PORT,
|
|
67
67
|
socketHost: DEFAULT_USBMUXD_HOST,
|
|
68
|
-
timeout: 5000
|
|
68
|
+
timeout: 5000,
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const hasOpts = Object.values(opts).some((v) => !_.isNil(v));
|
|
@@ -91,10 +91,14 @@ async function getDefaultSocket(opts = {}) {
|
|
|
91
91
|
|
|
92
92
|
const hasExplicitPath = !!(opts.socketPath || envOpts.socketPath);
|
|
93
93
|
const hasExplicitHostPort = !!(
|
|
94
|
-
opts.socketHost ||
|
|
94
|
+
opts.socketHost ||
|
|
95
|
+
opts.socketPort ||
|
|
96
|
+
envOpts.socketHost ||
|
|
97
|
+
envOpts.socketPort
|
|
95
98
|
);
|
|
96
|
-
const isWinOrWsl =
|
|
97
|
-
|
|
99
|
+
const isWinOrWsl =
|
|
100
|
+
process.platform === 'win32' ||
|
|
101
|
+
(process.platform === 'linux' && /microsoft/i.test(os.release()));
|
|
98
102
|
const preferPath = hasExplicitPath || !(hasExplicitHostPort || isWinOrWsl);
|
|
99
103
|
|
|
100
104
|
let socket;
|
|
@@ -102,7 +106,9 @@ async function getDefaultSocket(opts = {}) {
|
|
|
102
106
|
if (preferPath) {
|
|
103
107
|
const pathExists = await fs.exists(socketPath);
|
|
104
108
|
if (!pathExists) {
|
|
105
|
-
throw new Error(
|
|
109
|
+
throw new Error(
|
|
110
|
+
`The usbmuxd socket path '${socketPath}' does not exist or is not accessible`,
|
|
111
|
+
);
|
|
106
112
|
}
|
|
107
113
|
socket = net.createConnection(socketPath);
|
|
108
114
|
} else {
|
|
@@ -120,12 +126,14 @@ async function getDefaultSocket(opts = {}) {
|
|
|
120
126
|
*
|
|
121
127
|
* @returns {Partial<SocketOptions>}
|
|
122
128
|
*/
|
|
123
|
-
function getSocketOptionsFromEnv
|
|
129
|
+
function getSocketOptionsFromEnv() {
|
|
124
130
|
let usbmuxdSocketAddress = process.env.USBMUXD_SOCKET_ADDRESS;
|
|
125
131
|
if (!usbmuxdSocketAddress) {
|
|
126
132
|
return {};
|
|
127
133
|
}
|
|
128
|
-
log.debug(
|
|
134
|
+
log.debug(
|
|
135
|
+
`Using USBMUXD_SOCKET_ADDRESS environment variable as default socket: ${usbmuxdSocketAddress}`,
|
|
136
|
+
);
|
|
129
137
|
// "unix:" or "UNIX:" prefix is optional for unix socket paths.
|
|
130
138
|
usbmuxdSocketAddress = usbmuxdSocketAddress.replace(/^(unix):/i, '');
|
|
131
139
|
const [ip, port] = usbmuxdSocketAddress.split(':');
|
|
@@ -141,7 +149,7 @@ function getSocketOptionsFromEnv () {
|
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
class Usbmux extends BaseServiceSocket {
|
|
144
|
-
constructor
|
|
152
|
+
constructor(socketClient) {
|
|
145
153
|
super(socketClient);
|
|
146
154
|
|
|
147
155
|
this._decoder = new UsbmuxDecoder();
|
|
@@ -164,7 +172,7 @@ class Usbmux extends BaseServiceSocket {
|
|
|
164
172
|
this._decoder.on('data', this._handleData.bind(this));
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
_handleData
|
|
175
|
+
_handleData(data) {
|
|
168
176
|
const cb = this._responseCallbacks[data.header.tag] || _.noop;
|
|
169
177
|
cb(data); // eslint-disable-line promise/prefer-await-to-callbacks
|
|
170
178
|
}
|
|
@@ -174,7 +182,7 @@ class Usbmux extends BaseServiceSocket {
|
|
|
174
182
|
* @param {number} [timeout=5000] the timeout of receiving a response from usbmuxd
|
|
175
183
|
* @returns {Promise<string>}
|
|
176
184
|
*/
|
|
177
|
-
async readBUID
|
|
185
|
+
async readBUID(timeout = 5000) {
|
|
178
186
|
const {tag, receivePromise} = this._receivePlistPromise(timeout, (data) => {
|
|
179
187
|
if (data.payload.BUID) {
|
|
180
188
|
return data.payload.BUID;
|
|
@@ -187,8 +195,8 @@ class Usbmux extends BaseServiceSocket {
|
|
|
187
195
|
payload: {
|
|
188
196
|
MessageType: 'ReadBUID',
|
|
189
197
|
ProgName: PROG_NAME,
|
|
190
|
-
ClientVersionString: CLIENT_VERSION_STRING
|
|
191
|
-
}
|
|
198
|
+
ClientVersionString: CLIENT_VERSION_STRING,
|
|
199
|
+
},
|
|
192
200
|
});
|
|
193
201
|
|
|
194
202
|
return await receivePromise;
|
|
@@ -200,7 +208,7 @@ class Usbmux extends BaseServiceSocket {
|
|
|
200
208
|
* @param {number} [timeout=5000] the timeout of receiving a response from usbmuxd
|
|
201
209
|
* @returns {Promise<any?>}
|
|
202
210
|
*/
|
|
203
|
-
async readPairRecord
|
|
211
|
+
async readPairRecord(udid, timeout = 5000) {
|
|
204
212
|
const {tag, receivePromise} = this._receivePlistPromise(timeout, (data) => {
|
|
205
213
|
if (!data.payload.PairRecordData) {
|
|
206
214
|
return null;
|
|
@@ -218,17 +226,17 @@ class Usbmux extends BaseServiceSocket {
|
|
|
218
226
|
MessageType: 'ReadPairRecord',
|
|
219
227
|
PairRecordID: udid,
|
|
220
228
|
ProgName: PROG_NAME,
|
|
221
|
-
ClientVersionString: CLIENT_VERSION_STRING
|
|
222
|
-
}
|
|
229
|
+
ClientVersionString: CLIENT_VERSION_STRING,
|
|
230
|
+
},
|
|
223
231
|
});
|
|
224
232
|
return await receivePromise;
|
|
225
233
|
}
|
|
226
234
|
|
|
227
|
-
_sendPlist
|
|
235
|
+
_sendPlist(json) {
|
|
228
236
|
this._encoder.write(json);
|
|
229
237
|
}
|
|
230
238
|
|
|
231
|
-
_receivePlistPromise
|
|
239
|
+
_receivePlistPromise(timeout = 5000, responseCallback) {
|
|
232
240
|
const tag = this._tag++;
|
|
233
241
|
const receivePromise = new B((resolve, reject) => {
|
|
234
242
|
this._responseCallbacks[tag] = (data) => {
|
|
@@ -238,7 +246,10 @@ class Usbmux extends BaseServiceSocket {
|
|
|
238
246
|
reject(e);
|
|
239
247
|
}
|
|
240
248
|
};
|
|
241
|
-
setTimeout(
|
|
249
|
+
setTimeout(
|
|
250
|
+
() => reject(new Error(`Failed to receive any data within the timeout: ${timeout}`)),
|
|
251
|
+
timeout,
|
|
252
|
+
);
|
|
242
253
|
});
|
|
243
254
|
return {tag, receivePromise};
|
|
244
255
|
}
|
|
@@ -248,7 +259,7 @@ class Usbmux extends BaseServiceSocket {
|
|
|
248
259
|
* @param {number} [timeout=5000] the timeout of receiving a response from usbmuxd
|
|
249
260
|
* @returns {Promise<any[]>}
|
|
250
261
|
*/
|
|
251
|
-
async listDevices
|
|
262
|
+
async listDevices(timeout = 5000) {
|
|
252
263
|
const {tag, receivePromise} = this._receivePlistPromise(timeout, (data) => {
|
|
253
264
|
if (data.payload.DeviceList) {
|
|
254
265
|
return data.payload.DeviceList;
|
|
@@ -261,8 +272,8 @@ class Usbmux extends BaseServiceSocket {
|
|
|
261
272
|
payload: {
|
|
262
273
|
MessageType: 'ListDevices',
|
|
263
274
|
ProgName: PROG_NAME,
|
|
264
|
-
ClientVersionString: CLIENT_VERSION_STRING
|
|
265
|
-
}
|
|
275
|
+
ClientVersionString: CLIENT_VERSION_STRING,
|
|
276
|
+
},
|
|
266
277
|
});
|
|
267
278
|
|
|
268
279
|
return await receivePromise;
|
|
@@ -274,7 +285,7 @@ class Usbmux extends BaseServiceSocket {
|
|
|
274
285
|
* @param {number} [timeout=5000] the timeout of receiving a response from usbmuxd
|
|
275
286
|
* @returns {Promise<any?>}
|
|
276
287
|
*/
|
|
277
|
-
async findDevice
|
|
288
|
+
async findDevice(udid, timeout = 5000) {
|
|
278
289
|
const devices = await this.listDevices(timeout);
|
|
279
290
|
return _.find(devices, (device) => device.Properties.SerialNumber === udid);
|
|
280
291
|
}
|
|
@@ -285,7 +296,7 @@ class Usbmux extends BaseServiceSocket {
|
|
|
285
296
|
* @param {number} [timeout=5000] the timeout of receiving a response from usbmuxd
|
|
286
297
|
* @returns {Promise<Lockdown>}
|
|
287
298
|
*/
|
|
288
|
-
async connectLockdown
|
|
299
|
+
async connectLockdown(udid, timeout = 5000) {
|
|
289
300
|
const device = await this.findDevice(udid, timeout);
|
|
290
301
|
if (!device) {
|
|
291
302
|
throw new Error(`Could not find the expected device '${udid}'`);
|
|
@@ -301,7 +312,7 @@ class Usbmux extends BaseServiceSocket {
|
|
|
301
312
|
* @param {number} [timeout=5000] the timeout of receiving a response from usbmuxd
|
|
302
313
|
* @returns {Promise<net.Socket|Object>} The socket or the object returned in the callback if the callback function exists
|
|
303
314
|
*/
|
|
304
|
-
async connect
|
|
315
|
+
async connect(deviceID, port, timeout = 5000) {
|
|
305
316
|
const {tag, receivePromise} = this._receivePlistPromise(timeout, (data) => {
|
|
306
317
|
if (data.payload.MessageType !== 'Result') {
|
|
307
318
|
throw new Error(`Unexpected data: ${JSON.stringify(data)}`);
|
|
@@ -325,13 +336,13 @@ class Usbmux extends BaseServiceSocket {
|
|
|
325
336
|
ProgName: PROG_NAME,
|
|
326
337
|
ClientVersionString: CLIENT_VERSION_STRING,
|
|
327
338
|
DeviceID: deviceID,
|
|
328
|
-
PortNumber: swap16(port)
|
|
329
|
-
}
|
|
339
|
+
PortNumber: swap16(port),
|
|
340
|
+
},
|
|
330
341
|
});
|
|
331
342
|
|
|
332
343
|
return await receivePromise;
|
|
333
344
|
}
|
|
334
345
|
}
|
|
335
346
|
|
|
336
|
-
export {
|
|
347
|
+
export {Usbmux, getDefaultSocket};
|
|
337
348
|
export default Usbmux;
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import Stream from 'node:stream';
|
|
2
|
-
import {
|
|
2
|
+
import {plist} from '@appium/support';
|
|
3
3
|
|
|
4
4
|
const HEADER_LENGTH = 16;
|
|
5
5
|
|
|
6
6
|
class UsbmuxDecoder extends Stream.Transform {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
super({ objectMode: true });
|
|
7
|
+
constructor() {
|
|
8
|
+
super({objectMode: true});
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
_transform
|
|
11
|
+
_transform(data, encoding, onData) {
|
|
13
12
|
this._decode(data);
|
|
14
13
|
onData();
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
_decode
|
|
16
|
+
_decode(data) {
|
|
18
17
|
const header = {
|
|
19
18
|
length: data.readUInt32LE(0),
|
|
20
19
|
version: data.readUInt32LE(4),
|
|
21
20
|
type: data.readUInt32LE(8),
|
|
22
|
-
tag: data.readUInt32LE(12)
|
|
21
|
+
tag: data.readUInt32LE(12),
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
let payload = data.slice(HEADER_LENGTH, data.length);
|
|
26
|
-
this.push({
|
|
25
|
+
this.push({header, payload: plist.parsePlist(payload)});
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
export {
|
|
29
|
+
export {UsbmuxDecoder};
|
|
32
30
|
export default UsbmuxDecoder;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import Stream from 'node:stream';
|
|
2
|
-
import {
|
|
2
|
+
import {plist} from '@appium/support';
|
|
3
3
|
|
|
4
4
|
const HEADER_LENGTH = 16;
|
|
5
5
|
const VERSION = 1;
|
|
6
6
|
const TYPE = 8;
|
|
7
7
|
|
|
8
8
|
class UsbmuxEncoder extends Stream.Transform {
|
|
9
|
-
constructor
|
|
10
|
-
super({
|
|
9
|
+
constructor() {
|
|
10
|
+
super({objectMode: true});
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
_transform
|
|
13
|
+
_transform(data, encoding, onData) {
|
|
14
14
|
this._encode(data);
|
|
15
15
|
onData();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
_encode
|
|
18
|
+
_encode(data) {
|
|
19
19
|
const plistData = plist.createPlist(data.payload, false);
|
|
20
20
|
const payloadBuffer = Buffer.isBuffer(plistData) ? plistData : Buffer.from(plistData);
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ class UsbmuxEncoder extends Stream.Transform {
|
|
|
23
23
|
length: HEADER_LENGTH + payloadBuffer.length,
|
|
24
24
|
version: VERSION,
|
|
25
25
|
type: TYPE,
|
|
26
|
-
tag: data.tag
|
|
26
|
+
tag: data.tag,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const headerBuffer = Buffer.allocUnsafe(HEADER_LENGTH);
|
|
@@ -32,9 +32,11 @@ class UsbmuxEncoder extends Stream.Transform {
|
|
|
32
32
|
headerBuffer.writeUInt32LE(header.type, 8);
|
|
33
33
|
headerBuffer.writeUInt32LE(header.tag, 12);
|
|
34
34
|
|
|
35
|
-
this.push(
|
|
35
|
+
this.push(
|
|
36
|
+
Buffer.concat([headerBuffer, payloadBuffer], headerBuffer.length + payloadBuffer.length),
|
|
37
|
+
);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
export {
|
|
41
|
+
export {UsbmuxEncoder};
|
|
40
42
|
export default UsbmuxEncoder;
|