appium-ios-remotexpc 0.1.1 → 0.3.0
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 +21 -0
- package/build/src/base-plist-service.d.ts +6 -6
- package/build/src/base-plist-service.d.ts.map +1 -1
- package/build/src/base-plist-service.js +8 -8
- package/build/src/lib/types.d.ts +45 -0
- package/build/src/lib/types.d.ts.map +1 -1
- package/build/src/services/ios/notification-proxy/index.d.ts +59 -0
- package/build/src/services/ios/notification-proxy/index.d.ts.map +1 -0
- package/build/src/services/ios/notification-proxy/index.js +134 -0
- package/build/src/services.d.ts +2 -1
- package/build/src/services.d.ts.map +1 -1
- package/build/src/services.js +12 -0
- package/package.json +9 -12
- package/src/base-plist-service.ts +9 -9
- package/src/lib/types.ts +47 -0
- package/src/services/ios/notification-proxy/index.ts +180 -0
- package/src/services.ts +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [0.3.0](https://github.com/appium/appium-ios-remotexpc/compare/v0.2.0...v0.3.0) (2025-08-26)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* Tune Node.js engines ([#60](https://github.com/appium/appium-ios-remotexpc/issues/60)) ([ab3a259](https://github.com/appium/appium-ios-remotexpc/commit/ab3a25966569c4fa07c50aad250c91cf9a837507))
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* use 0.9+ explicitly for xmldom reps ([#63](https://github.com/appium/appium-ios-remotexpc/issues/63)) ([4940032](https://github.com/appium/appium-ios-remotexpc/commit/4940032d439e5dd6a4537c8b8dde8ed49be7ebb9))
|
|
10
|
+
|
|
11
|
+
### Miscellaneous Chores
|
|
12
|
+
|
|
13
|
+
* **deps:** bump actions/checkout from 3 to 4 ([#57](https://github.com/appium/appium-ios-remotexpc/issues/57)) ([4d80170](https://github.com/appium/appium-ios-remotexpc/commit/4d80170359af0b41edfb11016ecc08aa6867a28c))
|
|
14
|
+
* **deps:** bump actions/setup-node from 3 to 4 ([#58](https://github.com/appium/appium-ios-remotexpc/issues/58)) ([1f2abdd](https://github.com/appium/appium-ios-remotexpc/commit/1f2abddc315900825d5a94dd817b234a393e1f85))
|
|
15
|
+
|
|
16
|
+
## [0.2.0](https://github.com/appium/appium-ios-remotexpc/compare/v0.1.1...v0.2.0) (2025-08-14)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* implement notification proxy ([#59](https://github.com/appium/appium-ios-remotexpc/issues/59)) ([aede9f5](https://github.com/appium/appium-ios-remotexpc/commit/aede9f55d7c94657b15a5fe20cc221686a941596))
|
|
21
|
+
|
|
1
22
|
## [0.1.1](https://github.com/appium/appium-ios-remotexpc/compare/v0.1.0...v0.1.1) (2025-07-23)
|
|
2
23
|
|
|
3
24
|
### Bug Fixes
|
|
@@ -20,6 +20,12 @@ export declare abstract class BasePlistService {
|
|
|
20
20
|
* Closes the underlying connection
|
|
21
21
|
*/
|
|
22
22
|
close(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Waits for a message
|
|
25
|
+
* @param timeout Timeout in milliseconds
|
|
26
|
+
* @returns Promise resolving to the received message
|
|
27
|
+
*/
|
|
28
|
+
receive(timeout?: number): Promise<PlistMessage>;
|
|
23
29
|
/**
|
|
24
30
|
* Gets the PlistService instance
|
|
25
31
|
* @returns The PlistService instance
|
|
@@ -40,12 +46,6 @@ export declare abstract class BasePlistService {
|
|
|
40
46
|
* @param message The message to send
|
|
41
47
|
*/
|
|
42
48
|
protected send(message: PlistMessage): void;
|
|
43
|
-
/**
|
|
44
|
-
* Waits for a message
|
|
45
|
-
* @param timeout Timeout in milliseconds
|
|
46
|
-
* @returns Promise resolving to the received message
|
|
47
|
-
*/
|
|
48
|
-
protected receive(timeout?: number): Promise<PlistMessage>;
|
|
49
49
|
}
|
|
50
50
|
export {};
|
|
51
51
|
//# sourceMappingURL=base-plist-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-plist-service.d.ts","sourceRoot":"","sources":["../../src/base-plist-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;GAEG;AACH,KAAK,YAAY,GAAG,eAAe,CAAC;AAEpC;;GAEG;AACH,8BAAsB,gBAAgB;IACpC;;;;;OAKG;IACG,cAAc,CAClB,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC;IAIxB;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,YAAY;IAIzC;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC;IAEtC;;;;OAIG;IACH,SAAS,aACP,oBAAoB,EAAE,YAAY,GAAG,MAAM,EAC3C,OAAO,GAAE,mBAAwB;IASnC;;;OAGG;IACH,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"base-plist-service.d.ts","sourceRoot":"","sources":["../../src/base-plist-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;GAEG;AACH,KAAK,YAAY,GAAG,eAAe,CAAC;AAEpC;;GAEG;AACH,8BAAsB,gBAAgB;IACpC;;;;;OAKG;IACG,cAAc,CAClB,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC;IAIxB;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;OAIG;IACU,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI7D;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,YAAY;IAIzC;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC;IAEtC;;;;OAIG;IACH,SAAS,aACP,oBAAoB,EAAE,YAAY,GAAG,MAAM,EAC3C,OAAO,GAAE,mBAAwB;IASnC;;;OAGG;IACH,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;CAG5C"}
|
|
@@ -19,6 +19,14 @@ export class BasePlistService {
|
|
|
19
19
|
close() {
|
|
20
20
|
this._plistService.close();
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Waits for a message
|
|
24
|
+
* @param timeout Timeout in milliseconds
|
|
25
|
+
* @returns Promise resolving to the received message
|
|
26
|
+
*/
|
|
27
|
+
async receive(timeout) {
|
|
28
|
+
return this._plistService.receivePlist(timeout);
|
|
29
|
+
}
|
|
22
30
|
/**
|
|
23
31
|
* Gets the PlistService instance
|
|
24
32
|
* @returns The PlistService instance
|
|
@@ -50,12 +58,4 @@ export class BasePlistService {
|
|
|
50
58
|
send(message) {
|
|
51
59
|
this._plistService.sendPlist(message);
|
|
52
60
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Waits for a message
|
|
55
|
-
* @param timeout Timeout in milliseconds
|
|
56
|
-
* @returns Promise resolving to the received message
|
|
57
|
-
*/
|
|
58
|
-
async receive(timeout) {
|
|
59
|
-
return this._plistService.receivePlist(timeout);
|
|
60
|
-
}
|
|
61
61
|
}
|
package/build/src/lib/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { PacketData } from 'appium-ios-tuntap';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
|
+
import type { ServiceConnection } from '../service-connection.js';
|
|
6
7
|
import type { BaseService, Service } from '../services/ios/base-service.js';
|
|
7
8
|
import type { RemoteXpcConnection } from './remote-xpc/remote-xpc-connection.js';
|
|
8
9
|
import type { Device } from './usbmux/index.js';
|
|
@@ -139,6 +140,40 @@ export interface DiagnosticsService extends BaseService {
|
|
|
139
140
|
timeout?: number;
|
|
140
141
|
}): Promise<PlistDictionary[] | Record<string, any>>;
|
|
141
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Represents the static side of DiagnosticsService
|
|
145
|
+
*/
|
|
146
|
+
export interface NotificationProxyService extends BaseService {
|
|
147
|
+
/**
|
|
148
|
+
* Connect to the notification proxy service
|
|
149
|
+
* @returns Promise resolving to the ServiceConnection instance
|
|
150
|
+
*/
|
|
151
|
+
connectToNotificationProxyService(): Promise<ServiceConnection>;
|
|
152
|
+
/**
|
|
153
|
+
* Observe a notification
|
|
154
|
+
* @param notification The notification name to subscribe to
|
|
155
|
+
* @returns Promise that resolves when the subscription request is sent
|
|
156
|
+
*/
|
|
157
|
+
observe(notification: string): Promise<PlistDictionary>;
|
|
158
|
+
/**
|
|
159
|
+
* Post a notification
|
|
160
|
+
* @param notification The notification name to post
|
|
161
|
+
* @returns Promise that resolves when the post request is sent
|
|
162
|
+
*/
|
|
163
|
+
post(notification: string): Promise<PlistDictionary>;
|
|
164
|
+
/**
|
|
165
|
+
* Expect notifications as an async generator
|
|
166
|
+
* @param timeout Timeout in milliseconds
|
|
167
|
+
* @returns AsyncGenerator yielding PlistMessage objects
|
|
168
|
+
*/
|
|
169
|
+
expectNotifications(timeout?: number): AsyncGenerator<PlistMessage>;
|
|
170
|
+
/**
|
|
171
|
+
* Expect a single notification
|
|
172
|
+
* @param timeout Timeout in milliseconds
|
|
173
|
+
* @returns Promise resolving to the expected notification
|
|
174
|
+
*/
|
|
175
|
+
expectNotification(timeout?: number): Promise<PlistMessage>;
|
|
176
|
+
}
|
|
142
177
|
/**
|
|
143
178
|
* Represents the static side of DiagnosticsService
|
|
144
179
|
*/
|
|
@@ -163,6 +198,16 @@ export interface DiagnosticsServiceWithConnection {
|
|
|
163
198
|
/** The RemoteXPC connection that can be used to close the connection */
|
|
164
199
|
remoteXPC: RemoteXpcConnection;
|
|
165
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Represents a NotificationProxyService instance with its associated RemoteXPC connection
|
|
203
|
+
* This allows callers to properly manage the connection lifecycle
|
|
204
|
+
*/
|
|
205
|
+
export interface NotificationProxyServiceWithConnection {
|
|
206
|
+
/** The NotificationProxyService instance */
|
|
207
|
+
notificationProxyService: NotificationProxyService;
|
|
208
|
+
/** The RemoteXPC connection that can be used to close the connection */
|
|
209
|
+
remoteXPC: RemoteXpcConnection;
|
|
210
|
+
}
|
|
166
211
|
/**
|
|
167
212
|
* Options for configuring syslog capture
|
|
168
213
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,MAAM,GACN,UAAU,GACV,eAAe,GACf,IAAI,CAAC;AAET;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3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,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;IAExD;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IAE3D;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC;CAChD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { NotificationProxyService as NotificationProxyServiceInterface, PlistDictionary, PlistMessage } from '../../../lib/types.js';
|
|
2
|
+
import { ServiceConnection } from '../../../service-connection.js';
|
|
3
|
+
import { BaseService } from '../base-service.js';
|
|
4
|
+
export interface ObserveNotificationRequest extends PlistDictionary {
|
|
5
|
+
Command: 'ObserveNotification';
|
|
6
|
+
Name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PostNotificationRequest extends PlistDictionary {
|
|
9
|
+
Command: 'PostNotification';
|
|
10
|
+
Name: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* NotificationProxyService provides an API to:
|
|
14
|
+
* - Observe notifications
|
|
15
|
+
* - Post notifications
|
|
16
|
+
* - Expects notifications
|
|
17
|
+
*/
|
|
18
|
+
declare class NotificationProxyService extends BaseService implements NotificationProxyServiceInterface {
|
|
19
|
+
static readonly RSD_SERVICE_NAME = "com.apple.mobile.notification_proxy.shim.remote";
|
|
20
|
+
private readonly timeout;
|
|
21
|
+
private _conn;
|
|
22
|
+
private _pendingNotificationsObservationSet;
|
|
23
|
+
constructor(address: [string, number], timeout?: number);
|
|
24
|
+
/**
|
|
25
|
+
* Observe a notification
|
|
26
|
+
* @param notification The notification name to subscribe to
|
|
27
|
+
* @returns Promise that resolves when the subscription request is sent
|
|
28
|
+
*/
|
|
29
|
+
observe(notification: string): Promise<PlistDictionary>;
|
|
30
|
+
/**
|
|
31
|
+
* Post a notification
|
|
32
|
+
* @param notification The notification name to post
|
|
33
|
+
* @returns Promise that resolves when the post request is sent
|
|
34
|
+
*/
|
|
35
|
+
post(notification: string): Promise<PlistDictionary>;
|
|
36
|
+
/**
|
|
37
|
+
* Expect notifications as an async generator
|
|
38
|
+
* @param timeout Timeout in milliseconds
|
|
39
|
+
* @returns AsyncGenerator yielding PlistMessage objects
|
|
40
|
+
*/
|
|
41
|
+
expectNotifications(timeout?: number): AsyncGenerator<PlistMessage>;
|
|
42
|
+
/**
|
|
43
|
+
* Expect a single notification
|
|
44
|
+
* @param timeout Timeout in milliseconds
|
|
45
|
+
* @returns Promise resolving to the expected notification
|
|
46
|
+
*/
|
|
47
|
+
expectNotification(timeout?: number): Promise<PlistMessage>;
|
|
48
|
+
/**
|
|
49
|
+
* Connect to the notification proxy service
|
|
50
|
+
* @returns Promise resolving to the ServiceConnection instance
|
|
51
|
+
*/
|
|
52
|
+
connectToNotificationProxyService(): Promise<ServiceConnection>;
|
|
53
|
+
private createObserveNotificationRequest;
|
|
54
|
+
private createPostNotificationRequest;
|
|
55
|
+
private getServiceConfig;
|
|
56
|
+
private sendPlistDictionary;
|
|
57
|
+
}
|
|
58
|
+
export { NotificationProxyService };
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/ios/notification-proxy/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wBAAwB,IAAI,iCAAiC,EAC7D,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,OAAO,EAAE,kBAAkB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,cAAM,wBACJ,SAAQ,WACR,YAAW,iCAAiC;IAE5C,MAAM,CAAC,QAAQ,CAAC,gBAAgB,qDACoB;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,mCAAmC,CAA0B;gBAEzD,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAE,MAAc;IAK9D;;;;OAIG;IACG,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAU7D;;;;OAIG;IACG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAe1D;;;;OAIG;IACI,mBAAmB,CACxB,OAAO,GAAE,MAAe,GACvB,cAAc,CAAC,YAAY,CAAC;IAqB/B;;;;OAIG;IACG,kBAAkB,CAAC,OAAO,GAAE,MAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IASzE;;;OAGG;IACG,iCAAiC,IAAI,OAAO,CAAC,iBAAiB,CAAC;IASrE,OAAO,CAAC,gCAAgC;IASxC,OAAO,CAAC,6BAA6B;IASrC,OAAO,CAAC,gBAAgB;YAWV,mBAAmB;CAelC;AAED,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { logger } from '@appium/support';
|
|
2
|
+
import { ServiceConnection } from '../../../service-connection.js';
|
|
3
|
+
import { BaseService } from '../base-service.js';
|
|
4
|
+
const log = logger.getLogger('NotificationProxyService');
|
|
5
|
+
/**
|
|
6
|
+
* NotificationProxyService provides an API to:
|
|
7
|
+
* - Observe notifications
|
|
8
|
+
* - Post notifications
|
|
9
|
+
* - Expects notifications
|
|
10
|
+
*/
|
|
11
|
+
class NotificationProxyService extends BaseService {
|
|
12
|
+
static RSD_SERVICE_NAME = 'com.apple.mobile.notification_proxy.shim.remote';
|
|
13
|
+
timeout;
|
|
14
|
+
_conn = null;
|
|
15
|
+
_pendingNotificationsObservationSet = new Set();
|
|
16
|
+
constructor(address, timeout = 10000) {
|
|
17
|
+
super(address);
|
|
18
|
+
this.timeout = timeout;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Observe a notification
|
|
22
|
+
* @param notification The notification name to subscribe to
|
|
23
|
+
* @returns Promise that resolves when the subscription request is sent
|
|
24
|
+
*/
|
|
25
|
+
async observe(notification) {
|
|
26
|
+
if (!this._conn) {
|
|
27
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
28
|
+
}
|
|
29
|
+
const request = this.createObserveNotificationRequest(notification);
|
|
30
|
+
const result = await this.sendPlistDictionary(request);
|
|
31
|
+
this._pendingNotificationsObservationSet.add(notification);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Post a notification
|
|
36
|
+
* @param notification The notification name to post
|
|
37
|
+
* @returns Promise that resolves when the post request is sent
|
|
38
|
+
*/
|
|
39
|
+
async post(notification) {
|
|
40
|
+
if (!this._pendingNotificationsObservationSet.has(notification)) {
|
|
41
|
+
log.error('Posting notifications without observing them may not yield any results. ' +
|
|
42
|
+
'Consider calling observe() first.');
|
|
43
|
+
throw new Error('You must call observe() before posting notifications.');
|
|
44
|
+
}
|
|
45
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
46
|
+
const request = this.createPostNotificationRequest(notification);
|
|
47
|
+
const result = await this.sendPlistDictionary(request);
|
|
48
|
+
this._pendingNotificationsObservationSet.delete(notification);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Expect notifications as an async generator
|
|
53
|
+
* @param timeout Timeout in milliseconds
|
|
54
|
+
* @returns AsyncGenerator yielding PlistMessage objects
|
|
55
|
+
*/
|
|
56
|
+
async *expectNotifications(timeout = 120000) {
|
|
57
|
+
if (!this._conn) {
|
|
58
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
59
|
+
}
|
|
60
|
+
while (true) {
|
|
61
|
+
try {
|
|
62
|
+
const notification = await this._conn.receive(timeout);
|
|
63
|
+
const notificationStr = JSON.stringify(notification);
|
|
64
|
+
const truncatedStr = notificationStr.length > 500
|
|
65
|
+
? `${notificationStr.substring(0, 500)}...`
|
|
66
|
+
: notificationStr;
|
|
67
|
+
log.info(`received response: ${truncatedStr}`);
|
|
68
|
+
yield notification;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
log.error(`Error receiving notification: ${error.message}`);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Expect a single notification
|
|
78
|
+
* @param timeout Timeout in milliseconds
|
|
79
|
+
* @returns Promise resolving to the expected notification
|
|
80
|
+
*/
|
|
81
|
+
async expectNotification(timeout = 120000) {
|
|
82
|
+
const generator = this.expectNotifications(timeout);
|
|
83
|
+
const { value, done } = await generator.next();
|
|
84
|
+
if (done || !value) {
|
|
85
|
+
throw new Error('No notification received');
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Connect to the notification proxy service
|
|
91
|
+
* @returns Promise resolving to the ServiceConnection instance
|
|
92
|
+
*/
|
|
93
|
+
async connectToNotificationProxyService() {
|
|
94
|
+
if (this._conn) {
|
|
95
|
+
return this._conn;
|
|
96
|
+
}
|
|
97
|
+
const service = this.getServiceConfig();
|
|
98
|
+
this._conn = await this.startLockdownService(service);
|
|
99
|
+
return this._conn;
|
|
100
|
+
}
|
|
101
|
+
createObserveNotificationRequest(notification) {
|
|
102
|
+
return {
|
|
103
|
+
Command: 'ObserveNotification',
|
|
104
|
+
Name: notification,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
createPostNotificationRequest(notification) {
|
|
108
|
+
return {
|
|
109
|
+
Command: 'PostNotification',
|
|
110
|
+
Name: notification,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
getServiceConfig() {
|
|
114
|
+
return {
|
|
115
|
+
serviceName: NotificationProxyService.RSD_SERVICE_NAME,
|
|
116
|
+
port: this.address[1].toString(),
|
|
117
|
+
options: { createConnectionTimeout: this.timeout },
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async sendPlistDictionary(request) {
|
|
121
|
+
if (!this._conn) {
|
|
122
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
123
|
+
}
|
|
124
|
+
const response = await this._conn.sendPlistRequest(request, this.timeout);
|
|
125
|
+
if (!response) {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray(response)) {
|
|
129
|
+
return response.length > 0 ? response[0] : {};
|
|
130
|
+
}
|
|
131
|
+
return response;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export { NotificationProxyService };
|
package/build/src/services.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RemoteXpcConnection } from './lib/remote-xpc/remote-xpc-connection.js';
|
|
2
|
-
import type { DiagnosticsServiceWithConnection, SyslogService as SyslogServiceType } from './lib/types.js';
|
|
2
|
+
import type { DiagnosticsServiceWithConnection, NotificationProxyServiceWithConnection, SyslogService as SyslogServiceType } from './lib/types.js';
|
|
3
3
|
export declare function startDiagnosticsService(udid: string): Promise<DiagnosticsServiceWithConnection>;
|
|
4
|
+
export declare function startNotificationProxyService(udid: string): Promise<NotificationProxyServiceWithConnection>;
|
|
4
5
|
export declare function startSyslogService(udid: string): Promise<SyslogServiceType>;
|
|
5
6
|
export declare function createRemoteXPCConnection(udid: string): Promise<{
|
|
6
7
|
remoteXPC: RemoteXpcConnection;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,sCAAsC,EACtC,aAAa,IAAI,iBAAiB,EACnC,MAAM,gBAAgB,CAAC;AAQxB,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,gCAAgC,CAAC,CAY3C;AAED,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,sCAAsC,CAAC,CAYjD;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
|
@@ -3,6 +3,7 @@ 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';
|
|
6
|
+
import { NotificationProxyService } from './services/ios/notification-proxy/index.js';
|
|
6
7
|
import SyslogService from './services/ios/syslog-service/index.js';
|
|
7
8
|
const APPIUM_XCUITEST_DRIVER_NAME = 'appium-xcuitest-driver';
|
|
8
9
|
const TUNNEL_REGISTRY_PORT = 'tunnelRegistryPort';
|
|
@@ -17,6 +18,17 @@ export async function startDiagnosticsService(udid) {
|
|
|
17
18
|
]),
|
|
18
19
|
};
|
|
19
20
|
}
|
|
21
|
+
export async function startNotificationProxyService(udid) {
|
|
22
|
+
const { remoteXPC, tunnelConnection } = await createRemoteXPCConnection(udid);
|
|
23
|
+
const notificationProxyService = remoteXPC.findService(NotificationProxyService.RSD_SERVICE_NAME);
|
|
24
|
+
return {
|
|
25
|
+
remoteXPC: remoteXPC,
|
|
26
|
+
notificationProxyService: new NotificationProxyService([
|
|
27
|
+
tunnelConnection.host,
|
|
28
|
+
parseInt(notificationProxyService.port, 10),
|
|
29
|
+
]),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
20
32
|
export async function startSyslogService(udid) {
|
|
21
33
|
const { tunnelConnection } = await createRemoteXPCConnection(udid);
|
|
22
34
|
return new SyslogService([tunnelConnection.host, tunnelConnection.port]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-ios-remotexpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"main": "build/src/index.js",
|
|
5
5
|
"types": "build/src/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": "
|
|
14
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
|
|
15
|
+
"npm": ">=10"
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
18
|
"clean:build": "rimraf ./build",
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"test:tunnel": "mocha test/integration/tunnel-test.ts --exit --timeout 1m",
|
|
28
29
|
"test:pair-record": "mocha test/integration/read-pair-record-test.ts --exit --timeout 1m",
|
|
29
30
|
"test:diagnostics": "mocha test/integration/diagnostics-test.ts --exit --timeout 1m",
|
|
31
|
+
"test:notification": "mocha test/integration/notification-proxy-test.ts --exit --timeout 1m",
|
|
30
32
|
"test:unit": "mocha 'test/unit/**/*.ts' --exit --timeout 2m",
|
|
31
33
|
"test:tunnel-creation": "sudo tsx scripts/test-tunnel-creation.ts",
|
|
32
34
|
"test:tunnel-creation:lsof": "sudo tsx scripts/test-tunnel-creation.ts --keep-open"
|
|
@@ -43,21 +45,17 @@
|
|
|
43
45
|
},
|
|
44
46
|
"description": "",
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@appium/eslint-config-appium-ts": "^
|
|
47
|
-
"@appium/tsconfig": "^0.
|
|
48
|
-
"@eslint/js": "^9.23.0",
|
|
48
|
+
"@appium/eslint-config-appium-ts": "^2.0.0-rc.1",
|
|
49
|
+
"@appium/tsconfig": "^1.0.0-rc.1",
|
|
49
50
|
"@semantic-release/changelog": "^6.0.3",
|
|
50
51
|
"@semantic-release/git": "^10.0.1",
|
|
51
52
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
52
53
|
"@types/chai": "^5.2.1",
|
|
53
54
|
"@types/chai-as-promised": "^8.0.2",
|
|
54
55
|
"@types/mocha": "^10.0.10",
|
|
55
|
-
"appium": "^2.17.1",
|
|
56
56
|
"chai": "^5.2.0",
|
|
57
57
|
"chai-as-promised": "^8.0.1",
|
|
58
58
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
59
|
-
"eslint": "^9.23.0",
|
|
60
|
-
"eslint-config-prettier": "^10.1.2",
|
|
61
59
|
"eslint-plugin-unicorn": "^58.0.0",
|
|
62
60
|
"mocha": "^11.1.0",
|
|
63
61
|
"prettier": "^3.5.3",
|
|
@@ -65,12 +63,11 @@
|
|
|
65
63
|
"semantic-release": "^24.0.0",
|
|
66
64
|
"ts-node": "^10.9.2",
|
|
67
65
|
"tsx": "^4.7.0",
|
|
68
|
-
"typescript": "^5.2.2"
|
|
69
|
-
"typescript-eslint": "^8.29.0"
|
|
66
|
+
"typescript": "^5.2.2"
|
|
70
67
|
},
|
|
71
68
|
"dependencies": {
|
|
72
|
-
"@appium/strongbox": "^0.
|
|
73
|
-
"@appium/support": "^
|
|
69
|
+
"@appium/strongbox": "^1.0.0-rc.1",
|
|
70
|
+
"@appium/support": "^7.0.0-rc.1",
|
|
74
71
|
"@types/node": "^24.0.10",
|
|
75
72
|
"@xmldom/xmldom": "^0.9.8",
|
|
76
73
|
"npm-run-all2": "^7.0.2",
|
|
@@ -35,6 +35,15 @@ export abstract class BasePlistService {
|
|
|
35
35
|
this._plistService.close();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Waits for a message
|
|
40
|
+
* @param timeout Timeout in milliseconds
|
|
41
|
+
* @returns Promise resolving to the received message
|
|
42
|
+
*/
|
|
43
|
+
public async receive(timeout?: number): Promise<PlistMessage> {
|
|
44
|
+
return this._plistService.receivePlist(timeout);
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
/**
|
|
39
48
|
* Gets the PlistService instance
|
|
40
49
|
* @returns The PlistService instance
|
|
@@ -71,13 +80,4 @@ export abstract class BasePlistService {
|
|
|
71
80
|
protected send(message: PlistMessage): void {
|
|
72
81
|
this._plistService.sendPlist(message);
|
|
73
82
|
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Waits for a message
|
|
77
|
-
* @param timeout Timeout in milliseconds
|
|
78
|
-
* @returns Promise resolving to the received message
|
|
79
|
-
*/
|
|
80
|
-
protected async receive(timeout?: number): Promise<PlistMessage> {
|
|
81
|
-
return this._plistService.receivePlist(timeout);
|
|
82
|
-
}
|
|
83
83
|
}
|
package/src/lib/types.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { PacketData } from 'appium-ios-tuntap';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
6
|
|
|
7
|
+
import type { ServiceConnection } from '../service-connection.js';
|
|
7
8
|
import type { BaseService, Service } from '../services/ios/base-service.js';
|
|
8
9
|
import type { RemoteXpcConnection } from './remote-xpc/remote-xpc-connection.js';
|
|
9
10
|
import type { Device } from './usbmux/index.js';
|
|
@@ -176,6 +177,41 @@ export interface DiagnosticsService extends BaseService {
|
|
|
176
177
|
}): Promise<PlistDictionary[] | Record<string, any>>;
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Represents the static side of DiagnosticsService
|
|
182
|
+
*/
|
|
183
|
+
export interface NotificationProxyService extends BaseService {
|
|
184
|
+
/**
|
|
185
|
+
* Connect to the notification proxy service
|
|
186
|
+
* @returns Promise resolving to the ServiceConnection instance
|
|
187
|
+
*/
|
|
188
|
+
connectToNotificationProxyService(): Promise<ServiceConnection>;
|
|
189
|
+
/**
|
|
190
|
+
* Observe a notification
|
|
191
|
+
* @param notification The notification name to subscribe to
|
|
192
|
+
* @returns Promise that resolves when the subscription request is sent
|
|
193
|
+
*/
|
|
194
|
+
observe(notification: string): Promise<PlistDictionary>;
|
|
195
|
+
/**
|
|
196
|
+
* Post a notification
|
|
197
|
+
* @param notification The notification name to post
|
|
198
|
+
* @returns Promise that resolves when the post request is sent
|
|
199
|
+
*/
|
|
200
|
+
post(notification: string): Promise<PlistDictionary>;
|
|
201
|
+
/**
|
|
202
|
+
* Expect notifications as an async generator
|
|
203
|
+
* @param timeout Timeout in milliseconds
|
|
204
|
+
* @returns AsyncGenerator yielding PlistMessage objects
|
|
205
|
+
*/
|
|
206
|
+
expectNotifications(timeout?: number): AsyncGenerator<PlistMessage>;
|
|
207
|
+
/**
|
|
208
|
+
* Expect a single notification
|
|
209
|
+
* @param timeout Timeout in milliseconds
|
|
210
|
+
* @returns Promise resolving to the expected notification
|
|
211
|
+
*/
|
|
212
|
+
expectNotification(timeout?: number): Promise<PlistMessage>;
|
|
213
|
+
}
|
|
214
|
+
|
|
179
215
|
/**
|
|
180
216
|
* Represents the static side of DiagnosticsService
|
|
181
217
|
*/
|
|
@@ -202,6 +238,17 @@ export interface DiagnosticsServiceWithConnection {
|
|
|
202
238
|
remoteXPC: RemoteXpcConnection;
|
|
203
239
|
}
|
|
204
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Represents a NotificationProxyService instance with its associated RemoteXPC connection
|
|
243
|
+
* This allows callers to properly manage the connection lifecycle
|
|
244
|
+
*/
|
|
245
|
+
export interface NotificationProxyServiceWithConnection {
|
|
246
|
+
/** The NotificationProxyService instance */
|
|
247
|
+
notificationProxyService: NotificationProxyService;
|
|
248
|
+
/** The RemoteXPC connection that can be used to close the connection */
|
|
249
|
+
remoteXPC: RemoteXpcConnection;
|
|
250
|
+
}
|
|
251
|
+
|
|
205
252
|
/**
|
|
206
253
|
* Options for configuring syslog capture
|
|
207
254
|
*/
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { logger } from '@appium/support';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
NotificationProxyService as NotificationProxyServiceInterface,
|
|
5
|
+
PlistDictionary,
|
|
6
|
+
PlistMessage,
|
|
7
|
+
} from '../../../lib/types.js';
|
|
8
|
+
import { ServiceConnection } from '../../../service-connection.js';
|
|
9
|
+
import { BaseService } from '../base-service.js';
|
|
10
|
+
|
|
11
|
+
const log = logger.getLogger('NotificationProxyService');
|
|
12
|
+
|
|
13
|
+
export interface ObserveNotificationRequest extends PlistDictionary {
|
|
14
|
+
Command: 'ObserveNotification';
|
|
15
|
+
Name: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PostNotificationRequest extends PlistDictionary {
|
|
19
|
+
Command: 'PostNotification';
|
|
20
|
+
Name: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* NotificationProxyService provides an API to:
|
|
25
|
+
* - Observe notifications
|
|
26
|
+
* - Post notifications
|
|
27
|
+
* - Expects notifications
|
|
28
|
+
*/
|
|
29
|
+
class NotificationProxyService
|
|
30
|
+
extends BaseService
|
|
31
|
+
implements NotificationProxyServiceInterface
|
|
32
|
+
{
|
|
33
|
+
static readonly RSD_SERVICE_NAME =
|
|
34
|
+
'com.apple.mobile.notification_proxy.shim.remote';
|
|
35
|
+
private readonly timeout: number;
|
|
36
|
+
private _conn: ServiceConnection | null = null;
|
|
37
|
+
private _pendingNotificationsObservationSet: Set<string> = new Set();
|
|
38
|
+
|
|
39
|
+
constructor(address: [string, number], timeout: number = 10000) {
|
|
40
|
+
super(address);
|
|
41
|
+
this.timeout = timeout;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Observe a notification
|
|
46
|
+
* @param notification The notification name to subscribe to
|
|
47
|
+
* @returns Promise that resolves when the subscription request is sent
|
|
48
|
+
*/
|
|
49
|
+
async observe(notification: string): Promise<PlistDictionary> {
|
|
50
|
+
if (!this._conn) {
|
|
51
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
52
|
+
}
|
|
53
|
+
const request = this.createObserveNotificationRequest(notification);
|
|
54
|
+
const result = await this.sendPlistDictionary(request);
|
|
55
|
+
this._pendingNotificationsObservationSet.add(notification);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Post a notification
|
|
61
|
+
* @param notification The notification name to post
|
|
62
|
+
* @returns Promise that resolves when the post request is sent
|
|
63
|
+
*/
|
|
64
|
+
async post(notification: string): Promise<PlistDictionary> {
|
|
65
|
+
if (!this._pendingNotificationsObservationSet.has(notification)) {
|
|
66
|
+
log.error(
|
|
67
|
+
'Posting notifications without observing them may not yield any results. ' +
|
|
68
|
+
'Consider calling observe() first.',
|
|
69
|
+
);
|
|
70
|
+
throw new Error('You must call observe() before posting notifications.');
|
|
71
|
+
}
|
|
72
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
73
|
+
const request = this.createPostNotificationRequest(notification);
|
|
74
|
+
const result = await this.sendPlistDictionary(request);
|
|
75
|
+
this._pendingNotificationsObservationSet.delete(notification);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Expect notifications as an async generator
|
|
81
|
+
* @param timeout Timeout in milliseconds
|
|
82
|
+
* @returns AsyncGenerator yielding PlistMessage objects
|
|
83
|
+
*/
|
|
84
|
+
async *expectNotifications(
|
|
85
|
+
timeout: number = 120000,
|
|
86
|
+
): AsyncGenerator<PlistMessage> {
|
|
87
|
+
if (!this._conn) {
|
|
88
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
89
|
+
}
|
|
90
|
+
while (true) {
|
|
91
|
+
try {
|
|
92
|
+
const notification = await this._conn.receive(timeout);
|
|
93
|
+
const notificationStr = JSON.stringify(notification);
|
|
94
|
+
const truncatedStr =
|
|
95
|
+
notificationStr.length > 500
|
|
96
|
+
? `${notificationStr.substring(0, 500)}...`
|
|
97
|
+
: notificationStr;
|
|
98
|
+
log.info(`received response: ${truncatedStr}`);
|
|
99
|
+
yield notification;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
log.error(`Error receiving notification: ${(error as Error).message}`);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Expect a single notification
|
|
109
|
+
* @param timeout Timeout in milliseconds
|
|
110
|
+
* @returns Promise resolving to the expected notification
|
|
111
|
+
*/
|
|
112
|
+
async expectNotification(timeout: number = 120000): Promise<PlistMessage> {
|
|
113
|
+
const generator = this.expectNotifications(timeout);
|
|
114
|
+
const { value, done } = await generator.next();
|
|
115
|
+
if (done || !value) {
|
|
116
|
+
throw new Error('No notification received');
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Connect to the notification proxy service
|
|
123
|
+
* @returns Promise resolving to the ServiceConnection instance
|
|
124
|
+
*/
|
|
125
|
+
async connectToNotificationProxyService(): Promise<ServiceConnection> {
|
|
126
|
+
if (this._conn) {
|
|
127
|
+
return this._conn;
|
|
128
|
+
}
|
|
129
|
+
const service = this.getServiceConfig();
|
|
130
|
+
this._conn = await this.startLockdownService(service);
|
|
131
|
+
return this._conn;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private createObserveNotificationRequest(
|
|
135
|
+
notification: string,
|
|
136
|
+
): ObserveNotificationRequest {
|
|
137
|
+
return {
|
|
138
|
+
Command: 'ObserveNotification',
|
|
139
|
+
Name: notification,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private createPostNotificationRequest(
|
|
144
|
+
notification: string,
|
|
145
|
+
): PostNotificationRequest {
|
|
146
|
+
return {
|
|
147
|
+
Command: 'PostNotification',
|
|
148
|
+
Name: notification,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private getServiceConfig(): {
|
|
153
|
+
serviceName: string;
|
|
154
|
+
port: string;
|
|
155
|
+
options: { createConnectionTimeout: number };
|
|
156
|
+
} {
|
|
157
|
+
return {
|
|
158
|
+
serviceName: NotificationProxyService.RSD_SERVICE_NAME,
|
|
159
|
+
port: this.address[1].toString(),
|
|
160
|
+
options: { createConnectionTimeout: this.timeout },
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
private async sendPlistDictionary(
|
|
164
|
+
request: PlistDictionary,
|
|
165
|
+
): Promise<PlistDictionary> {
|
|
166
|
+
if (!this._conn) {
|
|
167
|
+
this._conn = await this.connectToNotificationProxyService();
|
|
168
|
+
}
|
|
169
|
+
const response = await this._conn.sendPlistRequest(request, this.timeout);
|
|
170
|
+
if (!response) {
|
|
171
|
+
return {};
|
|
172
|
+
}
|
|
173
|
+
if (Array.isArray(response)) {
|
|
174
|
+
return response.length > 0 ? (response[0] as PlistDictionary) : {};
|
|
175
|
+
}
|
|
176
|
+
return response as PlistDictionary;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { NotificationProxyService };
|
package/src/services.ts
CHANGED
|
@@ -5,9 +5,11 @@ import { TunnelManager } from './lib/tunnel/index.js';
|
|
|
5
5
|
import { TunnelApiClient } from './lib/tunnel/tunnel-api-client.js';
|
|
6
6
|
import type {
|
|
7
7
|
DiagnosticsServiceWithConnection,
|
|
8
|
+
NotificationProxyServiceWithConnection,
|
|
8
9
|
SyslogService as SyslogServiceType,
|
|
9
10
|
} from './lib/types.js';
|
|
10
11
|
import DiagnosticsService from './services/ios/diagnostic-service/index.js';
|
|
12
|
+
import { NotificationProxyService } from './services/ios/notification-proxy/index.js';
|
|
11
13
|
import SyslogService from './services/ios/syslog-service/index.js';
|
|
12
14
|
|
|
13
15
|
const APPIUM_XCUITEST_DRIVER_NAME = 'appium-xcuitest-driver';
|
|
@@ -29,6 +31,22 @@ export async function startDiagnosticsService(
|
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
export async function startNotificationProxyService(
|
|
35
|
+
udid: string,
|
|
36
|
+
): Promise<NotificationProxyServiceWithConnection> {
|
|
37
|
+
const { remoteXPC, tunnelConnection } = await createRemoteXPCConnection(udid);
|
|
38
|
+
const notificationProxyService = remoteXPC.findService(
|
|
39
|
+
NotificationProxyService.RSD_SERVICE_NAME,
|
|
40
|
+
);
|
|
41
|
+
return {
|
|
42
|
+
remoteXPC: remoteXPC as RemoteXpcConnection,
|
|
43
|
+
notificationProxyService: new NotificationProxyService([
|
|
44
|
+
tunnelConnection.host,
|
|
45
|
+
parseInt(notificationProxyService.port, 10),
|
|
46
|
+
]),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
32
50
|
export async function startSyslogService(
|
|
33
51
|
udid: string,
|
|
34
52
|
): Promise<SyslogServiceType> {
|