@socketsecurity/cli 0.14.65 → 0.14.66

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.
@@ -62,11 +62,12 @@ var BoxWidget = _socketInterop(require('blessed/lib/widgets/box'));
62
62
  var TableWidget = _socketInterop(require('blessed-contrib/lib/widget/table'));
63
63
  var readline$1 = require('node:readline');
64
64
 
65
- function handleUnsuccessfulApiResponse(_name, result) {
66
- // SocketSdkErrorType['error'] is not typed.
67
- const resultErrorMessage = result.error?.message;
68
- const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
69
- if (result.status === 401 || result.status === 403) {
65
+ function handleUnsuccessfulApiResponse(_name, sockSdkError) {
66
+ const message = sockSdkError.error || 'No error message returned';
67
+ const {
68
+ status
69
+ } = sockSdkError;
70
+ if (status === 401 || status === 403) {
70
71
  // Lazily access constants.spinner.
71
72
  const {
72
73
  spinner
@@ -88,7 +89,7 @@ async function handleApiCall(value, description) {
88
89
  }
89
90
  return result;
90
91
  }
91
- async function handleAPIError(code) {
92
+ async function handleApiError(code) {
92
93
  if (code === 400) {
93
94
  return 'One of the options passed might be incorrect.';
94
95
  } else if (code === 403) {
@@ -105,12 +106,12 @@ function getDefaultApiBaseUrl() {
105
106
  const baseUrl = process$1.env['SOCKET_SECURITY_API_BASE_URL'] || shadowNpmInject.getSetting('apiBaseUrl');
106
107
  return strings.isNonEmptyString(baseUrl) ? baseUrl : undefined;
107
108
  }
108
- async function queryAPI(path, apiToken) {
109
+ async function queryApi(path, apiToken) {
109
110
  const API_V0_URL = getDefaultApiBaseUrl();
110
111
  return await fetch(`${API_V0_URL}/${path}`, {
111
112
  method: 'GET',
112
113
  headers: {
113
- Authorization: `Basic ${btoa(`${apiToken}:${apiToken}`)}`
114
+ Authorization: `Basic ${btoa(`${apiToken}:`)}`
114
115
  }
115
116
  });
116
117
  }
@@ -652,7 +653,7 @@ function emitBanner(name) {
652
653
  }
653
654
  function getAsciiHeader(command) {
654
655
  const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
655
- "0.14.65:ace6cae:9b43c652:pub";
656
+ "0.14.66:3dec148:bec4e6c6:pub";
656
657
  const nodeVersion = process.version;
657
658
  const apiToken = shadowNpmInject.getSetting('apiToken');
658
659
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no';
@@ -1479,10 +1480,10 @@ async function fetchDiffScanWithToken(apiToken, {
1479
1480
  spinner
1480
1481
  } = constants;
1481
1482
  spinner.start('Fetching diff-scan...');
1482
- const response = await queryAPI(`orgs/${orgSlug}/full-scans/diff?before=${encodeURIComponent(before)}&after=${encodeURIComponent(after)}`, apiToken);
1483
+ const response = await queryApi(`orgs/${orgSlug}/full-scans/diff?before=${encodeURIComponent(before)}&after=${encodeURIComponent(after)}`, apiToken);
1483
1484
  spinner?.successAndStop('Received diff-scan response');
1484
1485
  if (!response.ok) {
1485
- const err = await handleAPIError(response.status);
1486
+ const err = await handleApiError(response.status);
1486
1487
  spinner.errorAndStop(`${colors.bgRed(colors.white(response.statusText))}: ${err}`);
1487
1488
  return;
1488
1489
  }
@@ -2467,7 +2468,7 @@ function formatScore$1(score) {
2467
2468
  return colors.red(`${score}`);
2468
2469
  }
2469
2470
  function outputPackageIssuesDetails(packageData, outputMarkdown) {
2470
- const issueDetails = packageData.filter(d => d.value?.severity === shadowNpmInject.SEVERITY.critical || d.value?.severity === shadowNpmInject.SEVERITY.high);
2471
+ const issueDetails = packageData.filter(d => d.value?.severity === shadowNpmInject.ALERT_SEVERITY.critical || d.value?.severity === shadowNpmInject.ALERT_SEVERITY.high);
2471
2472
  const uniqueIssueDetails = issueDetails.reduce((acc, issue) => {
2472
2473
  const {
2473
2474
  type
@@ -5482,10 +5483,10 @@ async function getFullScan(orgSlug, fullScanId) {
5482
5483
  throw new shadowNpmInject.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
5483
5484
  }
5484
5485
  spinner.start('Fetching full-scan...');
5485
- const response = await queryAPI(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
5486
+ const response = await queryApi(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
5486
5487
  spinner.stop('Fetch complete.');
5487
5488
  if (!response.ok) {
5488
- const err = await handleAPIError(response.status);
5489
+ const err = await handleApiError(response.status);
5489
5490
  logger.logger.fail(`${colors.bgRed(colors.white(response.statusText))}: Fetch error: ${err}`);
5490
5491
  return;
5491
5492
  }
@@ -7314,11 +7315,11 @@ includeSecurityPolicy) {
7314
7315
  // licensePolicyMaybe,
7315
7316
  securityPolicyMaybe] = await Promise.all([(async () => {
7316
7317
  try {
7317
- const response = await queryAPI(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
7318
+ const response = await queryApi(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
7318
7319
  haveScan = true;
7319
7320
  updateProgress();
7320
7321
  if (!response.ok) {
7321
- const err = await handleAPIError(response.status);
7322
+ const err = await handleApiError(response.status);
7322
7323
  logger.logger.fail(`${colors.bgRed(colors.white(response.statusText))}: Fetch error: ${err}`);
7323
7324
  return undefined;
7324
7325
  }
@@ -8032,7 +8033,7 @@ async function getThreatFeedWithToken({
8032
8033
  } = constants;
8033
8034
  const queryParams = new URLSearchParams([['direction', direction], ['ecosystem', ecosystem], ['filter', filter], ['page', page], ['per_page', String(perPage)]]);
8034
8035
  spinner.start('Fetching Threat Feed data...');
8035
- const response = await queryAPI(`threat-feed?${queryParams}`, apiToken);
8036
+ const response = await queryApi(`threat-feed?${queryParams}`, apiToken);
8036
8037
  const data = await response.json();
8037
8038
  spinner.stop('Threat feed data fetched');
8038
8039
  if (outputKind === 'json') {
@@ -8455,7 +8456,7 @@ void (async () => {
8455
8456
  await vendor.updater({
8456
8457
  name: SOCKET_CLI_BIN_NAME,
8457
8458
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
8458
- version: "0.14.65",
8459
+ version: "0.14.66",
8459
8460
  ttl: 86_400_000 /* 24 hours in milliseconds */
8460
8461
  });
8461
8462
  try {
@@ -8522,5 +8523,5 @@ void (async () => {
8522
8523
  await shadowNpmInject.captureException(e);
8523
8524
  }
8524
8525
  })();
8525
- //# debugId=765ca9f4-3784-4e50-beb4-36197117fbea
8526
+ //# debugId=442c46c8-a006-4075-9a1a-7cc92b7b9849
8526
8527
  //# sourceMappingURL=cli.js.map