appium 3.0.0-beta.1 → 3.0.0-rc.1

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 (47) hide show
  1. package/build/lib/appium.d.ts +9 -5
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +12 -25
  4. package/build/lib/appium.js.map +1 -1
  5. package/build/lib/cli/driver-command.js +1 -1
  6. package/build/lib/cli/driver-command.js.map +1 -1
  7. package/build/lib/cli/extension-command.js +1 -1
  8. package/build/lib/cli/extension-command.js.map +1 -1
  9. package/build/lib/cli/parser.js +1 -1
  10. package/build/lib/cli/plugin-command.js +1 -1
  11. package/build/lib/cli/plugin-command.js.map +1 -1
  12. package/build/lib/constants.d.ts +4 -0
  13. package/build/lib/constants.d.ts.map +1 -1
  14. package/build/lib/constants.js +5 -1
  15. package/build/lib/constants.js.map +1 -1
  16. package/build/lib/extension/extension-config.js +1 -1
  17. package/build/lib/extension/extension-config.js.map +1 -1
  18. package/build/lib/insecure-features.d.ts +18 -0
  19. package/build/lib/insecure-features.d.ts.map +1 -0
  20. package/build/lib/insecure-features.js +116 -0
  21. package/build/lib/insecure-features.js.map +1 -0
  22. package/build/lib/main.d.ts +1 -1
  23. package/build/lib/main.d.ts.map +1 -1
  24. package/build/lib/main.js +3 -1
  25. package/build/lib/main.js.map +1 -1
  26. package/build/lib/schema/cli-args.d.ts +1 -1
  27. package/build/lib/schema/cli-args.js +1 -1
  28. package/build/lib/schema/cli-args.js.map +1 -1
  29. package/build/lib/schema/schema.d.ts +1 -1
  30. package/build/lib/schema/schema.js +1 -1
  31. package/build/lib/utils.d.ts +1 -8
  32. package/build/lib/utils.d.ts.map +1 -1
  33. package/build/lib/utils.js +1 -30
  34. package/build/lib/utils.js.map +1 -1
  35. package/lib/appium.js +15 -37
  36. package/lib/cli/driver-command.js +1 -1
  37. package/lib/cli/extension-command.js +1 -1
  38. package/lib/cli/parser.js +1 -1
  39. package/lib/cli/plugin-command.js +1 -1
  40. package/lib/constants.js +5 -0
  41. package/lib/extension/extension-config.js +1 -1
  42. package/lib/insecure-features.ts +129 -0
  43. package/lib/main.js +4 -1
  44. package/lib/schema/cli-args.js +2 -2
  45. package/lib/schema/schema.js +1 -1
  46. package/lib/utils.js +1 -31
  47. package/package.json +9 -9
@@ -0,0 +1,129 @@
1
+ import _ from 'lodash';
2
+ import logger from './logger';
3
+
4
+ import type {AppiumDriver} from './appium';
5
+ import type {ExternalDriver} from '@appium/types';
6
+
7
+ const ALL_DRIVERS_MATCH = '*';
8
+ const FEATURE_NAME_SEPARATOR = ':';
9
+
10
+ /**
11
+ * Configures insecure features according to the values in `args.relaxedSecurityEnabled`,
12
+ * `args.allowInsecure`, and `args.denyInsecure`, and informs the user about any
13
+ * globally-applied features.
14
+ * Uses `logger` instead of `this.log` to reduce user confusion.
15
+ */
16
+ export function configureGlobalFeatures(this: AppiumDriver) {
17
+ if (this.args.relaxedSecurityEnabled) {
18
+ logger.info(
19
+ `Enabling relaxed security. All insecure features will be ` +
20
+ `enabled unless explicitly disabled by --deny-insecure`,
21
+ );
22
+ this.relaxedSecurityEnabled = true;
23
+ } else if (!_.isEmpty(this.args.allowInsecure)) {
24
+ this.allowInsecure = validateFeatures(this.args.allowInsecure);
25
+ const globalAllowedFeatures = filterInsecureFeatures(this.allowInsecure);
26
+ if (!_.isEmpty(globalAllowedFeatures)) {
27
+ logger.info('Explicitly enabling insecure features:');
28
+ globalAllowedFeatures.forEach((a) => logger.info(` ${a}`));
29
+ }
30
+ }
31
+ if (_.isEmpty(this.args.denyInsecure)) {
32
+ return;
33
+ }
34
+ this.denyInsecure = validateFeatures(this.args.denyInsecure);
35
+ const globalDeniedFeatures = filterInsecureFeatures(this.denyInsecure);
36
+ if (_.isEmpty(globalDeniedFeatures)) {
37
+ return;
38
+ }
39
+ logger.info('Explicitly disabling insecure features:');
40
+ globalDeniedFeatures.forEach((a) => logger.info(` ${a}`));
41
+ }
42
+
43
+ /**
44
+ * If anything in the umbrella driver's insecure feature configuration applies to this driver,
45
+ * assign it to the driver instance
46
+ *
47
+ * @param driver
48
+ * @param driverName
49
+ */
50
+ export function configureDriverFeatures(
51
+ this: AppiumDriver,
52
+ driver: ExternalDriver,
53
+ driverName: string,
54
+ ) {
55
+ if (this.relaxedSecurityEnabled) {
56
+ this.log.info(
57
+ `Enabling relaxed security for this session as per the server configuration. ` +
58
+ `All insecure features will be enabled unless explicitly disabled by --deny-insecure`,
59
+ );
60
+ driver.relaxedSecurityEnabled = true;
61
+ }
62
+ const allowedDriverFeatures = filterInsecureFeatures(this.allowInsecure, driverName);
63
+ if (!_.isEmpty(allowedDriverFeatures)) {
64
+ this.log.info('Explicitly enabling insecure features for this session ' +
65
+ 'as per the server configuration:',
66
+ );
67
+ allowedDriverFeatures.forEach((a) => this.log.info(` ${a}`));
68
+ driver.allowInsecure = allowedDriverFeatures;
69
+ }
70
+ const deniedDriverFeatures = filterInsecureFeatures(this.denyInsecure, driverName);
71
+ if (_.isEmpty(deniedDriverFeatures)) {
72
+ return;
73
+ }
74
+ this.log.info('Explicitly disabling insecure features for this session ' +
75
+ 'as per the server configuration:',
76
+ );
77
+ deniedDriverFeatures.forEach((a) => this.log.info(` ${a}`));
78
+ driver.denyInsecure = deniedDriverFeatures;
79
+ }
80
+
81
+ /**
82
+ * Validates the list of allowed/denied server features
83
+ *
84
+ * @param features
85
+ */
86
+ function validateFeatures(features: string[]): string[] {
87
+ const validator = (fullName: string) => {
88
+ const errMsg = `The full feature name must include both the destination automation name or the ` +
89
+ `'${ALL_DRIVERS_MATCH}' wildcard to apply the feature to all installed drivers, and ` +
90
+ `the feature name split by a colon. Got '${fullName}' instead`;
91
+
92
+ const separatorPos = fullName.indexOf(FEATURE_NAME_SEPARATOR);
93
+ if (separatorPos < 0) {
94
+ throw new Error(errMsg);
95
+ }
96
+ const [automationName, featureName] = [
97
+ fullName.substring(0, separatorPos),
98
+ fullName.substring(separatorPos + 1)
99
+ ];
100
+ if (!automationName || !featureName) {
101
+ throw new Error(errMsg);
102
+ }
103
+ return fullName;
104
+ };
105
+ return features.map(validator);
106
+ }
107
+
108
+ /**
109
+ * Filters the list of insecure features to only those that are
110
+ * applicable to the given driver name.
111
+ * Assumes that all feature names have already been validated
112
+ *
113
+ * @param features
114
+ * @param driverName
115
+ */
116
+ function filterInsecureFeatures(
117
+ features: string[],
118
+ driverName: string = ALL_DRIVERS_MATCH
119
+ ): string[] {
120
+ const filterFn = (fullName: string) => {
121
+ const separatorPos = fullName.indexOf(FEATURE_NAME_SEPARATOR);
122
+ if (separatorPos <= 0) {
123
+ return false;
124
+ }
125
+ const automationName = fullName.substring(0, separatorPos);
126
+ return [driverName, ALL_DRIVERS_MATCH].includes(automationName);
127
+ };
128
+ return features.filter(filterFn);
129
+ }
package/lib/main.js CHANGED
@@ -177,7 +177,7 @@ function determineAppiumHomeSource(appiumHomeFromArgs) {
177
177
  *
178
178
  * @template {CliCommand} [Cmd=ServerCommand]
179
179
  * @template {CliExtensionSubcommand|void} [SubCmd=void]
180
- * @param {Args<Cmd, SubCmd>} [args] - Partial args (progammatic usage only)
180
+ * @param {Args<Cmd, SubCmd>} [args] - Partial args (programmatic usage only)
181
181
  * @returns {Promise<InitResult<Cmd>>}
182
182
  * @example
183
183
  * import {init, getSchema} from 'appium';
@@ -375,6 +375,9 @@ async function main(args) {
375
375
 
376
376
  await logStartupInfo(parsedArgs);
377
377
 
378
+ // handle the insecure feature configuration since some features may apply globally
379
+ appiumDriver.configureGlobalFeatures();
380
+
378
381
  const appiumHomeSourceName = determineAppiumHomeSource(args?.appiumHome);
379
382
  logger.debug(`The ${appiumHomeSourceName}: ${appiumHome}`);
380
383
 
@@ -1,6 +1,6 @@
1
1
  import {ArgumentTypeError} from 'argparse';
2
2
  import _ from 'lodash';
3
- import {formatErrors as formatErrors} from '../config-file';
3
+ import {formatErrors} from '../config-file';
4
4
  import {flattenSchema, validate} from './schema';
5
5
  import {transformers, parseCsvLine} from './cli-transformers';
6
6
 
@@ -225,7 +225,7 @@ function subSchemaToArgDef(subSchema, argSpec) {
225
225
  * ArgumentDefinitions for handoff to `argparse`.
226
226
  *
227
227
  * @throws If schema has not been added to ajv (via `finalizeSchema()`)
228
- * @returns {import('../cli/args').ArgumentDefinitions} A map of arryas of
228
+ * @returns {import('../cli/args').ArgumentDefinitions} A map of arrays of
229
229
  * aliases to `argparse` arguments; empty if no schema found
230
230
  */
231
231
  export function toParserArgs() {
@@ -421,7 +421,7 @@ class AppiumSchema {
421
421
  * name. Used when translating to `argparse` options or getting the list of
422
422
  * default values (see {@link AppiumSchema.getDefaults}) for CLI or otherwise.
423
423
  *
424
- * The return value is an intermediate reprsentation used by `cli-args`
424
+ * The return value is an intermediate representation used by `cli-args`
425
425
  * module's `toParserArgs`, which converts the finalized schema to parameters
426
426
  * used by `argparse`.
427
427
  * @throws If {@link AppiumSchema.finalize} has not been called yet.
package/lib/utils.js CHANGED
@@ -17,8 +17,6 @@ const STANDARD_CAPS_LOWERCASE = new Set([...STANDARD_CAPS].map((cap) => cap.toLo
17
17
  export const V4_BROADCAST_IP = '0.0.0.0';
18
18
  export const V6_BROADCAST_IP = '::';
19
19
  export const npmPackage = fs.readPackageJsonFrom(__dirname);
20
- const ALL_DRIVERS_MATCH = '*';
21
- const FEATURE_NAME_SEPARATOR = ':';
22
20
 
23
21
  /**
24
22
  *
@@ -346,7 +344,7 @@ export function isPluginCommandArgs(args) {
346
344
  *
347
345
  * @param {4|6|null} family Either 4 to include ipv4 addresses only,
348
346
  * 6 to include ipv6 addresses only, or null to include all of them
349
- * @returns {os.NetworkInterfaceInfo[]} The list of matched interfcaes
347
+ * @returns {os.NetworkInterfaceInfo[]} The list of matched interfaces
350
348
  */
351
349
  export function fetchInterfaces (family = null) {
352
350
  let familyValue = null;
@@ -427,34 +425,6 @@ export function isBroadcastIp(address) {
427
425
  return [V4_BROADCAST_IP, V6_BROADCAST_IP, `[${V6_BROADCAST_IP}]`].includes(address);
428
426
  }
429
427
 
430
- /**
431
- * Validates the list of allowed/denied server features
432
- *
433
- * @param {string[]} features
434
- * @returns {string[]}
435
- */
436
- export function validateFeatures(features) {
437
- const validator = (/** @type {string} */ fullName) => {
438
- const errMsg = `The full feature name must include both the destination automation name or the ` +
439
- `'${ALL_DRIVERS_MATCH}' wildcard to apply the feature to all installed drivers, and ` +
440
- `the feature name split by a colon. Got '${fullName}' instead`;
441
-
442
- const separatorPos = fullName.indexOf(FEATURE_NAME_SEPARATOR);
443
- if (separatorPos < 0) {
444
- throw new Error(errMsg);
445
- }
446
- const [automationName, featureName] = [
447
- fullName.substring(0, separatorPos),
448
- fullName.substring(separatorPos + 1)
449
- ];
450
- if (!automationName || !featureName) {
451
- throw new Error(errMsg);
452
- }
453
- return fullName;
454
- };
455
- return features.map(validator);
456
- }
457
-
458
428
  /**
459
429
  * @typedef {import('@appium/types').StringRecord} StringRecord
460
430
  * @typedef {import('@appium/types').BaseDriverCapConstraints} BaseDriverCapConstraints
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-rc.1",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -66,7 +66,7 @@
66
66
  "@appium/logger": "^1.7.0",
67
67
  "@appium/schema": "^0.8.1",
68
68
  "@appium/support": "^6.1.0",
69
- "@appium/types": "^0.25.3",
69
+ "@appium/types": "^0.26.0",
70
70
  "@sidvind/better-ajv-errors": "3.0.1",
71
71
  "ajv": "8.17.1",
72
72
  "ajv-formats": "3.0.1",
@@ -81,22 +81,22 @@
81
81
  "ora": "5.4.1",
82
82
  "package-changed": "3.0.0",
83
83
  "resolve-from": "5.0.0",
84
- "semver": "7.7.1",
84
+ "semver": "7.7.2",
85
85
  "source-map-support": "0.5.21",
86
- "teen_process": "2.3.1",
87
- "type-fest": "4.40.0",
86
+ "teen_process": "2.3.2",
87
+ "type-fest": "4.41.0",
88
88
  "winston": "3.17.0",
89
89
  "wrap-ansi": "7.0.0",
90
- "ws": "8.18.1",
91
- "yaml": "2.7.1"
90
+ "ws": "8.18.2",
91
+ "yaml": "2.8.0"
92
92
  },
93
93
  "engines": {
94
- "node": "^20.9.0 || >=22.11.0",
94
+ "node": "^20.19.0 || >=22.12.0",
95
95
  "npm": ">=10"
96
96
  },
97
97
  "publishConfig": {
98
98
  "access": "public",
99
99
  "tag": "beta"
100
100
  },
101
- "gitHead": "dc5ef8d5f62c8a0775131305107a4037cd9ec9c9"
101
+ "gitHead": "92680d9b4a95da18a812187773240a51b52f5f29"
102
102
  }