@socketsecurity/cli-with-sentry 0.15.60 → 0.15.62

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.
package/dist/vendor.js CHANGED
@@ -32895,7 +32895,7 @@ var isInteractiveExports = /*@__PURE__*/ requireIsInteractive();
32895
32895
  var dist$e = {};
32896
32896
 
32897
32897
  var name$2 = "@socketsecurity/sdk";
32898
- var version$5 = "1.4.43";
32898
+ var version$5 = "1.4.45";
32899
32899
  var license = "MIT";
32900
32900
  var description = "SDK for the Socket API client";
32901
32901
  var author = {
@@ -32978,36 +32978,36 @@ var scripts = {
32978
32978
  "update:deps": "npx --yes npm-check-updates"
32979
32979
  };
32980
32980
  var dependencies = {
32981
- "@socketsecurity/registry": "1.0.205"
32981
+ "@socketsecurity/registry": "1.0.208"
32982
32982
  };
32983
32983
  var devDependencies = {
32984
32984
  "@biomejs/biome": "1.9.4",
32985
- "@dotenvx/dotenvx": "1.44.1",
32986
- "@eslint/compat": "1.2.9",
32985
+ "@dotenvx/dotenvx": "1.44.2",
32986
+ "@eslint/compat": "1.3.0",
32987
32987
  "@eslint/js": "9.28.0",
32988
- "@types/node": "22.15.30",
32989
- "@typescript-eslint/parser": "8.33.1",
32990
- "@vitest/coverage-v8": "3.2.2",
32988
+ "@types/node": "24.0.1",
32989
+ "@typescript-eslint/parser": "8.34.0",
32990
+ "@vitest/coverage-v8": "3.2.3",
32991
32991
  "del-cli": "6.0.0",
32992
32992
  eslint: "9.28.0",
32993
32993
  "eslint-import-resolver-typescript": "4.4.3",
32994
- "eslint-plugin-import-x": "4.15.1",
32995
- "eslint-plugin-jsdoc": "50.7.1",
32994
+ "eslint-plugin-import-x": "4.15.2",
32995
+ "eslint-plugin-jsdoc": "50.8.0",
32996
32996
  "eslint-plugin-n": "17.19.0",
32997
32997
  "eslint-plugin-sort-destructure-keys": "2.0.0",
32998
32998
  "eslint-plugin-unicorn": "56.0.1",
32999
32999
  globals: "16.2.0",
33000
33000
  husky: "9.1.7",
33001
- knip: "5.60.2",
33001
+ knip: "5.61.0",
33002
33002
  "lint-staged": "16.1.0",
33003
33003
  nock: "14.0.5",
33004
33004
  "npm-run-all2": "8.0.4",
33005
33005
  "openapi-typescript": "6.7.6",
33006
- oxlint: "0.18.0",
33006
+ oxlint: "1.1.0",
33007
33007
  "type-coverage": "2.29.7",
33008
33008
  typescript: "~5.8.3",
33009
- "typescript-eslint": "8.33.1",
33010
- vitest: "3.2.2"
33009
+ "typescript-eslint": "8.34.0",
33010
+ vitest: "3.2.3"
33011
33011
  };
33012
33012
  var overrides = {
33013
33013
  vite: "6.3.5"
@@ -33124,83 +33124,116 @@ function requireDist$e () {
33124
33124
  ];
33125
33125
  }
33126
33126
  async function createUploadRequest(baseUrl, urlPath, requestBodyNoBoundaries, options) {
33127
- // Generate a unique boundary for multipart encoding.
33128
- const boundary = `NodeMultipartBoundary${Date.now()}`;
33129
- const boundarySep = `--${boundary}\r\n`;
33130
- const finalBoundary = `--${boundary}--\r\n`;
33131
- const requestBody = [
33132
- ...requestBodyNoBoundaries.flatMap(part => [
33133
- boundarySep,
33134
- ...(Array.isArray(part) ? part : [part])
33135
- ]),
33136
- finalBoundary
33137
- ];
33138
- const url = new URL(urlPath, baseUrl);
33139
- const req = getHttpModule(baseUrl).request(url, {
33140
- method: 'POST',
33141
- ...options,
33142
- headers: {
33143
- ...options?.headers,
33144
- 'Content-Type': `multipart/form-data; boundary=${boundary}`
33145
- }
33146
- });
33147
- let aborted = false;
33148
- req.on('error', _err => {
33149
- aborted = true;
33150
- });
33151
- req.on('close', () => {
33152
- aborted = true;
33153
- });
33154
- try {
33155
- // Send the request body (headers + files).
33156
- for (const part of requestBody) {
33157
- if (aborted) {
33158
- break;
33127
+ // Note: this will create a regular http request and stream in the file content
33128
+ // implicitly. The outgoing buffer is (implicitly) flushed periodically
33129
+ // by node. When this happens first it will send the headers to the server
33130
+ // which may decide to reject the request, immediately send a response and
33131
+ // then cut the connection (EPIPE or ECONNRESET errors may follow while
33132
+ // writing the files).
33133
+ // We have to make sure to guard for sudden reject responses because if we
33134
+ // don't then the file streaming will fail with random errors and it gets
33135
+ // hard to debug what's going on why.
33136
+ // Example : `socket scan create --org badorg` should fail gracefully.
33137
+ // eslint-disable-next-line no-async-promise-executor
33138
+ return await new Promise(async (pass, fail) => {
33139
+ // Generate a unique boundary for multipart encoding.
33140
+ const boundary = `NodeMultipartBoundary${Date.now()}`;
33141
+ const boundarySep = `--${boundary}\r\n`;
33142
+ const finalBoundary = `--${boundary}--\r\n`;
33143
+ const requestBody = [
33144
+ ...requestBodyNoBoundaries.flatMap(part => [
33145
+ boundarySep,
33146
+ ...(Array.isArray(part) ? part : [part])
33147
+ ]),
33148
+ finalBoundary
33149
+ ];
33150
+ const url = new URL(urlPath, baseUrl);
33151
+ const req = getHttpModule(baseUrl).request(url, {
33152
+ method: 'POST',
33153
+ ...options,
33154
+ headers: {
33155
+ ...options?.headers,
33156
+ 'Content-Type': `multipart/form-data; boundary=${boundary}`
33159
33157
  }
33160
- if (typeof part === 'string') {
33161
- req.write(part);
33158
+ });
33159
+ // Send the headers now. If the server would reject this request, it should
33160
+ // do so asap. This prevents us from sending more data to it then necessary.
33161
+ // If it will reject we could just await the `req.on(response` now but if it
33162
+ // accepts the request then the response will not come until after the final
33163
+ // file. So we can't await the response at this time. Just proceed, carefully.
33164
+ req.flushHeaders();
33165
+ // Wait for the response. It may arrive at any point during the request or
33166
+ // afterwards. Node will flush the output buffer at some point, initiating
33167
+ // the request, and the server can decide to reject the request immediately
33168
+ // or at any point later (ike a timeout). We should handle those cases.
33169
+ getResponse(req).then(res => {
33170
+ // Note: this returns the response to the caller to createUploadRequest
33171
+ pass(res);
33172
+ }, async (err) => {
33173
+ // Note: this will throw an error for the caller to createUploadRequest
33174
+ if (err.response && !isResponseOk(err.response)) {
33175
+ fail(new ResponseError(err.response, `${err.method} request failed`));
33162
33176
  }
33163
- else if (typeof part?.pipe === 'function') {
33164
- part.pipe(req, { end: false });
33165
- // Wait for file streaming to complete.
33166
- // eslint-disable-next-line no-await-in-loop
33167
- await new Promise((resolve, reject) => {
33168
- const cleanup = () => {
33169
- part.off('end', onEnd);
33170
- part.off('error', onError);
33171
- };
33172
- const onEnd = () => {
33173
- cleanup();
33174
- resolve();
33175
- };
33176
- const onError = (e) => {
33177
- cleanup();
33178
- reject(e);
33179
- };
33180
- part.on('end', onEnd);
33181
- part.on('error', onError);
33182
- });
33183
- if (!aborted) {
33184
- // Ensure a new line after file content.
33185
- req.write('\r\n');
33177
+ fail(err);
33178
+ });
33179
+ let aborted = false;
33180
+ req.on('error', _err => {
33181
+ aborted = true;
33182
+ });
33183
+ req.on('close', () => {
33184
+ aborted = true;
33185
+ });
33186
+ try {
33187
+ // Send the request body (headers + files).
33188
+ for (const part of requestBody) {
33189
+ if (aborted) {
33190
+ break;
33191
+ }
33192
+ if (typeof part === 'string') {
33193
+ req.write(part);
33194
+ }
33195
+ else if (typeof part?.pipe === 'function') {
33196
+ part.pipe(req, { end: false });
33197
+ // Wait for file streaming to complete.
33198
+ // eslint-disable-next-line no-await-in-loop
33199
+ await new Promise((resolve, reject) => {
33200
+ const cleanup = () => {
33201
+ part.off('end', onEnd);
33202
+ part.off('error', onError);
33203
+ };
33204
+ const onEnd = () => {
33205
+ cleanup();
33206
+ resolve();
33207
+ };
33208
+ const onError = (e) => {
33209
+ cleanup();
33210
+ reject(e);
33211
+ };
33212
+ part.on('end', onEnd);
33213
+ part.on('error', onError);
33214
+ });
33215
+ if (!aborted) {
33216
+ // Ensure a new line after file content.
33217
+ req.write('\r\n');
33218
+ }
33219
+ }
33220
+ else {
33221
+ throw new TypeError('Socket API - Invalid multipart part, expected string or stream');
33186
33222
  }
33187
- }
33188
- else {
33189
- throw new TypeError('Socket API - Invalid multipart part, expected string or stream');
33190
33223
  }
33191
33224
  }
33192
- }
33193
- catch (e) {
33194
- req.destroy(e);
33195
- throw e;
33196
- }
33197
- finally {
33198
- if (!aborted) {
33199
- // Close request after writing all data.
33200
- req.end();
33225
+ catch (e) {
33226
+ req.destroy(e);
33227
+ fail(e);
33201
33228
  }
33202
- }
33203
- return await getResponse(req);
33229
+ finally {
33230
+ if (!aborted) {
33231
+ // Close request after writing all data.
33232
+ req.end();
33233
+ }
33234
+ }
33235
+ pass(getResponse(req));
33236
+ });
33204
33237
  }
33205
33238
  async function getErrorResponseBody(response) {
33206
33239
  const chunks = [];
@@ -33233,39 +33266,33 @@ function requireDist$e () {
33233
33266
  return protocol === 'https:' ? node_https_1.default : node_http_1.default;
33234
33267
  }
33235
33268
  async function getResponse(req) {
33236
- try {
33237
- const res = await new Promise((resolve, reject) => {
33238
- const cleanup = () => {
33239
- req.off('response', onResponse);
33240
- req.off('error', onError);
33241
- abort_signal_1.default?.removeEventListener('abort', onAbort);
33242
- };
33243
- const onAbort = () => {
33244
- cleanup();
33245
- req.destroy();
33246
- reject(new Error('Request aborted by signal'));
33247
- };
33248
- const onError = (e) => {
33249
- cleanup();
33250
- reject(e);
33251
- };
33252
- const onResponse = (res) => {
33253
- cleanup();
33254
- resolve(res);
33255
- };
33256
- req.on('response', onResponse);
33257
- req.on('error', onError);
33258
- abort_signal_1.default?.addEventListener('abort', onAbort);
33259
- });
33260
- if (!isResponseOk(res)) {
33261
- throw new ResponseError(res, `${req.method} request failed`);
33262
- }
33263
- return res;
33264
- }
33265
- catch (e) {
33266
- req.destroy();
33267
- throw e;
33269
+ const res = await new Promise((resolve, reject) => {
33270
+ const cleanup = () => {
33271
+ req.off('response', onResponse);
33272
+ req.off('error', onError);
33273
+ abort_signal_1.default?.removeEventListener('abort', onAbort);
33274
+ };
33275
+ const onAbort = () => {
33276
+ cleanup();
33277
+ req.destroy();
33278
+ reject(new Error('Request aborted by signal'));
33279
+ };
33280
+ const onError = (e) => {
33281
+ cleanup();
33282
+ reject(e);
33283
+ };
33284
+ const onResponse = (res) => {
33285
+ cleanup();
33286
+ resolve(res);
33287
+ };
33288
+ req.on('response', onResponse);
33289
+ req.on('error', onError);
33290
+ abort_signal_1.default?.addEventListener('abort', onAbort);
33291
+ });
33292
+ if (!isResponseOk(res)) {
33293
+ throw new ResponseError(res, `${req.method} request failed`);
33268
33294
  }
33295
+ return res;
33269
33296
  }
33270
33297
  async function getResponseJson(response) {
33271
33298
  let data = '';
@@ -33311,9 +33338,6 @@ function requireDist$e () {
33311
33338
  class SocketSdk {
33312
33339
  #baseUrl;
33313
33340
  #reqOptions;
33314
- /**
33315
- * @throws {SocketSdkAuthError}
33316
- */
33317
33341
  constructor(apiToken, options) {
33318
33342
  const { agent: agentOrObj, baseUrl = 'https://api.socket.dev/v0/', userAgent } = { __proto__: null, ...options };
33319
33343
  const agentKeys = agentOrObj ? Object.keys(agentOrObj) : [];
@@ -33344,7 +33368,17 @@ function requireDist$e () {
33344
33368
  let res;
33345
33369
  try {
33346
33370
  res = await (0, promises_1.pRetry)(() => this.#createBatchPurlRequest(queryParams, componentsObj), {
33347
- retries: 4
33371
+ retries: 4,
33372
+ onRetryRethrow: true,
33373
+ onRetry(_attempt, error) {
33374
+ if (!(error instanceof ResponseError)) {
33375
+ return;
33376
+ }
33377
+ const { statusCode } = error.response;
33378
+ if (statusCode === 401 || statusCode === 403) {
33379
+ throw error;
33380
+ }
33381
+ }
33348
33382
  });
33349
33383
  }
33350
33384
  catch (e) {
@@ -33365,7 +33399,7 @@ function requireDist$e () {
33365
33399
  cause: error
33366
33400
  });
33367
33401
  }
33368
- const statusCode = error.response.statusCode;
33402
+ const { statusCode } = error.response;
33369
33403
  if (statusCode >= 500) {
33370
33404
  throw new Error(`Socket API server error (${statusCode})`, {
33371
33405
  cause: error
@@ -33422,7 +33456,7 @@ function requireDist$e () {
33422
33456
  return this.#handleApiSuccess(results);
33423
33457
  }
33424
33458
  async *batchPackageStream(queryParams, componentsObj, options) {
33425
- const { chunkSize = 5, concurrencyLimit = 10 } = {
33459
+ const { chunkSize = 500, concurrencyLimit = 10 } = {
33426
33460
  __proto__: null,
33427
33461
  ...options
33428
33462
  };
@@ -148099,6 +148133,7 @@ function requireReify() {
148099
148133
  time
148100
148134
  } = requireLib$B();
148101
148135
  const rpj = requireLib$x();
148136
+ const hgi = requireLib$D();
148102
148137
  const {
148103
148138
  dirname,
148104
148139
  resolve,
@@ -148953,7 +148988,7 @@ function requireReify() {
148953
148988
  // Shrinkwrap and Node classes carefully, so for now, just treat
148954
148989
  // the default reg as the magical animal that it has been.
148955
148990
  try {
148956
- const resolvedURL = new URL(resolved);
148991
+ const resolvedURL = hgi.parseUrl(resolved);
148957
148992
  if (this.options.replaceRegistryHost === resolvedURL.hostname || this.options.replaceRegistryHost === 'always') {
148958
148993
  const registryURL = new URL(this.registry);
148959
148994
 
@@ -164963,5 +164998,5 @@ exports.terminalLinkExports = terminalLinkExports;
164963
164998
  exports.updater = updater$1;
164964
164999
  exports.yargsParser = yargsParser;
164965
165000
  exports.yoctocolorsCjsExports = yoctocolorsCjsExports;
164966
- //# debugId=54cac667-1a93-40c1-a094-bf9382b9516d
165001
+ //# debugId=2e114319-515b-421c-9aa6-21e4aadf9b6a
164967
165002
  //# sourceMappingURL=vendor.js.map