@socketsecurity/cli-with-sentry 1.1.3 → 1.1.5

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 (111) hide show
  1. package/CHANGELOG.md +432 -0
  2. package/bin/cli.js +3 -1
  3. package/dist/cli.js +816 -688
  4. package/dist/cli.js.map +1 -1
  5. package/dist/constants.js +232 -19
  6. package/dist/constants.js.map +1 -1
  7. package/dist/flags.js +17 -11
  8. package/dist/flags.js.map +1 -1
  9. package/dist/instrument-with-sentry.js +8 -8
  10. package/dist/instrument-with-sentry.js.map +1 -1
  11. package/dist/shadow-npm-bin.js +14 -14
  12. package/dist/shadow-npm-bin.js.map +1 -1
  13. package/dist/shadow-npm-inject.js +16 -16
  14. package/dist/shadow-npm-inject.js.map +1 -1
  15. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  16. package/dist/types/commands/analytics/cmd-analytics.d.mts.map +1 -1
  17. package/dist/types/commands/analytics/handle-analytics.d.mts +6 -5
  18. package/dist/types/commands/analytics/handle-analytics.d.mts.map +1 -1
  19. package/dist/types/commands/analytics/output-analytics.d.mts +6 -5
  20. package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
  21. package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +1 -1
  22. package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
  23. package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
  24. package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
  25. package/dist/types/commands/fix/handle-fix.d.mts +1 -1
  26. package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
  27. package/dist/types/commands/fix/pull-request.d.mts +2 -2
  28. package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
  29. package/dist/types/commands/fix/types.d.mts +1 -4
  30. package/dist/types/commands/fix/types.d.mts.map +1 -1
  31. package/dist/types/commands/login/cmd-login.d.mts.map +1 -1
  32. package/dist/types/commands/npm/cmd-npm.d.mts +1 -1
  33. package/dist/types/commands/npm/cmd-npm.d.mts.map +1 -1
  34. package/dist/types/commands/optimize/add-overrides.d.mts.map +1 -1
  35. package/dist/types/commands/organization/fetch-organization-list.d.mts +1 -1
  36. package/dist/types/commands/organization/fetch-organization-list.d.mts.map +1 -1
  37. package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
  38. package/dist/types/commands/patch/handle-patch.d.mts +5 -4
  39. package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
  40. package/dist/types/commands/patch/output-patch-result.d.mts +1 -1
  41. package/dist/types/commands/patch/output-patch-result.d.mts.map +1 -1
  42. package/dist/types/commands/repository/cmd-repository-create.d.mts.map +1 -1
  43. package/dist/types/commands/repository/cmd-repository-del.d.mts.map +1 -1
  44. package/dist/types/commands/repository/cmd-repository-update.d.mts.map +1 -1
  45. package/dist/types/commands/repository/cmd-repository-view.d.mts.map +1 -1
  46. package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
  47. package/dist/types/commands/scan/cmd-scan-github.d.mts.map +1 -1
  48. package/dist/types/commands/scan/cmd-scan-list.d.mts.map +1 -1
  49. package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
  50. package/dist/types/commands/scan/cmd-scan-report.d.mts.map +1 -1
  51. package/dist/types/commands/scan/create-scan-from-github.d.mts.map +1 -1
  52. package/dist/types/commands/scan/generate-report.d.mts +9 -8
  53. package/dist/types/commands/scan/generate-report.d.mts.map +1 -1
  54. package/dist/types/commands/scan/handle-create-new-scan.d.mts +5 -2
  55. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
  56. package/dist/types/commands/scan/handle-scan-report.d.mts +7 -5
  57. package/dist/types/commands/scan/handle-scan-report.d.mts.map +1 -1
  58. package/dist/types/commands/scan/output-scan-report.d.mts +10 -8
  59. package/dist/types/commands/scan/output-scan-report.d.mts.map +1 -1
  60. package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
  61. package/dist/types/commands/scan/types.d.mts +3 -0
  62. package/dist/types/commands/scan/types.d.mts.map +1 -0
  63. package/dist/types/constants.d.mts +113 -46
  64. package/dist/types/constants.d.mts.map +1 -1
  65. package/dist/types/flags.d.mts.map +1 -1
  66. package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -17
  67. package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
  68. package/dist/types/shadow/npm/bin.d.mts +4 -3
  69. package/dist/types/shadow/npm/bin.d.mts.map +1 -1
  70. package/dist/types/utils/api.d.mts +8 -7
  71. package/dist/types/utils/api.d.mts.map +1 -1
  72. package/dist/types/utils/coana.d.mts.map +1 -1
  73. package/dist/types/utils/config.d.mts.map +1 -1
  74. package/dist/types/utils/ecosystem.d.mts.map +1 -1
  75. package/dist/types/utils/get-output-kind.d.mts.map +1 -1
  76. package/dist/types/utils/git.d.mts +1 -0
  77. package/dist/types/utils/git.d.mts.map +1 -1
  78. package/dist/types/utils/glob.d.mts.map +1 -1
  79. package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
  80. package/dist/types/utils/package-environment.d.mts.map +1 -1
  81. package/dist/types/utils/purl.d.mts +39 -8
  82. package/dist/types/utils/purl.d.mts.map +1 -1
  83. package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
  84. package/dist/types/utils/spec.d.mts +1 -1
  85. package/dist/types/utils/spec.d.mts.map +1 -1
  86. package/dist/utils.js +209 -163
  87. package/dist/utils.js.map +1 -1
  88. package/dist/vendor.js +596 -4972
  89. package/external/@socketsecurity/registry/lib/constants/env.js +0 -3
  90. package/external/@socketsecurity/registry/lib/constants/ext-cjs.js +3 -0
  91. package/external/@socketsecurity/registry/lib/constants/ext-cts.js +3 -0
  92. package/external/@socketsecurity/registry/lib/constants/ext-dts.js +3 -0
  93. package/external/@socketsecurity/registry/lib/constants/ext-js.js +3 -0
  94. package/external/@socketsecurity/registry/lib/constants/ext-json.js +3 -0
  95. package/external/@socketsecurity/registry/lib/constants/ext-lock.js +3 -0
  96. package/external/@socketsecurity/registry/lib/constants/ext-lockb.js +3 -0
  97. package/external/@socketsecurity/registry/lib/constants/ext-md.js +3 -0
  98. package/external/@socketsecurity/registry/lib/constants/ext-mjs.js +3 -0
  99. package/external/@socketsecurity/registry/lib/constants/ext-mts.js +3 -0
  100. package/external/@socketsecurity/registry/lib/constants/index.js +82 -83
  101. package/external/@socketsecurity/registry/lib/constants/ipc-promise.js +4 -5
  102. package/external/@socketsecurity/registry/lib/constants/node-debug-flags.js +9 -0
  103. package/external/@socketsecurity/registry/lib/constants/pnpm.js +3 -0
  104. package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +0 -1
  105. package/external/@socketsecurity/registry/lib/constants/yarn-lock.js +3 -0
  106. package/external/@socketsecurity/registry/lib/json.js +11 -0
  107. package/external/@socketsecurity/registry/lib/strings.js +16 -0
  108. package/package.json +17 -15
  109. package/external/@socketsecurity/registry/lib/constants/socket-public-api-key.js +0 -3
  110. package/external/@socketsecurity/registry/lib/constants/tap.js +0 -3
  111. /package/external/@socketsecurity/registry/lib/constants/{ipc.js → ipc-object.js} +0 -0
package/dist/utils.js CHANGED
@@ -5,13 +5,13 @@ var logger = require('../external/@socketsecurity/registry/lib/logger');
5
5
  var strings = require('../external/@socketsecurity/registry/lib/strings');
6
6
  var require$$9 = require('../external/@socketsecurity/registry/lib/debug');
7
7
  var require$$11 = require('../external/@socketsecurity/registry/lib/objects');
8
+ var constants = require('./constants.js');
8
9
  var arrays = require('../external/@socketsecurity/registry/lib/arrays');
9
10
  var path$1 = require('../external/@socketsecurity/registry/lib/path');
10
11
  var sorts = require('../external/@socketsecurity/registry/lib/sorts');
11
12
  var words = require('../external/@socketsecurity/registry/lib/words');
12
13
  var Module = require('node:module');
13
14
  var path = require('node:path');
14
- var constants = require('./constants.js');
15
15
  var flags = require('./flags.js');
16
16
  var regexps = require('../external/@socketsecurity/registry/lib/regexps');
17
17
  var prompts = require('../external/@socketsecurity/registry/lib/prompts');
@@ -36,7 +36,7 @@ function getConfigValues() {
36
36
  _cachedConfig = {};
37
37
  const {
38
38
  socketAppDataPath
39
- } = constants;
39
+ } = constants.default;
40
40
  if (socketAppDataPath) {
41
41
  const raw = fs.safeReadFileSync(socketAppDataPath);
42
42
  if (raw) {
@@ -130,7 +130,10 @@ function getConfigValueOrUndef(key) {
130
130
 
131
131
  // Ensure export because dist/utils.js is required in src/constants.mts.
132
132
  // eslint-disable-next-line n/exports-style
133
- exports.getConfigValueOrUndef = getConfigValueOrUndef;
133
+ if (typeof exports === 'object' && exports !== null) {
134
+ // eslint-disable-next-line n/exports-style
135
+ exports.getConfigValueOrUndef = getConfigValueOrUndef;
136
+ }
134
137
  function getSupportedConfigEntries() {
135
138
  return [...supportedConfigEntries];
136
139
  }
@@ -238,7 +241,7 @@ function updateConfigValue(configKey, value) {
238
241
  _pendingSave = false;
239
242
  const {
240
243
  socketAppDataPath
241
- } = constants;
244
+ } = constants.default;
242
245
  if (socketAppDataPath) {
243
246
  fs$1.writeFileSync(socketAppDataPath, Buffer.from(JSON.stringify(localConfig)).toString('base64'));
244
247
  }
@@ -257,13 +260,13 @@ const TOKEN_VISIBLE_LENGTH = 5;
257
260
 
258
261
  // The Socket API server that should be used for operations.
259
262
  function getDefaultApiBaseUrl$1() {
260
- const baseUrl = constants.ENV.SOCKET_CLI_API_BASE_URL || getConfigValueOrUndef('apiBaseUrl');
263
+ const baseUrl = constants.default.ENV.SOCKET_CLI_API_BASE_URL || getConfigValueOrUndef('apiBaseUrl');
261
264
  return isUrl(baseUrl) ? baseUrl : undefined;
262
265
  }
263
266
 
264
267
  // The Socket API server that should be used for operations.
265
268
  function getDefaultProxyUrl() {
266
- const apiProxy = constants.ENV.SOCKET_CLI_API_PROXY || getConfigValueOrUndef('apiProxy');
269
+ const apiProxy = constants.default.ENV.SOCKET_CLI_API_PROXY || getConfigValueOrUndef('apiProxy');
267
270
  return isUrl(apiProxy) ? apiProxy : undefined;
268
271
  }
269
272
  function isUrl(value) {
@@ -280,16 +283,16 @@ function isUrl(value) {
280
283
  // This Socket API token should be stored globally for the duration of the CLI execution.
281
284
  let _defaultToken;
282
285
  function getDefaultApiToken() {
283
- if (constants.ENV.SOCKET_CLI_NO_API_TOKEN) {
286
+ if (constants.default.ENV.SOCKET_CLI_NO_API_TOKEN) {
284
287
  _defaultToken = undefined;
285
288
  return _defaultToken;
286
289
  }
287
- const key = constants.ENV.SOCKET_CLI_API_TOKEN || getConfigValueOrUndef('apiToken') || _defaultToken;
290
+ const key = constants.default.ENV.SOCKET_CLI_API_TOKEN || getConfigValueOrUndef('apiToken') || _defaultToken;
288
291
  _defaultToken = strings.isNonEmptyString(key) ? key : undefined;
289
292
  return _defaultToken;
290
293
  }
291
294
  function getPublicApiToken() {
292
- return getDefaultApiToken() || constants.ENV.SOCKET_CLI_API_TOKEN || constants.SOCKET_PUBLIC_API_TOKEN;
295
+ return getDefaultApiToken() || constants.default.ENV.SOCKET_CLI_API_TOKEN || constants.default.SOCKET_PUBLIC_API_TOKEN;
293
296
  }
294
297
  function getVisibleTokenPrefix() {
295
298
  const apiToken = getDefaultApiToken();
@@ -336,11 +339,11 @@ async function setupSdk(options) {
336
339
  proxy: apiProxy
337
340
  }) : undefined,
338
341
  baseUrl: apiBaseUrl,
339
- timeout: constants.ENV.SOCKET_CLI_API_TIMEOUT,
342
+ timeout: constants.default.ENV.SOCKET_CLI_API_TIMEOUT,
340
343
  userAgent: vendor.distExports.createUserAgentFromPkgJson({
341
- name: constants.ENV.INLINED_SOCKET_CLI_NAME,
342
- version: constants.ENV.INLINED_SOCKET_CLI_VERSION,
343
- homepage: constants.ENV.INLINED_SOCKET_CLI_HOMEPAGE
344
+ name: constants.default.ENV.INLINED_SOCKET_CLI_NAME,
345
+ version: constants.default.ENV.INLINED_SOCKET_CLI_VERSION,
346
+ homepage: constants.default.ENV.INLINED_SOCKET_CLI_HOMEPAGE
344
347
  })
345
348
  })
346
349
  };
@@ -350,11 +353,11 @@ const NO_ERROR_MESSAGE = 'No error message returned';
350
353
 
351
354
  // The Socket API server that should be used for operations.
352
355
  function getDefaultApiBaseUrl() {
353
- const baseUrl = constants.ENV.SOCKET_CLI_API_BASE_URL || getConfigValueOrUndef('apiBaseUrl');
356
+ const baseUrl = constants.default.ENV.SOCKET_CLI_API_BASE_URL || getConfigValueOrUndef('apiBaseUrl');
354
357
  if (strings.isNonEmptyString(baseUrl)) {
355
358
  return baseUrl;
356
359
  }
357
- const API_V0_URL = constants.API_V0_URL;
360
+ const API_V0_URL = constants.default.API_V0_URL;
358
361
  return API_V0_URL;
359
362
  }
360
363
  async function getErrorMessageForHttpStatusCode(code) {
@@ -374,14 +377,14 @@ async function getErrorMessageForHttpStatusCode(code) {
374
377
  }
375
378
  async function handleApiCall(value, options) {
376
379
  const {
377
- desc,
380
+ description,
378
381
  spinner
379
382
  } = {
380
383
  __proto__: null,
381
384
  ...options
382
385
  };
383
- if (desc) {
384
- spinner?.start(`Requesting ${desc} from API...`);
386
+ if (description) {
387
+ spinner?.start(`Requesting ${description} from API...`);
385
388
  } else {
386
389
  spinner?.start();
387
390
  }
@@ -389,8 +392,8 @@ async function handleApiCall(value, options) {
389
392
  try {
390
393
  sdkResult = await value;
391
394
  spinner?.stop();
392
- if (desc) {
393
- const message = `Received Socket API response (after requesting ${desc}).`;
395
+ if (description) {
396
+ const message = `Received Socket API response (after requesting ${description}).`;
394
397
  if (sdkResult.success) {
395
398
  logger.logger.success(message);
396
399
  } else {
@@ -404,9 +407,9 @@ async function handleApiCall(value, options) {
404
407
  message: 'Socket API returned an error',
405
408
  cause: vendor.messageWithCauses(e)
406
409
  };
407
- if (desc) {
408
- logger.logger.fail(`An error was thrown while requesting ${desc}`);
409
- require$$9.debugFn('error', `caught: ${desc} error`);
410
+ if (description) {
411
+ logger.logger.fail(`An error was thrown while requesting ${description}`);
412
+ require$$9.debugFn('error', `caught: ${description} error`);
410
413
  } else {
411
414
  require$$9.debugFn('error', `caught: Socket API request error`);
412
415
  }
@@ -419,23 +422,23 @@ async function handleApiCall(value, options) {
419
422
 
420
423
  // Note: TS can't narrow down the type of result due to generics.
421
424
  if (sdkResult.success === false) {
422
- const errorResult = sdkResult;
423
- const message = `${errorResult.error || NO_ERROR_MESSAGE}`;
424
- const {
425
- cause: reason
426
- } = errorResult;
425
+ require$$9.debugFn('error', `fail:${description ? ` ${description}` : ''} bad response`);
426
+ require$$9.debugDir('inspect', {
427
+ sdkResult
428
+ });
429
+ const errCResult = sdkResult;
430
+ const errStr = errCResult.error ? String(errCResult.error).trim() : '';
431
+ const message = errStr || NO_ERROR_MESSAGE;
432
+ const reason = errCResult.cause || NO_ERROR_MESSAGE;
433
+ const cause = reason && message !== reason ? `${message} (reason: ${reason})` : message;
427
434
  const socketSdkErrorResult = {
428
435
  ok: false,
429
436
  message: 'Socket API returned an error',
430
- cause: `${message}${reason ? ` ( Reason: ${reason} )` : ''}`,
437
+ cause,
431
438
  data: {
432
439
  code: sdkResult.status
433
440
  }
434
441
  };
435
- require$$9.debugFn('error', `fail:${desc ? ` ${desc}` : ''} bad response`);
436
- require$$9.debugDir('inspect', {
437
- sdkResult
438
- });
439
442
  return socketSdkErrorResult;
440
443
  }
441
444
  const socketSdkSuccessResult = {
@@ -445,44 +448,47 @@ async function handleApiCall(value, options) {
445
448
  return socketSdkSuccessResult;
446
449
  }
447
450
  async function handleApiCallNoSpinner(value, description) {
448
- let result;
451
+ let sdkResult;
449
452
  try {
450
- result = await value;
453
+ sdkResult = await value;
451
454
  } catch (e) {
452
- const message = `${e || NO_ERROR_MESSAGE}`;
453
- const reason = `${e || NO_ERROR_MESSAGE}`;
454
455
  require$$9.debugFn('error', `caught: ${description} error`);
455
456
  require$$9.debugDir('inspect', {
456
457
  error: e
457
458
  });
459
+ const errStr = e ? String(e).trim() : '';
460
+ const cause = errStr || NO_ERROR_MESSAGE;
458
461
  return {
459
462
  ok: false,
460
463
  message: 'Socket API returned an error',
461
- cause: `${message}${reason ? ` ( Reason: ${reason} )` : ''}`
464
+ cause
462
465
  };
463
466
  }
464
467
 
465
468
  // Note: TS can't narrow down the type of result due to generics
466
- if (result.success === false) {
467
- const error = result;
468
- const message = `${error.error || NO_ERROR_MESSAGE}`;
469
+ if (sdkResult.success === false) {
469
470
  require$$9.debugFn('error', `fail: ${description} bad response`);
470
471
  require$$9.debugDir('inspect', {
471
- error
472
+ sdkResult
472
473
  });
474
+ const sdkErrorResult = sdkResult;
475
+ const errStr = sdkErrorResult.error ? String(sdkErrorResult.error).trim() : '';
476
+ const message = errStr || NO_ERROR_MESSAGE;
477
+ const reason = sdkErrorResult.cause || NO_ERROR_MESSAGE;
478
+ const cause = reason && message !== reason ? `${message} (reason: ${reason})` : message;
473
479
  return {
474
480
  ok: false,
475
481
  message: 'Socket API returned an error',
476
- cause: `${message}${error.cause ? ` ( Reason: ${error.cause} )` : ''}`,
482
+ cause,
477
483
  data: {
478
- code: result.status
484
+ code: sdkResult.status
479
485
  }
480
486
  };
481
487
  } else {
482
- const ok = result;
488
+ const sdkSuccessResult = sdkResult;
483
489
  return {
484
490
  ok: true,
485
- data: ok.data
491
+ data: sdkSuccessResult.data
486
492
  };
487
493
  }
488
494
  }
@@ -498,7 +504,7 @@ async function queryApi(path, apiToken) {
498
504
  }
499
505
  });
500
506
  }
501
- async function queryApiSafeText(path, desc) {
507
+ async function queryApiSafeText(path, description) {
502
508
  const apiToken = getDefaultApiToken();
503
509
  if (!apiToken) {
504
510
  return {
@@ -509,19 +515,19 @@ async function queryApiSafeText(path, desc) {
509
515
  }
510
516
  const {
511
517
  spinner
512
- } = constants;
513
- if (desc) {
514
- spinner.start(`Requesting ${desc} from API...`);
518
+ } = constants.default;
519
+ if (description) {
520
+ spinner.start(`Requesting ${description} from API...`);
515
521
  }
516
522
  let result;
517
523
  try {
518
524
  result = await queryApi(path, apiToken);
519
- if (desc) {
520
- spinner.successAndStop(`Received Socket API response (after requesting ${desc}).`);
525
+ if (description) {
526
+ spinner.successAndStop(`Received Socket API response (after requesting ${description}).`);
521
527
  }
522
528
  } catch (e) {
523
- if (desc) {
524
- spinner.failAndStop(`An error was thrown while requesting ${desc}.`);
529
+ if (description) {
530
+ spinner.failAndStop(`An error was thrown while requesting ${description}.`);
525
531
  }
526
532
  const cause = e?.message;
527
533
  require$$9.debugFn('error', 'caught: await queryApi() error');
@@ -562,8 +568,8 @@ async function queryApiSafeText(path, desc) {
562
568
  };
563
569
  }
564
570
  }
565
- async function queryApiSafeJson(path, desc = '') {
566
- const result = await queryApiSafeText(path, desc);
571
+ async function queryApiSafeJson(path, description = '') {
572
+ const result = await queryApiSafeText(path, description);
567
573
  if (!result.ok) {
568
574
  return result;
569
575
  }
@@ -593,34 +599,42 @@ async function sendApiRequest(path, options) {
593
599
  if (!baseUrl) {
594
600
  logger.logger.warn('API endpoint is not set and default was empty. Request is likely to fail.');
595
601
  }
602
+ const {
603
+ body,
604
+ description,
605
+ method
606
+ } = {
607
+ __proto__: null,
608
+ ...options
609
+ };
596
610
  const {
597
611
  spinner
598
- } = constants;
599
- if (options.desc) {
600
- spinner.start(`Requesting ${options.desc} from API...`);
612
+ } = constants.default;
613
+ if (description) {
614
+ spinner.start(`Requesting ${description} from API...`);
601
615
  }
602
616
  let result;
603
617
  try {
604
618
  const fetchOptions = {
605
- method: options.method,
619
+ method,
606
620
  headers: {
607
621
  Authorization: `Basic ${btoa(`${apiToken}:`)}`,
608
622
  'Content-Type': 'application/json'
609
623
  },
610
- ...(options.body ? {
611
- body: JSON.stringify(options.body)
624
+ ...(body ? {
625
+ body: JSON.stringify(body)
612
626
  } : {})
613
627
  };
614
628
  result = await fetch(`${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${path}`, fetchOptions);
615
- if (options.desc) {
616
- spinner.successAndStop(`Received Socket API response (after requesting ${options.desc}).`);
629
+ if (description) {
630
+ spinner.successAndStop(`Received Socket API response (after requesting ${description}).`);
617
631
  }
618
632
  } catch (e) {
619
- if (options.desc) {
620
- spinner.failAndStop(`An error was thrown while requesting ${options.desc}.`);
633
+ if (description) {
634
+ spinner.failAndStop(`An error was thrown while requesting ${description}.`);
621
635
  }
622
636
  const cause = e?.message;
623
- require$$9.debugFn('error', `caught: await fetch() ${options.method} error`);
637
+ require$$9.debugFn('error', `caught: await fetch() ${method} error`);
624
638
  require$$9.debugDir('inspect', {
625
639
  error: e
626
640
  });
@@ -675,14 +689,20 @@ function mdTableStringNumber(title1, title2, obj) {
675
689
  // | Paragraph | 18 |
676
690
  let mw1 = title1.length;
677
691
  let mw2 = title2.length;
678
- for (const [key, value] of Object.entries(obj)) {
692
+ for (const {
693
+ 0: key,
694
+ 1: value
695
+ } of Object.entries(obj)) {
679
696
  mw1 = Math.max(mw1, key.length);
680
697
  mw2 = Math.max(mw2, String(value ?? '').length);
681
698
  }
682
699
  const lines = [];
683
700
  lines.push(`| ${title1.padEnd(mw1, ' ')} | ${title2.padEnd(mw2)} |`);
684
701
  lines.push(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} |`);
685
- for (const [key, value] of Object.entries(obj)) {
702
+ for (const {
703
+ 0: key,
704
+ 1: value
705
+ } of Object.entries(obj)) {
686
706
  lines.push(`| ${key.padEnd(mw1, ' ')} | ${String(value ?? '').padStart(mw2, ' ')} |`);
687
707
  }
688
708
  lines.push(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} |`);
@@ -843,19 +863,19 @@ function checkCommandInput(outputKind, ...checks) {
843
863
 
844
864
  function getOutputKind(json, markdown) {
845
865
  if (json) {
846
- return 'json';
866
+ return constants.OUTPUT_JSON;
847
867
  }
848
868
  if (markdown) {
849
- return 'markdown';
869
+ return constants.OUTPUT_MARKDOWN;
850
870
  }
851
- return 'text';
871
+ return constants.OUTPUT_TEXT;
852
872
  }
853
873
 
854
874
  const require$2 = Module.createRequire(require('node:url').pathToFileURL(__filename).href);
855
875
  let _requirements;
856
876
  function getRequirements() {
857
877
  if (_requirements === undefined) {
858
- _requirements = /*@__PURE__*/require$2(path.join(constants.rootPath, 'requirements.json'));
878
+ _requirements = /*@__PURE__*/require$2(path.join(constants.default.rootPath, 'requirements.json'));
859
879
  }
860
880
  return _requirements;
861
881
  }
@@ -935,7 +955,7 @@ function getHelpListOutput(list, options) {
935
955
  // Replace the start of a path with ~/ when it starts with your home dir.
936
956
  // A common way to abbreviate the user home dir (though not strictly posix).
937
957
  function tildify(cwd) {
938
- return cwd.replace(new RegExp(`^${regexps.escapeRegExp(constants.homePath)}(?:${path.sep}|$)`, 'i'), '~/');
958
+ return cwd.replace(new RegExp(`^${regexps.escapeRegExp(constants.default.homePath)}(?:${path.sep}|$)`, 'i'), '~/');
939
959
  }
940
960
 
941
961
  // Property names are picked such that the name is at the top when the props
@@ -1100,17 +1120,17 @@ async function meowWithSubcommands(subcommands, options) {
1100
1120
  // The env var overrides the --flag, which overrides the persisted config
1101
1121
  // Also, when either of these are used, config updates won't persist.
1102
1122
  let configOverrideResult;
1103
- if (constants.ENV.SOCKET_CLI_CONFIG) {
1104
- configOverrideResult = overrideCachedConfig(constants.ENV.SOCKET_CLI_CONFIG);
1123
+ if (constants.default.ENV.SOCKET_CLI_CONFIG) {
1124
+ configOverrideResult = overrideCachedConfig(constants.default.ENV.SOCKET_CLI_CONFIG);
1105
1125
  } else if (cli1.flags['config']) {
1106
1126
  configOverrideResult = overrideCachedConfig(String(cli1.flags['config'] || ''));
1107
1127
  }
1108
- if (constants.ENV.SOCKET_CLI_NO_API_TOKEN) {
1128
+ if (constants.default.ENV.SOCKET_CLI_NO_API_TOKEN) {
1109
1129
  // This overrides the config override and even the explicit token env var.
1110
1130
  // The config will be marked as readOnly to prevent persisting it.
1111
1131
  overrideConfigApiToken(undefined);
1112
1132
  } else {
1113
- const tokenOverride = constants.ENV.SOCKET_CLI_API_TOKEN;
1133
+ const tokenOverride = constants.default.ENV.SOCKET_CLI_API_TOKEN;
1114
1134
  if (tokenOverride) {
1115
1135
  // This will set the token (even if there was a config override) and
1116
1136
  // set it to readOnly, making sure the temp token won't be persisted.
@@ -1161,7 +1181,7 @@ async function meowWithSubcommands(subcommands, options) {
1161
1181
  // "Bucket" some commands for easier usage.
1162
1182
  const commands = new Set(['analytics', 'audit-log', 'ci', 'cdxgen', 'config', 'dependencies', 'fix', 'install',
1163
1183
  //'json',
1164
- 'license', 'login', 'logout', 'manifest', 'npm', 'npx', 'optimize', 'organization', 'package',
1184
+ 'license', 'login', 'logout', 'manifest', constants.NPM, constants.NPX, 'optimize', 'organization', 'package',
1165
1185
  //'patch',
1166
1186
  'raw-npm', 'raw-npx', 'repository', 'scan',
1167
1187
  //'security',
@@ -1179,7 +1199,7 @@ async function meowWithSubcommands(subcommands, options) {
1179
1199
  // test snapshots we use joinAnd.
1180
1200
  arrays.joinAnd(Array.from(commands).sort(sorts.naturalCompare).map(c => `'${c}'`)));
1181
1201
  }
1182
- lines.push('Note: All commands have their own --help', '', 'Main commands', ` socket login ${description(subcommands['login'])}`, ` socket scan create Create a new Socket scan and report`, ` socket npm/lodash@4.17.21 Request the Socket score of a package`, ` socket ci ${description(subcommands['ci'])}`, ``, 'Socket API', ` analytics ${description(subcommands['analytics'])}`, ` audit-log ${description(subcommands['audit-log'])}`, ` organization ${description(subcommands['organization'])}`, ` package ${description(subcommands['package'])}`, ` repository ${description(subcommands['repository'])}`, ` scan ${description(subcommands['scan'])}`, ` threat-feed ${description(subcommands['threat-feed'])}`, ``, 'Local tools', ` fix ${description(subcommands['fix'])}`, ` manifest ${description(subcommands['manifest'])}`, ` npm ${description(subcommands['npm'])}`, ` npx ${description(subcommands['npx'])}`, ` optimize ${description(subcommands['optimize'])}`, ` raw-npm ${description(subcommands['raw-npm'])}`, ` raw-npx ${description(subcommands['raw-npx'])}`, '', 'CLI configuration', ` config ${description(subcommands['config'])}`, ` install ${description(subcommands['install'])}`, ` login Socket API login and CLI setup`, ` logout ${description(subcommands['logout'])}`, ` uninstall ${description(subcommands['uninstall'])}`, ` wrapper ${description(subcommands['wrapper'])}`);
1202
+ lines.push('Note: All commands have their own --help', '', 'Main commands', ` socket login ${description(subcommands['login'])}`, ` socket scan create Create a new Socket scan and report`, ` socket npm/lodash@4.17.21 Request the Socket score of a package`, ` socket ci ${description(subcommands['ci'])}`, ``, 'Socket API', ` analytics ${description(subcommands['analytics'])}`, ` audit-log ${description(subcommands['audit-log'])}`, ` organization ${description(subcommands['organization'])}`, ` package ${description(subcommands['package'])}`, ` repository ${description(subcommands['repository'])}`, ` scan ${description(subcommands['scan'])}`, ` threat-feed ${description(subcommands['threat-feed'])}`, ``, 'Local tools', ` fix ${description(subcommands['fix'])}`, ` manifest ${description(subcommands['manifest'])}`, ` npm ${description(subcommands[constants.NPM])}`, ` npx ${description(subcommands[constants.NPX])}`, ` optimize ${description(subcommands['optimize'])}`, ` raw-npm ${description(subcommands['raw-npm'])}`, ` raw-npx ${description(subcommands['raw-npx'])}`, '', 'CLI configuration', ` config ${description(subcommands['config'])}`, ` install ${description(subcommands['install'])}`, ` login Socket API login and CLI setup`, ` logout ${description(subcommands['logout'])}`, ` uninstall ${description(subcommands['uninstall'])}`, ` wrapper ${description(subcommands['wrapper'])}`);
1183
1203
  } else {
1184
1204
  lines.push('Commands');
1185
1205
  lines.push(` ${getHelpListOutput({
@@ -1241,7 +1261,7 @@ async function meowWithSubcommands(subcommands, options) {
1241
1261
  }
1242
1262
  if (!cli2.flags['help'] && cli2.flags['dryRun']) {
1243
1263
  process.exitCode = 0;
1244
- logger.logger.log(`${constants.DRY_RUN_LABEL}: No-op, call a sub-command; ok`);
1264
+ logger.logger.log(`${constants.default.DRY_RUN_LABEL}: No-op, call a sub-command; ok`);
1245
1265
  } else {
1246
1266
  // When you explicitly request --help, the command should be successful
1247
1267
  // so we exit(0). If we do it because we need more input, we exit(2).
@@ -1276,7 +1296,8 @@ function meowOrExit({
1276
1296
  importMeta
1277
1297
  });
1278
1298
  if (!shouldSuppressBanner(cli.flags)) {
1279
- emitBanner(command, String(cli.flags['org'] || '') || undefined);
1299
+ const orgFlag = String(cli.flags['org'] || '').trim() || undefined;
1300
+ emitBanner(command, orgFlag);
1280
1301
  // Add newline in stderr.
1281
1302
  // Meow help adds a newline too so we do it here.
1282
1303
  logger.logger.error('');
@@ -1304,15 +1325,15 @@ function meowOrExit({
1304
1325
  cli.showHelp(0);
1305
1326
  }
1306
1327
 
1307
- // meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
1328
+ // Meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
1308
1329
  if (!require$$11.hasOwn(config.flags, 'version') && cli.flags['version']) {
1309
- // Use `console.error` here instead of `logger.error` to match meow behavior.
1330
+ // Use `console.error` here instead of `logger.error` to match Meow behavior.
1310
1331
  console.error('Unknown flag\n--version');
1311
1332
  // eslint-disable-next-line n/no-process-exit
1312
1333
  process.exit(2);
1313
1334
  }
1314
1335
 
1315
- // Now test for help state. Run meow again. If it exits now, it must be due
1336
+ // Now test for help state. Run Meow again. If it exits now, it must be due
1316
1337
  // to wanting to print the help screen. But it would exit(0) and we want a
1317
1338
  // consistent exit(2) for that case (missing input).
1318
1339
  // TODO: Move away from meow.
@@ -1349,9 +1370,9 @@ function getAsciiHeader(command, orgFlag) {
1349
1370
  // Note: In tests we return <redacted> because otherwise snapshots will fail.
1350
1371
  const {
1351
1372
  REDACTED
1352
- } = constants;
1353
- const redacting = constants.ENV.VITEST;
1354
- const cliVersion = redacting ? REDACTED : constants.ENV.INLINED_SOCKET_CLI_VERSION_HASH;
1373
+ } = constants.default;
1374
+ const redacting = constants.default.ENV.VITEST;
1375
+ const cliVersion = redacting ? REDACTED : constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH;
1355
1376
  const nodeVersion = redacting ? REDACTED : process.version;
1356
1377
  const defaultOrg = getConfigValueOrUndef('defaultOrg');
1357
1378
  const readOnlyConfig = isReadOnlyConfig() ? '*' : '.';
@@ -1396,7 +1417,7 @@ function msAtHome(isoTimeStamp) {
1396
1417
 
1397
1418
  async function fetchOrganization(options) {
1398
1419
  const {
1399
- desc = 'organization list',
1420
+ description = 'organization list',
1400
1421
  sdk,
1401
1422
  sdkOpts
1402
1423
  } = {
@@ -1412,7 +1433,7 @@ async function fetchOrganization(options) {
1412
1433
  sockSdk = sockSdkCResult.data;
1413
1434
  }
1414
1435
  const orgsCResult = await handleApiCall(sockSdk.getOrganizations(), {
1415
- desc
1436
+ description
1416
1437
  });
1417
1438
  if (!orgsCResult.ok) {
1418
1439
  return orgsCResult;
@@ -1542,7 +1563,7 @@ async function getDefaultOrgSlug() {
1542
1563
  data: defaultOrgResult
1543
1564
  };
1544
1565
  }
1545
- const envOrgSlug = constants.ENV.SOCKET_CLI_ORG_SLUG;
1566
+ const envOrgSlug = constants.default.ENV.SOCKET_CLI_ORG_SLUG;
1546
1567
  if (envOrgSlug) {
1547
1568
  require$$9.debugFn('notice', 'use: org from SOCKET_CLI_ORG_SLUG environment variable', envOrgSlug);
1548
1569
  return {
@@ -1598,7 +1619,7 @@ async function getBaseBranch(cwd = process.cwd()) {
1598
1619
  GITHUB_BASE_REF,
1599
1620
  GITHUB_REF_NAME,
1600
1621
  GITHUB_REF_TYPE
1601
- } = constants.ENV;
1622
+ } = constants.default.ENV;
1602
1623
  // 1. In a pull request, this is always the base branch.
1603
1624
  if (GITHUB_BASE_REF) {
1604
1625
  return GITHUB_BASE_REF;
@@ -1647,7 +1668,7 @@ async function getRepoInfo(cwd = process.cwd()) {
1647
1668
  }
1648
1669
  async function getRepoName(cwd = process.cwd()) {
1649
1670
  const repoInfo = await getRepoInfo(cwd);
1650
- return repoInfo?.repo ?? constants.SOCKET_DEFAULT_REPOSITORY;
1671
+ return repoInfo?.repo ?? constants.default.SOCKET_DEFAULT_REPOSITORY;
1651
1672
  }
1652
1673
  async function gitBranch(cwd = process.cwd()) {
1653
1674
  const stdioPipeOptions = {
@@ -1711,7 +1732,7 @@ async function detectDefaultBranch(cwd = process.cwd()) {
1711
1732
  return branch;
1712
1733
  }
1713
1734
  }
1714
- return constants.SOCKET_DEFAULT_BRANCH;
1735
+ return constants.default.SOCKET_DEFAULT_BRANCH;
1715
1736
  }
1716
1737
  async function gitCleanFdx(cwd = process.cwd()) {
1717
1738
  const stdioIgnoreOptions = {
@@ -1798,8 +1819,8 @@ async function gitCommit(commitMsg, filepaths, options) {
1798
1819
  }
1799
1820
  const {
1800
1821
  cwd = process.cwd(),
1801
- email = constants.ENV.SOCKET_CLI_GIT_USER_EMAIL,
1802
- user = constants.ENV.SOCKET_CLI_GIT_USER_NAME
1822
+ email = constants.default.ENV.SOCKET_CLI_GIT_USER_EMAIL,
1823
+ user = constants.default.ENV.SOCKET_CLI_GIT_USER_NAME
1803
1824
  } = {
1804
1825
  __proto__: null,
1805
1826
  ...options
@@ -2038,8 +2059,25 @@ function parseGitRemoteUrl(remoteUrl) {
2038
2059
  } : result;
2039
2060
  }
2040
2061
 
2041
- function getPurlObject(purl) {
2042
- return typeof purl === 'string' ? vendor.packageurlJsExports.PackageURL.fromString(purl) : purl;
2062
+ function getPurlObject(purl, options) {
2063
+ const {
2064
+ throws
2065
+ } = {
2066
+ __proto__: null,
2067
+ ...options
2068
+ };
2069
+ const shouldThrow = throws === undefined || !!throws;
2070
+ try {
2071
+ return typeof purl === 'string' ? vendor.packageurlJsExports.PackageURL.fromString(normalizePurl(purl)) : purl;
2072
+ } catch (e) {
2073
+ if (shouldThrow) {
2074
+ throw e;
2075
+ }
2076
+ return null;
2077
+ }
2078
+ }
2079
+ function normalizePurl(rawPurl) {
2080
+ return rawPurl.startsWith('pkg:') ? rawPurl : `pkg:${rawPurl}`;
2043
2081
  }
2044
2082
 
2045
2083
  function getPkgFullNameFromPurl(purl) {
@@ -2056,7 +2094,7 @@ function getSocketDevPackageOverviewUrlFromPurl(purl) {
2056
2094
  return getSocketDevPackageOverviewUrl(purlObj.type, fullName, purlObj.version);
2057
2095
  }
2058
2096
  function getSocketDevPackageOverviewUrl(ecosystem, fullName, version) {
2059
- const url = `${constants.SOCKET_WEBSITE_URL}/${ecosystem}/package/${fullName}`;
2097
+ const url = `${constants.default.SOCKET_WEBSITE_URL}/${ecosystem}/package/${fullName}`;
2060
2098
  return ecosystem === 'golang' ? `${url}${version ? `?section=overview&version=${version}` : ''}` : `${url}${version ? `/overview/${version}` : ''}`;
2061
2099
  }
2062
2100
 
@@ -2069,7 +2107,10 @@ function mapToObject(map) {
2069
2107
  }
2070
2108
 
2071
2109
  function* walkNestedMap(map, keys = []) {
2072
- for (const [key, value] of map.entries()) {
2110
+ for (const {
2111
+ 0: key,
2112
+ 1: value
2113
+ } of map.entries()) {
2073
2114
  if (value instanceof Map) {
2074
2115
  yield* walkNestedMap(value, [...keys, key]);
2075
2116
  } else {
@@ -2099,7 +2140,7 @@ const IGNORED_DIRS = [
2099
2140
  // Where Bower packages are installed, see <http://bower.io/>
2100
2141
  'coverage',
2101
2142
  // Standard output directory for code coverage reports, see <https://github.com/gotwarlost/istanbul>
2102
- 'node_modules',
2143
+ constants.NODE_MODULES,
2103
2144
  // Where Node modules are installed, see <https://nodejs.org/>
2104
2145
  // Taken from globby:
2105
2146
  // https://github.com/sindresorhus/globby/blob/v14.0.2/ignore.js#L11-L16
@@ -2107,7 +2148,7 @@ const IGNORED_DIRS = [
2107
2148
  const IGNORED_DIR_PATTERNS = IGNORED_DIRS.map(i => `**/${i}`);
2108
2149
  async function getWorkspaceGlobs(agent, cwd = process.cwd()) {
2109
2150
  let workspacePatterns;
2110
- if (agent === 'pnpm') {
2151
+ if (agent === constants.PNPM) {
2111
2152
  for (const workspacePath of [path.join(cwd, 'pnpm-workspace.yaml'), path.join(cwd, 'pnpm-workspace.yml')]) {
2112
2153
  // eslint-disable-next-line no-await-in-loop
2113
2154
  const yml = await fs.safeReadFile(workspacePath);
@@ -2289,7 +2330,7 @@ function findBinPathDetailsSync(binName) {
2289
2330
  }) ?? [];
2290
2331
  const {
2291
2332
  shadowBinPath
2292
- } = constants;
2333
+ } = constants.default;
2293
2334
  let shadowIndex = -1;
2294
2335
  let theBinPath;
2295
2336
  for (let i = 0, {
@@ -2313,10 +2354,10 @@ function findBinPathDetailsSync(binName) {
2313
2354
  function findNpmDirPathSync(npmBinPath) {
2314
2355
  const {
2315
2356
  WIN32
2316
- } = constants;
2357
+ } = constants.default;
2317
2358
  let thePath = npmBinPath;
2318
2359
  while (true) {
2319
- const libNmNpmPath = path.join(thePath, 'lib/node_modules/npm');
2360
+ const libNmNpmPath = path.join(thePath, `lib/${constants.NODE_MODULES}/${constants.NPM}`);
2320
2361
  // mise, which uses opaque binaries, puts its npm bin in a path like:
2321
2362
  // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/bin/npm.
2322
2363
  // HOWEVER, the location of the npm install is:
@@ -2328,8 +2369,8 @@ function findNpmDirPathSync(npmBinPath) {
2328
2369
  fs.isDirSync(libNmNpmPath)) {
2329
2370
  thePath = libNmNpmPath;
2330
2371
  }
2331
- const hasNmInCurrPath = fs.isDirSync(path.join(thePath, 'node_modules'));
2332
- const hasNmInParentPath = !hasNmInCurrPath && fs.isDirSync(path.join(thePath, '../node_modules'));
2372
+ const hasNmInCurrPath = fs.isDirSync(path.join(thePath, constants.NODE_MODULES));
2373
+ const hasNmInParentPath = !hasNmInCurrPath && fs.isDirSync(path.join(thePath, `../${constants.NODE_MODULES}`));
2333
2374
  if (
2334
2375
  // npm bin paths may look like:
2335
2376
  // /usr/local/share/npm/bin/npm
@@ -2345,9 +2386,9 @@ function findNpmDirPathSync(npmBinPath) {
2345
2386
  // In some bespoke cases the node_modules folder is in the parent directory.
2346
2387
  hasNmInParentPath) && (
2347
2388
  // Optimistically look for the default location.
2348
- path.basename(thePath) === 'npm' ||
2389
+ path.basename(thePath) === constants.NPM ||
2349
2390
  // Chocolatey installs npm bins in the same directory as node bins.
2350
- WIN32 && fs$1.existsSync(path.join(thePath, 'npm.cmd')))) {
2391
+ WIN32 && fs$1.existsSync(path.join(thePath, `${constants.NPM}.cmd`)))) {
2351
2392
  return hasNmInParentPath ? path.dirname(thePath) : thePath;
2352
2393
  }
2353
2394
  const parent = path.dirname(thePath);
@@ -2384,7 +2425,7 @@ function getNpmBinPath() {
2384
2425
  if (_npmBinPath === undefined) {
2385
2426
  _npmBinPath = getNpmBinPathDetails().path;
2386
2427
  if (!_npmBinPath) {
2387
- exitWithBinPathError('npm');
2428
+ exitWithBinPathError(constants.NPM);
2388
2429
  }
2389
2430
  }
2390
2431
  return _npmBinPath;
@@ -2392,7 +2433,7 @@ function getNpmBinPath() {
2392
2433
  let _npmBinPathDetails;
2393
2434
  function getNpmBinPathDetails() {
2394
2435
  if (_npmBinPathDetails === undefined) {
2395
- _npmBinPathDetails = findBinPathDetailsSync('npm');
2436
+ _npmBinPathDetails = findBinPathDetailsSync(constants.NPM);
2396
2437
  }
2397
2438
  return _npmBinPathDetails;
2398
2439
  }
@@ -2402,7 +2443,7 @@ function getNpmDirPath() {
2402
2443
  const npmBinPath = getNpmBinPath();
2403
2444
  _npmDirPath = npmBinPath ? findNpmDirPathSync(npmBinPath) : undefined;
2404
2445
  if (!_npmDirPath) {
2405
- _npmDirPath = constants.ENV.SOCKET_CLI_NPM_PATH || undefined;
2446
+ _npmDirPath = constants.default.ENV.SOCKET_CLI_NPM_PATH || undefined;
2406
2447
  }
2407
2448
  if (!_npmDirPath) {
2408
2449
  let message = 'Unable to find npm CLI install directory.';
@@ -2410,7 +2451,7 @@ function getNpmDirPath() {
2410
2451
  message += `\nSearched parent directories of ${path.dirname(npmBinPath)}.`;
2411
2452
  }
2412
2453
  message += '\n\nThis is may be a bug with socket-npm related to changes to the npm CLI.';
2413
- message += `\nPlease report to ${constants.SOCKET_CLI_ISSUES_URL}.`;
2454
+ message += `\nPlease report to ${constants.default.SOCKET_CLI_ISSUES_URL}.`;
2414
2455
  logger.logger.fail(message);
2415
2456
  // The exit code 127 indicates that the command or binary being executed
2416
2457
  // could not be found.
@@ -2424,7 +2465,7 @@ let _npmRequire;
2424
2465
  function getNpmRequire() {
2425
2466
  if (_npmRequire === undefined) {
2426
2467
  const npmDirPath = getNpmDirPath();
2427
- const npmNmPath = path.join(npmDirPath, 'node_modules/npm');
2468
+ const npmNmPath = path.join(npmDirPath, `${constants.NODE_MODULES}/npm`);
2428
2469
  _npmRequire = Module.createRequire(path.join(fs$1.existsSync(npmNmPath) ? npmNmPath : npmDirPath, '<dummy-basename>'));
2429
2470
  }
2430
2471
  return _npmRequire;
@@ -2495,7 +2536,7 @@ async function findUp(name, options) {
2495
2536
  };
2496
2537
  const {
2497
2538
  cwd = process.cwd(),
2498
- signal = constants.abortSignal
2539
+ signal = constants.default.abortSignal
2499
2540
  } = opts;
2500
2541
  let {
2501
2542
  onlyDirectories = false,
@@ -2551,7 +2592,7 @@ async function spawnCoana(args, orgSlug, options, extra) {
2551
2592
  ...options
2552
2593
  };
2553
2594
  const mixinsEnv = {
2554
- SOCKET_CLI_VERSION: constants.ENV.INLINED_SOCKET_CLI_VERSION
2595
+ SOCKET_CLI_VERSION: constants.default.ENV.INLINED_SOCKET_CLI_VERSION
2555
2596
  };
2556
2597
  const defaultApiToken = getDefaultApiToken();
2557
2598
  if (defaultApiToken) {
@@ -2568,16 +2609,18 @@ async function spawnCoana(args, orgSlug, options, extra) {
2568
2609
  try {
2569
2610
  const {
2570
2611
  spawnPromise
2571
- } = await shadowNpmBin('npx', ['--yes', `@coana-tech/cli@~${constants.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION}`, ...args], {
2612
+ } = await shadowNpmBin('npx', ['--yes', `@coana-tech/cli@~${constants.default.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION}`, ...args], {
2572
2613
  ...spawnOpts,
2573
2614
  env: {
2615
+ ...process.env,
2616
+ ...constants.default.processEnv,
2574
2617
  ...mixinsEnv,
2575
2618
  ...spawnEnv
2576
2619
  },
2577
2620
  ipc: {
2578
- [constants.SOCKET_CLI_SHADOW_ACCEPT_RISKS]: true,
2579
- [constants.SOCKET_CLI_SHADOW_API_TOKEN]: constants.SOCKET_PUBLIC_API_TOKEN,
2580
- [constants.SOCKET_CLI_SHADOW_SILENT]: true,
2621
+ [constants.default.SOCKET_CLI_SHADOW_ACCEPT_RISKS]: true,
2622
+ [constants.default.SOCKET_CLI_SHADOW_API_TOKEN]: constants.default.SOCKET_PUBLIC_API_TOKEN,
2623
+ [constants.default.SOCKET_CLI_SHADOW_SILENT]: true,
2581
2624
  ...ipc
2582
2625
  }
2583
2626
  }, extra);
@@ -2719,7 +2762,7 @@ async function writeSocketJson(cwd, sockJson) {
2719
2762
  async function readCache(key,
2720
2763
  // 5 minute in milliseconds time to live (TTL).
2721
2764
  ttlMs = 5 * 60 * 1000) {
2722
- const cacheJsonPath = path.join(constants.githubCachePath, `${key}.json`);
2765
+ const cacheJsonPath = path.join(constants.default.githubCachePath, `${key}.json`);
2723
2766
  const stat = fs.safeStatsSync(cacheJsonPath);
2724
2767
  if (stat) {
2725
2768
  const isExpired = Date.now() - stat.mtimeMs > ttlMs;
@@ -2732,7 +2775,7 @@ ttlMs = 5 * 60 * 1000) {
2732
2775
  async function writeCache(key, data) {
2733
2776
  const {
2734
2777
  githubCachePath
2735
- } = constants;
2778
+ } = constants.default;
2736
2779
  const cacheJsonPath = path.join(githubCachePath, `${key}.json`);
2737
2780
  if (!fs$1.existsSync(githubCachePath)) {
2738
2781
  await fs$1.promises.mkdir(githubCachePath, {
@@ -2743,7 +2786,7 @@ async function writeCache(key, data) {
2743
2786
  }
2744
2787
  async function cacheFetch(key, fetcher, ttlMs) {
2745
2788
  // Optionally disable cache.
2746
- if (constants.ENV.DISABLE_GITHUB_CACHE) {
2789
+ if (constants.default.ENV.DISABLE_GITHUB_CACHE) {
2747
2790
  return await fetcher();
2748
2791
  }
2749
2792
  let data = await readCache(key, ttlMs);
@@ -2795,7 +2838,7 @@ async function fetchGhsaDetails(ids) {
2795
2838
  }
2796
2839
  }
2797
2840
  } catch (e) {
2798
- require$$9.debugFn('error', `Failed to fetch GHSA details: ${e?.message || 'Unknown error'}`);
2841
+ require$$9.debugFn('error', `Failed to fetch GHSA details: ${e?.message || constants.UNKNOWN_ERROR}`);
2799
2842
  }
2800
2843
  return results;
2801
2844
  }
@@ -2804,13 +2847,13 @@ function getOctokit() {
2804
2847
  if (_octokit === undefined) {
2805
2848
  const {
2806
2849
  SOCKET_CLI_GITHUB_TOKEN
2807
- } = constants.ENV;
2850
+ } = constants.default.ENV;
2808
2851
  if (!SOCKET_CLI_GITHUB_TOKEN) {
2809
2852
  require$$9.debugFn('notice', 'miss: SOCKET_CLI_GITHUB_TOKEN env var');
2810
2853
  }
2811
2854
  const octokitOptions = {
2812
2855
  auth: SOCKET_CLI_GITHUB_TOKEN,
2813
- baseUrl: constants.ENV.GITHUB_API_URL
2856
+ baseUrl: constants.default.ENV.GITHUB_API_URL
2814
2857
  };
2815
2858
  require$$9.debugDir('inspect', {
2816
2859
  octokitOptions
@@ -2824,7 +2867,7 @@ function getOctokitGraphql() {
2824
2867
  if (!_octokitGraphql) {
2825
2868
  const {
2826
2869
  SOCKET_CLI_GITHUB_TOKEN
2827
- } = constants.ENV;
2870
+ } = constants.default.ENV;
2828
2871
  if (!SOCKET_CLI_GITHUB_TOKEN) {
2829
2872
  require$$9.debugFn('notice', 'miss: SOCKET_CLI_GITHUB_TOKEN env var');
2830
2873
  }
@@ -2878,7 +2921,7 @@ async function enablePrAutoMerge({
2878
2921
  async function setGitRemoteGithubRepoUrl(owner, repo, token, cwd = process.cwd()) {
2879
2922
  const {
2880
2923
  host
2881
- } = new URL(constants.ENV.GITHUB_SERVER_URL);
2924
+ } = new URL(constants.default.ENV.GITHUB_SERVER_URL);
2882
2925
  const url = `https://x-access-token:${token}@${host}/${owner}/${repo}`;
2883
2926
  const stdioIgnoreOptions = {
2884
2927
  cwd,
@@ -2910,7 +2953,7 @@ function getMajor(version) {
2910
2953
  const COMPLETION_CMD_PREFIX = 'complete -F _socket_completion';
2911
2954
  function getCompletionSourcingCommand() {
2912
2955
  // Note: this is exported to distPath in .config/rollup.dist.config.mjs
2913
- const completionScriptExportPath = path.join(constants.distPath, 'socket-completion.bash');
2956
+ const completionScriptExportPath = path.join(constants.default.distPath, 'socket-completion.bash');
2914
2957
  if (!fs$1.existsSync(completionScriptExportPath)) {
2915
2958
  return {
2916
2959
  ok: false,
@@ -2930,7 +2973,7 @@ function getBashrcDetails(targetCommandName) {
2930
2973
  }
2931
2974
  const {
2932
2975
  socketAppDataPath
2933
- } = constants;
2976
+ } = constants.default;
2934
2977
  if (!socketAppDataPath) {
2935
2978
  return {
2936
2979
  ok: false,
@@ -2969,7 +3012,7 @@ const {
2969
3012
  [kInternalsSymbol]: {
2970
3013
  getSentry
2971
3014
  }
2972
- } = constants;
3015
+ } = constants.default;
2973
3016
  class AuthError extends Error {}
2974
3017
  class InputError extends Error {
2975
3018
  constructor(message, body) {
@@ -3033,7 +3076,7 @@ function shadowNpmInstall(options) {
3033
3076
  } else {
3034
3077
  stdio = useIpc ? ['pipe', 'pipe', 'pipe', 'ipc'] : 'pipe';
3035
3078
  }
3036
- const spawnPromise = spawn.spawn(constants.execPath, [...constants.nodeNoWarningsFlags, ...constants.nodeDebugFlags, ...constants.nodeHardenFlags, ...constants.nodeMemoryFlags, ...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ? ['--require', constants.instrumentWithSentryPath] : []), '--require', constants.shadowNpmInjectPath, npm.resolveBinPathSync(agentExecPath), 'install',
3079
+ const spawnPromise = spawn.spawn(constants.default.execPath, [...constants.default.nodeNoWarningsFlags, ...constants.default.nodeDebugFlags, ...constants.default.nodeHardenFlags, ...constants.default.nodeMemoryFlags, ...(constants.default.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ? ['--require', constants.default.instrumentWithSentryPath] : []), '--require', constants.default.shadowNpmInjectPath, npm.resolveBinPathSync(agentExecPath), 'install',
3037
3080
  // Avoid code paths for 'audit' and 'fund'.
3038
3081
  '--no-audit', '--no-fund',
3039
3082
  // Add '--no-progress' to fix input being swallowed by the npm spinner.
@@ -3044,7 +3087,7 @@ function shadowNpmInstall(options) {
3044
3087
  ...spawnOpts,
3045
3088
  env: {
3046
3089
  ...process.env,
3047
- ...constants.processEnv,
3090
+ ...constants.default.processEnv,
3048
3091
  ...require$$11.getOwn(spawnOpts, 'env')
3049
3092
  },
3050
3093
  spinner,
@@ -3052,9 +3095,9 @@ function shadowNpmInstall(options) {
3052
3095
  });
3053
3096
  if (useIpc) {
3054
3097
  spawnPromise.process.send({
3055
- [constants.SOCKET_IPC_HANDSHAKE]: {
3056
- [constants.SOCKET_CLI_SHADOW_BIN]: 'npm',
3057
- [constants.SOCKET_CLI_SHADOW_PROGRESS]: progressArg,
3098
+ [constants.default.SOCKET_IPC_HANDSHAKE]: {
3099
+ [constants.default.SOCKET_CLI_SHADOW_BIN]: constants.NPM,
3100
+ [constants.default.SOCKET_CLI_SHADOW_PROGRESS]: progressArg,
3058
3101
  ...ipc
3059
3102
  }
3060
3103
  });
@@ -3067,8 +3110,8 @@ function runAgentInstall(pkgEnvDetails, options) {
3067
3110
  agent,
3068
3111
  agentExecPath
3069
3112
  } = pkgEnvDetails;
3070
- const isNpm = agent === 'npm';
3071
- const isPnpm = agent === 'pnpm';
3113
+ const isNpm = agent === constants.NPM;
3114
+ const isPnpm = agent === constants.PNPM;
3072
3115
  // All package managers support the "install" command.
3073
3116
  if (isNpm) {
3074
3117
  return shadowNpmInstall({
@@ -3086,24 +3129,25 @@ function runAgentInstall(pkgEnvDetails, options) {
3086
3129
  };
3087
3130
  const skipNodeHardenFlags = isPnpm && pkgEnvDetails.agentVersion.major < 11;
3088
3131
  return spawn.spawn(agentExecPath, ['install', ...args], {
3089
- shell: constants.WIN32,
3132
+ shell: constants.default.WIN32,
3090
3133
  spinner,
3091
3134
  stdio: 'inherit',
3092
3135
  ...spawnOpts,
3093
3136
  env: {
3094
3137
  ...process.env,
3095
- ...constants.processEnv,
3096
- NODE_OPTIONS: cmdFlagsToString([...(skipNodeHardenFlags ? [] : constants.nodeHardenFlags), ...constants.nodeNoWarningsFlags]),
3138
+ ...constants.default.processEnv,
3139
+ NODE_OPTIONS: cmdFlagsToString([...(skipNodeHardenFlags ? [] : constants.default.nodeHardenFlags), ...constants.default.nodeNoWarningsFlags]),
3097
3140
  ...require$$11.getOwn(spawnOpts, 'env')
3098
3141
  }
3099
3142
  });
3100
3143
  }
3101
3144
 
3102
3145
  const {
3103
- BINARY_LOCK_EXT,
3104
3146
  BUN,
3147
+ EXT_LOCK,
3148
+ EXT_LOCKB,
3105
3149
  HIDDEN_PACKAGE_LOCK_JSON,
3106
- LOCK_EXT,
3150
+ NODE_MODULES,
3107
3151
  NPM,
3108
3152
  NPM_BUGGY_OVERRIDES_PATCHED_VERSION,
3109
3153
  PACKAGE_JSON,
@@ -3112,7 +3156,7 @@ const {
3112
3156
  YARN,
3113
3157
  YARN_BERRY,
3114
3158
  YARN_CLASSIC
3115
- } = constants;
3159
+ } = constants.default;
3116
3160
  const AGENTS = [BUN, NPM, PNPM, YARN_BERRY, YARN_CLASSIC, VLT];
3117
3161
  const binByAgent = new Map([[BUN, BUN], [NPM, NPM], [PNPM, PNPM], [YARN_BERRY, YARN], [YARN_CLASSIC, YARN], [VLT, VLT]]);
3118
3162
  const readLockFileByAgent = (() => {
@@ -3128,10 +3172,10 @@ const readLockFileByAgent = (() => {
3128
3172
  const defaultReader = wrapReader(async lockPath => await fs.readFileUtf8(lockPath));
3129
3173
  return new Map([[BUN, wrapReader(async (lockPath, agentExecPath, cwd = process.cwd()) => {
3130
3174
  const ext = path.extname(lockPath);
3131
- if (ext === LOCK_EXT) {
3175
+ if (ext === EXT_LOCK) {
3132
3176
  return await defaultReader(lockPath);
3133
3177
  }
3134
- if (ext === BINARY_LOCK_EXT) {
3178
+ if (ext === EXT_LOCKB) {
3135
3179
  const lockBuffer = await binaryReader(lockPath);
3136
3180
  if (lockBuffer) {
3137
3181
  try {
@@ -3143,7 +3187,7 @@ const readLockFileByAgent = (() => {
3143
3187
  // https://bun.sh/guides/install/yarnlock
3144
3188
  return (await spawn.spawn(agentExecPath, [lockPath], {
3145
3189
  cwd,
3146
- shell: constants.WIN32
3190
+ shell: constants.default.WIN32
3147
3191
  })).stdout;
3148
3192
  }
3149
3193
  return undefined;
@@ -3152,8 +3196,8 @@ const readLockFileByAgent = (() => {
3152
3196
 
3153
3197
  // The order of LOCKS properties IS significant as it affects iteration order.
3154
3198
  const LOCKS = {
3155
- [`bun${LOCK_EXT}`]: BUN,
3156
- [`bun${BINARY_LOCK_EXT}`]: BUN,
3199
+ [`bun${EXT_LOCK}`]: BUN,
3200
+ [`bun${EXT_LOCKB}`]: BUN,
3157
3201
  // If both package-lock.json and npm-shrinkwrap.json are present in the root
3158
3202
  // of a project, npm-shrinkwrap.json will take precedence and package-lock.json
3159
3203
  // will be ignored.
@@ -3162,19 +3206,19 @@ const LOCKS = {
3162
3206
  'package-lock.json': NPM,
3163
3207
  'pnpm-lock.yaml': PNPM,
3164
3208
  'pnpm-lock.yml': PNPM,
3165
- [`yarn${LOCK_EXT}`]: YARN_CLASSIC,
3209
+ [`yarn${EXT_LOCK}`]: YARN_CLASSIC,
3166
3210
  'vlt-lock.json': VLT,
3167
3211
  // Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
3168
3212
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#hidden-lockfiles
3169
3213
  //
3170
3214
  // Unlike the other LOCKS keys this key contains a directory AND filename so
3171
3215
  // it has to be handled differently.
3172
- 'node_modules/.package-lock.json': NPM
3216
+ [`${NODE_MODULES}/.package-lock.json`]: NPM
3173
3217
  };
3174
3218
  async function getAgentExecPath(agent) {
3175
3219
  const binName = binByAgent.get(agent);
3176
3220
  if (binName === NPM) {
3177
- return constants.npmExecPath;
3221
+ return constants.default.npmExecPath;
3178
3222
  }
3179
3223
  return (await vendor.libExports$1(binName, {
3180
3224
  nothrow: true
@@ -3193,7 +3237,7 @@ async function getAgentVersion(agent, agentExecPath, cwd) {
3193
3237
  // All package managers support the "--version" flag.
3194
3238
  (await spawn.spawn(agentExecPath, ['--version'], {
3195
3239
  cwd,
3196
- shell: constants.WIN32
3240
+ shell: constants.default.WIN32
3197
3241
  })).stdout) ?? undefined;
3198
3242
  } catch (e) {
3199
3243
  require$$9.debugFn('error', `caught: ${quotedCmd} failed`);
@@ -3249,8 +3293,8 @@ async function detectPackageEnvironment({
3249
3293
  }
3250
3294
  const {
3251
3295
  maintainedNodeVersions
3252
- } = constants;
3253
- const minSupportedAgentVersion = constants.minimumVersionByAgent.get(agent);
3296
+ } = constants.default;
3297
+ const minSupportedAgentVersion = constants.default.minimumVersionByAgent.get(agent);
3254
3298
  const minSupportedNodeMajor = vendor.semverExports.major(maintainedNodeVersions.last);
3255
3299
  const minSupportedNodeVersion = `${minSupportedNodeMajor}.0.0`;
3256
3300
  const minSupportedNodeRange = `>=${minSupportedNodeMajor}`;
@@ -3360,7 +3404,7 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
3360
3404
  } = details;
3361
3405
  const agentVersion = details.agentVersion ?? 'unknown';
3362
3406
  if (!details.agentSupported) {
3363
- const minVersion = constants.minimumVersionByAgent.get(agent);
3407
+ const minVersion = constants.default.minimumVersionByAgent.get(agent);
3364
3408
  return {
3365
3409
  ok: false,
3366
3410
  message: 'Version mismatch',
@@ -3368,7 +3412,7 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
3368
3412
  };
3369
3413
  }
3370
3414
  if (!details.nodeSupported) {
3371
- const minVersion = constants.maintainedNodeVersions.last;
3415
+ const minVersion = constants.default.maintainedNodeVersions.last;
3372
3416
  return {
3373
3417
  ok: false,
3374
3418
  message: 'Version mismatch',
@@ -3420,7 +3464,7 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
3420
3464
  }
3421
3465
  if (details.lockPath && path.relative(cwd, details.lockPath).startsWith('.')) {
3422
3466
  // Note: In tests we return <redacted> because otherwise snapshots will fail.
3423
- logger?.warn(cmdPrefixMessage(cmdName, `Package ${lockName} found at ${constants.ENV.VITEST ? constants.REDACTED : details.lockPath}`));
3467
+ logger?.warn(cmdPrefixMessage(cmdName, `Package ${lockName} found at ${constants.default.ENV.VITEST ? constants.default.REDACTED : details.lockPath}`));
3424
3468
  }
3425
3469
  return {
3426
3470
  ok: true,
@@ -3428,7 +3472,7 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
3428
3472
  };
3429
3473
  }
3430
3474
 
3431
- const ALL_ECOSYSTEMS = ['apk', 'bitbucket', 'cargo', 'chrome', 'cocoapods', 'composer', 'conan', 'conda', 'cran', 'deb', 'docker', 'gem', 'generic', 'github', 'golang', 'hackage', 'hex', 'huggingface', 'maven', 'mlflow', 'npm', 'nuget', 'oci', 'pub', 'pypi', 'qpkg', 'rpm', 'swift', 'swid', 'unknown'];
3475
+ const ALL_ECOSYSTEMS = ['apk', 'bitbucket', 'cargo', 'chrome', 'cocoapods', 'composer', 'conan', 'conda', 'cran', 'deb', 'docker', 'gem', 'generic', 'github', 'golang', 'hackage', 'hex', 'huggingface', 'maven', 'mlflow', constants.NPM, 'nuget', 'oci', 'pub', 'pypi', 'qpkg', 'rpm', 'swift', 'swid', 'unknown'];
3432
3476
  new Set(ALL_ECOSYSTEMS);
3433
3477
  function getEcosystemChoicesForMeow() {
3434
3478
  return [...ALL_ECOSYSTEMS];
@@ -3438,7 +3482,7 @@ function isArtifactAlertCve(alert) {
3438
3482
  const {
3439
3483
  type
3440
3484
  } = alert;
3441
- return type === constants.ALERT_TYPE_CVE || type === constants.ALERT_TYPE_MEDIUM_CVE || type === constants.ALERT_TYPE_MILD_CVE || type === constants.ALERT_TYPE_CRITICAL_CVE;
3485
+ return type === constants.default.ALERT_TYPE_CVE || type === constants.default.ALERT_TYPE_MEDIUM_CVE || type === constants.default.ALERT_TYPE_MILD_CVE || type === constants.default.ALERT_TYPE_CRITICAL_CVE;
3442
3486
  }
3443
3487
 
3444
3488
  function createEnum(obj) {
@@ -3515,7 +3559,7 @@ const require$1 = Module.createRequire(require('node:url').pathToFileURL(__filen
3515
3559
  let _translations;
3516
3560
  function getTranslations() {
3517
3561
  if (_translations === undefined) {
3518
- _translations = /*@__PURE__*/require$1(path.join(constants.rootPath, 'translations.json'));
3562
+ _translations = /*@__PURE__*/require$1(path.join(constants.default.rootPath, 'translations.json'));
3519
3563
  }
3520
3564
  return _translations;
3521
3565
  }
@@ -3865,7 +3909,7 @@ function logAlertsMap(alertsMap, options) {
3865
3909
  }
3866
3910
 
3867
3911
  function idToNpmPurl(id) {
3868
- return `pkg:npm/${id}`;
3912
+ return `pkg:${constants.NPM}/${id}`;
3869
3913
  }
3870
3914
 
3871
3915
  async function getAlertsMapFromPurls(purls, options) {
@@ -4000,6 +4044,7 @@ exports.getOrgSlugs = getOrgSlugs;
4000
4044
  exports.getOutputKind = getOutputKind;
4001
4045
  exports.getPackageFilesForScan = getPackageFilesForScan;
4002
4046
  exports.getPublicApiToken = getPublicApiToken;
4047
+ exports.getPurlObject = getPurlObject;
4003
4048
  exports.getRepoInfo = getRepoInfo;
4004
4049
  exports.getRepoName = getRepoName;
4005
4050
  exports.getSocketDevPackageOverviewUrlFromPurl = getSocketDevPackageOverviewUrlFromPurl;
@@ -4036,6 +4081,7 @@ exports.mdTableStringNumber = mdTableStringNumber;
4036
4081
  exports.meowOrExit = meowOrExit;
4037
4082
  exports.meowWithSubcommands = meowWithSubcommands;
4038
4083
  exports.msAtHome = msAtHome;
4084
+ exports.normalizePurl = normalizePurl;
4039
4085
  exports.npa = npa;
4040
4086
  exports.queryApiSafeJson = queryApiSafeJson;
4041
4087
  exports.queryApiSafeText = queryApiSafeText;
@@ -4053,5 +4099,5 @@ exports.toFilterConfig = toFilterConfig;
4053
4099
  exports.updateConfigValue = updateConfigValue;
4054
4100
  exports.walkNestedMap = walkNestedMap;
4055
4101
  exports.writeSocketJson = writeSocketJson;
4056
- //# debugId=c9a337ab-9c3d-4d21-a5a6-ef5d89be0e38
4102
+ //# debugId=bb13588e-acd6-4f09-97dc-878030632d5
4057
4103
  //# sourceMappingURL=utils.js.map