@socketsecurity/sdk 3.5.0 → 4.0.0

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/index.js CHANGED
@@ -30,48 +30,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- DEFAULT_USER_AGENT: () => DEFAULT_USER_AGENT,
34
33
  ResponseError: () => ResponseError,
35
34
  SocketSdk: () => SocketSdk,
36
35
  calculateTotalQuotaCost: () => calculateTotalQuotaCost,
37
- calculateWordSetSimilarity: () => calculateWordSetSimilarity,
38
- createDeleteRequest: () => createDeleteRequest,
39
- createGetRequest: () => createGetRequest,
40
- createRequestBodyForFilepaths: () => createRequestBodyForFilepaths,
41
- createRequestBodyForJson: () => createRequestBodyForJson,
42
- createRequestWithJson: () => createRequestWithJson,
43
- createUploadRequest: () => createUploadRequest,
44
36
  createUserAgentFromPkgJson: () => createUserAgentFromPkgJson,
45
- filterRedundantCause: () => filterRedundantCause,
46
37
  getAllMethodRequirements: () => getAllMethodRequirements,
47
- getErrorResponseBody: () => getErrorResponseBody,
48
- getHttpModule: () => getHttpModule,
49
38
  getMethodRequirements: () => getMethodRequirements,
50
39
  getMethodsByPermissions: () => getMethodsByPermissions,
51
40
  getMethodsByQuotaCost: () => getMethodsByQuotaCost,
52
41
  getQuotaCost: () => getQuotaCost,
53
42
  getQuotaUsageSummary: () => getQuotaUsageSummary,
54
43
  getRequiredPermissions: () => getRequiredPermissions,
55
- getResponse: () => getResponse,
56
- getResponseJson: () => getResponseJson,
57
- hasQuotaForMethods: () => hasQuotaForMethods,
58
- httpAgentNames: () => httpAgentNames,
59
- isResponseOk: () => isResponseOk,
60
- normalizeBaseUrl: () => normalizeBaseUrl,
61
- promiseWithResolvers: () => promiseWithResolvers,
62
- publicPolicy: () => publicPolicy,
63
- queryToSearchParams: () => queryToSearchParams,
64
- reshapeArtifactForPublicPolicy: () => reshapeArtifactForPublicPolicy,
65
- resolveAbsPaths: () => resolveAbsPaths,
66
- resolveBasePath: () => resolveBasePath,
67
- shouldOmitReason: () => shouldOmitReason
44
+ hasQuotaForMethods: () => hasQuotaForMethods
68
45
  });
69
46
  module.exports = __toCommonJS(index_exports);
70
47
 
48
+ // src/http-client.ts
49
+ var import_debug = require("@socketsecurity/lib/debug");
50
+ var import_http_request = require("@socketsecurity/lib/http-request");
51
+ var import_parse = require("@socketsecurity/lib/json/parse");
52
+ var import_performance = require("@socketsecurity/lib/performance");
53
+
71
54
  // package.json
72
55
  var package_default = {
73
56
  name: "@socketsecurity/sdk",
74
- version: "3.5.0",
57
+ version: "4.0.0",
75
58
  description: "SDK for the Socket API client",
76
59
  homepage: "https://github.com/SocketDev/socket-sdk-js",
77
60
  license: "MIT",
@@ -119,7 +102,7 @@ var package_default = {
119
102
  clean: "node scripts/clean.mjs",
120
103
  cover: "node scripts/cover.mjs",
121
104
  fix: "node scripts/lint.mjs --fix",
122
- format: "oxfmt .",
105
+ format: "oxfmt --write .",
123
106
  "format:check": "oxfmt --check .",
124
107
  "generate-sdk": "node scripts/generate-sdk.mjs",
125
108
  lint: "node scripts/lint.mjs",
@@ -136,12 +119,11 @@ var package_default = {
136
119
  update: "node scripts/update.mjs"
137
120
  },
138
121
  dependencies: {
139
- "@socketregistry/packageurl-js": "1.4.1",
140
- "@socketsecurity/lib": "5.11.4",
122
+ "@socketsecurity/lib": "5.15.0",
141
123
  "form-data": "4.0.5"
142
124
  },
143
125
  devDependencies: {
144
- "@anthropic-ai/claude-code": "2.1.89",
126
+ "@anthropic-ai/claude-code": "2.1.92",
145
127
  "@babel/generator": "7.28.5",
146
128
  "@babel/parser": "7.26.3",
147
129
  "@babel/traverse": "7.26.4",
@@ -159,7 +141,6 @@ var package_default = {
159
141
  "ecc-agentshield": "1.4.0",
160
142
  esbuild: "0.25.11",
161
143
  "fast-glob": "3.3.3",
162
- "http2-wrapper": "2.2.1",
163
144
  husky: "9.1.7",
164
145
  "magic-string": "0.30.14",
165
146
  nock: "14.0.10",
@@ -193,7 +174,8 @@ var package_default = {
193
174
  "unrs-resolver"
194
175
  ],
195
176
  overrides: {
196
- vite: "7.1.12"
177
+ defu: ">=6.1.6",
178
+ vite: "7.3.2"
197
179
  }
198
180
  }
199
181
  };
@@ -330,111 +312,6 @@ var publicPolicy = /* @__PURE__ */ new Map([
330
312
  ["zeroWidth", "ignore"]
331
313
  ]);
332
314
 
333
- // src/utils.ts
334
- var import_node_path = __toESM(require("node:path"));
335
- var import_node_process = __toESM(require("node:process"));
336
- var import_memoization = require("@socketsecurity/lib/memoization");
337
- var import_normalize = require("@socketsecurity/lib/paths/normalize");
338
- function normalizeToWordSet(s) {
339
- const words = s.toLowerCase().match(/\w+/g);
340
- return new Set(words ?? []);
341
- }
342
- function calculateWordSetSimilarity(str1, str2) {
343
- const set1 = normalizeToWordSet(str1);
344
- const set2 = normalizeToWordSet(str2);
345
- if (set1.size === 0 && set2.size === 0) {
346
- return 1;
347
- }
348
- if (set1.size === 0 || set2.size === 0) {
349
- return 0;
350
- }
351
- let intersectionSize = 0;
352
- for (const word of set1) {
353
- if (set2.has(word)) {
354
- intersectionSize++;
355
- }
356
- }
357
- const unionSize = set1.size + set2.size - intersectionSize;
358
- return intersectionSize / unionSize;
359
- }
360
- function filterRedundantCause(errorMessage, errorCause, threshold = 0.6) {
361
- if (!errorCause || !errorCause.trim()) {
362
- return void 0;
363
- }
364
- const messageParts = errorMessage.split(":").map((part) => part.trim());
365
- for (const part of messageParts) {
366
- if (part && shouldOmitReason(part, errorCause, threshold)) {
367
- return void 0;
368
- }
369
- }
370
- return errorCause;
371
- }
372
- var normalizeBaseUrl = (0, import_memoization.memoize)(
373
- (baseUrl) => {
374
- return baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
375
- },
376
- { name: "normalizeBaseUrl" }
377
- );
378
- function promiseWithResolvers() {
379
- if (Promise.withResolvers) {
380
- return Promise.withResolvers();
381
- }
382
- const obj = {};
383
- obj.promise = new Promise((resolver, reject) => {
384
- obj.resolve = resolver;
385
- obj.reject = reject;
386
- });
387
- return obj;
388
- }
389
- function queryToSearchParams(init) {
390
- const params = new URLSearchParams(
391
- init
392
- );
393
- const normalized = { __proto__: null };
394
- const entries = params.entries();
395
- for (const entry of entries) {
396
- let key = entry[0];
397
- const value = entry[1];
398
- if (key === "defaultBranch") {
399
- key = "default_branch";
400
- } else if (key === "perPage") {
401
- key = "per_page";
402
- }
403
- if (value) {
404
- normalized[key] = value;
405
- }
406
- }
407
- return new URLSearchParams(normalized);
408
- }
409
- function resolveAbsPaths(filepaths, pathsRelativeTo) {
410
- const basePath = resolveBasePath(pathsRelativeTo);
411
- return filepaths.map((p) => (0, import_normalize.normalizePath)(import_node_path.default.resolve(basePath, p)));
412
- }
413
- function resolveBasePath(pathsRelativeTo = ".") {
414
- return (0, import_normalize.normalizePath)(import_node_path.default.resolve(import_node_process.default.cwd(), pathsRelativeTo));
415
- }
416
- function shouldOmitReason(errorMessage, reason, threshold = 0.6) {
417
- if (!reason || !reason.trim()) {
418
- return true;
419
- }
420
- const similarity = calculateWordSetSimilarity(errorMessage, reason);
421
- return similarity >= threshold;
422
- }
423
-
424
- // src/file-upload.ts
425
- var import_node_fs = require("node:fs");
426
- var import_node_path2 = __toESM(require("node:path"));
427
- var import_node_stream = require("node:stream");
428
- var import_form_data = __toESM(require("form-data"));
429
- var import_normalize2 = require("@socketsecurity/lib/paths/normalize");
430
-
431
- // src/http-client.ts
432
- var import_node_http = __toESM(require("node:http"));
433
- var import_node_https = __toESM(require("node:https"));
434
- var import_debug = require("@socketsecurity/lib/debug");
435
- var import_parse = require("@socketsecurity/lib/json/parse");
436
- var import_performance = require("@socketsecurity/lib/performance");
437
-
438
315
  // src/utils/header-sanitization.ts
439
316
  var SENSITIVE_HEADERS = [
440
317
  "authorization",
@@ -467,13 +344,9 @@ function sanitizeHeaders(headers) {
467
344
  var ResponseError = class _ResponseError extends Error {
468
345
  response;
469
346
  url;
470
- /**
471
- * Create a new ResponseError from an HTTP response.
472
- * Automatically formats error message with status code and message.
473
- */
474
347
  constructor(response, message = "", url) {
475
- const statusCode = response.statusCode ?? "unknown";
476
- const statusMessage = response.statusMessage ?? "No status message";
348
+ const statusCode = response.status ?? "unknown";
349
+ const statusMessage = response.statusText || "No status message";
477
350
  super(
478
351
  /* c8 ignore next - fallback empty message if not provided */
479
352
  `Socket API ${message || "Request failed"} (${statusCode}): ${statusMessage}`
@@ -493,34 +366,41 @@ async function createDeleteRequest(baseUrl, urlPath, options) {
493
366
  ...options
494
367
  };
495
368
  const opts = { __proto__: null, ...rawOpts };
496
- hooks?.onRequest?.({
497
- method,
498
- url,
499
- headers: sanitizeHeaders(opts.headers),
500
- timeout: opts.timeout
501
- });
502
- try {
503
- const req = getHttpModule(baseUrl).request(url, {
504
- method,
505
- ...opts
506
- }).end();
507
- const response = await getResponse(req);
508
- hooks?.onResponse?.({
369
+ if (hooks?.onRequest) {
370
+ hooks.onRequest({
509
371
  method,
510
372
  url,
511
- duration: Date.now() - startTime,
512
- status: response.statusCode,
513
- statusText: response.statusMessage,
514
- headers: sanitizeHeaders(response.headers)
373
+ headers: sanitizeHeaders(opts.headers),
374
+ timeout: opts.timeout
515
375
  });
516
- return response;
517
- } catch (error) {
518
- hooks?.onResponse?.({
376
+ }
377
+ try {
378
+ const response = await (0, import_http_request.httpRequest)(url, {
519
379
  method,
520
- url,
521
- duration: Date.now() - startTime,
522
- error
380
+ headers: opts.headers,
381
+ timeout: opts.timeout,
382
+ maxResponseSize: MAX_RESPONSE_SIZE
523
383
  });
384
+ if (hooks?.onResponse) {
385
+ hooks.onResponse({
386
+ method,
387
+ url,
388
+ duration: Date.now() - startTime,
389
+ status: response.status,
390
+ statusText: response.statusText,
391
+ headers: sanitizeHeaders(response.headers)
392
+ });
393
+ }
394
+ return response;
395
+ } catch (error) {
396
+ if (hooks?.onResponse) {
397
+ hooks.onResponse({
398
+ method,
399
+ url,
400
+ duration: Date.now() - startTime,
401
+ error
402
+ });
403
+ }
524
404
  throw error;
525
405
  }
526
406
  }
@@ -534,36 +414,43 @@ async function createGetRequest(baseUrl, urlPath, options) {
534
414
  ...options
535
415
  };
536
416
  const opts = { __proto__: null, ...rawOpts };
537
- hooks?.onRequest?.({
538
- method,
539
- url,
540
- headers: sanitizeHeaders(opts.headers),
541
- timeout: opts.timeout
542
- });
543
- try {
544
- const req = getHttpModule(baseUrl).request(url, {
545
- method,
546
- ...opts
547
- }).end();
548
- const response = await getResponse(req);
549
- stopTimer({ statusCode: response.statusCode });
550
- hooks?.onResponse?.({
417
+ if (hooks?.onRequest) {
418
+ hooks.onRequest({
551
419
  method,
552
420
  url,
553
- duration: Date.now() - startTime,
554
- status: response.statusCode,
555
- statusText: response.statusMessage,
556
- headers: sanitizeHeaders(response.headers)
421
+ headers: sanitizeHeaders(opts.headers),
422
+ timeout: opts.timeout
423
+ });
424
+ }
425
+ try {
426
+ const response = await (0, import_http_request.httpRequest)(url, {
427
+ method,
428
+ headers: opts.headers,
429
+ timeout: opts.timeout,
430
+ maxResponseSize: MAX_RESPONSE_SIZE
557
431
  });
432
+ stopTimer({ statusCode: response.status });
433
+ if (hooks?.onResponse) {
434
+ hooks.onResponse({
435
+ method,
436
+ url,
437
+ duration: Date.now() - startTime,
438
+ status: response.status,
439
+ statusText: response.statusText,
440
+ headers: sanitizeHeaders(response.headers)
441
+ });
442
+ }
558
443
  return response;
559
444
  } catch (error) {
560
445
  stopTimer({ error: true });
561
- hooks?.onResponse?.({
562
- method,
563
- url,
564
- duration: Date.now() - startTime,
565
- error
566
- });
446
+ if (hooks?.onResponse) {
447
+ hooks.onResponse({
448
+ method,
449
+ url,
450
+ duration: Date.now() - startTime,
451
+ error
452
+ });
453
+ }
567
454
  throw error;
568
455
  }
569
456
  }
@@ -581,157 +468,49 @@ async function createRequestWithJson(method, baseUrl, urlPath, json, options) {
581
468
  const body = JSON.stringify(json);
582
469
  const headers = {
583
470
  ...opts.headers,
584
- "Content-Length": Buffer.byteLength(body, "utf8"),
585
471
  "Content-Type": "application/json"
586
472
  };
587
- hooks?.onRequest?.({
588
- method,
589
- url,
590
- headers: sanitizeHeaders(headers),
591
- timeout: opts.timeout
592
- });
593
- try {
594
- const req = getHttpModule(baseUrl).request(url, {
473
+ if (hooks?.onRequest) {
474
+ hooks.onRequest({
595
475
  method,
596
- ...opts,
597
- headers
476
+ url,
477
+ headers: sanitizeHeaders(headers),
478
+ timeout: opts.timeout
598
479
  });
599
- req.write(body);
600
- req.end();
601
- const response = await getResponse(req);
602
- stopTimer({ statusCode: response.statusCode });
603
- hooks?.onResponse?.({
480
+ }
481
+ try {
482
+ const response = await (0, import_http_request.httpRequest)(url, {
604
483
  method,
605
- url,
606
- duration: Date.now() - startTime,
607
- status: response.statusCode,
608
- statusText: response.statusMessage,
609
- headers: sanitizeHeaders(response.headers)
484
+ body,
485
+ headers,
486
+ timeout: opts.timeout,
487
+ maxResponseSize: MAX_RESPONSE_SIZE
610
488
  });
489
+ stopTimer({ statusCode: response.status });
490
+ if (hooks?.onResponse) {
491
+ hooks.onResponse({
492
+ method,
493
+ url,
494
+ duration: Date.now() - startTime,
495
+ status: response.status,
496
+ statusText: response.statusText,
497
+ headers: sanitizeHeaders(response.headers)
498
+ });
499
+ }
611
500
  return response;
612
501
  } catch (error) {
613
502
  stopTimer({ error: true });
614
- hooks?.onResponse?.({
615
- method,
616
- url,
617
- duration: Date.now() - startTime,
618
- error
619
- });
503
+ if (hooks?.onResponse) {
504
+ hooks.onResponse({
505
+ method,
506
+ url,
507
+ duration: Date.now() - startTime,
508
+ error
509
+ });
510
+ }
620
511
  throw error;
621
512
  }
622
513
  }
623
- async function getErrorResponseBody(response) {
624
- return await new Promise((resolve, reject) => {
625
- let body = "";
626
- let totalBytes = 0;
627
- response.setEncoding("utf8");
628
- response.on("data", (chunk) => {
629
- const chunkBytes = Buffer.byteLength(chunk, "utf8");
630
- if (totalBytes + chunkBytes > MAX_RESPONSE_SIZE) {
631
- response.destroy();
632
- const projectedSize = totalBytes + chunkBytes;
633
- const sizeMB = (projectedSize / (1024 * 1024)).toFixed(2);
634
- const maxMB = (MAX_RESPONSE_SIZE / (1024 * 1024)).toFixed(2);
635
- const message = [
636
- `Response exceeds maximum size limit (${sizeMB}MB > ${maxMB}MB)`,
637
- "\u2192 The API response is too large to process safely.",
638
- "\u2192 Try: Use pagination parameters (limit, offset) to reduce response size.",
639
- "\u2192 Try: Request specific fields instead of full objects.",
640
- "\u2192 Contact support if you need to process larger responses."
641
- ].join("\n");
642
- reject(new Error(message));
643
- return;
644
- }
645
- totalBytes += chunkBytes;
646
- body += chunk;
647
- });
648
- response.on("end", () => resolve(body));
649
- response.on("error", (e) => reject(e));
650
- });
651
- }
652
- function getHttpModule(url) {
653
- return url.startsWith("https:") ? import_node_https.default : import_node_http.default;
654
- }
655
- async function getResponse(req) {
656
- return await new Promise((resolve, reject) => {
657
- let timedOut = false;
658
- req.on("response", (response) => {
659
- if (timedOut) {
660
- return;
661
- }
662
- resolve(response);
663
- });
664
- req.on("timeout", () => {
665
- timedOut = true;
666
- req.destroy();
667
- const method = req.method || "REQUEST";
668
- const path4 = req.path || "unknown";
669
- const timeout = req.timeout || "configured timeout";
670
- const message = [
671
- `${method} request timed out after ${timeout}ms: ${path4}`,
672
- "\u2192 The Socket API did not respond in time.",
673
- "\u2192 Try: Increase timeout option or check network connectivity.",
674
- "\u2192 If problem persists, Socket API may be experiencing issues."
675
- ].join("\n");
676
- reject(new Error(message));
677
- });
678
- req.on("error", (e) => {
679
- if (!timedOut) {
680
- const err = e;
681
- const method = req.method || "REQUEST";
682
- const path4 = req.path || "unknown";
683
- let message = `${method} request failed: ${path4}`;
684
- if (err.code === "ECONNREFUSED") {
685
- message += [
686
- "",
687
- "\u2192 Connection refused. Socket API server is unreachable.",
688
- "\u2192 Check: Network connectivity and firewall settings.",
689
- "\u2192 Verify: Base URL is correct (default: https://api.socket.dev)"
690
- ].join("\n");
691
- } else if (err.code === "ENOTFOUND") {
692
- message += [
693
- "",
694
- "\u2192 DNS lookup failed. Cannot resolve hostname.",
695
- "\u2192 Check: Internet connection and DNS settings.",
696
- "\u2192 Verify: Base URL hostname is correct."
697
- ].join("\n");
698
- } else if (err.code === "ETIMEDOUT") {
699
- message += [
700
- "",
701
- "\u2192 Connection timed out. Network or server issue.",
702
- "\u2192 Try: Check network connectivity and retry.",
703
- "\u2192 If using proxy, verify proxy configuration."
704
- ].join("\n");
705
- } else if (err.code === "ECONNRESET") {
706
- message += [
707
- "",
708
- "\u2192 Connection reset by server. Possible network interruption.",
709
- "\u2192 Try: Retry the request. Enable retries option if not set."
710
- ].join("\n");
711
- } else if (err.code === "EPIPE") {
712
- message += [
713
- "",
714
- "\u2192 Broken pipe. Server closed connection unexpectedly.",
715
- "\u2192 Possible: Authentication issue or server error.",
716
- "\u2192 Check: API token is valid and has required permissions."
717
- ].join("\n");
718
- } else if (err.code === "CERT_HAS_EXPIRED" || err.code === "UNABLE_TO_VERIFY_LEAF_SIGNATURE") {
719
- message += [
720
- "",
721
- "\u2192 SSL/TLS certificate error.",
722
- "\u2192 Check: System time and date are correct.",
723
- "\u2192 Try: Update CA certificates on your system."
724
- ].join("\n");
725
- } else if (err.code) {
726
- message += `
727
- \u2192 Error code: ${err.code}`;
728
- }
729
- const enhancedError = new Error(message, { cause: e });
730
- reject(enhancedError);
731
- }
732
- });
733
- });
734
- }
735
514
  async function getResponseJson(response, method, url) {
736
515
  const stopTimer = (0, import_performance.perfTimer)("http:parse-json");
737
516
  try {
@@ -742,7 +521,7 @@ async function getResponseJson(response, method, url) {
742
521
  url
743
522
  );
744
523
  }
745
- const responseBody = await getErrorResponseBody(response);
524
+ const responseBody = response.text();
746
525
  if (responseBody === "") {
747
526
  (0, import_debug.debugLog)("API response: empty response treated as {}");
748
527
  stopTimer({ success: true });
@@ -806,12 +585,11 @@ async function getResponseJson(response, method, url) {
806
585
  }
807
586
  }
808
587
  function isResponseOk(response) {
809
- const { statusCode } = response;
810
- return statusCode ? statusCode >= 200 && statusCode < 300 : false;
588
+ return response.ok;
811
589
  }
812
590
  function reshapeArtifactForPublicPolicy(data, isAuthenticated, actions, policy) {
813
591
  if (!isAuthenticated) {
814
- const allowedActions = actions?.trim() ? actions.split(",") : void 0;
592
+ const allowedActions = actions?.trim() ? new Set(actions.split(",")) : void 0;
815
593
  const resolvedPolicy = policy ?? publicPolicy;
816
594
  const reshapeArtifact = (artifact) => ({
817
595
  name: artifact.name,
@@ -822,23 +600,22 @@ function reshapeArtifactForPublicPolicy(data, isAuthenticated, actions, policy)
822
600
  supplyChainRisk: artifact.supplyChainRisk,
823
601
  scorecards: artifact.scorecards,
824
602
  topLevelAncestors: artifact.topLevelAncestors,
825
- // Compact the alerts array to reduce response size for non-authenticated
826
- // requests.
827
- alerts: artifact.alerts?.filter((alert) => {
828
- const action = resolvedPolicy.get(alert.type);
603
+ alerts: artifact.alerts?.reduce((acc, alert) => {
829
604
  if (alert.severity === "low") {
830
- return false;
605
+ return acc;
831
606
  }
832
- if (allowedActions && action && !allowedActions.includes(action)) {
833
- return false;
607
+ const action = resolvedPolicy.get(alert.type);
608
+ if (allowedActions && action && !allowedActions.has(action)) {
609
+ return acc;
834
610
  }
835
- return true;
836
- }).map((alert) => ({
837
- action: resolvedPolicy.get(alert.type),
838
- key: alert.key,
839
- severity: alert.severity,
840
- type: alert.type
841
- }))
611
+ acc.push({
612
+ action,
613
+ key: alert.key,
614
+ severity: alert.severity,
615
+ type: alert.type
616
+ });
617
+ return acc;
618
+ }, [])
842
619
  });
843
620
  if (data["artifacts"]) {
844
621
  const artifacts = data["artifacts"];
@@ -856,121 +633,22 @@ function reshapeArtifactForPublicPolicy(data, isAuthenticated, actions, policy)
856
633
  return data;
857
634
  }
858
635
 
859
- // src/file-upload.ts
860
- function createRequestBodyForFilepaths(filepaths, basePath) {
861
- const form = new import_form_data.default();
862
- for (const absPath of filepaths) {
863
- const relPath = (0, import_normalize2.normalizePath)(import_node_path2.default.relative(basePath, absPath));
864
- const filename = import_node_path2.default.basename(absPath);
865
- let stream;
866
- try {
867
- stream = (0, import_node_fs.createReadStream)(absPath, { highWaterMark: 1024 * 1024 });
868
- } catch (error) {
869
- const err = error;
870
- let message = `Failed to read file: ${absPath}`;
871
- if (err.code === "ENOENT") {
872
- message += "\n\u2192 File does not exist. Check the file path and try again.";
873
- } else if (err.code === "EACCES") {
874
- message += `
875
- \u2192 Permission denied. Run: chmod +r "${absPath}"`;
876
- } else if (err.code === "EISDIR") {
877
- message += "\n\u2192 Expected a file but found a directory.";
878
- } else if (err.code) {
879
- message += `
880
- \u2192 Error code: ${err.code}`;
881
- }
882
- throw new Error(message, { cause: error });
883
- }
884
- form.append(relPath, stream, {
885
- contentType: "application/octet-stream",
886
- filename
887
- });
888
- }
889
- return form;
890
- }
891
- function createRequestBodyForJson(jsonData, basename = "data.json") {
892
- const ext = import_node_path2.default.extname(basename);
893
- const name = import_node_path2.default.basename(basename, ext);
894
- const jsonStream = import_node_stream.Readable.from(JSON.stringify(jsonData), {
895
- highWaterMark: 1024 * 1024
896
- });
897
- const form = new import_form_data.default();
898
- form.append(name, jsonStream, {
899
- contentType: "application/json",
900
- filename: basename
901
- });
902
- return form;
903
- }
904
- async function createUploadRequest(baseUrl, urlPath, form, options) {
905
- const { hooks, ...rawOpts } = {
906
- __proto__: null,
907
- ...options
908
- };
909
- const opts = { __proto__: null, ...rawOpts };
910
- return await new Promise((pass, fail) => {
911
- const url = new URL(urlPath, baseUrl);
912
- const method = "POST";
913
- const formHeaders = form.getHeaders();
914
- const headers = {
915
- ...opts?.headers,
916
- ...formHeaders
917
- };
918
- const startTime = Date.now();
919
- const req = getHttpModule(baseUrl).request(url, {
920
- method,
921
- ...opts,
922
- headers
923
- });
924
- hooks?.onRequest?.({
925
- method,
926
- url: url.toString(),
927
- headers: sanitizeHeaders(headers),
928
- timeout: opts.timeout
929
- });
930
- req.flushHeaders();
931
- void getResponse(req).then(
932
- (response) => {
933
- hooks?.onResponse?.({
934
- method,
935
- url: url.toString(),
936
- duration: Date.now() - startTime,
937
- status: response.statusCode,
938
- statusText: response.statusMessage,
939
- headers: sanitizeHeaders(response.headers)
940
- });
941
- pass(response);
942
- },
943
- (error) => {
944
- hooks?.onResponse?.({
945
- method,
946
- url: url.toString(),
947
- duration: Date.now() - startTime,
948
- error
949
- });
950
- fail(error);
951
- }
952
- );
953
- form.pipe(req);
954
- form.on("error", fail);
955
- });
956
- }
957
-
958
636
  // src/quota-utils.ts
959
- var import_node_fs2 = require("node:fs");
960
- var import_node_path3 = require("node:path");
961
- var import_memoization2 = require("@socketsecurity/lib/memoization");
962
- var loadRequirements = (0, import_memoization2.once)(() => {
637
+ var import_node_fs = require("node:fs");
638
+ var import_node_path = require("node:path");
639
+ var import_memoization = require("@socketsecurity/lib/memoization");
640
+ var loadRequirements = (0, import_memoization.once)(() => {
963
641
  try {
964
- const requirementsPath = (0, import_node_path3.join)(
642
+ const requirementsPath = (0, import_node_path.join)(
965
643
  __dirname,
966
644
  "..",
967
645
  "data",
968
646
  "api-method-quota-and-permissions.json"
969
647
  );
970
- if (!(0, import_node_fs2.existsSync)(requirementsPath)) {
648
+ if (!(0, import_node_fs.existsSync)(requirementsPath)) {
971
649
  throw new Error(`Requirements file not found at: ${requirementsPath}`);
972
650
  }
973
- const data = (0, import_node_fs2.readFileSync)(requirementsPath, "utf8");
651
+ const data = (0, import_node_fs.readFileSync)(requirementsPath, "utf8");
974
652
  return JSON.parse(data);
975
653
  } catch (e) {
976
654
  throw new Error("Failed to load SDK method requirements", { cause: e });
@@ -992,7 +670,7 @@ function getAllMethodRequirements() {
992
670
  });
993
671
  return result;
994
672
  }
995
- var getMethodRequirements = (0, import_memoization2.memoize)(
673
+ var getMethodRequirements = (0, import_memoization.memoize)(
996
674
  (methodName) => {
997
675
  const reqs = loadRequirements();
998
676
  const requirement = reqs.api[methodName];
@@ -1006,7 +684,7 @@ var getMethodRequirements = (0, import_memoization2.memoize)(
1006
684
  },
1007
685
  { name: "getMethodRequirements" }
1008
686
  );
1009
- var getMethodsByPermissions = (0, import_memoization2.memoize)(
687
+ var getMethodsByPermissions = (0, import_memoization.memoize)(
1010
688
  (permissions) => {
1011
689
  const reqs = loadRequirements();
1012
690
  return Object.entries(reqs.api).filter(([, requirement]) => {
@@ -1017,14 +695,14 @@ var getMethodsByPermissions = (0, import_memoization2.memoize)(
1017
695
  },
1018
696
  { name: "getMethodsByPermissions" }
1019
697
  );
1020
- var getMethodsByQuotaCost = (0, import_memoization2.memoize)(
698
+ var getMethodsByQuotaCost = (0, import_memoization.memoize)(
1021
699
  (quotaCost) => {
1022
700
  const reqs = loadRequirements();
1023
701
  return Object.entries(reqs.api).filter(([, requirement]) => requirement.quota === quotaCost).map(([methodName]) => methodName).sort();
1024
702
  },
1025
703
  { name: "getMethodsByQuotaCost" }
1026
704
  );
1027
- var getQuotaCost = (0, import_memoization2.memoize)(
705
+ var getQuotaCost = (0, import_memoization.memoize)(
1028
706
  (methodName) => {
1029
707
  const reqs = loadRequirements();
1030
708
  const requirement = reqs.api[methodName];
@@ -1035,7 +713,7 @@ var getQuotaCost = (0, import_memoization2.memoize)(
1035
713
  },
1036
714
  { name: "getQuotaCost" }
1037
715
  );
1038
- var getQuotaUsageSummary = (0, import_memoization2.memoize)(
716
+ var getQuotaUsageSummary = (0, import_memoization.memoize)(
1039
717
  () => {
1040
718
  const reqs = loadRequirements();
1041
719
  const summary = {};
@@ -1053,7 +731,7 @@ var getQuotaUsageSummary = (0, import_memoization2.memoize)(
1053
731
  },
1054
732
  { name: "getQuotaUsageSummary" }
1055
733
  );
1056
- var getRequiredPermissions = (0, import_memoization2.memoize)(
734
+ var getRequiredPermissions = (0, import_memoization.memoize)(
1057
735
  (methodName) => {
1058
736
  const reqs = loadRequirements();
1059
737
  const requirement = reqs.api[methodName];
@@ -1070,11 +748,8 @@ function hasQuotaForMethods(availableQuota, methodNames) {
1070
748
  }
1071
749
 
1072
750
  // src/socket-sdk-class.ts
1073
- var import_node_events = __toESM(require("node:events"));
1074
- var import_node_fs3 = require("node:fs");
1075
751
  var import_node_path4 = __toESM(require("node:path"));
1076
752
  var import_node_process2 = __toESM(require("node:process"));
1077
- var import_node_readline = __toESM(require("node:readline"));
1078
753
  var import_cache_with_ttl = require("@socketsecurity/lib/cache-with-ttl");
1079
754
  var import_core = require("@socketsecurity/lib/constants/core");
1080
755
  var import_process = require("@socketsecurity/lib/constants/process");
@@ -1086,6 +761,202 @@ var import_objects = require("@socketsecurity/lib/objects");
1086
761
  var import_promises = require("@socketsecurity/lib/promises");
1087
762
  var import_suppress_warnings = require("@socketsecurity/lib/suppress-warnings");
1088
763
  var import_url = require("@socketsecurity/lib/url");
764
+ var import_http_request3 = require("@socketsecurity/lib/http-request");
765
+
766
+ // src/file-upload.ts
767
+ var import_node_fs2 = require("node:fs");
768
+ var import_node_path2 = __toESM(require("node:path"));
769
+ var import_form_data = __toESM(require("form-data"));
770
+ var import_http_request2 = require("@socketsecurity/lib/http-request");
771
+ var import_normalize = require("@socketsecurity/lib/paths/normalize");
772
+ function createRequestBodyForFilepaths(filepaths, basePath) {
773
+ const form = new import_form_data.default();
774
+ for (const absPath of filepaths) {
775
+ const relPath = (0, import_normalize.normalizePath)(import_node_path2.default.relative(basePath, absPath));
776
+ const filename = import_node_path2.default.basename(absPath);
777
+ let stream;
778
+ try {
779
+ stream = (0, import_node_fs2.createReadStream)(absPath, { highWaterMark: 1024 * 1024 });
780
+ } catch (error) {
781
+ const err = error;
782
+ let message = `Failed to read file: ${absPath}`;
783
+ if (err.code === "ENOENT") {
784
+ message += "\n\u2192 File does not exist. Check the file path and try again.";
785
+ } else if (err.code === "EACCES") {
786
+ message += `
787
+ \u2192 Permission denied. Run: chmod +r "${absPath}"`;
788
+ } else if (err.code === "EISDIR") {
789
+ message += "\n\u2192 Expected a file but found a directory.";
790
+ } else if (err.code) {
791
+ message += `
792
+ \u2192 Error code: ${err.code}`;
793
+ }
794
+ throw new Error(message, { cause: error });
795
+ }
796
+ form.append(relPath, stream, {
797
+ contentType: "application/octet-stream",
798
+ filename
799
+ });
800
+ }
801
+ return form;
802
+ }
803
+ async function createUploadRequest(baseUrl, urlPath, form, options) {
804
+ const { hooks, ...rawOpts } = {
805
+ __proto__: null,
806
+ ...options
807
+ };
808
+ const opts = { __proto__: null, ...rawOpts };
809
+ const url = new URL(urlPath, baseUrl).toString();
810
+ const method = "POST";
811
+ const startTime = Date.now();
812
+ const headers = {
813
+ ...opts.headers
814
+ };
815
+ if (hooks?.onRequest) {
816
+ hooks.onRequest({
817
+ method,
818
+ url,
819
+ headers: sanitizeHeaders(headers),
820
+ timeout: opts.timeout
821
+ });
822
+ }
823
+ try {
824
+ const response = await (0, import_http_request2.httpRequest)(url, {
825
+ method,
826
+ body: form,
827
+ headers,
828
+ maxResponseSize: MAX_RESPONSE_SIZE,
829
+ timeout: opts.timeout
830
+ });
831
+ if (hooks?.onResponse) {
832
+ hooks.onResponse({
833
+ method,
834
+ url,
835
+ duration: Date.now() - startTime,
836
+ status: response.status,
837
+ statusText: response.statusText,
838
+ headers: sanitizeHeaders(response.headers)
839
+ });
840
+ }
841
+ return response;
842
+ } catch (error) {
843
+ if (hooks?.onResponse) {
844
+ hooks.onResponse({
845
+ method,
846
+ url,
847
+ duration: Date.now() - startTime,
848
+ error
849
+ });
850
+ }
851
+ throw error;
852
+ }
853
+ }
854
+
855
+ // src/utils.ts
856
+ var import_node_path3 = __toESM(require("node:path"));
857
+ var import_node_process = __toESM(require("node:process"));
858
+ var import_memoization2 = require("@socketsecurity/lib/memoization");
859
+ var import_normalize2 = require("@socketsecurity/lib/paths/normalize");
860
+ function normalizeToWordSet(s) {
861
+ const words = s.toLowerCase().match(/\w+/g);
862
+ return new Set(words ?? []);
863
+ }
864
+ function calculateWordSetSimilarity(str1, str2) {
865
+ const set1 = normalizeToWordSet(str1);
866
+ const set2 = normalizeToWordSet(str2);
867
+ if (set1.size === 0 && set2.size === 0) {
868
+ return 1;
869
+ }
870
+ if (set1.size === 0 || set2.size === 0) {
871
+ return 0;
872
+ }
873
+ let intersectionSize = 0;
874
+ for (const word of set1) {
875
+ if (set2.has(word)) {
876
+ intersectionSize++;
877
+ }
878
+ }
879
+ const unionSize = set1.size + set2.size - intersectionSize;
880
+ return intersectionSize / unionSize;
881
+ }
882
+ function filterRedundantCause(errorMessage, errorCause, threshold = 0.6) {
883
+ if (!errorCause || !errorCause.trim()) {
884
+ return void 0;
885
+ }
886
+ const messageParts = errorMessage.split(":").map((part) => part.trim());
887
+ for (const part of messageParts) {
888
+ if (part && shouldOmitReason(part, errorCause, threshold)) {
889
+ return void 0;
890
+ }
891
+ }
892
+ return errorCause;
893
+ }
894
+ var normalizeBaseUrl = (0, import_memoization2.memoize)(
895
+ (baseUrl) => {
896
+ return baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
897
+ },
898
+ { name: "normalizeBaseUrl" }
899
+ );
900
+ function promiseWithResolvers() {
901
+ if (Promise.withResolvers) {
902
+ return Promise.withResolvers();
903
+ }
904
+ const obj = {};
905
+ obj.promise = new Promise((resolver, reject) => {
906
+ obj.resolve = resolver;
907
+ obj.reject = reject;
908
+ });
909
+ return obj;
910
+ }
911
+ function queryToSearchParams(init) {
912
+ const params = new URLSearchParams(
913
+ init
914
+ );
915
+ let needsNormalization = false;
916
+ let hasEmpty = false;
917
+ for (const [key, value] of params) {
918
+ if (key === "defaultBranch" || key === "perPage") {
919
+ needsNormalization = true;
920
+ break;
921
+ }
922
+ if (!value) {
923
+ hasEmpty = true;
924
+ }
925
+ }
926
+ if (!needsNormalization && !hasEmpty) {
927
+ return params;
928
+ }
929
+ const normalized = new URLSearchParams();
930
+ for (const [key, value] of params) {
931
+ if (!value) {
932
+ continue;
933
+ }
934
+ if (key === "defaultBranch") {
935
+ normalized.set("default_branch", value);
936
+ } else if (key === "perPage") {
937
+ normalized.set("per_page", value);
938
+ } else {
939
+ normalized.set(key, value);
940
+ }
941
+ }
942
+ return normalized;
943
+ }
944
+ function resolveAbsPaths(filepaths, pathsRelativeTo) {
945
+ const basePath = resolveBasePath(pathsRelativeTo);
946
+ return filepaths.map((p) => (0, import_normalize2.normalizePath)(import_node_path3.default.resolve(basePath, p)));
947
+ }
948
+ function resolveBasePath(pathsRelativeTo = ".") {
949
+ return (0, import_normalize2.normalizePath)(import_node_path3.default.resolve(import_node_process.default.cwd(), pathsRelativeTo));
950
+ }
951
+ function shouldOmitReason(errorMessage, reason, threshold = 0.6) {
952
+ if (!reason || !reason.trim()) {
953
+ return true;
954
+ }
955
+ const similarity = calculateWordSetSimilarity(errorMessage, reason);
956
+ return similarity >= threshold;
957
+ }
958
+
959
+ // src/socket-sdk-class.ts
1089
960
  var abortSignal = (0, import_process.getAbortSignal)();
1090
961
  var SocketSdk = class _SocketSdk {
1091
962
  #apiToken;
@@ -1096,6 +967,7 @@ var SocketSdk = class _SocketSdk {
1096
967
  #hooks;
1097
968
  #onFileValidation;
1098
969
  #reqOptions;
970
+ #reqOptionsWithHooks;
1099
971
  #retries;
1100
972
  #retryDelay;
1101
973
  /**
@@ -1168,6 +1040,10 @@ var SocketSdk = class _SocketSdk {
1168
1040
  /* c8 ignore next - Optional timeout parameter, tested implicitly through method calls */
1169
1041
  ...timeout ? { timeout } : {}
1170
1042
  };
1043
+ this.#reqOptionsWithHooks = {
1044
+ ...this.#reqOptions,
1045
+ hooks: this.#hooks
1046
+ };
1171
1047
  }
1172
1048
  /**
1173
1049
  * Create async generator for streaming batch package URL processing.
@@ -1186,33 +1062,30 @@ var SocketSdk = class _SocketSdk {
1186
1062
  if (!res) {
1187
1063
  throw new Error("Failed to get response from batch PURL request");
1188
1064
  }
1189
- const rli = import_node_readline.default.createInterface({
1190
- input: res,
1191
- crlfDelay: Number.POSITIVE_INFINITY,
1192
- signal: abortSignal
1193
- });
1194
1065
  const isPublicToken = this.#apiToken === import_socket2.SOCKET_PUBLIC_API_TOKEN;
1195
- try {
1196
- for await (const line of rli) {
1197
- const trimmed = line.trim();
1198
- const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1199
- /* c8 ignore next - Empty line handling in batch streaming response parsing. */
1200
- null
1201
- );
1202
- if ((0, import_objects.isObjectObject)(artifact)) {
1203
- yield this.#handleApiSuccess(
1204
- /* c8 ignore next 8 - Public token artifact reshaping branch for policy compliance. */
1205
- isPublicToken ? reshapeArtifactForPublicPolicy(
1206
- artifact,
1207
- false,
1208
- queryParams?.["actions"],
1209
- publicPolicy
1210
- ) : artifact
1211
- );
1066
+ const text = res.text();
1067
+ let start = 0;
1068
+ for (let i = 0; i <= text.length; i++) {
1069
+ if (i === text.length || text.charCodeAt(i) === 10) {
1070
+ if (i > start) {
1071
+ const line = text.slice(start, i);
1072
+ const artifact = (0, import_parse2.jsonParse)(line, {
1073
+ throws: false
1074
+ });
1075
+ if ((0, import_objects.isObjectObject)(artifact)) {
1076
+ yield this.#handleApiSuccess(
1077
+ /* c8 ignore next 8 - Public token artifact reshaping branch for policy compliance. */
1078
+ isPublicToken ? reshapeArtifactForPublicPolicy(
1079
+ artifact,
1080
+ false,
1081
+ queryParams?.["actions"],
1082
+ publicPolicy
1083
+ ) : artifact
1084
+ );
1085
+ }
1212
1086
  }
1087
+ start = i + 1;
1213
1088
  }
1214
- } finally {
1215
- rli.close();
1216
1089
  }
1217
1090
  }
1218
1091
  /**
@@ -1221,11 +1094,13 @@ var SocketSdk = class _SocketSdk {
1221
1094
  */
1222
1095
  async #createBatchPurlRequest(componentsObj, queryParams) {
1223
1096
  const url = `${this.#baseUrl}purl?${queryToSearchParams(queryParams)}`;
1224
- const req = getHttpModule(this.#baseUrl).request(url, {
1097
+ const response = await (0, import_http_request3.httpRequest)(url, {
1225
1098
  method: "POST",
1226
- ...this.#reqOptions
1227
- }).end(JSON.stringify(componentsObj));
1228
- const response = await getResponse(req);
1099
+ body: JSON.stringify(componentsObj),
1100
+ headers: this.#reqOptions.headers,
1101
+ timeout: this.#reqOptions.timeout,
1102
+ maxResponseSize: MAX_RESPONSE_SIZE
1103
+ });
1229
1104
  if (!isResponseOk(response)) {
1230
1105
  throw new ResponseError(response, "", url);
1231
1106
  }
@@ -1272,17 +1147,18 @@ var SocketSdk = class _SocketSdk {
1272
1147
  if (!(error instanceof ResponseError)) {
1273
1148
  return void 0;
1274
1149
  }
1275
- const { statusCode } = error.response;
1276
- if (statusCode === 401 || statusCode === 403) {
1277
- throw error;
1278
- }
1279
- if (statusCode === 429) {
1150
+ const { status } = error.response;
1151
+ if (status === 429) {
1280
1152
  const retryAfter = this.#parseRetryAfter(
1281
1153
  error.response.headers["retry-after"]
1282
1154
  );
1283
1155
  if (retryAfter !== void 0) {
1284
1156
  return retryAfter;
1285
1157
  }
1158
+ return void 0;
1159
+ }
1160
+ if (status >= 400 && status < 500) {
1161
+ throw error;
1286
1162
  }
1287
1163
  return void 0;
1288
1164
  },
@@ -1343,23 +1219,6 @@ var SocketSdk = class _SocketSdk {
1343
1219
  return await this.#executeWithRetry(fetcher);
1344
1220
  });
1345
1221
  }
1346
- /**
1347
- * Extract text content from HTTP response stream.
1348
- * Internal method with size limits to prevent memory exhaustion.
1349
- */
1350
- async #getResponseText(response) {
1351
- const chunks = [];
1352
- let size = 0;
1353
- const MAX = 50 * 1024 * 1024;
1354
- for await (const chunk of response) {
1355
- size += chunk.length;
1356
- if (size > MAX) {
1357
- throw new Error("Response body exceeds maximum size limit");
1358
- }
1359
- chunks.push(chunk);
1360
- }
1361
- return Buffer.concat(chunks).toString("utf8");
1362
- }
1363
1222
  /**
1364
1223
  * Handle API error responses and convert to standardized error result.
1365
1224
  * Internal error handling with status code analysis and message formatting.
@@ -1378,13 +1237,13 @@ var SocketSdk = class _SocketSdk {
1378
1237
  cause: error
1379
1238
  });
1380
1239
  }
1381
- const { statusCode } = error.response;
1240
+ const { status: statusCode } = error.response;
1382
1241
  if (statusCode && statusCode >= 500) {
1383
1242
  throw new Error(`Socket API server error (${statusCode})`, {
1384
1243
  cause: error
1385
1244
  });
1386
1245
  }
1387
- const bodyStr = await getErrorResponseBody(error.response);
1246
+ const bodyStr = error.response.text();
1388
1247
  let body;
1389
1248
  try {
1390
1249
  const parsed = JSON.parse(bodyStr);
@@ -1402,7 +1261,7 @@ var SocketSdk = class _SocketSdk {
1402
1261
  import_core.UNKNOWN_ERROR;
1403
1262
  const trimmedBody = body?.trim();
1404
1263
  if (trimmedBody && !errorMessage.includes(trimmedBody)) {
1405
- const statusMessage = error.response?.statusMessage;
1264
+ const statusMessage = error.response?.statusText;
1406
1265
  if (statusMessage && errorMessage.includes(statusMessage)) {
1407
1266
  errorMessage = errorMessage.replace(statusMessage, trimmedBody);
1408
1267
  } else {
@@ -1486,7 +1345,7 @@ var SocketSdk = class _SocketSdk {
1486
1345
  return response;
1487
1346
  }
1488
1347
  if (responseType === "text") {
1489
- return await this.#getResponseText(response);
1348
+ return response.text();
1490
1349
  }
1491
1350
  if (responseType === "json") {
1492
1351
  return await getResponseJson(response);
@@ -1557,11 +1416,13 @@ var SocketSdk = class _SocketSdk {
1557
1416
  let res;
1558
1417
  try {
1559
1418
  res = await this.#executeWithRetry(async () => {
1560
- const req = getHttpModule(this.#baseUrl).request(url, {
1419
+ const response = await (0, import_http_request3.httpRequest)(url, {
1561
1420
  method: "POST",
1562
- ...this.#reqOptions
1563
- }).end(JSON.stringify(componentsObj));
1564
- const response = await getResponse(req);
1421
+ body: JSON.stringify(componentsObj),
1422
+ headers: this.#reqOptions.headers,
1423
+ timeout: this.#reqOptions.timeout,
1424
+ maxResponseSize: MAX_RESPONSE_SIZE
1425
+ });
1565
1426
  if (!isResponseOk(response)) {
1566
1427
  throw new ResponseError(response, "POST Request failed", url);
1567
1428
  }
@@ -1573,25 +1434,22 @@ var SocketSdk = class _SocketSdk {
1573
1434
  if (!res) {
1574
1435
  throw new Error("Failed to get response from batch PURL request");
1575
1436
  }
1576
- const rli = import_node_readline.default.createInterface({
1577
- input: res,
1578
- crlfDelay: Number.POSITIVE_INFINITY,
1579
- signal: abortSignal
1580
- });
1581
1437
  const results = [];
1582
- try {
1583
- for await (const line of rli) {
1584
- const trimmed = line.trim();
1585
- const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1586
- /* c8 ignore next - Empty line handling in batch parsing. */
1587
- null
1588
- );
1589
- if ((0, import_objects.isObjectObject)(artifact)) {
1590
- results.push(artifact);
1438
+ const text = res.text();
1439
+ let start = 0;
1440
+ for (let i = 0; i <= text.length; i++) {
1441
+ if (i === text.length || text.charCodeAt(i) === 10) {
1442
+ if (i > start) {
1443
+ const line = text.slice(start, i);
1444
+ const artifact = (0, import_parse2.jsonParse)(line, {
1445
+ throws: false
1446
+ });
1447
+ if ((0, import_objects.isObjectObject)(artifact)) {
1448
+ results.push(artifact);
1449
+ }
1591
1450
  }
1451
+ start = i + 1;
1592
1452
  }
1593
- } finally {
1594
- rli.close();
1595
1453
  }
1596
1454
  const compact = (0, import_url.urlSearchParamAsBoolean)(
1597
1455
  (0, import_objects.getOwn)(queryParams, "compact")
@@ -1616,34 +1474,31 @@ var SocketSdk = class _SocketSdk {
1616
1474
  if (!res) {
1617
1475
  throw new Error("Failed to get response from batch PURL request");
1618
1476
  }
1619
- const rli = import_node_readline.default.createInterface({
1620
- input: res,
1621
- crlfDelay: Number.POSITIVE_INFINITY,
1622
- signal: abortSignal
1623
- });
1624
1477
  const isPublicToken = this.#apiToken === import_socket2.SOCKET_PUBLIC_API_TOKEN;
1625
1478
  const results = [];
1626
- try {
1627
- for await (const line of rli) {
1628
- const trimmed = line.trim();
1629
- const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1630
- /* c8 ignore next - Empty line handling in batch parsing. */
1631
- null
1632
- );
1633
- if ((0, import_objects.isObjectObject)(artifact)) {
1634
- results.push(
1635
- /* c8 ignore next 8 - Public token artifact reshaping for policy compliance. */
1636
- isPublicToken ? reshapeArtifactForPublicPolicy(
1637
- artifact,
1638
- false,
1639
- queryParams?.["actions"],
1640
- publicPolicy
1641
- ) : artifact
1642
- );
1479
+ const text = res.text();
1480
+ let start = 0;
1481
+ for (let i = 0; i <= text.length; i++) {
1482
+ if (i === text.length || text.charCodeAt(i) === 10) {
1483
+ if (i > start) {
1484
+ const line = text.slice(start, i);
1485
+ const artifact = (0, import_parse2.jsonParse)(line, {
1486
+ throws: false
1487
+ });
1488
+ if ((0, import_objects.isObjectObject)(artifact)) {
1489
+ results.push(
1490
+ /* c8 ignore next 8 - Public token artifact reshaping for policy compliance. */
1491
+ isPublicToken ? reshapeArtifactForPublicPolicy(
1492
+ artifact,
1493
+ false,
1494
+ queryParams?.["actions"],
1495
+ publicPolicy
1496
+ ) : artifact
1497
+ );
1498
+ }
1643
1499
  }
1500
+ start = i + 1;
1644
1501
  }
1645
- } finally {
1646
- rli.close();
1647
1502
  }
1648
1503
  const compact = (0, import_url.urlSearchParamAsBoolean)(
1649
1504
  (0, import_objects.getOwn)(queryParams, "compact")
@@ -1671,7 +1526,7 @@ var SocketSdk = class _SocketSdk {
1671
1526
  (0, import_suppress_warnings.setMaxEventTargetListeners)(abortSignal, neededMaxListeners);
1672
1527
  const { components } = componentsObj;
1673
1528
  const { length: componentsCount } = components;
1674
- const running = [];
1529
+ const running = /* @__PURE__ */ new Map();
1675
1530
  let index = 0;
1676
1531
  const enqueueGen = () => {
1677
1532
  if (index >= componentsCount) {
@@ -1679,7 +1534,6 @@ var SocketSdk = class _SocketSdk {
1679
1534
  }
1680
1535
  const generator = this.#createBatchPurlGenerator(
1681
1536
  {
1682
- // Chunk components.
1683
1537
  components: components.slice(index, index + chunkSize)
1684
1538
  },
1685
1539
  queryParams
@@ -1693,29 +1547,20 @@ var SocketSdk = class _SocketSdk {
1693
1547
  reject: rejectFn,
1694
1548
  resolve: resolveFn
1695
1549
  } = promiseWithResolvers();
1696
- running.push({
1697
- generator,
1698
- promise
1699
- });
1550
+ running.set(generator, promise);
1700
1551
  void generator.next().then(
1701
1552
  (iteratorResult) => resolveFn({ generator, iteratorResult }),
1702
1553
  rejectFn
1703
1554
  );
1704
1555
  };
1705
- while (running.length < concurrencyLimit && index < componentsCount) {
1556
+ while (running.size < concurrencyLimit && index < componentsCount) {
1706
1557
  enqueueGen();
1707
1558
  }
1708
- while (running.length > 0) {
1559
+ while (running.size > 0) {
1709
1560
  const { generator, iteratorResult } = await Promise.race(
1710
- running.map((entry) => entry.promise)
1711
- );
1712
- const runningIndex = running.findIndex(
1713
- (entry) => entry.generator === generator
1561
+ running.values()
1714
1562
  );
1715
- if (runningIndex === -1) {
1716
- continue;
1717
- }
1718
- running.splice(runningIndex, 1);
1563
+ running.delete(generator);
1719
1564
  if (iteratorResult.value) {
1720
1565
  yield iteratorResult.value;
1721
1566
  }
@@ -1905,7 +1750,7 @@ var SocketSdk = class _SocketSdk {
1905
1750
  this.#baseUrl,
1906
1751
  `dependencies/upload?${queryToSearchParams(queryParams)}`,
1907
1752
  createRequestBodyForFilepaths(validPaths, basePath),
1908
- { ...this.#reqOptions, hooks: this.#hooks }
1753
+ this.#reqOptionsWithHooks
1909
1754
  )
1910
1755
  )
1911
1756
  );
@@ -2019,7 +1864,7 @@ var SocketSdk = class _SocketSdk {
2019
1864
  this.#baseUrl,
2020
1865
  `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(queryParams)}`,
2021
1866
  createRequestBodyForFilepaths(validPaths, basePath),
2022
- { ...this.#reqOptions, hooks: this.#hooks }
1867
+ this.#reqOptionsWithHooks
2023
1868
  )
2024
1869
  )
2025
1870
  );
@@ -2083,7 +1928,7 @@ var SocketSdk = class _SocketSdk {
2083
1928
  this.#baseUrl,
2084
1929
  `orgs/${encodeURIComponent(orgSlug)}/diff-scans/from-ids?${queryToSearchParams(options)}`,
2085
1930
  {},
2086
- { ...this.#reqOptions, hooks: this.#hooks }
1931
+ this.#reqOptionsWithHooks
2087
1932
  )
2088
1933
  )
2089
1934
  );
@@ -2112,7 +1957,7 @@ var SocketSdk = class _SocketSdk {
2112
1957
  this.#baseUrl,
2113
1958
  `orgs/${encodeURIComponent(orgSlug)}/full-scans/archive?${queryToSearchParams(options)}`,
2114
1959
  createRequestBodyForFilepaths([archivePath], basePath),
2115
- { ...this.#reqOptions, hooks: this.#hooks }
1960
+ this.#reqOptionsWithHooks
2116
1961
  )
2117
1962
  )
2118
1963
  );
@@ -2140,7 +1985,7 @@ var SocketSdk = class _SocketSdk {
2140
1985
  this.#baseUrl,
2141
1986
  `orgs/${encodeURIComponent(orgSlug)}/webhooks`,
2142
1987
  webhookData,
2143
- { ...this.#reqOptions, hooks: this.#hooks }
1988
+ this.#reqOptionsWithHooks
2144
1989
  )
2145
1990
  )
2146
1991
  );
@@ -2193,7 +2038,7 @@ var SocketSdk = class _SocketSdk {
2193
2038
  this.#baseUrl,
2194
2039
  `orgs/${encodeURIComponent(orgSlug)}/repos`,
2195
2040
  { ...params, name: repoSlug },
2196
- { ...this.#reqOptions, hooks: this.#hooks }
2041
+ this.#reqOptionsWithHooks
2197
2042
  )
2198
2043
  )
2199
2044
  );
@@ -2249,7 +2094,7 @@ var SocketSdk = class _SocketSdk {
2249
2094
  this.#baseUrl,
2250
2095
  `orgs/${encodeURIComponent(orgSlug)}/repos/labels`,
2251
2096
  labelData,
2252
- { ...this.#reqOptions, hooks: this.#hooks }
2097
+ this.#reqOptionsWithHooks
2253
2098
  )
2254
2099
  )
2255
2100
  );
@@ -2302,7 +2147,7 @@ var SocketSdk = class _SocketSdk {
2302
2147
  await createDeleteRequest(
2303
2148
  this.#baseUrl,
2304
2149
  `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
2305
- { ...this.#reqOptions, hooks: this.#hooks }
2150
+ this.#reqOptionsWithHooks
2306
2151
  )
2307
2152
  )
2308
2153
  );
@@ -2337,7 +2182,7 @@ var SocketSdk = class _SocketSdk {
2337
2182
  await createDeleteRequest(
2338
2183
  this.#baseUrl,
2339
2184
  `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}`,
2340
- { ...this.#reqOptions, hooks: this.#hooks }
2185
+ this.#reqOptionsWithHooks
2341
2186
  )
2342
2187
  )
2343
2188
  );
@@ -2363,7 +2208,7 @@ var SocketSdk = class _SocketSdk {
2363
2208
  await createDeleteRequest(
2364
2209
  this.#baseUrl,
2365
2210
  `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
2366
- { ...this.#reqOptions, hooks: this.#hooks }
2211
+ this.#reqOptionsWithHooks
2367
2212
  )
2368
2213
  )
2369
2214
  );
@@ -2409,7 +2254,7 @@ var SocketSdk = class _SocketSdk {
2409
2254
  await createDeleteRequest(
2410
2255
  this.#baseUrl,
2411
2256
  `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}${queryString}`,
2412
- { ...this.#reqOptions, hooks: this.#hooks }
2257
+ this.#reqOptionsWithHooks
2413
2258
  )
2414
2259
  )
2415
2260
  );
@@ -2462,7 +2307,7 @@ var SocketSdk = class _SocketSdk {
2462
2307
  await createDeleteRequest(
2463
2308
  this.#baseUrl,
2464
2309
  `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
2465
- { ...this.#reqOptions, hooks: this.#hooks }
2310
+ this.#reqOptionsWithHooks
2466
2311
  )
2467
2312
  )
2468
2313
  );
@@ -2500,35 +2345,24 @@ var SocketSdk = class _SocketSdk {
2500
2345
  const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/files.tar`;
2501
2346
  try {
2502
2347
  const res = await this.#executeWithRetry(async () => {
2503
- const req = getHttpModule(this.#baseUrl).request(url, {
2348
+ const response = await (0, import_http_request3.httpRequest)(url, {
2504
2349
  method: "GET",
2505
- ...this.#reqOptions
2506
- }).end();
2507
- const response = await getResponse(req);
2350
+ headers: this.#reqOptions.headers,
2351
+ stream: true,
2352
+ timeout: this.#reqOptions.timeout
2353
+ });
2508
2354
  if (!isResponseOk(response)) {
2509
2355
  throw new ResponseError(response, "", url);
2510
2356
  }
2511
2357
  return response;
2512
2358
  });
2513
- const writeStream = (0, import_node_fs3.createWriteStream)(outputPath);
2514
- let bytesWritten = 0;
2515
- res.on("data", (chunk) => {
2516
- if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
2517
- const error = new Error(
2518
- `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
2519
- );
2520
- res.destroy(error);
2521
- writeStream.destroy(error);
2522
- return;
2523
- }
2524
- bytesWritten += chunk.length;
2525
- });
2526
- res.pipe(writeStream);
2527
- writeStream.on("error", (error) => {
2528
- res.destroy();
2529
- writeStream.destroy(error);
2359
+ const { createWriteStream } = await import("node:fs");
2360
+ await new Promise((resolve, reject) => {
2361
+ const ws = createWriteStream(outputPath);
2362
+ ws.on("error", reject);
2363
+ ws.on("close", resolve);
2364
+ res.rawResponse.pipe(ws);
2530
2365
  });
2531
- await import_node_events.default.once(writeStream, "finish");
2532
2366
  return this.#handleApiSuccess(res);
2533
2367
  } catch (e) {
2534
2368
  return await this.#handleApiError(e);
@@ -2557,90 +2391,34 @@ var SocketSdk = class _SocketSdk {
2557
2391
  * ```
2558
2392
  */
2559
2393
  async downloadPatch(hash, options) {
2560
- const https2 = await import("node:https");
2561
- const http2 = await import("node:http");
2562
2394
  const blobPath = `/blob/${encodeURIComponent(hash)}`;
2563
2395
  const blobBaseUrl = options?.baseUrl || SOCKET_PUBLIC_BLOB_STORE_URL;
2564
2396
  const url = `${blobBaseUrl}${blobPath}`;
2565
- const isHttps = url.startsWith("https:");
2566
- return await new Promise((resolve, reject) => {
2567
- const client = isHttps ? https2 : http2;
2568
- client.get(url, (res) => {
2569
- if (res.statusCode === 404) {
2570
- const message = [
2571
- `Blob not found: ${hash}`,
2572
- `\u2192 URL: ${url}`,
2573
- "\u2192 The patch file may have expired or the hash is incorrect.",
2574
- "\u2192 Verify: The blob hash is correct.",
2575
- "\u2192 Note: Blob URLs may expire after a certain time period."
2576
- ].join("\n");
2577
- reject(new Error(message));
2578
- return;
2579
- }
2580
- if (res.statusCode !== 200) {
2581
- const message = [
2582
- `Failed to download blob: ${res.statusCode} ${res.statusMessage}`,
2583
- `\u2192 Hash: ${hash}`,
2584
- `\u2192 URL: ${url}`,
2585
- "\u2192 The blob storage service may be temporarily unavailable.",
2586
- res.statusCode && res.statusCode >= 500 ? "\u2192 Try: Retry the download after a short delay." : "\u2192 Verify: The blob hash and URL are correct."
2587
- ].join("\n");
2588
- reject(new Error(message));
2589
- return;
2590
- }
2591
- let data = "";
2592
- let bytesRead = 0;
2593
- const MAX_PATCH_SIZE = 50 * 1024 * 1024;
2594
- res.on("data", (chunk) => {
2595
- if (bytesRead + chunk.length > MAX_PATCH_SIZE) {
2596
- const error = new Error(
2597
- [
2598
- `Patch file exceeds maximum size of ${MAX_PATCH_SIZE} bytes`,
2599
- `\u2192 Current size: ${bytesRead + chunk.length} bytes`,
2600
- "\u2192 This may indicate an incorrect hash or corrupted blob."
2601
- ].join("\n")
2602
- );
2603
- res.destroy(error);
2604
- reject(error);
2605
- return;
2606
- }
2607
- bytesRead += chunk.length;
2608
- data += chunk.toString("utf8");
2609
- });
2610
- res.on("end", () => {
2611
- resolve(data);
2612
- });
2613
- res.on("error", (err) => {
2614
- reject(err);
2615
- });
2616
- }).on("error", (err) => {
2617
- const nodeErr = err;
2618
- const message = [
2619
- `Error downloading blob: ${hash}`,
2620
- `\u2192 URL: ${url}`,
2621
- `\u2192 Network error: ${nodeErr.message}`
2622
- ];
2623
- if (nodeErr.code === "ENOTFOUND") {
2624
- message.push(
2625
- "\u2192 DNS lookup failed. Cannot resolve blob storage hostname.",
2626
- "\u2192 Check: Internet connection and DNS settings."
2627
- );
2628
- } else if (nodeErr.code === "ECONNREFUSED") {
2629
- message.push(
2630
- "\u2192 Connection refused. Blob storage service is unreachable.",
2631
- "\u2192 Check: Network connectivity and firewall settings."
2632
- );
2633
- } else if (nodeErr.code === "ETIMEDOUT") {
2634
- message.push(
2635
- "\u2192 Connection timed out.",
2636
- "\u2192 Try: Check network connectivity and retry."
2637
- );
2638
- } else if (nodeErr.code) {
2639
- message.push(`\u2192 Error code: ${nodeErr.code}`);
2640
- }
2641
- reject(new Error(message.join("\n"), { cause: err }));
2642
- });
2397
+ const MAX_PATCH_SIZE = 50 * 1024 * 1024;
2398
+ const res = await (0, import_http_request3.httpRequest)(url, {
2399
+ maxResponseSize: MAX_PATCH_SIZE
2643
2400
  });
2401
+ if (res.status === 404) {
2402
+ const message = [
2403
+ `Blob not found: ${hash}`,
2404
+ `\u2192 URL: ${url}`,
2405
+ "\u2192 The patch file may have expired or the hash is incorrect.",
2406
+ "\u2192 Verify: The blob hash is correct.",
2407
+ "\u2192 Note: Blob URLs may expire after a certain time period."
2408
+ ].join("\n");
2409
+ throw new Error(message);
2410
+ }
2411
+ if (res.status !== 200) {
2412
+ const message = [
2413
+ `Failed to download blob: ${res.status} ${res.statusText}`,
2414
+ `\u2192 Hash: ${hash}`,
2415
+ `\u2192 URL: ${url}`,
2416
+ "\u2192 The blob storage service may be temporarily unavailable.",
2417
+ res.status >= 500 ? "\u2192 Try: Retry the download after a short delay." : "\u2192 Verify: The blob hash and URL are correct."
2418
+ ].join("\n");
2419
+ throw new Error(message);
2420
+ }
2421
+ return res.text();
2644
2422
  }
2645
2423
  /**
2646
2424
  * Export scan results in CycloneDX SBOM format.
@@ -2655,7 +2433,7 @@ var SocketSdk = class _SocketSdk {
2655
2433
  await createGetRequest(
2656
2434
  this.#baseUrl,
2657
2435
  `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/sbom/export/cdx`,
2658
- { ...this.#reqOptions, hooks: this.#hooks }
2436
+ this.#reqOptionsWithHooks
2659
2437
  )
2660
2438
  )
2661
2439
  );
@@ -2700,7 +2478,7 @@ var SocketSdk = class _SocketSdk {
2700
2478
  await createGetRequest(
2701
2479
  this.#baseUrl,
2702
2480
  `orgs/${encodeURIComponent(orgSlug)}/export/openvex/${encodeURIComponent(id)}${queryString}`,
2703
- { ...this.#reqOptions, hooks: this.#hooks }
2481
+ this.#reqOptionsWithHooks
2704
2482
  )
2705
2483
  )
2706
2484
  );
@@ -2722,7 +2500,7 @@ var SocketSdk = class _SocketSdk {
2722
2500
  await createGetRequest(
2723
2501
  this.#baseUrl,
2724
2502
  `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/sbom/export/spdx`,
2725
- { ...this.#reqOptions, hooks: this.#hooks }
2503
+ this.#reqOptionsWithHooks
2726
2504
  )
2727
2505
  )
2728
2506
  );
@@ -2746,10 +2524,11 @@ var SocketSdk = class _SocketSdk {
2746
2524
  const url = `${this.#baseUrl}${urlPath}`;
2747
2525
  try {
2748
2526
  const response = await this.#executeWithRetry(async () => {
2749
- const res = await createGetRequest(this.#baseUrl, urlPath, {
2750
- ...this.#reqOptions,
2751
- hooks: this.#hooks
2752
- });
2527
+ const res = await createGetRequest(
2528
+ this.#baseUrl,
2529
+ urlPath,
2530
+ this.#reqOptionsWithHooks
2531
+ );
2753
2532
  if (!isResponseOk(res)) {
2754
2533
  throw new ResponseError(res, "", url);
2755
2534
  }
@@ -2766,8 +2545,7 @@ var SocketSdk = class _SocketSdk {
2766
2545
  cause: void 0,
2767
2546
  data,
2768
2547
  error: void 0,
2769
- /* c8 ignore next - Defensive fallback: response.statusCode is always defined in Node.js http/https */
2770
- status: response.statusCode ?? 200,
2548
+ status: response.status,
2771
2549
  success: true
2772
2550
  };
2773
2551
  } catch (e) {
@@ -2801,7 +2579,7 @@ var SocketSdk = class _SocketSdk {
2801
2579
  await createGetRequest(
2802
2580
  this.#baseUrl,
2803
2581
  `orgs/${encodeURIComponent(orgSlug)}/tokens`,
2804
- { ...this.#reqOptions, hooks: this.#hooks }
2582
+ this.#reqOptionsWithHooks
2805
2583
  )
2806
2584
  )
2807
2585
  );
@@ -2823,7 +2601,7 @@ var SocketSdk = class _SocketSdk {
2823
2601
  await createGetRequest(
2824
2602
  this.#baseUrl,
2825
2603
  `orgs/${encodeURIComponent(orgSlug)}/audit-log?${queryToSearchParams(queryParams)}`,
2826
- { ...this.#reqOptions, hooks: this.#hooks }
2604
+ this.#reqOptionsWithHooks
2827
2605
  )
2828
2606
  )
2829
2607
  );
@@ -2845,7 +2623,7 @@ var SocketSdk = class _SocketSdk {
2845
2623
  await createGetRequest(
2846
2624
  this.#baseUrl,
2847
2625
  `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}`,
2848
- { ...this.#reqOptions, hooks: this.#hooks }
2626
+ this.#reqOptionsWithHooks
2849
2627
  )
2850
2628
  )
2851
2629
  );
@@ -2887,7 +2665,7 @@ var SocketSdk = class _SocketSdk {
2887
2665
  await createGetRequest(
2888
2666
  this.#baseUrl,
2889
2667
  `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}/gfm${options ? `?${queryToSearchParams(options)}` : ""}`,
2890
- { ...this.#reqOptions, hooks: this.#hooks }
2668
+ this.#reqOptionsWithHooks
2891
2669
  )
2892
2670
  )
2893
2671
  );
@@ -2908,7 +2686,7 @@ var SocketSdk = class _SocketSdk {
2908
2686
  await createGetRequest(
2909
2687
  this.#baseUrl,
2910
2688
  `orgs/${encodeURIComponent(orgSlug)}/entitlements`,
2911
- { ...this.#reqOptions, hooks: this.#hooks }
2689
+ this.#reqOptionsWithHooks
2912
2690
  )
2913
2691
  )
2914
2692
  );
@@ -2927,7 +2705,7 @@ var SocketSdk = class _SocketSdk {
2927
2705
  await createGetRequest(
2928
2706
  this.#baseUrl,
2929
2707
  `orgs/${encodeURIComponent(orgSlug)}/entitlements`,
2930
- { ...this.#reqOptions, hooks: this.#hooks }
2708
+ this.#reqOptionsWithHooks
2931
2709
  )
2932
2710
  )
2933
2711
  );
@@ -2966,7 +2744,7 @@ var SocketSdk = class _SocketSdk {
2966
2744
  await createGetRequest(
2967
2745
  this.#baseUrl,
2968
2746
  `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
2969
- { ...this.#reqOptions, hooks: this.#hooks }
2747
+ this.#reqOptionsWithHooks
2970
2748
  )
2971
2749
  )
2972
2750
  );
@@ -3021,7 +2799,7 @@ var SocketSdk = class _SocketSdk {
3021
2799
  await createGetRequest(
3022
2800
  this.#baseUrl,
3023
2801
  `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}/metadata`,
3024
- { ...this.#reqOptions, hooks: this.#hooks }
2802
+ this.#reqOptionsWithHooks
3025
2803
  )
3026
2804
  )
3027
2805
  );
@@ -3056,7 +2834,7 @@ var SocketSdk = class _SocketSdk {
3056
2834
  await createGetRequest(
3057
2835
  this.#baseUrl,
3058
2836
  `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/issues`,
3059
- { ...this.#reqOptions, hooks: this.#hooks }
2837
+ this.#reqOptionsWithHooks
3060
2838
  )
3061
2839
  )
3062
2840
  );
@@ -3101,7 +2879,7 @@ var SocketSdk = class _SocketSdk {
3101
2879
  await createGetRequest(
3102
2880
  this.#baseUrl,
3103
2881
  `orgs/${encodeURIComponent(orgSlug)}/alert-full-scan-search?${queryToSearchParams(options)}`,
3104
- { ...this.#reqOptions, hooks: this.#hooks }
2882
+ this.#reqOptionsWithHooks
3105
2883
  )
3106
2884
  )
3107
2885
  );
@@ -3127,7 +2905,7 @@ var SocketSdk = class _SocketSdk {
3127
2905
  await createGetRequest(
3128
2906
  this.#baseUrl,
3129
2907
  `orgs/${encodeURIComponent(orgSlug)}/alerts?${queryToSearchParams(options)}`,
3130
- { ...this.#reqOptions, hooks: this.#hooks }
2908
+ this.#reqOptionsWithHooks
3131
2909
  )
3132
2910
  )
3133
2911
  );
@@ -3149,7 +2927,7 @@ var SocketSdk = class _SocketSdk {
3149
2927
  await createGetRequest(
3150
2928
  this.#baseUrl,
3151
2929
  `analytics/org/${encodeURIComponent(time)}`,
3152
- { ...this.#reqOptions, hooks: this.#hooks }
2930
+ this.#reqOptionsWithHooks
3153
2931
  )
3154
2932
  )
3155
2933
  );
@@ -3175,7 +2953,7 @@ var SocketSdk = class _SocketSdk {
3175
2953
  await createGetRequest(
3176
2954
  this.#baseUrl,
3177
2955
  `orgs/${encodeURIComponent(orgSlug)}/fixes?${queryToSearchParams(options)}`,
3178
- { ...this.#reqOptions, hooks: this.#hooks }
2956
+ this.#reqOptionsWithHooks
3179
2957
  )
3180
2958
  )
3181
2959
  );
@@ -3197,7 +2975,7 @@ var SocketSdk = class _SocketSdk {
3197
2975
  await createGetRequest(
3198
2976
  this.#baseUrl,
3199
2977
  `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy`,
3200
- { ...this.#reqOptions, hooks: this.#hooks }
2978
+ this.#reqOptionsWithHooks
3201
2979
  )
3202
2980
  )
3203
2981
  );
@@ -3219,7 +2997,7 @@ var SocketSdk = class _SocketSdk {
3219
2997
  await createGetRequest(
3220
2998
  this.#baseUrl,
3221
2999
  `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
3222
- { ...this.#reqOptions, hooks: this.#hooks }
3000
+ this.#reqOptionsWithHooks
3223
3001
  )
3224
3002
  )
3225
3003
  );
@@ -3244,7 +3022,7 @@ var SocketSdk = class _SocketSdk {
3244
3022
  await createGetRequest(
3245
3023
  this.#baseUrl,
3246
3024
  `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
3247
- { ...this.#reqOptions, hooks: this.#hooks }
3025
+ this.#reqOptionsWithHooks
3248
3026
  )
3249
3027
  )
3250
3028
  );
@@ -3266,7 +3044,7 @@ var SocketSdk = class _SocketSdk {
3266
3044
  await createGetRequest(
3267
3045
  this.#baseUrl,
3268
3046
  `orgs/${encodeURIComponent(orgSlug)}/triage`,
3269
- { ...this.#reqOptions, hooks: this.#hooks }
3047
+ this.#reqOptionsWithHooks
3270
3048
  )
3271
3049
  )
3272
3050
  );
@@ -3292,7 +3070,7 @@ var SocketSdk = class _SocketSdk {
3292
3070
  await createGetRequest(
3293
3071
  this.#baseUrl,
3294
3072
  `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
3295
- { ...this.#reqOptions, hooks: this.#hooks }
3073
+ this.#reqOptionsWithHooks
3296
3074
  )
3297
3075
  )
3298
3076
  );
@@ -3318,7 +3096,7 @@ var SocketSdk = class _SocketSdk {
3318
3096
  await createGetRequest(
3319
3097
  this.#baseUrl,
3320
3098
  `orgs/${encodeURIComponent(orgSlug)}/webhooks?${queryToSearchParams(options)}`,
3321
- { ...this.#reqOptions, hooks: this.#hooks }
3099
+ this.#reqOptionsWithHooks
3322
3100
  )
3323
3101
  )
3324
3102
  );
@@ -3338,10 +3116,11 @@ var SocketSdk = class _SocketSdk {
3338
3116
  const data = await this.#getCached(
3339
3117
  "quota",
3340
3118
  async () => await getResponseJson(
3341
- await createGetRequest(this.#baseUrl, "quota", {
3342
- ...this.#reqOptions,
3343
- hooks: this.#hooks
3344
- })
3119
+ await createGetRequest(
3120
+ this.#baseUrl,
3121
+ "quota",
3122
+ this.#reqOptionsWithHooks
3123
+ )
3345
3124
  ),
3346
3125
  "quota"
3347
3126
  );
@@ -3363,7 +3142,7 @@ var SocketSdk = class _SocketSdk {
3363
3142
  await createGetRequest(
3364
3143
  this.#baseUrl,
3365
3144
  `analytics/repo/${encodeURIComponent(repo)}/${encodeURIComponent(time)}`,
3366
- { ...this.#reqOptions, hooks: this.#hooks }
3145
+ this.#reqOptionsWithHooks
3367
3146
  )
3368
3147
  )
3369
3148
  );
@@ -3413,7 +3192,7 @@ var SocketSdk = class _SocketSdk {
3413
3192
  await createGetRequest(
3414
3193
  this.#baseUrl,
3415
3194
  `orgs/${orgSlugParam}/repos/${repoSlugParam}${queryString}`,
3416
- { ...this.#reqOptions, hooks: this.#hooks }
3195
+ this.#reqOptionsWithHooks
3417
3196
  )
3418
3197
  )
3419
3198
  );
@@ -3468,7 +3247,7 @@ var SocketSdk = class _SocketSdk {
3468
3247
  await createGetRequest(
3469
3248
  this.#baseUrl,
3470
3249
  `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
3471
- { ...this.#reqOptions, hooks: this.#hooks }
3250
+ this.#reqOptionsWithHooks
3472
3251
  )
3473
3252
  )
3474
3253
  );
@@ -3503,7 +3282,7 @@ var SocketSdk = class _SocketSdk {
3503
3282
  await createGetRequest(
3504
3283
  this.#baseUrl,
3505
3284
  `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`,
3506
- { ...this.#reqOptions, hooks: this.#hooks }
3285
+ this.#reqOptionsWithHooks
3507
3286
  )
3508
3287
  )
3509
3288
  );
@@ -3545,10 +3324,7 @@ var SocketSdk = class _SocketSdk {
3545
3324
  await createGetRequest(
3546
3325
  this.#baseUrl,
3547
3326
  `orgs/${encodeURIComponent(orgSlug)}/supported-files`,
3548
- {
3549
- ...this.#reqOptions,
3550
- hooks: this.#hooks
3551
- }
3327
+ this.#reqOptionsWithHooks
3552
3328
  )
3553
3329
  )
3554
3330
  );
@@ -3557,29 +3333,6 @@ var SocketSdk = class _SocketSdk {
3557
3333
  return await this.#handleApiError(e);
3558
3334
  }
3559
3335
  }
3560
- /**
3561
- * Get list of file types and formats supported for scanning.
3562
- * Returns supported manifest files, lockfiles, and configuration formats.
3563
- *
3564
- * @deprecated Use getSupportedFiles() instead. This endpoint has been deprecated
3565
- * since 2023-01-15 and now uses the /report/supported endpoint.
3566
- * @throws {Error} When server returns 5xx status codes
3567
- */
3568
- async getSupportedScanFiles() {
3569
- try {
3570
- const data = await this.#executeWithRetry(
3571
- async () => await getResponseJson(
3572
- await createGetRequest(this.#baseUrl, "report/supported", {
3573
- ...this.#reqOptions,
3574
- hooks: this.#hooks
3575
- })
3576
- )
3577
- );
3578
- return this.#handleApiSuccess(data);
3579
- } catch (e) {
3580
- return await this.#handleApiError(e);
3581
- }
3582
- }
3583
3336
  /**
3584
3337
  * List all full scans for an organization.
3585
3338
  *
@@ -3618,7 +3371,7 @@ var SocketSdk = class _SocketSdk {
3618
3371
  await createGetRequest(
3619
3372
  this.#baseUrl,
3620
3373
  `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(options)}`,
3621
- { ...this.#reqOptions, hooks: this.#hooks }
3374
+ this.#reqOptionsWithHooks
3622
3375
  )
3623
3376
  )
3624
3377
  );
@@ -3668,10 +3421,11 @@ var SocketSdk = class _SocketSdk {
3668
3421
  const data = await this.#getCached(
3669
3422
  "organizations",
3670
3423
  async () => await getResponseJson(
3671
- await createGetRequest(this.#baseUrl, "organizations", {
3672
- ...this.#reqOptions,
3673
- hooks: this.#hooks
3674
- })
3424
+ await createGetRequest(
3425
+ this.#baseUrl,
3426
+ "organizations",
3427
+ this.#reqOptionsWithHooks
3428
+ )
3675
3429
  ),
3676
3430
  "organizations"
3677
3431
  );
@@ -3706,7 +3460,7 @@ var SocketSdk = class _SocketSdk {
3706
3460
  await createGetRequest(
3707
3461
  this.#baseUrl,
3708
3462
  `orgs/${encodeURIComponent(orgSlug)}/diff-scans`,
3709
- { ...this.#reqOptions, hooks: this.#hooks }
3463
+ this.#reqOptionsWithHooks
3710
3464
  )
3711
3465
  )
3712
3466
  );
@@ -3752,7 +3506,7 @@ var SocketSdk = class _SocketSdk {
3752
3506
  await createGetRequest(
3753
3507
  this.#baseUrl,
3754
3508
  `orgs/${encodeURIComponent(orgSlug)}/repos?${queryToSearchParams(options)}`,
3755
- { ...this.#reqOptions, hooks: this.#hooks }
3509
+ this.#reqOptionsWithHooks
3756
3510
  )
3757
3511
  )
3758
3512
  );
@@ -3808,7 +3562,7 @@ var SocketSdk = class _SocketSdk {
3808
3562
  await createGetRequest(
3809
3563
  this.#baseUrl,
3810
3564
  `orgs/${encodeURIComponent(orgSlug)}/repos/labels?${queryToSearchParams(options)}`,
3811
- { ...this.#reqOptions, hooks: this.#hooks }
3565
+ this.#reqOptionsWithHooks
3812
3566
  )
3813
3567
  )
3814
3568
  );
@@ -3845,7 +3599,7 @@ var SocketSdk = class _SocketSdk {
3845
3599
  this.#baseUrl,
3846
3600
  `orgs/${encodeURIComponent(orgSlug)}/tokens`,
3847
3601
  tokenData,
3848
- { ...this.#reqOptions, hooks: this.#hooks }
3602
+ this.#reqOptionsWithHooks
3849
3603
  )
3850
3604
  )
3851
3605
  );
@@ -3869,7 +3623,7 @@ var SocketSdk = class _SocketSdk {
3869
3623
  this.#baseUrl,
3870
3624
  `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/revoke`,
3871
3625
  {},
3872
- { ...this.#reqOptions, hooks: this.#hooks }
3626
+ this.#reqOptionsWithHooks
3873
3627
  )
3874
3628
  )
3875
3629
  );
@@ -3893,7 +3647,7 @@ var SocketSdk = class _SocketSdk {
3893
3647
  this.#baseUrl,
3894
3648
  `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/rotate`,
3895
3649
  {},
3896
- { ...this.#reqOptions, hooks: this.#hooks }
3650
+ this.#reqOptionsWithHooks
3897
3651
  )
3898
3652
  )
3899
3653
  );
@@ -3917,7 +3671,7 @@ var SocketSdk = class _SocketSdk {
3917
3671
  this.#baseUrl,
3918
3672
  `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/update`,
3919
3673
  updateData,
3920
- { ...this.#reqOptions, hooks: this.#hooks }
3674
+ this.#reqOptionsWithHooks
3921
3675
  )
3922
3676
  )
3923
3677
  );
@@ -3945,7 +3699,7 @@ var SocketSdk = class _SocketSdk {
3945
3699
  this.#baseUrl,
3946
3700
  `orgs/${encodeURIComponent(orgSlug)}/telemetry`,
3947
3701
  telemetryData,
3948
- { ...this.#reqOptions, hooks: this.#hooks }
3702
+ this.#reqOptionsWithHooks
3949
3703
  )
3950
3704
  )
3951
3705
  );
@@ -3975,7 +3729,7 @@ var SocketSdk = class _SocketSdk {
3975
3729
  this.#baseUrl,
3976
3730
  "settings",
3977
3731
  { json: selectors },
3978
- { ...this.#reqOptions, hooks: this.#hooks }
3732
+ this.#reqOptionsWithHooks
3979
3733
  )
3980
3734
  )
3981
3735
  );
@@ -4027,7 +3781,7 @@ var SocketSdk = class _SocketSdk {
4027
3781
  this.#baseUrl,
4028
3782
  `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/rescan${queryString}`,
4029
3783
  {},
4030
- { ...this.#reqOptions, hooks: this.#hooks }
3784
+ this.#reqOptionsWithHooks
4031
3785
  )
4032
3786
  )
4033
3787
  );
@@ -4051,7 +3805,7 @@ var SocketSdk = class _SocketSdk {
4051
3805
  this.#baseUrl,
4052
3806
  "dependencies/search",
4053
3807
  queryParams,
4054
- { ...this.#reqOptions, hooks: this.#hooks }
3808
+ this.#reqOptionsWithHooks
4055
3809
  )
4056
3810
  )
4057
3811
  );
@@ -4082,7 +3836,7 @@ var SocketSdk = class _SocketSdk {
4082
3836
  this.#baseUrl,
4083
3837
  urlPath,
4084
3838
  body,
4085
- { ...this.#reqOptions, hooks: this.#hooks }
3839
+ this.#reqOptionsWithHooks
4086
3840
  );
4087
3841
  if (!isResponseOk(res)) {
4088
3842
  throw new ResponseError(res, "", url);
@@ -4097,8 +3851,7 @@ var SocketSdk = class _SocketSdk {
4097
3851
  cause: void 0,
4098
3852
  data,
4099
3853
  error: void 0,
4100
- /* c8 ignore next - Defensive fallback: response.statusCode is always defined in Node.js http/https */
4101
- status: response.statusCode ?? 200,
3854
+ status: response.status,
4102
3855
  success: true
4103
3856
  };
4104
3857
  } catch (e) {
@@ -4159,60 +3912,33 @@ var SocketSdk = class _SocketSdk {
4159
3912
  };
4160
3913
  const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`;
4161
3914
  try {
3915
+ const needsStream = typeof output === "string" || output === true;
4162
3916
  const res = await this.#executeWithRetry(async () => {
4163
- const req = getHttpModule(this.#baseUrl).request(url, {
3917
+ const response = await (0, import_http_request3.httpRequest)(url, {
4164
3918
  method: "GET",
4165
- ...this.#reqOptions
4166
- }).end();
4167
- const response = await getResponse(req);
3919
+ headers: this.#reqOptions.headers,
3920
+ stream: needsStream,
3921
+ timeout: this.#reqOptions.timeout,
3922
+ ...!needsStream && { maxResponseSize: MAX_RESPONSE_SIZE }
3923
+ });
4168
3924
  if (!isResponseOk(response)) {
4169
3925
  throw new ResponseError(response, "", url);
4170
3926
  }
4171
3927
  return response;
4172
3928
  });
4173
3929
  if (typeof output === "string") {
4174
- const writeStream = (0, import_node_fs3.createWriteStream)(output);
4175
- let bytesWritten = 0;
4176
- res.on("data", (chunk) => {
4177
- if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
4178
- const error = new Error(
4179
- `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
4180
- );
4181
- res.destroy(error);
4182
- writeStream.destroy(error);
4183
- return;
4184
- }
4185
- bytesWritten += chunk.length;
4186
- });
4187
- res.pipe(writeStream);
4188
- writeStream.on("error", (error) => {
4189
- res.destroy();
4190
- writeStream.destroy(error);
3930
+ const { createWriteStream } = await import("node:fs");
3931
+ await new Promise((resolve, reject) => {
3932
+ const ws = createWriteStream(output);
3933
+ ws.on("error", reject);
3934
+ ws.on("close", resolve);
3935
+ res.rawResponse.pipe(ws);
4191
3936
  });
4192
- await import_node_events.default.once(writeStream, "finish");
4193
3937
  } else if (output === true) {
4194
- let bytesWritten = 0;
4195
- res.on("data", (chunk) => {
4196
- if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
4197
- const error = new Error(
4198
- `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
4199
- );
4200
- res.destroy(error);
4201
- return;
4202
- }
4203
- bytesWritten += chunk.length;
4204
- });
4205
- const stdoutErrorHandler = (_error) => {
4206
- res.destroy();
4207
- import_node_process2.default.stdout.removeListener("error", stdoutErrorHandler);
4208
- };
4209
- import_node_process2.default.stdout.on("error", stdoutErrorHandler);
4210
- res.pipe(import_node_process2.default.stdout);
4211
- res.on("end", () => {
4212
- import_node_process2.default.stdout.removeListener("error", stdoutErrorHandler);
4213
- });
4214
- res.on("error", () => {
4215
- import_node_process2.default.stdout.removeListener("error", stdoutErrorHandler);
3938
+ await new Promise((resolve, reject) => {
3939
+ res.rawResponse.on("error", reject);
3940
+ res.rawResponse.on("end", resolve);
3941
+ res.rawResponse.pipe(import_node_process2.default.stdout);
4216
3942
  });
4217
3943
  }
4218
3944
  return this.#handleApiSuccess(res);
@@ -4232,43 +3958,34 @@ var SocketSdk = class _SocketSdk {
4232
3958
  const urlPath = `orgs/${encodeURIComponent(orgSlug)}/patches/scan?scan_id=${encodeURIComponent(scanId)}`;
4233
3959
  const url = `${this.#baseUrl}${urlPath}`;
4234
3960
  const response = await this.#executeWithRetry(
4235
- async () => await createGetRequest(this.#baseUrl, urlPath, {
4236
- ...this.#reqOptions,
4237
- hooks: this.#hooks
4238
- })
3961
+ async () => await createGetRequest(
3962
+ this.#baseUrl,
3963
+ urlPath,
3964
+ this.#reqOptionsWithHooks
3965
+ )
4239
3966
  );
4240
3967
  if (!isResponseOk(response)) {
4241
3968
  throw new ResponseError(response, "GET Request failed", url);
4242
3969
  }
4243
- const rli = import_node_readline.default.createInterface({
4244
- input: response,
4245
- crlfDelay: Number.POSITIVE_INFINITY
4246
- });
3970
+ const text = response.text();
4247
3971
  return new ReadableStream({
4248
- async start(controller) {
4249
- try {
4250
- for await (const line of rli) {
4251
- const trimmed = line.trim();
4252
- if (!trimmed) {
4253
- continue;
4254
- }
4255
- try {
4256
- const data = JSON.parse(trimmed);
4257
- controller.enqueue(data);
4258
- } catch (e) {
4259
- (0, import_debug2.debugLog)("streamPatchesFromScan", `Failed to parse line: ${e}`);
3972
+ start(controller) {
3973
+ let start = 0;
3974
+ for (let i = 0; i <= text.length; i++) {
3975
+ if (i === text.length || text.charCodeAt(i) === 10) {
3976
+ if (i > start) {
3977
+ const line = text.slice(start, i);
3978
+ try {
3979
+ const data = JSON.parse(line);
3980
+ controller.enqueue(data);
3981
+ } catch (e) {
3982
+ (0, import_debug2.debugLog)("streamPatchesFromScan", `Failed to parse line: ${e}`);
3983
+ }
4260
3984
  }
3985
+ start = i + 1;
4261
3986
  }
4262
- } catch (error) {
4263
- controller.error(error);
4264
- } finally {
4265
- rli.close();
4266
- controller.close();
4267
3987
  }
4268
- },
4269
- /* c8 ignore next 3 - Stream cancellation cleanup, difficult to test reliably. */
4270
- cancel() {
4271
- rli.close();
3988
+ controller.close();
4272
3989
  }
4273
3990
  });
4274
3991
  }
@@ -4287,7 +4004,7 @@ var SocketSdk = class _SocketSdk {
4287
4004
  this.#baseUrl,
4288
4005
  `orgs/${encodeURIComponent(orgSlug)}/triage/${encodeURIComponent(alertId)}`,
4289
4006
  triageData,
4290
- { ...this.#reqOptions, hooks: this.#hooks }
4007
+ this.#reqOptionsWithHooks
4291
4008
  )
4292
4009
  )
4293
4010
  );
@@ -4311,7 +4028,7 @@ var SocketSdk = class _SocketSdk {
4311
4028
  this.#baseUrl,
4312
4029
  `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy?${queryToSearchParams(queryParams)}`,
4313
4030
  policyData,
4314
- { ...this.#reqOptions, hooks: this.#hooks }
4031
+ this.#reqOptionsWithHooks
4315
4032
  )
4316
4033
  )
4317
4034
  );
@@ -4335,7 +4052,7 @@ var SocketSdk = class _SocketSdk {
4335
4052
  this.#baseUrl,
4336
4053
  `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
4337
4054
  policyData,
4338
- { ...this.#reqOptions, hooks: this.#hooks }
4055
+ this.#reqOptionsWithHooks
4339
4056
  )
4340
4057
  )
4341
4058
  );
@@ -4363,7 +4080,7 @@ var SocketSdk = class _SocketSdk {
4363
4080
  this.#baseUrl,
4364
4081
  `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
4365
4082
  telemetryData,
4366
- { ...this.#reqOptions, hooks: this.#hooks }
4083
+ this.#reqOptionsWithHooks
4367
4084
  )
4368
4085
  )
4369
4086
  );
@@ -4392,7 +4109,7 @@ var SocketSdk = class _SocketSdk {
4392
4109
  this.#baseUrl,
4393
4110
  `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
4394
4111
  webhookData,
4395
- { ...this.#reqOptions, hooks: this.#hooks }
4112
+ this.#reqOptionsWithHooks
4396
4113
  )
4397
4114
  )
4398
4115
  );
@@ -4444,7 +4161,7 @@ var SocketSdk = class _SocketSdk {
4444
4161
  this.#baseUrl,
4445
4162
  `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}${queryString}`,
4446
4163
  params,
4447
- { ...this.#reqOptions, hooks: this.#hooks }
4164
+ this.#reqOptionsWithHooks
4448
4165
  )
4449
4166
  )
4450
4167
  );
@@ -4501,7 +4218,7 @@ var SocketSdk = class _SocketSdk {
4501
4218
  this.#baseUrl,
4502
4219
  `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
4503
4220
  labelData,
4504
- { ...this.#reqOptions, hooks: this.#hooks }
4221
+ this.#reqOptionsWithHooks
4505
4222
  )
4506
4223
  )
4507
4224
  );
@@ -4597,7 +4314,7 @@ var SocketSdk = class _SocketSdk {
4597
4314
  this.#baseUrl,
4598
4315
  `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`,
4599
4316
  createRequestBodyForFilepaths(validPaths, basePath),
4600
- { ...this.#reqOptions, hooks: this.#hooks }
4317
+ this.#reqOptionsWithHooks
4601
4318
  )
4602
4319
  )
4603
4320
  );
@@ -4623,7 +4340,7 @@ var SocketSdk = class _SocketSdk {
4623
4340
  await createGetRequest(
4624
4341
  this.#baseUrl,
4625
4342
  `orgs/${encodeURIComponent(orgSlug)}/patches/view/${encodeURIComponent(uuid)}`,
4626
- { ...this.#reqOptions, hooks: this.#hooks }
4343
+ this.#reqOptionsWithHooks
4627
4344
  )
4628
4345
  )
4629
4346
  );
@@ -4640,39 +4357,16 @@ if ((0, import_debug2.isDebugNs)("heap")) {
4640
4357
  }
4641
4358
  // Annotate the CommonJS export names for ESM import in node:
4642
4359
  0 && (module.exports = {
4643
- DEFAULT_USER_AGENT,
4644
4360
  ResponseError,
4645
4361
  SocketSdk,
4646
4362
  calculateTotalQuotaCost,
4647
- calculateWordSetSimilarity,
4648
- createDeleteRequest,
4649
- createGetRequest,
4650
- createRequestBodyForFilepaths,
4651
- createRequestBodyForJson,
4652
- createRequestWithJson,
4653
- createUploadRequest,
4654
4363
  createUserAgentFromPkgJson,
4655
- filterRedundantCause,
4656
4364
  getAllMethodRequirements,
4657
- getErrorResponseBody,
4658
- getHttpModule,
4659
4365
  getMethodRequirements,
4660
4366
  getMethodsByPermissions,
4661
4367
  getMethodsByQuotaCost,
4662
4368
  getQuotaCost,
4663
4369
  getQuotaUsageSummary,
4664
4370
  getRequiredPermissions,
4665
- getResponse,
4666
- getResponseJson,
4667
- hasQuotaForMethods,
4668
- httpAgentNames,
4669
- isResponseOk,
4670
- normalizeBaseUrl,
4671
- promiseWithResolvers,
4672
- publicPolicy,
4673
- queryToSearchParams,
4674
- reshapeArtifactForPublicPolicy,
4675
- resolveAbsPaths,
4676
- resolveBasePath,
4677
- shouldOmitReason
4371
+ hasQuotaForMethods
4678
4372
  });