@socketsecurity/cli 0.14.34 → 0.14.36

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 (37) hide show
  1. package/bin/cli.js +37 -1
  2. package/bin/npm-cli.js +2 -1
  3. package/bin/npx-cli.js +2 -1
  4. package/dist/constants.js +69 -38
  5. package/dist/module-sync/cli.js +773 -1555
  6. package/dist/module-sync/constants.d.ts +16 -79
  7. package/dist/module-sync/constants.d.ts.map +1 -0
  8. package/dist/module-sync/npm-injection.js +77 -396
  9. package/dist/module-sync/path-resolve.d.ts +6 -1
  10. package/dist/module-sync/path-resolve.js +47 -38
  11. package/dist/module-sync/sdk.js +60 -110
  12. package/dist/module-sync/shadow-bin.d.ts +2 -0
  13. package/dist/module-sync/shadow-bin.js +103 -0
  14. package/dist/require/cli.js +768 -1549
  15. package/dist/require/constants.d.ts.map +1 -0
  16. package/dist/require/npm-injection.js +76 -394
  17. package/dist/require/path-resolve.js +47 -38
  18. package/dist/require/sdk.js +57 -106
  19. package/dist/require/shadow-bin.js +103 -0
  20. package/dist/require/vendor.js +8295 -8708
  21. package/package.json +30 -31
  22. package/shadow-bin/npm +4 -0
  23. package/shadow-bin/npx +4 -0
  24. package/bin/shadow/module-sync/npm +0 -3
  25. package/bin/shadow/module-sync/npx +0 -3
  26. package/bin/shadow/require/npm +0 -3
  27. package/bin/shadow/require/npx +0 -3
  28. package/dist/module-sync/link.d.ts +0 -2
  29. package/dist/module-sync/link.js +0 -54
  30. package/dist/module-sync/npm-cli.d.ts +0 -2
  31. package/dist/module-sync/npm-cli.js +0 -101
  32. package/dist/module-sync/npx-cli.d.ts +0 -2
  33. package/dist/module-sync/npx-cli.js +0 -77
  34. package/dist/module-sync/vendor.js +0 -70
  35. package/dist/require/link.js +0 -54
  36. package/dist/require/npm-cli.js +0 -101
  37. package/dist/require/npx-cli.js +0 -77
@@ -4,290 +4,44 @@ function _socketInterop(e) {
4
4
  let c = 0
5
5
  for (const k in e ?? {}) {
6
6
  c = c === 0 && k === 'default' ? 1 : 0
7
- if (!c) break
7
+ if (!c && k !== '__esModule') break
8
8
  }
9
9
  return c ? e.default : e
10
10
  }
11
11
 
12
- var vendor = require('./vendor.js');
13
- var constants = require('./constants.js');
14
- var require$$1$3 = require('node:events');
15
- var require$$0 = require('node:fs');
16
- var require$$3$3 = require('node:https');
17
- var require$$1 = require('node:path');
18
- var require$$3 = require('node:readline');
19
- var require$$6$2 = require('node:timers/promises');
20
- var require$$1$2 = require('@socketsecurity/registry/lib/prompts');
21
- var require$$3$2 = require('@socketregistry/yocto-spinner');
22
- var require$$2$1 = _socketInterop(require('is-interactive'));
23
- var require$$5$1 = _socketInterop(require('npm-package-arg'));
24
- var require$$3$1 = _socketInterop(require('semver'));
25
- var require$$6$1 = require('@socketsecurity/config');
26
- var require$$7 = require('@socketsecurity/registry/lib/objects');
27
- var require$$8 = require('@socketsecurity/registry/lib/packages');
28
- var require$$1$1 = require('node:net');
29
- var require$$2 = require('node:os');
30
- var require$$5 = require('node:stream');
12
+ var events = require('node:events');
13
+ var fs = require('node:fs');
14
+ var https = require('node:https');
15
+ var path = require('node:path');
16
+ var readline = require('node:readline');
17
+ var promises = require('node:timers/promises');
18
+ var prompts = require('@socketsecurity/registry/lib/prompts');
19
+ var yoctoSpinner = require('@socketregistry/yocto-spinner');
20
+ var isInteractive = _socketInterop(require('is-interactive'));
21
+ var npa = _socketInterop(require('npm-package-arg'));
22
+ var semver = _socketInterop(require('semver'));
23
+ var config = require('@socketsecurity/config');
24
+ var objects = require('@socketsecurity/registry/lib/objects');
25
+ var packages = require('@socketsecurity/registry/lib/packages');
26
+ var net = require('node:net');
27
+ var homedir = require('node:os');
28
+ var node_stream = require('node:stream');
31
29
  var sdk = require('./sdk.js');
30
+ var constants = require('./constants.js');
32
31
  var pathResolve = require('./path-resolve.js');
33
- var link = require('./link.js');
34
-
35
- var npmInjection$2 = {};
36
-
37
- var npmInjection$1 = {};
38
32
 
39
- var arborist = {};
40
-
41
- var ttyServer$1 = {};
42
-
43
- var name = "@socketsecurity/cli";
44
- var version = "0.14.34";
45
- var description = "CLI tool for Socket.dev";
46
- var homepage = "http://github.com/SocketDev/socket-cli";
47
- var license = "MIT";
48
- var repository = {
49
- type: "git",
50
- url: "git+https://github.com/SocketDev/socket-cli.git"
51
- };
52
- var author = {
53
- name: "Socket Inc",
54
- email: "eng@socket.dev",
55
- url: "https://socket.dev"
56
- };
57
- var bin = {
58
- cli: "./bin/cli.js",
59
- socket: "./bin/cli.js",
60
- "socket-npm": "./bin/npm-cli.js",
61
- "socket-npx": "./bin/npx-cli.js"
62
- };
63
- var exports$1 = {
64
- "./bin/cli.js": {
65
- types: "./dist/module-sync/cli.d.ts",
66
- "module-sync": "./dist/module-sync/cli.js",
67
- require: "./dist/require/cli.js"
68
- },
69
- "./bin/npm-cli.js": {
70
- types: "./dist/module-sync/npm-cli.d.ts",
71
- "module-sync": "./dist/module-sync/npm-cli.js",
72
- require: "./dist/require/npm-cli.js"
73
- },
74
- "./bin/npx-cli.js": {
75
- types: "./dist/module-sync/npx-cli.d.ts",
76
- "module-sync": "./dist/module-sync/npx-cli.js",
77
- require: "./dist/require/npx-cli.js"
78
- },
79
- "./package.json": "./package.json",
80
- "./translations.json": "./translations.json"
81
- };
82
- var scripts = {
83
- build: "run-s build:*",
84
- "build:dist": "rollup -c .config/rollup.dist.config.mjs",
85
- "build:test": "rollup -c .config/rollup.test.config.mjs",
86
- check: "run-p -c --aggregate-output check:*",
87
- "check:lint": "eslint --report-unused-disable-directives .",
88
- "check:tsc": "tsc",
89
- "check:type-coverage": "type-coverage --detail --strict --at-least 95 --ignore-files 'test/*'",
90
- "knip:dependencies": "knip --dependencies",
91
- "knip:exports": "knip --include exports,duplicates",
92
- lint: "oxlint -c=./.oxlintrc.json --ignore-path=./.prettierignore --tsconfig=./tsconfig.json .",
93
- "lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
94
- "lint:fix:fast": "prettier --cache --log-level warn --write .",
95
- prepare: "husky && custompatch",
96
- test: "run-s check build:* test:* test:coverage:*",
97
- "test-ci": "run-s build:* test:*",
98
- "test:unit": "tap-run",
99
- "test:coverage:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
100
- "test:coverage:merge": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report"
101
- };
102
- var dependencies = {
103
- "@apideck/better-ajv-errors": "^0.3.6",
104
- "@cyclonedx/cdxgen": "^11.0.5",
105
- "@npmcli/promise-spawn": "^8.0.2",
106
- "@socketregistry/hyrious__bun.lockb": "1.0.5",
107
- "@socketregistry/yocto-spinner": "^1.0.1",
108
- "@socketsecurity/config": "^2.1.3",
109
- "@socketsecurity/registry": "^1.0.51",
110
- "@socketsecurity/sdk": "^1.3.0",
111
- blessed: "^0.1.81",
112
- "blessed-contrib": "^4.11.0",
113
- browserslist: "4.24.2",
114
- "chalk-table": "^1.0.2",
115
- "has-flag": "^4.0.0",
116
- hpagent: "^1.2.0",
117
- ignore: "^6.0.2",
118
- micromatch: "^4.0.8",
119
- "npm-package-arg": "^12.0.0",
120
- "pony-cause": "^2.1.11",
121
- semver: "^7.6.3",
122
- synp: "^1.9.14",
123
- tinyglobby: "^0.2.10",
124
- which: "^5.0.0",
125
- yaml: "^2.6.1",
126
- "yargs-parser": "^21.1.1",
127
- "yoctocolors-cjs": "^2.1.2"
128
- };
129
- var devDependencies = {
130
- "@babel/core": "^7.26.0",
131
- "@babel/plugin-proposal-export-default-from": "^7.25.9",
132
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
133
- "@babel/plugin-transform-export-namespace-from": "^7.25.9",
134
- "@babel/plugin-transform-modules-commonjs": "^7.26.3",
135
- "@babel/plugin-transform-runtime": "^7.25.9",
136
- "@babel/preset-env": "^7.26.0",
137
- "@babel/preset-typescript": "^7.26.0",
138
- "@babel/runtime": "^7.26.0",
139
- "@eslint/compat": "^1.2.4",
140
- "@eslint/js": "^9.16.0",
141
- "@rollup/plugin-commonjs": "^28.0.1",
142
- "@rollup/plugin-json": "^6.1.0",
143
- "@rollup/plugin-node-resolve": "^15.3.0",
144
- "@rollup/plugin-replace": "^6.0.1",
145
- "@rollup/pluginutils": "^5.1.3",
146
- "@tapjs/run": "^4.0.1",
147
- "@types/blessed": "^0.1.25",
148
- "@types/micromatch": "^4.0.9",
149
- "@types/mocha": "^10.0.10",
150
- "@types/mock-fs": "^4.13.4",
151
- "@types/node": "^22.10.1",
152
- "@types/npmcli__arborist": "^5.6.11",
153
- "@types/npmcli__promise-spawn": "^6.0.3",
154
- "@types/proc-log": "^3.0.4",
155
- "@types/semver": "^7.5.8",
156
- "@types/update-notifier": "^6.0.8",
157
- "@types/which": "^3.0.4",
158
- "@types/yargs-parser": "^21.0.3",
159
- "@typescript-eslint/eslint-plugin": "^8.17.0",
160
- "@typescript-eslint/parser": "^8.17.0",
161
- c8: "^10.1.2",
162
- custompatch: "^1.0.28",
163
- eslint: "^9.16.0",
164
- "eslint-import-resolver-oxc": "^0.6.0",
165
- "eslint-plugin-depend": "^0.12.0",
166
- "eslint-plugin-import-x": "^4.5.0",
167
- "eslint-plugin-n": "^17.14.0",
168
- "eslint-plugin-sort-destructure-keys": "^2.0.0",
169
- "eslint-plugin-unicorn": "^56.0.1",
170
- husky: "^9.1.7",
171
- "is-interactive": "^2.0.0",
172
- "is-unicode-supported": "^2.1.0",
173
- knip: "^5.39.2",
174
- "magic-string": "^0.30.14",
175
- meow: "^13.2.0",
176
- "mock-fs": "^5.4.1",
177
- nock: "^13.5.6",
178
- "npm-run-all2": "^7.0.1",
179
- open: "^10.1.0",
180
- oxlint: "0.14.1",
181
- prettier: "3.4.2",
182
- "read-package-up": "^11.0.0",
183
- rollup: "4.28.1",
184
- "rollup-plugin-ts": "^3.4.5",
185
- "terminal-link": "^3.0.0",
186
- "tiny-updater": "^3.5.2",
187
- "type-coverage": "^2.29.7",
188
- typescript: "5.4.5",
189
- "typescript-eslint": "^8.17.0",
190
- "unplugin-purge-polyfills": "^0.0.7"
191
- };
192
- var overrides = {
193
- "aggregate-error": "npm:@socketregistry/aggregate-error@^1",
194
- "es-define-property": "npm:@socketregistry/es-define-property@^1",
195
- "function-bind": "npm:@socketregistry/function-bind@^1",
196
- globalthis: "npm:@socketregistry/globalthis@^1",
197
- gopd: "npm:@socketregistry/gopd@^1",
198
- "has-property-descriptors": "npm:@socketregistry/has-property-descriptors@^1",
199
- "has-proto": "npm:@socketregistry/has-proto@^1",
200
- "has-symbols": "npm:@socketregistry/has-symbols@^1",
201
- hasown: "npm:@socketregistry/hasown@^1",
202
- "indent-string": "npm:@socketregistry/indent-string@^1",
203
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
204
- isarray: "npm:@socketregistry/isarray@^1",
205
- "npm-package-arg": "$npm-package-arg",
206
- "packageurl-js": "npm:@socketregistry/packageurl-js@^1",
207
- "path-parse": "npm:@socketregistry/path-parse@^1",
208
- "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
209
- "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
210
- semver: "$semver",
211
- "set-function-length": "npm:@socketregistry/set-function-length@^1",
212
- "side-channel": "npm:@socketregistry/side-channel@^1",
213
- "tiny-colors": "$yoctocolors-cjs",
214
- typedarray: "npm:@socketregistry/typedarray@^1",
215
- yaml: "$yaml"
216
- };
217
- var resolutions = {
218
- "aggregate-error": "npm:@socketregistry/aggregate-error@^1",
219
- "es-define-property": "npm:@socketregistry/es-define-property@^1",
220
- "function-bind": "npm:@socketregistry/function-bind@^1",
221
- globalthis: "npm:@socketregistry/globalthis@^1",
222
- gopd: "npm:@socketregistry/gopd@^1",
223
- "has-property-descriptors": "npm:@socketregistry/has-property-descriptors@^1",
224
- "has-proto": "npm:@socketregistry/has-proto@^1",
225
- "has-symbols": "npm:@socketregistry/has-symbols@^1",
226
- hasown: "npm:@socketregistry/hasown@^1",
227
- "indent-string": "npm:@socketregistry/indent-string@^1",
228
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
229
- isarray: "npm:@socketregistry/isarray@^1",
230
- "npm-package-arg": "^12.0.0",
231
- "packageurl-js": "npm:@socketregistry/packageurl-js@^1",
232
- "path-parse": "npm:@socketregistry/path-parse@^1",
233
- "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
234
- "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
235
- semver: "^7.6.3",
236
- "set-function-length": "npm:@socketregistry/set-function-length@^1",
237
- "side-channel": "npm:@socketregistry/side-channel@^1",
238
- "tiny-colors": "npm:yoctocolors-cjs@^2.1.2",
239
- typedarray: "npm:@socketregistry/typedarray@^1",
240
- yaml: "^2.6.0"
241
- };
242
- var engines = {
243
- node: "^18.20.4 || ^20.9.0 || >=22.0.0"
244
- };
245
- var files = [
246
- "bin/**",
247
- "dist/**",
248
- "translations.json"
249
- ];
250
- var require$$6 = {
251
- name: name,
252
- version: version,
253
- description: description,
254
- homepage: homepage,
255
- license: license,
256
- repository: repository,
257
- author: author,
258
- bin: bin,
259
- exports: exports$1,
260
- scripts: scripts,
261
- dependencies: dependencies,
262
- devDependencies: devDependencies,
263
- overrides: overrides,
264
- resolutions: resolutions,
265
- engines: engines,
266
- files: files
267
- };
33
+ var version = "0.14.36";
268
34
 
269
- Object.defineProperty(ttyServer$1, "__esModule", {
270
- value: true
271
- });
272
- ttyServer$1.createTTYServer = createTTYServer;
273
- var _nodeFs$1 = require$$0;
274
- var _nodeNet = require$$1$1;
275
- var _nodeOs = require$$2;
276
- var _nodePath$1 = require$$1;
277
- var _nodeReadline$1 = require$$3;
278
- var _nodeStream = require$$5;
279
- var _package = require$$6;
280
- var _misc$1 = sdk.misc;
281
35
  const NEWLINE_CHAR_CODE = 10; /*'\n'*/
282
36
 
283
37
  const TTY_IPC = process.env['SOCKET_SECURITY_TTY_IPC'];
284
- const sock = _nodePath$1.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
38
+ const sock = path.join(homedir.tmpdir(), `socket-security-tty-${process.pid}.sock`);
285
39
  process.env['SOCKET_SECURITY_TTY_IPC'] = sock;
286
40
  function createNonStandardTTYServer() {
287
41
  return {
288
42
  async captureTTY(mutexFn) {
289
43
  return await new Promise((resolve, reject) => {
290
- const conn = _nodeNet.createConnection({
44
+ const conn = net.createConnection({
291
45
  path: TTY_IPC
292
46
  }).on('error', reject);
293
47
  let captured = false;
@@ -310,23 +64,23 @@ function createNonStandardTTYServer() {
310
64
  } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf8'));
311
65
  lineBuff = null;
312
66
  captured = true;
313
- if (remote_ipc_version !== _package.version) {
67
+ if (remote_ipc_version !== version) {
314
68
  throw new Error('Mismatched STDIO tunnel IPC version, ensure you only have 1 version of socket CLI being called.');
315
69
  }
316
- const input = hasInput ? new _nodeStream.PassThrough() : null;
70
+ const input = hasInput ? new node_stream.PassThrough() : null;
317
71
  input?.pause();
318
72
  if (input) conn.pipe(input);
319
- const output = hasOutput ? new _nodeStream.PassThrough() : null;
73
+ const output = hasOutput ? new node_stream.PassThrough() : null;
320
74
  if (output) {
321
75
  output.pipe(conn)
322
76
  // Make ora happy
323
77
  ;
324
78
  output.isTTY = true;
325
79
  output.cursorTo = function cursorTo(x, y, callback) {
326
- _nodeReadline$1.cursorTo(this, x, y, callback);
80
+ readline.cursorTo(this, x, y, callback);
327
81
  };
328
82
  output.clearLine = function clearLine(dir, callback) {
329
- _nodeReadline$1.clearLine(this, dir, callback);
83
+ readline.clearLine(this, dir, callback);
330
84
  };
331
85
  }
332
86
  mutexFn(hasInput ? input : undefined, hasOutput ? output : undefined).then(resolve, reject).finally(() => {
@@ -349,7 +103,7 @@ function createIPCServer(captureState, npmlog) {
349
103
  const input = process.stdin;
350
104
  const output = process.stderr;
351
105
  return new Promise((resolve, reject) => {
352
- const server = _nodeNet
106
+ const server = net
353
107
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
354
108
  .createServer(async conn => {
355
109
  if (captureState.captured) {
@@ -369,7 +123,7 @@ function createIPCServer(captureState, npmlog) {
369
123
  npmlog.disableProgress();
370
124
  }
371
125
  conn.write(`${JSON.stringify({
372
- ipc_version: _package.version,
126
+ ipc_version: version,
373
127
  capabilities: {
374
128
  input: Boolean(input),
375
129
  output: true
@@ -454,9 +208,9 @@ function createStandardTTYServer(isInteractive, npmlog) {
454
208
  }
455
209
  function tryUnlinkSync(filepath) {
456
210
  try {
457
- (0, _nodeFs$1.unlinkSync)(filepath);
211
+ fs.unlinkSync(filepath);
458
212
  } catch (e) {
459
- if ((0, _misc$1.isErrnoException)(e) && e.code !== 'ENOENT') {
213
+ if (sdk.isErrnoException(e) && e.code !== 'ENOENT') {
460
214
  throw e;
461
215
  }
462
216
  }
@@ -465,12 +219,6 @@ function createTTYServer(isInteractive, npmlog) {
465
219
  return !isInteractive && TTY_IPC ? createNonStandardTTYServer() : createStandardTTYServer(isInteractive, npmlog);
466
220
  }
467
221
 
468
- var alertRules = {};
469
-
470
- Object.defineProperty(alertRules, "__esModule", {
471
- value: true
472
- });
473
- alertRules.createAlertUXLookup = createAlertUXLookup;
474
222
  //#region UX Constants
475
223
 
476
224
  const IGNORE_UX = {
@@ -614,35 +362,8 @@ function createAlertUXLookup(settings) {
614
362
  return ux;
615
363
  };
616
364
  }
365
+ //#endregion
617
366
 
618
- var _interopRequireDefault = vendor.interopRequireDefault.default;
619
- Object.defineProperty(arborist, "__esModule", {
620
- value: true
621
- });
622
- arborist.SafeArborist = void 0;
623
- arborist.installSafeArborist = installSafeArborist;
624
- var _nodeEvents = require$$1$3;
625
- var _nodeFs = require$$0;
626
- var _nodeHttps = require$$3$3;
627
- var _nodePath = require$$1;
628
- var _nodeReadline = require$$3;
629
- var _promises = require$$6$2;
630
- var _prompts = require$$1$2;
631
- var _yoctoSpinner = require$$3$2;
632
- var _isInteractive = _interopRequireDefault(require$$2$1);
633
- var _npmPackageArg = require$$5$1;
634
- var _semver = require$$3$1;
635
- var _config = require$$6$1;
636
- var _objects = require$$7;
637
- var _packages = require$$8;
638
- var _ttyServer = ttyServer$1;
639
- var _constants$1 = constants.constants;
640
- var _colorOrMarkdown = sdk.colorOrMarkdown;
641
- var _alertRules = alertRules;
642
- var _misc = sdk.misc;
643
- var _pathResolve = pathResolve.pathResolve;
644
- var _sdk = sdk.sdk;
645
- var _settings = sdk.settings;
646
367
  const {
647
368
  API_V0_URL,
648
369
  ENV,
@@ -651,11 +372,12 @@ const {
651
372
  SOCKET_CLI_ISSUES_URL,
652
373
  SOCKET_PUBLIC_API_KEY,
653
374
  UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
375
+ abortSignal,
654
376
  rootPath
655
- } = _constants$1;
377
+ } = constants;
656
378
  const POTENTIAL_BUG_ERROR_MESSAGE = `This is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`;
657
- const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
658
- const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
379
+ const npmEntrypoint = fs.realpathSync(process.argv[1]);
380
+ const npmRootPath = pathResolve.findRoot(path.dirname(npmEntrypoint));
659
381
  function tryRequire(...ids) {
660
382
  for (const data of ids) {
661
383
  let id;
@@ -680,32 +402,32 @@ function tryRequire(...ids) {
680
402
  }
681
403
  if (npmRootPath === undefined) {
682
404
  console.error(`Unable to find npm CLI install directory.\nSearched parent directories of ${npmEntrypoint}.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}`);
405
+ // The exit code 127 indicates that the command or binary being executed
406
+ // could not be found.
683
407
  process.exit(127);
684
408
  }
685
- const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
686
- const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
687
- const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
688
- const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
689
- const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
690
- const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
691
- const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
692
- const log = tryRequire([_nodePath.join(npmNmPath, 'proc-log/lib/index.js'),
409
+ const npmNmPath = path.join(npmRootPath, 'node_modules');
410
+ const arboristPkgPath = path.join(npmNmPath, '@npmcli/arborist');
411
+ const arboristClassPath = path.join(arboristPkgPath, 'lib/arborist/index.js');
412
+ const arboristDepValidPath = path.join(arboristPkgPath, 'lib/dep-valid.js');
413
+ const arboristEdgeClassPath = path.join(arboristPkgPath, 'lib/edge.js');
414
+ const arboristNodeClassPath = path.join(arboristPkgPath, 'lib/node.js');
415
+ const arboristOverrideSetClassPatch = path.join(arboristPkgPath, 'lib/override-set.js');
416
+ const log = tryRequire([path.join(npmNmPath, 'proc-log/lib/index.js'),
693
417
  // The proc-log DefinitelyTyped definition is incorrect. The type definition
694
418
  // is really that of its export log.
695
- mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
419
+ mod => mod.log], path.join(npmNmPath, 'npmlog/lib/log.js'));
696
420
  if (log === undefined) {
697
421
  console.error(`Unable to integrate with npm CLI logging infrastructure.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}.`);
422
+ // The exit code 127 indicates that the command or binary being executed
423
+ // could not be found.
698
424
  process.exit(127);
699
425
  }
700
- const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
426
+ const pacote = tryRequire(path.join(npmNmPath, 'pacote'), 'pacote');
701
427
  const {
702
428
  tarball
703
429
  } = pacote;
704
- const translations = require(_nodePath.join(rootPath, 'translations.json'));
705
- const abortController = new AbortController();
706
- const {
707
- signal: abortSignal
708
- } = abortController;
430
+ const translations = require(path.join(rootPath, 'translations.json'));
709
431
  const Arborist = require(arboristClassPath);
710
432
  const depValid = require(arboristDepValidPath);
711
433
  const Edge = require(arboristEdgeClassPath);
@@ -713,23 +435,23 @@ const Node = require(arboristNodeClassPath);
713
435
  const OverrideSet = require(arboristOverrideSetClassPatch);
714
436
  const kCtorArgs = Symbol('ctorArgs');
715
437
  const kRiskyReify = Symbol('riskyReify');
716
- const formatter = new _colorOrMarkdown.ColorOrMarkdown(false);
717
- const pubToken = (0, _sdk.getDefaultKey)() ?? SOCKET_PUBLIC_API_KEY;
718
- const ttyServer = (0, _ttyServer.createTTYServer)((0, _isInteractive.default)({
438
+ const formatter = new sdk.ColorOrMarkdown(false);
439
+ const pubToken = sdk.getDefaultKey() ?? SOCKET_PUBLIC_API_KEY;
440
+ const ttyServer = createTTYServer(isInteractive({
719
441
  stream: process.stdin
720
442
  }), log);
721
443
  let _uxLookup;
722
444
  async function uxLookup(settings) {
723
445
  while (_uxLookup === undefined) {
724
446
  // eslint-disable-next-line no-await-in-loop
725
- await (0, _promises.setTimeout)(1, {
447
+ await promises.setTimeout(1, {
726
448
  signal: abortSignal
727
449
  });
728
450
  }
729
451
  return _uxLookup(settings);
730
452
  }
731
453
  async function* batchScan(pkgIds) {
732
- const req = _nodeHttps.request(`${API_V0_URL}/purl?alerts=true`, {
454
+ const req = https.request(`${API_V0_URL}/purl?alerts=true`, {
733
455
  method: 'POST',
734
456
  headers: {
735
457
  Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
@@ -742,12 +464,12 @@ async function* batchScan(pkgIds) {
742
464
  }));
743
465
  const {
744
466
  0: res
745
- } = await _nodeEvents.once(req, 'response');
467
+ } = await events.once(req, 'response');
746
468
  const ok = res.statusCode >= 200 && res.statusCode <= 299;
747
469
  if (!ok) {
748
470
  throw new Error(`Socket API Error: ${res.statusCode}`);
749
471
  }
750
- const rli = _nodeReadline.createInterface(res);
472
+ const rli = readline.createInterface(res);
751
473
  for await (const line of rli) {
752
474
  yield JSON.parse(line);
753
475
  }
@@ -765,24 +487,24 @@ function findSocketYmlSync() {
765
487
  let prevDir = null;
766
488
  let dir = process.cwd();
767
489
  while (dir !== prevDir) {
768
- let ymlPath = _nodePath.join(dir, 'socket.yml');
490
+ let ymlPath = path.join(dir, 'socket.yml');
769
491
  let yml = maybeReadfileSync(ymlPath);
770
492
  if (yml === undefined) {
771
- ymlPath = _nodePath.join(dir, 'socket.yaml');
493
+ ymlPath = path.join(dir, 'socket.yaml');
772
494
  yml = maybeReadfileSync(ymlPath);
773
495
  }
774
496
  if (typeof yml === 'string') {
775
497
  try {
776
498
  return {
777
499
  path: ymlPath,
778
- parsed: _config.parseSocketConfig(yml)
500
+ parsed: config.parseSocketConfig(yml)
779
501
  };
780
502
  } catch {
781
503
  throw new Error(`Found file but was unable to parse ${ymlPath}`);
782
504
  }
783
505
  }
784
506
  prevDir = dir;
785
- dir = _nodePath.join(dir, '..');
507
+ dir = path.join(dir, '..');
786
508
  }
787
509
  return null;
788
510
  }
@@ -819,12 +541,12 @@ function isAlertFixable(alert) {
819
541
  }
820
542
  function maybeReadfileSync(filepath) {
821
543
  try {
822
- return (0, _nodeFs.readFileSync)(filepath, 'utf8');
544
+ return fs.readFileSync(filepath, 'utf8');
823
545
  } catch {}
824
546
  return undefined;
825
547
  }
826
548
  async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
827
- const spinner = _yoctoSpinner({
549
+ const spinner = yoctoSpinner({
828
550
  stream: output
829
551
  });
830
552
  let {
@@ -845,7 +567,7 @@ async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
845
567
  const {
846
568
  version
847
569
  } = artifact;
848
- const name = (0, _packages.resolvePackageName)(artifact);
570
+ const name = packages.resolvePackageName(artifact);
849
571
  const id = `${name}@${artifact.version}`;
850
572
  let blocked = false;
851
573
  let displayWarning = false;
@@ -1282,12 +1004,12 @@ class SafeNode extends Node {
1282
1004
  // is based on https://github.com/npm/cli/pull/7025.
1283
1005
  //
1284
1006
  // If we prefer dedupe, or if the version is equal, take the other.
1285
- if (preferDedupe || _semver.eq(other.version, this.version)) {
1007
+ if (preferDedupe || semver.eq(other.version, this.version)) {
1286
1008
  return true;
1287
1009
  }
1288
1010
  // If our current version isn't the result of an override, then prefer to
1289
1011
  // take the greater version.
1290
- if (!this.overridden && _semver.gt(other.version, this.version)) {
1012
+ if (!this.overridden && semver.gt(other.version, this.version)) {
1291
1013
  return true;
1292
1014
  }
1293
1015
  return false;
@@ -1568,18 +1290,18 @@ class SafeOverrideSet extends OverrideSet {
1568
1290
  //
1569
1291
  // We need to use the rawSpec here, because the spec has the overrides
1570
1292
  // applied to it already.
1571
- let spec = _npmPackageArg(`${edge.name}@${edge.rawSpec}`);
1293
+ let spec = npa(`${edge.name}@${edge.rawSpec}`);
1572
1294
  if (spec.type === 'alias') {
1573
1295
  spec = spec.subSpec;
1574
1296
  }
1575
1297
  if (spec.type === 'git') {
1576
- if (spec.gitRange && rule.keySpec && _semver.intersects(spec.gitRange, rule.keySpec)) {
1298
+ if (spec.gitRange && rule.keySpec && semver.intersects(spec.gitRange, rule.keySpec)) {
1577
1299
  return rule;
1578
1300
  }
1579
1301
  continue;
1580
1302
  }
1581
1303
  if (spec.type === 'range' || spec.type === 'version') {
1582
- if (rule.keySpec && _semver.intersects(spec.fetchSpec, rule.keySpec)) {
1304
+ if (rule.keySpec && semver.intersects(spec.fetchSpec, rule.keySpec)) {
1583
1305
  return rule;
1584
1306
  }
1585
1307
  continue;
@@ -1676,7 +1398,7 @@ class SafeArborist extends Arborist {
1676
1398
  if (!alerts.length) {
1677
1399
  return true;
1678
1400
  }
1679
- return await (0, _prompts.confirm)({
1401
+ return await prompts.confirm({
1680
1402
  message: 'Accept risks of installing these packages?',
1681
1403
  default: false
1682
1404
  }, {
@@ -1697,7 +1419,6 @@ class SafeArborist extends Arborist {
1697
1419
  }
1698
1420
  }
1699
1421
  }
1700
- arborist.SafeArborist = SafeArborist;
1701
1422
  function installSafeArborist() {
1702
1423
  const cache = require.cache;
1703
1424
  cache[arboristClassPath] = {
@@ -1716,7 +1437,7 @@ function installSafeArborist() {
1716
1437
  void (async () => {
1717
1438
  const remoteSettings = await (async () => {
1718
1439
  try {
1719
- const socketSdk = await (0, _sdk.setupSdk)(pubToken);
1440
+ const socketSdk = await sdk.setupSdk(pubToken);
1720
1441
  const orgResult = await socketSdk.getOrganizations();
1721
1442
  if (!orgResult.success) {
1722
1443
  throw new Error(`Failed to fetch Socket organization info: ${orgResult.error.message}`);
@@ -1738,11 +1459,11 @@ void (async () => {
1738
1459
  settings: result.data
1739
1460
  };
1740
1461
  } catch (e) {
1741
- if ((0, _objects.isObject)(e) && 'cause' in e) {
1462
+ if (objects.isObject(e) && 'cause' in e) {
1742
1463
  const {
1743
1464
  cause
1744
1465
  } = e;
1745
- if ((0, _misc.isErrnoException)(cause)) {
1466
+ if (sdk.isErrnoException(cause)) {
1746
1467
  if (cause.code === 'ENOTFOUND' || cause.code === 'ECONNREFUSED') {
1747
1468
  throw new Error('Unable to connect to socket.dev, ensure internet connectivity before retrying', {
1748
1469
  cause: e
@@ -1757,7 +1478,7 @@ void (async () => {
1757
1478
  orgs,
1758
1479
  settings
1759
1480
  } = remoteSettings;
1760
- const enforcedOrgs = (0, _settings.getSetting)('enforcedOrgs') ?? [];
1481
+ const enforcedOrgs = sdk.getSetting('enforcedOrgs') ?? [];
1761
1482
 
1762
1483
  // Remove any organizations not being enforced.
1763
1484
  for (const {
@@ -1785,47 +1506,7 @@ void (async () => {
1785
1506
  }
1786
1507
  });
1787
1508
  }
1788
- _uxLookup = (0, _alertRules.createAlertUXLookup)(settings);
1509
+ _uxLookup = createAlertUXLookup(settings);
1789
1510
  })();
1790
1511
 
1791
- var _constants = constants.constants;
1792
- var _arborist = arborist;
1793
- var _link = link.link;
1794
- const {
1795
- shadowBinPath
1796
- } = _constants;
1797
-
1798
- // Shadow `npm` and `npx` to mitigate subshells.
1799
- (0, _link.installLinks)(shadowBinPath, 'npm');
1800
- (0, _arborist.installSafeArborist)();
1801
-
1802
- (function (exports) {
1803
-
1804
- var _interopRequireWildcard = vendor.interopRequireWildcard.default;
1805
- Object.defineProperty(exports, "__esModule", {
1806
- value: true
1807
- });
1808
- var _exportNames = {};
1809
- Object.defineProperty(exports, "default", {
1810
- enumerable: true,
1811
- get: function () {
1812
- return _npmInjection.default;
1813
- }
1814
- });
1815
- var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
1816
- Object.keys(_npmInjection).forEach(function (key) {
1817
- if (key === "default" || key === "__esModule") return;
1818
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
1819
- if (key in exports && exports[key] === _npmInjection[key]) return;
1820
- Object.defineProperty(exports, key, {
1821
- enumerable: true,
1822
- get: function () {
1823
- return _npmInjection[key];
1824
- }
1825
- });
1826
- });
1827
- } (npmInjection$2));
1828
-
1829
- var npmInjection = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmInjection$2);
1830
-
1831
- module.exports = npmInjection;
1512
+ installSafeArborist();