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
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {archive, unarchive} from './transformer/nskeyed';
|
|
2
|
-
import {
|
|
2
|
+
import {parseBuffer} from 'bplist-parser';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
|
|
5
5
|
const DTX_MESSAGE_PAYLOAD_HEADER_LENGTH = 16;
|
|
6
6
|
const DTX_MESSAGE_HEADER_LENGTH = 32;
|
|
7
|
-
const DTX_MESSAGE_HEADER_MAGIC =
|
|
7
|
+
const DTX_MESSAGE_HEADER_MAGIC = 0x1f3d5b79;
|
|
8
8
|
const DTX_MESSAGE_HEADER_MAGIC_LEN = 4;
|
|
9
|
-
const DTX_MESSAGE_AUX_HEADER =
|
|
9
|
+
const DTX_MESSAGE_AUX_HEADER = 0x01f0;
|
|
10
10
|
const DTX_AUXILIARY_MAGIC = 0xa;
|
|
11
11
|
|
|
12
12
|
const FLAG_TYPES = Object.freeze({
|
|
13
13
|
push: 0,
|
|
14
14
|
recv: 1,
|
|
15
15
|
send: 2,
|
|
16
|
-
reply: 3
|
|
16
|
+
reply: 3,
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const AUX_TYPES = Object.freeze({
|
|
@@ -21,7 +21,7 @@ const AUX_TYPES = Object.freeze({
|
|
|
21
21
|
NSKeyed: 2,
|
|
22
22
|
UInt32LE: 3,
|
|
23
23
|
BigUInt64LE: 4,
|
|
24
|
-
BigInt64LE: 6
|
|
24
|
+
BigInt64LE: 6,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -56,7 +56,7 @@ class DTXMessageHeader {
|
|
|
56
56
|
* @param {Partial<DTXMessageOptions>} data
|
|
57
57
|
* @returns {Buffer} DTXMessageHeaderBuffer
|
|
58
58
|
*/
|
|
59
|
-
static build
|
|
59
|
+
static build(data) {
|
|
60
60
|
const messageHeader = Buffer.alloc(DTX_MESSAGE_HEADER_LENGTH);
|
|
61
61
|
messageHeader.writeUInt32LE(DTX_MESSAGE_HEADER_MAGIC, 0);
|
|
62
62
|
messageHeader.writeUInt32LE(DTX_MESSAGE_HEADER_LENGTH, 4);
|
|
@@ -74,7 +74,7 @@ class DTXMessageHeader {
|
|
|
74
74
|
* @param headerBuffer DTXMessageHeaderBuffer
|
|
75
75
|
* @returns {Object}
|
|
76
76
|
*/
|
|
77
|
-
static parse
|
|
77
|
+
static parse(headerBuffer) {
|
|
78
78
|
return {
|
|
79
79
|
magic: headerBuffer.readUInt32LE(0),
|
|
80
80
|
headerLength: headerBuffer.readUInt32LE(4),
|
|
@@ -109,7 +109,7 @@ class DTXMessagePayloadHeader {
|
|
|
109
109
|
* @param data {DTXMessagePayloadHeaderObject}
|
|
110
110
|
* @returns {Buffer} DTXMessagePayloadHeaderBuffer
|
|
111
111
|
*/
|
|
112
|
-
static build
|
|
112
|
+
static build(data) {
|
|
113
113
|
const messageHeader = Buffer.alloc(DTX_MESSAGE_PAYLOAD_HEADER_LENGTH);
|
|
114
114
|
messageHeader.writeUInt32LE(data.flags, 0);
|
|
115
115
|
messageHeader.writeUInt32LE(data.auxLength, 4);
|
|
@@ -121,21 +121,20 @@ class DTXMessagePayloadHeader {
|
|
|
121
121
|
* @param headerBuffer
|
|
122
122
|
* @returns {DTXMessagePayloadHeaderObject}
|
|
123
123
|
*/
|
|
124
|
-
static parse
|
|
124
|
+
static parse(headerBuffer) {
|
|
125
125
|
return {
|
|
126
126
|
flags: headerBuffer.readUInt32LE(0),
|
|
127
127
|
auxLength: headerBuffer.readUInt32LE(4),
|
|
128
|
-
totalLength: headerBuffer.readBigInt64LE(8)
|
|
128
|
+
totalLength: headerBuffer.readBigInt64LE(8),
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
134
133
|
class DTXMessageAux {
|
|
135
134
|
/**
|
|
136
135
|
* @param {any[] | DTXMessageAuxBuffer} data
|
|
137
136
|
*/
|
|
138
|
-
constructor
|
|
137
|
+
constructor(data = []) {
|
|
139
138
|
this.data = data;
|
|
140
139
|
}
|
|
141
140
|
|
|
@@ -143,7 +142,7 @@ class DTXMessageAux {
|
|
|
143
142
|
* JS Array to Apple NSKeyed Buffer
|
|
144
143
|
* @returns {Buffer}
|
|
145
144
|
*/
|
|
146
|
-
build
|
|
145
|
+
build() {
|
|
147
146
|
if (this.data instanceof DTXMessageAuxBuffer) {
|
|
148
147
|
return this.data.getBytes();
|
|
149
148
|
}
|
|
@@ -169,7 +168,7 @@ class DTXMessageAux {
|
|
|
169
168
|
* @param {DTXMessagePayloadHeaderObject} payloadHeader
|
|
170
169
|
* @returns {any[]}
|
|
171
170
|
*/
|
|
172
|
-
static parse
|
|
171
|
+
static parse(headerBuffer, payloadHeader) {
|
|
173
172
|
let cursor = 0;
|
|
174
173
|
const data = [];
|
|
175
174
|
const length = headerBuffer.readBigInt64LE(8);
|
|
@@ -221,20 +220,20 @@ class DTXMessageAux {
|
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
class InstrumentRPCParseError {
|
|
224
|
-
constructor
|
|
223
|
+
constructor(data) {
|
|
225
224
|
this.data = data;
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
class DTXMessageAuxBuffer {
|
|
230
|
-
constructor
|
|
229
|
+
constructor() {
|
|
231
230
|
this._buf = Buffer.alloc(0);
|
|
232
231
|
}
|
|
233
232
|
|
|
234
233
|
/**
|
|
235
234
|
* @param {number} value
|
|
236
235
|
*/
|
|
237
|
-
appendInt
|
|
236
|
+
appendInt(value) {
|
|
238
237
|
const buf = Buffer.alloc(12);
|
|
239
238
|
buf.writeUInt32LE(DTX_AUXILIARY_MAGIC, 0);
|
|
240
239
|
buf.writeUInt32LE(3, 4);
|
|
@@ -245,7 +244,7 @@ class DTXMessageAuxBuffer {
|
|
|
245
244
|
/**
|
|
246
245
|
* @param {bigint} value
|
|
247
246
|
*/
|
|
248
|
-
appendLong
|
|
247
|
+
appendLong(value) {
|
|
249
248
|
const buf = Buffer.alloc(16);
|
|
250
249
|
buf.writeUInt32LE(DTX_AUXILIARY_MAGIC, 0);
|
|
251
250
|
buf.writeUInt32LE(4, 4);
|
|
@@ -256,7 +255,7 @@ class DTXMessageAuxBuffer {
|
|
|
256
255
|
/**
|
|
257
256
|
* @param {number} value
|
|
258
257
|
*/
|
|
259
|
-
appendSignedInt
|
|
258
|
+
appendSignedInt(value) {
|
|
260
259
|
const buf = Buffer.alloc(12);
|
|
261
260
|
buf.writeUInt32LE(DTX_AUXILIARY_MAGIC, 0);
|
|
262
261
|
buf.writeUInt32LE(3, 4);
|
|
@@ -267,7 +266,7 @@ class DTXMessageAuxBuffer {
|
|
|
267
266
|
/**
|
|
268
267
|
* @param {bigint} value
|
|
269
268
|
*/
|
|
270
|
-
appendSignedLong
|
|
269
|
+
appendSignedLong(value) {
|
|
271
270
|
const buf = Buffer.alloc(16);
|
|
272
271
|
buf.writeUInt32LE(DTX_AUXILIARY_MAGIC, 0);
|
|
273
272
|
buf.writeUInt32LE(6, 4);
|
|
@@ -278,7 +277,7 @@ class DTXMessageAuxBuffer {
|
|
|
278
277
|
/**
|
|
279
278
|
* @param {Object} value
|
|
280
279
|
*/
|
|
281
|
-
appendObject
|
|
280
|
+
appendObject(value) {
|
|
282
281
|
const buf = archive(value);
|
|
283
282
|
const buf2 = Buffer.alloc(12);
|
|
284
283
|
buf2.writeUInt32LE(DTX_AUXILIARY_MAGIC, 0);
|
|
@@ -287,7 +286,7 @@ class DTXMessageAuxBuffer {
|
|
|
287
286
|
this._buf = Buffer.concat([this._buf, buf2, buf]);
|
|
288
287
|
}
|
|
289
288
|
|
|
290
|
-
getBytes
|
|
289
|
+
getBytes() {
|
|
291
290
|
const out = Buffer.alloc(16);
|
|
292
291
|
out.writeUInt32LE(DTX_MESSAGE_AUX_HEADER, 0);
|
|
293
292
|
out.writeUInt32LE(this._buf.length, 8);
|
|
@@ -295,20 +294,18 @@ class DTXMessageAuxBuffer {
|
|
|
295
294
|
}
|
|
296
295
|
}
|
|
297
296
|
|
|
298
|
-
|
|
299
|
-
|
|
300
297
|
class DTXMessage {
|
|
301
298
|
/**
|
|
302
299
|
* @param {Partial<DTXMessageOptions>} opts
|
|
303
300
|
*/
|
|
304
|
-
constructor
|
|
301
|
+
constructor(opts = {}) {
|
|
305
302
|
const {
|
|
306
303
|
identifier,
|
|
307
304
|
channelCode,
|
|
308
305
|
selector,
|
|
309
306
|
expectsReply,
|
|
310
307
|
conversationIndex = 0,
|
|
311
|
-
flags = FLAG_TYPES.send
|
|
308
|
+
flags = FLAG_TYPES.send,
|
|
312
309
|
} = opts;
|
|
313
310
|
this._messageHeader = undefined;
|
|
314
311
|
this._payloadHeader = undefined;
|
|
@@ -325,7 +322,7 @@ class DTXMessage {
|
|
|
325
322
|
* get DTXMessageHeader identifier. Packet transmission sequence
|
|
326
323
|
* @returns {number}
|
|
327
324
|
*/
|
|
328
|
-
get identifier
|
|
325
|
+
get identifier() {
|
|
329
326
|
return this._messageHeader?.identifier;
|
|
330
327
|
}
|
|
331
328
|
|
|
@@ -335,7 +332,7 @@ class DTXMessage {
|
|
|
335
332
|
* call this method `InstrumentService.registerChannelCallback` get the channel message
|
|
336
333
|
* @returns {number}
|
|
337
334
|
*/
|
|
338
|
-
get channelCode
|
|
335
|
+
get channelCode() {
|
|
339
336
|
return this._messageHeader?.channel;
|
|
340
337
|
}
|
|
341
338
|
|
|
@@ -344,7 +341,7 @@ class DTXMessage {
|
|
|
344
341
|
* if expectsReply is true must reply ack message
|
|
345
342
|
* @returns {boolean}
|
|
346
343
|
*/
|
|
347
|
-
get expectsReply
|
|
344
|
+
get expectsReply() {
|
|
348
345
|
return this._messageHeader?.expectsReply;
|
|
349
346
|
}
|
|
350
347
|
|
|
@@ -352,14 +349,14 @@ class DTXMessage {
|
|
|
352
349
|
* call this method `InstrumentService.registerSelectorCallback` get the selector message
|
|
353
350
|
* @returns {*} Unknown data
|
|
354
351
|
*/
|
|
355
|
-
get selector
|
|
352
|
+
get selector() {
|
|
356
353
|
return this._selector;
|
|
357
354
|
}
|
|
358
355
|
|
|
359
356
|
/**
|
|
360
357
|
* @param data
|
|
361
358
|
*/
|
|
362
|
-
set selector
|
|
359
|
+
set selector(data) {
|
|
363
360
|
this._selector = data;
|
|
364
361
|
}
|
|
365
362
|
|
|
@@ -367,7 +364,7 @@ class DTXMessage {
|
|
|
367
364
|
* get DTXMessageHeader conversationIndex
|
|
368
365
|
* @returns {number}
|
|
369
366
|
*/
|
|
370
|
-
get conversationIndex
|
|
367
|
+
get conversationIndex() {
|
|
371
368
|
return this._messageHeader?.conversationIndex;
|
|
372
369
|
}
|
|
373
370
|
|
|
@@ -375,7 +372,7 @@ class DTXMessage {
|
|
|
375
372
|
* DTXMessage Buffer: DTXMessageHeader + PayloadHeader + DTXMessageAuxBuffer(nullable) + selector(nullable)
|
|
376
373
|
* @returns {Buffer}
|
|
377
374
|
*/
|
|
378
|
-
build
|
|
375
|
+
build() {
|
|
379
376
|
const sel = this._selector ? archive(this._selector) : Buffer.alloc(0);
|
|
380
377
|
const aux = this.auxiliaries.build();
|
|
381
378
|
const payloadHeader = DTXMessagePayloadHeader.build({
|
|
@@ -390,7 +387,7 @@ class DTXMessage {
|
|
|
390
387
|
identifier: this._identifier,
|
|
391
388
|
conversationIndex: this._conversationIndex,
|
|
392
389
|
channelCode: this._channelCode,
|
|
393
|
-
expectsReply: this._expectsReply
|
|
390
|
+
expectsReply: this._expectsReply,
|
|
394
391
|
});
|
|
395
392
|
return Buffer.concat([messageHeader, payloadHeader, aux, sel]);
|
|
396
393
|
}
|
|
@@ -401,14 +398,16 @@ class DTXMessage {
|
|
|
401
398
|
* @param {Buffer} payloadBuf PayloadHeaderBuffer + DTXMessageAuxBuffer(nullable) + selectorBuffer(nullable)
|
|
402
399
|
* @returns {DTXMessage}
|
|
403
400
|
*/
|
|
404
|
-
static parse
|
|
401
|
+
static parse(headerBuf, payloadBuf) {
|
|
405
402
|
let cursor = 0;
|
|
406
403
|
const ret = new DTXMessage();
|
|
407
404
|
ret._messageHeader = DTXMessageHeader.parse(headerBuf);
|
|
408
405
|
if (ret._messageHeader.payloadLength === 0) {
|
|
409
406
|
return ret;
|
|
410
407
|
}
|
|
411
|
-
ret._payloadHeader = DTXMessagePayloadHeader.parse(
|
|
408
|
+
ret._payloadHeader = DTXMessagePayloadHeader.parse(
|
|
409
|
+
payloadBuf.slice(cursor, DTX_MESSAGE_PAYLOAD_HEADER_LENGTH),
|
|
410
|
+
);
|
|
412
411
|
cursor += DTX_MESSAGE_PAYLOAD_HEADER_LENGTH;
|
|
413
412
|
// totalLength is bigint use 0n
|
|
414
413
|
if (ret._payloadHeader.totalLength === 0n) {
|
|
@@ -416,7 +415,10 @@ class DTXMessage {
|
|
|
416
415
|
}
|
|
417
416
|
if (ret._payloadHeader.auxLength > 0) {
|
|
418
417
|
// @ts-ignore Not 100% sure if this ok
|
|
419
|
-
ret.auxiliaries = DTXMessageAux.parse(
|
|
418
|
+
ret.auxiliaries = DTXMessageAux.parse(
|
|
419
|
+
payloadBuf.slice(cursor, cursor + ret._payloadHeader.auxLength),
|
|
420
|
+
ret._payloadHeader,
|
|
421
|
+
);
|
|
420
422
|
cursor += ret._payloadHeader.auxLength;
|
|
421
423
|
}
|
|
422
424
|
|
|
@@ -436,6 +438,15 @@ class DTXMessage {
|
|
|
436
438
|
}
|
|
437
439
|
}
|
|
438
440
|
|
|
439
|
-
export {
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
export {
|
|
442
|
+
DTXMessageHeader,
|
|
443
|
+
DTXMessagePayloadHeader,
|
|
444
|
+
DTXMessageAuxBuffer,
|
|
445
|
+
DTXMessageAux,
|
|
446
|
+
DTXMessage,
|
|
447
|
+
DTX_MESSAGE_PAYLOAD_HEADER_LENGTH,
|
|
448
|
+
DTX_MESSAGE_HEADER_LENGTH,
|
|
449
|
+
DTX_MESSAGE_HEADER_MAGIC,
|
|
450
|
+
DTX_MESSAGE_HEADER_MAGIC_LEN,
|
|
451
|
+
FLAG_TYPES,
|
|
452
|
+
};
|
package/lib/instrument/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
// Adapted from https://github.com/YueChen-C/py-ios-device
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import {BaseServiceSocket} from '../base-service';
|
|
4
|
+
import {DTXMessage, DTXMessageAuxBuffer, FLAG_TYPES} from './headers';
|
|
5
|
+
import {DTXEncoder} from './transformer/dtx-encode';
|
|
6
|
+
import {DTXDecoder} from './transformer/dtx-decode';
|
|
7
7
|
import events from 'node:events';
|
|
8
8
|
import _ from 'lodash';
|
|
9
|
-
import {
|
|
9
|
+
import {waitForCondition} from 'asyncbox';
|
|
10
10
|
|
|
11
11
|
const CHECK_FREQ_MS = 500;
|
|
12
12
|
const WAIT_REPLY_TIME_MS = 10000;
|
|
13
13
|
const CHANNEL_CANCELED = '_channelCanceled';
|
|
14
14
|
const CHANNEL_OFFSET = 2 ** 32;
|
|
15
15
|
|
|
16
|
-
const INSTRUMENT_SERVICE_NAME_VERSION_14 =
|
|
16
|
+
const INSTRUMENT_SERVICE_NAME_VERSION_14 =
|
|
17
|
+
'com.apple.instruments.remoteserver.DVTSecureSocketProxy';
|
|
17
18
|
const INSTRUMENT_SERVICE_NAME = 'com.apple.instruments.remoteserver';
|
|
18
19
|
|
|
19
20
|
export const INSTRUMENT_CHANNEL = Object.freeze({
|
|
@@ -24,7 +25,7 @@ export const INSTRUMENT_CHANNEL = Object.freeze({
|
|
|
24
25
|
MOBILE_NOTIFICATIONS: 'com.apple.instruments.server.services.mobilenotifications',
|
|
25
26
|
GRAPHICS_OPENGL: 'com.apple.instruments.server.services.graphics.opengl',
|
|
26
27
|
APPLICATION_LISTING: 'com.apple.instruments.server.services.device.applictionListing',
|
|
27
|
-
CONDITION_INDUCER: 'com.apple.instruments.server.services.ConditionInducer'
|
|
28
|
+
CONDITION_INDUCER: 'com.apple.instruments.server.services.ConditionInducer',
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
function defaultDict(createValue) {
|
|
@@ -34,14 +35,14 @@ function defaultDict(createValue) {
|
|
|
34
35
|
storage[property] = createValue(property);
|
|
35
36
|
}
|
|
36
37
|
return storage[property];
|
|
37
|
-
}
|
|
38
|
+
},
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/** The callback function which will be called during the data transmission in instrument serve
|
|
42
43
|
* @callback DTXCallback
|
|
43
44
|
* @param {DTXMessage} object
|
|
44
|
-
*/
|
|
45
|
+
*/
|
|
45
46
|
|
|
46
47
|
class InstrumentService extends BaseServiceSocket {
|
|
47
48
|
/**
|
|
@@ -53,7 +54,7 @@ class InstrumentService extends BaseServiceSocket {
|
|
|
53
54
|
this._undefinedCallback = event;
|
|
54
55
|
this._callbacks = new events.EventEmitter();
|
|
55
56
|
this._channelCallbacks = new events.EventEmitter();
|
|
56
|
-
const {
|
|
57
|
+
const {proxy, revoke} = defaultDict(() => []);
|
|
57
58
|
this._replyQueues = proxy;
|
|
58
59
|
this._replyQueuesRevoker = revoke;
|
|
59
60
|
this._channels = {};
|
|
@@ -141,19 +142,29 @@ class InstrumentService extends BaseServiceSocket {
|
|
|
141
142
|
sync,
|
|
142
143
|
channelCode,
|
|
143
144
|
selector,
|
|
144
|
-
auxiliaries:
|
|
145
|
-
|
|
145
|
+
auxiliaries:
|
|
146
|
+
auxiliaries.length === 1 && auxiliaries[0] instanceof DTXMessageAuxBuffer
|
|
147
|
+
? auxiliaries[0]
|
|
148
|
+
: auxiliaries,
|
|
149
|
+
identifier,
|
|
146
150
|
});
|
|
147
151
|
++this._nextIdentifier;
|
|
148
152
|
if (sync) {
|
|
149
153
|
try {
|
|
150
|
-
return await waitForCondition(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
return await waitForCondition(
|
|
155
|
+
() => {
|
|
156
|
+
const queue = this._replyQueues[identifier];
|
|
157
|
+
const data = queue.shift();
|
|
158
|
+
if (!_.isUndefined(data)) {
|
|
159
|
+
return data;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
waitMs: WAIT_REPLY_TIME_MS,
|
|
164
|
+
intervalMs: CHECK_FREQ_MS,
|
|
165
|
+
error: 'reply channel data timeout',
|
|
166
|
+
},
|
|
167
|
+
);
|
|
157
168
|
} catch (err) {
|
|
158
169
|
this.close();
|
|
159
170
|
throw new Error(err);
|
|
@@ -196,7 +207,7 @@ class InstrumentService extends BaseServiceSocket {
|
|
|
196
207
|
identifier: data.identifier,
|
|
197
208
|
channelCode: data.channelCode,
|
|
198
209
|
conversationIndex: data.conversationIndex + 1,
|
|
199
|
-
flags: FLAG_TYPES.reply
|
|
210
|
+
flags: FLAG_TYPES.reply,
|
|
200
211
|
});
|
|
201
212
|
this._socketClient.write(reply.build());
|
|
202
213
|
}
|
|
@@ -212,4 +223,4 @@ class InstrumentService extends BaseServiceSocket {
|
|
|
212
223
|
}
|
|
213
224
|
}
|
|
214
225
|
|
|
215
|
-
export {
|
|
226
|
+
export {InstrumentService, INSTRUMENT_SERVICE_NAME_VERSION_14, INSTRUMENT_SERVICE_NAME};
|
|
@@ -1,41 +1,50 @@
|
|
|
1
1
|
import Stream from 'node:stream';
|
|
2
2
|
import {
|
|
3
|
-
DTX_MESSAGE_HEADER_LENGTH,
|
|
4
|
-
|
|
3
|
+
DTX_MESSAGE_HEADER_LENGTH,
|
|
4
|
+
DTX_MESSAGE_HEADER_MAGIC,
|
|
5
|
+
DTX_MESSAGE_HEADER_MAGIC_LEN,
|
|
6
|
+
DTXMessageHeader,
|
|
7
|
+
DTXMessage,
|
|
5
8
|
} from '../headers';
|
|
6
|
-
import {
|
|
9
|
+
import {log} from '../../logger';
|
|
7
10
|
|
|
8
11
|
class DTXDecoder extends Stream.Transform {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
super({ objectMode: true });
|
|
12
|
+
constructor() {
|
|
13
|
+
super({objectMode: true});
|
|
12
14
|
this._dtxManager = {};
|
|
13
15
|
this.buffer = Buffer.allocUnsafe(0);
|
|
14
16
|
this.cursor = 0;
|
|
15
17
|
this.header = undefined;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
_transform
|
|
20
|
+
_transform(data, encoding, onData) {
|
|
19
21
|
this._decode(data);
|
|
20
22
|
onData();
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
_decode
|
|
25
|
+
_decode(data) {
|
|
24
26
|
// Merge packets
|
|
25
27
|
this.buffer = Buffer.concat([this.buffer.slice(this.cursor, this.buffer.length), data]);
|
|
26
28
|
this.cursor = 0;
|
|
27
29
|
while (this.cursor < this.buffer.length) {
|
|
28
30
|
const magic = this._recv(DTX_MESSAGE_HEADER_MAGIC_LEN);
|
|
29
|
-
if (!magic) {
|
|
31
|
+
if (!magic) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
30
34
|
this.cursor -= DTX_MESSAGE_HEADER_MAGIC_LEN;
|
|
31
35
|
if (magic && magic.readUInt32LE(0) === DTX_MESSAGE_HEADER_MAGIC) {
|
|
32
36
|
const headerBuffer = this._recv(DTX_MESSAGE_HEADER_LENGTH);
|
|
33
|
-
if (!headerBuffer) {
|
|
37
|
+
if (!headerBuffer) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
34
40
|
this.header = DTXMessageHeader.parse(headerBuffer);
|
|
35
41
|
if (this.header.fragmentId === 0) {
|
|
36
42
|
// only the 0th fragment contains a message header
|
|
37
43
|
if (!(this.header.channel in this._dtxManager)) {
|
|
38
|
-
this._dtxManager[this.header.channel] = {
|
|
44
|
+
this._dtxManager[this.header.channel] = {
|
|
45
|
+
headerBuffer,
|
|
46
|
+
payloadBuffer: Buffer.allocUnsafe(0),
|
|
47
|
+
};
|
|
39
48
|
}
|
|
40
49
|
if (this.header.fragmentCount > 1) {
|
|
41
50
|
// Continue to get the next message fragments
|
|
@@ -44,11 +53,16 @@ class DTXDecoder extends Stream.Transform {
|
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
const bodyBuffer = this._recv(this.header.payloadLength);
|
|
47
|
-
if (!bodyBuffer) {
|
|
56
|
+
if (!bodyBuffer) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
48
59
|
if (this._dtxManager[this.header.channel]) {
|
|
49
|
-
this._dtxManager[this.header.channel].payloadBuffer = Buffer.concat([
|
|
60
|
+
this._dtxManager[this.header.channel].payloadBuffer = Buffer.concat([
|
|
61
|
+
this._dtxManager[this.header.channel].payloadBuffer,
|
|
62
|
+
bodyBuffer,
|
|
63
|
+
]);
|
|
50
64
|
}
|
|
51
|
-
if (this.header.fragmentId ===
|
|
65
|
+
if (this.header.fragmentId === this.header.fragmentCount - 1) {
|
|
52
66
|
data = this._dtxManager[this.header.channel];
|
|
53
67
|
delete this._dtxManager[this.header.channel];
|
|
54
68
|
if (data) {
|
|
@@ -66,7 +80,7 @@ class DTXDecoder extends Stream.Transform {
|
|
|
66
80
|
this.buffer = Buffer.allocUnsafe(0);
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
_recv
|
|
83
|
+
_recv(length) {
|
|
70
84
|
if (this.buffer.length < this.cursor + length) {
|
|
71
85
|
return null;
|
|
72
86
|
}
|
|
@@ -76,4 +90,4 @@ class DTXDecoder extends Stream.Transform {
|
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
|
|
79
|
-
export {
|
|
93
|
+
export {DTXDecoder};
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import Stream from 'node:stream';
|
|
2
2
|
import {DTXMessage, DTXMessageAux} from '../headers';
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
class DTXEncoder extends Stream.Transform {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
super({ objectMode: true });
|
|
5
|
+
constructor() {
|
|
6
|
+
super({objectMode: true});
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
_transform
|
|
9
|
+
_transform(data, encoding, onData) {
|
|
12
10
|
this.push(this._encode(data), 'binary');
|
|
13
11
|
onData();
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
_encode
|
|
14
|
+
_encode(data) {
|
|
17
15
|
const {sync, channelCode, selector, auxiliaries, identifier} = data;
|
|
18
16
|
const dtx = new DTXMessage({
|
|
19
17
|
identifier,
|
|
20
18
|
channelCode,
|
|
21
19
|
selector,
|
|
22
|
-
expectsReply: sync
|
|
20
|
+
expectsReply: sync,
|
|
23
21
|
});
|
|
24
22
|
if (auxiliaries instanceof DTXMessageAux) {
|
|
25
23
|
dtx.auxiliaries = auxiliaries;
|
|
@@ -30,4 +28,4 @@ class DTXEncoder extends Stream.Transform {
|
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
export {
|
|
31
|
+
export {DTXEncoder};
|