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