@socketsecurity/cli 0.14.33 → 0.14.35

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 (52) hide show
  1. package/bin/cli.js +34 -4
  2. package/bin/npm-cli.js +3 -4
  3. package/bin/npx-cli.js +3 -4
  4. package/dist/constants.js +59 -0
  5. package/dist/module-sync/cli.d.ts +0 -1
  6. package/dist/module-sync/cli.js +637 -1423
  7. package/dist/module-sync/constants.d.ts +24 -21
  8. package/dist/module-sync/constants.d.ts.map +1 -0
  9. package/dist/module-sync/constants.js +2 -79
  10. package/dist/module-sync/npm-injection.js +116 -436
  11. package/dist/module-sync/path-resolve.js +24 -45
  12. package/dist/module-sync/sdk.js +69 -118
  13. package/dist/module-sync/shadow-bin.d.ts +2 -0
  14. package/dist/module-sync/shadow-bin.js +109 -0
  15. package/dist/require/cli.js +633 -1418
  16. package/dist/require/constants.d.ts.map +1 -0
  17. package/dist/require/constants.js +2 -79
  18. package/dist/require/npm-injection.js +116 -435
  19. package/dist/require/path-resolve.js +24 -45
  20. package/dist/require/sdk.js +67 -115
  21. package/dist/require/shadow-bin.js +109 -0
  22. package/dist/require/vendor.js +8300 -8798
  23. package/package.json +39 -54
  24. package/shadow-bin/npm +4 -0
  25. package/shadow-bin/npx +4 -0
  26. package/bin/shadow/module-sync/npm +0 -3
  27. package/bin/shadow/module-sync/npx +0 -3
  28. package/bin/shadow/require/npm +0 -3
  29. package/bin/shadow/require/npx +0 -3
  30. package/dist/module-sync/cli.d.ts.map +0 -1
  31. package/dist/module-sync/link.d.ts +0 -2
  32. package/dist/module-sync/link.js +0 -57
  33. package/dist/module-sync/npm-cli.d.ts +0 -2
  34. package/dist/module-sync/npm-cli.js +0 -97
  35. package/dist/module-sync/npx-cli.d.ts +0 -2
  36. package/dist/module-sync/npx-cli.js +0 -73
  37. package/dist/module-sync/vendor.js +0 -82
  38. package/dist/require/cli.d.ts +0 -3
  39. package/dist/require/cli.d.ts.map +0 -1
  40. package/dist/require/color-or-markdown.d.ts +0 -23
  41. package/dist/require/constants.d.ts +0 -21
  42. package/dist/require/errors.d.ts +0 -7
  43. package/dist/require/link.d.ts +0 -2
  44. package/dist/require/link.js +0 -57
  45. package/dist/require/npm-cli.d.ts +0 -2
  46. package/dist/require/npm-cli.js +0 -97
  47. package/dist/require/npm-injection.d.ts +0 -1
  48. package/dist/require/npx-cli.d.ts +0 -2
  49. package/dist/require/npx-cli.js +0 -73
  50. package/dist/require/path-resolve.d.ts +0 -8
  51. package/dist/require/sdk.d.ts +0 -8
  52. package/dist/require/settings.d.ts +0 -9
@@ -1,309 +1,47 @@
1
1
  'use strict';
2
2
 
3
- function _interop(e) {
4
- let d
5
- if (e) {
6
- let c = 0
7
- for (const k in e) {
8
- d = c++ === 0 && k === 'default' ? e[k] : void 0
9
- if (!d) break
10
- }
3
+ function _socketInterop(e) {
4
+ let c = 0
5
+ for (const k in e ?? {}) {
6
+ c = c === 0 && k === 'default' ? 1 : 0
7
+ if (!c && k !== '__esModule') break
11
8
  }
12
- return d ?? e
9
+ return c ? e.default : e
13
10
  }
14
11
 
15
- var vendor = _interop(require('./vendor.js'));
16
- var constants = _interop(require('./constants.js'));
17
- var require$$1$3 = _interop(require('node:events'));
18
- var require$$0 = _interop(require('node:fs'));
19
- var require$$3$3 = _interop(require('node:https'));
20
- var require$$1 = _interop(require('node:path'));
21
- var require$$3 = _interop(require('node:readline'));
22
- var require$$6$2 = _interop(require('node:timers/promises'));
23
- var require$$1$2 = _interop(require('@inquirer/confirm'));
24
- var require$$3$2 = _interop(require('@socketregistry/yocto-spinner'));
25
- var require$$3$1 = _interop(require('is-interactive'));
26
- var require$$5$1 = _interop(require('npm-package-arg'));
27
- var require$$4 = _interop(require('semver'));
28
- var require$$6$1 = _interop(require('@socketsecurity/config'));
29
- var require$$7 = _interop(require('@socketsecurity/registry/lib/objects'));
30
- var require$$1$1 = _interop(require('node:net'));
31
- var require$$2 = _interop(require('node:os'));
32
- var require$$5 = _interop(require('node:stream'));
33
- var sdk = _interop(require('./sdk.js'));
34
- var pathResolve = _interop(require('./path-resolve.js'));
35
- var link = _interop(require('./link.js'));
36
-
37
- var npmInjection$2 = {};
38
-
39
- var npmInjection$1 = {};
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');
29
+ var sdk = require('./sdk.js');
30
+ var constants = require('./constants.js');
31
+ var pathResolve = require('./path-resolve.js');
40
32
 
41
- var arborist = {};
42
-
43
- var ttyServer$1 = {};
44
-
45
- var name = "@socketsecurity/cli";
46
- var version = "0.14.33";
47
- var description = "CLI tool for Socket.dev";
48
- var homepage = "http://github.com/SocketDev/socket-cli";
49
- var license = "MIT";
50
- var repository = {
51
- type: "git",
52
- url: "git+https://github.com/SocketDev/socket-cli.git"
53
- };
54
- var author = {
55
- name: "Socket Inc",
56
- email: "eng@socket.dev",
57
- url: "https://socket.dev"
58
- };
59
- var bin = {
60
- cli: "./bin/cli.js",
61
- socket: "./bin/cli.js",
62
- "socket-npm": "./bin/npm-cli.js",
63
- "socket-npx": "./bin/npx-cli.js"
64
- };
65
- var exports$1 = {
66
- "./bin/cli.js": {
67
- "module-sync": {
68
- types: "./dist/module-sync/cli.d.ts",
69
- "default": "./dist/module-sync/cli.js"
70
- },
71
- require: {
72
- types: "./dist/require/cli.d.ts",
73
- "default": "./dist/require/cli.js"
74
- }
75
- },
76
- "./bin/npm-cli.js": {
77
- "module-sync": {
78
- types: "./dist/module-sync/npm-cli.d.ts",
79
- "default": "./dist/module-sync/npm-cli.js"
80
- },
81
- require: {
82
- types: "./dist/require/npm-cli.d.ts",
83
- "default": "./dist/require/npm-cli.js"
84
- }
85
- },
86
- "./bin/npx-cli.js": {
87
- "module-sync": {
88
- types: "./dist/module-sync/npx-cli.d.ts",
89
- "default": "./dist/module-sync/npx-cli.js"
90
- },
91
- require: {
92
- types: "./dist/require/npx-cli.d.ts",
93
- "default": "./dist/require/npx-cli.js"
94
- }
95
- },
96
- "./package.json": "./package.json",
97
- "./translations.json": "./translations.json"
98
- };
99
- var scripts = {
100
- build: "run-s build:*",
101
- "build:dist": "rollup -c .config/rollup.dist.config.mjs",
102
- "build:test": "rollup -c .config/rollup.test.config.mjs",
103
- check: "run-p -c --aggregate-output check:*",
104
- "check:lint": "eslint --report-unused-disable-directives .",
105
- "check:tsc": "tsc",
106
- "check:type-coverage": "type-coverage --detail --strict --at-least 95 --ignore-files 'test/*'",
107
- "knip:dependencies": "knip --dependencies",
108
- "knip:exports": "knip --include exports,duplicates",
109
- lint: "oxlint -c=./.oxlintrc.json --ignore-path=./.prettierignore --tsconfig=./tsconfig.json .",
110
- "lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
111
- "lint:fix:fast": "prettier --cache --log-level warn --write .",
112
- prepare: "husky && custompatch",
113
- test: "run-s check build:* test:*",
114
- "test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
115
- "test-ci": "run-s build:* test:*",
116
- "test:unit": "tap-run",
117
- "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"
118
- };
119
- var dependencies = {
120
- "@apideck/better-ajv-errors": "^0.3.6",
121
- "@cyclonedx/cdxgen": "^11.0.5",
122
- "@inquirer/confirm": "^5.0.2",
123
- "@inquirer/password": "^4.0.3",
124
- "@inquirer/select": "^4.0.3",
125
- "@npmcli/promise-spawn": "^8.0.2",
126
- "@socketregistry/hyrious__bun.lockb": "1.0.5",
127
- "@socketregistry/yocto-spinner": "^1.0.1",
128
- "@socketsecurity/config": "^2.1.3",
129
- "@socketsecurity/registry": "^1.0.35",
130
- "@socketsecurity/sdk": "^1.3.0",
131
- blessed: "^0.1.81",
132
- "blessed-contrib": "^4.11.0",
133
- browserslist: "4.24.2",
134
- "chalk-table": "^1.0.2",
135
- "has-flag": "^4.0.0",
136
- hpagent: "^1.2.0",
137
- ignore: "^6.0.2",
138
- micromatch: "^4.0.8",
139
- "npm-package-arg": "^12.0.0",
140
- "pony-cause": "^2.1.11",
141
- semver: "^7.6.3",
142
- synp: "^1.9.14",
143
- tinyglobby: "^0.2.10",
144
- which: "^5.0.0",
145
- yaml: "^2.6.1",
146
- "yargs-parser": "^21.1.1",
147
- "yoctocolors-cjs": "^2.1.2"
148
- };
149
- var devDependencies = {
150
- "@babel/core": "^7.26.0",
151
- "@babel/plugin-proposal-export-default-from": "^7.25.9",
152
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
153
- "@babel/plugin-transform-export-namespace-from": "^7.25.9",
154
- "@babel/plugin-transform-modules-commonjs": "^7.26.3",
155
- "@babel/plugin-transform-runtime": "^7.25.9",
156
- "@babel/preset-env": "^7.26.0",
157
- "@babel/preset-typescript": "^7.26.0",
158
- "@babel/runtime": "^7.26.0",
159
- "@eslint/compat": "^1.2.4",
160
- "@eslint/js": "^9.16.0",
161
- "@rollup/plugin-commonjs": "^28.0.1",
162
- "@rollup/plugin-json": "^6.1.0",
163
- "@rollup/plugin-node-resolve": "^15.3.0",
164
- "@rollup/plugin-replace": "^6.0.1",
165
- "@rollup/pluginutils": "^5.1.3",
166
- "@tapjs/run": "^4.0.1",
167
- "@types/blessed": "^0.1.25",
168
- "@types/micromatch": "^4.0.9",
169
- "@types/mocha": "^10.0.10",
170
- "@types/mock-fs": "^4.13.4",
171
- "@types/node": "^22.10.1",
172
- "@types/npmcli__arborist": "^5.6.11",
173
- "@types/npmcli__promise-spawn": "^6.0.3",
174
- "@types/proc-log": "^3.0.4",
175
- "@types/semver": "^7.5.8",
176
- "@types/update-notifier": "^6.0.8",
177
- "@types/which": "^3.0.4",
178
- "@types/yargs-parser": "^21.0.3",
179
- "@typescript-eslint/eslint-plugin": "^8.17.0",
180
- "@typescript-eslint/parser": "^8.17.0",
181
- c8: "^10.1.2",
182
- custompatch: "^1.0.28",
183
- eslint: "^9.16.0",
184
- "eslint-import-resolver-oxc": "^0.6.0",
185
- "eslint-plugin-depend": "^0.12.0",
186
- "eslint-plugin-import-x": "^4.5.0",
187
- "eslint-plugin-n": "^17.14.0",
188
- "eslint-plugin-sort-destructure-keys": "^2.0.0",
189
- "eslint-plugin-unicorn": "^56.0.1",
190
- husky: "^9.1.7",
191
- "is-interactive": "^2.0.0",
192
- "is-unicode-supported": "^2.1.0",
193
- knip: "^5.39.2",
194
- "magic-string": "^0.30.14",
195
- meow: "^13.2.0",
196
- "mock-fs": "^5.4.1",
197
- nock: "^13.5.6",
198
- "npm-run-all2": "^7.0.1",
199
- open: "^10.1.0",
200
- oxlint: "0.14.1",
201
- prettier: "3.4.2",
202
- "read-package-up": "^11.0.0",
203
- rollup: "4.28.1",
204
- "rollup-plugin-ts": "^3.4.5",
205
- "terminal-link": "^3.0.0",
206
- "tiny-updater": "^3.5.2",
207
- "type-coverage": "^2.29.7",
208
- typescript: "5.4.5",
209
- "typescript-eslint": "^8.17.0",
210
- "unplugin-purge-polyfills": "^0.0.7"
211
- };
212
- var overrides = {
213
- "aggregate-error": "npm:@socketregistry/aggregate-error@^1",
214
- "es-define-property": "npm:@socketregistry/es-define-property@^1",
215
- "function-bind": "npm:@socketregistry/function-bind@^1",
216
- globalthis: "npm:@socketregistry/globalthis@^1",
217
- gopd: "npm:@socketregistry/gopd@^1",
218
- "has-property-descriptors": "npm:@socketregistry/has-property-descriptors@^1",
219
- "has-proto": "npm:@socketregistry/has-proto@^1",
220
- "has-symbols": "npm:@socketregistry/has-symbols@^1",
221
- hasown: "npm:@socketregistry/hasown@^1",
222
- "indent-string": "npm:@socketregistry/indent-string@^1",
223
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
224
- isarray: "npm:@socketregistry/isarray@^1",
225
- "npm-package-arg": "$npm-package-arg",
226
- "packageurl-js": "npm:@socketregistry/packageurl-js@^1",
227
- "path-parse": "npm:@socketregistry/path-parse@^1",
228
- "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
229
- "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
230
- semver: "$semver",
231
- "set-function-length": "npm:@socketregistry/set-function-length@^1",
232
- "side-channel": "npm:@socketregistry/side-channel@^1",
233
- yaml: "$yaml"
234
- };
235
- var resolutions = {
236
- "aggregate-error": "npm:@socketregistry/aggregate-error@^1",
237
- "es-define-property": "npm:@socketregistry/es-define-property@^1",
238
- "function-bind": "npm:@socketregistry/function-bind@^1",
239
- globalthis: "npm:@socketregistry/globalthis@^1",
240
- gopd: "npm:@socketregistry/gopd@^1",
241
- "has-property-descriptors": "npm:@socketregistry/has-property-descriptors@^1",
242
- "has-proto": "npm:@socketregistry/has-proto@^1",
243
- "has-symbols": "npm:@socketregistry/has-symbols@^1",
244
- hasown: "npm:@socketregistry/hasown@^1",
245
- "indent-string": "npm:@socketregistry/indent-string@^1",
246
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
247
- isarray: "npm:@socketregistry/isarray@^1",
248
- "npm-package-arg": "^12.0.0",
249
- "packageurl-js": "npm:@socketregistry/packageurl-js@^1",
250
- "path-parse": "npm:@socketregistry/path-parse@^1",
251
- "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
252
- "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
253
- semver: "^7.6.3",
254
- "set-function-length": "npm:@socketregistry/set-function-length@^1",
255
- "side-channel": "npm:@socketregistry/side-channel@^1",
256
- yaml: "^2.6.0"
257
- };
258
- var engines = {
259
- node: "^18.20.4 || ^20.9.0 || >=22.0.0"
260
- };
261
- var files = [
262
- "bin/**",
263
- "dist/**",
264
- "translations.json"
265
- ];
266
- var require$$6 = {
267
- name: name,
268
- version: version,
269
- description: description,
270
- homepage: homepage,
271
- license: license,
272
- repository: repository,
273
- author: author,
274
- bin: bin,
275
- exports: exports$1,
276
- scripts: scripts,
277
- dependencies: dependencies,
278
- devDependencies: devDependencies,
279
- overrides: overrides,
280
- resolutions: resolutions,
281
- engines: engines,
282
- files: files
283
- };
33
+ var version = "0.14.35";
284
34
 
285
- Object.defineProperty(ttyServer$1, "__esModule", {
286
- value: true
287
- });
288
- ttyServer$1.createTTYServer = createTTYServer;
289
- var _nodeFs$1 = require$$0;
290
- var _nodeNet = require$$1$1;
291
- var _nodeOs = require$$2;
292
- var _nodePath$1 = require$$1;
293
- var _nodeReadline$1 = require$$3;
294
- var _nodeStream = require$$5;
295
- var _package = require$$6;
296
- var _misc$1 = sdk.misc;
297
35
  const NEWLINE_CHAR_CODE = 10; /*'\n'*/
298
36
 
299
37
  const TTY_IPC = process.env['SOCKET_SECURITY_TTY_IPC'];
300
- 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`);
301
39
  process.env['SOCKET_SECURITY_TTY_IPC'] = sock;
302
40
  function createNonStandardTTYServer() {
303
41
  return {
304
42
  async captureTTY(mutexFn) {
305
43
  return await new Promise((resolve, reject) => {
306
- const conn = _nodeNet.createConnection({
44
+ const conn = net.createConnection({
307
45
  path: TTY_IPC
308
46
  }).on('error', reject);
309
47
  let captured = false;
@@ -323,26 +61,26 @@ function createNonStandardTTYServer() {
323
61
  output: hasOutput
324
62
  },
325
63
  ipc_version: remote_ipc_version
326
- } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf-8'));
64
+ } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf8'));
327
65
  lineBuff = null;
328
66
  captured = true;
329
- if (remote_ipc_version !== _package.version) {
67
+ if (remote_ipc_version !== version) {
330
68
  throw new Error('Mismatched STDIO tunnel IPC version, ensure you only have 1 version of socket CLI being called.');
331
69
  }
332
- const input = hasInput ? new _nodeStream.PassThrough() : null;
70
+ const input = hasInput ? new node_stream.PassThrough() : null;
333
71
  input?.pause();
334
72
  if (input) conn.pipe(input);
335
- const output = hasOutput ? new _nodeStream.PassThrough() : null;
73
+ const output = hasOutput ? new node_stream.PassThrough() : null;
336
74
  if (output) {
337
75
  output.pipe(conn)
338
76
  // Make ora happy
339
77
  ;
340
78
  output.isTTY = true;
341
79
  output.cursorTo = function cursorTo(x, y, callback) {
342
- _nodeReadline$1.cursorTo(this, x, y, callback);
80
+ readline.cursorTo(this, x, y, callback);
343
81
  };
344
82
  output.clearLine = function clearLine(dir, callback) {
345
- _nodeReadline$1.clearLine(this, dir, callback);
83
+ readline.clearLine(this, dir, callback);
346
84
  };
347
85
  }
348
86
  mutexFn(hasInput ? input : undefined, hasOutput ? output : undefined).then(resolve, reject).finally(() => {
@@ -365,7 +103,7 @@ function createIPCServer(captureState, npmlog) {
365
103
  const input = process.stdin;
366
104
  const output = process.stderr;
367
105
  return new Promise((resolve, reject) => {
368
- const server = _nodeNet
106
+ const server = net
369
107
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
370
108
  .createServer(async conn => {
371
109
  if (captureState.captured) {
@@ -385,7 +123,7 @@ function createIPCServer(captureState, npmlog) {
385
123
  npmlog.disableProgress();
386
124
  }
387
125
  conn.write(`${JSON.stringify({
388
- ipc_version: _package.version,
126
+ ipc_version: version,
389
127
  capabilities: {
390
128
  input: Boolean(input),
391
129
  output: true
@@ -470,9 +208,9 @@ function createStandardTTYServer(isInteractive, npmlog) {
470
208
  }
471
209
  function tryUnlinkSync(filepath) {
472
210
  try {
473
- (0, _nodeFs$1.unlinkSync)(filepath);
211
+ fs.unlinkSync(filepath);
474
212
  } catch (e) {
475
- if ((0, _misc$1.isErrnoException)(e) && e.code !== 'ENOENT') {
213
+ if (sdk.isErrnoException(e) && e.code !== 'ENOENT') {
476
214
  throw e;
477
215
  }
478
216
  }
@@ -481,12 +219,6 @@ function createTTYServer(isInteractive, npmlog) {
481
219
  return !isInteractive && TTY_IPC ? createNonStandardTTYServer() : createStandardTTYServer(isInteractive, npmlog);
482
220
  }
483
221
 
484
- var issueRules = {};
485
-
486
- Object.defineProperty(issueRules, "__esModule", {
487
- value: true
488
- });
489
- issueRules.createAlertUXLookup = createAlertUXLookup;
490
222
  //#region UX Constants
491
223
 
492
224
  const IGNORE_UX = {
@@ -509,7 +241,7 @@ const ERROR_UX = {
509
241
  * all issue rules and finds the first defined value that does not defer otherwise
510
242
  * uses the defaultValue. Takes the value and converts into a UX workflow
511
243
  */
512
- function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
244
+ function resolveAlertRuleUX(orderedRulesCollection, defaultValue) {
513
245
  if (defaultValue === true || defaultValue == null) {
514
246
  defaultValue = {
515
247
  action: 'error'
@@ -522,9 +254,9 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
522
254
  let block = false;
523
255
  let display = false;
524
256
  let needDefault = true;
525
- iterate_entries: for (const issueRuleArr of entriesOrderedIssueRules) {
526
- for (const rule of issueRuleArr) {
527
- if (issueRuleValueDoesNotDefer(rule)) {
257
+ iterate_entries: for (const rules of orderedRulesCollection) {
258
+ for (const rule of rules) {
259
+ if (ruleValueDoesNotDefer(rule)) {
528
260
  needDefault = false;
529
261
  const narrowingFilter = uxForDefinedNonDeferValue(rule);
530
262
  block = block || narrowingFilter.block;
@@ -550,13 +282,13 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
550
282
  /**
551
283
  * Negative form because it is narrowing the type
552
284
  */
553
- function issueRuleValueDoesNotDefer(issueRule) {
554
- if (issueRule === undefined) {
285
+ function ruleValueDoesNotDefer(rule) {
286
+ if (rule === undefined) {
555
287
  return false;
556
- } else if (issueRule !== null && typeof issueRule === 'object') {
288
+ } else if (rule !== null && typeof rule === 'object') {
557
289
  const {
558
290
  action
559
- } = issueRule;
291
+ } = rule;
560
292
  if (action === undefined || action === 'defer') {
561
293
  return false;
562
294
  }
@@ -567,13 +299,13 @@ function issueRuleValueDoesNotDefer(issueRule) {
567
299
  /**
568
300
  * Handles booleans for backwards compatibility
569
301
  */
570
- function uxForDefinedNonDeferValue(issueRuleValue) {
571
- if (typeof issueRuleValue === 'boolean') {
572
- return issueRuleValue ? ERROR_UX : IGNORE_UX;
302
+ function uxForDefinedNonDeferValue(ruleValue) {
303
+ if (typeof ruleValue === 'boolean') {
304
+ return ruleValue ? ERROR_UX : IGNORE_UX;
573
305
  }
574
306
  const {
575
307
  action
576
- } = issueRuleValue;
308
+ } = ruleValue;
577
309
  if (action === 'warn') {
578
310
  return WARN_UX;
579
311
  } else if (action === 'ignore') {
@@ -595,9 +327,9 @@ function createAlertUXLookup(settings) {
595
327
  if (ux) {
596
328
  return ux;
597
329
  }
598
- const entriesOrderedIssueRules = [];
330
+ const orderedRulesCollection = [];
599
331
  for (const settingsEntry of settings.entries) {
600
- const orderedIssueRules = [];
332
+ const orderedRules = [];
601
333
  let target = settingsEntry.start;
602
334
  while (target !== null) {
603
335
  const resolvedTarget = settingsEntry.settings[target];
@@ -606,11 +338,11 @@ function createAlertUXLookup(settings) {
606
338
  }
607
339
  const issueRuleValue = resolvedTarget.issueRules?.[type];
608
340
  if (typeof issueRuleValue !== 'undefined') {
609
- orderedIssueRules.push(issueRuleValue);
341
+ orderedRules.push(issueRuleValue);
610
342
  }
611
343
  target = resolvedTarget.deferTo ?? null;
612
344
  }
613
- entriesOrderedIssueRules.push(orderedIssueRules);
345
+ orderedRulesCollection.push(orderedRules);
614
346
  }
615
347
  const defaultValue = settings.defaults.issueRules[type];
616
348
  let resolvedDefaultValue = {
@@ -625,42 +357,27 @@ function createAlertUXLookup(settings) {
625
357
  action: defaultValue.action ?? 'error'
626
358
  };
627
359
  }
628
- ux = resolveIssueRuleUX(entriesOrderedIssueRules, resolvedDefaultValue);
360
+ ux = resolveAlertRuleUX(orderedRulesCollection, resolvedDefaultValue);
629
361
  cachedUX.set(type, ux);
630
362
  return ux;
631
363
  };
632
364
  }
365
+ //#endregion
633
366
 
634
- var _interopRequireDefault = vendor.interopRequireDefault.default;
635
- Object.defineProperty(arborist, "__esModule", {
636
- value: true
637
- });
638
- arborist.SafeArborist = void 0;
639
- arborist.installSafeArborist = installSafeArborist;
640
- var _nodeEvents = require$$1$3;
641
- var _nodeFs = require$$0;
642
- var _nodeHttps = require$$3$3;
643
- var _nodePath = require$$1;
644
- var _nodeReadline = require$$3;
645
- var _promises = require$$6$2;
646
- var _confirm = require$$1$2;
647
- var _yoctoSpinner = require$$3$2;
648
- var _isInteractive = _interopRequireDefault(require$$3$1);
649
- var _npmPackageArg = require$$5$1;
650
- var _semver = require$$4;
651
- var _config = require$$6$1;
652
- var _objects = require$$7;
653
- var _ttyServer = ttyServer$1;
654
- var _constants$1 = constants.constants;
655
- var _colorOrMarkdown = sdk.colorOrMarkdown;
656
- var _issueRules = issueRules;
657
- var _misc = sdk.misc;
658
- var _pathResolve = pathResolve.pathResolve;
659
- var _sdk = sdk.sdk;
660
- var _settings = sdk.settings;
661
- 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}.`;
662
- const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
663
- const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
367
+ const {
368
+ API_V0_URL,
369
+ ENV,
370
+ LOOP_SENTINEL,
371
+ NPM_REGISTRY_URL,
372
+ SOCKET_CLI_ISSUES_URL,
373
+ SOCKET_PUBLIC_API_KEY,
374
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
375
+ abortSignal,
376
+ rootPath
377
+ } = constants;
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}.`;
379
+ const npmEntrypoint = fs.realpathSync(process.argv[1]);
380
+ const npmRootPath = pathResolve.findRoot(path.dirname(npmEntrypoint));
664
381
  function tryRequire(...ids) {
665
382
  for (const data of ids) {
666
383
  let id;
@@ -685,32 +402,32 @@ function tryRequire(...ids) {
685
402
  }
686
403
  if (npmRootPath === undefined) {
687
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.
688
407
  process.exit(127);
689
408
  }
690
- const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
691
- const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
692
- const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
693
- const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
694
- const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
695
- const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
696
- const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
697
- 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'),
698
417
  // The proc-log DefinitelyTyped definition is incorrect. The type definition
699
418
  // is really that of its export log.
700
- mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
419
+ mod => mod.log], path.join(npmNmPath, 'npmlog/lib/log.js'));
701
420
  if (log === undefined) {
702
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.
703
424
  process.exit(127);
704
425
  }
705
- const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
426
+ const pacote = tryRequire(path.join(npmNmPath, 'pacote'), 'pacote');
706
427
  const {
707
428
  tarball
708
429
  } = pacote;
709
- const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
710
- const abortController = new AbortController();
711
- const {
712
- signal: abortSignal
713
- } = abortController;
430
+ const translations = require(path.join(rootPath, 'translations.json'));
714
431
  const Arborist = require(arboristClassPath);
715
432
  const depValid = require(arboristDepValidPath);
716
433
  const Edge = require(arboristEdgeClassPath);
@@ -718,23 +435,23 @@ const Node = require(arboristNodeClassPath);
718
435
  const OverrideSet = require(arboristOverrideSetClassPatch);
719
436
  const kCtorArgs = Symbol('ctorArgs');
720
437
  const kRiskyReify = Symbol('riskyReify');
721
- const formatter = new _colorOrMarkdown.ColorOrMarkdown(false);
722
- const pubToken = (0, _sdk.getDefaultKey)() ?? _constants$1.SOCKET_PUBLIC_API_KEY;
723
- 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({
724
441
  stream: process.stdin
725
442
  }), log);
726
443
  let _uxLookup;
727
444
  async function uxLookup(settings) {
728
445
  while (_uxLookup === undefined) {
729
446
  // eslint-disable-next-line no-await-in-loop
730
- await (0, _promises.setTimeout)(1, {
447
+ await promises.setTimeout(1, {
731
448
  signal: abortSignal
732
449
  });
733
450
  }
734
451
  return _uxLookup(settings);
735
452
  }
736
453
  async function* batchScan(pkgIds) {
737
- const req = _nodeHttps.request(`${_constants$1.API_V0_URL}/purl?alerts=true`, {
454
+ const req = https.request(`${API_V0_URL}/purl?alerts=true`, {
738
455
  method: 'POST',
739
456
  headers: {
740
457
  Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
@@ -747,12 +464,12 @@ async function* batchScan(pkgIds) {
747
464
  }));
748
465
  const {
749
466
  0: res
750
- } = await _nodeEvents.once(req, 'response');
467
+ } = await events.once(req, 'response');
751
468
  const ok = res.statusCode >= 200 && res.statusCode <= 299;
752
469
  if (!ok) {
753
470
  throw new Error(`Socket API Error: ${res.statusCode}`);
754
471
  }
755
- const rli = _nodeReadline.createInterface(res);
472
+ const rli = readline.createInterface(res);
756
473
  for await (const line of rli) {
757
474
  yield JSON.parse(line);
758
475
  }
@@ -770,24 +487,24 @@ function findSocketYmlSync() {
770
487
  let prevDir = null;
771
488
  let dir = process.cwd();
772
489
  while (dir !== prevDir) {
773
- let ymlPath = _nodePath.join(dir, 'socket.yml');
490
+ let ymlPath = path.join(dir, 'socket.yml');
774
491
  let yml = maybeReadfileSync(ymlPath);
775
492
  if (yml === undefined) {
776
- ymlPath = _nodePath.join(dir, 'socket.yaml');
493
+ ymlPath = path.join(dir, 'socket.yaml');
777
494
  yml = maybeReadfileSync(ymlPath);
778
495
  }
779
496
  if (typeof yml === 'string') {
780
497
  try {
781
498
  return {
782
499
  path: ymlPath,
783
- parsed: _config.parseSocketConfig(yml)
500
+ parsed: config.parseSocketConfig(yml)
784
501
  };
785
502
  } catch {
786
503
  throw new Error(`Found file but was unable to parse ${ymlPath}`);
787
504
  }
788
505
  }
789
506
  prevDir = dir;
790
- dir = _nodePath.join(dir, '..');
507
+ dir = path.join(dir, '..');
791
508
  }
792
509
  return null;
793
510
  }
@@ -824,12 +541,12 @@ function isAlertFixable(alert) {
824
541
  }
825
542
  function maybeReadfileSync(filepath) {
826
543
  try {
827
- return (0, _nodeFs.readFileSync)(filepath, 'utf8');
544
+ return fs.readFileSync(filepath, 'utf8');
828
545
  } catch {}
829
546
  return undefined;
830
547
  }
831
548
  async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
832
- const spinner = _yoctoSpinner({
549
+ const spinner = yoctoSpinner({
833
550
  stream: output
834
551
  });
835
552
  let {
@@ -850,7 +567,7 @@ async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
850
567
  const {
851
568
  version
852
569
  } = artifact;
853
- const name = `${artifact.namespace ? `${artifact.namespace}/` : ''}${artifact.name}`;
570
+ const name = packages.resolvePackageName(artifact);
854
571
  const id = `${name}@${artifact.version}`;
855
572
  let blocked = false;
856
573
  let displayWarning = false;
@@ -948,7 +665,7 @@ function walk(diff_, needInfoOn = []) {
948
665
  length: queueLength
949
666
  } = queue;
950
667
  while (pos < queueLength) {
951
- if (pos === _constants$1.LOOP_SENTINEL) {
668
+ if (pos === LOOP_SENTINEL) {
952
669
  throw new Error('Detected infinite loop while walking Arborist diff');
953
670
  }
954
671
  const diff = queue[pos++];
@@ -1287,12 +1004,12 @@ class SafeNode extends Node {
1287
1004
  // is based on https://github.com/npm/cli/pull/7025.
1288
1005
  //
1289
1006
  // If we prefer dedupe, or if the version is equal, take the other.
1290
- if (preferDedupe || _semver.eq(other.version, this.version)) {
1007
+ if (preferDedupe || semver.eq(other.version, this.version)) {
1291
1008
  return true;
1292
1009
  }
1293
1010
  // If our current version isn't the result of an override, then prefer to
1294
1011
  // take the greater version.
1295
- if (!this.overridden && _semver.gt(other.version, this.version)) {
1012
+ if (!this.overridden && semver.gt(other.version, this.version)) {
1296
1013
  return true;
1297
1014
  }
1298
1015
  return false;
@@ -1528,7 +1245,7 @@ class SafeOverrideSet extends OverrideSet {
1528
1245
  length: queueLength
1529
1246
  } = queue;
1530
1247
  while (pos < queueLength) {
1531
- if (pos === _constants$1.LOOP_SENTINEL) {
1248
+ if (pos === LOOP_SENTINEL) {
1532
1249
  throw new Error('Detected infinite loop while comparing override sets');
1533
1250
  }
1534
1251
  const {
@@ -1573,18 +1290,18 @@ class SafeOverrideSet extends OverrideSet {
1573
1290
  //
1574
1291
  // We need to use the rawSpec here, because the spec has the overrides
1575
1292
  // applied to it already.
1576
- let spec = _npmPackageArg(`${edge.name}@${edge.rawSpec}`);
1293
+ let spec = npa(`${edge.name}@${edge.rawSpec}`);
1577
1294
  if (spec.type === 'alias') {
1578
1295
  spec = spec.subSpec;
1579
1296
  }
1580
1297
  if (spec.type === 'git') {
1581
- if (spec.gitRange && rule.keySpec && _semver.intersects(spec.gitRange, rule.keySpec)) {
1298
+ if (spec.gitRange && rule.keySpec && semver.intersects(spec.gitRange, rule.keySpec)) {
1582
1299
  return rule;
1583
1300
  }
1584
1301
  continue;
1585
1302
  }
1586
1303
  if (spec.type === 'range' || spec.type === 'version') {
1587
- if (rule.keySpec && _semver.intersects(spec.fetchSpec, rule.keySpec)) {
1304
+ if (rule.keySpec && semver.intersects(spec.fetchSpec, rule.keySpec)) {
1588
1305
  return rule;
1589
1306
  }
1590
1307
  continue;
@@ -1670,10 +1387,10 @@ class SafeArborist extends Arborist {
1670
1387
  options['save'] = old.save;
1671
1388
  options['saveBundle'] = old.saveBundle;
1672
1389
  // Nothing to check, mmm already installed or all private?
1673
- if (diff.findIndex(c => c.repository_url === _constants$1.NPM_REGISTRY_URL) === -1) {
1390
+ if (diff.findIndex(c => c.repository_url === NPM_REGISTRY_URL) === -1) {
1674
1391
  return await this[kRiskyReify](...args);
1675
1392
  }
1676
- let proceed = _constants$1.ENV[_constants$1.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1393
+ let proceed = ENV[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1677
1394
  if (!proceed) {
1678
1395
  proceed = await ttyServer.captureTTY(async (input, output) => {
1679
1396
  if (input && output) {
@@ -1681,7 +1398,7 @@ class SafeArborist extends Arborist {
1681
1398
  if (!alerts.length) {
1682
1399
  return true;
1683
1400
  }
1684
- return await _confirm({
1401
+ return await prompts.confirm({
1685
1402
  message: 'Accept risks of installing these packages?',
1686
1403
  default: false
1687
1404
  }, {
@@ -1702,7 +1419,6 @@ class SafeArborist extends Arborist {
1702
1419
  }
1703
1420
  }
1704
1421
  }
1705
- arborist.SafeArborist = SafeArborist;
1706
1422
  function installSafeArborist() {
1707
1423
  const cache = require.cache;
1708
1424
  cache[arboristClassPath] = {
@@ -1721,7 +1437,7 @@ function installSafeArborist() {
1721
1437
  void (async () => {
1722
1438
  const remoteSettings = await (async () => {
1723
1439
  try {
1724
- const socketSdk = await (0, _sdk.setupSdk)(pubToken);
1440
+ const socketSdk = await sdk.setupSdk(pubToken);
1725
1441
  const orgResult = await socketSdk.getOrganizations();
1726
1442
  if (!orgResult.success) {
1727
1443
  throw new Error(`Failed to fetch Socket organization info: ${orgResult.error.message}`);
@@ -1743,11 +1459,11 @@ void (async () => {
1743
1459
  settings: result.data
1744
1460
  };
1745
1461
  } catch (e) {
1746
- if ((0, _objects.isObject)(e) && 'cause' in e) {
1462
+ if (objects.isObject(e) && 'cause' in e) {
1747
1463
  const {
1748
1464
  cause
1749
1465
  } = e;
1750
- if ((0, _misc.isErrnoException)(cause)) {
1466
+ if (sdk.isErrnoException(cause)) {
1751
1467
  if (cause.code === 'ENOTFOUND' || cause.code === 'ECONNREFUSED') {
1752
1468
  throw new Error('Unable to connect to socket.dev, ensure internet connectivity before retrying', {
1753
1469
  cause: e
@@ -1762,7 +1478,7 @@ void (async () => {
1762
1478
  orgs,
1763
1479
  settings
1764
1480
  } = remoteSettings;
1765
- const enforcedOrgs = (0, _settings.getSetting)('enforcedOrgs') ?? [];
1481
+ const enforcedOrgs = sdk.getSetting('enforcedOrgs') ?? [];
1766
1482
 
1767
1483
  // Remove any organizations not being enforced.
1768
1484
  for (const {
@@ -1790,43 +1506,7 @@ void (async () => {
1790
1506
  }
1791
1507
  });
1792
1508
  }
1793
- _uxLookup = (0, _issueRules.createAlertUXLookup)(settings);
1509
+ _uxLookup = createAlertUXLookup(settings);
1794
1510
  })();
1795
1511
 
1796
- var _constants = constants.constants;
1797
- var _arborist = arborist;
1798
- var _link = link.link;
1799
- // Shadow `npm` and `npx` to mitigate subshells.
1800
- (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
1801
- (0, _arborist.installSafeArborist)();
1802
-
1803
- (function (exports) {
1804
-
1805
- var _interopRequireWildcard = vendor.interopRequireWildcard.default;
1806
- Object.defineProperty(exports, "__esModule", {
1807
- value: true
1808
- });
1809
- var _exportNames = {};
1810
- Object.defineProperty(exports, "default", {
1811
- enumerable: true,
1812
- get: function () {
1813
- return _npmInjection.default;
1814
- }
1815
- });
1816
- var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
1817
- Object.keys(_npmInjection).forEach(function (key) {
1818
- if (key === "default" || key === "__esModule") return;
1819
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
1820
- if (key in exports && exports[key] === _npmInjection[key]) return;
1821
- Object.defineProperty(exports, key, {
1822
- enumerable: true,
1823
- get: function () {
1824
- return _npmInjection[key];
1825
- }
1826
- });
1827
- });
1828
- } (npmInjection$2));
1829
-
1830
- var npmInjection = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmInjection$2);
1831
-
1832
- module.exports = npmInjection;
1512
+ installSafeArborist();