extension-install 4.4.0 → 4.4.1-canary.477.f420b16

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.
@@ -54,6 +54,7 @@ export interface RunCommandOptions {
54
54
  }
55
55
  export declare function runCommand(command: string, args: string[], opts: RunCommandOptions): Promise<CommandResult>;
56
56
  export declare function edgeInstallNeedsInteractivePrivilegedSession(platform?: NodeJS.Platform, stdinIsTTY?: boolean): boolean;
57
+ export declare function sudoNeedsNoPassword(): boolean;
57
58
  export declare function isEdgePrivilegeEscalationFailure(output: string): boolean;
58
59
  export interface SystemEdgeLookup {
59
60
  platform?: NodeJS.Platform;
package/dist/module.cjs CHANGED
@@ -1134,6 +1134,19 @@ async function runCommand(command, args, opts) {
1134
1134
  function runner_edgeInstallNeedsInteractivePrivilegedSession(platform = process.platform, stdinIsTTY) {
1135
1135
  return 'linux' === platform && !(stdinIsTTY ?? process.stdin?.isTTY);
1136
1136
  }
1137
+ function sudoNeedsNoPassword() {
1138
+ try {
1139
+ return 0 === (0, external_node_child_process_namespaceObject.spawnSync)('sudo', [
1140
+ '-n',
1141
+ 'true'
1142
+ ], {
1143
+ stdio: 'ignore',
1144
+ timeout: 5000
1145
+ }).status;
1146
+ } catch {
1147
+ return false;
1148
+ }
1149
+ }
1137
1150
  const ESCALATION_FAILURES = [
1138
1151
  /^\s*sudo:\s+a password is required/im,
1139
1152
  /^\s*sudo:\s+a terminal is required/im,
@@ -1384,7 +1397,7 @@ async function installUnderLock({ defaulted, locateInstalledBinary, runInstaller
1384
1397
  throw withRemovalFailure((message)=>new BrowserInstallFailedError(message), installIncomplete(target, destination, discard.removed), destination, discard);
1385
1398
  }
1386
1399
  async function extensionInstall(options) {
1387
- const { browser, env, platform, cwd, stdinIsTTY, isRoot = process.getuid?.() === 0, systemEdge, lock: lockSeams = {} } = options;
1400
+ const { browser, env, platform, cwd, stdinIsTTY, isRoot = process.getuid?.() === 0, sudoNeedsNoPassword: sudoIsFree = sudoNeedsNoPassword, systemEdge, lock: lockSeams = {} } = options;
1388
1401
  const target = normalizeBrowserName(browser);
1389
1402
  const cacheRoot = resolveBrowsersCacheRoot(env, platform, cwd);
1390
1403
  const destination = resolveBrowserInstallDir(target, cacheRoot);
@@ -1396,7 +1409,7 @@ async function extensionInstall(options) {
1396
1409
  if ('edge' === target && runner_edgeInstallNeedsInteractivePrivilegedSession(platform, stdinIsTTY)) {
1397
1410
  const present = locateSystemEdge(edgeLookup);
1398
1411
  if (present) return void humanLine(edgeAlreadyInstalled(present.path, present.launcherFinds));
1399
- if (!isRoot) throw new BrowserInstallPrivilegeError(edgeInstallNeedsInteractivePrivilegedSession());
1412
+ if (!isRoot && !sudoIsFree()) throw new BrowserInstallPrivilegeError(edgeInstallNeedsInteractivePrivilegedSession());
1400
1413
  }
1401
1414
  const plan = planOnUsableCacheRoot(target, destination, cacheRoot, {
1402
1415
  env,
package/dist/module.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface InstallOptions extends InstallPlanOptions {
11
11
  runInstaller?: typeof runCommand;
12
12
  stdinIsTTY?: boolean;
13
13
  isRoot?: boolean;
14
+ sudoNeedsNoPassword?: () => boolean;
14
15
  systemEdge?: SystemEdgeLookup;
15
16
  removeTree?: (dir: string) => void;
16
17
  lock?: LockSeams;
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "name": "extension-install",
25
- "version": "4.4.0",
25
+ "version": "4.4.1-canary.477.f420b16",
26
26
  "description": "Managed browser installer/uninstaller for Extension.js",
27
27
  "author": {
28
28
  "name": "Cezar Augusto",