appium-ios-remotexpc 0.0.4 → 0.0.6
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/src/index.d.ts +1 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/lib/apple-tv/constants.d.ts +28 -0
- package/build/src/lib/apple-tv/constants.d.ts.map +1 -1
- package/build/src/lib/apple-tv/constants.js +35 -0
- package/build/src/lib/apple-tv/encryption/chacha20-poly1305.d.ts +22 -0
- package/build/src/lib/apple-tv/encryption/chacha20-poly1305.d.ts.map +1 -0
- package/build/src/lib/apple-tv/encryption/chacha20-poly1305.js +97 -0
- package/build/src/lib/apple-tv/encryption/ed25519.d.ts +16 -0
- package/build/src/lib/apple-tv/encryption/ed25519.d.ts.map +1 -0
- package/build/src/lib/apple-tv/encryption/ed25519.js +93 -0
- package/build/src/lib/apple-tv/encryption/hkdf.d.ts +18 -0
- package/build/src/lib/apple-tv/encryption/hkdf.d.ts.map +1 -0
- package/build/src/lib/apple-tv/encryption/hkdf.js +73 -0
- package/build/src/lib/apple-tv/encryption/index.d.ts +5 -0
- package/build/src/lib/apple-tv/encryption/index.d.ts.map +1 -0
- package/build/src/lib/apple-tv/encryption/index.js +4 -0
- package/build/src/lib/apple-tv/encryption/opack2.d.ts +57 -0
- package/build/src/lib/apple-tv/encryption/opack2.d.ts.map +1 -0
- package/build/src/lib/apple-tv/encryption/opack2.js +203 -0
- package/build/src/lib/remote-xpc/remote-xpc-connection.d.ts +1 -2
- package/build/src/lib/remote-xpc/remote-xpc-connection.d.ts.map +1 -1
- package/build/src/lib/remote-xpc/remote-xpc-connection.js +1 -2
- package/build/src/lib/tunnel/index.d.ts +3 -2
- package/build/src/lib/tunnel/index.d.ts.map +1 -1
- package/build/src/lib/tunnel/index.js +6 -3
- package/build/src/lib/types.d.ts +11 -0
- package/build/src/lib/types.d.ts.map +1 -1
- package/build/src/services/ios/diagnostic-service/index.d.ts.map +1 -1
- package/build/src/services/ios/diagnostic-service/index.js +0 -1
- package/build/src/services.d.ts +3 -3
- package/build/src/services.d.ts.map +1 -1
- package/build/src/services.js +8 -5
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/lib/apple-tv/constants.ts +42 -0
- package/src/lib/apple-tv/encryption/chacha20-poly1305.ts +147 -0
- package/src/lib/apple-tv/encryption/ed25519.ts +126 -0
- package/src/lib/apple-tv/encryption/hkdf.ts +95 -0
- package/src/lib/apple-tv/encryption/index.ts +11 -0
- package/src/lib/apple-tv/encryption/opack2.ts +257 -0
- package/src/lib/remote-xpc/remote-xpc-connection.ts +1 -2
- package/src/lib/tunnel/index.ts +7 -5
- package/src/lib/types.ts +12 -0
- package/src/services/ios/diagnostic-service/index.ts +0 -1
- package/src/services.ts +10 -7
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as constants from '../constants.js';
|
|
2
|
+
import { AppleTVError } from '../errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* OPACK2 binary serialization format encoder
|
|
5
|
+
* Implements Apple's OPACK2 protocol for efficient binary serialization of structured data
|
|
6
|
+
*/
|
|
7
|
+
export class Opack2 {
|
|
8
|
+
/**
|
|
9
|
+
* Serializes a JavaScript object to OPACK2 binary format
|
|
10
|
+
* @param obj - The object to serialize (supports primitives, arrays, objects, and Buffers)
|
|
11
|
+
* @returns Buffer containing the serialized data
|
|
12
|
+
* @throws AppleTVError if the object contains unsupported types
|
|
13
|
+
*/
|
|
14
|
+
static dumps(obj) {
|
|
15
|
+
return this.encode(obj);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Main encoding dispatcher that routes values to appropriate type-specific encoders
|
|
19
|
+
* @param obj - Value to encode
|
|
20
|
+
* @returns Buffer containing encoded value
|
|
21
|
+
* @throws AppleTVError for unsupported types
|
|
22
|
+
*/
|
|
23
|
+
static encode(obj) {
|
|
24
|
+
if (obj === null || obj === undefined) {
|
|
25
|
+
return Buffer.from([constants.OPACK2_NULL]);
|
|
26
|
+
}
|
|
27
|
+
if (typeof obj === 'boolean') {
|
|
28
|
+
return Buffer.from([
|
|
29
|
+
obj ? constants.OPACK2_TRUE : constants.OPACK2_FALSE,
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
if (typeof obj === 'number') {
|
|
33
|
+
return this.encodeNumber(obj);
|
|
34
|
+
}
|
|
35
|
+
if (typeof obj === 'string') {
|
|
36
|
+
return this.encodeString(obj);
|
|
37
|
+
}
|
|
38
|
+
if (Buffer.isBuffer(obj)) {
|
|
39
|
+
return this.encodeBytes(obj);
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(obj)) {
|
|
42
|
+
return this.encodeArray(obj);
|
|
43
|
+
}
|
|
44
|
+
if (typeof obj === 'object' &&
|
|
45
|
+
!Array.isArray(obj) &&
|
|
46
|
+
!Buffer.isBuffer(obj)) {
|
|
47
|
+
return this.encodeDict(obj);
|
|
48
|
+
}
|
|
49
|
+
throw new AppleTVError(`Unsupported type for OPACK2 serialization: ${typeof obj}`);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Encodes numeric values with the appropriate size optimization
|
|
53
|
+
* @param num - Number to encode
|
|
54
|
+
* @returns Buffer containing encoded number
|
|
55
|
+
*/
|
|
56
|
+
static encodeNumber(num) {
|
|
57
|
+
if (!Number.isInteger(num) || num < 0) {
|
|
58
|
+
const buffer = Buffer.allocUnsafe(5);
|
|
59
|
+
buffer[0] = constants.OPACK2_FLOAT_MARKER;
|
|
60
|
+
buffer.writeFloatLE(num, 1);
|
|
61
|
+
return buffer;
|
|
62
|
+
}
|
|
63
|
+
if (num <= constants.OPACK2_SMALL_INT_MAX) {
|
|
64
|
+
return Buffer.from([num + constants.OPACK2_SMALL_INT_OFFSET]);
|
|
65
|
+
}
|
|
66
|
+
if (num <= constants.OPACK2_UINT8_MAX) {
|
|
67
|
+
return Buffer.from([constants.OPACK2_INT8_MARKER, num]);
|
|
68
|
+
}
|
|
69
|
+
if (num <= constants.OPACK2_UINT32_MAX) {
|
|
70
|
+
const buffer = Buffer.allocUnsafe(5);
|
|
71
|
+
buffer[0] = constants.OPACK2_INT32_MARKER;
|
|
72
|
+
buffer.writeUInt32LE(num, 1);
|
|
73
|
+
return buffer;
|
|
74
|
+
}
|
|
75
|
+
if (num <= Number.MAX_SAFE_INTEGER) {
|
|
76
|
+
const buffer = Buffer.allocUnsafe(9);
|
|
77
|
+
buffer[0] = constants.OPACK2_INT64_MARKER;
|
|
78
|
+
buffer.writeBigUInt64LE(BigInt(num), 1);
|
|
79
|
+
return buffer;
|
|
80
|
+
}
|
|
81
|
+
throw new AppleTVError(`Number too large for OPACK2 encoding: ${num}`);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Encodes UTF-8 strings with length-optimized headers
|
|
85
|
+
* @param str - String to encode
|
|
86
|
+
* @returns Buffer containing encoded string
|
|
87
|
+
*/
|
|
88
|
+
static encodeString(str) {
|
|
89
|
+
const encoded = Buffer.from(str, 'utf8');
|
|
90
|
+
const length = encoded.length;
|
|
91
|
+
if (length <= constants.OPACK2_SMALL_STRING_MAX) {
|
|
92
|
+
return Buffer.concat([
|
|
93
|
+
Buffer.from([constants.OPACK2_SMALL_STRING_BASE + length]),
|
|
94
|
+
encoded,
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
if (length <= constants.OPACK2_UINT8_MAX) {
|
|
98
|
+
return Buffer.concat([
|
|
99
|
+
Buffer.from([constants.OPACK2_STRING_8BIT_LEN_MARKER, length]),
|
|
100
|
+
encoded,
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
if (length <= constants.OPACK2_UINT16_MAX) {
|
|
104
|
+
const header = Buffer.allocUnsafe(3);
|
|
105
|
+
header[0] = constants.OPACK2_STRING_16BIT_LEN_MARKER;
|
|
106
|
+
header.writeUInt16BE(length, 1);
|
|
107
|
+
return Buffer.concat([header, encoded]);
|
|
108
|
+
}
|
|
109
|
+
if (length <= constants.OPACK2_UINT32_MAX) {
|
|
110
|
+
const header = Buffer.allocUnsafe(5);
|
|
111
|
+
header[0] = constants.OPACK2_STRING_32BIT_LEN_MARKER;
|
|
112
|
+
header.writeUInt32BE(length, 1);
|
|
113
|
+
return Buffer.concat([header, encoded]);
|
|
114
|
+
}
|
|
115
|
+
throw new AppleTVError(`String too long for OPACK2 encoding: ${length} bytes`);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Encodes binary data with length-optimized headers
|
|
119
|
+
* @param bytes - Buffer to encode
|
|
120
|
+
* @returns Buffer containing encoded binary data
|
|
121
|
+
*/
|
|
122
|
+
static encodeBytes(bytes) {
|
|
123
|
+
const length = bytes.length;
|
|
124
|
+
if (length <= constants.OPACK2_SMALL_BYTES_MAX) {
|
|
125
|
+
return Buffer.concat([
|
|
126
|
+
Buffer.from([constants.OPACK2_SMALL_BYTES_BASE + length]),
|
|
127
|
+
bytes,
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
if (length <= constants.OPACK2_UINT8_MAX) {
|
|
131
|
+
return Buffer.concat([
|
|
132
|
+
Buffer.from([constants.OPACK2_BYTES_8BIT_LEN_MARKER, length]),
|
|
133
|
+
bytes,
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
if (length <= constants.OPACK2_UINT16_MAX) {
|
|
137
|
+
const header = Buffer.allocUnsafe(3);
|
|
138
|
+
header[0] = constants.OPACK2_BYTES_16BIT_LEN_MARKER;
|
|
139
|
+
header.writeUInt16BE(length, 1);
|
|
140
|
+
return Buffer.concat([header, bytes]);
|
|
141
|
+
}
|
|
142
|
+
if (length <= constants.OPACK2_UINT32_MAX) {
|
|
143
|
+
const header = Buffer.allocUnsafe(5);
|
|
144
|
+
header[0] = constants.OPACK2_BYTES_32BIT_LEN_MARKER;
|
|
145
|
+
header.writeUInt32BE(length, 1);
|
|
146
|
+
return Buffer.concat([header, bytes]);
|
|
147
|
+
}
|
|
148
|
+
throw new AppleTVError(`Byte array too long for OPACK2 encoding: ${length} bytes`);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Encodes arrays with count-optimized headers
|
|
152
|
+
* @param arr - Array to encode
|
|
153
|
+
* @returns Buffer containing encoded array
|
|
154
|
+
*/
|
|
155
|
+
static encodeArray(arr) {
|
|
156
|
+
const length = arr.length;
|
|
157
|
+
if (length <= constants.OPACK2_SMALL_ARRAY_MAX) {
|
|
158
|
+
const parts = [
|
|
159
|
+
Buffer.from([constants.OPACK2_SMALL_ARRAY_BASE + length]),
|
|
160
|
+
];
|
|
161
|
+
for (const item of arr) {
|
|
162
|
+
parts.push(this.encode(item));
|
|
163
|
+
}
|
|
164
|
+
return Buffer.concat(parts);
|
|
165
|
+
}
|
|
166
|
+
const parts = [
|
|
167
|
+
Buffer.from([constants.OPACK2_VARIABLE_ARRAY_MARKER]),
|
|
168
|
+
];
|
|
169
|
+
for (const item of arr) {
|
|
170
|
+
parts.push(this.encode(item));
|
|
171
|
+
}
|
|
172
|
+
parts.push(Buffer.from([constants.OPACK2_NULL]));
|
|
173
|
+
return Buffer.concat(parts);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Encodes objects/dictionaries with count-optimized headers
|
|
177
|
+
* @param dict - Object to encode
|
|
178
|
+
* @returns Buffer containing encoded dictionary
|
|
179
|
+
*/
|
|
180
|
+
static encodeDict(dict) {
|
|
181
|
+
const entries = Object.entries(dict);
|
|
182
|
+
const length = entries.length;
|
|
183
|
+
if (length < constants.OPACK2_SMALL_DICT_MAX) {
|
|
184
|
+
const parts = [
|
|
185
|
+
Buffer.from([constants.OPACK2_SMALL_DICT_BASE + length]),
|
|
186
|
+
];
|
|
187
|
+
for (const [key, value] of entries) {
|
|
188
|
+
parts.push(this.encode(key));
|
|
189
|
+
parts.push(this.encode(value));
|
|
190
|
+
}
|
|
191
|
+
return Buffer.concat(parts);
|
|
192
|
+
}
|
|
193
|
+
const parts = [
|
|
194
|
+
Buffer.from([constants.OPACK2_VARIABLE_DICT_MARKER]),
|
|
195
|
+
];
|
|
196
|
+
for (const [key, value] of entries) {
|
|
197
|
+
parts.push(this.encode(key));
|
|
198
|
+
parts.push(this.encode(value));
|
|
199
|
+
}
|
|
200
|
+
parts.push(Buffer.from([constants.OPACK2_NULL, constants.OPACK2_NULL]));
|
|
201
|
+
return Buffer.concat(parts);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -50,6 +50,5 @@ declare class RemoteXpcConnection {
|
|
|
50
50
|
*/
|
|
51
51
|
private forceCleanup;
|
|
52
52
|
}
|
|
53
|
-
export
|
|
54
|
-
export { type Service, type ServicesResponse };
|
|
53
|
+
export { RemoteXpcConnection, type Service, type ServicesResponse };
|
|
55
54
|
//# sourceMappingURL=remote-xpc-connection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-xpc-connection.d.ts","sourceRoot":"","sources":["../../../../src/lib/remote-xpc/remote-xpc-connection.ts"],"names":[],"mappings":"AAgBA,UAAU,OAAO;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,gBAAgB;IACxB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAKD,cAAM,mBAAmB;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,SAAS,CAAwB;gBAE7B,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IAQrC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA0J1C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0E5B;;;OAGG;IACH,WAAW,IAAI,OAAO,EAAE;IAOxB;;;OAGG;IACH,eAAe,IAAI,OAAO,EAAE;IAI5B;;;;OAIG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAYzC;;OAEG;IACH,OAAO,CAAC,aAAa;IAgCrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACH,OAAO,CAAC,YAAY;CAerB;AAkFD,
|
|
1
|
+
{"version":3,"file":"remote-xpc-connection.d.ts","sourceRoot":"","sources":["../../../../src/lib/remote-xpc/remote-xpc-connection.ts"],"names":[],"mappings":"AAgBA,UAAU,OAAO;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,gBAAgB;IACxB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAKD,cAAM,mBAAmB;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,SAAS,CAAwB;gBAE7B,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IAQrC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA0J1C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0E5B;;;OAGG;IACH,WAAW,IAAI,OAAO,EAAE;IAOxB;;;OAGG;IACH,eAAe,IAAI,OAAO,EAAE;IAI5B;;;;OAIG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAYzC;;OAEG;IACH,OAAO,CAAC,aAAa;IAgCrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACH,OAAO,CAAC,YAAY;CAerB;AAkFD,OAAO,EAAE,mBAAmB,EAAE,KAAK,OAAO,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TLSSocket } from 'tls';
|
|
2
2
|
import { type TunnelConnection } from 'tuntap-bridge';
|
|
3
|
+
import { RemoteXpcConnection } from '../remote-xpc/remote-xpc-connection.js';
|
|
3
4
|
/**
|
|
4
5
|
* A wrapper around the tunnel connection that
|
|
5
6
|
* maintains a registry of active tunnels that can be reused.
|
|
@@ -26,7 +27,7 @@ declare class TunnelManagerService {
|
|
|
26
27
|
* @param rsdPort - The RSD port of the tunnel
|
|
27
28
|
* @returns A promise that resolves to the RemoteXPC connection
|
|
28
29
|
*/
|
|
29
|
-
createRemoteXPCConnection(address: string, rsdPort: number): Promise<
|
|
30
|
+
createRemoteXPCConnection(address: string, rsdPort: number): Promise<RemoteXpcConnection>;
|
|
30
31
|
/**
|
|
31
32
|
* Establishes a tunnel connection if not already connected.
|
|
32
33
|
* If a tunnel is already open for the same address, it will be reused.
|
|
@@ -64,6 +65,6 @@ declare class TunnelManagerService {
|
|
|
64
65
|
closeTunnel(): Promise<void>;
|
|
65
66
|
}
|
|
66
67
|
export declare const TunnelManager: TunnelManagerService;
|
|
67
|
-
export { PacketStreamServer } from './packet-stream-server.js';
|
|
68
68
|
export { PacketStreamClient } from './packet-stream-client.js';
|
|
69
|
+
export { PacketStreamServer } from './packet-stream-server.js';
|
|
69
70
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/tunnel/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/tunnel/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,eAAe,CAAC;AAE/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAsB7E;;;GAGG;AACH,cAAM,oBAAoB;IAExB,OAAO,CAAC,cAAc,CAA+C;IAErE;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAKtC;;;;OAIG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAM5B;;;;;;OAMG;IACG,yBAAyB,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC;IA2C/B;;;;;;OAMG;IACG,SAAS,CAAC,mBAAmB,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmD1E;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAU5D;;;;;OAKG;IACG,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC1D;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAatC;;;;;OAKG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnC;AAGD,eAAO,MAAM,aAAa,sBAA6B,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger } from '@appium/support';
|
|
2
2
|
import { connectToTunnelLockdown } from 'tuntap-bridge';
|
|
3
|
-
import RemoteXpcConnection from '../remote-xpc/remote-xpc-connection.js';
|
|
3
|
+
import { RemoteXpcConnection } from '../remote-xpc/remote-xpc-connection.js';
|
|
4
4
|
const log = logger.getLogger('TunnelManager');
|
|
5
5
|
/**
|
|
6
6
|
* A wrapper around the tunnel connection that
|
|
@@ -38,7 +38,10 @@ class TunnelManagerService {
|
|
|
38
38
|
*/
|
|
39
39
|
async createRemoteXPCConnection(address, rsdPort) {
|
|
40
40
|
try {
|
|
41
|
-
const remoteXPC = new RemoteXpcConnection([
|
|
41
|
+
const remoteXPC = new RemoteXpcConnection([
|
|
42
|
+
address,
|
|
43
|
+
rsdPort,
|
|
44
|
+
]);
|
|
42
45
|
// Connect to RemoteXPC with delay between retries
|
|
43
46
|
let retries = 3;
|
|
44
47
|
let lastError;
|
|
@@ -201,5 +204,5 @@ class TunnelManagerService {
|
|
|
201
204
|
// Create and export the singleton instance
|
|
202
205
|
export const TunnelManager = new TunnelManagerService();
|
|
203
206
|
// Export packet streaming IPC functionality
|
|
204
|
-
export { PacketStreamServer } from './packet-stream-server.js';
|
|
205
207
|
export { PacketStreamClient } from './packet-stream-client.js';
|
|
208
|
+
export { PacketStreamServer } from './packet-stream-server.js';
|
package/build/src/lib/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import type { PacketData } from 'tuntap-bridge';
|
|
6
6
|
import type { BaseService, Service } from '../services/ios/base-service.js';
|
|
7
|
+
import type { RemoteXpcConnection } from './remote-xpc/remote-xpc-connection.js';
|
|
7
8
|
import type { Device } from './usbmux/index.js';
|
|
8
9
|
/**
|
|
9
10
|
* Represents a value that can be stored in a plist
|
|
@@ -152,6 +153,16 @@ export interface DiagnosticsServiceConstructor {
|
|
|
152
153
|
*/
|
|
153
154
|
new (address: [string, number]): DiagnosticsService;
|
|
154
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Represents a DiagnosticsService instance with its associated RemoteXPC connection
|
|
158
|
+
* This allows callers to properly manage the connection lifecycle
|
|
159
|
+
*/
|
|
160
|
+
export interface DiagnosticsServiceWithConnection {
|
|
161
|
+
/** The DiagnosticsService instance */
|
|
162
|
+
diagnosticsService: DiagnosticsService;
|
|
163
|
+
/** The RemoteXPC connection that can be used to close the connection */
|
|
164
|
+
remoteXPC: RemoteXpcConnection;
|
|
165
|
+
}
|
|
155
166
|
/**
|
|
156
167
|
* Options for configuring syslog capture
|
|
157
168
|
*/
|
|
@@ -1 +1 @@
|
|
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|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/ios/diagnostic-service/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,kBAAkB,IAAI,2BAA2B,EACjD,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD;;;;;GAKG;AACH,cAAM,kBACJ,SAAQ,WACR,YAAW,2BAA2B;IAEtC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,oDACmB;gBAEvC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IAIrC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;IAazC;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC;IAa1C;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC;IAavC;;;;OAIG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IA4CpD,OAAO,CAAC,gBAAgB;YAOV,0BAA0B;YAK1B,WAAW;IAoBzB,OAAO,CAAC,yBAAyB;YA0CnB,iCAAiC;CA6BhD;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -154,7 +154,6 @@ class DiagnosticsService extends BaseService {
|
|
|
154
154
|
};
|
|
155
155
|
log.debug('Sending follow-up request for additional data');
|
|
156
156
|
const additionalResponse = await conn.sendPlistRequest(emptyRequest, timeout);
|
|
157
|
-
log.debug('Additional response: ', additionalResponse);
|
|
158
157
|
const hasDiagnostics = 'Diagnostics' in additionalResponse &&
|
|
159
158
|
typeof additionalResponse.Diagnostics === 'object' &&
|
|
160
159
|
additionalResponse.Diagnostics !== null &&
|
package/build/src/services.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import RemoteXpcConnection from './lib/remote-xpc/remote-xpc-connection.js';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function startDiagnosticsService(udid: string): Promise<
|
|
1
|
+
import { RemoteXpcConnection } from './lib/remote-xpc/remote-xpc-connection.js';
|
|
2
|
+
import type { DiagnosticsServiceWithConnection, SyslogService as SyslogServiceType } from './lib/types.js';
|
|
3
|
+
export declare function startDiagnosticsService(udid: string): Promise<DiagnosticsServiceWithConnection>;
|
|
4
4
|
export declare function startSyslogService(udid: string): Promise<SyslogServiceType>;
|
|
5
5
|
export declare function createRemoteXPCConnection(udid: string): Promise<{
|
|
6
6
|
remoteXPC: RemoteXpcConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAEA,OAAO,mBAAmB,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAGhF,OAAO,KAAK,EACV,gCAAgC,EAChC,aAAa,IAAI,iBAAiB,EACnC,MAAM,gBAAgB,CAAC;AAOxB,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,gCAAgC,CAAC,CAY3C;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,iBAAiB,CAAC,CAG5B;AAED,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,MAAM;;;;;;;;GAO3D"}
|
package/build/src/services.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { strongbox } from '@appium/strongbox';
|
|
2
|
-
import RemoteXpcConnection from './lib/remote-xpc/remote-xpc-connection.js';
|
|
2
|
+
import { RemoteXpcConnection } from './lib/remote-xpc/remote-xpc-connection.js';
|
|
3
3
|
import { TunnelManager } from './lib/tunnel/index.js';
|
|
4
4
|
import { TunnelApiClient } from './lib/tunnel/tunnel-api-client.js';
|
|
5
5
|
import DiagnosticsService from './services/ios/diagnostic-service/index.js';
|
|
@@ -9,10 +9,13 @@ const TUNNEL_REGISTRY_PORT = 'tunnelRegistryPort';
|
|
|
9
9
|
export async function startDiagnosticsService(udid) {
|
|
10
10
|
const { remoteXPC, tunnelConnection } = await createRemoteXPCConnection(udid);
|
|
11
11
|
const diagnosticsService = remoteXPC.findService(DiagnosticsService.RSD_SERVICE_NAME);
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
return {
|
|
13
|
+
remoteXPC: remoteXPC,
|
|
14
|
+
diagnosticsService: new DiagnosticsService([
|
|
15
|
+
tunnelConnection.host,
|
|
16
|
+
parseInt(diagnosticsService.port, 10),
|
|
17
|
+
]),
|
|
18
|
+
};
|
|
16
19
|
}
|
|
17
20
|
export async function startSyslogService(udid) {
|
|
18
21
|
const { tunnelConnection } = await createRemoteXPCConnection(udid);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -81,3 +81,45 @@ export const HKDF_HASH_ALGORITHM = 'sha512';
|
|
|
81
81
|
|
|
82
82
|
// Output length (in bytes) for HKDF key derivation
|
|
83
83
|
export const HKDF_HASH_LENGTH = 64;
|
|
84
|
+
|
|
85
|
+
// OPACK2 encoding constants
|
|
86
|
+
export const OPACK2_NULL = 0x03;
|
|
87
|
+
export const OPACK2_TRUE = 0x01;
|
|
88
|
+
export const OPACK2_FALSE = 0x02;
|
|
89
|
+
export const OPACK2_SMALL_INT_OFFSET = 8;
|
|
90
|
+
export const OPACK2_SMALL_INT_MAX = 0x27;
|
|
91
|
+
export const OPACK2_SMALL_STRING_MAX = 0x20;
|
|
92
|
+
export const OPACK2_SMALL_BYTES_MAX = 0x20;
|
|
93
|
+
export const OPACK2_SMALL_ARRAY_MAX = 15;
|
|
94
|
+
export const OPACK2_SMALL_DICT_MAX = 15;
|
|
95
|
+
|
|
96
|
+
// OPACK2 number type markers
|
|
97
|
+
export const OPACK2_INT8_MARKER = 0x30;
|
|
98
|
+
export const OPACK2_INT32_MARKER = 0x32;
|
|
99
|
+
export const OPACK2_INT64_MARKER = 0x33;
|
|
100
|
+
export const OPACK2_FLOAT_MARKER = 0x35;
|
|
101
|
+
|
|
102
|
+
// OPACK2 string type markers
|
|
103
|
+
export const OPACK2_SMALL_STRING_BASE = 0x40;
|
|
104
|
+
export const OPACK2_STRING_8BIT_LEN_MARKER = 0x61;
|
|
105
|
+
export const OPACK2_STRING_16BIT_LEN_MARKER = 0x62;
|
|
106
|
+
export const OPACK2_STRING_32BIT_LEN_MARKER = 0x63;
|
|
107
|
+
|
|
108
|
+
// OPACK2 bytes type markers
|
|
109
|
+
export const OPACK2_SMALL_BYTES_BASE = 0x70;
|
|
110
|
+
export const OPACK2_BYTES_8BIT_LEN_MARKER = 0x91;
|
|
111
|
+
export const OPACK2_BYTES_16BIT_LEN_MARKER = 0x92;
|
|
112
|
+
export const OPACK2_BYTES_32BIT_LEN_MARKER = 0x93;
|
|
113
|
+
|
|
114
|
+
// OPACK2 array type markers
|
|
115
|
+
export const OPACK2_SMALL_ARRAY_BASE = 0xd0;
|
|
116
|
+
export const OPACK2_VARIABLE_ARRAY_MARKER = 0xdf;
|
|
117
|
+
|
|
118
|
+
// OPACK2 dictionary type markers
|
|
119
|
+
export const OPACK2_SMALL_DICT_BASE = 0xe0;
|
|
120
|
+
export const OPACK2_VARIABLE_DICT_MARKER = 0xef;
|
|
121
|
+
|
|
122
|
+
// OPACK2 size limits
|
|
123
|
+
export const OPACK2_UINT8_MAX = 0xff;
|
|
124
|
+
export const OPACK2_UINT16_MAX = 0xffff;
|
|
125
|
+
export const OPACK2_UINT32_MAX = 0xffffffff;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { logger } from '@appium/support';
|
|
2
|
+
import { createCipheriv, createDecipheriv } from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
import { CryptographyError } from '../errors.js';
|
|
5
|
+
|
|
6
|
+
const log = logger.getLogger('ChaCha20Poly1305');
|
|
7
|
+
|
|
8
|
+
export interface ChaCha20Poly1305Params {
|
|
9
|
+
plaintext?: Buffer;
|
|
10
|
+
ciphertext?: Buffer;
|
|
11
|
+
key: Buffer;
|
|
12
|
+
nonce: Buffer;
|
|
13
|
+
aad?: Buffer;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface DecryptionAttempt {
|
|
17
|
+
tagLen: number;
|
|
18
|
+
aad?: Buffer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Encrypts data using ChaCha20-Poly1305 AEAD cipher
|
|
23
|
+
* @param params - Encryption parameters including plaintext, key, nonce, and optional AAD
|
|
24
|
+
* @returns Buffer containing encrypted data concatenated with authentication tag
|
|
25
|
+
* @throws CryptographyError if encryption fails or required parameters are missing
|
|
26
|
+
*/
|
|
27
|
+
export function encryptChaCha20Poly1305(
|
|
28
|
+
params: ChaCha20Poly1305Params,
|
|
29
|
+
): Buffer {
|
|
30
|
+
const { plaintext, key, nonce, aad } = params;
|
|
31
|
+
|
|
32
|
+
if (!plaintext) {
|
|
33
|
+
throw new CryptographyError('Plaintext is required for encryption');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!key || key.length !== 32) {
|
|
37
|
+
throw new CryptographyError('Key must be 32 bytes');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!nonce || nonce.length !== 12) {
|
|
41
|
+
throw new CryptographyError('Nonce must be 12 bytes');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const cipher = createCipheriv('chacha20-poly1305', key, nonce) as any;
|
|
46
|
+
|
|
47
|
+
if (aad) {
|
|
48
|
+
cipher.setAAD(aad, { plaintextLength: plaintext.length });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
52
|
+
const authTag = cipher.getAuthTag();
|
|
53
|
+
|
|
54
|
+
return Buffer.concat([encrypted, authTag]);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
log.error('ChaCha20-Poly1305 encryption failed:', error);
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
throw new CryptographyError(
|
|
59
|
+
`ChaCha20-Poly1305 encryption failed: ${message}`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Decrypts data using ChaCha20-Poly1305 AEAD cipher with multiple fallback strategies
|
|
66
|
+
* @param params - Decryption parameters including ciphertext, key, nonce, and optional AAD
|
|
67
|
+
* @returns Buffer containing decrypted plaintext
|
|
68
|
+
* @throws CryptographyError if all decryption attempts fail or required parameters are missing
|
|
69
|
+
*/
|
|
70
|
+
export function decryptChaCha20Poly1305(
|
|
71
|
+
params: ChaCha20Poly1305Params,
|
|
72
|
+
): Buffer {
|
|
73
|
+
const { ciphertext, key, nonce, aad } = params;
|
|
74
|
+
|
|
75
|
+
if (!ciphertext) {
|
|
76
|
+
throw new CryptographyError('Ciphertext is required for decryption');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!key || key.length !== 32) {
|
|
80
|
+
throw new CryptographyError('Key must be 32 bytes');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!nonce || nonce.length !== 12) {
|
|
84
|
+
throw new CryptographyError('Nonce must be 12 bytes');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (ciphertext.length < 16) {
|
|
88
|
+
throw new CryptographyError(
|
|
89
|
+
'Ciphertext too short to contain authentication tag',
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ChaCha20-Poly1305 in Node.js only supports 16-byte authentication tags
|
|
94
|
+
const tagLength = 16;
|
|
95
|
+
const decryptionAttempts: DecryptionAttempt[] = [
|
|
96
|
+
{ tagLen: tagLength, aad },
|
|
97
|
+
{ tagLen: tagLength, aad: Buffer.alloc(0) },
|
|
98
|
+
{ tagLen: tagLength, aad: undefined },
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
let lastError: Error | undefined;
|
|
102
|
+
|
|
103
|
+
for (const attempt of decryptionAttempts) {
|
|
104
|
+
try {
|
|
105
|
+
const encrypted = ciphertext.subarray(
|
|
106
|
+
0,
|
|
107
|
+
ciphertext.length - attempt.tagLen,
|
|
108
|
+
);
|
|
109
|
+
const authTag = ciphertext.subarray(ciphertext.length - attempt.tagLen);
|
|
110
|
+
|
|
111
|
+
const decipher = createDecipheriv('chacha20-poly1305', key, nonce) as any;
|
|
112
|
+
decipher.setAuthTag(authTag);
|
|
113
|
+
|
|
114
|
+
if (attempt.aad !== undefined) {
|
|
115
|
+
decipher.setAAD(attempt.aad, { plaintextLength: encrypted.length });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const decrypted = Buffer.concat([
|
|
119
|
+
decipher.update(encrypted),
|
|
120
|
+
decipher.final(),
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
log.debug(
|
|
124
|
+
'Decryption successful with AAD:',
|
|
125
|
+
attempt.aad ? 'provided' : 'none',
|
|
126
|
+
);
|
|
127
|
+
return decrypted;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const errorMessage = lastError
|
|
134
|
+
? `ChaCha20-Poly1305 decryption failed: ${lastError.message}`
|
|
135
|
+
: 'ChaCha20-Poly1305 decryption failed: invalid ciphertext or authentication tag';
|
|
136
|
+
|
|
137
|
+
// Log the error with stack trace for debugging real failures
|
|
138
|
+
// Skip logging in test environment to avoid cluttering test output with expected failures
|
|
139
|
+
if (lastError && process.env.NODE_ENV !== 'test') {
|
|
140
|
+
log.error('All ChaCha20-Poly1305 decryption attempts failed:', {
|
|
141
|
+
message: lastError.message,
|
|
142
|
+
stack: lastError.stack,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
throw new CryptographyError(errorMessage);
|
|
147
|
+
}
|