@socketsecurity/sdk 3.2.0 → 3.3.1

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
@@ -71,8 +71,8 @@ module.exports = __toCommonJS(index_exports);
71
71
  // package.json
72
72
  var package_default = {
73
73
  name: "@socketsecurity/sdk",
74
- version: "3.2.0",
75
- packageManager: "pnpm@10.25.0",
74
+ version: "3.3.1",
75
+ packageManager: "pnpm@10.30.3",
76
76
  license: "MIT",
77
77
  description: "SDK for the Socket API client",
78
78
  author: {
@@ -128,7 +128,7 @@ var package_default = {
128
128
  },
129
129
  dependencies: {
130
130
  "@socketregistry/packageurl-js": "1.3.5",
131
- "@socketsecurity/lib": "5.0.0",
131
+ "@socketsecurity/lib": "5.7.0",
132
132
  "form-data": "4.0.5"
133
133
  },
134
134
  devDependencies: {
@@ -137,13 +137,15 @@ var package_default = {
137
137
  "@babel/traverse": "7.26.4",
138
138
  "@babel/types": "7.26.3",
139
139
  "@biomejs/biome": "2.2.4",
140
- "@dotenvx/dotenvx": "^1.51.1",
140
+ "@dotenvx/dotenvx": "^1.52.0",
141
141
  "@eslint/compat": "1.3.2",
142
142
  "@eslint/js": "9.35.0",
143
+ "@sveltejs/acorn-typescript": "1.0.8",
143
144
  "@types/babel__traverse": "7.28.0",
144
145
  "@types/node": "24.9.2",
145
146
  "@typescript/native-preview": "7.0.0-dev.20250926.1",
146
147
  "@vitest/coverage-v8": "4.0.3",
148
+ acorn: "8.15.0",
147
149
  del: "8.0.1",
148
150
  "dev-null-cli": "2.0.0",
149
151
  esbuild: "0.25.11",
@@ -165,8 +167,7 @@ var package_default = {
165
167
  taze: "19.9.2",
166
168
  "type-coverage": "2.29.7",
167
169
  "typescript-eslint": "8.44.1",
168
- vitest: "4.0.3",
169
- "yoctocolors-cjs": "2.1.3"
170
+ vitest: "4.0.3"
170
171
  },
171
172
  pnpm: {
172
173
  ignoredBuiltDependencies: [
@@ -335,6 +336,40 @@ var publicPolicy = /* @__PURE__ */ new Map([
335
336
  var import_node_path = __toESM(require("node:path"));
336
337
  var import_memoization = require("@socketsecurity/lib/memoization");
337
338
  var import_normalize = require("@socketsecurity/lib/paths/normalize");
339
+ function normalizeToWordSet(s) {
340
+ const words = s.toLowerCase().match(/\w+/g);
341
+ return new Set(words ?? []);
342
+ }
343
+ function calculateWordSetSimilarity(str1, str2) {
344
+ const set1 = normalizeToWordSet(str1);
345
+ const set2 = normalizeToWordSet(str2);
346
+ if (set1.size === 0 && set2.size === 0) {
347
+ return 1;
348
+ }
349
+ if (set1.size === 0 || set2.size === 0) {
350
+ return 0;
351
+ }
352
+ let intersectionSize = 0;
353
+ for (const word of set1) {
354
+ if (set2.has(word)) {
355
+ intersectionSize++;
356
+ }
357
+ }
358
+ const unionSize = set1.size + set2.size - intersectionSize;
359
+ return intersectionSize / unionSize;
360
+ }
361
+ function filterRedundantCause(errorMessage, errorCause, threshold = 0.6) {
362
+ if (!errorCause || !errorCause.trim()) {
363
+ return void 0;
364
+ }
365
+ const messageParts = errorMessage.split(":").map((part) => part.trim());
366
+ for (const part of messageParts) {
367
+ if (part && shouldOmitReason(part, errorCause, threshold)) {
368
+ return void 0;
369
+ }
370
+ }
371
+ return errorCause;
372
+ }
338
373
  var normalizeBaseUrl = (0, import_memoization.memoize)(
339
374
  (baseUrl) => {
340
375
  return baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
@@ -379,28 +414,6 @@ function resolveAbsPaths(filepaths, pathsRelativeTo) {
379
414
  function resolveBasePath(pathsRelativeTo = ".") {
380
415
  return (0, import_normalize.normalizePath)(import_node_path.default.resolve(process.cwd(), pathsRelativeTo));
381
416
  }
382
- function normalizeToWordSet(s) {
383
- const words = s.toLowerCase().match(/\w+/g);
384
- return new Set(words ?? []);
385
- }
386
- function calculateWordSetSimilarity(str1, str2) {
387
- const set1 = normalizeToWordSet(str1);
388
- const set2 = normalizeToWordSet(str2);
389
- if (set1.size === 0 && set2.size === 0) {
390
- return 1;
391
- }
392
- if (set1.size === 0 || set2.size === 0) {
393
- return 0;
394
- }
395
- let intersectionSize = 0;
396
- for (const word of set1) {
397
- if (set2.has(word)) {
398
- intersectionSize++;
399
- }
400
- }
401
- const unionSize = set1.size + set2.size - intersectionSize;
402
- return intersectionSize / unionSize;
403
- }
404
417
  function shouldOmitReason(errorMessage, reason, threshold = 0.6) {
405
418
  if (!reason || !reason.trim()) {
406
419
  return true;
@@ -408,18 +421,6 @@ function shouldOmitReason(errorMessage, reason, threshold = 0.6) {
408
421
  const similarity = calculateWordSetSimilarity(errorMessage, reason);
409
422
  return similarity >= threshold;
410
423
  }
411
- function filterRedundantCause(errorMessage, errorCause, threshold = 0.6) {
412
- if (!errorCause || !errorCause.trim()) {
413
- return void 0;
414
- }
415
- const messageParts = errorMessage.split(":").map((part) => part.trim());
416
- for (const part of messageParts) {
417
- if (part && shouldOmitReason(part, errorCause, threshold)) {
418
- return void 0;
419
- }
420
- }
421
- return errorCause;
422
- }
423
424
 
424
425
  // src/file-upload.ts
425
426
  var import_node_fs = require("node:fs");
@@ -466,11 +467,12 @@ function sanitizeHeaders(headers) {
466
467
  // src/http-client.ts
467
468
  var ResponseError = class _ResponseError extends Error {
468
469
  response;
470
+ url;
469
471
  /**
470
472
  * Create a new ResponseError from an HTTP response.
471
473
  * Automatically formats error message with status code and message.
472
474
  */
473
- constructor(response, message = "") {
475
+ constructor(response, message = "", url) {
474
476
  const statusCode = response.statusCode ?? "unknown";
475
477
  const statusMessage = response.statusMessage ?? "No status message";
476
478
  super(
@@ -479,6 +481,7 @@ var ResponseError = class _ResponseError extends Error {
479
481
  );
480
482
  this.name = "ResponseError";
481
483
  this.response = response;
484
+ this.url = url;
482
485
  Error.captureStackTrace(this, _ResponseError);
483
486
  }
484
487
  };
@@ -625,10 +628,10 @@ async function getErrorResponseBody(response) {
625
628
  response.setEncoding("utf8");
626
629
  response.on("data", (chunk) => {
627
630
  const chunkBytes = Buffer.byteLength(chunk, "utf8");
628
- totalBytes += chunkBytes;
629
- if (totalBytes > MAX_RESPONSE_SIZE) {
631
+ if (totalBytes + chunkBytes > MAX_RESPONSE_SIZE) {
630
632
  response.destroy();
631
- const sizeMB = (totalBytes / (1024 * 1024)).toFixed(2);
633
+ const projectedSize = totalBytes + chunkBytes;
634
+ const sizeMB = (projectedSize / (1024 * 1024)).toFixed(2);
632
635
  const maxMB = (MAX_RESPONSE_SIZE / (1024 * 1024)).toFixed(2);
633
636
  const message = [
634
637
  `Response exceeds maximum size limit (${sizeMB}MB > ${maxMB}MB)`,
@@ -640,6 +643,7 @@ async function getErrorResponseBody(response) {
640
643
  reject(new Error(message));
641
644
  return;
642
645
  }
646
+ totalBytes += chunkBytes;
643
647
  body += chunk;
644
648
  });
645
649
  response.on("end", () => resolve(body));
@@ -729,13 +733,14 @@ async function getResponse(req) {
729
733
  });
730
734
  });
731
735
  }
732
- async function getResponseJson(response, method) {
736
+ async function getResponseJson(response, method, url) {
733
737
  const stopTimer = (0, import_performance.perfTimer)("http:parse-json");
734
738
  try {
735
739
  if (!isResponseOk(response)) {
736
740
  throw new ResponseError(
737
741
  response,
738
- method ? `${method} Request failed` : void 0
742
+ method ? `${method} Request failed` : void 0,
743
+ url
739
744
  );
740
745
  }
741
746
  const responseBody = await getErrorResponseBody(response);
@@ -807,7 +812,7 @@ function isResponseOk(response) {
807
812
  }
808
813
  function reshapeArtifactForPublicPolicy(data, isAuthenticated, actions) {
809
814
  if (!isAuthenticated) {
810
- const allowedActions = actions ? actions.split(",") : void 0;
815
+ const allowedActions = actions?.trim() ? actions.split(",") : void 0;
811
816
  const reshapeArtifact = (artifact) => ({
812
817
  name: artifact.name,
813
818
  version: artifact.version,
@@ -921,7 +926,7 @@ async function createUploadRequest(baseUrl, urlPath, form, options) {
921
926
  timeout: opts.timeout
922
927
  });
923
928
  req.flushHeaders();
924
- getResponse(req).then(
929
+ void getResponse(req).then(
925
930
  (response) => {
926
931
  hooks?.onResponse?.({
927
932
  method,
@@ -945,7 +950,6 @@ async function createUploadRequest(baseUrl, urlPath, form, options) {
945
950
  );
946
951
  form.pipe(req);
947
952
  form.on("error", fail);
948
- req.on("error", fail);
949
953
  });
950
954
  }
951
955
 
@@ -1122,7 +1126,7 @@ var SocketSdk = class {
1122
1126
  userAgent
1123
1127
  } = { __proto__: null, ...options };
1124
1128
  if (timeout !== void 0) {
1125
- if (typeof timeout !== "number" || timeout < MIN_HTTP_TIMEOUT || timeout > MAX_HTTP_TIMEOUT) {
1129
+ if (typeof timeout !== "number" || Number.isNaN(timeout) || timeout < MIN_HTTP_TIMEOUT || timeout > MAX_HTTP_TIMEOUT) {
1126
1130
  throw new TypeError(
1127
1131
  `"timeout" must be a number between ${MIN_HTTP_TIMEOUT} and ${MAX_HTTP_TIMEOUT} milliseconds`
1128
1132
  );
@@ -1185,22 +1189,26 @@ var SocketSdk = class {
1185
1189
  signal: abortSignal
1186
1190
  });
1187
1191
  const isPublicToken = this.#apiToken === import_socket2.SOCKET_PUBLIC_API_TOKEN;
1188
- for await (const line of rli) {
1189
- const trimmed = line.trim();
1190
- const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1191
- /* c8 ignore next - Empty line handling in batch streaming response parsing. */
1192
- null
1193
- );
1194
- if ((0, import_objects.isObjectObject)(artifact)) {
1195
- yield this.#handleApiSuccess(
1196
- /* c8 ignore next 7 - Public token artifact reshaping branch for policy compliance. */
1197
- isPublicToken ? reshapeArtifactForPublicPolicy(
1198
- artifact,
1199
- false,
1200
- queryParams?.["actions"]
1201
- ) : artifact
1192
+ try {
1193
+ for await (const line of rli) {
1194
+ const trimmed = line.trim();
1195
+ const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1196
+ /* c8 ignore next - Empty line handling in batch streaming response parsing. */
1197
+ null
1202
1198
  );
1199
+ if ((0, import_objects.isObjectObject)(artifact)) {
1200
+ yield this.#handleApiSuccess(
1201
+ /* c8 ignore next 7 - Public token artifact reshaping branch for policy compliance. */
1202
+ isPublicToken ? reshapeArtifactForPublicPolicy(
1203
+ artifact,
1204
+ false,
1205
+ queryParams?.["actions"]
1206
+ ) : artifact
1207
+ );
1208
+ }
1203
1209
  }
1210
+ } finally {
1211
+ rli.close();
1204
1212
  }
1205
1213
  }
1206
1214
  /**
@@ -1208,13 +1216,14 @@ var SocketSdk = class {
1208
1216
  * Internal method for handling PURL batch API calls with retry logic.
1209
1217
  */
1210
1218
  async #createBatchPurlRequest(componentsObj, queryParams) {
1211
- const req = getHttpModule(this.#baseUrl).request(`${this.#baseUrl}purl?${queryToSearchParams(queryParams)}`, {
1219
+ const url = `${this.#baseUrl}purl?${queryToSearchParams(queryParams)}`;
1220
+ const req = getHttpModule(this.#baseUrl).request(url, {
1212
1221
  method: "POST",
1213
1222
  ...this.#reqOptions
1214
1223
  }).end(JSON.stringify(componentsObj));
1215
1224
  const response = await getResponse(req);
1216
1225
  if (!isResponseOk(response)) {
1217
- throw new ResponseError(response);
1226
+ throw new ResponseError(response, "", url);
1218
1227
  }
1219
1228
  return response;
1220
1229
  }
@@ -1448,7 +1457,8 @@ var SocketSdk = class {
1448
1457
  error: errorMessage,
1449
1458
  /* c8 ignore next - fallback for missing status code in edge cases. */
1450
1459
  status: statusCode ?? 0,
1451
- success: false
1460
+ success: false,
1461
+ url: error.url
1452
1462
  };
1453
1463
  }
1454
1464
  /**
@@ -1506,6 +1516,85 @@ var SocketSdk = class {
1506
1516
  }
1507
1517
  return void 0;
1508
1518
  }
1519
+ /**
1520
+ * Get package metadata and alerts by PURL strings for a specific organization.
1521
+ * Organization-scoped version of batchPackageFetch with security policy label support.
1522
+ *
1523
+ * @param orgSlug - Organization identifier
1524
+ * @param componentsObj - Object containing array of components with PURL strings
1525
+ * @param queryParams - Optional query parameters including labels, alerts, compact, etc.
1526
+ * @returns Package metadata and alerts for the requested PURLs
1527
+ *
1528
+ * @example
1529
+ * ```typescript
1530
+ * const result = await sdk.batchOrgPackageFetch('my-org',
1531
+ * {
1532
+ * components: [
1533
+ * { purl: 'pkg:npm/express@4.19.2' },
1534
+ * { purl: 'pkg:pypi/django@5.0.6' }
1535
+ * ]
1536
+ * },
1537
+ * { labels: ['production'], alerts: true }
1538
+ * )
1539
+ *
1540
+ * if (result.success) {
1541
+ * for (const artifact of result.data) {
1542
+ * console.log(`${artifact.name}@${artifact.version}`)
1543
+ * }
1544
+ * }
1545
+ * ```
1546
+ *
1547
+ * @see https://docs.socket.dev/reference/batchpackagefetchbyorg
1548
+ * @apiEndpoint POST /orgs/{org_slug}/purl
1549
+ * @quota 100 units
1550
+ * @scopes packages:list
1551
+ * @throws {Error} When server returns 5xx status codes
1552
+ */
1553
+ async batchOrgPackageFetch(orgSlug, componentsObj, queryParams) {
1554
+ const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/purl?${queryToSearchParams(queryParams)}`;
1555
+ let res;
1556
+ try {
1557
+ const req = getHttpModule(this.#baseUrl).request(url, {
1558
+ method: "POST",
1559
+ ...this.#reqOptions
1560
+ }).end(JSON.stringify(componentsObj));
1561
+ res = await getResponse(req);
1562
+ if (!isResponseOk(res)) {
1563
+ throw new ResponseError(res, "", url);
1564
+ }
1565
+ } catch (e) {
1566
+ return await this.#handleApiError(e);
1567
+ }
1568
+ if (!res) {
1569
+ throw new Error("Failed to get response from batch PURL request");
1570
+ }
1571
+ const rli = import_node_readline.default.createInterface({
1572
+ input: res,
1573
+ crlfDelay: Number.POSITIVE_INFINITY,
1574
+ signal: abortSignal
1575
+ });
1576
+ const results = [];
1577
+ try {
1578
+ for await (const line of rli) {
1579
+ const trimmed = line.trim();
1580
+ const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1581
+ /* c8 ignore next - Empty line handling in batch parsing. */
1582
+ null
1583
+ );
1584
+ if ((0, import_objects.isObjectObject)(artifact)) {
1585
+ results.push(artifact);
1586
+ }
1587
+ }
1588
+ } finally {
1589
+ rli.close();
1590
+ }
1591
+ const compact = (0, import_url.urlSearchParamAsBoolean)(
1592
+ (0, import_objects.getOwn)(queryParams, "compact")
1593
+ );
1594
+ return this.#handleApiSuccess(
1595
+ compact ? results : results
1596
+ );
1597
+ }
1509
1598
  /**
1510
1599
  * Fetch package analysis data for multiple packages in a single batch request.
1511
1600
  * Returns all results at once after processing is complete.
@@ -1529,22 +1618,26 @@ var SocketSdk = class {
1529
1618
  });
1530
1619
  const isPublicToken = this.#apiToken === import_socket2.SOCKET_PUBLIC_API_TOKEN;
1531
1620
  const results = [];
1532
- for await (const line of rli) {
1533
- const trimmed = line.trim();
1534
- const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1535
- /* c8 ignore next - Empty line handling in batch parsing. */
1536
- null
1537
- );
1538
- if ((0, import_objects.isObjectObject)(artifact)) {
1539
- results.push(
1540
- /* c8 ignore next 7 - Public token artifact reshaping for policy compliance. */
1541
- isPublicToken ? reshapeArtifactForPublicPolicy(
1542
- artifact,
1543
- false,
1544
- queryParams?.["actions"]
1545
- ) : artifact
1621
+ try {
1622
+ for await (const line of rli) {
1623
+ const trimmed = line.trim();
1624
+ const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1625
+ /* c8 ignore next - Empty line handling in batch parsing. */
1626
+ null
1546
1627
  );
1628
+ if ((0, import_objects.isObjectObject)(artifact)) {
1629
+ results.push(
1630
+ /* c8 ignore next 7 - Public token artifact reshaping for policy compliance. */
1631
+ isPublicToken ? reshapeArtifactForPublicPolicy(
1632
+ artifact,
1633
+ false,
1634
+ queryParams?.["actions"]
1635
+ ) : artifact
1636
+ );
1637
+ }
1547
1638
  }
1639
+ } finally {
1640
+ rli.close();
1548
1641
  }
1549
1642
  const compact = (0, import_url.urlSearchParamAsBoolean)(
1550
1643
  (0, import_objects.getOwn)(queryParams, "compact")
@@ -1610,11 +1703,13 @@ var SocketSdk = class {
1610
1703
  const { generator, iteratorResult } = await Promise.race(
1611
1704
  running.map((entry) => entry.promise)
1612
1705
  );
1613
- const index2 = running.findIndex((entry) => entry.generator === generator);
1614
- if (index2 === -1) {
1706
+ const runningIndex = running.findIndex(
1707
+ (entry) => entry.generator === generator
1708
+ );
1709
+ if (runningIndex === -1) {
1615
1710
  continue;
1616
1711
  }
1617
- running.splice(index2, 1);
1712
+ running.splice(runningIndex, 1);
1618
1713
  if (iteratorResult.value) {
1619
1714
  yield iteratorResult.value;
1620
1715
  }
@@ -1708,30 +1803,6 @@ var SocketSdk = class {
1708
1803
  return await this.#handleApiError(e);
1709
1804
  }
1710
1805
  }
1711
- /**
1712
- * Create a diff scan from two full scan IDs.
1713
- * Compares two existing full scans to identify changes.
1714
- *
1715
- * @throws {Error} When server returns 5xx status codes
1716
- */
1717
- async createOrgDiffScanFromIds(orgSlug, queryParams) {
1718
- try {
1719
- const data = await this.#executeWithRetry(
1720
- async () => await getResponseJson(
1721
- await createRequestWithJson(
1722
- "POST",
1723
- this.#baseUrl,
1724
- `orgs/${encodeURIComponent(orgSlug)}/diff-scans?${queryToSearchParams(queryParams)}`,
1725
- {},
1726
- { ...this.#reqOptions, hooks: this.#hooks }
1727
- )
1728
- )
1729
- );
1730
- return this.#handleApiSuccess(data);
1731
- } catch (e) {
1732
- return await this.#handleApiError(e);
1733
- }
1734
- }
1735
1806
  /**
1736
1807
  * Create a full security scan for an organization.
1737
1808
  *
@@ -1764,7 +1835,7 @@ var SocketSdk = class {
1764
1835
  *
1765
1836
  * @see https://docs.socket.dev/reference/createorgfullscan
1766
1837
  * @apiEndpoint POST /orgs/{org_slug}/full-scans
1767
- * @quota 1 unit
1838
+ * @quota 0 units
1768
1839
  * @scopes full-scans:create
1769
1840
  * @throws {Error} When server returns 5xx status codes
1770
1841
  */
@@ -1859,21 +1930,136 @@ var SocketSdk = class {
1859
1930
  };
1860
1931
  }
1861
1932
  }
1933
+ /**
1934
+ * Create a diff scan from two full scan IDs.
1935
+ * Compares two existing full scans to identify changes.
1936
+ *
1937
+ * @param orgSlug - Organization identifier
1938
+ * @param options - Diff scan creation options
1939
+ * @param options.after - ID of the after/head full scan (newer)
1940
+ * @param options.before - ID of the before/base full scan (older)
1941
+ * @param options.description - Description of the diff scan
1942
+ * @param options.external_href - External URL to associate with the diff scan
1943
+ * @param options.merge - Set true for merged commits, false for open PR diffs
1944
+ * @returns Diff scan details
1945
+ *
1946
+ * @example
1947
+ * ```typescript
1948
+ * const result = await sdk.createOrgDiffScanFromIds('my-org', {
1949
+ * before: 'scan-id-1',
1950
+ * after: 'scan-id-2',
1951
+ * description: 'Compare versions',
1952
+ * merge: false
1953
+ * })
1954
+ *
1955
+ * if (result.success) {
1956
+ * console.log('Diff scan created:', result.data.diff_scan.id)
1957
+ * }
1958
+ * ```
1959
+ *
1960
+ * @see https://docs.socket.dev/reference/createorgdiffscanfromids
1961
+ * @apiEndpoint POST /orgs/{org_slug}/diff-scans/from-ids
1962
+ * @quota 0 units
1963
+ * @scopes diff-scans:create, full-scans:list
1964
+ * @throws {Error} When server returns 5xx status codes
1965
+ */
1966
+ async createOrgDiffScanFromIds(orgSlug, options) {
1967
+ try {
1968
+ const data = await this.#executeWithRetry(
1969
+ async () => await getResponseJson(
1970
+ await createRequestWithJson(
1971
+ "POST",
1972
+ this.#baseUrl,
1973
+ `orgs/${encodeURIComponent(orgSlug)}/diff-scans/from-ids?${queryToSearchParams(options)}`,
1974
+ {},
1975
+ { ...this.#reqOptions, hooks: this.#hooks }
1976
+ )
1977
+ )
1978
+ );
1979
+ return this.#handleApiSuccess(data);
1980
+ } catch (e) {
1981
+ return await this.#handleApiError(e);
1982
+ }
1983
+ }
1984
+ /**
1985
+ * Create a full scan from an archive file (.tar, .tar.gz/.tgz, or .zip).
1986
+ * Uploads and scans a compressed archive of project files.
1987
+ *
1988
+ * @param orgSlug - Organization identifier
1989
+ * @param archivePath - Path to the archive file to upload
1990
+ * @param options - Scan configuration options including repo, branch, and metadata
1991
+ * @returns Created full scan details with scan ID and status
1992
+ *
1993
+ * @throws {Error} When server returns 5xx status codes or file cannot be read
1994
+ */
1995
+ async createOrgFullScanFromArchive(orgSlug, archivePath, options) {
1996
+ const basePath = import_node_path4.default.dirname(archivePath);
1997
+ try {
1998
+ const data = await this.#executeWithRetry(
1999
+ async () => await getResponseJson(
2000
+ await createUploadRequest(
2001
+ this.#baseUrl,
2002
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/archive?${queryToSearchParams(options)}`,
2003
+ createRequestBodyForFilepaths([archivePath], basePath),
2004
+ { ...this.#reqOptions, hooks: this.#hooks }
2005
+ )
2006
+ )
2007
+ );
2008
+ return this.#handleApiSuccess(data);
2009
+ } catch (e) {
2010
+ return await this.#handleApiError(e);
2011
+ }
2012
+ }
2013
+ /**
2014
+ * Create a new webhook for an organization.
2015
+ * Webhooks allow you to receive HTTP POST notifications when specific events occur.
2016
+ *
2017
+ * @param orgSlug - Organization identifier
2018
+ * @param webhookData - Webhook configuration including name, URL, secret, and events
2019
+ * @returns Created webhook details including webhook ID
2020
+ *
2021
+ * @throws {Error} When server returns 5xx status codes
2022
+ */
2023
+ async createOrgWebhook(orgSlug, webhookData) {
2024
+ try {
2025
+ const data = await this.#executeWithRetry(
2026
+ async () => await getResponseJson(
2027
+ await createRequestWithJson(
2028
+ "POST",
2029
+ this.#baseUrl,
2030
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks`,
2031
+ webhookData,
2032
+ { ...this.#reqOptions, hooks: this.#hooks }
2033
+ )
2034
+ )
2035
+ );
2036
+ return this.#handleApiSuccess(data);
2037
+ } catch (e) {
2038
+ return await this.#handleApiError(e);
2039
+ }
2040
+ }
1862
2041
  /**
1863
2042
  * Create a new repository in an organization.
1864
2043
  *
1865
2044
  * Registers a repository for monitoring and security scanning.
1866
2045
  *
1867
2046
  * @param orgSlug - Organization identifier
1868
- * @param params - Repository configuration (name, description, homepage, etc.)
2047
+ * @param repoSlug - Repository name/slug
2048
+ * @param params - Additional repository configuration
2049
+ * @param params.archived - Whether the repository is archived
2050
+ * @param params.default_branch - Default branch of the repository
2051
+ * @param params.description - Description of the repository
2052
+ * @param params.homepage - Homepage URL of the repository
2053
+ * @param params.visibility - Visibility setting ('public' or 'private')
2054
+ * @param params.workspace - Workspace of the repository
1869
2055
  * @returns Created repository details
1870
2056
  *
1871
2057
  * @example
1872
2058
  * ```typescript
1873
- * const result = await sdk.createRepository('my-org', {
1874
- * name: 'my-repo',
2059
+ * const result = await sdk.createRepository('my-org', 'my-repo', {
1875
2060
  * description: 'My project repository',
1876
- * homepage: 'https://example.com'
2061
+ * homepage: 'https://example.com',
2062
+ * visibility: 'private'
1877
2063
  * })
1878
2064
  *
1879
2065
  * if (result.success) {
@@ -1883,11 +2069,11 @@ var SocketSdk = class {
1883
2069
  *
1884
2070
  * @see https://docs.socket.dev/reference/createorgrepo
1885
2071
  * @apiEndpoint POST /orgs/{org_slug}/repos
1886
- * @quota 1 unit
2072
+ * @quota 0 units
1887
2073
  * @scopes repo:write
1888
2074
  * @throws {Error} When server returns 5xx status codes
1889
2075
  */
1890
- async createRepository(orgSlug, params) {
2076
+ async createRepository(orgSlug, repoSlug, params) {
1891
2077
  try {
1892
2078
  const data = await this.#executeWithRetry(
1893
2079
  async () => await getResponseJson(
@@ -1895,7 +2081,7 @@ var SocketSdk = class {
1895
2081
  "POST",
1896
2082
  this.#baseUrl,
1897
2083
  `orgs/${encodeURIComponent(orgSlug)}/repos`,
1898
- params,
2084
+ { ...params, name: repoSlug },
1899
2085
  { ...this.#reqOptions, hooks: this.#hooks }
1900
2086
  )
1901
2087
  )
@@ -1939,7 +2125,7 @@ var SocketSdk = class {
1939
2125
  *
1940
2126
  * @see https://docs.socket.dev/reference/createorgrepolabel
1941
2127
  * @apiEndpoint POST /orgs/{org_slug}/repos/labels
1942
- * @quota 1 unit
2128
+ * @quota 0 units
1943
2129
  * @scopes repo-label:create
1944
2130
  * @throws {Error} When server returns 5xx status codes
1945
2131
  */
@@ -1975,32 +2161,56 @@ var SocketSdk = class {
1975
2161
  }
1976
2162
  }
1977
2163
  /**
1978
- * Create a full scan from an archive file (.tar, .tar.gz/.tgz, or .zip).
1979
- * Uploads and scans a compressed archive of project files.
2164
+ * Delete a full scan from an organization.
2165
+ *
2166
+ * Permanently removes scan data and results.
1980
2167
  *
1981
2168
  * @param orgSlug - Organization identifier
1982
- * @param archivePath - Path to the archive file to upload
1983
- * @param options - Scan configuration options including repo, branch, and metadata
1984
- * @returns Created full scan details with scan ID and status
2169
+ * @param scanId - Full scan identifier to delete
2170
+ * @returns Success confirmation
1985
2171
  *
1986
- * @throws {Error} When server returns 5xx status codes or file cannot be read
1987
- */
1988
- async createOrgFullScanFromArchive(orgSlug, archivePath, options) {
1989
- const basePath = import_node_path4.default.dirname(archivePath);
1990
- try {
1991
- const data = await this.#executeWithRetry(
1992
- async () => await getResponseJson(
1993
- await createUploadRequest(
1994
- this.#baseUrl,
1995
- `orgs/${encodeURIComponent(orgSlug)}/full-scans/archive?${queryToSearchParams(options)}`,
1996
- createRequestBodyForFilepaths([archivePath], basePath),
2172
+ * @example
2173
+ * ```typescript
2174
+ * const result = await sdk.deleteFullScan('my-org', 'scan_123')
2175
+ *
2176
+ * if (result.success) {
2177
+ * console.log('Scan deleted successfully')
2178
+ * }
2179
+ * ```
2180
+ *
2181
+ * @see https://docs.socket.dev/reference/deleteorgfullscan
2182
+ * @apiEndpoint DELETE /orgs/{org_slug}/full-scans/{full_scan_id}
2183
+ * @quota 0 units
2184
+ * @scopes full-scans:delete
2185
+ * @throws {Error} When server returns 5xx status codes
2186
+ */
2187
+ async deleteFullScan(orgSlug, scanId) {
2188
+ try {
2189
+ const data = await this.#executeWithRetry(
2190
+ async () => await getResponseJson(
2191
+ await createDeleteRequest(
2192
+ this.#baseUrl,
2193
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
1997
2194
  { ...this.#reqOptions, hooks: this.#hooks }
1998
2195
  )
1999
2196
  )
2000
2197
  );
2001
- return this.#handleApiSuccess(data);
2198
+ return {
2199
+ cause: void 0,
2200
+ data,
2201
+ error: void 0,
2202
+ status: 200,
2203
+ success: true
2204
+ };
2002
2205
  } catch (e) {
2003
- return await this.#handleApiError(e);
2206
+ const errorResult = await this.#handleApiError(e);
2207
+ return {
2208
+ cause: errorResult.cause,
2209
+ data: void 0,
2210
+ error: errorResult.error,
2211
+ status: errorResult.status,
2212
+ success: false
2213
+ };
2004
2214
  }
2005
2215
  }
2006
2216
  /**
@@ -2026,56 +2236,29 @@ var SocketSdk = class {
2026
2236
  }
2027
2237
  }
2028
2238
  /**
2029
- * Delete a full scan from an organization.
2030
- *
2031
- * Permanently removes scan data and results.
2239
+ * Delete a webhook from an organization.
2240
+ * This will stop all future webhook deliveries to the webhook URL.
2032
2241
  *
2033
2242
  * @param orgSlug - Organization identifier
2034
- * @param scanId - Full scan identifier to delete
2035
- * @returns Success confirmation
2036
- *
2037
- * @example
2038
- * ```typescript
2039
- * const result = await sdk.deleteFullScan('my-org', 'scan_123')
2040
- *
2041
- * if (result.success) {
2042
- * console.log('Scan deleted successfully')
2043
- * }
2044
- * ```
2243
+ * @param webhookId - Webhook ID to delete
2244
+ * @returns Success status
2045
2245
  *
2046
- * @see https://docs.socket.dev/reference/deleteorgfullscan
2047
- * @apiEndpoint DELETE /orgs/{org_slug}/full-scans/{full_scan_id}
2048
- * @quota 1 unit
2049
- * @scopes full-scans:delete
2050
2246
  * @throws {Error} When server returns 5xx status codes
2051
2247
  */
2052
- async deleteFullScan(orgSlug, scanId) {
2248
+ async deleteOrgWebhook(orgSlug, webhookId) {
2053
2249
  try {
2054
2250
  const data = await this.#executeWithRetry(
2055
2251
  async () => await getResponseJson(
2056
2252
  await createDeleteRequest(
2057
2253
  this.#baseUrl,
2058
- `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
2254
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
2059
2255
  { ...this.#reqOptions, hooks: this.#hooks }
2060
2256
  )
2061
2257
  )
2062
2258
  );
2063
- return {
2064
- cause: void 0,
2065
- data,
2066
- error: void 0,
2067
- status: 200,
2068
- success: true
2069
- };
2259
+ return this.#handleApiSuccess(data);
2070
2260
  } catch (e) {
2071
- const errorResult = await this.#handleApiError(e);
2072
- return {
2073
- cause: errorResult.cause,
2074
- data: void 0,
2075
- error: errorResult.error,
2076
- status: errorResult.status,
2077
- success: false
2078
- };
2261
+ return await this.#handleApiError(e);
2079
2262
  }
2080
2263
  }
2081
2264
  /**
@@ -2085,6 +2268,7 @@ var SocketSdk = class {
2085
2268
  *
2086
2269
  * @param orgSlug - Organization identifier
2087
2270
  * @param repoSlug - Repository slug/name to delete
2271
+ * @param options - Optional parameters including workspace
2088
2272
  * @returns Success confirmation
2089
2273
  *
2090
2274
  * @example
@@ -2098,17 +2282,22 @@ var SocketSdk = class {
2098
2282
  *
2099
2283
  * @see https://docs.socket.dev/reference/deleteorgrepo
2100
2284
  * @apiEndpoint DELETE /orgs/{org_slug}/repos/{repo_slug}
2101
- * @quota 1 unit
2285
+ * @quota 0 units
2102
2286
  * @scopes repo:write
2103
2287
  * @throws {Error} When server returns 5xx status codes
2104
2288
  */
2105
- async deleteRepository(orgSlug, repoSlug) {
2289
+ async deleteRepository(orgSlug, repoSlug, options) {
2290
+ const { workspace } = {
2291
+ __proto__: null,
2292
+ ...options
2293
+ };
2294
+ const queryString = workspace ? `?${queryToSearchParams({ workspace })}` : "";
2106
2295
  try {
2107
2296
  const data = await this.#executeWithRetry(
2108
2297
  async () => await getResponseJson(
2109
2298
  await createDeleteRequest(
2110
2299
  this.#baseUrl,
2111
- `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`,
2300
+ `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}${queryString}`,
2112
2301
  { ...this.#reqOptions, hooks: this.#hooks }
2113
2302
  )
2114
2303
  )
@@ -2151,7 +2340,7 @@ var SocketSdk = class {
2151
2340
  *
2152
2341
  * @see https://docs.socket.dev/reference/deleteorgrepolabel
2153
2342
  * @apiEndpoint DELETE /orgs/{org_slug}/repos/labels/{label_id}
2154
- * @quota 1 unit
2343
+ * @quota 0 units
2155
2344
  * @scopes repo-label:delete
2156
2345
  * @throws {Error} When server returns 5xx status codes
2157
2346
  */
@@ -2185,7 +2374,173 @@ var SocketSdk = class {
2185
2374
  }
2186
2375
  }
2187
2376
  /**
2188
- * Delete a legacy scan report permanently.
2377
+ * Delete a legacy scan report permanently.
2378
+
2379
+ /**
2380
+ * Download patch file content by hash.
2381
+ *
2382
+ * Downloads the actual patched file content from the public Socket blob store.
2383
+ * This is used after calling viewPatch() to get the patch metadata.
2384
+ * No authentication is required as patch blobs are publicly accessible.
2385
+ *
2386
+ * @param hash - The blob hash in SSRI (sha256-base64) or hex format
2387
+ * @param options - Optional configuration
2388
+ * @param options.baseUrl - Override blob store URL (for testing)
2389
+ * @returns Promise<string> - The patch file content as UTF-8 string
2390
+ * @throws Error if blob not found (404) or download fails
2391
+ *
2392
+ * @example
2393
+ * ```typescript
2394
+ * const sdk = new SocketSdk('your-api-token')
2395
+ * // First get patch metadata
2396
+ * const patch = await sdk.viewPatch('my-org', 'patch-uuid')
2397
+ * // Then download the actual patched file
2398
+ * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
2399
+ * ```
2400
+ */
2401
+ async downloadOrgFullScanFilesAsTar(orgSlug, fullScanId, outputPath) {
2402
+ const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/files.tar`;
2403
+ try {
2404
+ const req = getHttpModule(this.#baseUrl).request(url, {
2405
+ method: "GET",
2406
+ ...this.#reqOptions
2407
+ }).end();
2408
+ const res = await getResponse(req);
2409
+ if (!isResponseOk(res)) {
2410
+ throw new ResponseError(res, "", url);
2411
+ }
2412
+ const writeStream = (0, import_node_fs3.createWriteStream)(outputPath);
2413
+ let bytesWritten = 0;
2414
+ res.on("data", (chunk) => {
2415
+ if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
2416
+ const error = new Error(
2417
+ `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
2418
+ );
2419
+ res.destroy(error);
2420
+ writeStream.destroy(error);
2421
+ return;
2422
+ }
2423
+ bytesWritten += chunk.length;
2424
+ });
2425
+ res.pipe(writeStream);
2426
+ writeStream.on("error", (error) => {
2427
+ res.destroy();
2428
+ writeStream.destroy(error);
2429
+ });
2430
+ await import_node_events.default.once(writeStream, "finish");
2431
+ return this.#handleApiSuccess(res);
2432
+ } catch (e) {
2433
+ return await this.#handleApiError(e);
2434
+ }
2435
+ }
2436
+ /**
2437
+ * Download patch file content from Socket blob storage.
2438
+ * Retrieves patched file contents using SSRI hash or hex hash.
2439
+ *
2440
+ * This is a low-level utility method - you'll typically use this after calling
2441
+ * `viewPatch()` to get patch metadata, then download individual patched files.
2442
+ *
2443
+ * @param hash - The blob hash in SSRI (sha256-base64) or hex format
2444
+ * @param options - Optional configuration
2445
+ * @param options.baseUrl - Override blob store URL (for testing)
2446
+ * @returns Promise<string> - The patch file content as UTF-8 string
2447
+ * @throws Error if blob not found (404) or download fails
2448
+ *
2449
+ * @example
2450
+ * ```typescript
2451
+ * const sdk = new SocketSdk('your-api-token')
2452
+ * // First get patch metadata
2453
+ * const patch = await sdk.viewPatch('my-org', 'patch-uuid')
2454
+ * // Then download the actual patched file
2455
+ * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
2456
+ * ```
2457
+ */
2458
+ async downloadPatch(hash, options) {
2459
+ const https2 = await import("node:https");
2460
+ const http2 = await import("node:http");
2461
+ const blobPath = `/blob/${encodeURIComponent(hash)}`;
2462
+ const blobBaseUrl = options?.baseUrl || SOCKET_PUBLIC_BLOB_STORE_URL;
2463
+ const url = `${blobBaseUrl}${blobPath}`;
2464
+ const isHttps = url.startsWith("https:");
2465
+ return await new Promise((resolve, reject) => {
2466
+ const client = isHttps ? https2 : http2;
2467
+ client.get(url, (res) => {
2468
+ if (res.statusCode === 404) {
2469
+ const message = [
2470
+ `Blob not found: ${hash}`,
2471
+ `\u2192 URL: ${url}`,
2472
+ "\u2192 The patch file may have expired or the hash is incorrect.",
2473
+ "\u2192 Verify: The blob hash is correct.",
2474
+ "\u2192 Note: Blob URLs may expire after a certain time period."
2475
+ ].join("\n");
2476
+ reject(new Error(message));
2477
+ return;
2478
+ }
2479
+ if (res.statusCode !== 200) {
2480
+ const message = [
2481
+ `Failed to download blob: ${res.statusCode} ${res.statusMessage}`,
2482
+ `\u2192 Hash: ${hash}`,
2483
+ `\u2192 URL: ${url}`,
2484
+ "\u2192 The blob storage service may be temporarily unavailable.",
2485
+ res.statusCode && res.statusCode >= 500 ? "\u2192 Try: Retry the download after a short delay." : "\u2192 Verify: The blob hash and URL are correct."
2486
+ ].join("\n");
2487
+ reject(new Error(message));
2488
+ return;
2489
+ }
2490
+ let data = "";
2491
+ let bytesRead = 0;
2492
+ const MAX_PATCH_SIZE = 50 * 1024 * 1024;
2493
+ res.on("data", (chunk) => {
2494
+ if (bytesRead + chunk.length > MAX_PATCH_SIZE) {
2495
+ const error = new Error(
2496
+ [
2497
+ `Patch file exceeds maximum size of ${MAX_PATCH_SIZE} bytes`,
2498
+ `\u2192 Current size: ${bytesRead + chunk.length} bytes`,
2499
+ "\u2192 This may indicate an incorrect hash or corrupted blob."
2500
+ ].join("\n")
2501
+ );
2502
+ res.destroy(error);
2503
+ reject(error);
2504
+ return;
2505
+ }
2506
+ bytesRead += chunk.length;
2507
+ data += chunk.toString("utf8");
2508
+ });
2509
+ res.on("end", () => {
2510
+ resolve(data);
2511
+ });
2512
+ res.on("error", (err) => {
2513
+ reject(err);
2514
+ });
2515
+ }).on("error", (err) => {
2516
+ const nodeErr = err;
2517
+ const message = [
2518
+ `Error downloading blob: ${hash}`,
2519
+ `\u2192 URL: ${url}`,
2520
+ `\u2192 Network error: ${nodeErr.message}`
2521
+ ];
2522
+ if (nodeErr.code === "ENOTFOUND") {
2523
+ message.push(
2524
+ "\u2192 DNS lookup failed. Cannot resolve blob storage hostname.",
2525
+ "\u2192 Check: Internet connection and DNS settings."
2526
+ );
2527
+ } else if (nodeErr.code === "ECONNREFUSED") {
2528
+ message.push(
2529
+ "\u2192 Connection refused. Blob storage service is unreachable.",
2530
+ "\u2192 Check: Network connectivity and firewall settings."
2531
+ );
2532
+ } else if (nodeErr.code === "ETIMEDOUT") {
2533
+ message.push(
2534
+ "\u2192 Connection timed out.",
2535
+ "\u2192 Try: Check network connectivity and retry."
2536
+ );
2537
+ } else if (nodeErr.code) {
2538
+ message.push(`\u2192 Error code: ${nodeErr.code}`);
2539
+ }
2540
+ reject(new Error(message.join("\n"), { cause: err }));
2541
+ });
2542
+ });
2543
+ }
2189
2544
  /**
2190
2545
  * Export scan results in CycloneDX SBOM format.
2191
2546
  * Returns Software Bill of Materials compliant with CycloneDX standard.
@@ -2208,6 +2563,51 @@ var SocketSdk = class {
2208
2563
  return await this.#handleApiError(e);
2209
2564
  }
2210
2565
  }
2566
+ /**
2567
+ * Export vulnerability exploitability data as an OpenVEX v0.2.0 document.
2568
+ * Includes patch data and reachability analysis for vulnerability assessment.
2569
+ *
2570
+ * @param orgSlug - Organization identifier
2571
+ * @param id - Full scan or SBOM report ID
2572
+ * @param options - Optional parameters including author, role, and document_id
2573
+ * @returns OpenVEX document with vulnerability exploitability information
2574
+ *
2575
+ * @example
2576
+ * ```typescript
2577
+ * const result = await sdk.exportOpenVEX('my-org', 'scan-id', {
2578
+ * author: 'Security Team',
2579
+ * role: 'VEX Generator'
2580
+ * })
2581
+ *
2582
+ * if (result.success) {
2583
+ * console.log('VEX Version:', result.data.version)
2584
+ * console.log('Statements:', result.data.statements.length)
2585
+ * }
2586
+ * ```
2587
+ *
2588
+ * @see https://docs.socket.dev/reference/exportopenvex
2589
+ * @apiEndpoint GET /orgs/{org_slug}/export/openvex/{id}
2590
+ * @quota 0 units
2591
+ * @scopes report:read
2592
+ * @throws {Error} When server returns 5xx status codes
2593
+ */
2594
+ async exportOpenVEX(orgSlug, id, options) {
2595
+ const queryString = options ? `?${queryToSearchParams(options)}` : "";
2596
+ try {
2597
+ const data = await this.#executeWithRetry(
2598
+ async () => await getResponseJson(
2599
+ await createGetRequest(
2600
+ this.#baseUrl,
2601
+ `orgs/${encodeURIComponent(orgSlug)}/export/openvex/${encodeURIComponent(id)}${queryString}`,
2602
+ { ...this.#reqOptions, hooks: this.#hooks }
2603
+ )
2604
+ )
2605
+ );
2606
+ return this.#handleApiSuccess(data);
2607
+ } catch (e) {
2608
+ return await this.#handleApiError(e);
2609
+ }
2610
+ }
2211
2611
  /**
2212
2612
  * Export scan results in SPDX SBOM format.
2213
2613
  * Returns Software Bill of Materials compliant with SPDX standard.
@@ -2242,6 +2642,7 @@ var SocketSdk = class {
2242
2642
  __proto__: null,
2243
2643
  ...options
2244
2644
  };
2645
+ const url = `${this.#baseUrl}${urlPath}`;
2245
2646
  try {
2246
2647
  const response = await createGetRequest(this.#baseUrl, urlPath, {
2247
2648
  ...this.#reqOptions,
@@ -2249,17 +2650,18 @@ var SocketSdk = class {
2249
2650
  });
2250
2651
  if (!isResponseOk(response)) {
2251
2652
  if (throws) {
2252
- throw new ResponseError(response);
2653
+ throw new ResponseError(response, "", url);
2253
2654
  }
2254
2655
  const errorResult = await this.#handleApiError(
2255
- new ResponseError(response)
2656
+ new ResponseError(response, "", url)
2256
2657
  );
2257
2658
  return {
2258
2659
  cause: errorResult.cause,
2259
2660
  data: void 0,
2260
2661
  error: errorResult.error,
2261
2662
  status: errorResult.status,
2262
- success: false
2663
+ success: false,
2664
+ url: errorResult.url
2263
2665
  };
2264
2666
  }
2265
2667
  const data = await this.#handleQueryResponseData(
@@ -2361,81 +2763,38 @@ var SocketSdk = class {
2361
2763
  }
2362
2764
  }
2363
2765
  /**
2364
- * Retrieve the enabled entitlements for an organization.
2766
+ * Get GitHub-flavored markdown comments for a diff scan.
2767
+ * Returns dependency overview and alert comments suitable for pull requests.
2365
2768
  *
2366
- * This method fetches the organization's entitlements and filters for only* the enabled ones, returning their keys. Entitlements represent Socket
2367
- * Products that the organization has access to use.
2368
- */
2369
- async getEnabledEntitlements(orgSlug) {
2370
- const data = await this.#executeWithRetry(
2371
- async () => await getResponseJson(
2372
- await createGetRequest(
2373
- this.#baseUrl,
2374
- `orgs/${encodeURIComponent(orgSlug)}/entitlements`,
2375
- { ...this.#reqOptions, hooks: this.#hooks }
2376
- )
2377
- )
2378
- );
2379
- const items = data?.items || [];
2380
- return items.filter((item) => item && item.enabled === true && item.key).map((item) => item.key);
2381
- }
2382
- /**
2383
- * Retrieve all entitlements for an organization.
2769
+ * @param orgSlug - Organization identifier
2770
+ * @param diffScanId - Diff scan identifier
2771
+ * @param options - Optional query parameters
2772
+ * @param options.github_installation_id - GitHub installation ID for settings
2773
+ * @returns Diff scan metadata with formatted markdown comments
2384
2774
  *
2385
- * This method fetches all entitlements (both enabled and disabled) for
2386
- * an organization, returning the complete list with their status.
2387
- */
2388
- async getEntitlements(orgSlug) {
2389
- const data = await this.#executeWithRetry(
2390
- async () => await getResponseJson(
2391
- await createGetRequest(
2392
- this.#baseUrl,
2393
- `orgs/${encodeURIComponent(orgSlug)}/entitlements`,
2394
- { ...this.#reqOptions, hooks: this.#hooks }
2395
- )
2396
- )
2397
- );
2398
- return data?.items || [];
2399
- }
2400
- /**
2401
- * Get security issues for a specific npm package and version.
2402
- * Returns detailed vulnerability and security alert information.
2403
- *
2404
- * @throws {Error} When server returns 5xx status codes
2405
- */
2406
- async getIssuesByNpmPackage(pkgName, version) {
2407
- try {
2408
- const data = await this.#executeWithRetry(
2409
- async () => await getResponseJson(
2410
- await createGetRequest(
2411
- this.#baseUrl,
2412
- `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/issues`,
2413
- { ...this.#reqOptions, hooks: this.#hooks }
2414
- )
2415
- )
2416
- );
2417
- return this.#handleApiSuccess(data);
2418
- } catch (e) {
2419
- return await this.#handleApiError(e);
2420
- }
2421
- }
2422
- /**
2423
- * List latest alerts for an organization (Beta).
2424
- * Returns paginated alerts with comprehensive filtering options.
2775
+ * @example
2776
+ * ```typescript
2777
+ * const result = await sdk.getDiffScanGfm('my-org', 'diff-scan-id')
2425
2778
  *
2426
- * @param orgSlug - Organization identifier
2427
- * @param options - Optional query parameters for pagination and filtering
2428
- * @returns Paginated list of alerts with cursor-based pagination
2779
+ * if (result.success) {
2780
+ * console.log(result.data.dependency_overview_comment)
2781
+ * console.log(result.data.dependency_alert_comment)
2782
+ * }
2783
+ * ```
2429
2784
  *
2785
+ * @see https://docs.socket.dev/reference/getdiffscangfm
2786
+ * @apiEndpoint GET /orgs/{org_slug}/diff-scans/{diff_scan_id}/gfm
2787
+ * @quota 0 units
2788
+ * @scopes diff-scans:list
2430
2789
  * @throws {Error} When server returns 5xx status codes
2431
2790
  */
2432
- async getOrgAlertsList(orgSlug, options) {
2791
+ async getDiffScanGfm(orgSlug, diffScanId, options) {
2433
2792
  try {
2434
2793
  const data = await this.#executeWithRetry(
2435
2794
  async () => await getResponseJson(
2436
2795
  await createGetRequest(
2437
2796
  this.#baseUrl,
2438
- `orgs/${encodeURIComponent(orgSlug)}/alerts?${queryToSearchParams(options)}`,
2797
+ `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}/gfm${options ? `?${queryToSearchParams(options)}` : ""}`,
2439
2798
  { ...this.#reqOptions, hooks: this.#hooks }
2440
2799
  )
2441
2800
  )
@@ -2446,79 +2805,41 @@ var SocketSdk = class {
2446
2805
  }
2447
2806
  }
2448
2807
  /**
2449
- * Get analytics data for organization usage patterns and security metrics.
2450
- * Returns statistical analysis for specified time period.
2808
+ * Retrieve the enabled entitlements for an organization.
2451
2809
  *
2452
- * @throws {Error} When server returns 5xx status codes
2810
+ * This method fetches the organization's entitlements and filters for only* the enabled ones, returning their keys. Entitlements represent Socket
2811
+ * Products that the organization has access to use.
2453
2812
  */
2454
- async getOrgAnalytics(time) {
2455
- try {
2456
- const data = await this.#executeWithRetry(
2457
- async () => await getResponseJson(
2458
- await createGetRequest(
2459
- this.#baseUrl,
2460
- `analytics/org/${encodeURIComponent(time)}`,
2461
- { ...this.#reqOptions, hooks: this.#hooks }
2462
- )
2813
+ async getEnabledEntitlements(orgSlug) {
2814
+ const data = await this.#executeWithRetry(
2815
+ async () => await getResponseJson(
2816
+ await createGetRequest(
2817
+ this.#baseUrl,
2818
+ `orgs/${encodeURIComponent(orgSlug)}/entitlements`,
2819
+ { ...this.#reqOptions, hooks: this.#hooks }
2463
2820
  )
2464
- );
2465
- return this.#handleApiSuccess(data);
2466
- } catch (e) {
2467
- return await this.#handleApiError(e);
2468
- }
2821
+ )
2822
+ );
2823
+ const items = data?.items || [];
2824
+ return items.filter((item) => item && item.enabled === true && item.key).map((item) => item.key);
2469
2825
  }
2470
2826
  /**
2471
- * List all organizations accessible to the current user.
2472
- *
2473
- * Returns organization details and access permissions with guaranteed required fields.
2474
- *
2475
- * @returns List of organizations with metadata
2476
- *
2477
- * @example
2478
- * ```typescript
2479
- * const result = await sdk.listOrganizations()
2480
- *
2481
- * if (result.success) {
2482
- * result.data.organizations.forEach(org => {
2483
- * console.log(org.name, org.slug) // Guaranteed fields
2484
- * })
2485
- * }
2486
- * ```
2827
+ * Retrieve all entitlements for an organization.
2487
2828
  *
2488
- * @see https://docs.socket.dev/reference/getorganizations
2489
- * @apiEndpoint GET /organizations
2490
- * @quota 1 unit
2491
- * @throws {Error} When server returns 5xx status codes
2829
+ * This method fetches all entitlements (both enabled and disabled) for
2830
+ * an organization, returning the complete list with their status.
2492
2831
  */
2493
- async listOrganizations() {
2494
- try {
2495
- const data = await this.#getCached(
2496
- "organizations",
2497
- async () => await getResponseJson(
2498
- await createGetRequest(this.#baseUrl, "organizations", {
2499
- ...this.#reqOptions,
2500
- hooks: this.#hooks
2501
- })
2502
- ),
2503
- "organizations"
2504
- );
2505
- return {
2506
- cause: void 0,
2507
- data,
2508
- error: void 0,
2509
- status: 200,
2510
- success: true
2511
- };
2512
- } catch (e) {
2513
- const errorResult = await this.#handleApiError(e);
2514
- return {
2515
- cause: errorResult.cause,
2516
- data: void 0,
2517
- error: errorResult.error,
2518
- status: errorResult.status,
2519
- success: false
2520
- };
2521
- }
2832
+ async getEntitlements(orgSlug) {
2833
+ const data = await this.#executeWithRetry(
2834
+ async () => await getResponseJson(
2835
+ await createGetRequest(
2836
+ this.#baseUrl,
2837
+ `orgs/${encodeURIComponent(orgSlug)}/entitlements`,
2838
+ { ...this.#reqOptions, hooks: this.#hooks }
2839
+ )
2840
+ )
2841
+ );
2842
+ return data?.items || [];
2522
2843
  }
2523
2844
  /**
2524
2845
  * Get complete full scan results buffered in memory.
@@ -2542,7 +2863,7 @@ var SocketSdk = class {
2542
2863
  *
2543
2864
  * @see https://docs.socket.dev/reference/getorgfullscan
2544
2865
  * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
2545
- * @quota 1 unit
2866
+ * @quota 0 units
2546
2867
  * @scopes full-scans:list
2547
2868
  * @throws {Error} When server returns 5xx status codes
2548
2869
  */
@@ -2576,43 +2897,38 @@ var SocketSdk = class {
2576
2897
  }
2577
2898
  }
2578
2899
  /**
2579
- * List all full scans for an organization.
2900
+ * Get metadata for a specific full scan.
2580
2901
  *
2581
- * Returns paginated list of full scan metadata with guaranteed required fields
2582
- * for improved TypeScript autocomplete.
2902
+ * Returns scan configuration, status, and summary information without full artifact data.
2903
+ * Useful for checking scan status without downloading complete results.
2583
2904
  *
2584
2905
  * @param orgSlug - Organization identifier
2585
- * @param options - Filtering and pagination options
2586
- * @returns List of full scans with metadata
2906
+ * @param scanId - Full scan identifier
2907
+ * @returns Scan metadata including status and configuration
2587
2908
  *
2588
2909
  * @example
2589
2910
  * ```typescript
2590
- * const result = await sdk.listFullScans('my-org', {
2591
- * branch: 'main',
2592
- * per_page: 50,
2593
- * use_cursor: true
2594
- * })
2911
+ * const result = await sdk.getFullScanMetadata('my-org', 'scan_123')
2595
2912
  *
2596
2913
  * if (result.success) {
2597
- * result.data.results.forEach(scan => {
2598
- * console.log(scan.id, scan.created_at) // Guaranteed fields
2599
- * })
2914
+ * console.log('Scan state:', result.data.scan_state)
2915
+ * console.log('Branch:', result.data.branch)
2600
2916
  * }
2601
2917
  * ```
2602
2918
  *
2603
- * @see https://docs.socket.dev/reference/getorgfullscanlist
2604
- * @apiEndpoint GET /orgs/{org_slug}/full-scans
2605
- * @quota 1 unit
2919
+ * @see https://docs.socket.dev/reference/getorgfullscanmetadata
2920
+ * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}/metadata
2921
+ * @quota 0 units
2606
2922
  * @scopes full-scans:list
2607
2923
  * @throws {Error} When server returns 5xx status codes
2608
2924
  */
2609
- async listFullScans(orgSlug, options) {
2925
+ async getFullScanMetadata(orgSlug, scanId) {
2610
2926
  try {
2611
2927
  const data = await this.#executeWithRetry(
2612
2928
  async () => await getResponseJson(
2613
2929
  await createGetRequest(
2614
2930
  this.#baseUrl,
2615
- `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(options)}`,
2931
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}/metadata`,
2616
2932
  { ...this.#reqOptions, hooks: this.#hooks }
2617
2933
  )
2618
2934
  )
@@ -2636,77 +2952,89 @@ var SocketSdk = class {
2636
2952
  }
2637
2953
  }
2638
2954
  /**
2639
- * Get metadata for a specific full scan.
2955
+ * Get security issues for a specific npm package and version.
2956
+ * Returns detailed vulnerability and security alert information.
2640
2957
  *
2641
- * Returns scan configuration, status, and summary information without full artifact data.
2642
- * Useful for checking scan status without downloading complete results.
2958
+ * @throws {Error} When server returns 5xx status codes
2959
+ */
2960
+ async getIssuesByNpmPackage(pkgName, version) {
2961
+ try {
2962
+ const data = await this.#executeWithRetry(
2963
+ async () => await getResponseJson(
2964
+ await createGetRequest(
2965
+ this.#baseUrl,
2966
+ `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/issues`,
2967
+ { ...this.#reqOptions, hooks: this.#hooks }
2968
+ )
2969
+ )
2970
+ );
2971
+ return this.#handleApiSuccess(data);
2972
+ } catch (e) {
2973
+ return await this.#handleApiError(e);
2974
+ }
2975
+ }
2976
+ /**
2977
+ * List full scans associated with a specific alert.
2978
+ * Returns paginated full scan references for alert investigation.
2643
2979
  *
2644
2980
  * @param orgSlug - Organization identifier
2645
- * @param scanId - Full scan identifier
2646
- * @returns Scan metadata including status and configuration
2981
+ * @param options - Query parameters including alertKey, range, pagination
2982
+ * @returns Paginated array of full scans associated with the alert
2647
2983
  *
2648
2984
  * @example
2649
2985
  * ```typescript
2650
- * const result = await sdk.getFullScanMetadata('my-org', 'scan_123')
2986
+ * const result = await sdk.getOrgAlertFullScans('my-org', {
2987
+ * alertKey: 'npm/lodash/cve-2021-23337',
2988
+ * range: '-7d',
2989
+ * per_page: 50
2990
+ * })
2651
2991
  *
2652
2992
  * if (result.success) {
2653
- * console.log('Scan state:', result.data.scan_state)
2654
- * console.log('Branch:', result.data.branch)
2993
+ * for (const item of result.data.items) {
2994
+ * console.log('Full Scan ID:', item.fullScanId)
2995
+ * }
2655
2996
  * }
2656
2997
  * ```
2657
2998
  *
2658
- * @see https://docs.socket.dev/reference/getorgfullscanmetadata
2659
- * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}/metadata
2660
- * @quota 1 unit
2661
- * @scopes full-scans:list
2999
+ * @see https://docs.socket.dev/reference/alertfullscans
3000
+ * @apiEndpoint GET /orgs/{org_slug}/alert-full-scan-search
3001
+ * @quota 10 units
3002
+ * @scopes alerts:list
2662
3003
  * @throws {Error} When server returns 5xx status codes
2663
3004
  */
2664
- async getFullScanMetadata(orgSlug, scanId) {
3005
+ async getOrgAlertFullScans(orgSlug, options) {
2665
3006
  try {
2666
3007
  const data = await this.#executeWithRetry(
2667
3008
  async () => await getResponseJson(
2668
3009
  await createGetRequest(
2669
3010
  this.#baseUrl,
2670
- `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}/metadata`,
3011
+ `orgs/${encodeURIComponent(orgSlug)}/alert-full-scan-search?${queryToSearchParams(options)}`,
2671
3012
  { ...this.#reqOptions, hooks: this.#hooks }
2672
3013
  )
2673
3014
  )
2674
3015
  );
2675
- return {
2676
- cause: void 0,
2677
- data,
2678
- error: void 0,
2679
- status: 200,
2680
- success: true
2681
- };
3016
+ return this.#handleApiSuccess(data);
2682
3017
  } catch (e) {
2683
- const errorResult = await this.#handleApiError(e);
2684
- return {
2685
- cause: errorResult.cause,
2686
- data: void 0,
2687
- error: errorResult.error,
2688
- status: errorResult.status,
2689
- success: false
2690
- };
3018
+ return await this.#handleApiError(e);
2691
3019
  }
2692
3020
  }
2693
3021
  /**
2694
- * Fetch available fixes for vulnerabilities in a repository or scan.
2695
- * Returns fix recommendations including version upgrades and update types.
3022
+ * List latest alerts for an organization (Beta).
3023
+ * Returns paginated alerts with comprehensive filtering options.
2696
3024
  *
2697
3025
  * @param orgSlug - Organization identifier
2698
- * @param options - Fix query options including repo_slug or full_scan_id, vulnerability IDs, and preferences
2699
- * @returns Fix details for requested vulnerabilities with upgrade recommendations
3026
+ * @param options - Optional query parameters for pagination and filtering
3027
+ * @returns Paginated list of alerts with cursor-based pagination
2700
3028
  *
2701
3029
  * @throws {Error} When server returns 5xx status codes
2702
3030
  */
2703
- async getOrgFixes(orgSlug, options) {
3031
+ async getOrgAlertsList(orgSlug, options) {
2704
3032
  try {
2705
3033
  const data = await this.#executeWithRetry(
2706
3034
  async () => await getResponseJson(
2707
3035
  await createGetRequest(
2708
3036
  this.#baseUrl,
2709
- `orgs/${encodeURIComponent(orgSlug)}/fixes?${queryToSearchParams(options)}`,
3037
+ `orgs/${encodeURIComponent(orgSlug)}/alerts?${queryToSearchParams(options)}`,
2710
3038
  { ...this.#reqOptions, hooks: this.#hooks }
2711
3039
  )
2712
3040
  )
@@ -2717,17 +3045,18 @@ var SocketSdk = class {
2717
3045
  }
2718
3046
  }
2719
3047
  /**
2720
- * Get organization's license policy configuration.* Returns allowed, restricted, and monitored license types.
3048
+ * Get analytics data for organization usage patterns and security metrics.
3049
+ * Returns statistical analysis for specified time period.
2721
3050
  *
2722
3051
  * @throws {Error} When server returns 5xx status codes
2723
3052
  */
2724
- async getOrgLicensePolicy(orgSlug) {
3053
+ async getOrgAnalytics(time) {
2725
3054
  try {
2726
3055
  const data = await this.#executeWithRetry(
2727
3056
  async () => await getResponseJson(
2728
3057
  await createGetRequest(
2729
3058
  this.#baseUrl,
2730
- `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy`,
3059
+ `analytics/org/${encodeURIComponent(time)}`,
2731
3060
  { ...this.#reqOptions, hooks: this.#hooks }
2732
3061
  )
2733
3062
  )
@@ -2738,244 +3067,89 @@ var SocketSdk = class {
2738
3067
  }
2739
3068
  }
2740
3069
  /**
2741
- * Get details for a specific repository.
2742
- *
2743
- * Returns repository configuration, monitoring status, and metadata.
3070
+ * Fetch available fixes for vulnerabilities in a repository or scan.
3071
+ * Returns fix recommendations including version upgrades and update types.
2744
3072
  *
2745
3073
  * @param orgSlug - Organization identifier
2746
- * @param repoSlug - Repository slug/name
2747
- * @returns Repository details with configuration
2748
- *
2749
- * @example
2750
- * ```typescript
2751
- * const result = await sdk.getRepository('my-org', 'my-repo')
2752
- *
2753
- * if (result.success) {
2754
- * console.log('Repository:', result.data.name)
2755
- * console.log('Visibility:', result.data.visibility)
2756
- * console.log('Default branch:', result.data.default_branch)
2757
- * }
2758
- * ```
3074
+ * @param options - Fix query options including repo_slug or full_scan_id, vulnerability IDs, and preferences
3075
+ * @returns Fix details for requested vulnerabilities with upgrade recommendations
2759
3076
  *
2760
- * @see https://docs.socket.dev/reference/getorgrepo
2761
- * @apiEndpoint GET /orgs/{org_slug}/repos/{repo_slug}
2762
- * @quota 1 unit
2763
- * @scopes repo:read
2764
3077
  * @throws {Error} When server returns 5xx status codes
2765
3078
  */
2766
- async getRepository(orgSlug, repoSlug) {
2767
- const orgSlugParam = encodeURIComponent(orgSlug);
2768
- const repoSlugParam = encodeURIComponent(repoSlug);
3079
+ async getOrgFixes(orgSlug, options) {
2769
3080
  try {
2770
3081
  const data = await this.#executeWithRetry(
2771
3082
  async () => await getResponseJson(
2772
3083
  await createGetRequest(
2773
3084
  this.#baseUrl,
2774
- `orgs/${orgSlugParam}/repos/${repoSlugParam}`,
3085
+ `orgs/${encodeURIComponent(orgSlug)}/fixes?${queryToSearchParams(options)}`,
2775
3086
  { ...this.#reqOptions, hooks: this.#hooks }
2776
3087
  )
2777
3088
  )
2778
3089
  );
2779
- return {
2780
- cause: void 0,
2781
- data,
2782
- error: void 0,
2783
- status: 200,
2784
- success: true
2785
- };
3090
+ return this.#handleApiSuccess(data);
2786
3091
  } catch (e) {
2787
- const errorResult = await this.#handleApiError(e);
2788
- return {
2789
- cause: errorResult.cause,
2790
- data: void 0,
2791
- error: errorResult.error,
2792
- status: errorResult.status,
2793
- success: false
2794
- };
3092
+ return await this.#handleApiError(e);
2795
3093
  }
2796
3094
  }
2797
3095
  /**
2798
- * Get details for a specific repository label.
2799
- *
2800
- * Returns label configuration, associated repositories, and policy settings.
2801
- *
2802
- * @param orgSlug - Organization identifier
2803
- * @param labelId - Label identifier
2804
- * @returns Label details with guaranteed id and name fields
2805
- *
2806
- * @example
2807
- * ```typescript
2808
- * const result = await sdk.getRepositoryLabel('my-org', 'label-id-123')
2809
- *
2810
- * if (result.success) {
2811
- * console.log('Label name:', result.data.name)
2812
- * console.log('Associated repos:', result.data.repository_ids)
2813
- * console.log('Has security policy:', result.data.has_security_policy)
2814
- * }
2815
- * ```
3096
+ * Get organization's license policy configuration.* Returns allowed, restricted, and monitored license types.
2816
3097
  *
2817
- * @see https://docs.socket.dev/reference/getorgrepolabel
2818
- * @apiEndpoint GET /orgs/{org_slug}/repos/labels/{label_id}
2819
- * @quota 1 unit
2820
- * @scopes repo-label:list
2821
3098
  * @throws {Error} When server returns 5xx status codes
2822
3099
  */
2823
- async getRepositoryLabel(orgSlug, labelId) {
3100
+ async getOrgLicensePolicy(orgSlug) {
2824
3101
  try {
2825
3102
  const data = await this.#executeWithRetry(
2826
3103
  async () => await getResponseJson(
2827
3104
  await createGetRequest(
2828
3105
  this.#baseUrl,
2829
- `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
3106
+ `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy`,
2830
3107
  { ...this.#reqOptions, hooks: this.#hooks }
2831
3108
  )
2832
3109
  )
2833
3110
  );
2834
- return {
2835
- cause: void 0,
2836
- data,
2837
- error: void 0,
2838
- status: 200,
2839
- success: true
2840
- };
3111
+ return this.#handleApiSuccess(data);
2841
3112
  } catch (e) {
2842
- const errorResult = await this.#handleApiError(e);
2843
- return {
2844
- cause: errorResult.cause,
2845
- data: void 0,
2846
- error: errorResult.error,
2847
- status: errorResult.status,
2848
- success: false
2849
- };
3113
+ return await this.#handleApiError(e);
2850
3114
  }
2851
3115
  }
2852
3116
  /**
2853
- * List all repository labels for an organization.
2854
- *
2855
- * Returns paginated list of labels configured for repository organization and policy management.
2856
- *
2857
- * @param orgSlug - Organization identifier
2858
- * @param options - Pagination options
2859
- * @returns List of labels with guaranteed id and name fields
2860
- *
2861
- * @example
2862
- * ```typescript
2863
- * const result = await sdk.listRepositoryLabels('my-org', { per_page: 50, page: 1 })
2864
- *
2865
- * if (result.success) {
2866
- * result.data.results.forEach(label => {
2867
- * console.log('Label:', label.name)
2868
- * console.log('Associated repos:', label.repository_ids?.length || 0)
2869
- * })
2870
- * }
2871
- * ```
3117
+ * Get organization's security policy configuration.* Returns alert rules, severity thresholds, and enforcement settings.
2872
3118
  *
2873
- * @see https://docs.socket.dev/reference/getorgrepolabellist
2874
- * @apiEndpoint GET /orgs/{org_slug}/repos/labels
2875
- * @quota 1 unit
2876
- * @scopes repo-label:list
2877
3119
  * @throws {Error} When server returns 5xx status codes
2878
3120
  */
2879
- async listRepositoryLabels(orgSlug, options) {
3121
+ async getOrgSecurityPolicy(orgSlug) {
2880
3122
  try {
2881
3123
  const data = await this.#executeWithRetry(
2882
3124
  async () => await getResponseJson(
2883
3125
  await createGetRequest(
2884
3126
  this.#baseUrl,
2885
- `orgs/${encodeURIComponent(orgSlug)}/repos/labels?${queryToSearchParams(options)}`,
3127
+ `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
2886
3128
  { ...this.#reqOptions, hooks: this.#hooks }
2887
3129
  )
2888
3130
  )
2889
3131
  );
2890
- return {
2891
- cause: void 0,
2892
- data,
2893
- error: void 0,
2894
- status: 200,
2895
- success: true
2896
- };
3132
+ return this.#handleApiSuccess(data);
2897
3133
  } catch (e) {
2898
- const errorResult = await this.#handleApiError(e);
2899
- return {
2900
- cause: errorResult.cause,
2901
- data: void 0,
2902
- error: errorResult.error,
2903
- status: errorResult.status,
2904
- success: false
2905
- };
3134
+ return await this.#handleApiError(e);
2906
3135
  }
2907
3136
  }
2908
3137
  /**
2909
- * List all repositories in an organization.
2910
- *
2911
- * Returns paginated list of repository metadata with guaranteed required fields.
3138
+ * Get organization's telemetry configuration.
3139
+ * Returns whether telemetry is enabled for the organization.
2912
3140
  *
2913
3141
  * @param orgSlug - Organization identifier
2914
- * @param options - Pagination and filtering options
2915
- * @returns List of repositories with metadata
2916
- *
2917
- * @example
2918
- * ```typescript
2919
- * const result = await sdk.listRepositories('my-org', {
2920
- * per_page: 50,
2921
- * sort: 'name',
2922
- * direction: 'asc'
2923
- * })
2924
- *
2925
- * if (result.success) {
2926
- * result.data.results.forEach(repo => {
2927
- * console.log(repo.name, repo.visibility)
2928
- * })
2929
- * }
2930
- * ```
2931
- *
2932
- * @see https://docs.socket.dev/reference/getorgrepolist
2933
- * @apiEndpoint GET /orgs/{org_slug}/repos
2934
- * @quota 1 unit
2935
- * @scopes repo:list
2936
- * @throws {Error} When server returns 5xx status codes
2937
- */
2938
- async listRepositories(orgSlug, options) {
2939
- try {
2940
- const data = await this.#executeWithRetry(
2941
- async () => await getResponseJson(
2942
- await createGetRequest(
2943
- this.#baseUrl,
2944
- `orgs/${encodeURIComponent(orgSlug)}/repos?${queryToSearchParams(options)}`,
2945
- { ...this.#reqOptions, hooks: this.#hooks }
2946
- )
2947
- )
2948
- );
2949
- return {
2950
- cause: void 0,
2951
- data,
2952
- error: void 0,
2953
- status: 200,
2954
- success: true
2955
- };
2956
- } catch (e) {
2957
- const errorResult = await this.#handleApiError(e);
2958
- return {
2959
- cause: errorResult.cause,
2960
- data: void 0,
2961
- error: errorResult.error,
2962
- status: errorResult.status,
2963
- success: false
2964
- };
2965
- }
2966
- }
2967
- /**
2968
- * Get organization's security policy configuration.* Returns alert rules, severity thresholds, and enforcement settings.
3142
+ * @returns Telemetry configuration with enabled status
2969
3143
  *
2970
3144
  * @throws {Error} When server returns 5xx status codes
2971
3145
  */
2972
- async getOrgSecurityPolicy(orgSlug) {
3146
+ async getOrgTelemetryConfig(orgSlug) {
2973
3147
  try {
2974
3148
  const data = await this.#executeWithRetry(
2975
3149
  async () => await getResponseJson(
2976
3150
  await createGetRequest(
2977
3151
  this.#baseUrl,
2978
- `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
3152
+ `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
2979
3153
  { ...this.#reqOptions, hooks: this.#hooks }
2980
3154
  )
2981
3155
  )
@@ -3008,41 +3182,22 @@ var SocketSdk = class {
3008
3182
  }
3009
3183
  }
3010
3184
  /**
3011
- * Get current API quota usage and limits.
3012
- * Returns remaining requests, rate limits, and quota reset times.
3185
+ * Get details of a specific webhook.
3186
+ * Returns webhook configuration including events, URL, and filters.
3013
3187
  *
3014
- * @throws {Error} When server returns 5xx status codes
3015
- */
3016
- async getQuota() {
3017
- try {
3018
- const data = await this.#getCached(
3019
- "quota",
3020
- async () => await getResponseJson(
3021
- await createGetRequest(this.#baseUrl, "quota", {
3022
- ...this.#reqOptions,
3023
- hooks: this.#hooks
3024
- })
3025
- ),
3026
- "quota"
3027
- );
3028
- return this.#handleApiSuccess(data);
3029
- } catch (e) {
3030
- return await this.#handleApiError(e);
3031
- }
3032
- }
3033
- /**
3034
- * Get analytics data for a specific repository.
3035
- * Returns security metrics, dependency trends, and vulnerability statistics.
3188
+ * @param orgSlug - Organization identifier
3189
+ * @param webhookId - Webhook ID to retrieve
3190
+ * @returns Webhook details
3036
3191
  *
3037
3192
  * @throws {Error} When server returns 5xx status codes
3038
3193
  */
3039
- async getRepoAnalytics(repo, time) {
3194
+ async getOrgWebhook(orgSlug, webhookId) {
3040
3195
  try {
3041
3196
  const data = await this.#executeWithRetry(
3042
3197
  async () => await getResponseJson(
3043
3198
  await createGetRequest(
3044
3199
  this.#baseUrl,
3045
- `analytics/repo/${encodeURIComponent(repo)}/${encodeURIComponent(time)}`,
3200
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
3046
3201
  { ...this.#reqOptions, hooks: this.#hooks }
3047
3202
  )
3048
3203
  )
@@ -3053,21 +3208,22 @@ var SocketSdk = class {
3053
3208
  }
3054
3209
  }
3055
3210
  /**
3056
- * Get detailed results for a legacy scan report.
3057
- /**
3058
- /**
3059
- * Get security score for a specific npm package and version.
3060
- * Returns numerical security rating and scoring breakdown.
3211
+ * List all webhooks for an organization.
3212
+ * Supports pagination and sorting options.
3213
+ *
3214
+ * @param orgSlug - Organization identifier
3215
+ * @param options - Optional query parameters for pagination and sorting
3216
+ * @returns List of webhooks with pagination info
3061
3217
  *
3062
3218
  * @throws {Error} When server returns 5xx status codes
3063
3219
  */
3064
- async getScoreByNpmPackage(pkgName, version) {
3220
+ async getOrgWebhooksList(orgSlug, options) {
3065
3221
  try {
3066
3222
  const data = await this.#executeWithRetry(
3067
3223
  async () => await getResponseJson(
3068
3224
  await createGetRequest(
3069
3225
  this.#baseUrl,
3070
- `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`,
3226
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks?${queryToSearchParams(options)}`,
3071
3227
  { ...this.#reqOptions, hooks: this.#hooks }
3072
3228
  )
3073
3229
  )
@@ -3078,20 +3234,22 @@ var SocketSdk = class {
3078
3234
  }
3079
3235
  }
3080
3236
  /**
3081
- * Get list of file types and formats supported for scanning.
3082
- * Returns supported manifest files, lockfiles, and configuration formats.
3237
+ * Get current API quota usage and limits.
3238
+ * Returns remaining requests, rate limits, and quota reset times.
3083
3239
  *
3084
3240
  * @throws {Error} When server returns 5xx status codes
3085
3241
  */
3086
- async getSupportedScanFiles() {
3242
+ async getQuota() {
3087
3243
  try {
3088
- const data = await this.#executeWithRetry(
3244
+ const data = await this.#getCached(
3245
+ "quota",
3089
3246
  async () => await getResponseJson(
3090
- await createGetRequest(this.#baseUrl, "report/supported", {
3247
+ await createGetRequest(this.#baseUrl, "quota", {
3091
3248
  ...this.#reqOptions,
3092
3249
  hooks: this.#hooks
3093
3250
  })
3094
- )
3251
+ ),
3252
+ "quota"
3095
3253
  );
3096
3254
  return this.#handleApiSuccess(data);
3097
3255
  } catch (e) {
@@ -3099,18 +3257,18 @@ var SocketSdk = class {
3099
3257
  }
3100
3258
  }
3101
3259
  /**
3102
- * List all diff scans for an organization.
3103
- * Returns paginated list of diff scan metadata and status.
3260
+ * Get analytics data for a specific repository.
3261
+ * Returns security metrics, dependency trends, and vulnerability statistics.
3104
3262
  *
3105
3263
  * @throws {Error} When server returns 5xx status codes
3106
3264
  */
3107
- async listOrgDiffScans(orgSlug) {
3265
+ async getRepoAnalytics(repo, time) {
3108
3266
  try {
3109
3267
  const data = await this.#executeWithRetry(
3110
3268
  async () => await getResponseJson(
3111
3269
  await createGetRequest(
3112
3270
  this.#baseUrl,
3113
- `orgs/${encodeURIComponent(orgSlug)}/diff-scans`,
3271
+ `analytics/repo/${encodeURIComponent(repo)}/${encodeURIComponent(time)}`,
3114
3272
  { ...this.#reqOptions, hooks: this.#hooks }
3115
3273
  )
3116
3274
  )
@@ -3121,68 +3279,140 @@ var SocketSdk = class {
3121
3279
  }
3122
3280
  }
3123
3281
  /**
3124
- * Create a new API token for an organization.
3125
- * Generates API token with specified scopes and metadata.
3126
- *
3127
- * @throws {Error} When server returns 5xx status codes
3128
- */
3129
- async postAPIToken(orgSlug, tokenData) {
3282
+ * Get detailed results for a legacy scan report.
3283
+ /**
3284
+
3285
+ /**
3286
+ * Get details for a specific repository.
3287
+ *
3288
+ * Returns repository configuration, monitoring status, and metadata.
3289
+ *
3290
+ * @param orgSlug - Organization identifier
3291
+ * @param repoSlug - Repository slug/name
3292
+ * @param options - Optional parameters including workspace
3293
+ * @returns Repository details with configuration
3294
+ *
3295
+ * @example
3296
+ * ```typescript
3297
+ * const result = await sdk.getRepository('my-org', 'my-repo')
3298
+ *
3299
+ * if (result.success) {
3300
+ * console.log('Repository:', result.data.name)
3301
+ * console.log('Visibility:', result.data.visibility)
3302
+ * console.log('Default branch:', result.data.default_branch)
3303
+ * }
3304
+ * ```
3305
+ *
3306
+ * @see https://docs.socket.dev/reference/getorgrepo
3307
+ * @apiEndpoint GET /orgs/{org_slug}/repos/{repo_slug}
3308
+ * @quota 0 units
3309
+ * @scopes repo:read
3310
+ * @throws {Error} When server returns 5xx status codes
3311
+ */
3312
+ async getRepository(orgSlug, repoSlug, options) {
3313
+ const orgSlugParam = encodeURIComponent(orgSlug);
3314
+ const repoSlugParam = encodeURIComponent(repoSlug);
3315
+ const { workspace } = {
3316
+ __proto__: null,
3317
+ ...options
3318
+ };
3319
+ const queryString = workspace ? `?${queryToSearchParams({ workspace })}` : "";
3130
3320
  try {
3131
3321
  const data = await this.#executeWithRetry(
3132
3322
  async () => await getResponseJson(
3133
- await createRequestWithJson(
3134
- "POST",
3323
+ await createGetRequest(
3135
3324
  this.#baseUrl,
3136
- `orgs/${encodeURIComponent(orgSlug)}/tokens`,
3137
- tokenData,
3325
+ `orgs/${orgSlugParam}/repos/${repoSlugParam}${queryString}`,
3138
3326
  { ...this.#reqOptions, hooks: this.#hooks }
3139
3327
  )
3140
3328
  )
3141
3329
  );
3142
- return this.#handleApiSuccess(data);
3143
- } catch (e) {
3144
- return await this.#handleApiError(e);
3330
+ return {
3331
+ cause: void 0,
3332
+ data,
3333
+ error: void 0,
3334
+ status: 200,
3335
+ success: true
3336
+ };
3337
+ } catch (e) {
3338
+ const errorResult = await this.#handleApiError(e);
3339
+ return {
3340
+ cause: errorResult.cause,
3341
+ data: void 0,
3342
+ error: errorResult.error,
3343
+ status: errorResult.status,
3344
+ success: false
3345
+ };
3145
3346
  }
3146
3347
  }
3147
3348
  /**
3148
- * Revoke an API token for an organization.
3149
- * Permanently disables the token and removes access.
3349
+ * Get details for a specific repository label.
3350
+ *
3351
+ * Returns label configuration, associated repositories, and policy settings.
3352
+ *
3353
+ * @param orgSlug - Organization identifier
3354
+ * @param labelId - Label identifier
3355
+ * @returns Label details with guaranteed id and name fields
3356
+ *
3357
+ * @example
3358
+ * ```typescript
3359
+ * const result = await sdk.getRepositoryLabel('my-org', 'label-id-123')
3360
+ *
3361
+ * if (result.success) {
3362
+ * console.log('Label name:', result.data.name)
3363
+ * console.log('Associated repos:', result.data.repository_ids)
3364
+ * console.log('Has security policy:', result.data.has_security_policy)
3365
+ * }
3366
+ * ```
3150
3367
  *
3368
+ * @see https://docs.socket.dev/reference/getorgrepolabel
3369
+ * @apiEndpoint GET /orgs/{org_slug}/repos/labels/{label_id}
3370
+ * @quota 0 units
3371
+ * @scopes repo-label:list
3151
3372
  * @throws {Error} When server returns 5xx status codes
3152
3373
  */
3153
- async postAPITokensRevoke(orgSlug, tokenId) {
3374
+ async getRepositoryLabel(orgSlug, labelId) {
3154
3375
  try {
3155
3376
  const data = await this.#executeWithRetry(
3156
3377
  async () => await getResponseJson(
3157
- await createRequestWithJson(
3158
- "POST",
3378
+ await createGetRequest(
3159
3379
  this.#baseUrl,
3160
- `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/revoke`,
3161
- {},
3380
+ `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
3162
3381
  { ...this.#reqOptions, hooks: this.#hooks }
3163
3382
  )
3164
3383
  )
3165
3384
  );
3166
- return this.#handleApiSuccess(data);
3385
+ return {
3386
+ cause: void 0,
3387
+ data,
3388
+ error: void 0,
3389
+ status: 200,
3390
+ success: true
3391
+ };
3167
3392
  } catch (e) {
3168
- return await this.#handleApiError(e);
3393
+ const errorResult = await this.#handleApiError(e);
3394
+ return {
3395
+ cause: errorResult.cause,
3396
+ data: void 0,
3397
+ error: errorResult.error,
3398
+ status: errorResult.status,
3399
+ success: false
3400
+ };
3169
3401
  }
3170
3402
  }
3171
3403
  /**
3172
- * Rotate an API token for an organization.
3173
- * Generates new token value while preserving token metadata.
3404
+ * Get security score for a specific npm package and version.
3405
+ * Returns numerical security rating and scoring breakdown.
3174
3406
  *
3175
3407
  * @throws {Error} When server returns 5xx status codes
3176
3408
  */
3177
- async postAPITokensRotate(orgSlug, tokenId) {
3409
+ async getScoreByNpmPackage(pkgName, version) {
3178
3410
  try {
3179
3411
  const data = await this.#executeWithRetry(
3180
3412
  async () => await getResponseJson(
3181
- await createRequestWithJson(
3182
- "POST",
3413
+ await createGetRequest(
3183
3414
  this.#baseUrl,
3184
- `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/rotate`,
3185
- {},
3415
+ `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`,
3186
3416
  { ...this.#reqOptions, hooks: this.#hooks }
3187
3417
  )
3188
3418
  )
@@ -3193,21 +3423,42 @@ var SocketSdk = class {
3193
3423
  }
3194
3424
  }
3195
3425
  /**
3196
- * Update an existing API token for an organization.
3197
- * Modifies token metadata, scopes, or other properties.
3426
+ * Get list of supported file types for full scan generation.
3427
+ * Returns glob patterns for supported manifest files, lockfiles, and configuration formats.
3428
+ *
3429
+ * Files whose names match the patterns returned by this endpoint can be uploaded
3430
+ * for report generation. Examples include `package.json`, `package-lock.json`, and `yarn.lock`.
3431
+ *
3432
+ * @param orgSlug - Organization identifier
3433
+ * @returns Nested object with environment and file type patterns
3434
+ *
3435
+ * @example
3436
+ * ```typescript
3437
+ * const result = await sdk.getSupportedFiles('my-org')
3438
+ *
3439
+ * if (result.success) {
3440
+ * console.log('NPM patterns:', result.data.NPM)
3441
+ * console.log('PyPI patterns:', result.data.PyPI)
3442
+ * }
3443
+ * ```
3198
3444
  *
3445
+ * @see https://docs.socket.dev/reference/getsupportedfiles
3446
+ * @apiEndpoint GET /orgs/{org_slug}/supported-files
3447
+ * @quota 0 units
3448
+ * @scopes No scopes required, but authentication is required
3199
3449
  * @throws {Error} When server returns 5xx status codes
3200
3450
  */
3201
- async postAPITokenUpdate(orgSlug, tokenId, updateData) {
3451
+ async getSupportedFiles(orgSlug) {
3202
3452
  try {
3203
3453
  const data = await this.#executeWithRetry(
3204
3454
  async () => await getResponseJson(
3205
- await createRequestWithJson(
3206
- "POST",
3455
+ await createGetRequest(
3207
3456
  this.#baseUrl,
3208
- `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/update`,
3209
- updateData,
3210
- { ...this.#reqOptions, hooks: this.#hooks }
3457
+ `orgs/${encodeURIComponent(orgSlug)}/supported-files`,
3458
+ {
3459
+ ...this.#reqOptions,
3460
+ hooks: this.#hooks
3461
+ }
3211
3462
  )
3212
3463
  )
3213
3464
  );
@@ -3217,22 +3468,21 @@ var SocketSdk = class {
3217
3468
  }
3218
3469
  }
3219
3470
  /**
3220
- * Update user or organization settings.
3221
- * Configures preferences, notifications, and security policies.
3471
+ * Get list of file types and formats supported for scanning.
3472
+ * Returns supported manifest files, lockfiles, and configuration formats.
3222
3473
  *
3474
+ * @deprecated Use getSupportedFiles() instead. This endpoint has been deprecated
3475
+ * since 2023-01-15 and now uses the /report/supported endpoint.
3223
3476
  * @throws {Error} When server returns 5xx status codes
3224
3477
  */
3225
- async postSettings(selectors) {
3478
+ async getSupportedScanFiles() {
3226
3479
  try {
3227
3480
  const data = await this.#executeWithRetry(
3228
3481
  async () => await getResponseJson(
3229
- await createRequestWithJson(
3230
- "POST",
3231
- this.#baseUrl,
3232
- "settings",
3233
- { json: selectors },
3234
- { ...this.#reqOptions, hooks: this.#hooks }
3235
- )
3482
+ await createGetRequest(this.#baseUrl, "report/supported", {
3483
+ ...this.#reqOptions,
3484
+ hooks: this.#hooks
3485
+ })
3236
3486
  )
3237
3487
  );
3238
3488
  return this.#handleApiSuccess(data);
@@ -3241,261 +3491,131 @@ var SocketSdk = class {
3241
3491
  }
3242
3492
  }
3243
3493
  /**
3244
- * Search for dependencies across monitored projects.
3245
- * Returns matching packages with security information and usage patterns.
3494
+ * List all full scans for an organization.
3495
+ *
3496
+ * Returns paginated list of full scan metadata with guaranteed required fields
3497
+ * for improved TypeScript autocomplete.
3498
+ *
3499
+ * @param orgSlug - Organization identifier
3500
+ * @param options - Filtering and pagination options
3501
+ * @returns List of full scans with metadata
3502
+ *
3503
+ * @example
3504
+ * ```typescript
3505
+ * const result = await sdk.listFullScans('my-org', {
3506
+ * branch: 'main',
3507
+ * per_page: 50,
3508
+ * use_cursor: true
3509
+ * })
3510
+ *
3511
+ * if (result.success) {
3512
+ * result.data.results.forEach(scan => {
3513
+ * console.log(scan.id, scan.created_at) // Guaranteed fields
3514
+ * })
3515
+ * }
3516
+ * ```
3246
3517
  *
3518
+ * @see https://docs.socket.dev/reference/getorgfullscanlist
3519
+ * @apiEndpoint GET /orgs/{org_slug}/full-scans
3520
+ * @quota 0 units
3521
+ * @scopes full-scans:list
3247
3522
  * @throws {Error} When server returns 5xx status codes
3248
3523
  */
3249
- async searchDependencies(queryParams) {
3524
+ async listFullScans(orgSlug, options) {
3250
3525
  try {
3251
3526
  const data = await this.#executeWithRetry(
3252
3527
  async () => await getResponseJson(
3253
- await createRequestWithJson(
3254
- "POST",
3528
+ await createGetRequest(
3255
3529
  this.#baseUrl,
3256
- "dependencies/search",
3257
- queryParams,
3530
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(options)}`,
3258
3531
  { ...this.#reqOptions, hooks: this.#hooks }
3259
3532
  )
3260
3533
  )
3261
3534
  );
3262
- return this.#handleApiSuccess(data);
3263
- } catch (e) {
3264
- return await this.#handleApiError(e);
3265
- }
3266
- }
3267
- /**
3268
- * Send POST or PUT request with JSON body and return parsed JSON response.
3269
- * Supports both throwing (default) and non-throwing modes.
3270
- * @param urlPath - API endpoint path (e.g., 'organizations')
3271
- * @param options - Request options including method, body, and throws behavior
3272
- * @returns Parsed JSON response or SocketSdkGenericResult based on options
3273
- */
3274
- async sendApi(urlPath, options) {
3275
- const {
3276
- body,
3277
- // Default to POST method for JSON API requests.
3278
- method = "POST",
3279
- throws = true
3280
- } = { __proto__: null, ...options };
3281
- try {
3282
- const response = await createRequestWithJson(
3283
- method,
3284
- this.#baseUrl,
3285
- urlPath,
3286
- body,
3287
- { ...this.#reqOptions, hooks: this.#hooks }
3288
- );
3289
- const data = await getResponseJson(response);
3290
- if (throws) {
3291
- return data;
3292
- }
3293
3535
  return {
3294
3536
  cause: void 0,
3295
3537
  data,
3296
3538
  error: void 0,
3297
- /* c8 ignore next - Defensive fallback: response.statusCode is always defined in Node.js http/https */
3298
- status: response.statusCode ?? 200,
3539
+ status: 200,
3299
3540
  success: true
3300
3541
  };
3301
3542
  } catch (e) {
3302
- if (throws) {
3303
- throw e;
3304
- }
3305
- if (e instanceof ResponseError) {
3306
- const errorResult = await this.#handleApiError(e);
3307
- return {
3308
- cause: errorResult.cause,
3309
- data: void 0,
3310
- error: errorResult.error,
3311
- status: errorResult.status,
3312
- success: false
3313
- };
3314
- }
3315
- const errStr = e ? String(e).trim() : "";
3543
+ const errorResult = await this.#handleApiError(e);
3316
3544
  return {
3317
- cause: errStr || import_core.UNKNOWN_ERROR,
3545
+ cause: errorResult.cause,
3318
3546
  data: void 0,
3319
- error: "API request failed",
3320
- status: 0,
3547
+ error: errorResult.error,
3548
+ status: errorResult.status,
3321
3549
  success: false
3322
3550
  };
3323
3551
  }
3324
3552
  }
3325
3553
  /**
3326
- * Stream a full scan's results to file or stdout.
3554
+ * List all organizations accessible to the current user.
3327
3555
  *
3328
- * Provides efficient streaming for large scan datasets without loading
3329
- * entire response into memory. Useful for processing large SBOMs.
3556
+ * Returns organization details and access permissions with guaranteed required fields.
3330
3557
  *
3331
- * @param orgSlug - Organization identifier
3332
- * @param scanId - Full scan identifier
3333
- * @param options - Streaming options (output file path, stdout, or buffered)
3334
- * @returns Scan result with streaming response
3558
+ * @returns List of organizations with metadata
3335
3559
  *
3336
3560
  * @example
3337
3561
  * ```typescript
3338
- * // Stream to file
3339
- * await sdk.streamFullScan('my-org', 'scan_123', {
3340
- * output: './scan-results.json'
3341
- * })
3342
- *
3343
- * // Stream to stdout
3344
- * await sdk.streamFullScan('my-org', 'scan_123', {
3345
- * output: true
3346
- * })
3562
+ * const result = await sdk.listOrganizations()
3347
3563
  *
3348
- * // Get buffered response
3349
- * const result = await sdk.streamFullScan('my-org', 'scan_123')
3564
+ * if (result.success) {
3565
+ * result.data.organizations.forEach(org => {
3566
+ * console.log(org.name, org.slug) // Guaranteed fields
3567
+ * })
3568
+ * }
3350
3569
  * ```
3351
3570
  *
3352
- * @see https://docs.socket.dev/reference/getorgfullscan
3353
- * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
3354
- * @quota 1 unit
3355
- * @scopes full-scans:list
3571
+ * @see https://docs.socket.dev/reference/getorganizations
3572
+ * @apiEndpoint GET /organizations
3573
+ * @quota 0 units
3356
3574
  * @throws {Error} When server returns 5xx status codes
3357
3575
  */
3358
- async streamFullScan(orgSlug, scanId, options) {
3359
- const { output } = {
3360
- __proto__: null,
3361
- ...options
3362
- };
3576
+ async listOrganizations() {
3363
3577
  try {
3364
- const req = getHttpModule(this.#baseUrl).request(
3365
- `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
3366
- {
3367
- method: "GET",
3368
- ...this.#reqOptions
3369
- }
3370
- ).end();
3371
- const res = await getResponse(req);
3372
- if (!isResponseOk(res)) {
3373
- throw new ResponseError(res);
3374
- }
3375
- if (typeof output === "string") {
3376
- const writeStream = (0, import_node_fs3.createWriteStream)(output);
3377
- let bytesWritten = 0;
3378
- res.on("data", (chunk) => {
3379
- bytesWritten += chunk.length;
3380
- if (bytesWritten > MAX_STREAM_SIZE) {
3381
- res.destroy();
3382
- writeStream.destroy();
3383
- throw new Error(
3384
- `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
3385
- );
3386
- }
3387
- });
3388
- res.pipe(writeStream);
3389
- writeStream.on("error", (error) => {
3390
- throw new Error(`Failed to write to file: ${output}`, {
3391
- cause: error
3392
- });
3393
- });
3394
- } else if (output === true) {
3395
- let bytesWritten = 0;
3396
- res.on("data", (chunk) => {
3397
- bytesWritten += chunk.length;
3398
- if (bytesWritten > MAX_STREAM_SIZE) {
3399
- res.destroy();
3400
- throw new Error(
3401
- `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
3402
- );
3403
- }
3404
- });
3405
- res.pipe(process.stdout);
3406
- process.stdout.on("error", (error) => {
3407
- throw new Error("Failed to write to stdout", { cause: error });
3408
- });
3409
- }
3410
- return this.#handleApiSuccess(res);
3411
- } catch (e) {
3412
- return await this.#handleApiError(e);
3413
- }
3414
- }
3415
- /**
3416
- * Stream patches for artifacts in a scan report.
3417
- *
3418
- * This method streams all available patches for artifacts in a scan.
3419
- * Free tier users will only receive free patches.
3420
- *
3421
- * Note: This method returns a ReadableStream for processing large datasets.
3422
- */
3423
- async streamPatchesFromScan(orgSlug, scanId) {
3424
- const response = await this.#executeWithRetry(
3425
- async () => await createGetRequest(
3426
- this.#baseUrl,
3427
- `orgs/${encodeURIComponent(orgSlug)}/patches/scan?scan_id=${encodeURIComponent(scanId)}`,
3428
- { ...this.#reqOptions, hooks: this.#hooks }
3429
- )
3430
- );
3431
- if (!isResponseOk(response)) {
3432
- throw new ResponseError(response, "GET Request failed");
3433
- }
3434
- const rli = import_node_readline.default.createInterface({
3435
- input: response,
3436
- crlfDelay: Number.POSITIVE_INFINITY
3437
- });
3438
- return new ReadableStream({
3439
- async start(controller) {
3440
- try {
3441
- for await (const line of rli) {
3442
- const trimmed = line.trim();
3443
- if (!trimmed) {
3444
- continue;
3445
- }
3446
- try {
3447
- const data = JSON.parse(trimmed);
3448
- controller.enqueue(data);
3449
- } catch (e) {
3450
- (0, import_debug2.debugLog)("streamPatchesFromScan", `Failed to parse line: ${e}`);
3451
- }
3452
- }
3453
- } catch (error) {
3454
- controller.error(error);
3455
- } finally {
3456
- controller.close();
3457
- }
3458
- }
3459
- });
3460
- }
3461
- /**
3462
- * Update alert triage status for an organization.
3463
- * Modifies alert resolution status and triage decisions.
3464
- *
3465
- * @throws {Error} When server returns 5xx status codes
3466
- */
3467
- async updateOrgAlertTriage(orgSlug, alertId, triageData) {
3468
- try {
3469
- const data = await this.#executeWithRetry(
3578
+ const data = await this.#getCached(
3579
+ "organizations",
3470
3580
  async () => await getResponseJson(
3471
- await createRequestWithJson(
3472
- "PUT",
3473
- this.#baseUrl,
3474
- `orgs/${encodeURIComponent(orgSlug)}/triage/${encodeURIComponent(alertId)}`,
3475
- triageData,
3476
- { ...this.#reqOptions, hooks: this.#hooks }
3477
- )
3478
- )
3581
+ await createGetRequest(this.#baseUrl, "organizations", {
3582
+ ...this.#reqOptions,
3583
+ hooks: this.#hooks
3584
+ })
3585
+ ),
3586
+ "organizations"
3479
3587
  );
3480
- return this.#handleApiSuccess(data);
3588
+ return {
3589
+ cause: void 0,
3590
+ data,
3591
+ error: void 0,
3592
+ status: 200,
3593
+ success: true
3594
+ };
3481
3595
  } catch (e) {
3482
- return await this.#handleApiError(e);
3596
+ const errorResult = await this.#handleApiError(e);
3597
+ return {
3598
+ cause: errorResult.cause,
3599
+ data: void 0,
3600
+ error: errorResult.error,
3601
+ status: errorResult.status,
3602
+ success: false
3603
+ };
3483
3604
  }
3484
3605
  }
3485
3606
  /**
3486
- * Update organization's license policy configuration.* Modifies allowed, restricted, and monitored license types.
3607
+ * List all diff scans for an organization.
3608
+ * Returns paginated list of diff scan metadata and status.
3487
3609
  *
3488
3610
  * @throws {Error} When server returns 5xx status codes
3489
3611
  */
3490
- async updateOrgLicensePolicy(orgSlug, policyData, queryParams) {
3612
+ async listOrgDiffScans(orgSlug) {
3491
3613
  try {
3492
3614
  const data = await this.#executeWithRetry(
3493
3615
  async () => await getResponseJson(
3494
- await createRequestWithJson(
3495
- "POST",
3616
+ await createGetRequest(
3496
3617
  this.#baseUrl,
3497
- `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy?${queryToSearchParams(queryParams)}`,
3498
- policyData,
3618
+ `orgs/${encodeURIComponent(orgSlug)}/diff-scans`,
3499
3619
  { ...this.#reqOptions, hooks: this.#hooks }
3500
3620
  )
3501
3621
  )
@@ -3506,42 +3626,42 @@ var SocketSdk = class {
3506
3626
  }
3507
3627
  }
3508
3628
  /**
3509
- * Update configuration for a repository.
3629
+ * List all repositories in an organization.
3510
3630
  *
3511
- * Modifies monitoring settings, branch configuration, and scan preferences.
3631
+ * Returns paginated list of repository metadata with guaranteed required fields.
3512
3632
  *
3513
3633
  * @param orgSlug - Organization identifier
3514
- * @param repoSlug - Repository slug/name
3515
- * @param params - Configuration updates (description, homepage, default_branch, etc.)
3516
- * @returns Updated repository details
3634
+ * @param options - Pagination and filtering options
3635
+ * @returns List of repositories with metadata
3517
3636
  *
3518
3637
  * @example
3519
3638
  * ```typescript
3520
- * const result = await sdk.updateRepository('my-org', 'my-repo', {
3521
- * description: 'Updated description',
3522
- * default_branch: 'develop'
3639
+ * const result = await sdk.listRepositories('my-org', {
3640
+ * per_page: 50,
3641
+ * sort: 'name',
3642
+ * direction: 'asc'
3523
3643
  * })
3524
3644
  *
3525
3645
  * if (result.success) {
3526
- * console.log('Repository updated:', result.data.name)
3646
+ * result.data.results.forEach(repo => {
3647
+ * console.log(repo.name, repo.visibility)
3648
+ * })
3527
3649
  * }
3528
3650
  * ```
3529
3651
  *
3530
- * @see https://docs.socket.dev/reference/updateorgrepo
3531
- * @apiEndpoint POST /orgs/{org_slug}/repos/{repo_slug}
3532
- * @quota 1 unit
3533
- * @scopes repo:write
3652
+ * @see https://docs.socket.dev/reference/getorgrepolist
3653
+ * @apiEndpoint GET /orgs/{org_slug}/repos
3654
+ * @quota 0 units
3655
+ * @scopes repo:list
3534
3656
  * @throws {Error} When server returns 5xx status codes
3535
3657
  */
3536
- async updateRepository(orgSlug, repoSlug, params) {
3658
+ async listRepositories(orgSlug, options) {
3537
3659
  try {
3538
3660
  const data = await this.#executeWithRetry(
3539
3661
  async () => await getResponseJson(
3540
- await createRequestWithJson(
3541
- "POST",
3662
+ await createGetRequest(
3542
3663
  this.#baseUrl,
3543
- `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`,
3544
- params,
3664
+ `orgs/${encodeURIComponent(orgSlug)}/repos?${queryToSearchParams(options)}`,
3545
3665
  { ...this.#reqOptions, hooks: this.#hooks }
3546
3666
  )
3547
3667
  )
@@ -3565,40 +3685,39 @@ var SocketSdk = class {
3565
3685
  }
3566
3686
  }
3567
3687
  /**
3568
- * Update a repository label for an organization.
3688
+ * List all repository labels for an organization.
3569
3689
  *
3570
- * Modifies label properties like name. Label names must be non-empty and less than 1000 characters.
3690
+ * Returns paginated list of labels configured for repository organization and policy management.
3571
3691
  *
3572
3692
  * @param orgSlug - Organization identifier
3573
- * @param labelId - Label identifier
3574
- * @param labelData - Label updates (typically name property)
3575
- * @returns Updated label with guaranteed id and name fields
3693
+ * @param options - Pagination options
3694
+ * @returns List of labels with guaranteed id and name fields
3576
3695
  *
3577
3696
  * @example
3578
3697
  * ```typescript
3579
- * const result = await sdk.updateRepositoryLabel('my-org', 'label-id-123', { name: 'staging' })
3698
+ * const result = await sdk.listRepositoryLabels('my-org', { per_page: 50, page: 1 })
3580
3699
  *
3581
3700
  * if (result.success) {
3582
- * console.log('Label updated:', result.data.name)
3583
- * console.log('Label ID:', result.data.id)
3701
+ * result.data.results.forEach(label => {
3702
+ * console.log('Label:', label.name)
3703
+ * console.log('Associated repos:', label.repository_ids?.length || 0)
3704
+ * })
3584
3705
  * }
3585
3706
  * ```
3586
3707
  *
3587
- * @see https://docs.socket.dev/reference/updateorgrepolabel
3588
- * @apiEndpoint PUT /orgs/{org_slug}/repos/labels/{label_id}
3589
- * @quota 1 unit
3590
- * @scopes repo-label:update
3708
+ * @see https://docs.socket.dev/reference/getorgrepolabellist
3709
+ * @apiEndpoint GET /orgs/{org_slug}/repos/labels
3710
+ * @quota 0 units
3711
+ * @scopes repo-label:list
3591
3712
  * @throws {Error} When server returns 5xx status codes
3592
3713
  */
3593
- async updateRepositoryLabel(orgSlug, labelId, labelData) {
3714
+ async listRepositoryLabels(orgSlug, options) {
3594
3715
  try {
3595
3716
  const data = await this.#executeWithRetry(
3596
3717
  async () => await getResponseJson(
3597
- await createRequestWithJson(
3598
- "PUT",
3718
+ await createGetRequest(
3599
3719
  this.#baseUrl,
3600
- `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
3601
- labelData,
3720
+ `orgs/${encodeURIComponent(orgSlug)}/repos/labels?${queryToSearchParams(options)}`,
3602
3721
  { ...this.#reqOptions, hooks: this.#hooks }
3603
3722
  )
3604
3723
  )
@@ -3622,19 +3741,20 @@ var SocketSdk = class {
3622
3741
  }
3623
3742
  }
3624
3743
  /**
3625
- * Update organization's security policy configuration.* Modifies alert rules, severity thresholds, and enforcement settings.
3744
+ * Create a new API token for an organization.
3745
+ * Generates API token with specified scopes and metadata.
3626
3746
  *
3627
3747
  * @throws {Error} When server returns 5xx status codes
3628
3748
  */
3629
- async updateOrgSecurityPolicy(orgSlug, policyData) {
3749
+ async postAPIToken(orgSlug, tokenData) {
3630
3750
  try {
3631
3751
  const data = await this.#executeWithRetry(
3632
3752
  async () => await getResponseJson(
3633
3753
  await createRequestWithJson(
3634
3754
  "POST",
3635
3755
  this.#baseUrl,
3636
- `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
3637
- policyData,
3756
+ `orgs/${encodeURIComponent(orgSlug)}/tokens`,
3757
+ tokenData,
3638
3758
  { ...this.#reqOptions, hooks: this.#hooks }
3639
3759
  )
3640
3760
  )
@@ -3645,279 +3765,434 @@ var SocketSdk = class {
3645
3765
  }
3646
3766
  }
3647
3767
  /**
3648
- * Upload manifest files for dependency analysis.
3649
- * Processes package files to create dependency snapshots and security analysis.
3768
+ * Revoke an API token for an organization.
3769
+ * Permanently disables the token and removes access.
3650
3770
  *
3651
3771
  * @throws {Error} When server returns 5xx status codes
3652
3772
  */
3653
- async uploadManifestFiles(orgSlug, filepaths, options) {
3654
- const { pathsRelativeTo = "." } = {
3655
- __proto__: null,
3656
- ...options
3657
- };
3658
- const basePath = resolveBasePath(pathsRelativeTo);
3659
- const absFilepaths = resolveAbsPaths(filepaths, basePath);
3660
- const { invalidPaths, validPaths } = (0, import_fs.validateFiles)(absFilepaths);
3661
- if (this.#onFileValidation && invalidPaths.length > 0) {
3662
- const result = await this.#onFileValidation(validPaths, invalidPaths, {
3663
- operation: "uploadManifestFiles",
3664
- orgSlug
3665
- });
3666
- if (!result.shouldContinue) {
3667
- const errorMsg = result.errorMessage ?? "File validation failed";
3668
- const finalCause = filterRedundantCause(errorMsg, result.errorCause);
3669
- return {
3670
- error: errorMsg,
3671
- status: 400,
3672
- success: false,
3673
- ...finalCause ? { cause: finalCause } : {}
3674
- };
3675
- }
3676
- }
3677
- if (!this.#onFileValidation && invalidPaths.length > 0) {
3678
- const samplePaths = invalidPaths.slice(0, 3).join("\n - ");
3679
- const remaining = invalidPaths.length > 3 ? `
3680
- ... and ${invalidPaths.length - 3} more` : "";
3681
- console.warn(
3682
- `Warning: ${invalidPaths.length} files skipped (unreadable):
3683
- - ${samplePaths}${remaining}
3684
- \u2192 This may occur with Yarn Berry PnP or pnpm symlinks.
3685
- \u2192 Try: Run installation command to ensure files are accessible.`
3686
- );
3687
- }
3688
- if (validPaths.length === 0) {
3689
- const samplePaths = invalidPaths.slice(0, 5).join("\n - ");
3690
- const remaining = invalidPaths.length > 5 ? `
3691
- ... and ${invalidPaths.length - 5} more` : "";
3692
- return {
3693
- cause: [
3694
- `All ${invalidPaths.length} files failed validation:`,
3695
- ` - ${samplePaths}${remaining}`,
3696
- "",
3697
- "\u2192 Common causes:",
3698
- " \xB7Yarn Berry PnP virtual filesystem (files are not on disk)",
3699
- " \xB7pnpm symlinks pointing to inaccessible locations",
3700
- " \xB7Incorrect file permissions",
3701
- " \xB7Files were deleted after discovery",
3702
- "",
3703
- "\u2192 Solutions:",
3704
- " \xB7Yarn Berry: Use `nodeLinker: node-modules` in .yarnrc.yml",
3705
- " \xB7pnpm: Use `node-linker=hoisted` in .npmrc",
3706
- " \xB7Check file permissions with: ls -la <file>",
3707
- " \xB7Run package manager install command"
3708
- ].join("\n"),
3709
- error: "No readable manifest files found",
3710
- status: 400,
3711
- success: false
3712
- };
3713
- }
3773
+ async postAPITokensRevoke(orgSlug, tokenId) {
3714
3774
  try {
3715
3775
  const data = await this.#executeWithRetry(
3716
3776
  async () => await getResponseJson(
3717
- await createUploadRequest(
3777
+ await createRequestWithJson(
3778
+ "POST",
3718
3779
  this.#baseUrl,
3719
- `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`,
3720
- createRequestBodyForFilepaths(validPaths, basePath),
3780
+ `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/revoke`,
3781
+ {},
3721
3782
  { ...this.#reqOptions, hooks: this.#hooks }
3722
3783
  )
3723
3784
  )
3724
3785
  );
3725
- return this.#handleApiSuccess(
3726
- data
3786
+ return this.#handleApiSuccess(data);
3787
+ } catch (e) {
3788
+ return await this.#handleApiError(e);
3789
+ }
3790
+ }
3791
+ /**
3792
+ * Rotate an API token for an organization.
3793
+ * Generates new token value while preserving token metadata.
3794
+ *
3795
+ * @throws {Error} When server returns 5xx status codes
3796
+ */
3797
+ async postAPITokensRotate(orgSlug, tokenId) {
3798
+ try {
3799
+ const data = await this.#executeWithRetry(
3800
+ async () => await getResponseJson(
3801
+ await createRequestWithJson(
3802
+ "POST",
3803
+ this.#baseUrl,
3804
+ `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/rotate`,
3805
+ {},
3806
+ { ...this.#reqOptions, hooks: this.#hooks }
3807
+ )
3808
+ )
3727
3809
  );
3810
+ return this.#handleApiSuccess(data);
3728
3811
  } catch (e) {
3729
- return await this.#handleApiError(
3730
- e
3812
+ return await this.#handleApiError(e);
3813
+ }
3814
+ }
3815
+ /**
3816
+ * Update an existing API token for an organization.
3817
+ * Modifies token metadata, scopes, or other properties.
3818
+ *
3819
+ * @throws {Error} When server returns 5xx status codes
3820
+ */
3821
+ async postAPITokenUpdate(orgSlug, tokenId, updateData) {
3822
+ try {
3823
+ const data = await this.#executeWithRetry(
3824
+ async () => await getResponseJson(
3825
+ await createRequestWithJson(
3826
+ "POST",
3827
+ this.#baseUrl,
3828
+ `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/update`,
3829
+ updateData,
3830
+ { ...this.#reqOptions, hooks: this.#hooks }
3831
+ )
3832
+ )
3731
3833
  );
3834
+ return this.#handleApiSuccess(data);
3835
+ } catch (e) {
3836
+ return await this.#handleApiError(e);
3732
3837
  }
3733
3838
  }
3734
3839
  /**
3735
- * View detailed information about a specific patch by its UUID.
3840
+ * Post telemetry data for an organization.
3841
+ * Sends telemetry events and analytics data for monitoring and analysis.
3736
3842
  *
3737
- * This method retrieves comprehensive patch details including files,
3738
- * vulnerabilities, description, license, and tier information.
3843
+ * @param orgSlug - Organization identifier
3844
+ * @param telemetryData - Telemetry payload containing events and metrics
3845
+ * @returns Empty object on successful submission
3846
+ *
3847
+ * @throws {Error} When server returns 5xx status codes
3739
3848
  */
3740
- async viewPatch(orgSlug, uuid) {
3741
- const data = await getResponseJson(
3742
- await createGetRequest(
3743
- this.#baseUrl,
3744
- `orgs/${encodeURIComponent(orgSlug)}/patches/view/${encodeURIComponent(uuid)}`,
3745
- { ...this.#reqOptions, hooks: this.#hooks }
3746
- )
3747
- );
3748
- return data;
3849
+ async postOrgTelemetry(orgSlug, telemetryData) {
3850
+ try {
3851
+ const data = await this.#executeWithRetry(
3852
+ async () => await getResponseJson(
3853
+ await createRequestWithJson(
3854
+ "POST",
3855
+ this.#baseUrl,
3856
+ `orgs/${encodeURIComponent(orgSlug)}/telemetry`,
3857
+ telemetryData,
3858
+ { ...this.#reqOptions, hooks: this.#hooks }
3859
+ )
3860
+ )
3861
+ );
3862
+ return {
3863
+ cause: void 0,
3864
+ data,
3865
+ error: void 0,
3866
+ status: 200,
3867
+ success: true
3868
+ };
3869
+ } catch (e) {
3870
+ return this.#createQueryErrorResult(e);
3871
+ }
3749
3872
  }
3750
3873
  /**
3751
- * Download patch file content by hash.
3874
+ * Update user or organization settings.
3875
+ * Configures preferences, notifications, and security policies.
3752
3876
  *
3753
- * Downloads the actual patched file content from the public Socket blob store.
3754
- * This is used after calling viewPatch() to get the patch metadata.
3755
- * No authentication is required as patch blobs are publicly accessible.
3877
+ * @throws {Error} When server returns 5xx status codes
3878
+ */
3879
+ async postSettings(selectors) {
3880
+ try {
3881
+ const data = await this.#executeWithRetry(
3882
+ async () => await getResponseJson(
3883
+ await createRequestWithJson(
3884
+ "POST",
3885
+ this.#baseUrl,
3886
+ "settings",
3887
+ { json: selectors },
3888
+ { ...this.#reqOptions, hooks: this.#hooks }
3889
+ )
3890
+ )
3891
+ );
3892
+ return this.#handleApiSuccess(data);
3893
+ } catch (e) {
3894
+ return await this.#handleApiError(e);
3895
+ }
3896
+ }
3897
+ /**
3898
+ * Create a new full scan by rescanning an existing scan.
3899
+ * Supports shallow (policy reapplication) and deep (dependency resolution rerun) modes.
3756
3900
  *
3757
- * @param hash - The blob hash in SSRI (sha256-base64) or hex format
3758
- * @param options - Optional configuration
3759
- * @param options.baseUrl - Override blob store URL (for testing)
3760
- * @returns Promise<string> - The patch file content as UTF-8 string
3761
- * @throws Error if blob not found (404) or download fails
3901
+ * @param orgSlug - Organization identifier
3902
+ * @param fullScanId - Full scan ID to rescan
3903
+ * @param options - Rescan options including mode (shallow or deep)
3904
+ * @returns New scan ID and status
3762
3905
  *
3763
3906
  * @example
3764
3907
  * ```typescript
3765
- * const sdk = new SocketSdk('your-api-token')
3766
- * // First get patch metadata
3767
- * const patch = await sdk.viewPatch('my-org', 'patch-uuid')
3768
- * // Then download the actual patched file
3769
- * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
3908
+ * // Shallow rescan (reapply policies to cached data)
3909
+ * const result = await sdk.rescanFullScan('my-org', 'scan_123', {
3910
+ * mode: 'shallow'
3911
+ * })
3912
+ *
3913
+ * if (result.success) {
3914
+ * console.log('New Scan ID:', result.data.id)
3915
+ * console.log('Status:', result.data.status)
3916
+ * }
3917
+ *
3918
+ * // Deep rescan (rerun dependency resolution)
3919
+ * const deepResult = await sdk.rescanFullScan('my-org', 'scan_123', {
3920
+ * mode: 'deep'
3921
+ * })
3770
3922
  * ```
3923
+ *
3924
+ * @see https://docs.socket.dev/reference/rescanorgfullscan
3925
+ * @apiEndpoint POST /orgs/{org_slug}/full-scans/{full_scan_id}/rescan
3926
+ * @quota 0 units
3927
+ * @scopes full-scans:create
3928
+ * @throws {Error} When server returns 5xx status codes
3771
3929
  */
3772
- async downloadOrgFullScanFilesAsTar(orgSlug, fullScanId, outputPath) {
3930
+ async rescanFullScan(orgSlug, fullScanId, options) {
3931
+ const queryString = options ? `?${queryToSearchParams(options)}` : "";
3773
3932
  try {
3774
- const req = getHttpModule(this.#baseUrl).request(
3775
- `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/files.tar`,
3776
- {
3777
- method: "GET",
3778
- ...this.#reqOptions
3779
- }
3780
- ).end();
3781
- const res = await getResponse(req);
3782
- if (!isResponseOk(res)) {
3783
- throw new ResponseError(res);
3784
- }
3785
- const writeStream = (0, import_node_fs3.createWriteStream)(outputPath);
3786
- let bytesWritten = 0;
3787
- res.on("data", (chunk) => {
3788
- bytesWritten += chunk.length;
3789
- if (bytesWritten > MAX_STREAM_SIZE) {
3790
- res.destroy();
3791
- writeStream.destroy();
3792
- throw new Error(
3793
- `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
3794
- );
3795
- }
3796
- });
3797
- res.pipe(writeStream);
3798
- writeStream.on("error", (error) => {
3799
- throw new Error(`Failed to write to file: ${outputPath}`, {
3800
- cause: error
3801
- });
3802
- });
3803
- await import_node_events.default.once(writeStream, "finish");
3804
- return this.#handleApiSuccess(res);
3933
+ const data = await this.#executeWithRetry(
3934
+ async () => await getResponseJson(
3935
+ await createRequestWithJson(
3936
+ "POST",
3937
+ this.#baseUrl,
3938
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/rescan${queryString}`,
3939
+ {},
3940
+ { ...this.#reqOptions, hooks: this.#hooks }
3941
+ )
3942
+ )
3943
+ );
3944
+ return this.#handleApiSuccess(data);
3805
3945
  } catch (e) {
3806
3946
  return await this.#handleApiError(e);
3807
3947
  }
3808
3948
  }
3809
3949
  /**
3810
- * Download patch file content from Socket blob storage.
3811
- * Retrieves patched file contents using SSRI hash or hex hash.
3950
+ * Search for dependencies across monitored projects.
3951
+ * Returns matching packages with security information and usage patterns.
3812
3952
  *
3813
- * This is a low-level utility method - you'll typically use this after calling
3814
- * `viewPatch()` to get patch metadata, then download individual patched files.
3953
+ * @throws {Error} When server returns 5xx status codes
3954
+ */
3955
+ async searchDependencies(queryParams) {
3956
+ try {
3957
+ const data = await this.#executeWithRetry(
3958
+ async () => await getResponseJson(
3959
+ await createRequestWithJson(
3960
+ "POST",
3961
+ this.#baseUrl,
3962
+ "dependencies/search",
3963
+ queryParams,
3964
+ { ...this.#reqOptions, hooks: this.#hooks }
3965
+ )
3966
+ )
3967
+ );
3968
+ return this.#handleApiSuccess(data);
3969
+ } catch (e) {
3970
+ return await this.#handleApiError(e);
3971
+ }
3972
+ }
3973
+ /**
3974
+ * Send POST or PUT request with JSON body and return parsed JSON response.
3975
+ * Supports both throwing (default) and non-throwing modes.
3976
+ * @param urlPath - API endpoint path (e.g., 'organizations')
3977
+ * @param options - Request options including method, body, and throws behavior
3978
+ * @returns Parsed JSON response or SocketSdkGenericResult based on options
3979
+ */
3980
+ async sendApi(urlPath, options) {
3981
+ const {
3982
+ body,
3983
+ // Default to POST method for JSON API requests.
3984
+ method = "POST",
3985
+ throws = true
3986
+ } = { __proto__: null, ...options };
3987
+ try {
3988
+ const response = await createRequestWithJson(
3989
+ method,
3990
+ this.#baseUrl,
3991
+ urlPath,
3992
+ body,
3993
+ { ...this.#reqOptions, hooks: this.#hooks }
3994
+ );
3995
+ const data = await getResponseJson(response);
3996
+ if (throws) {
3997
+ return data;
3998
+ }
3999
+ return {
4000
+ cause: void 0,
4001
+ data,
4002
+ error: void 0,
4003
+ /* c8 ignore next - Defensive fallback: response.statusCode is always defined in Node.js http/https */
4004
+ status: response.statusCode ?? 200,
4005
+ success: true
4006
+ };
4007
+ } catch (e) {
4008
+ if (throws) {
4009
+ throw e;
4010
+ }
4011
+ if (e instanceof ResponseError) {
4012
+ const errorResult = await this.#handleApiError(e);
4013
+ return {
4014
+ cause: errorResult.cause,
4015
+ data: void 0,
4016
+ error: errorResult.error,
4017
+ status: errorResult.status,
4018
+ success: false
4019
+ };
4020
+ }
4021
+ const errStr = e ? String(e).trim() : "";
4022
+ return {
4023
+ cause: errStr || import_core.UNKNOWN_ERROR,
4024
+ data: void 0,
4025
+ error: "API request failed",
4026
+ status: 0,
4027
+ success: false
4028
+ };
4029
+ }
4030
+ }
4031
+ /**
4032
+ * Stream a full scan's results to file or stdout.
3815
4033
  *
3816
- * @param hash - The blob hash in SSRI (sha256-base64) or hex format
3817
- * @param options - Optional configuration
3818
- * @param options.baseUrl - Override blob store URL (for testing)
3819
- * @returns Promise<string> - The patch file content as UTF-8 string
3820
- * @throws Error if blob not found (404) or download fails
4034
+ * Provides efficient streaming for large scan datasets without loading
4035
+ * entire response into memory. Useful for processing large SBOMs.
4036
+ *
4037
+ * @param orgSlug - Organization identifier
4038
+ * @param scanId - Full scan identifier
4039
+ * @param options - Streaming options (output file path, stdout, or buffered)
4040
+ * @returns Scan result with streaming response
3821
4041
  *
3822
4042
  * @example
3823
4043
  * ```typescript
3824
- * const sdk = new SocketSdk('your-api-token')
3825
- * // First get patch metadata
3826
- * const patch = await sdk.viewPatch('my-org', 'patch-uuid')
3827
- * // Then download the actual patched file
3828
- * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
4044
+ * // Stream to file
4045
+ * await sdk.streamFullScan('my-org', 'scan_123', {
4046
+ * output: './scan-results.json'
4047
+ * })
4048
+ *
4049
+ * // Stream to stdout
4050
+ * await sdk.streamFullScan('my-org', 'scan_123', {
4051
+ * output: true
4052
+ * })
4053
+ *
4054
+ * // Get buffered response
4055
+ * const result = await sdk.streamFullScan('my-org', 'scan_123')
3829
4056
  * ```
4057
+ *
4058
+ * @see https://docs.socket.dev/reference/getorgfullscan
4059
+ * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
4060
+ * @quota 0 units
4061
+ * @scopes full-scans:list
4062
+ * @throws {Error} When server returns 5xx status codes
3830
4063
  */
3831
- async downloadPatch(hash, options) {
3832
- const https2 = await import("node:https");
3833
- const http2 = await import("node:http");
3834
- const blobPath = `/blob/${encodeURIComponent(hash)}`;
3835
- const blobBaseUrl = options?.baseUrl || SOCKET_PUBLIC_BLOB_STORE_URL;
3836
- const url = `${blobBaseUrl}${blobPath}`;
3837
- const isHttps = url.startsWith("https:");
3838
- return await new Promise((resolve, reject) => {
3839
- const client = isHttps ? https2 : http2;
3840
- client.get(url, (res) => {
3841
- if (res.statusCode === 404) {
3842
- const message = [
3843
- `Blob not found: ${hash}`,
3844
- `\u2192 URL: ${url}`,
3845
- "\u2192 The patch file may have expired or the hash is incorrect.",
3846
- "\u2192 Verify: The blob hash is correct.",
3847
- "\u2192 Note: Blob URLs may expire after a certain time period."
3848
- ].join("\n");
3849
- reject(new Error(message));
3850
- return;
3851
- }
3852
- if (res.statusCode !== 200) {
3853
- const message = [
3854
- `Failed to download blob: ${res.statusCode} ${res.statusMessage}`,
3855
- `\u2192 Hash: ${hash}`,
3856
- `\u2192 URL: ${url}`,
3857
- "\u2192 The blob storage service may be temporarily unavailable.",
3858
- res.statusCode && res.statusCode >= 500 ? "\u2192 Try: Retry the download after a short delay." : "\u2192 Verify: The blob hash and URL are correct."
3859
- ].join("\n");
3860
- reject(new Error(message));
3861
- return;
3862
- }
3863
- let data = "";
4064
+ async streamFullScan(orgSlug, scanId, options) {
4065
+ const { output } = {
4066
+ __proto__: null,
4067
+ ...options
4068
+ };
4069
+ const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`;
4070
+ try {
4071
+ const req = getHttpModule(this.#baseUrl).request(url, {
4072
+ method: "GET",
4073
+ ...this.#reqOptions
4074
+ }).end();
4075
+ const res = await getResponse(req);
4076
+ if (!isResponseOk(res)) {
4077
+ throw new ResponseError(res, "", url);
4078
+ }
4079
+ if (typeof output === "string") {
4080
+ const writeStream = (0, import_node_fs3.createWriteStream)(output);
4081
+ let bytesWritten = 0;
3864
4082
  res.on("data", (chunk) => {
3865
- data += chunk;
4083
+ if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
4084
+ const error = new Error(
4085
+ `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
4086
+ );
4087
+ res.destroy(error);
4088
+ writeStream.destroy(error);
4089
+ return;
4090
+ }
4091
+ bytesWritten += chunk.length;
3866
4092
  });
4093
+ res.pipe(writeStream);
4094
+ writeStream.on("error", (error) => {
4095
+ res.destroy();
4096
+ writeStream.destroy(error);
4097
+ });
4098
+ await import_node_events.default.once(writeStream, "finish");
4099
+ } else if (output === true) {
4100
+ let bytesWritten = 0;
4101
+ res.on("data", (chunk) => {
4102
+ if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
4103
+ const error = new Error(
4104
+ `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
4105
+ );
4106
+ res.destroy(error);
4107
+ return;
4108
+ }
4109
+ bytesWritten += chunk.length;
4110
+ });
4111
+ const stdoutErrorHandler = (_error) => {
4112
+ res.destroy();
4113
+ process.stdout.removeListener("error", stdoutErrorHandler);
4114
+ };
4115
+ process.stdout.on("error", stdoutErrorHandler);
4116
+ res.pipe(process.stdout);
3867
4117
  res.on("end", () => {
3868
- resolve(data);
4118
+ process.stdout.removeListener("error", stdoutErrorHandler);
3869
4119
  });
3870
- res.on("error", (err) => {
3871
- reject(err);
4120
+ res.on("error", () => {
4121
+ process.stdout.removeListener("error", stdoutErrorHandler);
3872
4122
  });
3873
- }).on("error", (err) => {
3874
- const nodeErr = err;
3875
- const message = [
3876
- `Error downloading blob: ${hash}`,
3877
- `\u2192 URL: ${url}`,
3878
- `\u2192 Network error: ${nodeErr.message}`
3879
- ];
3880
- if (nodeErr.code === "ENOTFOUND") {
3881
- message.push(
3882
- "\u2192 DNS lookup failed. Cannot resolve blob storage hostname.",
3883
- "\u2192 Check: Internet connection and DNS settings."
3884
- );
3885
- } else if (nodeErr.code === "ECONNREFUSED") {
3886
- message.push(
3887
- "\u2192 Connection refused. Blob storage service is unreachable.",
3888
- "\u2192 Check: Network connectivity and firewall settings."
3889
- );
3890
- } else if (nodeErr.code === "ETIMEDOUT") {
3891
- message.push(
3892
- "\u2192 Connection timed out.",
3893
- "\u2192 Try: Check network connectivity and retry."
3894
- );
3895
- } else if (nodeErr.code) {
3896
- message.push(`\u2192 Error code: ${nodeErr.code}`);
4123
+ }
4124
+ return this.#handleApiSuccess(res);
4125
+ } catch (e) {
4126
+ return await this.#handleApiError(e);
4127
+ }
4128
+ }
4129
+ /**
4130
+ * Stream patches for artifacts in a scan report.
4131
+ *
4132
+ * This method streams all available patches for artifacts in a scan.
4133
+ * Free tier users will only receive free patches.
4134
+ *
4135
+ * Note: This method returns a ReadableStream for processing large datasets.
4136
+ */
4137
+ async streamPatchesFromScan(orgSlug, scanId) {
4138
+ const urlPath = `orgs/${encodeURIComponent(orgSlug)}/patches/scan?scan_id=${encodeURIComponent(scanId)}`;
4139
+ const url = `${this.#baseUrl}${urlPath}`;
4140
+ const response = await this.#executeWithRetry(
4141
+ async () => await createGetRequest(this.#baseUrl, urlPath, {
4142
+ ...this.#reqOptions,
4143
+ hooks: this.#hooks
4144
+ })
4145
+ );
4146
+ if (!isResponseOk(response)) {
4147
+ throw new ResponseError(response, "GET Request failed", url);
4148
+ }
4149
+ const rli = import_node_readline.default.createInterface({
4150
+ input: response,
4151
+ crlfDelay: Number.POSITIVE_INFINITY
4152
+ });
4153
+ return new ReadableStream({
4154
+ async start(controller) {
4155
+ try {
4156
+ for await (const line of rli) {
4157
+ const trimmed = line.trim();
4158
+ if (!trimmed) {
4159
+ continue;
4160
+ }
4161
+ try {
4162
+ const data = JSON.parse(trimmed);
4163
+ controller.enqueue(data);
4164
+ } catch (e) {
4165
+ (0, import_debug2.debugLog)("streamPatchesFromScan", `Failed to parse line: ${e}`);
4166
+ }
4167
+ }
4168
+ } catch (error) {
4169
+ controller.error(error);
4170
+ } finally {
4171
+ rli.close();
4172
+ controller.close();
3897
4173
  }
3898
- reject(new Error(message.join("\n"), { cause: err }));
3899
- });
4174
+ },
4175
+ /* c8 ignore next 3 - Stream cancellation cleanup, difficult to test reliably. */
4176
+ cancel() {
4177
+ rli.close();
4178
+ }
3900
4179
  });
3901
4180
  }
3902
4181
  /**
3903
- * Update organization's telemetry configuration.
3904
- * Enables or disables telemetry for the organization.
3905
- *
3906
- * @param orgSlug - Organization identifier
3907
- * @param telemetryData - Telemetry configuration with enabled flag
3908
- * @returns Updated telemetry configuration
4182
+ * Update alert triage status for an organization.
4183
+ * Modifies alert resolution status and triage decisions.
3909
4184
  *
3910
4185
  * @throws {Error} When server returns 5xx status codes
3911
4186
  */
3912
- async updateOrgTelemetryConfig(orgSlug, telemetryData) {
4187
+ async updateOrgAlertTriage(orgSlug, alertId, triageData) {
3913
4188
  try {
3914
4189
  const data = await this.#executeWithRetry(
3915
4190
  async () => await getResponseJson(
3916
4191
  await createRequestWithJson(
3917
4192
  "PUT",
3918
4193
  this.#baseUrl,
3919
- `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
3920
- telemetryData,
4194
+ `orgs/${encodeURIComponent(orgSlug)}/triage/${encodeURIComponent(alertId)}`,
4195
+ triageData,
3921
4196
  { ...this.#reqOptions, hooks: this.#hooks }
3922
4197
  )
3923
4198
  )
@@ -3928,21 +4203,19 @@ var SocketSdk = class {
3928
4203
  }
3929
4204
  }
3930
4205
  /**
3931
- * Get organization's telemetry configuration.
3932
- * Returns whether telemetry is enabled for the organization.
3933
- *
3934
- * @param orgSlug - Organization identifier
3935
- * @returns Telemetry configuration with enabled status
4206
+ * Update organization's license policy configuration.* Modifies allowed, restricted, and monitored license types.
3936
4207
  *
3937
4208
  * @throws {Error} When server returns 5xx status codes
3938
4209
  */
3939
- async getOrgTelemetryConfig(orgSlug) {
4210
+ async updateOrgLicensePolicy(orgSlug, policyData, queryParams) {
3940
4211
  try {
3941
4212
  const data = await this.#executeWithRetry(
3942
4213
  async () => await getResponseJson(
3943
- await createGetRequest(
4214
+ await createRequestWithJson(
4215
+ "POST",
3944
4216
  this.#baseUrl,
3945
- `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
4217
+ `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy?${queryToSearchParams(queryParams)}`,
4218
+ policyData,
3946
4219
  { ...this.#reqOptions, hooks: this.#hooks }
3947
4220
  )
3948
4221
  )
@@ -3953,58 +4226,47 @@ var SocketSdk = class {
3953
4226
  }
3954
4227
  }
3955
4228
  /**
3956
- * Post telemetry data for an organization.
3957
- * Sends telemetry events and analytics data for monitoring and analysis.
3958
- *
3959
- * @param orgSlug - Organization identifier
3960
- * @param telemetryData - Telemetry payload containing events and metrics
3961
- * @returns Empty object on successful submission
4229
+ * Update organization's security policy configuration.* Modifies alert rules, severity thresholds, and enforcement settings.
3962
4230
  *
3963
4231
  * @throws {Error} When server returns 5xx status codes
3964
4232
  */
3965
- async postOrgTelemetry(orgSlug, telemetryData) {
4233
+ async updateOrgSecurityPolicy(orgSlug, policyData) {
3966
4234
  try {
3967
4235
  const data = await this.#executeWithRetry(
3968
4236
  async () => await getResponseJson(
3969
4237
  await createRequestWithJson(
3970
4238
  "POST",
3971
4239
  this.#baseUrl,
3972
- `orgs/${encodeURIComponent(orgSlug)}/telemetry`,
3973
- telemetryData,
4240
+ `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
4241
+ policyData,
3974
4242
  { ...this.#reqOptions, hooks: this.#hooks }
3975
4243
  )
3976
4244
  )
3977
4245
  );
3978
- return {
3979
- cause: void 0,
3980
- data,
3981
- error: void 0,
3982
- status: 200,
3983
- success: true
3984
- };
4246
+ return this.#handleApiSuccess(data);
3985
4247
  } catch (e) {
3986
- return this.#createQueryErrorResult(e);
4248
+ return await this.#handleApiError(e);
3987
4249
  }
3988
4250
  }
3989
4251
  /**
3990
- * Create a new webhook for an organization.
3991
- * Webhooks allow you to receive HTTP POST notifications when specific events occur.
4252
+ * Update organization's telemetry configuration.
4253
+ * Enables or disables telemetry for the organization.
3992
4254
  *
3993
4255
  * @param orgSlug - Organization identifier
3994
- * @param webhookData - Webhook configuration including name, URL, secret, and events
3995
- * @returns Created webhook details including webhook ID
4256
+ * @param telemetryData - Telemetry configuration with enabled flag
4257
+ * @returns Updated telemetry configuration
3996
4258
  *
3997
4259
  * @throws {Error} When server returns 5xx status codes
3998
4260
  */
3999
- async createOrgWebhook(orgSlug, webhookData) {
4261
+ async updateOrgTelemetryConfig(orgSlug, telemetryData) {
4000
4262
  try {
4001
4263
  const data = await this.#executeWithRetry(
4002
4264
  async () => await getResponseJson(
4003
4265
  await createRequestWithJson(
4004
- "POST",
4266
+ "PUT",
4005
4267
  this.#baseUrl,
4006
- `orgs/${encodeURIComponent(orgSlug)}/webhooks`,
4007
- webhookData,
4268
+ `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
4269
+ telemetryData,
4008
4270
  { ...this.#reqOptions, hooks: this.#hooks }
4009
4271
  )
4010
4272
  )
@@ -4015,22 +4277,25 @@ var SocketSdk = class {
4015
4277
  }
4016
4278
  }
4017
4279
  /**
4018
- * Delete a webhook from an organization.
4019
- * This will stop all future webhook deliveries to the webhook URL.
4280
+ * Update an existing webhook's configuration.
4281
+ * All fields are optional - only provided fields will be updated.
4020
4282
  *
4021
4283
  * @param orgSlug - Organization identifier
4022
- * @param webhookId - Webhook ID to delete
4023
- * @returns Success status
4284
+ * @param webhookId - Webhook ID to update
4285
+ * @param webhookData - Updated webhook configuration
4286
+ * @returns Updated webhook details
4024
4287
  *
4025
4288
  * @throws {Error} When server returns 5xx status codes
4026
4289
  */
4027
- async deleteOrgWebhook(orgSlug, webhookId) {
4290
+ async updateOrgWebhook(orgSlug, webhookId, webhookData) {
4028
4291
  try {
4029
4292
  const data = await this.#executeWithRetry(
4030
4293
  async () => await getResponseJson(
4031
- await createDeleteRequest(
4294
+ await createRequestWithJson(
4295
+ "PUT",
4032
4296
  this.#baseUrl,
4033
4297
  `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
4298
+ webhookData,
4034
4299
  { ...this.#reqOptions, hooks: this.#hooks }
4035
4300
  )
4036
4301
  )
@@ -4041,86 +4306,230 @@ var SocketSdk = class {
4041
4306
  }
4042
4307
  }
4043
4308
  /**
4044
- * Get details of a specific webhook.
4045
- * Returns webhook configuration including events, URL, and filters.
4309
+ * Update configuration for a repository.
4310
+ *
4311
+ * Modifies monitoring settings, branch configuration, and scan preferences.
4046
4312
  *
4047
4313
  * @param orgSlug - Organization identifier
4048
- * @param webhookId - Webhook ID to retrieve
4049
- * @returns Webhook details
4314
+ * @param repoSlug - Repository slug/name
4315
+ * @param params - Configuration updates (description, homepage, default_branch, etc.)
4316
+ * @param options - Optional parameters including workspace
4317
+ * @returns Updated repository details
4318
+ *
4319
+ * @example
4320
+ * ```typescript
4321
+ * const result = await sdk.updateRepository('my-org', 'my-repo', {
4322
+ * description: 'Updated description',
4323
+ * default_branch: 'develop'
4324
+ * })
4050
4325
  *
4326
+ * if (result.success) {
4327
+ * console.log('Repository updated:', result.data.name)
4328
+ * }
4329
+ * ```
4330
+ *
4331
+ * @see https://docs.socket.dev/reference/updateorgrepo
4332
+ * @apiEndpoint POST /orgs/{org_slug}/repos/{repo_slug}
4333
+ * @quota 0 units
4334
+ * @scopes repo:write
4051
4335
  * @throws {Error} When server returns 5xx status codes
4052
4336
  */
4053
- async getOrgWebhook(orgSlug, webhookId) {
4337
+ async updateRepository(orgSlug, repoSlug, params, options) {
4338
+ const { workspace } = {
4339
+ __proto__: null,
4340
+ ...options
4341
+ };
4342
+ const queryString = workspace ? `?${queryToSearchParams({ workspace })}` : "";
4054
4343
  try {
4055
4344
  const data = await this.#executeWithRetry(
4056
4345
  async () => await getResponseJson(
4057
- await createGetRequest(
4346
+ await createRequestWithJson(
4347
+ "POST",
4058
4348
  this.#baseUrl,
4059
- `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
4349
+ `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}${queryString}`,
4350
+ params,
4060
4351
  { ...this.#reqOptions, hooks: this.#hooks }
4061
4352
  )
4062
4353
  )
4063
4354
  );
4064
- return this.#handleApiSuccess(data);
4355
+ return {
4356
+ cause: void 0,
4357
+ data,
4358
+ error: void 0,
4359
+ status: 200,
4360
+ success: true
4361
+ };
4065
4362
  } catch (e) {
4066
- return await this.#handleApiError(e);
4363
+ const errorResult = await this.#handleApiError(e);
4364
+ return {
4365
+ cause: errorResult.cause,
4366
+ data: void 0,
4367
+ error: errorResult.error,
4368
+ status: errorResult.status,
4369
+ success: false
4370
+ };
4067
4371
  }
4068
4372
  }
4069
4373
  /**
4070
- * List all webhooks for an organization.
4071
- * Supports pagination and sorting options.
4374
+ * Update a repository label for an organization.
4375
+ *
4376
+ * Modifies label properties like name. Label names must be non-empty and less than 1000 characters.
4072
4377
  *
4073
4378
  * @param orgSlug - Organization identifier
4074
- * @param options - Optional query parameters for pagination and sorting
4075
- * @returns List of webhooks with pagination info
4379
+ * @param labelId - Label identifier
4380
+ * @param labelData - Label updates (typically name property)
4381
+ * @returns Updated label with guaranteed id and name fields
4382
+ *
4383
+ * @example
4384
+ * ```typescript
4385
+ * const result = await sdk.updateRepositoryLabel('my-org', 'label-id-123', { name: 'staging' })
4076
4386
  *
4387
+ * if (result.success) {
4388
+ * console.log('Label updated:', result.data.name)
4389
+ * console.log('Label ID:', result.data.id)
4390
+ * }
4391
+ * ```
4392
+ *
4393
+ * @see https://docs.socket.dev/reference/updateorgrepolabel
4394
+ * @apiEndpoint PUT /orgs/{org_slug}/repos/labels/{label_id}
4395
+ * @quota 0 units
4396
+ * @scopes repo-label:update
4077
4397
  * @throws {Error} When server returns 5xx status codes
4078
4398
  */
4079
- async getOrgWebhooksList(orgSlug, options) {
4399
+ async updateRepositoryLabel(orgSlug, labelId, labelData) {
4080
4400
  try {
4081
4401
  const data = await this.#executeWithRetry(
4082
4402
  async () => await getResponseJson(
4083
- await createGetRequest(
4403
+ await createRequestWithJson(
4404
+ "PUT",
4084
4405
  this.#baseUrl,
4085
- `orgs/${encodeURIComponent(orgSlug)}/webhooks?${queryToSearchParams(options)}`,
4406
+ `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
4407
+ labelData,
4086
4408
  { ...this.#reqOptions, hooks: this.#hooks }
4087
4409
  )
4088
4410
  )
4089
4411
  );
4090
- return this.#handleApiSuccess(data);
4412
+ return {
4413
+ cause: void 0,
4414
+ data,
4415
+ error: void 0,
4416
+ status: 200,
4417
+ success: true
4418
+ };
4091
4419
  } catch (e) {
4092
- return await this.#handleApiError(e);
4420
+ const errorResult = await this.#handleApiError(e);
4421
+ return {
4422
+ cause: errorResult.cause,
4423
+ data: void 0,
4424
+ error: errorResult.error,
4425
+ status: errorResult.status,
4426
+ success: false
4427
+ };
4093
4428
  }
4094
4429
  }
4095
4430
  /**
4096
- * Update an existing webhook's configuration.
4097
- * All fields are optional - only provided fields will be updated.
4098
- *
4099
- * @param orgSlug - Organization identifier
4100
- * @param webhookId - Webhook ID to update
4101
- * @param webhookData - Updated webhook configuration
4102
- * @returns Updated webhook details
4431
+ * Upload manifest files for dependency analysis.
4432
+ * Processes package files to create dependency snapshots and security analysis.
4103
4433
  *
4104
4434
  * @throws {Error} When server returns 5xx status codes
4105
4435
  */
4106
- async updateOrgWebhook(orgSlug, webhookId, webhookData) {
4436
+ async uploadManifestFiles(orgSlug, filepaths, options) {
4437
+ const { pathsRelativeTo = "." } = {
4438
+ __proto__: null,
4439
+ ...options
4440
+ };
4441
+ const basePath = resolveBasePath(pathsRelativeTo);
4442
+ const absFilepaths = resolveAbsPaths(filepaths, basePath);
4443
+ const { invalidPaths, validPaths } = (0, import_fs.validateFiles)(absFilepaths);
4444
+ if (this.#onFileValidation && invalidPaths.length > 0) {
4445
+ const result = await this.#onFileValidation(validPaths, invalidPaths, {
4446
+ operation: "uploadManifestFiles",
4447
+ orgSlug
4448
+ });
4449
+ if (!result.shouldContinue) {
4450
+ const errorMsg = result.errorMessage ?? "File validation failed";
4451
+ const finalCause = filterRedundantCause(errorMsg, result.errorCause);
4452
+ return {
4453
+ error: errorMsg,
4454
+ status: 400,
4455
+ success: false,
4456
+ ...finalCause ? { cause: finalCause } : {}
4457
+ };
4458
+ }
4459
+ }
4460
+ if (!this.#onFileValidation && invalidPaths.length > 0) {
4461
+ const samplePaths = invalidPaths.slice(0, 3).join("\n - ");
4462
+ const remaining = invalidPaths.length > 3 ? `
4463
+ ... and ${invalidPaths.length - 3} more` : "";
4464
+ console.warn(
4465
+ `Warning: ${invalidPaths.length} files skipped (unreadable):
4466
+ - ${samplePaths}${remaining}
4467
+ \u2192 This may occur with Yarn Berry PnP or pnpm symlinks.
4468
+ \u2192 Try: Run installation command to ensure files are accessible.`
4469
+ );
4470
+ }
4471
+ if (validPaths.length === 0) {
4472
+ const samplePaths = invalidPaths.slice(0, 5).join("\n - ");
4473
+ const remaining = invalidPaths.length > 5 ? `
4474
+ ... and ${invalidPaths.length - 5} more` : "";
4475
+ return {
4476
+ cause: [
4477
+ `All ${invalidPaths.length} files failed validation:`,
4478
+ ` - ${samplePaths}${remaining}`,
4479
+ "",
4480
+ "\u2192 Common causes:",
4481
+ " \xB7Yarn Berry PnP virtual filesystem (files are not on disk)",
4482
+ " \xB7pnpm symlinks pointing to inaccessible locations",
4483
+ " \xB7Incorrect file permissions",
4484
+ " \xB7Files were deleted after discovery",
4485
+ "",
4486
+ "\u2192 Solutions:",
4487
+ " \xB7Yarn Berry: Use `nodeLinker: node-modules` in .yarnrc.yml",
4488
+ " \xB7pnpm: Use `node-linker=hoisted` in .npmrc",
4489
+ " \xB7Check file permissions with: ls -la <file>",
4490
+ " \xB7Run package manager install command"
4491
+ ].join("\n"),
4492
+ error: "No readable manifest files found",
4493
+ status: 400,
4494
+ success: false
4495
+ };
4496
+ }
4107
4497
  try {
4108
4498
  const data = await this.#executeWithRetry(
4109
4499
  async () => await getResponseJson(
4110
- await createRequestWithJson(
4111
- "PUT",
4500
+ await createUploadRequest(
4112
4501
  this.#baseUrl,
4113
- `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
4114
- webhookData,
4502
+ `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`,
4503
+ createRequestBodyForFilepaths(validPaths, basePath),
4115
4504
  { ...this.#reqOptions, hooks: this.#hooks }
4116
4505
  )
4117
4506
  )
4118
4507
  );
4119
- return this.#handleApiSuccess(data);
4508
+ return this.#handleApiSuccess(
4509
+ data
4510
+ );
4120
4511
  } catch (e) {
4121
- return await this.#handleApiError(e);
4512
+ return await this.#handleApiError(
4513
+ e
4514
+ );
4122
4515
  }
4123
4516
  }
4517
+ /**
4518
+ * View detailed information about a specific patch by its UUID.
4519
+ *
4520
+ * This method retrieves comprehensive patch details including files,
4521
+ * vulnerabilities, description, license, and tier information.
4522
+ */
4523
+ async viewPatch(orgSlug, uuid) {
4524
+ const data = await getResponseJson(
4525
+ await createGetRequest(
4526
+ this.#baseUrl,
4527
+ `orgs/${encodeURIComponent(orgSlug)}/patches/view/${encodeURIComponent(uuid)}`,
4528
+ { ...this.#reqOptions, hooks: this.#hooks }
4529
+ )
4530
+ );
4531
+ return data;
4532
+ }
4124
4533
  };
4125
4534
  if ((0, import_debug2.isDebugNs)("heap")) {
4126
4535
  const used = process.memoryUsage();