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/afc/index.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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 {
|
|
12
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
182
|
-
const {packetNumber, response} = this._createPacketPromise(
|
|
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
|
|
205
|
-
const {packetNumber, response} = this._createPacketPromise(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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 {
|
|
364
|
+
export {AfcService, AFC_SERVICE_NAME};
|
package/lib/afc/protocol.js
CHANGED
|
@@ -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,
|
|
9
|
-
STATUS: 0x00000001,
|
|
10
|
-
DATA: 0x00000002,
|
|
11
|
-
READ_DIR: 0x00000003,
|
|
12
|
-
READ_FILE: 0x00000004,
|
|
13
|
-
WRITE_FILE: 0x00000005,
|
|
14
|
-
WRITE_PART: 0x00000006,
|
|
15
|
-
TRUNCATE: 0x00000007,
|
|
16
|
-
REMOVE_PATH: 0x00000008,
|
|
17
|
-
MAKE_DIR: 0x00000009,
|
|
18
|
-
GET_FILE_INFO:
|
|
19
|
-
GET_DEVINFO:
|
|
20
|
-
WRITE_FILE_ATOM:
|
|
21
|
-
FILE_OPEN:
|
|
22
|
-
FILE_OPEN_RES:
|
|
23
|
-
FILE_READ:
|
|
24
|
-
FILE_WRITE: 0x00000010,
|
|
25
|
-
FILE_SEEK: 0x00000011,
|
|
26
|
-
FILE_TELL: 0x00000012,
|
|
27
|
-
FILE_TELL_RES: 0x00000013,
|
|
28
|
-
FILE_CLOSE: 0x00000014,
|
|
29
|
-
FILE_SET_SIZE: 0x00000015,
|
|
30
|
-
GET_CON_INFO: 0x00000016,
|
|
31
|
-
SET_CON_OPTIONS: 0x00000017,
|
|
32
|
-
RENAME_PATH: 0x00000018,
|
|
33
|
-
SET_FS_BS: 0x00000019,
|
|
34
|
-
SET_SOCKET_BS:
|
|
35
|
-
FILE_LOCK:
|
|
36
|
-
MAKE_LINK:
|
|
37
|
-
GET_FILE_HASH:
|
|
38
|
-
SET_FILE_MOD_TIME:
|
|
39
|
-
GET_FILE_HASH_RANGE:
|
|
40
|
-
FILE_SET_IMMUTABLE_HINT: 0x00000020,
|
|
41
|
-
GET_SIZE_OF_PATH_CONTENTS: 0x00000021,
|
|
42
|
-
REMOVE_PATH_AND_CONTENTS: 0x00000022,
|
|
43
|
-
DIR_OPEN: 0x00000023,
|
|
44
|
-
DIR_OPEN_RESULT: 0x00000024,
|
|
45
|
-
DIR_READ: 0x00000025,
|
|
46
|
-
DIR_CLOSE: 0x00000026,
|
|
47
|
-
FILE_READ_OFFSET: 0x00000027,
|
|
48
|
-
FILE_WRITE_OFFSET:
|
|
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
|
|
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
|
|
86
|
+
function errorCode(code) {
|
|
87
87
|
return Errors_Code[code];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
90
|
const FileModes = {
|
|
92
|
-
|
|
91
|
+
r: 0x00000001, // O_RDONLY
|
|
93
92
|
'r+': 0x00000002, // O_RDWR | O_CREAT
|
|
94
|
-
|
|
93
|
+
w: 0x00000003, // O_WRONLY | O_CREAT | O_TRUNC
|
|
95
94
|
'w+': 0x00000004, // O_RDWR | O_CREAT | O_TRUNC
|
|
96
|
-
|
|
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,
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
MAGIC_NUMBER,
|
|
101
|
+
AFC_PACKET_HEADER_SIZE,
|
|
102
|
+
Operations,
|
|
103
|
+
operationCode,
|
|
104
|
+
Errors,
|
|
105
|
+
errorCode,
|
|
106
|
+
FileModes,
|
|
104
107
|
};
|
package/lib/afc/streams.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import stream from 'node:stream';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
3
|
-
|
|
2
|
+
import {MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE} from '../protocol';
|
|
4
3
|
|
|
5
4
|
class AfcDecoder 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._decode(data);
|
|
13
11
|
onData();
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
_decode
|
|
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({
|
|
27
|
+
this.push({messageLength, packetNumber, opCode, headerPayload, content});
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
readUInt64LE
|
|
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 {
|
|
36
|
+
export {AfcDecoder};
|
|
39
37
|
export default AfcDecoder;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import Stream from 'node:stream';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {MAGIC_NUMBER, AFC_PACKET_HEADER_SIZE} from '../protocol';
|
|
4
3
|
|
|
5
4
|
class AfcEncoder 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
|
onData(null, this._encode(data));
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
_encode
|
|
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
|
|
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 {
|
|
37
|
+
export {AfcEncoder};
|
|
41
38
|
export default AfcEncoder;
|
package/lib/base-service.js
CHANGED
|
@@ -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,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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 {
|
|
8
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
75
|
+
_receivePlistPromise(timeout = 10000) {
|
|
77
76
|
return new B((resolve, reject) => {
|
|
78
77
|
this._decoder.once('data', resolve);
|
|
79
|
-
setTimeout(
|
|
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 {
|
|
86
|
+
export {HouseArrestService, HOUSE_ARREST_SERVICE_NAME};
|
|
85
87
|
export default HouseArrestService;
|