@socketsecurity/cli-with-sentry 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:076379f8:pub";
656
+ "0.14.66:3dec148:3a36e9f3: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
  }
@@ -2469,7 +2470,7 @@ function formatScore$1(score) {
2469
2470
  return colors.red(`${score}`);
2470
2471
  }
2471
2472
  function outputPackageIssuesDetails(packageData, outputMarkdown) {
2472
- const issueDetails = packageData.filter(d => d.value?.severity === shadowNpmInject.SEVERITY.critical || d.value?.severity === shadowNpmInject.SEVERITY.high);
2473
+ const issueDetails = packageData.filter(d => d.value?.severity === shadowNpmInject.ALERT_SEVERITY.critical || d.value?.severity === shadowNpmInject.ALERT_SEVERITY.high);
2473
2474
  const uniqueIssueDetails = issueDetails.reduce((acc, issue) => {
2474
2475
  const {
2475
2476
  type
@@ -5484,10 +5485,10 @@ async function getFullScan(orgSlug, fullScanId) {
5484
5485
  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.');
5485
5486
  }
5486
5487
  spinner.start('Fetching full-scan...');
5487
- const response = await queryAPI(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
5488
+ const response = await queryApi(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
5488
5489
  spinner.stop('Fetch complete.');
5489
5490
  if (!response.ok) {
5490
- const err = await handleAPIError(response.status);
5491
+ const err = await handleApiError(response.status);
5491
5492
  logger.logger.fail(`${colors.bgRed(colors.white(response.statusText))}: Fetch error: ${err}`);
5492
5493
  return;
5493
5494
  }
@@ -7316,11 +7317,11 @@ includeSecurityPolicy) {
7316
7317
  // licensePolicyMaybe,
7317
7318
  securityPolicyMaybe] = await Promise.all([(async () => {
7318
7319
  try {
7319
- const response = await queryAPI(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
7320
+ const response = await queryApi(`orgs/${orgSlug}/full-scans/${encodeURIComponent(fullScanId)}`, apiToken);
7320
7321
  haveScan = true;
7321
7322
  updateProgress();
7322
7323
  if (!response.ok) {
7323
- const err = await handleAPIError(response.status);
7324
+ const err = await handleApiError(response.status);
7324
7325
  logger.logger.fail(`${colors.bgRed(colors.white(response.statusText))}: Fetch error: ${err}`);
7325
7326
  return undefined;
7326
7327
  }
@@ -8034,7 +8035,7 @@ async function getThreatFeedWithToken({
8034
8035
  } = constants;
8035
8036
  const queryParams = new URLSearchParams([['direction', direction], ['ecosystem', ecosystem], ['filter', filter], ['page', page], ['per_page', String(perPage)]]);
8036
8037
  spinner.start('Fetching Threat Feed data...');
8037
- const response = await queryAPI(`threat-feed?${queryParams}`, apiToken);
8038
+ const response = await queryApi(`threat-feed?${queryParams}`, apiToken);
8038
8039
  const data = await response.json();
8039
8040
  spinner.stop('Threat feed data fetched');
8040
8041
  if (outputKind === 'json') {
@@ -8457,7 +8458,7 @@ void (async () => {
8457
8458
  await vendor.updater({
8458
8459
  name: SOCKET_CLI_BIN_NAME,
8459
8460
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
8460
- version: "0.14.65",
8461
+ version: "0.14.66",
8461
8462
  ttl: 86_400_000 /* 24 hours in milliseconds */
8462
8463
  });
8463
8464
  try {
@@ -8524,5 +8525,5 @@ void (async () => {
8524
8525
  await shadowNpmInject.captureException(e);
8525
8526
  }
8526
8527
  })();
8527
- //# debugId=4f35ba71-7571-4877-b38b-469cb0fdda66
8528
+ //# debugId=af4902b3-7202-4316-abae-4f8c0524080c
8528
8529
  //# sourceMappingURL=cli.js.map