socket 0.14.28 → 0.14.30

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 (53) hide show
  1. package/bin/cli.js +7 -0
  2. package/bin/npm-cli.js +7 -0
  3. package/bin/npx-cli.js +7 -0
  4. package/bin/shadow/module-sync/npm +3 -0
  5. package/bin/shadow/module-sync/npx +3 -0
  6. package/bin/shadow/require/npm +3 -0
  7. package/bin/shadow/require/npx +3 -0
  8. package/dist/module-sync/cli.d.ts.map +1 -0
  9. package/dist/module-sync/cli.js +5258 -0
  10. package/dist/module-sync/constants.d.ts +20 -0
  11. package/dist/module-sync/constants.js +72 -0
  12. package/dist/module-sync/npm-cli.js +85 -0
  13. package/dist/module-sync/npm-injection.js +1611 -0
  14. package/dist/module-sync/npx-cli.js +61 -0
  15. package/dist/{sdk.d.ts → module-sync/sdk.d.ts} +1 -5
  16. package/dist/module-sync/sdk.js +253 -0
  17. package/dist/require/cli.d.ts +3 -0
  18. package/dist/require/cli.d.ts.map +1 -0
  19. package/dist/{cli.js → require/cli.js} +80 -82
  20. package/dist/require/color-or-markdown.d.ts +23 -0
  21. package/dist/require/constants.d.ts +20 -0
  22. package/dist/require/constants.js +67 -0
  23. package/dist/require/errors.d.ts +7 -0
  24. package/dist/require/link.d.ts +2 -0
  25. package/dist/require/link.js +45 -0
  26. package/dist/require/npm-cli.d.ts +2 -0
  27. package/dist/{npm-cli.js → require/npm-cli.js} +12 -10
  28. package/dist/require/npm-injection.d.ts +1 -0
  29. package/dist/{npm-injection.js → require/npm-injection.js} +170 -134
  30. package/dist/require/npx-cli.d.ts +2 -0
  31. package/dist/{npx-cli.js → require/npx-cli.js} +12 -12
  32. package/dist/require/path-resolve.d.ts +8 -0
  33. package/dist/require/path-resolve.js +183 -0
  34. package/dist/require/sdk.d.ts +9 -0
  35. package/dist/{sdk.js → require/sdk.js} +16 -36
  36. package/dist/require/settings.d.ts +9 -0
  37. package/dist/{vendor.js → require/vendor.js} +6 -1
  38. package/package.json +53 -18
  39. package/translations.json +190 -287
  40. package/bin/npm +0 -2
  41. package/bin/npx +0 -2
  42. package/dist/cli.d.ts.map +0 -1
  43. /package/dist/{cli.d.ts → module-sync/cli.d.ts} +0 -0
  44. /package/dist/{color-or-markdown.d.ts → module-sync/color-or-markdown.d.ts} +0 -0
  45. /package/dist/{errors.d.ts → module-sync/errors.d.ts} +0 -0
  46. /package/dist/{link.d.ts → module-sync/link.d.ts} +0 -0
  47. /package/dist/{link.js → module-sync/link.js} +0 -0
  48. /package/dist/{npm-cli.d.ts → module-sync/npm-cli.d.ts} +0 -0
  49. /package/dist/{npm-injection.d.ts → module-sync/npm-injection.d.ts} +0 -0
  50. /package/dist/{npx-cli.d.ts → module-sync/npx-cli.d.ts} +0 -0
  51. /package/dist/{path-resolve.d.ts → module-sync/path-resolve.d.ts} +0 -0
  52. /package/dist/{path-resolve.js → module-sync/path-resolve.js} +0 -0
  53. /package/dist/{settings.d.ts → module-sync/settings.d.ts} +0 -0
@@ -5,22 +5,22 @@ var vendor = require('./vendor.js');
5
5
  var require$$0 = require('node:fs');
6
6
  var require$$1 = require('node:path');
7
7
  var require$$1$1 = require('@npmcli/promise-spawn');
8
+ var constants = require('./constants.js');
8
9
  var link = require('./link.js');
9
10
  var pathResolve = require('./path-resolve.js');
10
11
 
11
- var npmCli$1 = {};
12
+ var npmCli$2 = {};
12
13
 
13
- var npmCli = {};
14
+ var npmCli$1 = {};
14
15
 
15
16
  var _nodeFs = require$$0;
16
17
  var _nodePath = require$$1;
17
18
  var _promiseSpawn = require$$1$1;
19
+ var _constants = constants.constants;
18
20
  var _link = link.link;
19
21
  var _pathResolve = pathResolve.pathResolve;
20
- const realFilename = (0, _nodeFs.realpathSync)(__filename);
21
- const realDirname = _nodePath.dirname(realFilename);
22
- const npmPath = (0, _link.installLinks)(_nodePath.join(realDirname, 'bin'), 'npm');
23
- const injectionPath = _nodePath.join(realDirname, 'npm-injection.js');
22
+ const npmPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
23
+ const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
24
24
 
25
25
  // Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
26
26
  // is found to fix a UX issue when running the command with recent versions of
@@ -42,7 +42,7 @@ if (npmArgs.includes('install') && !npmArgs.includes('--no-progress') && !npmArg
42
42
  }
43
43
  }
44
44
  process.exitCode = 1;
45
- const spawnPromise = _promiseSpawn(process.execPath, ['--require', injectionPath, npmPath, ...npmArgs], {
45
+ const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npmPath, ...npmArgs], {
46
46
  stdio: 'inherit'
47
47
  });
48
48
  spawnPromise.process.on('exit', (code, signal) => {
@@ -66,7 +66,7 @@ spawnPromise.process.on('exit', (code, signal) => {
66
66
  return _npmCli.default;
67
67
  }
68
68
  });
69
- var _npmCli = _interopRequireWildcard(npmCli, true);
69
+ var _npmCli = _interopRequireWildcard(npmCli$1, true);
70
70
  Object.keys(_npmCli).forEach(function (key) {
71
71
  if (key === "default" || key === "__esModule") return;
72
72
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -78,6 +78,8 @@ spawnPromise.process.on('exit', (code, signal) => {
78
78
  }
79
79
  });
80
80
  });
81
- } (npmCli$1));
81
+ } (npmCli$2));
82
+
83
+ var npmCli = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmCli$2);
82
84
 
83
- module.exports = npmCli$1;
85
+ module.exports = npmCli;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,34 +1,36 @@
1
1
  'use strict';
2
2
 
3
3
  var vendor = require('./vendor.js');
4
+ var constants = require('./constants.js');
5
+ var require$$1$3 = require('node:events');
4
6
  var require$$0 = require('node:fs');
7
+ var require$$3$2 = require('node:https');
5
8
  var require$$1$1 = require('node:path');
6
- var require$$1$3 = require('node:events');
7
- var require$$3$3 = require('node:https');
8
9
  var require$$3 = require('node:readline');
9
10
  var require$$5 = require('node:stream');
10
11
  var require$$7$1 = require('node:timers/promises');
11
12
  var require$$5$1 = require('npm-package-arg');
12
- var require$$3$2 = require('@socketregistry/yocto-spinner');
13
- var require$$3$1 = require('semver');
13
+ var require$$3$1 = require('@socketregistry/yocto-spinner');
14
+ var require$$4 = require('semver');
14
15
  var require$$6$1 = require('@socketsecurity/config');
15
16
  var require$$7 = require('@socketsecurity/registry/lib/objects');
17
+ var require$$8 = require('@socketsecurity/registry/lib/packages');
16
18
  var require$$1$2 = require('node:net');
17
19
  var require$$1 = require('node:os');
18
20
  var sdk = require('./sdk.js');
19
21
  var pathResolve = require('./path-resolve.js');
20
22
  var link = require('./link.js');
21
23
 
22
- var npmInjection$1 = {};
24
+ var npmInjection$2 = {};
23
25
 
24
- var npmInjection = {};
26
+ var npmInjection$1 = {};
25
27
 
26
28
  var arborist = {};
27
29
 
28
30
  var ttyServer$1 = {};
29
31
 
30
32
  var name = "socket";
31
- var version = "0.14.28";
33
+ var version = "0.14.30";
32
34
  var description = "CLI tool for Socket.dev";
33
35
  var homepage = "http://github.com/SocketDev/socket-cli";
34
36
  var license = "MIT";
@@ -42,9 +44,43 @@ var author = {
42
44
  url: "https://socket.dev"
43
45
  };
44
46
  var bin = {
45
- socket: "dist/cli.js",
46
- "socket-npm": "dist/npm-cli.js",
47
- "socket-npx": "dist/npx-cli.js"
47
+ socket: "./bin/cli.js",
48
+ "socket-npm": "./bin/npm-cli.js",
49
+ "socket-npx": "./bin/npx-cli.js"
50
+ };
51
+ var exports$1 = {
52
+ "./bin/cli.js": {
53
+ "module-sync": {
54
+ types: "./dist/module-sync/cli.d.ts",
55
+ "default": "./dist/module-sync/cli.js"
56
+ },
57
+ require: {
58
+ types: "./dist/require/cli.d.ts",
59
+ "default": "./dist/require/cli.js"
60
+ }
61
+ },
62
+ "./bin/npm-cli.js": {
63
+ "module-sync": {
64
+ types: "./dist/module-sync/npm-cli.d.ts",
65
+ "default": "./dist/module-sync/npm-cli.js"
66
+ },
67
+ require: {
68
+ types: "./dist/require/npm-cli.d.ts",
69
+ "default": "./dist/require/npm-cli.js"
70
+ }
71
+ },
72
+ "./bin/npx-cli.js": {
73
+ "module-sync": {
74
+ types: "./dist/module-sync/npx-cli.d.ts",
75
+ "default": "./dist/module-sync/npx-cli.js"
76
+ },
77
+ require: {
78
+ types: "./dist/require/npx-cli.d.ts",
79
+ "default": "./dist/require/npx-cli.js"
80
+ }
81
+ },
82
+ "./package.json": "./package.json",
83
+ "./translations.json": "./translations.json"
48
84
  };
49
85
  var scripts = {
50
86
  build: "run-s build:*",
@@ -59,22 +95,22 @@ var scripts = {
59
95
  lint: "oxlint -c=./.oxlintrc.json --ignore-path=./.prettierignore --tsconfig=./tsconfig.json .",
60
96
  "lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
61
97
  "lint:fix:fast": "prettier --cache --log-level warn --write .",
62
- prepare: "husky",
98
+ prepare: "husky && custompatch",
63
99
  test: "run-s check build:* test:*",
64
100
  "test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
65
101
  "test-ci": "run-s build:* test:*",
66
- "test:unit": "tap",
67
- "test:coverage": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/*.js' --exclude 'dist/vendor.js' report"
102
+ "test:unit": "tap-run",
103
+ "test:coverage": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report"
68
104
  };
69
105
  var dependencies = {
70
106
  "@apideck/better-ajv-errors": "^0.3.6",
71
- "@cyclonedx/cdxgen": "^11.0.3",
107
+ "@cyclonedx/cdxgen": "^11.0.5",
72
108
  "@inquirer/prompts": "^7.1.0",
73
109
  "@npmcli/promise-spawn": "^8.0.2",
74
110
  "@socketregistry/hyrious__bun.lockb": "1.0.5",
75
111
  "@socketregistry/yocto-spinner": "^1.0.1",
76
112
  "@socketsecurity/config": "^2.1.3",
77
- "@socketsecurity/registry": "^1.0.32",
113
+ "@socketsecurity/registry": "^1.0.33",
78
114
  "@socketsecurity/sdk": "^1.3.0",
79
115
  blessed: "^0.1.81",
80
116
  "blessed-contrib": "^4.11.0",
@@ -99,18 +135,19 @@ var devDependencies = {
99
135
  "@babel/plugin-proposal-export-default-from": "^7.25.9",
100
136
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
101
137
  "@babel/plugin-transform-export-namespace-from": "^7.25.9",
102
- "@babel/plugin-transform-modules-commonjs": "^7.25.9",
138
+ "@babel/plugin-transform-modules-commonjs": "^7.26.3",
103
139
  "@babel/plugin-transform-runtime": "^7.25.9",
104
140
  "@babel/preset-env": "^7.26.0",
105
141
  "@babel/preset-typescript": "^7.26.0",
106
142
  "@babel/runtime": "^7.26.0",
107
- "@eslint/compat": "^1.2.3",
143
+ "@eslint/compat": "^1.2.4",
108
144
  "@eslint/js": "^9.16.0",
109
145
  "@rollup/plugin-commonjs": "^28.0.1",
110
146
  "@rollup/plugin-json": "^6.1.0",
111
147
  "@rollup/plugin-node-resolve": "^15.3.0",
112
148
  "@rollup/plugin-replace": "^6.0.1",
113
149
  "@rollup/pluginutils": "^5.1.3",
150
+ "@tapjs/run": "^4.0.1",
114
151
  "@types/blessed": "^0.1.25",
115
152
  "@types/micromatch": "^4.0.9",
116
153
  "@types/mocha": "^10.0.10",
@@ -126,29 +163,29 @@ var devDependencies = {
126
163
  "@typescript-eslint/eslint-plugin": "^8.17.0",
127
164
  "@typescript-eslint/parser": "^8.17.0",
128
165
  c8: "^10.1.2",
166
+ custompatch: "^1.0.28",
129
167
  eslint: "^9.16.0",
130
- "eslint-import-resolver-oxc": "^0.5.0",
168
+ "eslint-import-resolver-oxc": "^0.6.0",
131
169
  "eslint-plugin-depend": "^0.12.0",
132
- "eslint-plugin-import-x": "^4.4.3",
170
+ "eslint-plugin-import-x": "^4.5.0",
133
171
  "eslint-plugin-n": "^17.14.0",
134
172
  "eslint-plugin-sort-destructure-keys": "^2.0.0",
135
173
  "eslint-plugin-unicorn": "^56.0.1",
136
174
  husky: "^9.1.7",
137
175
  "is-interactive": "^2.0.0",
138
176
  "is-unicode-supported": "^2.1.0",
139
- knip: "^5.39.0",
177
+ knip: "^5.39.2",
140
178
  "magic-string": "^0.30.14",
141
179
  meow: "^13.2.0",
142
180
  "mock-fs": "^5.4.1",
143
181
  nock: "^13.5.6",
144
182
  "npm-run-all2": "^7.0.1",
145
183
  open: "^10.1.0",
146
- oxlint: "0.14.0",
147
- prettier: "3.4.1",
184
+ oxlint: "0.14.1",
185
+ prettier: "3.4.2",
148
186
  "read-package-up": "^11.0.0",
149
- rollup: "4.28.0",
187
+ rollup: "4.28.1",
150
188
  "rollup-plugin-ts": "^3.4.5",
151
- tap: "^21.0.1",
152
189
  "terminal-link": "^3.0.0",
153
190
  "tiny-updater": "^3.5.2",
154
191
  "type-coverage": "^2.29.7",
@@ -219,6 +256,7 @@ var require$$6 = {
219
256
  repository: repository,
220
257
  author: author,
221
258
  bin: bin,
259
+ exports: exports$1,
222
260
  scripts: scripts,
223
261
  dependencies: dependencies,
224
262
  devDependencies: devDependencies,
@@ -232,10 +270,10 @@ Object.defineProperty(ttyServer$1, "__esModule", {
232
270
  value: true
233
271
  });
234
272
  ttyServer$1.createTTYServer = createTTYServer;
235
- var _nodeFs$2 = require$$0;
273
+ var _nodeFs$1 = require$$0;
236
274
  var _nodeNet = require$$1$2;
237
275
  var _nodeOs = require$$1;
238
- var _nodePath$2 = require$$1$1;
276
+ var _nodePath$1 = require$$1$1;
239
277
  var _nodeReadline$1 = require$$3;
240
278
  var _nodeStream$1 = require$$5;
241
279
  var _package = require$$6;
@@ -243,7 +281,7 @@ var _misc$1 = sdk.misc;
243
281
  const NEWLINE_CHAR_CODE = 10; /*'\n'*/
244
282
 
245
283
  const TTY_IPC = process.env['SOCKET_SECURITY_TTY_IPC'];
246
- const sock = _nodePath$2.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
284
+ const sock = _nodePath$1.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
247
285
  process.env['SOCKET_SECURITY_TTY_IPC'] = sock;
248
286
  function createNonStandardTTYServer() {
249
287
  return {
@@ -416,7 +454,7 @@ function createStandardTTYServer(isInteractive, npmlog) {
416
454
  }
417
455
  function tryUnlinkSync(filepath) {
418
456
  try {
419
- (0, _nodeFs$2.unlinkSync)(filepath);
457
+ (0, _nodeFs$1.unlinkSync)(filepath);
420
458
  } catch (e) {
421
459
  if ((0, _misc$1.isErrnoException)(e) && e.code !== 'ENOENT') {
422
460
  throw e;
@@ -582,31 +620,30 @@ Object.defineProperty(arborist, "__esModule", {
582
620
  arborist.SafeArborist = void 0;
583
621
  arborist.installSafeArborist = installSafeArborist;
584
622
  var _nodeEvents = require$$1$3;
585
- var _nodeFs$1 = require$$0;
586
- var _nodeHttps = require$$3$3;
587
- var _nodePath$1 = require$$1$1;
623
+ var _nodeFs = require$$0;
624
+ var _nodeHttps = require$$3$2;
625
+ var _nodePath = require$$1$1;
588
626
  var _nodeReadline = require$$3;
589
627
  var _nodeStream = require$$5;
590
628
  var _promises = require$$7$1;
591
629
  var _isInteractive = _interopRequireDefault(vendor.isInteractive);
592
630
  var _npmPackageArg = require$$5$1;
593
- var _yoctoSpinner = require$$3$2;
594
- var _semver = require$$3$1;
631
+ var _yoctoSpinner = require$$3$1;
632
+ var _semver = require$$4;
595
633
  var _config = require$$6$1;
596
634
  var _objects = require$$7;
635
+ var _packages = require$$8;
597
636
  var _ttyServer = ttyServer$1;
598
- var _constants = sdk.constants;
637
+ var _constants$1 = constants.constants;
599
638
  var _colorOrMarkdown = sdk.colorOrMarkdown;
600
639
  var _issueRules = issueRules;
601
640
  var _misc = sdk.misc;
602
641
  var _pathResolve = pathResolve.pathResolve;
603
642
  var _sdk = sdk.sdk;
604
643
  var _settings = sdk.settings;
605
- const POTENTIALLY_BUG_ERROR_SNIPPET = 'this is potentially a bug with socket-npm caused by changes to the npm cli';
606
- const distPath$1 = __dirname;
607
- const rootPath$1 = _nodePath$1.resolve(distPath$1, '..');
608
- const npmEntrypoint = (0, _nodeFs$1.realpathSync)(process.argv[1]);
609
- const npmRootPath = (0, _pathResolve.findRoot)(_nodePath$1.dirname(npmEntrypoint));
644
+ const POTENTIAL_BUG_ERROR_MESSAGE = `This is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${_constants$1.SOCKET_CLI_ISSUES_URL}.`;
645
+ const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
646
+ const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
610
647
  function tryRequire(...ids) {
611
648
  for (const data of ids) {
612
649
  let id;
@@ -630,32 +667,29 @@ function tryRequire(...ids) {
630
667
  return undefined;
631
668
  }
632
669
  if (npmRootPath === undefined) {
633
- console.error(`Unable to find npm cli install directory, ${POTENTIALLY_BUG_ERROR_SNIPPET}.`);
634
- console.error(`Searched parent directories of ${npmEntrypoint}`);
670
+ console.error(`Unable to find npm CLI install directory.\nSearched parent directories of ${npmEntrypoint}.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}`);
635
671
  process.exit(127);
636
672
  }
637
- const LOOP_SENTINEL = 1_000_000;
638
- const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
639
- const npmNmPath = _nodePath$1.join(npmRootPath, 'node_modules');
640
- const arboristPkgPath = _nodePath$1.join(npmNmPath, '@npmcli/arborist');
641
- const arboristClassPath = _nodePath$1.join(arboristPkgPath, 'lib/arborist/index.js');
642
- const arboristDepValidPath = _nodePath$1.join(arboristPkgPath, 'lib/dep-valid.js');
643
- const arboristEdgeClassPath = _nodePath$1.join(arboristPkgPath, 'lib/edge.js');
644
- const arboristNodeClassPath = _nodePath$1.join(arboristPkgPath, 'lib/node.js');
645
- const arboristOverrideSetClassPatch = _nodePath$1.join(arboristPkgPath, 'lib/override-set.js');
646
- const log = tryRequire([_nodePath$1.join(npmNmPath, 'proc-log/lib/index.js'),
673
+ const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
674
+ const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
675
+ const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
676
+ const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
677
+ const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
678
+ const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
679
+ const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
680
+ const log = tryRequire([_nodePath.join(npmNmPath, 'proc-log/lib/index.js'),
647
681
  // The proc-log DefinitelyTyped definition is incorrect. The type definition
648
682
  // is really that of its export log.
649
- mod => mod.log], _nodePath$1.join(npmNmPath, 'npmlog/lib/log.js'));
683
+ mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
650
684
  if (log === undefined) {
651
- console.error(`Unable to integrate with npm cli logging infrastructure, ${POTENTIALLY_BUG_ERROR_SNIPPET}.`);
685
+ console.error(`Unable to integrate with npm CLI logging infrastructure.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}.`);
652
686
  process.exit(127);
653
687
  }
654
- const pacote = tryRequire(_nodePath$1.join(npmNmPath, 'pacote'), 'pacote');
688
+ const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
655
689
  const {
656
690
  tarball
657
691
  } = pacote;
658
- const translations = require(_nodePath$1.join(rootPath$1, 'translations.json'));
692
+ const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
659
693
  const abortController = new AbortController();
660
694
  const {
661
695
  signal: abortSignal
@@ -684,11 +718,11 @@ async function uxLookup(settings) {
684
718
  }
685
719
  async function* batchScan(pkgIds) {
686
720
  const query = {
687
- packages: pkgIds.map(pkgid => {
721
+ packages: pkgIds.map(id => {
688
722
  const {
689
723
  name,
690
724
  version
691
- } = pkgidParts(pkgid);
725
+ } = pkgidParts(id);
692
726
  return {
693
727
  eco: 'npm',
694
728
  pkg: name,
@@ -698,7 +732,7 @@ async function* batchScan(pkgIds) {
698
732
  })
699
733
  };
700
734
  // TODO: Migrate to SDK.
701
- const pkgDataReq = _nodeHttps.request(`${_constants.API_V0_URL}/scan/batch`, {
735
+ const pkgDataReq = _nodeHttps.request(`${_constants$1.API_V0_URL}/scan/batch`, {
702
736
  method: 'POST',
703
737
  headers: {
704
738
  Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
@@ -730,10 +764,10 @@ function findSocketYmlSync() {
730
764
  let prevDir = null;
731
765
  let dir = process.cwd();
732
766
  while (dir !== prevDir) {
733
- let ymlPath = _nodePath$1.join(dir, 'socket.yml');
767
+ let ymlPath = _nodePath.join(dir, 'socket.yml');
734
768
  let yml = maybeReadfileSync(ymlPath);
735
769
  if (yml === undefined) {
736
- ymlPath = _nodePath$1.join(dir, 'socket.yaml');
770
+ ymlPath = _nodePath.join(dir, 'socket.yaml');
737
771
  yml = maybeReadfileSync(ymlPath);
738
772
  }
739
773
  if (typeof yml === 'string') {
@@ -747,7 +781,7 @@ function findSocketYmlSync() {
747
781
  }
748
782
  }
749
783
  prevDir = dir;
750
- dir = _nodePath$1.join(dir, '..');
784
+ dir = _nodePath.join(dir, '..');
751
785
  }
752
786
  return null;
753
787
  }
@@ -775,36 +809,46 @@ function findSpecificOverrideSet(first, second) {
775
809
  }
776
810
  function maybeReadfileSync(filepath) {
777
811
  try {
778
- return (0, _nodeFs$1.readFileSync)(filepath, 'utf8');
812
+ return (0, _nodeFs.readFileSync)(filepath, 'utf8');
779
813
  } catch {}
780
814
  return undefined;
781
815
  }
782
816
  async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
817
+ const spinner = _yoctoSpinner({
818
+ stream: output
819
+ });
783
820
  let result = false;
784
- let remaining = pkgs.length;
821
+ let {
822
+ length: remaining
823
+ } = pkgs;
785
824
  if (!remaining) {
786
- _yoctoSpinner().success('No changes detected');
825
+ spinner.success('No changes detected');
787
826
  return result;
788
827
  }
789
828
  const getText = () => `Looking up data for ${remaining} packages`;
790
- const spinner = _yoctoSpinner({
791
- stream: output
792
- }).start(getText());
829
+ spinner.start(getText());
793
830
  try {
794
- for await (const pkgData of batchScan(pkgs.map(pkg => pkg.pkgid))) {
795
- let failures = [];
796
- let displayWarning = false;
797
- const name = pkgData.pkg;
798
- const version = pkgData.ver;
831
+ for await (const pkgData of batchScan(pkgs.map(p => p.pkgid))) {
832
+ const {
833
+ pkg: name,
834
+ ver: version
835
+ } = pkgData;
799
836
  const id = `${name}@${version}`;
837
+ let displayWarning = false;
838
+ let failures = [];
800
839
  if (pkgData.type === 'missing') {
801
840
  result = true;
802
841
  failures.push({
803
- type: 'missingDependency'
842
+ type: 'missingDependency',
843
+ block: false,
844
+ raw: undefined
804
845
  });
805
846
  } else {
806
847
  let blocked = false;
807
848
  for (const failure of pkgData.value.issues) {
849
+ const {
850
+ type
851
+ } = failure;
808
852
  // eslint-disable-next-line no-await-in-loop
809
853
  const ux = await uxLookup({
810
854
  package: {
@@ -812,36 +856,37 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
812
856
  version
813
857
  },
814
858
  issue: {
815
- type: failure.type
859
+ type
816
860
  }
817
861
  });
818
- if (ux.display || ux.block) {
862
+ if (ux.block) {
863
+ result = true;
864
+ blocked = true;
865
+ }
866
+ if (ux.display) {
867
+ displayWarning = true;
868
+ }
869
+ if (ux.block || ux.display) {
819
870
  failures.push({
820
- raw: failure,
821
- block: ux.block
871
+ type,
872
+ block: ux.block,
873
+ raw: failure
822
874
  });
823
875
  // Before we ask about problematic issues, check to see if they
824
876
  // already existed in the old version if they did, be quiet.
825
- const pkg = pkgs.find(pkg => pkg.pkgid === id && pkg.existing?.startsWith(`${name}@`));
877
+ const pkg = pkgs.find(p => p.pkgid === id && p.existing?.startsWith(`${name}@`));
826
878
  if (pkg?.existing) {
879
+ const oldPkgData =
827
880
  // eslint-disable-next-line no-await-in-loop
828
- for await (const oldPkgData of batchScan([pkg.existing])) {
829
- if (oldPkgData.type === 'success') {
830
- failures = failures.filter(issue => oldPkgData.value.issues.find(oldIssue => oldIssue.type === issue.raw.type) == null);
831
- }
881
+ (await batchScan([pkg.existing]).next()).value;
882
+ if (oldPkgData.type === 'success') {
883
+ failures = failures.filter(issue => oldPkgData.value.issues.find(oldIssue => oldIssue.type === issue.type) === undefined);
832
884
  }
833
885
  }
834
886
  }
835
- if (ux.block) {
836
- result = true;
837
- blocked = true;
838
- }
839
- if (ux.display) {
840
- displayWarning = true;
841
- }
842
887
  }
843
888
  if (!blocked) {
844
- const pkg = pkgs.find(pkg => pkg.pkgid === id);
889
+ const pkg = pkgs.find(p => p.pkgid === id);
845
890
  if (pkg) {
846
891
  await tarball.stream(id, stream => {
847
892
  stream.resume();
@@ -853,17 +898,27 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
853
898
  }
854
899
  }
855
900
  if (displayWarning) {
856
- spinner.stop();
857
- output?.write(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:\n`);
858
- failures.sort((a, b) => a.raw.type < b.raw.type ? -1 : 1);
901
+ spinner.stop(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:`);
902
+ // Filter issues for blessed packages.
903
+ if ((0, _packages.isBlessedPackageName)(name)) {
904
+ failures = failures.filter(({
905
+ type
906
+ }) => type !== 'unpopularPackage' && type !== 'unstableOwnership');
907
+ }
908
+ failures.sort((a, b) => a.type < b.type ? -1 : 1);
859
909
  const lines = new Set();
860
910
  for (const failure of failures) {
861
- const type = failure.raw.type;
862
- if (type) {
863
- const issueTypeTranslation = translations.issues[type];
864
- // TODO: emoji seems to mis-align terminals sometimes
865
- lines.add(` ${issueTypeTranslation?.title ?? type}${failure.block ? '' : ' (non-blocking)'} - ${issueTypeTranslation?.description ?? ''}\n`);
866
- }
911
+ const {
912
+ type
913
+ } = failure;
914
+ // Based data from { pageProps: { alertTypes } } of:
915
+ // https://socket.dev/_next/data/94666139314b6437ee4491a0864e72b264547585/en-US.json
916
+ const info = translations.issues[type];
917
+ const title = info?.title ?? type;
918
+ const maybeBlocking = failure.block ? '' : ' (non-blocking)';
919
+ const maybeDesc = info?.description ? ` - ${info.description}` : '';
920
+ // TODO: emoji seems to mis-align terminals sometimes
921
+ lines.add(` ${title}${maybeBlocking}${maybeDesc}\n`);
867
922
  }
868
923
  for (const line of lines) {
869
924
  output?.write(line);
@@ -875,9 +930,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
875
930
  }
876
931
  return result;
877
932
  } finally {
878
- if (spinner.isSpinning) {
879
- spinner.stop();
880
- }
933
+ spinner.stop();
881
934
  }
882
935
  }
883
936
  function pkgidParts(pkgid) {
@@ -889,18 +942,8 @@ function pkgidParts(pkgid) {
889
942
  version
890
943
  };
891
944
  }
892
- function toPURL(pkgid, resolved) {
893
- const repo = resolved.replace(/#[\s\S]*$/u, '').replace(/\?[\s\S]*$/u, '').replace(/\/[^/]*\/-\/[\s\S]*$/u, '');
894
- const {
895
- name,
896
- version
897
- } = pkgidParts(pkgid);
898
- return {
899
- type: 'npm',
900
- namespace_and_name: name,
901
- version,
902
- repository_url: repo
903
- };
945
+ function toRepoUrl(resolved) {
946
+ return resolved.replace(/#[\s\S]*$/, '').replace(/\?[\s\S]*$/, '').replace(/\/[^/]*\/-\/[\s\S]*$/, '');
904
947
  }
905
948
  function walk(diff_, needInfoOn = []) {
906
949
  const queue = [diff_];
@@ -909,7 +952,7 @@ function walk(diff_, needInfoOn = []) {
909
952
  length: queueLength
910
953
  } = queue;
911
954
  while (pos < queueLength) {
912
- if (pos === LOOP_SENTINEL) {
955
+ if (pos === _constants$1.LOOP_SENTINEL) {
913
956
  throw new Error('Detected infinite loop while walking Arborist diff');
914
957
  }
915
958
  const diff = queue[pos++];
@@ -931,12 +974,8 @@ function walk(diff_, needInfoOn = []) {
931
974
  if (keep && diff.ideal?.pkgid && diff.ideal.resolved && (!diff.actual || diff.actual.resolved)) {
932
975
  needInfoOn.push({
933
976
  existing,
934
- action: diff.action,
935
- location: diff.ideal.location,
936
977
  pkgid: diff.ideal.pkgid,
937
- newPackage: toPURL(diff.ideal.pkgid, diff.ideal.resolved),
938
- oldPackage: diff.actual && diff.actual.resolved ? toPURL(diff.actual.pkgid, diff.actual.resolved) : null,
939
- resolved: diff.ideal.resolved
978
+ repository_url: toRepoUrl(diff.ideal.resolved)
940
979
  });
941
980
  }
942
981
  }
@@ -1485,7 +1524,7 @@ class SafeOverrideSet extends OverrideSet {
1485
1524
  length: queueLength
1486
1525
  } = queue;
1487
1526
  while (pos < queueLength) {
1488
- if (pos === LOOP_SENTINEL) {
1527
+ if (pos === _constants$1.LOOP_SENTINEL) {
1489
1528
  throw new Error('Detected infinite loop while comparing override sets');
1490
1529
  }
1491
1530
  const {
@@ -1627,10 +1666,10 @@ class SafeArborist extends Arborist {
1627
1666
  options['save'] = old.save;
1628
1667
  options['saveBundle'] = old.saveBundle;
1629
1668
  // Nothing to check, mmm already installed or all private?
1630
- if (diff.findIndex(c => c.newPackage.repository_url === NPM_REGISTRY_URL) === -1) {
1669
+ if (diff.findIndex(c => c.repository_url === _constants$1.NPM_REGISTRY_URL) === -1) {
1631
1670
  return await this[kRiskyReify](...args);
1632
1671
  }
1633
- let proceed = _constants.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
1672
+ let proceed = _constants$1.ENV[_constants$1.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1634
1673
  if (!proceed) {
1635
1674
  proceed = await ttyServer.captureTTY(async (input, output) => {
1636
1675
  if (input && output) {
@@ -1767,16 +1806,11 @@ void (async () => {
1767
1806
  _uxLookup = (0, _issueRules.createIssueUXLookup)(settings);
1768
1807
  })();
1769
1808
 
1770
- var _nodeFs = require$$0;
1771
- var _nodePath = require$$1$1;
1809
+ var _constants = constants.constants;
1772
1810
  var _arborist = arborist;
1773
1811
  var _link = link.link;
1774
- const distPath = __dirname;
1775
- const rootPath = _nodePath.resolve(distPath, '..');
1776
- const binPath = _nodePath.join(rootPath, 'bin');
1777
-
1778
- // shadow `npm` and `npx` to mitigate subshells
1779
- (0, _link.installLinks)((0, _nodeFs.realpathSync)(binPath), 'npm');
1812
+ // Shadow `npm` and `npx` to mitigate subshells.
1813
+ (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
1780
1814
  (0, _arborist.installSafeArborist)();
1781
1815
 
1782
1816
  (function (exports) {
@@ -1792,7 +1826,7 @@ const binPath = _nodePath.join(rootPath, 'bin');
1792
1826
  return _npmInjection.default;
1793
1827
  }
1794
1828
  });
1795
- var _npmInjection = _interopRequireWildcard(npmInjection, true);
1829
+ var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
1796
1830
  Object.keys(_npmInjection).forEach(function (key) {
1797
1831
  if (key === "default" || key === "__esModule") return;
1798
1832
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -1804,6 +1838,8 @@ const binPath = _nodePath.join(rootPath, 'bin');
1804
1838
  }
1805
1839
  });
1806
1840
  });
1807
- } (npmInjection$1));
1841
+ } (npmInjection$2));
1842
+
1843
+ var npmInjection = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmInjection$2);
1808
1844
 
1809
- module.exports = npmInjection$1;
1845
+ module.exports = npmInjection;