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.
Files changed (152) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/afc/index.d.ts +1 -1
  3. package/build/lib/afc/index.d.ts.map +1 -1
  4. package/build/lib/afc/index.js +9 -9
  5. package/build/lib/afc/index.js.map +1 -1
  6. package/build/lib/afc/protocol.d.ts.map +1 -1
  7. package/build/lib/afc/protocol.js +16 -16
  8. package/build/lib/afc/protocol.js.map +1 -1
  9. package/build/lib/afc/streams.d.ts.map +1 -1
  10. package/build/lib/afc/streams.js.map +1 -1
  11. package/build/lib/afc/transformer/afcdecoder.d.ts.map +1 -1
  12. package/build/lib/afc/transformer/afcdecoder.js.map +1 -1
  13. package/build/lib/afc/transformer/afcencoder.d.ts.map +1 -1
  14. package/build/lib/afc/transformer/afcencoder.js.map +1 -1
  15. package/build/lib/base-service.d.ts.map +1 -1
  16. package/build/lib/base-service.js.map +1 -1
  17. package/build/lib/house-arrest/index.d.ts.map +1 -1
  18. package/build/lib/house-arrest/index.js.map +1 -1
  19. package/build/lib/imagemounter/index.d.ts.map +1 -1
  20. package/build/lib/imagemounter/index.js +4 -4
  21. package/build/lib/imagemounter/index.js.map +1 -1
  22. package/build/lib/imagemounter/utils/list_developer_image.d.ts.map +1 -1
  23. package/build/lib/imagemounter/utils/list_developer_image.js +3 -3
  24. package/build/lib/imagemounter/utils/list_developer_image.js.map +1 -1
  25. package/build/lib/installation-proxy/index.d.ts +11 -11
  26. package/build/lib/installation-proxy/index.d.ts.map +1 -1
  27. package/build/lib/installation-proxy/index.js +19 -17
  28. package/build/lib/installation-proxy/index.js.map +1 -1
  29. package/build/lib/instrument/headers.d.ts.map +1 -1
  30. package/build/lib/instrument/headers.js +7 -7
  31. package/build/lib/instrument/headers.js.map +1 -1
  32. package/build/lib/instrument/index.d.ts +1 -1
  33. package/build/lib/instrument/index.d.ts.map +1 -1
  34. package/build/lib/instrument/index.js +13 -7
  35. package/build/lib/instrument/index.js.map +1 -1
  36. package/build/lib/instrument/transformer/dtx-decode.d.ts.map +1 -1
  37. package/build/lib/instrument/transformer/dtx-decode.js +9 -3
  38. package/build/lib/instrument/transformer/dtx-decode.js.map +1 -1
  39. package/build/lib/instrument/transformer/dtx-encode.d.ts.map +1 -1
  40. package/build/lib/instrument/transformer/dtx-encode.js +1 -1
  41. package/build/lib/instrument/transformer/dtx-encode.js.map +1 -1
  42. package/build/lib/instrument/transformer/nskeyed.d.ts.map +1 -1
  43. package/build/lib/instrument/transformer/nskeyed.js +16 -9
  44. package/build/lib/instrument/transformer/nskeyed.js.map +1 -1
  45. package/build/lib/lockdown/index.d.ts +5 -5
  46. package/build/lib/lockdown/index.d.ts.map +1 -1
  47. package/build/lib/lockdown/index.js +9 -10
  48. package/build/lib/lockdown/index.js.map +1 -1
  49. package/build/lib/logger.js.map +1 -1
  50. package/build/lib/mcinstall/index.d.ts.map +1 -1
  51. package/build/lib/mcinstall/index.js +14 -6
  52. package/build/lib/mcinstall/index.js.map +1 -1
  53. package/build/lib/notification-proxy/index.d.ts.map +1 -1
  54. package/build/lib/notification-proxy/index.js +2 -2
  55. package/build/lib/notification-proxy/index.js.map +1 -1
  56. package/build/lib/plist-service/index.d.ts.map +1 -1
  57. package/build/lib/plist-service/index.js.map +1 -1
  58. package/build/lib/plist-service/transformer/plist-service-decoder.d.ts.map +1 -1
  59. package/build/lib/plist-service/transformer/plist-service-decoder.js.map +1 -1
  60. package/build/lib/plist-service/transformer/plist-service-encoder.d.ts.map +1 -1
  61. package/build/lib/plist-service/transformer/plist-service-encoder.js.map +1 -1
  62. package/build/lib/services.d.ts.map +1 -1
  63. package/build/lib/services.js +3 -3
  64. package/build/lib/services.js.map +1 -1
  65. package/build/lib/simulatelocation/index.d.ts.map +1 -1
  66. package/build/lib/simulatelocation/index.js.map +1 -1
  67. package/build/lib/ssl-helper.js +3 -3
  68. package/build/lib/ssl-helper.js.map +1 -1
  69. package/build/lib/syslog/index.d.ts +1 -1
  70. package/build/lib/syslog/index.d.ts.map +1 -1
  71. package/build/lib/syslog/index.js +1 -1
  72. package/build/lib/syslog/index.js.map +1 -1
  73. package/build/lib/syslog/transformer/syslog-decoder.d.ts.map +1 -1
  74. package/build/lib/syslog/transformer/syslog-decoder.js +4 -2
  75. package/build/lib/syslog/transformer/syslog-decoder.js.map +1 -1
  76. package/build/lib/testmanagerd/index.d.ts.map +1 -1
  77. package/build/lib/testmanagerd/index.js.map +1 -1
  78. package/build/lib/usbmux/index.d.ts.map +1 -1
  79. package/build/lib/usbmux/index.js +16 -13
  80. package/build/lib/usbmux/index.js.map +1 -1
  81. package/build/lib/usbmux/transformer/usbmux-decoder.d.ts.map +1 -1
  82. package/build/lib/usbmux/transformer/usbmux-decoder.js +1 -1
  83. package/build/lib/usbmux/transformer/usbmux-decoder.js.map +1 -1
  84. package/build/lib/usbmux/transformer/usbmux-encoder.d.ts.map +1 -1
  85. package/build/lib/usbmux/transformer/usbmux-encoder.js +1 -1
  86. package/build/lib/usbmux/transformer/usbmux-encoder.js.map +1 -1
  87. package/build/lib/util/transformer/length-based-splitter.d.ts.map +1 -1
  88. package/build/lib/util/transformer/length-based-splitter.js +9 -4
  89. package/build/lib/util/transformer/length-based-splitter.js.map +1 -1
  90. package/build/lib/util/transformer/stream-logger.d.ts.map +1 -1
  91. package/build/lib/util/transformer/stream-logger.js +4 -3
  92. package/build/lib/util/transformer/stream-logger.js.map +1 -1
  93. package/build/lib/util/uuid/parse.js.map +1 -1
  94. package/build/lib/util/uuid/stringify.js.map +1 -1
  95. package/build/lib/util/uuid/validate.d.ts.map +1 -1
  96. package/build/lib/util/uuid/validate.js.map +1 -1
  97. package/build/lib/utilities.d.ts.map +1 -1
  98. package/build/lib/utilities.js +12 -12
  99. package/build/lib/utilities.js.map +1 -1
  100. package/build/lib/webinspector/index.d.ts.map +1 -1
  101. package/build/lib/webinspector/index.js +11 -9
  102. package/build/lib/webinspector/index.js.map +1 -1
  103. package/build/lib/webinspector/transformer/webinspector-decoder.d.ts.map +1 -1
  104. package/build/lib/webinspector/transformer/webinspector-decoder.js.map +1 -1
  105. package/build/lib/webinspector/transformer/webinspector-encoder.d.ts.map +1 -1
  106. package/build/lib/webinspector/transformer/webinspector-encoder.js.map +1 -1
  107. package/build/lib/xctest.d.ts.map +1 -1
  108. package/build/lib/xctest.js +3 -6
  109. package/build/lib/xctest.js.map +1 -1
  110. package/lib/afc/index.js +49 -43
  111. package/lib/afc/protocol.js +53 -50
  112. package/lib/afc/streams.js +7 -9
  113. package/lib/afc/transformer/afcdecoder.js +8 -10
  114. package/lib/afc/transformer/afcencoder.js +7 -10
  115. package/lib/base-service.js +2 -4
  116. package/lib/constants.js +1 -1
  117. package/lib/house-arrest/index.js +16 -14
  118. package/lib/imagemounter/index.js +107 -104
  119. package/lib/imagemounter/utils/list_developer_image.js +115 -100
  120. package/lib/installation-proxy/index.js +31 -27
  121. package/lib/instrument/headers.js +51 -40
  122. package/lib/instrument/index.js +32 -21
  123. package/lib/instrument/transformer/dtx-decode.js +30 -16
  124. package/lib/instrument/transformer/dtx-encode.js +6 -8
  125. package/lib/instrument/transformer/nskeyed.js +40 -21
  126. package/lib/lockdown/index.js +44 -35
  127. package/lib/logger.js +1 -1
  128. package/lib/mcinstall/index.js +20 -13
  129. package/lib/notification-proxy/index.js +18 -17
  130. package/lib/plist-service/index.js +13 -14
  131. package/lib/plist-service/transformer/plist-service-decoder.js +6 -7
  132. package/lib/plist-service/transformer/plist-service-encoder.js +6 -7
  133. package/lib/services.js +45 -29
  134. package/lib/simulatelocation/index.js +4 -5
  135. package/lib/ssl-helper.js +6 -7
  136. package/lib/syslog/index.js +7 -8
  137. package/lib/syslog/transformer/syslog-decoder.js +11 -10
  138. package/lib/testmanagerd/index.js +10 -7
  139. package/lib/usbmux/index.js +52 -41
  140. package/lib/usbmux/transformer/usbmux-decoder.js +8 -10
  141. package/lib/usbmux/transformer/usbmux-encoder.js +10 -8
  142. package/lib/util/transformer/length-based-splitter.js +62 -24
  143. package/lib/util/transformer/stream-logger.js +14 -11
  144. package/lib/util/uuid/parse.ts +2 -2
  145. package/lib/util/uuid/stringify.ts +1 -1
  146. package/lib/util/uuid/validate.ts +2 -1
  147. package/lib/utilities.js +39 -28
  148. package/lib/webinspector/index.js +59 -46
  149. package/lib/webinspector/transformer/webinspector-decoder.js +22 -11
  150. package/lib/webinspector/transformer/webinspector-encoder.js +6 -8
  151. package/lib/xctest.js +284 -245
  152. package/package.json +4 -2
@@ -1,10 +1,10 @@
1
- import plistlib, { parseBuffer } from 'bplist-parser';
1
+ import plistlib, {parseBuffer} from 'bplist-parser';
2
2
  import bplistCreate from 'bplist-creator';
3
- import { parse as uuidParse } from '../../util/uuid/parse';
4
- import { stringify as uuidStringify } from '../../util/uuid/stringify';
3
+ import {parse as uuidParse} from '../../util/uuid/parse';
4
+ import {stringify as uuidStringify} from '../../util/uuid/stringify';
5
5
  import _ from 'lodash';
6
- import { format as stringFormat } from 'node:util';
7
- import { log } from '../../logger';
6
+ import {format as stringFormat} from 'node:util';
7
+ import {log} from '../../logger';
8
8
 
9
9
  const NSKEYED_ARCHIVE_VERSION = 100_000;
10
10
  // @ts-ignore UID is not exposed to typedefs
@@ -17,7 +17,6 @@ const UNIX2APPLE_TIMESTAMP_SECOND = 978307200;
17
17
  const FORMAT_VERSION = 'formatVersion';
18
18
  const NS_OBJECT = 'NSObject';
19
19
 
20
-
21
20
  class ArchivedObject {
22
21
  /**
23
22
  * Stateful wrapper around Archive for an object being archived.
@@ -121,7 +120,7 @@ class NSError extends BaseArchiveHandler {
121
120
  $class: 'NSError',
122
121
  domain: archive.decode('NSDomain'),
123
122
  userinfo: archive.decode('NSUserInfo'),
124
- code: archive.decode('NSCode')
123
+ code: archive.decode('NSCode'),
125
124
  };
126
125
  }
127
126
  }
@@ -132,7 +131,7 @@ class NSException extends BaseArchiveHandler {
132
131
  $class: 'NSException',
133
132
  reason: archive.decode('NS.reason'),
134
133
  userinfo: archive.decode('userinfo'),
135
- name: archive.decode('NS.name')
134
+ name: archive.decode('NS.name'),
136
135
  };
137
136
  }
138
137
  }
@@ -150,7 +149,11 @@ class NSURL extends BaseArchiveHandler {
150
149
  }
151
150
 
152
151
  decodeArchive(archive) {
153
- return { $class: 'NSURL', base: archive.decode('NS.base'), relative: archive.decode('NS.relative') };
152
+ return {
153
+ $class: 'NSURL',
154
+ base: archive.decode('NS.base'),
155
+ relative: archive.decode('NS.relative'),
156
+ };
154
157
  }
155
158
 
156
159
  encodeArchive(obj, archive) {
@@ -247,7 +250,7 @@ class NSNull extends BaseArchiveHandler {
247
250
  class XCTestConfiguration extends BaseArchiveHandler {
248
251
  static _default = {
249
252
  aggregateStatisticsBeforeCrash: {
250
- XCSuiteRecordsKey: {}
253
+ XCSuiteRecordsKey: {},
251
254
  },
252
255
  automationFrameworkPath: '/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework',
253
256
  baselineFileRelativePath: undefined,
@@ -278,7 +281,7 @@ class XCTestConfiguration extends BaseArchiveHandler {
278
281
  testsToRun: undefined,
279
282
  testsToSkip: undefined,
280
283
  treatMissingBaselinesAsFailures: false,
281
- userAttachmentLifetime: 1
284
+ userAttachmentLifetime: 1,
282
285
  };
283
286
 
284
287
  /**
@@ -298,7 +301,7 @@ class XCTestConfiguration extends BaseArchiveHandler {
298
301
  if (!(data.testBundleURL instanceof NSURL)) {
299
302
  throw new TypeError(
300
303
  // @ts-ignore constructor is always present
301
- `Expected testBundleURL to be a valid NSURL instance, got ${data.testBundleURL.constructor.name} instead`
304
+ `Expected testBundleURL to be a valid NSURL instance, got ${data.testBundleURL.constructor.name} instead`,
302
305
  );
303
306
  }
304
307
  if (typeof data.sessionIdentifier === 'string') {
@@ -307,10 +310,10 @@ class XCTestConfiguration extends BaseArchiveHandler {
307
310
  if (!(data.sessionIdentifier instanceof NSUUID)) {
308
311
  throw new TypeError(
309
312
  // @ts-ignore constructor is always present
310
- `Expected sessionIdentifier to be a valid NSUUID instance, got ${data.sessionIdentifier.constructor.name} instead`
313
+ `Expected sessionIdentifier to be a valid NSUUID instance, got ${data.sessionIdentifier.constructor.name} instead`,
311
314
  );
312
315
  }
313
- this._data = { ...XCTestConfiguration._default, ...data };
316
+ this._data = {...XCTestConfiguration._default, ...data};
314
317
  }
315
318
 
316
319
  getBytes() {
@@ -456,7 +459,7 @@ class Archive {
456
459
  const val = new plistlib.UID(this.objects.length);
457
460
  this.objects.push({
458
461
  $classes: [archiver, ...addition],
459
- $classname: archiver
462
+ $classname: archiver,
460
463
  });
461
464
  return val;
462
465
  }
@@ -530,7 +533,10 @@ class Archive {
530
533
  */
531
534
  encodeXCTestConfiguration(obj, archiveObj) {
532
535
  archiveObj.$class = this.uidForArchiver('XCTestConfiguration', NS_OBJECT);
533
- _.entries(obj._data).forEach(([key, value]) => archiveObj[key] = (key === FORMAT_VERSION) ? this.archive(value) : this.encode(value));
536
+ _.entries(obj._data).forEach(
537
+ ([key, value]) =>
538
+ (archiveObj[key] = key === FORMAT_VERSION ? this.archive(value) : this.encode(value)),
539
+ );
534
540
  }
535
541
 
536
542
  toBytes() {
@@ -541,8 +547,8 @@ class Archive {
541
547
  $version: NSKEYED_ARCHIVE_VERSION,
542
548
  $archiver: NSKEYEDARCHIVER,
543
549
  // @ts-ignore UID is not exposed to typedefs
544
- $top: { root: new plistlib.UID(1) },
545
- $objects: this.objects
550
+ $top: {root: new plistlib.UID(1)},
551
+ $objects: this.objects,
546
552
  };
547
553
  return bplistCreate(d);
548
554
  }
@@ -572,8 +578,12 @@ function unarchive(inputBytes) {
572
578
  * @param {BaseArchiveHandler} subClass inherit from BaseArchiveHandler class
573
579
  */
574
580
  function updateNSKeyedArchiveClass(name, subClass) {
575
- // @ts-ignore prototype always exists
576
- if (!_.isFunction(subClass.prototype?.decodeArchive) && !_.isFunction(subClass.prototype?.encodeArchive)) {
581
+ if (
582
+ // @ts-ignore prototype always exists
583
+ !_.isFunction(subClass.prototype?.decodeArchive) &&
584
+ // @ts-ignore prototype always exists
585
+ !_.isFunction(subClass.prototype?.encodeArchive)
586
+ ) {
577
587
  throw new Error('subClass must have decodeArchive or encodeArchive methods');
578
588
  }
579
589
  if (!(name in UNARCHIVE_CLASS_MAP)) {
@@ -581,4 +591,13 @@ function updateNSKeyedArchiveClass(name, subClass) {
581
591
  }
582
592
  }
583
593
 
584
- export { updateNSKeyedArchiveClass, BaseArchiveHandler, NSURL, NSUUID, NSDate, XCTestConfiguration, unarchive, archive };
594
+ export {
595
+ updateNSKeyedArchiveClass,
596
+ BaseArchiveHandler,
597
+ NSURL,
598
+ NSUUID,
599
+ NSDate,
600
+ XCTestConfiguration,
601
+ unarchive,
602
+ archive,
603
+ };
@@ -1,6 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { BaseServicePlist } from '../base-service';
3
-
2
+ import {BaseServicePlist} from '../base-service';
4
3
 
5
4
  const LOCKDOWN_PORT = 62078;
6
5
  const LABEL = 'usbmuxd';
@@ -12,12 +11,15 @@ class Lockdown extends BaseServicePlist {
12
11
  * @param {number} [timeout=5000] the timeout of receiving a response from lockdownd
13
12
  * @returns {Promise<any>}
14
13
  */
15
- async queryType (timeout = 5000) {
16
- const data = await this._plistService.sendPlistAndReceive({
17
- Label: LABEL,
18
- ProtocolVersion: PROTOCOL_VERSION,
19
- Request: 'QueryType'
20
- }, timeout);
14
+ async queryType(timeout = 5000) {
15
+ const data = await this._plistService.sendPlistAndReceive(
16
+ {
17
+ Label: LABEL,
18
+ ProtocolVersion: PROTOCOL_VERSION,
19
+ Request: 'QueryType',
20
+ },
21
+ timeout,
22
+ );
21
23
  if (data.Request === 'QueryType' && data.Type === 'com.apple.mobile.lockdown') {
22
24
  return data;
23
25
  } else {
@@ -32,17 +34,20 @@ class Lockdown extends BaseServicePlist {
32
34
  * @param {number} [timeout=5000] the timeout of receiving a response from lockdownd
33
35
  * @returns {Promise<any>}
34
36
  */
35
- async startSession (hostID, systemBUID, timeout = 5000) {
36
- const data = await this._plistService.sendPlistAndReceive({
37
- Label: LABEL,
38
- ProtocolVersion: PROTOCOL_VERSION,
39
- Request: 'StartSession',
40
- HostID: hostID,
41
- SystemBUID: systemBUID
42
- }, timeout);
37
+ async startSession(hostID, systemBUID, timeout = 5000) {
38
+ const data = await this._plistService.sendPlistAndReceive(
39
+ {
40
+ Label: LABEL,
41
+ ProtocolVersion: PROTOCOL_VERSION,
42
+ Request: 'StartSession',
43
+ HostID: hostID,
44
+ SystemBUID: systemBUID,
45
+ },
46
+ timeout,
47
+ );
43
48
 
44
49
  if (data.Request === 'StartSession' && data.SessionID) {
45
- return { sessionID: data.SessionID, enableSessionSSL: data.EnableSessionSSL };
50
+ return {sessionID: data.SessionID, enableSessionSSL: data.EnableSessionSSL};
46
51
  } else {
47
52
  throw new Error(`Unexpected data: ${JSON.stringify(data)}`);
48
53
  }
@@ -53,16 +58,16 @@ class Lockdown extends BaseServicePlist {
53
58
  * @param {Buffer} hostPrivateKey the private key which can be retrieved from the pair record
54
59
  * @param {Buffer} hostCertificate the certificate which can be retrieved from the pair record
55
60
  */
56
- enableSessionSSL (hostPrivateKey, hostCertificate) {
61
+ enableSessionSSL(hostPrivateKey, hostCertificate) {
57
62
  this._plistService.enableSessionSSL(hostPrivateKey, hostCertificate);
58
63
  }
59
64
 
60
65
  /**
61
- * @typedef {Object} Query
62
- *
63
- * @property {string} Key The key we want to access
64
- * @property {string} Domain The domain where we want to access
65
- */
66
+ * @typedef {Object} Query
67
+ *
68
+ * @property {string} Key The key we want to access
69
+ * @property {string} Domain The domain where we want to access
70
+ */
66
71
 
67
72
  /**
68
73
  * Gets values from the device according to the query passed
@@ -72,19 +77,20 @@ class Lockdown extends BaseServicePlist {
72
77
  * @returns {Promise<any>} The actual response value. It should never be `null` or `undefined`
73
78
  * @throws {Error} If an unexpected response is received from lockdownd
74
79
  */
75
- async getValue (query = {}, timeout = 5000) {
80
+ async getValue(query = {}, timeout = 5000) {
76
81
  const plist = {
77
82
  Label: LABEL,
78
83
  ProtocolVersion: PROTOCOL_VERSION,
79
84
  Request: 'GetValue',
80
- ...query
85
+ ...query,
81
86
  };
82
87
  const data = await this._plistService.sendPlistAndReceive(plist, timeout);
83
88
  if (data?.Request === 'GetValue' && !_.isNil(data?.Value)) {
84
89
  return data.Value;
85
90
  }
86
- throw new Error(`Unexpected data received for ${JSON.stringify(query)} request: ` +
87
- JSON.stringify(data));
91
+ throw new Error(
92
+ `Unexpected data received for ${JSON.stringify(query)} request: ` + JSON.stringify(data),
93
+ );
88
94
  }
89
95
 
90
96
  /**
@@ -93,13 +99,16 @@ class Lockdown extends BaseServicePlist {
93
99
  * @param {number} [timeout=5000] the timeout of receiving a response from lockdownd
94
100
  * @returns {Promise<any>}
95
101
  */
96
- async startService (serviceName, timeout = 5000) {
97
- const data = await this._plistService.sendPlistAndReceive({
98
- Label: LABEL,
99
- ProtocolVersion: PROTOCOL_VERSION,
100
- Request: 'StartService',
101
- Service: serviceName,
102
- }, timeout);
102
+ async startService(serviceName, timeout = 5000) {
103
+ const data = await this._plistService.sendPlistAndReceive(
104
+ {
105
+ Label: LABEL,
106
+ ProtocolVersion: PROTOCOL_VERSION,
107
+ Request: 'StartService',
108
+ Service: serviceName,
109
+ },
110
+ timeout,
111
+ );
103
112
 
104
113
  if (data.Error) {
105
114
  throw new Error(`Unexpected data: ${JSON.stringify(data)}`);
@@ -109,5 +118,5 @@ class Lockdown extends BaseServicePlist {
109
118
  }
110
119
  }
111
120
 
112
- export { Lockdown, LOCKDOWN_PORT };
121
+ export {Lockdown, LOCKDOWN_PORT};
113
122
  export default Lockdown;
package/lib/logger.js CHANGED
@@ -1,3 +1,3 @@
1
- import { logger } from '@appium/support';
1
+ import {logger} from '@appium/support';
2
2
 
3
3
  export const log = logger.getLogger('ios-device');
@@ -1,11 +1,10 @@
1
1
  import {BaseServicePlist} from '../base-service';
2
2
  import {fs, plist} from '@appium/support';
3
3
 
4
-
5
4
  const MC_INSTALL_SERVICE_NAME = 'com.apple.mobile.MCInstall';
6
5
  const ACKNOWLEDGED = 'Acknowledged';
7
6
 
8
- function checkACK (res, name) {
7
+ function checkACK(res, name) {
9
8
  if (res.Status !== ACKNOWLEDGED) {
10
9
  throw new Error(`${name} error: ${JSON.stringify(res)}`);
11
10
  }
@@ -13,7 +12,7 @@ function checkACK (res, name) {
13
12
  }
14
13
 
15
14
  class MCInstallProxyService extends BaseServicePlist {
16
- constructor (socketClient) {
15
+ constructor(socketClient) {
17
16
  super(socketClient);
18
17
  }
19
18
 
@@ -48,7 +47,7 @@ class MCInstallProxyService extends BaseServicePlist {
48
47
  * Status: 'Acknowledged'
49
48
  * }
50
49
  */
51
- async getProfileList () {
50
+ async getProfileList() {
52
51
  const res = await this._plistService.sendPlistAndReceive({RequestType: 'GetProfileList'});
53
52
  return checkACK(res, 'getProfileList');
54
53
  }
@@ -59,9 +58,12 @@ class MCInstallProxyService extends BaseServicePlist {
59
58
  * e.g: /Downloads/charles-certificate.pem
60
59
  * @returns {Promise<Record<any, any>>} e.g. {Status: 'Acknowledged'}
61
60
  */
62
- async installProfile (path) {
61
+ async installProfile(path) {
63
62
  const payload = await fs.readFile(path);
64
- const res = await this._plistService.sendPlistAndReceive({'RequestType': 'InstallProfile', 'Payload': payload});
63
+ const res = await this._plistService.sendPlistAndReceive({
64
+ RequestType: 'InstallProfile',
65
+ Payload: payload,
66
+ });
65
67
  return checkACK(res, 'installProfile');
66
68
  }
67
69
 
@@ -70,20 +72,25 @@ class MCInstallProxyService extends BaseServicePlist {
70
72
  * @param {String} ident Query identifier list through getProfileList method
71
73
  * @returns {Promise<Record<any, any>>} e.g. {Status: 'Acknowledged'}
72
74
  */
73
- async removeProfile (ident) {
75
+ async removeProfile(ident) {
74
76
  const profiles = await this.getProfileList();
75
77
  const meta = profiles.ProfileMetadata[ident];
76
78
  if (!meta) {
77
79
  throw new Error(`not find installed profile ident:${ident}`);
78
80
  }
79
- const data = plist.createBinaryPlist({'PayloadType': 'Configuration',
80
- 'PayloadIdentifier': ident,
81
- 'PayloadUUID': meta.PayloadUUID,
82
- 'PayloadVersion': meta.PayloadVersion});
83
- const res = await this._plistService.sendPlistAndReceive({'RequestType': 'RemoveProfile', 'ProfileIdentifier': data});
81
+ const data = plist.createBinaryPlist({
82
+ PayloadType: 'Configuration',
83
+ PayloadIdentifier: ident,
84
+ PayloadUUID: meta.PayloadUUID,
85
+ PayloadVersion: meta.PayloadVersion,
86
+ });
87
+ const res = await this._plistService.sendPlistAndReceive({
88
+ RequestType: 'RemoveProfile',
89
+ ProfileIdentifier: data,
90
+ });
84
91
  return checkACK(res, 'removeProfile');
85
92
  }
86
93
  }
87
94
 
88
- export { MCInstallProxyService, MC_INSTALL_SERVICE_NAME };
95
+ export {MCInstallProxyService, MC_INSTALL_SERVICE_NAME};
89
96
  export default MCInstallProxyService;
@@ -1,11 +1,10 @@
1
- import { PlistServiceEncoder } from '../plist-service/transformer/plist-service-encoder';
2
- import { PlistServiceDecoder } from '../plist-service/transformer/plist-service-decoder';
3
- import { LengthBasedSplitter } from '../util/transformer/length-based-splitter';
4
- import { KB } from '../constants';
1
+ import {PlistServiceEncoder} from '../plist-service/transformer/plist-service-encoder';
2
+ import {PlistServiceDecoder} from '../plist-service/transformer/plist-service-decoder';
3
+ import {LengthBasedSplitter} from '../util/transformer/length-based-splitter';
4
+ import {KB} from '../constants';
5
5
  import _ from 'lodash';
6
- import { BaseServiceSocket } from '../base-service';
7
- import { getMaxFrameLength } from '../utilities';
8
-
6
+ import {BaseServiceSocket} from '../base-service';
7
+ import {getMaxFrameLength} from '../utilities';
9
8
 
10
9
  const NOTIFICATION_PROXY_SERVICE_NAME = 'com.apple.mobile.notification_proxy';
11
10
  const MAX_FRAME_SIZE = 16 * KB;
@@ -14,7 +13,7 @@ const RELAY_NOTIFICATION = 'RelayNotification';
14
13
  const PROXY_DEATH = 'ProxyDeath';
15
14
 
16
15
  class NotificationProxyService extends BaseServiceSocket {
17
- constructor (socketClient) {
16
+ constructor(socketClient) {
18
17
  super(socketClient);
19
18
 
20
19
  this._decoder = new PlistServiceDecoder();
@@ -36,7 +35,7 @@ class NotificationProxyService extends BaseServiceSocket {
36
35
  this._decoder.on('data', this._handleData.bind(this));
37
36
  }
38
37
 
39
- _handleData (data) {
38
+ _handleData(data) {
40
39
  switch (data.Command) {
41
40
  case RELAY_NOTIFICATION: {
42
41
  const listener = this._listeners[data.Name];
@@ -69,14 +68,16 @@ class NotificationProxyService extends BaseServiceSocket {
69
68
  * @param {string} notification The name of the notification which is desired to be observed
70
69
  * @param {Object} listener The listener object which will be invoked when there is a notification or if the proxy is dead
71
70
  */
72
- observeNotification (notification, listener) {
71
+ observeNotification(notification, listener) {
73
72
  if (this._listeners[notification]) {
74
- throw new Error(`Notification listener for ${notification} already exists. Another one can't be added`);
73
+ throw new Error(
74
+ `Notification listener for ${notification} already exists. Another one can't be added`,
75
+ );
75
76
  }
76
77
  this._listeners[notification] = listener;
77
78
  this._encoder.write({
78
79
  Command: 'ObserveNotification',
79
- Name: notification
80
+ Name: notification,
80
81
  });
81
82
  }
82
83
 
@@ -84,27 +85,27 @@ class NotificationProxyService extends BaseServiceSocket {
84
85
  * The api to broadcast notifications to the phone. This allows the client to talk to the daemons or apps on the phone
85
86
  * @param {*} notification The name of the notification which is desired notified
86
87
  */
87
- postNotification (notification) {
88
+ postNotification(notification) {
88
89
  this._encoder.write({
89
90
  Command: 'PostNotification',
90
- Name: notification
91
+ Name: notification,
91
92
  });
92
93
  }
93
94
 
94
95
  /**
95
96
  * The api to shutdown the proxy. Consequently, all the notifications that are observing will receive the proxyDeath response
96
97
  */
97
- shutdown () {
98
+ shutdown() {
98
99
  this._encoder.write({
99
100
  Command: 'Shutdown',
100
101
  });
101
102
  }
102
103
 
103
- close () {
104
+ close() {
104
105
  this.shutdown();
105
106
  super.close();
106
107
  }
107
108
  }
108
109
 
109
110
  export default NotificationProxyService;
110
- export { NotificationProxyService, NOTIFICATION_PROXY_SERVICE_NAME };
111
+ export {NotificationProxyService, NOTIFICATION_PROXY_SERVICE_NAME};
@@ -1,19 +1,18 @@
1
1
  import B from 'bluebird';
2
- import { upgradeToSSL } from '../ssl-helper';
3
- import { PlistServiceEncoder } from './transformer/plist-service-encoder';
4
- import { PlistServiceDecoder } from './transformer/plist-service-decoder';
5
- import { LengthBasedSplitter } from '../util/transformer/length-based-splitter';
6
- import { BaseServiceSocket } from '../base-service';
7
- import { getMaxFrameLength } from '../utilities';
8
- import { MB } from '../constants';
9
-
2
+ import {upgradeToSSL} from '../ssl-helper';
3
+ import {PlistServiceEncoder} from './transformer/plist-service-encoder';
4
+ import {PlistServiceDecoder} from './transformer/plist-service-decoder';
5
+ import {LengthBasedSplitter} from '../util/transformer/length-based-splitter';
6
+ import {BaseServiceSocket} from '../base-service';
7
+ import {getMaxFrameLength} from '../utilities';
8
+ import {MB} from '../constants';
10
9
 
11
10
  const MAX_FRAME_SIZE = 1 * MB;
12
11
 
13
12
  const CHECK_FREQ_MS = 50;
14
13
 
15
14
  class PlistService extends BaseServiceSocket {
16
- constructor (socketClient) {
15
+ constructor(socketClient) {
17
16
  super(socketClient);
18
17
 
19
18
  this._decoder = new PlistServiceDecoder();
@@ -35,19 +34,19 @@ class PlistService extends BaseServiceSocket {
35
34
  this._decoder.on('data', (data) => this.replyQueue.push(data));
36
35
  }
37
36
 
38
- async sendPlistAndReceive (json, timeout = 5000) {
37
+ async sendPlistAndReceive(json, timeout = 5000) {
39
38
  this.sendPlist(json);
40
39
  return await this.receivePlist(timeout);
41
40
  }
42
41
 
43
- sendPlist (json) {
42
+ sendPlist(json) {
44
43
  if (!json) {
45
44
  throw new Error('Cant send a null a object');
46
45
  }
47
46
  this._encoder.write(json);
48
47
  }
49
48
 
50
- async receivePlist (timeout = 5000) {
49
+ async receivePlist(timeout = 5000) {
51
50
  return await new B((resolve, reject) => {
52
51
  const queue = this.replyQueue;
53
52
  const data = queue.shift();
@@ -70,7 +69,7 @@ class PlistService extends BaseServiceSocket {
70
69
  });
71
70
  }
72
71
 
73
- enableSessionSSL (hostPrivateKey, hostCertificate) {
72
+ enableSessionSSL(hostPrivateKey, hostCertificate) {
74
73
  this._socketClient.unpipe(this._splitter);
75
74
  this._encoder.unpipe(this._socketClient);
76
75
  this._socketClient = upgradeToSSL(this._socketClient, hostPrivateKey, hostCertificate);
@@ -79,5 +78,5 @@ class PlistService extends BaseServiceSocket {
79
78
  }
80
79
  }
81
80
 
82
- export { PlistService };
81
+ export {PlistService};
83
82
  export default PlistService;
@@ -1,21 +1,20 @@
1
1
  import _ from 'lodash';
2
2
  import Stream from 'node:stream';
3
- import { plist } from '@appium/support';
3
+ import {plist} from '@appium/support';
4
4
 
5
5
  const HEADER_LENGTH = 4;
6
6
 
7
7
  class PlistServiceDecoder extends Stream.Transform {
8
-
9
- constructor () {
10
- super({ objectMode: true });
8
+ constructor() {
9
+ super({objectMode: true});
11
10
  }
12
11
 
13
- _transform (data, encoding, onData) {
12
+ _transform(data, encoding, onData) {
14
13
  this._decode(data);
15
14
  onData();
16
15
  }
17
16
 
18
- _decode (data) {
17
+ _decode(data) {
19
18
  const payload = data.slice(HEADER_LENGTH, data.length);
20
19
  if (_.isEmpty(payload)) {
21
20
  return;
@@ -28,5 +27,5 @@ class PlistServiceDecoder extends Stream.Transform {
28
27
  }
29
28
  }
30
29
 
31
- export { PlistServiceDecoder };
30
+ export {PlistServiceDecoder};
32
31
  export default PlistServiceDecoder;
@@ -1,20 +1,19 @@
1
1
  import Stream from 'node:stream';
2
- import { plist } from '@appium/support';
3
-
2
+ import {plist} from '@appium/support';
4
3
 
5
4
  const HEADER_LENGTH = 4;
6
5
 
7
6
  class PlistServiceEncoder extends Stream.Transform {
8
- constructor () {
9
- super({ objectMode: true });
7
+ constructor() {
8
+ super({objectMode: true});
10
9
  }
11
10
 
12
- _transform (data, encoding, onData) {
11
+ _transform(data, encoding, onData) {
13
12
  this.push(this._encode(data), 'binary');
14
13
  onData();
15
14
  }
16
15
 
17
- _encode (data) {
16
+ _encode(data) {
18
17
  const payloadBuffer = plist.createBinaryPlist(data);
19
18
  const headerBuffer = Buffer.alloc(HEADER_LENGTH);
20
19
  headerBuffer.writeUInt32BE(payloadBuffer.length, 0);
@@ -22,5 +21,5 @@ class PlistServiceEncoder extends Stream.Transform {
22
21
  }
23
22
  }
24
23
 
25
- export { PlistServiceEncoder };
24
+ export {PlistServiceEncoder};
26
25
  export default PlistServiceEncoder;