@socketsecurity/sdk 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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.0",
75
+ packageManager: "pnpm@10.28.1",
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.5.3",
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.51.4",
141
141
  "@eslint/compat": "1.3.2",
142
142
  "@eslint/js": "9.35.0",
143
143
  "@types/babel__traverse": "7.28.0",
144
144
  "@types/node": "24.9.2",
145
145
  "@typescript/native-preview": "7.0.0-dev.20250926.1",
146
146
  "@vitest/coverage-v8": "4.0.3",
147
+ "@sveltejs/acorn-typescript": "1.0.8",
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",
@@ -335,6 +337,40 @@ var publicPolicy = /* @__PURE__ */ new Map([
335
337
  var import_node_path = __toESM(require("node:path"));
336
338
  var import_memoization = require("@socketsecurity/lib/memoization");
337
339
  var import_normalize = require("@socketsecurity/lib/paths/normalize");
340
+ function normalizeToWordSet(s) {
341
+ const words = s.toLowerCase().match(/\w+/g);
342
+ return new Set(words ?? []);
343
+ }
344
+ function calculateWordSetSimilarity(str1, str2) {
345
+ const set1 = normalizeToWordSet(str1);
346
+ const set2 = normalizeToWordSet(str2);
347
+ if (set1.size === 0 && set2.size === 0) {
348
+ return 1;
349
+ }
350
+ if (set1.size === 0 || set2.size === 0) {
351
+ return 0;
352
+ }
353
+ let intersectionSize = 0;
354
+ for (const word of set1) {
355
+ if (set2.has(word)) {
356
+ intersectionSize++;
357
+ }
358
+ }
359
+ const unionSize = set1.size + set2.size - intersectionSize;
360
+ return intersectionSize / unionSize;
361
+ }
362
+ function filterRedundantCause(errorMessage, errorCause, threshold = 0.6) {
363
+ if (!errorCause || !errorCause.trim()) {
364
+ return void 0;
365
+ }
366
+ const messageParts = errorMessage.split(":").map((part) => part.trim());
367
+ for (const part of messageParts) {
368
+ if (part && shouldOmitReason(part, errorCause, threshold)) {
369
+ return void 0;
370
+ }
371
+ }
372
+ return errorCause;
373
+ }
338
374
  var normalizeBaseUrl = (0, import_memoization.memoize)(
339
375
  (baseUrl) => {
340
376
  return baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
@@ -379,28 +415,6 @@ function resolveAbsPaths(filepaths, pathsRelativeTo) {
379
415
  function resolveBasePath(pathsRelativeTo = ".") {
380
416
  return (0, import_normalize.normalizePath)(import_node_path.default.resolve(process.cwd(), pathsRelativeTo));
381
417
  }
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
418
  function shouldOmitReason(errorMessage, reason, threshold = 0.6) {
405
419
  if (!reason || !reason.trim()) {
406
420
  return true;
@@ -408,18 +422,6 @@ function shouldOmitReason(errorMessage, reason, threshold = 0.6) {
408
422
  const similarity = calculateWordSetSimilarity(errorMessage, reason);
409
423
  return similarity >= threshold;
410
424
  }
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
425
 
424
426
  // src/file-upload.ts
425
427
  var import_node_fs = require("node:fs");
@@ -1506,6 +1508,83 @@ var SocketSdk = class {
1506
1508
  }
1507
1509
  return void 0;
1508
1510
  }
1511
+ /**
1512
+ * Get package metadata and alerts by PURL strings for a specific organization.
1513
+ * Organization-scoped version of batchPackageFetch with security policy label support.
1514
+ *
1515
+ * @param orgSlug - Organization identifier
1516
+ * @param componentsObj - Object containing array of components with PURL strings
1517
+ * @param queryParams - Optional query parameters including labels, alerts, compact, etc.
1518
+ * @returns Package metadata and alerts for the requested PURLs
1519
+ *
1520
+ * @example
1521
+ * ```typescript
1522
+ * const result = await sdk.batchOrgPackageFetch('my-org',
1523
+ * {
1524
+ * components: [
1525
+ * { purl: 'pkg:npm/express@4.19.2' },
1526
+ * { purl: 'pkg:pypi/django@5.0.6' }
1527
+ * ]
1528
+ * },
1529
+ * { labels: ['production'], alerts: true }
1530
+ * )
1531
+ *
1532
+ * if (result.success) {
1533
+ * for (const artifact of result.data) {
1534
+ * console.log(`${artifact.name}@${artifact.version}`)
1535
+ * }
1536
+ * }
1537
+ * ```
1538
+ *
1539
+ * @see https://docs.socket.dev/reference/batchpackagefetchbyorg
1540
+ * @apiEndpoint POST /orgs/{org_slug}/purl
1541
+ * @quota 100 units
1542
+ * @scopes packages:list
1543
+ * @throws {Error} When server returns 5xx status codes
1544
+ */
1545
+ async batchOrgPackageFetch(orgSlug, componentsObj, queryParams) {
1546
+ let res;
1547
+ try {
1548
+ const req = getHttpModule(this.#baseUrl).request(
1549
+ `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/purl?${queryToSearchParams(queryParams)}`,
1550
+ {
1551
+ method: "POST",
1552
+ ...this.#reqOptions
1553
+ }
1554
+ ).end(JSON.stringify(componentsObj));
1555
+ res = await getResponse(req);
1556
+ if (!isResponseOk(res)) {
1557
+ throw new ResponseError(res);
1558
+ }
1559
+ } catch (e) {
1560
+ return await this.#handleApiError(e);
1561
+ }
1562
+ if (!res) {
1563
+ throw new Error("Failed to get response from batch PURL request");
1564
+ }
1565
+ const rli = import_node_readline.default.createInterface({
1566
+ input: res,
1567
+ crlfDelay: Number.POSITIVE_INFINITY,
1568
+ signal: abortSignal
1569
+ });
1570
+ const results = [];
1571
+ for await (const line of rli) {
1572
+ const trimmed = line.trim();
1573
+ const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
1574
+ /* c8 ignore next - Empty line handling in batch parsing. */
1575
+ null
1576
+ );
1577
+ if ((0, import_objects.isObjectObject)(artifact)) {
1578
+ results.push(artifact);
1579
+ }
1580
+ }
1581
+ const compact = (0, import_url.urlSearchParamAsBoolean)(
1582
+ (0, import_objects.getOwn)(queryParams, "compact")
1583
+ );
1584
+ return this.#handleApiSuccess(
1585
+ compact ? results : results
1586
+ );
1587
+ }
1509
1588
  /**
1510
1589
  * Fetch package analysis data for multiple packages in a single batch request.
1511
1590
  * Returns all results at once after processing is complete.
@@ -1708,30 +1787,6 @@ var SocketSdk = class {
1708
1787
  return await this.#handleApiError(e);
1709
1788
  }
1710
1789
  }
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
1790
  /**
1736
1791
  * Create a full security scan for an organization.
1737
1792
  *
@@ -1859,6 +1914,87 @@ var SocketSdk = class {
1859
1914
  };
1860
1915
  }
1861
1916
  }
1917
+ /**
1918
+ * Create a diff scan from two full scan IDs.
1919
+ * Compares two existing full scans to identify changes.
1920
+ *
1921
+ * @throws {Error} When server returns 5xx status codes
1922
+ */
1923
+ async createOrgDiffScanFromIds(orgSlug, queryParams) {
1924
+ try {
1925
+ const data = await this.#executeWithRetry(
1926
+ async () => await getResponseJson(
1927
+ await createRequestWithJson(
1928
+ "POST",
1929
+ this.#baseUrl,
1930
+ `orgs/${encodeURIComponent(orgSlug)}/diff-scans?${queryToSearchParams(queryParams)}`,
1931
+ {},
1932
+ { ...this.#reqOptions, hooks: this.#hooks }
1933
+ )
1934
+ )
1935
+ );
1936
+ return this.#handleApiSuccess(data);
1937
+ } catch (e) {
1938
+ return await this.#handleApiError(e);
1939
+ }
1940
+ }
1941
+ /**
1942
+ * Create a full scan from an archive file (.tar, .tar.gz/.tgz, or .zip).
1943
+ * Uploads and scans a compressed archive of project files.
1944
+ *
1945
+ * @param orgSlug - Organization identifier
1946
+ * @param archivePath - Path to the archive file to upload
1947
+ * @param options - Scan configuration options including repo, branch, and metadata
1948
+ * @returns Created full scan details with scan ID and status
1949
+ *
1950
+ * @throws {Error} When server returns 5xx status codes or file cannot be read
1951
+ */
1952
+ async createOrgFullScanFromArchive(orgSlug, archivePath, options) {
1953
+ const basePath = import_node_path4.default.dirname(archivePath);
1954
+ try {
1955
+ const data = await this.#executeWithRetry(
1956
+ async () => await getResponseJson(
1957
+ await createUploadRequest(
1958
+ this.#baseUrl,
1959
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/archive?${queryToSearchParams(options)}`,
1960
+ createRequestBodyForFilepaths([archivePath], basePath),
1961
+ { ...this.#reqOptions, hooks: this.#hooks }
1962
+ )
1963
+ )
1964
+ );
1965
+ return this.#handleApiSuccess(data);
1966
+ } catch (e) {
1967
+ return await this.#handleApiError(e);
1968
+ }
1969
+ }
1970
+ /**
1971
+ * Create a new webhook for an organization.
1972
+ * Webhooks allow you to receive HTTP POST notifications when specific events occur.
1973
+ *
1974
+ * @param orgSlug - Organization identifier
1975
+ * @param webhookData - Webhook configuration including name, URL, secret, and events
1976
+ * @returns Created webhook details including webhook ID
1977
+ *
1978
+ * @throws {Error} When server returns 5xx status codes
1979
+ */
1980
+ async createOrgWebhook(orgSlug, webhookData) {
1981
+ try {
1982
+ const data = await this.#executeWithRetry(
1983
+ async () => await getResponseJson(
1984
+ await createRequestWithJson(
1985
+ "POST",
1986
+ this.#baseUrl,
1987
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks`,
1988
+ webhookData,
1989
+ { ...this.#reqOptions, hooks: this.#hooks }
1990
+ )
1991
+ )
1992
+ );
1993
+ return this.#handleApiSuccess(data);
1994
+ } catch (e) {
1995
+ return await this.#handleApiError(e);
1996
+ }
1997
+ }
1862
1998
  /**
1863
1999
  * Create a new repository in an organization.
1864
2000
  *
@@ -1975,32 +2111,56 @@ var SocketSdk = class {
1975
2111
  }
1976
2112
  }
1977
2113
  /**
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.
2114
+ * Delete a full scan from an organization.
2115
+ *
2116
+ * Permanently removes scan data and results.
1980
2117
  *
1981
2118
  * @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
2119
+ * @param scanId - Full scan identifier to delete
2120
+ * @returns Success confirmation
1985
2121
  *
1986
- * @throws {Error} When server returns 5xx status codes or file cannot be read
2122
+ * @example
2123
+ * ```typescript
2124
+ * const result = await sdk.deleteFullScan('my-org', 'scan_123')
2125
+ *
2126
+ * if (result.success) {
2127
+ * console.log('Scan deleted successfully')
2128
+ * }
2129
+ * ```
2130
+ *
2131
+ * @see https://docs.socket.dev/reference/deleteorgfullscan
2132
+ * @apiEndpoint DELETE /orgs/{org_slug}/full-scans/{full_scan_id}
2133
+ * @quota 1 unit
2134
+ * @scopes full-scans:delete
2135
+ * @throws {Error} When server returns 5xx status codes
1987
2136
  */
1988
- async createOrgFullScanFromArchive(orgSlug, archivePath, options) {
1989
- const basePath = import_node_path4.default.dirname(archivePath);
2137
+ async deleteFullScan(orgSlug, scanId) {
1990
2138
  try {
1991
2139
  const data = await this.#executeWithRetry(
1992
2140
  async () => await getResponseJson(
1993
- await createUploadRequest(
2141
+ await createDeleteRequest(
1994
2142
  this.#baseUrl,
1995
- `orgs/${encodeURIComponent(orgSlug)}/full-scans/archive?${queryToSearchParams(options)}`,
1996
- createRequestBodyForFilepaths([archivePath], basePath),
2143
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
1997
2144
  { ...this.#reqOptions, hooks: this.#hooks }
1998
2145
  )
1999
2146
  )
2000
2147
  );
2001
- return this.#handleApiSuccess(data);
2148
+ return {
2149
+ cause: void 0,
2150
+ data,
2151
+ error: void 0,
2152
+ status: 200,
2153
+ success: true
2154
+ };
2002
2155
  } catch (e) {
2003
- return await this.#handleApiError(e);
2156
+ const errorResult = await this.#handleApiError(e);
2157
+ return {
2158
+ cause: errorResult.cause,
2159
+ data: void 0,
2160
+ error: errorResult.error,
2161
+ status: errorResult.status,
2162
+ success: false
2163
+ };
2004
2164
  }
2005
2165
  }
2006
2166
  /**
@@ -2026,56 +2186,29 @@ var SocketSdk = class {
2026
2186
  }
2027
2187
  }
2028
2188
  /**
2029
- * Delete a full scan from an organization.
2030
- *
2031
- * Permanently removes scan data and results.
2189
+ * Delete a webhook from an organization.
2190
+ * This will stop all future webhook deliveries to the webhook URL.
2032
2191
  *
2033
2192
  * @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
- * ```
2193
+ * @param webhookId - Webhook ID to delete
2194
+ * @returns Success status
2045
2195
  *
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
2196
  * @throws {Error} When server returns 5xx status codes
2051
2197
  */
2052
- async deleteFullScan(orgSlug, scanId) {
2198
+ async deleteOrgWebhook(orgSlug, webhookId) {
2053
2199
  try {
2054
2200
  const data = await this.#executeWithRetry(
2055
2201
  async () => await getResponseJson(
2056
2202
  await createDeleteRequest(
2057
2203
  this.#baseUrl,
2058
- `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
2204
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
2059
2205
  { ...this.#reqOptions, hooks: this.#hooks }
2060
2206
  )
2061
2207
  )
2062
2208
  );
2063
- return {
2064
- cause: void 0,
2065
- data,
2066
- error: void 0,
2067
- status: 200,
2068
- success: true
2069
- };
2209
+ return this.#handleApiSuccess(data);
2070
2210
  } 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
- };
2211
+ return await this.#handleApiError(e);
2079
2212
  }
2080
2213
  }
2081
2214
  /**
@@ -2085,6 +2218,7 @@ var SocketSdk = class {
2085
2218
  *
2086
2219
  * @param orgSlug - Organization identifier
2087
2220
  * @param repoSlug - Repository slug/name to delete
2221
+ * @param options - Optional parameters including workspace
2088
2222
  * @returns Success confirmation
2089
2223
  *
2090
2224
  * @example
@@ -2102,13 +2236,18 @@ var SocketSdk = class {
2102
2236
  * @scopes repo:write
2103
2237
  * @throws {Error} When server returns 5xx status codes
2104
2238
  */
2105
- async deleteRepository(orgSlug, repoSlug) {
2239
+ async deleteRepository(orgSlug, repoSlug, options) {
2240
+ const { workspace } = {
2241
+ __proto__: null,
2242
+ ...options
2243
+ };
2244
+ const queryString = workspace ? `?${queryToSearchParams({ workspace })}` : "";
2106
2245
  try {
2107
2246
  const data = await this.#executeWithRetry(
2108
2247
  async () => await getResponseJson(
2109
2248
  await createDeleteRequest(
2110
2249
  this.#baseUrl,
2111
- `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`,
2250
+ `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}${queryString}`,
2112
2251
  { ...this.#reqOptions, hooks: this.#hooks }
2113
2252
  )
2114
2253
  )
@@ -2185,7 +2324,160 @@ var SocketSdk = class {
2185
2324
  }
2186
2325
  }
2187
2326
  /**
2188
- * Delete a legacy scan report permanently.
2327
+ * Delete a legacy scan report permanently.
2328
+
2329
+ /**
2330
+ * Download patch file content by hash.
2331
+ *
2332
+ * Downloads the actual patched file content from the public Socket blob store.
2333
+ * This is used after calling viewPatch() to get the patch metadata.
2334
+ * No authentication is required as patch blobs are publicly accessible.
2335
+ *
2336
+ * @param hash - The blob hash in SSRI (sha256-base64) or hex format
2337
+ * @param options - Optional configuration
2338
+ * @param options.baseUrl - Override blob store URL (for testing)
2339
+ * @returns Promise<string> - The patch file content as UTF-8 string
2340
+ * @throws Error if blob not found (404) or download fails
2341
+ *
2342
+ * @example
2343
+ * ```typescript
2344
+ * const sdk = new SocketSdk('your-api-token')
2345
+ * // First get patch metadata
2346
+ * const patch = await sdk.viewPatch('my-org', 'patch-uuid')
2347
+ * // Then download the actual patched file
2348
+ * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
2349
+ * ```
2350
+ */
2351
+ async downloadOrgFullScanFilesAsTar(orgSlug, fullScanId, outputPath) {
2352
+ try {
2353
+ const req = getHttpModule(this.#baseUrl).request(
2354
+ `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/files.tar`,
2355
+ {
2356
+ method: "GET",
2357
+ ...this.#reqOptions
2358
+ }
2359
+ ).end();
2360
+ const res = await getResponse(req);
2361
+ if (!isResponseOk(res)) {
2362
+ throw new ResponseError(res);
2363
+ }
2364
+ const writeStream = (0, import_node_fs3.createWriteStream)(outputPath);
2365
+ let bytesWritten = 0;
2366
+ res.on("data", (chunk) => {
2367
+ bytesWritten += chunk.length;
2368
+ if (bytesWritten > MAX_STREAM_SIZE) {
2369
+ res.destroy();
2370
+ writeStream.destroy();
2371
+ throw new Error(
2372
+ `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
2373
+ );
2374
+ }
2375
+ });
2376
+ res.pipe(writeStream);
2377
+ writeStream.on("error", (error) => {
2378
+ throw new Error(`Failed to write to file: ${outputPath}`, {
2379
+ cause: error
2380
+ });
2381
+ });
2382
+ await import_node_events.default.once(writeStream, "finish");
2383
+ return this.#handleApiSuccess(res);
2384
+ } catch (e) {
2385
+ return await this.#handleApiError(e);
2386
+ }
2387
+ }
2388
+ /**
2389
+ * Download patch file content from Socket blob storage.
2390
+ * Retrieves patched file contents using SSRI hash or hex hash.
2391
+ *
2392
+ * This is a low-level utility method - you'll typically use this after calling
2393
+ * `viewPatch()` to get patch metadata, then download individual patched files.
2394
+ *
2395
+ * @param hash - The blob hash in SSRI (sha256-base64) or hex format
2396
+ * @param options - Optional configuration
2397
+ * @param options.baseUrl - Override blob store URL (for testing)
2398
+ * @returns Promise<string> - The patch file content as UTF-8 string
2399
+ * @throws Error if blob not found (404) or download fails
2400
+ *
2401
+ * @example
2402
+ * ```typescript
2403
+ * const sdk = new SocketSdk('your-api-token')
2404
+ * // First get patch metadata
2405
+ * const patch = await sdk.viewPatch('my-org', 'patch-uuid')
2406
+ * // Then download the actual patched file
2407
+ * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
2408
+ * ```
2409
+ */
2410
+ async downloadPatch(hash, options) {
2411
+ const https2 = await import("node:https");
2412
+ const http2 = await import("node:http");
2413
+ const blobPath = `/blob/${encodeURIComponent(hash)}`;
2414
+ const blobBaseUrl = options?.baseUrl || SOCKET_PUBLIC_BLOB_STORE_URL;
2415
+ const url = `${blobBaseUrl}${blobPath}`;
2416
+ const isHttps = url.startsWith("https:");
2417
+ return await new Promise((resolve, reject) => {
2418
+ const client = isHttps ? https2 : http2;
2419
+ client.get(url, (res) => {
2420
+ if (res.statusCode === 404) {
2421
+ const message = [
2422
+ `Blob not found: ${hash}`,
2423
+ `\u2192 URL: ${url}`,
2424
+ "\u2192 The patch file may have expired or the hash is incorrect.",
2425
+ "\u2192 Verify: The blob hash is correct.",
2426
+ "\u2192 Note: Blob URLs may expire after a certain time period."
2427
+ ].join("\n");
2428
+ reject(new Error(message));
2429
+ return;
2430
+ }
2431
+ if (res.statusCode !== 200) {
2432
+ const message = [
2433
+ `Failed to download blob: ${res.statusCode} ${res.statusMessage}`,
2434
+ `\u2192 Hash: ${hash}`,
2435
+ `\u2192 URL: ${url}`,
2436
+ "\u2192 The blob storage service may be temporarily unavailable.",
2437
+ res.statusCode && res.statusCode >= 500 ? "\u2192 Try: Retry the download after a short delay." : "\u2192 Verify: The blob hash and URL are correct."
2438
+ ].join("\n");
2439
+ reject(new Error(message));
2440
+ return;
2441
+ }
2442
+ let data = "";
2443
+ res.on("data", (chunk) => {
2444
+ data += chunk;
2445
+ });
2446
+ res.on("end", () => {
2447
+ resolve(data);
2448
+ });
2449
+ res.on("error", (err) => {
2450
+ reject(err);
2451
+ });
2452
+ }).on("error", (err) => {
2453
+ const nodeErr = err;
2454
+ const message = [
2455
+ `Error downloading blob: ${hash}`,
2456
+ `\u2192 URL: ${url}`,
2457
+ `\u2192 Network error: ${nodeErr.message}`
2458
+ ];
2459
+ if (nodeErr.code === "ENOTFOUND") {
2460
+ message.push(
2461
+ "\u2192 DNS lookup failed. Cannot resolve blob storage hostname.",
2462
+ "\u2192 Check: Internet connection and DNS settings."
2463
+ );
2464
+ } else if (nodeErr.code === "ECONNREFUSED") {
2465
+ message.push(
2466
+ "\u2192 Connection refused. Blob storage service is unreachable.",
2467
+ "\u2192 Check: Network connectivity and firewall settings."
2468
+ );
2469
+ } else if (nodeErr.code === "ETIMEDOUT") {
2470
+ message.push(
2471
+ "\u2192 Connection timed out.",
2472
+ "\u2192 Try: Check network connectivity and retry."
2473
+ );
2474
+ } else if (nodeErr.code) {
2475
+ message.push(`\u2192 Error code: ${nodeErr.code}`);
2476
+ }
2477
+ reject(new Error(message.join("\n"), { cause: err }));
2478
+ });
2479
+ });
2480
+ }
2189
2481
  /**
2190
2482
  * Export scan results in CycloneDX SBOM format.
2191
2483
  * Returns Software Bill of Materials compliant with CycloneDX standard.
@@ -2208,6 +2500,51 @@ var SocketSdk = class {
2208
2500
  return await this.#handleApiError(e);
2209
2501
  }
2210
2502
  }
2503
+ /**
2504
+ * Export vulnerability exploitability data as an OpenVEX v0.2.0 document.
2505
+ * Includes patch data and reachability analysis for vulnerability assessment.
2506
+ *
2507
+ * @param orgSlug - Organization identifier
2508
+ * @param id - Full scan or SBOM report ID
2509
+ * @param options - Optional parameters including author, role, and document_id
2510
+ * @returns OpenVEX document with vulnerability exploitability information
2511
+ *
2512
+ * @example
2513
+ * ```typescript
2514
+ * const result = await sdk.exportOpenVEX('my-org', 'scan-id', {
2515
+ * author: 'Security Team',
2516
+ * role: 'VEX Generator'
2517
+ * })
2518
+ *
2519
+ * if (result.success) {
2520
+ * console.log('VEX Version:', result.data.version)
2521
+ * console.log('Statements:', result.data.statements.length)
2522
+ * }
2523
+ * ```
2524
+ *
2525
+ * @see https://docs.socket.dev/reference/exportopenvex
2526
+ * @apiEndpoint GET /orgs/{org_slug}/export/openvex/{id}
2527
+ * @quota 1 unit
2528
+ * @scopes report:read
2529
+ * @throws {Error} When server returns 5xx status codes
2530
+ */
2531
+ async exportOpenVEX(orgSlug, id, options) {
2532
+ const queryString = options ? `?${queryToSearchParams(options)}` : "";
2533
+ try {
2534
+ const data = await this.#executeWithRetry(
2535
+ async () => await getResponseJson(
2536
+ await createGetRequest(
2537
+ this.#baseUrl,
2538
+ `orgs/${encodeURIComponent(orgSlug)}/export/openvex/${encodeURIComponent(id)}${queryString}`,
2539
+ { ...this.#reqOptions, hooks: this.#hooks }
2540
+ )
2541
+ )
2542
+ );
2543
+ return this.#handleApiSuccess(data);
2544
+ } catch (e) {
2545
+ return await this.#handleApiError(e);
2546
+ }
2547
+ }
2211
2548
  /**
2212
2549
  * Export scan results in SPDX SBOM format.
2213
2550
  * Returns Software Bill of Materials compliant with SPDX standard.
@@ -2398,110 +2735,42 @@ var SocketSdk = class {
2398
2735
  return data?.items || [];
2399
2736
  }
2400
2737
  /**
2401
- * Get security issues for a specific npm package and version.
2402
- * Returns detailed vulnerability and security alert information.
2738
+ * Get complete full scan results buffered in memory.
2739
+ *
2740
+ * Returns entire scan data as JSON for programmatic processing.
2741
+ * For large scans, consider using streamFullScan() instead.
2742
+ *
2743
+ * @param orgSlug - Organization identifier
2744
+ * @param scanId - Full scan identifier
2745
+ * @returns Complete full scan data including all artifacts
2746
+ *
2747
+ * @example
2748
+ * ```typescript
2749
+ * const result = await sdk.getFullScan('my-org', 'scan_123')
2750
+ *
2751
+ * if (result.success) {
2752
+ * console.log('Scan status:', result.data.scan_state)
2753
+ * console.log('Repository:', result.data.repository_slug)
2754
+ * }
2755
+ * ```
2403
2756
  *
2757
+ * @see https://docs.socket.dev/reference/getorgfullscan
2758
+ * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
2759
+ * @quota 1 unit
2760
+ * @scopes full-scans:list
2404
2761
  * @throws {Error} When server returns 5xx status codes
2405
2762
  */
2406
- async getIssuesByNpmPackage(pkgName, version) {
2763
+ async getFullScan(orgSlug, scanId) {
2407
2764
  try {
2408
2765
  const data = await this.#executeWithRetry(
2409
2766
  async () => await getResponseJson(
2410
2767
  await createGetRequest(
2411
2768
  this.#baseUrl,
2412
- `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/issues`,
2769
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
2413
2770
  { ...this.#reqOptions, hooks: this.#hooks }
2414
2771
  )
2415
2772
  )
2416
2773
  );
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.
2425
- *
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
2429
- *
2430
- * @throws {Error} When server returns 5xx status codes
2431
- */
2432
- async getOrgAlertsList(orgSlug, options) {
2433
- try {
2434
- const data = await this.#executeWithRetry(
2435
- async () => await getResponseJson(
2436
- await createGetRequest(
2437
- this.#baseUrl,
2438
- `orgs/${encodeURIComponent(orgSlug)}/alerts?${queryToSearchParams(options)}`,
2439
- { ...this.#reqOptions, hooks: this.#hooks }
2440
- )
2441
- )
2442
- );
2443
- return this.#handleApiSuccess(data);
2444
- } catch (e) {
2445
- return await this.#handleApiError(e);
2446
- }
2447
- }
2448
- /**
2449
- * Get analytics data for organization usage patterns and security metrics.
2450
- * Returns statistical analysis for specified time period.
2451
- *
2452
- * @throws {Error} When server returns 5xx status codes
2453
- */
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
- )
2463
- )
2464
- );
2465
- return this.#handleApiSuccess(data);
2466
- } catch (e) {
2467
- return await this.#handleApiError(e);
2468
- }
2469
- }
2470
- /**
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
- * ```
2487
- *
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
2492
- */
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
2774
  return {
2506
2775
  cause: void 0,
2507
2776
  data,
@@ -2521,38 +2790,38 @@ var SocketSdk = class {
2521
2790
  }
2522
2791
  }
2523
2792
  /**
2524
- * Get complete full scan results buffered in memory.
2793
+ * Get metadata for a specific full scan.
2525
2794
  *
2526
- * Returns entire scan data as JSON for programmatic processing.
2527
- * For large scans, consider using streamFullScan() instead.
2795
+ * Returns scan configuration, status, and summary information without full artifact data.
2796
+ * Useful for checking scan status without downloading complete results.
2528
2797
  *
2529
2798
  * @param orgSlug - Organization identifier
2530
2799
  * @param scanId - Full scan identifier
2531
- * @returns Complete full scan data including all artifacts
2800
+ * @returns Scan metadata including status and configuration
2532
2801
  *
2533
2802
  * @example
2534
2803
  * ```typescript
2535
- * const result = await sdk.getFullScan('my-org', 'scan_123')
2804
+ * const result = await sdk.getFullScanMetadata('my-org', 'scan_123')
2536
2805
  *
2537
2806
  * if (result.success) {
2538
- * console.log('Scan status:', result.data.scan_state)
2539
- * console.log('Repository:', result.data.repository_slug)
2807
+ * console.log('Scan state:', result.data.scan_state)
2808
+ * console.log('Branch:', result.data.branch)
2540
2809
  * }
2541
2810
  * ```
2542
2811
  *
2543
- * @see https://docs.socket.dev/reference/getorgfullscan
2544
- * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
2812
+ * @see https://docs.socket.dev/reference/getorgfullscanmetadata
2813
+ * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}/metadata
2545
2814
  * @quota 1 unit
2546
2815
  * @scopes full-scans:list
2547
2816
  * @throws {Error} When server returns 5xx status codes
2548
2817
  */
2549
- async getFullScan(orgSlug, scanId) {
2818
+ async getFullScanMetadata(orgSlug, scanId) {
2550
2819
  try {
2551
2820
  const data = await this.#executeWithRetry(
2552
2821
  async () => await getResponseJson(
2553
2822
  await createGetRequest(
2554
2823
  this.#baseUrl,
2555
- `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
2824
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}/metadata`,
2556
2825
  { ...this.#reqOptions, hooks: this.#hooks }
2557
2826
  )
2558
2827
  )
@@ -2576,118 +2845,118 @@ var SocketSdk = class {
2576
2845
  }
2577
2846
  }
2578
2847
  /**
2579
- * List all full scans for an organization.
2848
+ * Get security issues for a specific npm package and version.
2849
+ * Returns detailed vulnerability and security alert information.
2580
2850
  *
2581
- * Returns paginated list of full scan metadata with guaranteed required fields
2582
- * for improved TypeScript autocomplete.
2851
+ * @throws {Error} When server returns 5xx status codes
2852
+ */
2853
+ async getIssuesByNpmPackage(pkgName, version) {
2854
+ try {
2855
+ const data = await this.#executeWithRetry(
2856
+ async () => await getResponseJson(
2857
+ await createGetRequest(
2858
+ this.#baseUrl,
2859
+ `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/issues`,
2860
+ { ...this.#reqOptions, hooks: this.#hooks }
2861
+ )
2862
+ )
2863
+ );
2864
+ return this.#handleApiSuccess(data);
2865
+ } catch (e) {
2866
+ return await this.#handleApiError(e);
2867
+ }
2868
+ }
2869
+ /**
2870
+ * List full scans associated with a specific alert.
2871
+ * Returns paginated full scan references for alert investigation.
2583
2872
  *
2584
2873
  * @param orgSlug - Organization identifier
2585
- * @param options - Filtering and pagination options
2586
- * @returns List of full scans with metadata
2874
+ * @param options - Query parameters including alertKey, range, pagination
2875
+ * @returns Paginated array of full scans associated with the alert
2587
2876
  *
2588
2877
  * @example
2589
2878
  * ```typescript
2590
- * const result = await sdk.listFullScans('my-org', {
2591
- * branch: 'main',
2592
- * per_page: 50,
2593
- * use_cursor: true
2879
+ * const result = await sdk.getOrgAlertFullScans('my-org', {
2880
+ * alertKey: 'npm/lodash/cve-2021-23337',
2881
+ * range: '-7d',
2882
+ * per_page: 50
2594
2883
  * })
2595
2884
  *
2596
2885
  * if (result.success) {
2597
- * result.data.results.forEach(scan => {
2598
- * console.log(scan.id, scan.created_at) // Guaranteed fields
2599
- * })
2886
+ * for (const item of result.data.items) {
2887
+ * console.log('Full Scan ID:', item.fullScanId)
2888
+ * }
2600
2889
  * }
2601
2890
  * ```
2602
2891
  *
2603
- * @see https://docs.socket.dev/reference/getorgfullscanlist
2604
- * @apiEndpoint GET /orgs/{org_slug}/full-scans
2605
- * @quota 1 unit
2606
- * @scopes full-scans:list
2892
+ * @see https://docs.socket.dev/reference/alertfullscans
2893
+ * @apiEndpoint GET /orgs/{org_slug}/alert-full-scan-search
2894
+ * @quota 10 units
2895
+ * @scopes alerts:list
2607
2896
  * @throws {Error} When server returns 5xx status codes
2608
2897
  */
2609
- async listFullScans(orgSlug, options) {
2898
+ async getOrgAlertFullScans(orgSlug, options) {
2610
2899
  try {
2611
2900
  const data = await this.#executeWithRetry(
2612
2901
  async () => await getResponseJson(
2613
2902
  await createGetRequest(
2614
2903
  this.#baseUrl,
2615
- `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(options)}`,
2904
+ `orgs/${encodeURIComponent(orgSlug)}/alert-full-scan-search?${queryToSearchParams(options)}`,
2616
2905
  { ...this.#reqOptions, hooks: this.#hooks }
2617
2906
  )
2618
2907
  )
2619
2908
  );
2620
- return {
2621
- cause: void 0,
2622
- data,
2623
- error: void 0,
2624
- status: 200,
2625
- success: true
2626
- };
2909
+ return this.#handleApiSuccess(data);
2627
2910
  } catch (e) {
2628
- const errorResult = await this.#handleApiError(e);
2629
- return {
2630
- cause: errorResult.cause,
2631
- data: void 0,
2632
- error: errorResult.error,
2633
- status: errorResult.status,
2634
- success: false
2635
- };
2911
+ return await this.#handleApiError(e);
2636
2912
  }
2637
2913
  }
2638
2914
  /**
2639
- * Get metadata for a specific full scan.
2640
- *
2641
- * Returns scan configuration, status, and summary information without full artifact data.
2642
- * Useful for checking scan status without downloading complete results.
2915
+ * List latest alerts for an organization (Beta).
2916
+ * Returns paginated alerts with comprehensive filtering options.
2643
2917
  *
2644
2918
  * @param orgSlug - Organization identifier
2645
- * @param scanId - Full scan identifier
2646
- * @returns Scan metadata including status and configuration
2647
- *
2648
- * @example
2649
- * ```typescript
2650
- * const result = await sdk.getFullScanMetadata('my-org', 'scan_123')
2919
+ * @param options - Optional query parameters for pagination and filtering
2920
+ * @returns Paginated list of alerts with cursor-based pagination
2651
2921
  *
2652
- * if (result.success) {
2653
- * console.log('Scan state:', result.data.scan_state)
2654
- * console.log('Branch:', result.data.branch)
2655
- * }
2656
- * ```
2922
+ * @throws {Error} When server returns 5xx status codes
2923
+ */
2924
+ async getOrgAlertsList(orgSlug, options) {
2925
+ try {
2926
+ const data = await this.#executeWithRetry(
2927
+ async () => await getResponseJson(
2928
+ await createGetRequest(
2929
+ this.#baseUrl,
2930
+ `orgs/${encodeURIComponent(orgSlug)}/alerts?${queryToSearchParams(options)}`,
2931
+ { ...this.#reqOptions, hooks: this.#hooks }
2932
+ )
2933
+ )
2934
+ );
2935
+ return this.#handleApiSuccess(data);
2936
+ } catch (e) {
2937
+ return await this.#handleApiError(e);
2938
+ }
2939
+ }
2940
+ /**
2941
+ * Get analytics data for organization usage patterns and security metrics.
2942
+ * Returns statistical analysis for specified time period.
2657
2943
  *
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
2662
2944
  * @throws {Error} When server returns 5xx status codes
2663
2945
  */
2664
- async getFullScanMetadata(orgSlug, scanId) {
2946
+ async getOrgAnalytics(time) {
2665
2947
  try {
2666
2948
  const data = await this.#executeWithRetry(
2667
2949
  async () => await getResponseJson(
2668
2950
  await createGetRequest(
2669
2951
  this.#baseUrl,
2670
- `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}/metadata`,
2952
+ `analytics/org/${encodeURIComponent(time)}`,
2671
2953
  { ...this.#reqOptions, hooks: this.#hooks }
2672
2954
  )
2673
2955
  )
2674
2956
  );
2675
- return {
2676
- cause: void 0,
2677
- data,
2678
- error: void 0,
2679
- status: 200,
2680
- success: true
2681
- };
2957
+ return this.#handleApiSuccess(data);
2682
2958
  } 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
- };
2959
+ return await this.#handleApiError(e);
2691
2960
  }
2692
2961
  }
2693
2962
  /**
@@ -2738,244 +3007,90 @@ var SocketSdk = class {
2738
3007
  }
2739
3008
  }
2740
3009
  /**
2741
- * Get details for a specific repository.
2742
- *
2743
- * Returns repository configuration, monitoring status, and metadata.
2744
- *
2745
- * @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
- * ```
3010
+ * Get organization's security policy configuration.* Returns alert rules, severity thresholds, and enforcement settings.
2759
3011
  *
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
3012
  * @throws {Error} When server returns 5xx status codes
2765
3013
  */
2766
- async getRepository(orgSlug, repoSlug) {
2767
- const orgSlugParam = encodeURIComponent(orgSlug);
2768
- const repoSlugParam = encodeURIComponent(repoSlug);
3014
+ async getOrgSecurityPolicy(orgSlug) {
2769
3015
  try {
2770
3016
  const data = await this.#executeWithRetry(
2771
3017
  async () => await getResponseJson(
2772
3018
  await createGetRequest(
2773
3019
  this.#baseUrl,
2774
- `orgs/${orgSlugParam}/repos/${repoSlugParam}`,
3020
+ `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
2775
3021
  { ...this.#reqOptions, hooks: this.#hooks }
2776
3022
  )
2777
3023
  )
2778
3024
  );
2779
- return {
2780
- cause: void 0,
2781
- data,
2782
- error: void 0,
2783
- status: 200,
2784
- success: true
2785
- };
3025
+ return this.#handleApiSuccess(data);
2786
3026
  } 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
- };
3027
+ return await this.#handleApiError(e);
2795
3028
  }
2796
3029
  }
2797
3030
  /**
2798
- * Get details for a specific repository label.
2799
- *
2800
- * Returns label configuration, associated repositories, and policy settings.
3031
+ * Get organization's telemetry configuration.
3032
+ * Returns whether telemetry is enabled for the organization.
2801
3033
  *
2802
3034
  * @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
- * ```
3035
+ * @returns Telemetry configuration with enabled status
2816
3036
  *
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
3037
  * @throws {Error} When server returns 5xx status codes
2822
3038
  */
2823
- async getRepositoryLabel(orgSlug, labelId) {
3039
+ async getOrgTelemetryConfig(orgSlug) {
2824
3040
  try {
2825
3041
  const data = await this.#executeWithRetry(
2826
3042
  async () => await getResponseJson(
2827
3043
  await createGetRequest(
2828
3044
  this.#baseUrl,
2829
- `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
3045
+ `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
2830
3046
  { ...this.#reqOptions, hooks: this.#hooks }
2831
3047
  )
2832
3048
  )
2833
3049
  );
2834
- return {
2835
- cause: void 0,
2836
- data,
2837
- error: void 0,
2838
- status: 200,
2839
- success: true
2840
- };
3050
+ return this.#handleApiSuccess(data);
2841
3051
  } 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
- };
3052
+ return await this.#handleApiError(e);
2850
3053
  }
2851
3054
  }
2852
3055
  /**
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
- * ```
3056
+ * Get organization triage settings and status.
3057
+ * Returns alert triage configuration and current state.
2872
3058
  *
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
3059
  * @throws {Error} When server returns 5xx status codes
2878
3060
  */
2879
- async listRepositoryLabels(orgSlug, options) {
3061
+ async getOrgTriage(orgSlug) {
2880
3062
  try {
2881
3063
  const data = await this.#executeWithRetry(
2882
3064
  async () => await getResponseJson(
2883
3065
  await createGetRequest(
2884
3066
  this.#baseUrl,
2885
- `orgs/${encodeURIComponent(orgSlug)}/repos/labels?${queryToSearchParams(options)}`,
3067
+ `orgs/${encodeURIComponent(orgSlug)}/triage`,
2886
3068
  { ...this.#reqOptions, hooks: this.#hooks }
2887
3069
  )
2888
3070
  )
2889
3071
  );
2890
- return {
2891
- cause: void 0,
2892
- data,
2893
- error: void 0,
2894
- status: 200,
2895
- success: true
2896
- };
3072
+ return this.#handleApiSuccess(data);
2897
3073
  } 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
- };
3074
+ return await this.#handleApiError(e);
2906
3075
  }
2907
3076
  }
2908
3077
  /**
2909
- * List all repositories in an organization.
2910
- *
2911
- * Returns paginated list of repository metadata with guaranteed required fields.
3078
+ * Get details of a specific webhook.
3079
+ * Returns webhook configuration including events, URL, and filters.
2912
3080
  *
2913
3081
  * @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.
3082
+ * @param webhookId - Webhook ID to retrieve
3083
+ * @returns Webhook details
2969
3084
  *
2970
3085
  * @throws {Error} When server returns 5xx status codes
2971
3086
  */
2972
- async getOrgSecurityPolicy(orgSlug) {
3087
+ async getOrgWebhook(orgSlug, webhookId) {
2973
3088
  try {
2974
3089
  const data = await this.#executeWithRetry(
2975
3090
  async () => await getResponseJson(
2976
3091
  await createGetRequest(
2977
3092
  this.#baseUrl,
2978
- `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
3093
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
2979
3094
  { ...this.#reqOptions, hooks: this.#hooks }
2980
3095
  )
2981
3096
  )
@@ -2986,18 +3101,22 @@ var SocketSdk = class {
2986
3101
  }
2987
3102
  }
2988
3103
  /**
2989
- * Get organization triage settings and status.
2990
- * Returns alert triage configuration and current state.
3104
+ * List all webhooks for an organization.
3105
+ * Supports pagination and sorting options.
3106
+ *
3107
+ * @param orgSlug - Organization identifier
3108
+ * @param options - Optional query parameters for pagination and sorting
3109
+ * @returns List of webhooks with pagination info
2991
3110
  *
2992
3111
  * @throws {Error} When server returns 5xx status codes
2993
3112
  */
2994
- async getOrgTriage(orgSlug) {
3113
+ async getOrgWebhooksList(orgSlug, options) {
2995
3114
  try {
2996
3115
  const data = await this.#executeWithRetry(
2997
3116
  async () => await getResponseJson(
2998
3117
  await createGetRequest(
2999
3118
  this.#baseUrl,
3000
- `orgs/${encodeURIComponent(orgSlug)}/triage`,
3119
+ `orgs/${encodeURIComponent(orgSlug)}/webhooks?${queryToSearchParams(options)}`,
3001
3120
  { ...this.#reqOptions, hooks: this.#hooks }
3002
3121
  )
3003
3122
  )
@@ -3053,88 +3172,140 @@ var SocketSdk = class {
3053
3172
  }
3054
3173
  }
3055
3174
  /**
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.
3061
- *
3062
- * @throws {Error} When server returns 5xx status codes
3063
- */
3064
- async getScoreByNpmPackage(pkgName, version) {
3175
+ * Get detailed results for a legacy scan report.
3176
+ /**
3177
+
3178
+ /**
3179
+ * Get details for a specific repository.
3180
+ *
3181
+ * Returns repository configuration, monitoring status, and metadata.
3182
+ *
3183
+ * @param orgSlug - Organization identifier
3184
+ * @param repoSlug - Repository slug/name
3185
+ * @param options - Optional parameters including workspace
3186
+ * @returns Repository details with configuration
3187
+ *
3188
+ * @example
3189
+ * ```typescript
3190
+ * const result = await sdk.getRepository('my-org', 'my-repo')
3191
+ *
3192
+ * if (result.success) {
3193
+ * console.log('Repository:', result.data.name)
3194
+ * console.log('Visibility:', result.data.visibility)
3195
+ * console.log('Default branch:', result.data.default_branch)
3196
+ * }
3197
+ * ```
3198
+ *
3199
+ * @see https://docs.socket.dev/reference/getorgrepo
3200
+ * @apiEndpoint GET /orgs/{org_slug}/repos/{repo_slug}
3201
+ * @quota 1 unit
3202
+ * @scopes repo:read
3203
+ * @throws {Error} When server returns 5xx status codes
3204
+ */
3205
+ async getRepository(orgSlug, repoSlug, options) {
3206
+ const orgSlugParam = encodeURIComponent(orgSlug);
3207
+ const repoSlugParam = encodeURIComponent(repoSlug);
3208
+ const { workspace } = {
3209
+ __proto__: null,
3210
+ ...options
3211
+ };
3212
+ const queryString = workspace ? `?${queryToSearchParams({ workspace })}` : "";
3065
3213
  try {
3066
3214
  const data = await this.#executeWithRetry(
3067
3215
  async () => await getResponseJson(
3068
3216
  await createGetRequest(
3069
3217
  this.#baseUrl,
3070
- `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`,
3218
+ `orgs/${orgSlugParam}/repos/${repoSlugParam}${queryString}`,
3071
3219
  { ...this.#reqOptions, hooks: this.#hooks }
3072
3220
  )
3073
3221
  )
3074
3222
  );
3075
- return this.#handleApiSuccess(data);
3223
+ return {
3224
+ cause: void 0,
3225
+ data,
3226
+ error: void 0,
3227
+ status: 200,
3228
+ success: true
3229
+ };
3076
3230
  } catch (e) {
3077
- return await this.#handleApiError(e);
3231
+ const errorResult = await this.#handleApiError(e);
3232
+ return {
3233
+ cause: errorResult.cause,
3234
+ data: void 0,
3235
+ error: errorResult.error,
3236
+ status: errorResult.status,
3237
+ success: false
3238
+ };
3078
3239
  }
3079
3240
  }
3080
3241
  /**
3081
- * Get list of file types and formats supported for scanning.
3082
- * Returns supported manifest files, lockfiles, and configuration formats.
3242
+ * Get details for a specific repository label.
3083
3243
  *
3084
- * @throws {Error} When server returns 5xx status codes
3085
- */
3086
- async getSupportedScanFiles() {
3087
- try {
3088
- const data = await this.#executeWithRetry(
3089
- async () => await getResponseJson(
3090
- await createGetRequest(this.#baseUrl, "report/supported", {
3091
- ...this.#reqOptions,
3092
- hooks: this.#hooks
3093
- })
3094
- )
3095
- );
3096
- return this.#handleApiSuccess(data);
3097
- } catch (e) {
3098
- return await this.#handleApiError(e);
3099
- }
3100
- }
3101
- /**
3102
- * List all diff scans for an organization.
3103
- * Returns paginated list of diff scan metadata and status.
3244
+ * Returns label configuration, associated repositories, and policy settings.
3245
+ *
3246
+ * @param orgSlug - Organization identifier
3247
+ * @param labelId - Label identifier
3248
+ * @returns Label details with guaranteed id and name fields
3249
+ *
3250
+ * @example
3251
+ * ```typescript
3252
+ * const result = await sdk.getRepositoryLabel('my-org', 'label-id-123')
3253
+ *
3254
+ * if (result.success) {
3255
+ * console.log('Label name:', result.data.name)
3256
+ * console.log('Associated repos:', result.data.repository_ids)
3257
+ * console.log('Has security policy:', result.data.has_security_policy)
3258
+ * }
3259
+ * ```
3104
3260
  *
3261
+ * @see https://docs.socket.dev/reference/getorgrepolabel
3262
+ * @apiEndpoint GET /orgs/{org_slug}/repos/labels/{label_id}
3263
+ * @quota 1 unit
3264
+ * @scopes repo-label:list
3105
3265
  * @throws {Error} When server returns 5xx status codes
3106
3266
  */
3107
- async listOrgDiffScans(orgSlug) {
3267
+ async getRepositoryLabel(orgSlug, labelId) {
3108
3268
  try {
3109
3269
  const data = await this.#executeWithRetry(
3110
3270
  async () => await getResponseJson(
3111
3271
  await createGetRequest(
3112
3272
  this.#baseUrl,
3113
- `orgs/${encodeURIComponent(orgSlug)}/diff-scans`,
3273
+ `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
3114
3274
  { ...this.#reqOptions, hooks: this.#hooks }
3115
3275
  )
3116
3276
  )
3117
3277
  );
3118
- return this.#handleApiSuccess(data);
3119
- } catch (e) {
3120
- return await this.#handleApiError(e);
3278
+ return {
3279
+ cause: void 0,
3280
+ data,
3281
+ error: void 0,
3282
+ status: 200,
3283
+ success: true
3284
+ };
3285
+ } catch (e) {
3286
+ const errorResult = await this.#handleApiError(e);
3287
+ return {
3288
+ cause: errorResult.cause,
3289
+ data: void 0,
3290
+ error: errorResult.error,
3291
+ status: errorResult.status,
3292
+ success: false
3293
+ };
3121
3294
  }
3122
3295
  }
3123
3296
  /**
3124
- * Create a new API token for an organization.
3125
- * Generates API token with specified scopes and metadata.
3297
+ * Get security score for a specific npm package and version.
3298
+ * Returns numerical security rating and scoring breakdown.
3126
3299
  *
3127
3300
  * @throws {Error} When server returns 5xx status codes
3128
3301
  */
3129
- async postAPIToken(orgSlug, tokenData) {
3302
+ async getScoreByNpmPackage(pkgName, version) {
3130
3303
  try {
3131
3304
  const data = await this.#executeWithRetry(
3132
3305
  async () => await getResponseJson(
3133
- await createRequestWithJson(
3134
- "POST",
3306
+ await createGetRequest(
3135
3307
  this.#baseUrl,
3136
- `orgs/${encodeURIComponent(orgSlug)}/tokens`,
3137
- tokenData,
3308
+ `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`,
3138
3309
  { ...this.#reqOptions, hooks: this.#hooks }
3139
3310
  )
3140
3311
  )
@@ -3145,22 +3316,19 @@ var SocketSdk = class {
3145
3316
  }
3146
3317
  }
3147
3318
  /**
3148
- * Revoke an API token for an organization.
3149
- * Permanently disables the token and removes access.
3319
+ * Get list of file types and formats supported for scanning.
3320
+ * Returns supported manifest files, lockfiles, and configuration formats.
3150
3321
  *
3151
3322
  * @throws {Error} When server returns 5xx status codes
3152
3323
  */
3153
- async postAPITokensRevoke(orgSlug, tokenId) {
3324
+ async getSupportedScanFiles() {
3154
3325
  try {
3155
3326
  const data = await this.#executeWithRetry(
3156
3327
  async () => await getResponseJson(
3157
- await createRequestWithJson(
3158
- "POST",
3159
- this.#baseUrl,
3160
- `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/revoke`,
3161
- {},
3162
- { ...this.#reqOptions, hooks: this.#hooks }
3163
- )
3328
+ await createGetRequest(this.#baseUrl, "report/supported", {
3329
+ ...this.#reqOptions,
3330
+ hooks: this.#hooks
3331
+ })
3164
3332
  )
3165
3333
  );
3166
3334
  return this.#handleApiSuccess(data);
@@ -3169,68 +3337,131 @@ var SocketSdk = class {
3169
3337
  }
3170
3338
  }
3171
3339
  /**
3172
- * Rotate an API token for an organization.
3173
- * Generates new token value while preserving token metadata.
3340
+ * List all full scans for an organization.
3341
+ *
3342
+ * Returns paginated list of full scan metadata with guaranteed required fields
3343
+ * for improved TypeScript autocomplete.
3344
+ *
3345
+ * @param orgSlug - Organization identifier
3346
+ * @param options - Filtering and pagination options
3347
+ * @returns List of full scans with metadata
3348
+ *
3349
+ * @example
3350
+ * ```typescript
3351
+ * const result = await sdk.listFullScans('my-org', {
3352
+ * branch: 'main',
3353
+ * per_page: 50,
3354
+ * use_cursor: true
3355
+ * })
3356
+ *
3357
+ * if (result.success) {
3358
+ * result.data.results.forEach(scan => {
3359
+ * console.log(scan.id, scan.created_at) // Guaranteed fields
3360
+ * })
3361
+ * }
3362
+ * ```
3174
3363
  *
3364
+ * @see https://docs.socket.dev/reference/getorgfullscanlist
3365
+ * @apiEndpoint GET /orgs/{org_slug}/full-scans
3366
+ * @quota 1 unit
3367
+ * @scopes full-scans:list
3175
3368
  * @throws {Error} When server returns 5xx status codes
3176
3369
  */
3177
- async postAPITokensRotate(orgSlug, tokenId) {
3370
+ async listFullScans(orgSlug, options) {
3178
3371
  try {
3179
3372
  const data = await this.#executeWithRetry(
3180
3373
  async () => await getResponseJson(
3181
- await createRequestWithJson(
3182
- "POST",
3374
+ await createGetRequest(
3183
3375
  this.#baseUrl,
3184
- `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/rotate`,
3185
- {},
3376
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(options)}`,
3186
3377
  { ...this.#reqOptions, hooks: this.#hooks }
3187
3378
  )
3188
3379
  )
3189
3380
  );
3190
- return this.#handleApiSuccess(data);
3381
+ return {
3382
+ cause: void 0,
3383
+ data,
3384
+ error: void 0,
3385
+ status: 200,
3386
+ success: true
3387
+ };
3191
3388
  } catch (e) {
3192
- return await this.#handleApiError(e);
3389
+ const errorResult = await this.#handleApiError(e);
3390
+ return {
3391
+ cause: errorResult.cause,
3392
+ data: void 0,
3393
+ error: errorResult.error,
3394
+ status: errorResult.status,
3395
+ success: false
3396
+ };
3193
3397
  }
3194
3398
  }
3195
3399
  /**
3196
- * Update an existing API token for an organization.
3197
- * Modifies token metadata, scopes, or other properties.
3400
+ * List all organizations accessible to the current user.
3401
+ *
3402
+ * Returns organization details and access permissions with guaranteed required fields.
3403
+ *
3404
+ * @returns List of organizations with metadata
3405
+ *
3406
+ * @example
3407
+ * ```typescript
3408
+ * const result = await sdk.listOrganizations()
3409
+ *
3410
+ * if (result.success) {
3411
+ * result.data.organizations.forEach(org => {
3412
+ * console.log(org.name, org.slug) // Guaranteed fields
3413
+ * })
3414
+ * }
3415
+ * ```
3198
3416
  *
3417
+ * @see https://docs.socket.dev/reference/getorganizations
3418
+ * @apiEndpoint GET /organizations
3419
+ * @quota 1 unit
3199
3420
  * @throws {Error} When server returns 5xx status codes
3200
3421
  */
3201
- async postAPITokenUpdate(orgSlug, tokenId, updateData) {
3422
+ async listOrganizations() {
3202
3423
  try {
3203
- const data = await this.#executeWithRetry(
3424
+ const data = await this.#getCached(
3425
+ "organizations",
3204
3426
  async () => await getResponseJson(
3205
- await createRequestWithJson(
3206
- "POST",
3207
- this.#baseUrl,
3208
- `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/update`,
3209
- updateData,
3210
- { ...this.#reqOptions, hooks: this.#hooks }
3211
- )
3212
- )
3427
+ await createGetRequest(this.#baseUrl, "organizations", {
3428
+ ...this.#reqOptions,
3429
+ hooks: this.#hooks
3430
+ })
3431
+ ),
3432
+ "organizations"
3213
3433
  );
3214
- return this.#handleApiSuccess(data);
3434
+ return {
3435
+ cause: void 0,
3436
+ data,
3437
+ error: void 0,
3438
+ status: 200,
3439
+ success: true
3440
+ };
3215
3441
  } catch (e) {
3216
- return await this.#handleApiError(e);
3442
+ const errorResult = await this.#handleApiError(e);
3443
+ return {
3444
+ cause: errorResult.cause,
3445
+ data: void 0,
3446
+ error: errorResult.error,
3447
+ status: errorResult.status,
3448
+ success: false
3449
+ };
3217
3450
  }
3218
3451
  }
3219
3452
  /**
3220
- * Update user or organization settings.
3221
- * Configures preferences, notifications, and security policies.
3453
+ * List all diff scans for an organization.
3454
+ * Returns paginated list of diff scan metadata and status.
3222
3455
  *
3223
3456
  * @throws {Error} When server returns 5xx status codes
3224
3457
  */
3225
- async postSettings(selectors) {
3458
+ async listOrgDiffScans(orgSlug) {
3226
3459
  try {
3227
3460
  const data = await this.#executeWithRetry(
3228
3461
  async () => await getResponseJson(
3229
- await createRequestWithJson(
3230
- "POST",
3462
+ await createGetRequest(
3231
3463
  this.#baseUrl,
3232
- "settings",
3233
- { json: selectors },
3464
+ `orgs/${encodeURIComponent(orgSlug)}/diff-scans`,
3234
3465
  { ...this.#reqOptions, hooks: this.#hooks }
3235
3466
  )
3236
3467
  )
@@ -3241,238 +3472,159 @@ var SocketSdk = class {
3241
3472
  }
3242
3473
  }
3243
3474
  /**
3244
- * Search for dependencies across monitored projects.
3245
- * Returns matching packages with security information and usage patterns.
3475
+ * List all repositories in an organization.
3476
+ *
3477
+ * Returns paginated list of repository metadata with guaranteed required fields.
3478
+ *
3479
+ * @param orgSlug - Organization identifier
3480
+ * @param options - Pagination and filtering options
3481
+ * @returns List of repositories with metadata
3482
+ *
3483
+ * @example
3484
+ * ```typescript
3485
+ * const result = await sdk.listRepositories('my-org', {
3486
+ * per_page: 50,
3487
+ * sort: 'name',
3488
+ * direction: 'asc'
3489
+ * })
3490
+ *
3491
+ * if (result.success) {
3492
+ * result.data.results.forEach(repo => {
3493
+ * console.log(repo.name, repo.visibility)
3494
+ * })
3495
+ * }
3496
+ * ```
3246
3497
  *
3498
+ * @see https://docs.socket.dev/reference/getorgrepolist
3499
+ * @apiEndpoint GET /orgs/{org_slug}/repos
3500
+ * @quota 1 unit
3501
+ * @scopes repo:list
3247
3502
  * @throws {Error} When server returns 5xx status codes
3248
3503
  */
3249
- async searchDependencies(queryParams) {
3504
+ async listRepositories(orgSlug, options) {
3250
3505
  try {
3251
3506
  const data = await this.#executeWithRetry(
3252
3507
  async () => await getResponseJson(
3253
- await createRequestWithJson(
3254
- "POST",
3508
+ await createGetRequest(
3255
3509
  this.#baseUrl,
3256
- "dependencies/search",
3257
- queryParams,
3510
+ `orgs/${encodeURIComponent(orgSlug)}/repos?${queryToSearchParams(options)}`,
3258
3511
  { ...this.#reqOptions, hooks: this.#hooks }
3259
3512
  )
3260
3513
  )
3261
3514
  );
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
3515
  return {
3294
3516
  cause: void 0,
3295
3517
  data,
3296
3518
  error: void 0,
3297
- /* c8 ignore next - Defensive fallback: response.statusCode is always defined in Node.js http/https */
3298
- status: response.statusCode ?? 200,
3519
+ status: 200,
3299
3520
  success: true
3300
3521
  };
3301
3522
  } 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() : "";
3523
+ const errorResult = await this.#handleApiError(e);
3316
3524
  return {
3317
- cause: errStr || import_core.UNKNOWN_ERROR,
3525
+ cause: errorResult.cause,
3318
3526
  data: void 0,
3319
- error: "API request failed",
3320
- status: 0,
3527
+ error: errorResult.error,
3528
+ status: errorResult.status,
3321
3529
  success: false
3322
3530
  };
3323
3531
  }
3324
3532
  }
3325
3533
  /**
3326
- * Stream a full scan's results to file or stdout.
3534
+ * List all repository labels for an organization.
3327
3535
  *
3328
- * Provides efficient streaming for large scan datasets without loading
3329
- * entire response into memory. Useful for processing large SBOMs.
3536
+ * Returns paginated list of labels configured for repository organization and policy management.
3330
3537
  *
3331
3538
  * @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
3539
+ * @param options - Pagination options
3540
+ * @returns List of labels with guaranteed id and name fields
3335
3541
  *
3336
3542
  * @example
3337
3543
  * ```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
- * })
3544
+ * const result = await sdk.listRepositoryLabels('my-org', { per_page: 50, page: 1 })
3347
3545
  *
3348
- * // Get buffered response
3349
- * const result = await sdk.streamFullScan('my-org', 'scan_123')
3546
+ * if (result.success) {
3547
+ * result.data.results.forEach(label => {
3548
+ * console.log('Label:', label.name)
3549
+ * console.log('Associated repos:', label.repository_ids?.length || 0)
3550
+ * })
3551
+ * }
3350
3552
  * ```
3351
3553
  *
3352
- * @see https://docs.socket.dev/reference/getorgfullscan
3353
- * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
3554
+ * @see https://docs.socket.dev/reference/getorgrepolabellist
3555
+ * @apiEndpoint GET /orgs/{org_slug}/repos/labels
3354
3556
  * @quota 1 unit
3355
- * @scopes full-scans:list
3557
+ * @scopes repo-label:list
3356
3558
  * @throws {Error} When server returns 5xx status codes
3357
3559
  */
3358
- async streamFullScan(orgSlug, scanId, options) {
3359
- const { output } = {
3360
- __proto__: null,
3361
- ...options
3362
- };
3560
+ async listRepositoryLabels(orgSlug, options) {
3363
3561
  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);
3562
+ const data = await this.#executeWithRetry(
3563
+ async () => await getResponseJson(
3564
+ await createGetRequest(
3565
+ this.#baseUrl,
3566
+ `orgs/${encodeURIComponent(orgSlug)}/repos/labels?${queryToSearchParams(options)}`,
3567
+ { ...this.#reqOptions, hooks: this.#hooks }
3568
+ )
3569
+ )
3570
+ );
3571
+ return {
3572
+ cause: void 0,
3573
+ data,
3574
+ error: void 0,
3575
+ status: 200,
3576
+ success: true
3577
+ };
3411
3578
  } catch (e) {
3412
- return await this.#handleApiError(e);
3579
+ const errorResult = await this.#handleApiError(e);
3580
+ return {
3581
+ cause: errorResult.cause,
3582
+ data: void 0,
3583
+ error: errorResult.error,
3584
+ status: errorResult.status,
3585
+ success: false
3586
+ };
3413
3587
  }
3414
3588
  }
3415
3589
  /**
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.
3590
+ * Create a new API token for an organization.
3591
+ * Generates API token with specified scopes and metadata.
3420
3592
  *
3421
- * Note: This method returns a ReadableStream for processing large datasets.
3593
+ * @throws {Error} When server returns 5xx status codes
3422
3594
  */
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");
3595
+ async postAPIToken(orgSlug, tokenData) {
3596
+ try {
3597
+ const data = await this.#executeWithRetry(
3598
+ async () => await getResponseJson(
3599
+ await createRequestWithJson(
3600
+ "POST",
3601
+ this.#baseUrl,
3602
+ `orgs/${encodeURIComponent(orgSlug)}/tokens`,
3603
+ tokenData,
3604
+ { ...this.#reqOptions, hooks: this.#hooks }
3605
+ )
3606
+ )
3607
+ );
3608
+ return this.#handleApiSuccess(data);
3609
+ } catch (e) {
3610
+ return await this.#handleApiError(e);
3433
3611
  }
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
3612
  }
3461
3613
  /**
3462
- * Update alert triage status for an organization.
3463
- * Modifies alert resolution status and triage decisions.
3614
+ * Revoke an API token for an organization.
3615
+ * Permanently disables the token and removes access.
3464
3616
  *
3465
3617
  * @throws {Error} When server returns 5xx status codes
3466
3618
  */
3467
- async updateOrgAlertTriage(orgSlug, alertId, triageData) {
3619
+ async postAPITokensRevoke(orgSlug, tokenId) {
3468
3620
  try {
3469
3621
  const data = await this.#executeWithRetry(
3470
3622
  async () => await getResponseJson(
3471
3623
  await createRequestWithJson(
3472
- "PUT",
3624
+ "POST",
3473
3625
  this.#baseUrl,
3474
- `orgs/${encodeURIComponent(orgSlug)}/triage/${encodeURIComponent(alertId)}`,
3475
- triageData,
3626
+ `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/revoke`,
3627
+ {},
3476
3628
  { ...this.#reqOptions, hooks: this.#hooks }
3477
3629
  )
3478
3630
  )
@@ -3483,19 +3635,20 @@ var SocketSdk = class {
3483
3635
  }
3484
3636
  }
3485
3637
  /**
3486
- * Update organization's license policy configuration.* Modifies allowed, restricted, and monitored license types.
3638
+ * Rotate an API token for an organization.
3639
+ * Generates new token value while preserving token metadata.
3487
3640
  *
3488
3641
  * @throws {Error} When server returns 5xx status codes
3489
3642
  */
3490
- async updateOrgLicensePolicy(orgSlug, policyData, queryParams) {
3643
+ async postAPITokensRotate(orgSlug, tokenId) {
3491
3644
  try {
3492
3645
  const data = await this.#executeWithRetry(
3493
3646
  async () => await getResponseJson(
3494
3647
  await createRequestWithJson(
3495
3648
  "POST",
3496
3649
  this.#baseUrl,
3497
- `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy?${queryToSearchParams(queryParams)}`,
3498
- policyData,
3650
+ `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/rotate`,
3651
+ {},
3499
3652
  { ...this.#reqOptions, hooks: this.#hooks }
3500
3653
  )
3501
3654
  )
@@ -3506,42 +3659,48 @@ var SocketSdk = class {
3506
3659
  }
3507
3660
  }
3508
3661
  /**
3509
- * Update configuration for a repository.
3662
+ * Update an existing API token for an organization.
3663
+ * Modifies token metadata, scopes, or other properties.
3510
3664
  *
3511
- * Modifies monitoring settings, branch configuration, and scan preferences.
3665
+ * @throws {Error} When server returns 5xx status codes
3666
+ */
3667
+ async postAPITokenUpdate(orgSlug, tokenId, updateData) {
3668
+ try {
3669
+ const data = await this.#executeWithRetry(
3670
+ async () => await getResponseJson(
3671
+ await createRequestWithJson(
3672
+ "POST",
3673
+ this.#baseUrl,
3674
+ `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/update`,
3675
+ updateData,
3676
+ { ...this.#reqOptions, hooks: this.#hooks }
3677
+ )
3678
+ )
3679
+ );
3680
+ return this.#handleApiSuccess(data);
3681
+ } catch (e) {
3682
+ return await this.#handleApiError(e);
3683
+ }
3684
+ }
3685
+ /**
3686
+ * Post telemetry data for an organization.
3687
+ * Sends telemetry events and analytics data for monitoring and analysis.
3512
3688
  *
3513
3689
  * @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
3517
- *
3518
- * @example
3519
- * ```typescript
3520
- * const result = await sdk.updateRepository('my-org', 'my-repo', {
3521
- * description: 'Updated description',
3522
- * default_branch: 'develop'
3523
- * })
3524
- *
3525
- * if (result.success) {
3526
- * console.log('Repository updated:', result.data.name)
3527
- * }
3528
- * ```
3690
+ * @param telemetryData - Telemetry payload containing events and metrics
3691
+ * @returns Empty object on successful submission
3529
3692
  *
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
3534
3693
  * @throws {Error} When server returns 5xx status codes
3535
3694
  */
3536
- async updateRepository(orgSlug, repoSlug, params) {
3695
+ async postOrgTelemetry(orgSlug, telemetryData) {
3537
3696
  try {
3538
3697
  const data = await this.#executeWithRetry(
3539
3698
  async () => await getResponseJson(
3540
3699
  await createRequestWithJson(
3541
3700
  "POST",
3542
3701
  this.#baseUrl,
3543
- `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`,
3544
- params,
3702
+ `orgs/${encodeURIComponent(orgSlug)}/telemetry`,
3703
+ telemetryData,
3545
3704
  { ...this.#reqOptions, hooks: this.#hooks }
3546
3705
  )
3547
3706
  )
@@ -3554,87 +3713,100 @@ var SocketSdk = class {
3554
3713
  success: true
3555
3714
  };
3556
3715
  } catch (e) {
3557
- const errorResult = await this.#handleApiError(e);
3558
- return {
3559
- cause: errorResult.cause,
3560
- data: void 0,
3561
- error: errorResult.error,
3562
- status: errorResult.status,
3563
- success: false
3564
- };
3716
+ return this.#createQueryErrorResult(e);
3565
3717
  }
3566
3718
  }
3567
3719
  /**
3568
- * Update a repository label for an organization.
3720
+ * Update user or organization settings.
3721
+ * Configures preferences, notifications, and security policies.
3569
3722
  *
3570
- * Modifies label properties like name. Label names must be non-empty and less than 1000 characters.
3723
+ * @throws {Error} When server returns 5xx status codes
3724
+ */
3725
+ async postSettings(selectors) {
3726
+ try {
3727
+ const data = await this.#executeWithRetry(
3728
+ async () => await getResponseJson(
3729
+ await createRequestWithJson(
3730
+ "POST",
3731
+ this.#baseUrl,
3732
+ "settings",
3733
+ { json: selectors },
3734
+ { ...this.#reqOptions, hooks: this.#hooks }
3735
+ )
3736
+ )
3737
+ );
3738
+ return this.#handleApiSuccess(data);
3739
+ } catch (e) {
3740
+ return await this.#handleApiError(e);
3741
+ }
3742
+ }
3743
+ /**
3744
+ * Create a new full scan by rescanning an existing scan.
3745
+ * Supports shallow (policy reapplication) and deep (dependency resolution rerun) modes.
3571
3746
  *
3572
3747
  * @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
3748
+ * @param fullScanId - Full scan ID to rescan
3749
+ * @param options - Rescan options including mode (shallow or deep)
3750
+ * @returns New scan ID and status
3576
3751
  *
3577
3752
  * @example
3578
3753
  * ```typescript
3579
- * const result = await sdk.updateRepositoryLabel('my-org', 'label-id-123', { name: 'staging' })
3754
+ * // Shallow rescan (reapply policies to cached data)
3755
+ * const result = await sdk.rescanFullScan('my-org', 'scan_123', {
3756
+ * mode: 'shallow'
3757
+ * })
3580
3758
  *
3581
3759
  * if (result.success) {
3582
- * console.log('Label updated:', result.data.name)
3583
- * console.log('Label ID:', result.data.id)
3760
+ * console.log('New Scan ID:', result.data.id)
3761
+ * console.log('Status:', result.data.status)
3584
3762
  * }
3763
+ *
3764
+ * // Deep rescan (rerun dependency resolution)
3765
+ * const deepResult = await sdk.rescanFullScan('my-org', 'scan_123', {
3766
+ * mode: 'deep'
3767
+ * })
3585
3768
  * ```
3586
3769
  *
3587
- * @see https://docs.socket.dev/reference/updateorgrepolabel
3588
- * @apiEndpoint PUT /orgs/{org_slug}/repos/labels/{label_id}
3770
+ * @see https://docs.socket.dev/reference/rescanorgfullscan
3771
+ * @apiEndpoint POST /orgs/{org_slug}/full-scans/{full_scan_id}/rescan
3589
3772
  * @quota 1 unit
3590
- * @scopes repo-label:update
3773
+ * @scopes full-scans:create
3591
3774
  * @throws {Error} When server returns 5xx status codes
3592
3775
  */
3593
- async updateRepositoryLabel(orgSlug, labelId, labelData) {
3776
+ async rescanFullScan(orgSlug, fullScanId, options) {
3777
+ const queryString = options ? `?${queryToSearchParams(options)}` : "";
3594
3778
  try {
3595
3779
  const data = await this.#executeWithRetry(
3596
3780
  async () => await getResponseJson(
3597
3781
  await createRequestWithJson(
3598
- "PUT",
3782
+ "POST",
3599
3783
  this.#baseUrl,
3600
- `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
3601
- labelData,
3784
+ `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/rescan${queryString}`,
3785
+ {},
3602
3786
  { ...this.#reqOptions, hooks: this.#hooks }
3603
3787
  )
3604
3788
  )
3605
3789
  );
3606
- return {
3607
- cause: void 0,
3608
- data,
3609
- error: void 0,
3610
- status: 200,
3611
- success: true
3612
- };
3790
+ return this.#handleApiSuccess(data);
3613
3791
  } catch (e) {
3614
- const errorResult = await this.#handleApiError(e);
3615
- return {
3616
- cause: errorResult.cause,
3617
- data: void 0,
3618
- error: errorResult.error,
3619
- status: errorResult.status,
3620
- success: false
3621
- };
3792
+ return await this.#handleApiError(e);
3622
3793
  }
3623
3794
  }
3624
3795
  /**
3625
- * Update organization's security policy configuration.* Modifies alert rules, severity thresholds, and enforcement settings.
3796
+ * Search for dependencies across monitored projects.
3797
+ * Returns matching packages with security information and usage patterns.
3626
3798
  *
3627
3799
  * @throws {Error} When server returns 5xx status codes
3628
3800
  */
3629
- async updateOrgSecurityPolicy(orgSlug, policyData) {
3801
+ async searchDependencies(queryParams) {
3630
3802
  try {
3631
3803
  const data = await this.#executeWithRetry(
3632
3804
  async () => await getResponseJson(
3633
3805
  await createRequestWithJson(
3634
3806
  "POST",
3635
3807
  this.#baseUrl,
3636
- `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
3637
- policyData,
3808
+ "dependencies/search",
3809
+ queryParams,
3638
3810
  { ...this.#reqOptions, hooks: this.#hooks }
3639
3811
  )
3640
3812
  )
@@ -3645,134 +3817,104 @@ var SocketSdk = class {
3645
3817
  }
3646
3818
  }
3647
3819
  /**
3648
- * Upload manifest files for dependency analysis.
3649
- * Processes package files to create dependency snapshots and security analysis.
3650
- *
3651
- * @throws {Error} When server returns 5xx status codes
3820
+ * Send POST or PUT request with JSON body and return parsed JSON response.
3821
+ * Supports both throwing (default) and non-throwing modes.
3822
+ * @param urlPath - API endpoint path (e.g., 'organizations')
3823
+ * @param options - Request options including method, body, and throws behavior
3824
+ * @returns Parsed JSON response or SocketSdkGenericResult based on options
3652
3825
  */
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);
3826
+ async sendApi(urlPath, options) {
3827
+ const {
3828
+ body,
3829
+ // Default to POST method for JSON API requests.
3830
+ method = "POST",
3831
+ throws = true
3832
+ } = { __proto__: null, ...options };
3833
+ try {
3834
+ const response = await createRequestWithJson(
3835
+ method,
3836
+ this.#baseUrl,
3837
+ urlPath,
3838
+ body,
3839
+ { ...this.#reqOptions, hooks: this.#hooks }
3840
+ );
3841
+ const data = await getResponseJson(response);
3842
+ if (throws) {
3843
+ return data;
3844
+ }
3845
+ return {
3846
+ cause: void 0,
3847
+ data,
3848
+ error: void 0,
3849
+ /* c8 ignore next - Defensive fallback: response.statusCode is always defined in Node.js http/https */
3850
+ status: response.statusCode ?? 200,
3851
+ success: true
3852
+ };
3853
+ } catch (e) {
3854
+ if (throws) {
3855
+ throw e;
3856
+ }
3857
+ if (e instanceof ResponseError) {
3858
+ const errorResult = await this.#handleApiError(e);
3669
3859
  return {
3670
- error: errorMsg,
3671
- status: 400,
3672
- success: false,
3673
- ...finalCause ? { cause: finalCause } : {}
3860
+ cause: errorResult.cause,
3861
+ data: void 0,
3862
+ error: errorResult.error,
3863
+ status: errorResult.status,
3864
+ success: false
3674
3865
  };
3675
3866
  }
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` : "";
3867
+ const errStr = e ? String(e).trim() : "";
3692
3868
  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,
3869
+ cause: errStr || import_core.UNKNOWN_ERROR,
3870
+ data: void 0,
3871
+ error: "API request failed",
3872
+ status: 0,
3711
3873
  success: false
3712
3874
  };
3713
3875
  }
3714
- try {
3715
- const data = await this.#executeWithRetry(
3716
- async () => await getResponseJson(
3717
- await createUploadRequest(
3718
- this.#baseUrl,
3719
- `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`,
3720
- createRequestBodyForFilepaths(validPaths, basePath),
3721
- { ...this.#reqOptions, hooks: this.#hooks }
3722
- )
3723
- )
3724
- );
3725
- return this.#handleApiSuccess(
3726
- data
3727
- );
3728
- } catch (e) {
3729
- return await this.#handleApiError(
3730
- e
3731
- );
3732
- }
3733
3876
  }
3734
3877
  /**
3735
- * View detailed information about a specific patch by its UUID.
3736
- *
3737
- * This method retrieves comprehensive patch details including files,
3738
- * vulnerabilities, description, license, and tier information.
3739
- */
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;
3749
- }
3750
- /**
3751
- * Download patch file content by hash.
3878
+ * Stream a full scan's results to file or stdout.
3752
3879
  *
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.
3880
+ * Provides efficient streaming for large scan datasets without loading
3881
+ * entire response into memory. Useful for processing large SBOMs.
3756
3882
  *
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
3883
+ * @param orgSlug - Organization identifier
3884
+ * @param scanId - Full scan identifier
3885
+ * @param options - Streaming options (output file path, stdout, or buffered)
3886
+ * @returns Scan result with streaming response
3762
3887
  *
3763
3888
  * @example
3764
3889
  * ```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)
3890
+ * // Stream to file
3891
+ * await sdk.streamFullScan('my-org', 'scan_123', {
3892
+ * output: './scan-results.json'
3893
+ * })
3894
+ *
3895
+ * // Stream to stdout
3896
+ * await sdk.streamFullScan('my-org', 'scan_123', {
3897
+ * output: true
3898
+ * })
3899
+ *
3900
+ * // Get buffered response
3901
+ * const result = await sdk.streamFullScan('my-org', 'scan_123')
3770
3902
  * ```
3903
+ *
3904
+ * @see https://docs.socket.dev/reference/getorgfullscan
3905
+ * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
3906
+ * @quota 1 unit
3907
+ * @scopes full-scans:list
3908
+ * @throws {Error} When server returns 5xx status codes
3771
3909
  */
3772
- async downloadOrgFullScanFilesAsTar(orgSlug, fullScanId, outputPath) {
3910
+ async streamFullScan(orgSlug, scanId, options) {
3911
+ const { output } = {
3912
+ __proto__: null,
3913
+ ...options
3914
+ };
3773
3915
  try {
3774
3916
  const req = getHttpModule(this.#baseUrl).request(
3775
- `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/files.tar`,
3917
+ `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`,
3776
3918
  {
3777
3919
  method: "GET",
3778
3920
  ...this.#reqOptions
@@ -3782,142 +3924,107 @@ var SocketSdk = class {
3782
3924
  if (!isResponseOk(res)) {
3783
3925
  throw new ResponseError(res);
3784
3926
  }
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
3927
+ if (typeof output === "string") {
3928
+ const writeStream = (0, import_node_fs3.createWriteStream)(output);
3929
+ let bytesWritten = 0;
3930
+ res.on("data", (chunk) => {
3931
+ bytesWritten += chunk.length;
3932
+ if (bytesWritten > MAX_STREAM_SIZE) {
3933
+ res.destroy();
3934
+ writeStream.destroy();
3935
+ throw new Error(
3936
+ `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
3937
+ );
3938
+ }
3801
3939
  });
3802
- });
3803
- await import_node_events.default.once(writeStream, "finish");
3940
+ res.pipe(writeStream);
3941
+ writeStream.on("error", (error) => {
3942
+ throw new Error(`Failed to write to file: ${output}`, {
3943
+ cause: error
3944
+ });
3945
+ });
3946
+ } else if (output === true) {
3947
+ let bytesWritten = 0;
3948
+ res.on("data", (chunk) => {
3949
+ bytesWritten += chunk.length;
3950
+ if (bytesWritten > MAX_STREAM_SIZE) {
3951
+ res.destroy();
3952
+ throw new Error(
3953
+ `Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
3954
+ );
3955
+ }
3956
+ });
3957
+ res.pipe(process.stdout);
3958
+ process.stdout.on("error", (error) => {
3959
+ throw new Error("Failed to write to stdout", { cause: error });
3960
+ });
3961
+ }
3804
3962
  return this.#handleApiSuccess(res);
3805
3963
  } catch (e) {
3806
3964
  return await this.#handleApiError(e);
3807
3965
  }
3808
3966
  }
3809
3967
  /**
3810
- * Download patch file content from Socket blob storage.
3811
- * Retrieves patched file contents using SSRI hash or hex hash.
3812
- *
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.
3968
+ * Stream patches for artifacts in a scan report.
3815
3969
  *
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
3970
+ * This method streams all available patches for artifacts in a scan.
3971
+ * Free tier users will only receive free patches.
3821
3972
  *
3822
- * @example
3823
- * ```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)
3829
- * ```
3973
+ * Note: This method returns a ReadableStream for processing large datasets.
3830
3974
  */
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 = "";
3864
- res.on("data", (chunk) => {
3865
- data += chunk;
3866
- });
3867
- res.on("end", () => {
3868
- resolve(data);
3869
- });
3870
- res.on("error", (err) => {
3871
- reject(err);
3872
- });
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}`);
3975
+ async streamPatchesFromScan(orgSlug, scanId) {
3976
+ const response = await this.#executeWithRetry(
3977
+ async () => await createGetRequest(
3978
+ this.#baseUrl,
3979
+ `orgs/${encodeURIComponent(orgSlug)}/patches/scan?scan_id=${encodeURIComponent(scanId)}`,
3980
+ { ...this.#reqOptions, hooks: this.#hooks }
3981
+ )
3982
+ );
3983
+ if (!isResponseOk(response)) {
3984
+ throw new ResponseError(response, "GET Request failed");
3985
+ }
3986
+ const rli = import_node_readline.default.createInterface({
3987
+ input: response,
3988
+ crlfDelay: Number.POSITIVE_INFINITY
3989
+ });
3990
+ return new ReadableStream({
3991
+ async start(controller) {
3992
+ try {
3993
+ for await (const line of rli) {
3994
+ const trimmed = line.trim();
3995
+ if (!trimmed) {
3996
+ continue;
3997
+ }
3998
+ try {
3999
+ const data = JSON.parse(trimmed);
4000
+ controller.enqueue(data);
4001
+ } catch (e) {
4002
+ (0, import_debug2.debugLog)("streamPatchesFromScan", `Failed to parse line: ${e}`);
4003
+ }
4004
+ }
4005
+ } catch (error) {
4006
+ controller.error(error);
4007
+ } finally {
4008
+ controller.close();
3897
4009
  }
3898
- reject(new Error(message.join("\n"), { cause: err }));
3899
- });
4010
+ }
3900
4011
  });
3901
4012
  }
3902
4013
  /**
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
4014
+ * Update alert triage status for an organization.
4015
+ * Modifies alert resolution status and triage decisions.
3909
4016
  *
3910
4017
  * @throws {Error} When server returns 5xx status codes
3911
4018
  */
3912
- async updateOrgTelemetryConfig(orgSlug, telemetryData) {
4019
+ async updateOrgAlertTriage(orgSlug, alertId, triageData) {
3913
4020
  try {
3914
4021
  const data = await this.#executeWithRetry(
3915
4022
  async () => await getResponseJson(
3916
4023
  await createRequestWithJson(
3917
4024
  "PUT",
3918
4025
  this.#baseUrl,
3919
- `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
3920
- telemetryData,
4026
+ `orgs/${encodeURIComponent(orgSlug)}/triage/${encodeURIComponent(alertId)}`,
4027
+ triageData,
3921
4028
  { ...this.#reqOptions, hooks: this.#hooks }
3922
4029
  )
3923
4030
  )
@@ -3928,83 +4035,70 @@ var SocketSdk = class {
3928
4035
  }
3929
4036
  }
3930
4037
  /**
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
4038
+ * Update organization's license policy configuration.* Modifies allowed, restricted, and monitored license types.
3936
4039
  *
3937
4040
  * @throws {Error} When server returns 5xx status codes
3938
4041
  */
3939
- async getOrgTelemetryConfig(orgSlug) {
4042
+ async updateOrgLicensePolicy(orgSlug, policyData, queryParams) {
3940
4043
  try {
3941
4044
  const data = await this.#executeWithRetry(
3942
4045
  async () => await getResponseJson(
3943
- await createGetRequest(
4046
+ await createRequestWithJson(
4047
+ "POST",
3944
4048
  this.#baseUrl,
3945
- `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
4049
+ `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy?${queryToSearchParams(queryParams)}`,
4050
+ policyData,
3946
4051
  { ...this.#reqOptions, hooks: this.#hooks }
3947
4052
  )
3948
4053
  )
3949
4054
  );
3950
4055
  return this.#handleApiSuccess(data);
3951
- } catch (e) {
3952
- return await this.#handleApiError(e);
3953
- }
3954
- }
3955
- /**
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
4056
+ } catch (e) {
4057
+ return await this.#handleApiError(e);
4058
+ }
4059
+ }
4060
+ /**
4061
+ * Update organization's security policy configuration.* Modifies alert rules, severity thresholds, and enforcement settings.
3962
4062
  *
3963
4063
  * @throws {Error} When server returns 5xx status codes
3964
4064
  */
3965
- async postOrgTelemetry(orgSlug, telemetryData) {
4065
+ async updateOrgSecurityPolicy(orgSlug, policyData) {
3966
4066
  try {
3967
4067
  const data = await this.#executeWithRetry(
3968
4068
  async () => await getResponseJson(
3969
4069
  await createRequestWithJson(
3970
4070
  "POST",
3971
4071
  this.#baseUrl,
3972
- `orgs/${encodeURIComponent(orgSlug)}/telemetry`,
3973
- telemetryData,
4072
+ `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`,
4073
+ policyData,
3974
4074
  { ...this.#reqOptions, hooks: this.#hooks }
3975
4075
  )
3976
4076
  )
3977
4077
  );
3978
- return {
3979
- cause: void 0,
3980
- data,
3981
- error: void 0,
3982
- status: 200,
3983
- success: true
3984
- };
4078
+ return this.#handleApiSuccess(data);
3985
4079
  } catch (e) {
3986
- return this.#createQueryErrorResult(e);
4080
+ return await this.#handleApiError(e);
3987
4081
  }
3988
4082
  }
3989
4083
  /**
3990
- * Create a new webhook for an organization.
3991
- * Webhooks allow you to receive HTTP POST notifications when specific events occur.
4084
+ * Update organization's telemetry configuration.
4085
+ * Enables or disables telemetry for the organization.
3992
4086
  *
3993
4087
  * @param orgSlug - Organization identifier
3994
- * @param webhookData - Webhook configuration including name, URL, secret, and events
3995
- * @returns Created webhook details including webhook ID
4088
+ * @param telemetryData - Telemetry configuration with enabled flag
4089
+ * @returns Updated telemetry configuration
3996
4090
  *
3997
4091
  * @throws {Error} When server returns 5xx status codes
3998
4092
  */
3999
- async createOrgWebhook(orgSlug, webhookData) {
4093
+ async updateOrgTelemetryConfig(orgSlug, telemetryData) {
4000
4094
  try {
4001
4095
  const data = await this.#executeWithRetry(
4002
4096
  async () => await getResponseJson(
4003
4097
  await createRequestWithJson(
4004
- "POST",
4098
+ "PUT",
4005
4099
  this.#baseUrl,
4006
- `orgs/${encodeURIComponent(orgSlug)}/webhooks`,
4007
- webhookData,
4100
+ `orgs/${encodeURIComponent(orgSlug)}/telemetry/config`,
4101
+ telemetryData,
4008
4102
  { ...this.#reqOptions, hooks: this.#hooks }
4009
4103
  )
4010
4104
  )
@@ -4015,22 +4109,25 @@ var SocketSdk = class {
4015
4109
  }
4016
4110
  }
4017
4111
  /**
4018
- * Delete a webhook from an organization.
4019
- * This will stop all future webhook deliveries to the webhook URL.
4112
+ * Update an existing webhook's configuration.
4113
+ * All fields are optional - only provided fields will be updated.
4020
4114
  *
4021
4115
  * @param orgSlug - Organization identifier
4022
- * @param webhookId - Webhook ID to delete
4023
- * @returns Success status
4116
+ * @param webhookId - Webhook ID to update
4117
+ * @param webhookData - Updated webhook configuration
4118
+ * @returns Updated webhook details
4024
4119
  *
4025
4120
  * @throws {Error} When server returns 5xx status codes
4026
4121
  */
4027
- async deleteOrgWebhook(orgSlug, webhookId) {
4122
+ async updateOrgWebhook(orgSlug, webhookId, webhookData) {
4028
4123
  try {
4029
4124
  const data = await this.#executeWithRetry(
4030
4125
  async () => await getResponseJson(
4031
- await createDeleteRequest(
4126
+ await createRequestWithJson(
4127
+ "PUT",
4032
4128
  this.#baseUrl,
4033
4129
  `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
4130
+ webhookData,
4034
4131
  { ...this.#reqOptions, hooks: this.#hooks }
4035
4132
  )
4036
4133
  )
@@ -4041,86 +4138,230 @@ var SocketSdk = class {
4041
4138
  }
4042
4139
  }
4043
4140
  /**
4044
- * Get details of a specific webhook.
4045
- * Returns webhook configuration including events, URL, and filters.
4141
+ * Update configuration for a repository.
4142
+ *
4143
+ * Modifies monitoring settings, branch configuration, and scan preferences.
4046
4144
  *
4047
4145
  * @param orgSlug - Organization identifier
4048
- * @param webhookId - Webhook ID to retrieve
4049
- * @returns Webhook details
4146
+ * @param repoSlug - Repository slug/name
4147
+ * @param params - Configuration updates (description, homepage, default_branch, etc.)
4148
+ * @param options - Optional parameters including workspace
4149
+ * @returns Updated repository details
4150
+ *
4151
+ * @example
4152
+ * ```typescript
4153
+ * const result = await sdk.updateRepository('my-org', 'my-repo', {
4154
+ * description: 'Updated description',
4155
+ * default_branch: 'develop'
4156
+ * })
4157
+ *
4158
+ * if (result.success) {
4159
+ * console.log('Repository updated:', result.data.name)
4160
+ * }
4161
+ * ```
4050
4162
  *
4163
+ * @see https://docs.socket.dev/reference/updateorgrepo
4164
+ * @apiEndpoint POST /orgs/{org_slug}/repos/{repo_slug}
4165
+ * @quota 1 unit
4166
+ * @scopes repo:write
4051
4167
  * @throws {Error} When server returns 5xx status codes
4052
4168
  */
4053
- async getOrgWebhook(orgSlug, webhookId) {
4169
+ async updateRepository(orgSlug, repoSlug, params, options) {
4170
+ const { workspace } = {
4171
+ __proto__: null,
4172
+ ...options
4173
+ };
4174
+ const queryString = workspace ? `?${queryToSearchParams({ workspace })}` : "";
4054
4175
  try {
4055
4176
  const data = await this.#executeWithRetry(
4056
4177
  async () => await getResponseJson(
4057
- await createGetRequest(
4178
+ await createRequestWithJson(
4179
+ "POST",
4058
4180
  this.#baseUrl,
4059
- `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
4181
+ `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}${queryString}`,
4182
+ params,
4060
4183
  { ...this.#reqOptions, hooks: this.#hooks }
4061
4184
  )
4062
4185
  )
4063
4186
  );
4064
- return this.#handleApiSuccess(data);
4187
+ return {
4188
+ cause: void 0,
4189
+ data,
4190
+ error: void 0,
4191
+ status: 200,
4192
+ success: true
4193
+ };
4065
4194
  } catch (e) {
4066
- return await this.#handleApiError(e);
4195
+ const errorResult = await this.#handleApiError(e);
4196
+ return {
4197
+ cause: errorResult.cause,
4198
+ data: void 0,
4199
+ error: errorResult.error,
4200
+ status: errorResult.status,
4201
+ success: false
4202
+ };
4067
4203
  }
4068
4204
  }
4069
4205
  /**
4070
- * List all webhooks for an organization.
4071
- * Supports pagination and sorting options.
4206
+ * Update a repository label for an organization.
4207
+ *
4208
+ * Modifies label properties like name. Label names must be non-empty and less than 1000 characters.
4072
4209
  *
4073
4210
  * @param orgSlug - Organization identifier
4074
- * @param options - Optional query parameters for pagination and sorting
4075
- * @returns List of webhooks with pagination info
4211
+ * @param labelId - Label identifier
4212
+ * @param labelData - Label updates (typically name property)
4213
+ * @returns Updated label with guaranteed id and name fields
4214
+ *
4215
+ * @example
4216
+ * ```typescript
4217
+ * const result = await sdk.updateRepositoryLabel('my-org', 'label-id-123', { name: 'staging' })
4218
+ *
4219
+ * if (result.success) {
4220
+ * console.log('Label updated:', result.data.name)
4221
+ * console.log('Label ID:', result.data.id)
4222
+ * }
4223
+ * ```
4076
4224
  *
4225
+ * @see https://docs.socket.dev/reference/updateorgrepolabel
4226
+ * @apiEndpoint PUT /orgs/{org_slug}/repos/labels/{label_id}
4227
+ * @quota 1 unit
4228
+ * @scopes repo-label:update
4077
4229
  * @throws {Error} When server returns 5xx status codes
4078
4230
  */
4079
- async getOrgWebhooksList(orgSlug, options) {
4231
+ async updateRepositoryLabel(orgSlug, labelId, labelData) {
4080
4232
  try {
4081
4233
  const data = await this.#executeWithRetry(
4082
4234
  async () => await getResponseJson(
4083
- await createGetRequest(
4235
+ await createRequestWithJson(
4236
+ "PUT",
4084
4237
  this.#baseUrl,
4085
- `orgs/${encodeURIComponent(orgSlug)}/webhooks?${queryToSearchParams(options)}`,
4238
+ `orgs/${encodeURIComponent(orgSlug)}/repos/labels/${encodeURIComponent(labelId)}`,
4239
+ labelData,
4086
4240
  { ...this.#reqOptions, hooks: this.#hooks }
4087
4241
  )
4088
4242
  )
4089
4243
  );
4090
- return this.#handleApiSuccess(data);
4244
+ return {
4245
+ cause: void 0,
4246
+ data,
4247
+ error: void 0,
4248
+ status: 200,
4249
+ success: true
4250
+ };
4091
4251
  } catch (e) {
4092
- return await this.#handleApiError(e);
4252
+ const errorResult = await this.#handleApiError(e);
4253
+ return {
4254
+ cause: errorResult.cause,
4255
+ data: void 0,
4256
+ error: errorResult.error,
4257
+ status: errorResult.status,
4258
+ success: false
4259
+ };
4093
4260
  }
4094
4261
  }
4095
4262
  /**
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
4263
+ * Upload manifest files for dependency analysis.
4264
+ * Processes package files to create dependency snapshots and security analysis.
4103
4265
  *
4104
4266
  * @throws {Error} When server returns 5xx status codes
4105
4267
  */
4106
- async updateOrgWebhook(orgSlug, webhookId, webhookData) {
4268
+ async uploadManifestFiles(orgSlug, filepaths, options) {
4269
+ const { pathsRelativeTo = "." } = {
4270
+ __proto__: null,
4271
+ ...options
4272
+ };
4273
+ const basePath = resolveBasePath(pathsRelativeTo);
4274
+ const absFilepaths = resolveAbsPaths(filepaths, basePath);
4275
+ const { invalidPaths, validPaths } = (0, import_fs.validateFiles)(absFilepaths);
4276
+ if (this.#onFileValidation && invalidPaths.length > 0) {
4277
+ const result = await this.#onFileValidation(validPaths, invalidPaths, {
4278
+ operation: "uploadManifestFiles",
4279
+ orgSlug
4280
+ });
4281
+ if (!result.shouldContinue) {
4282
+ const errorMsg = result.errorMessage ?? "File validation failed";
4283
+ const finalCause = filterRedundantCause(errorMsg, result.errorCause);
4284
+ return {
4285
+ error: errorMsg,
4286
+ status: 400,
4287
+ success: false,
4288
+ ...finalCause ? { cause: finalCause } : {}
4289
+ };
4290
+ }
4291
+ }
4292
+ if (!this.#onFileValidation && invalidPaths.length > 0) {
4293
+ const samplePaths = invalidPaths.slice(0, 3).join("\n - ");
4294
+ const remaining = invalidPaths.length > 3 ? `
4295
+ ... and ${invalidPaths.length - 3} more` : "";
4296
+ console.warn(
4297
+ `Warning: ${invalidPaths.length} files skipped (unreadable):
4298
+ - ${samplePaths}${remaining}
4299
+ \u2192 This may occur with Yarn Berry PnP or pnpm symlinks.
4300
+ \u2192 Try: Run installation command to ensure files are accessible.`
4301
+ );
4302
+ }
4303
+ if (validPaths.length === 0) {
4304
+ const samplePaths = invalidPaths.slice(0, 5).join("\n - ");
4305
+ const remaining = invalidPaths.length > 5 ? `
4306
+ ... and ${invalidPaths.length - 5} more` : "";
4307
+ return {
4308
+ cause: [
4309
+ `All ${invalidPaths.length} files failed validation:`,
4310
+ ` - ${samplePaths}${remaining}`,
4311
+ "",
4312
+ "\u2192 Common causes:",
4313
+ " \xB7Yarn Berry PnP virtual filesystem (files are not on disk)",
4314
+ " \xB7pnpm symlinks pointing to inaccessible locations",
4315
+ " \xB7Incorrect file permissions",
4316
+ " \xB7Files were deleted after discovery",
4317
+ "",
4318
+ "\u2192 Solutions:",
4319
+ " \xB7Yarn Berry: Use `nodeLinker: node-modules` in .yarnrc.yml",
4320
+ " \xB7pnpm: Use `node-linker=hoisted` in .npmrc",
4321
+ " \xB7Check file permissions with: ls -la <file>",
4322
+ " \xB7Run package manager install command"
4323
+ ].join("\n"),
4324
+ error: "No readable manifest files found",
4325
+ status: 400,
4326
+ success: false
4327
+ };
4328
+ }
4107
4329
  try {
4108
4330
  const data = await this.#executeWithRetry(
4109
4331
  async () => await getResponseJson(
4110
- await createRequestWithJson(
4111
- "PUT",
4332
+ await createUploadRequest(
4112
4333
  this.#baseUrl,
4113
- `orgs/${encodeURIComponent(orgSlug)}/webhooks/${encodeURIComponent(webhookId)}`,
4114
- webhookData,
4334
+ `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`,
4335
+ createRequestBodyForFilepaths(validPaths, basePath),
4115
4336
  { ...this.#reqOptions, hooks: this.#hooks }
4116
4337
  )
4117
4338
  )
4118
4339
  );
4119
- return this.#handleApiSuccess(data);
4340
+ return this.#handleApiSuccess(
4341
+ data
4342
+ );
4120
4343
  } catch (e) {
4121
- return await this.#handleApiError(e);
4344
+ return await this.#handleApiError(
4345
+ e
4346
+ );
4122
4347
  }
4123
4348
  }
4349
+ /**
4350
+ * View detailed information about a specific patch by its UUID.
4351
+ *
4352
+ * This method retrieves comprehensive patch details including files,
4353
+ * vulnerabilities, description, license, and tier information.
4354
+ */
4355
+ async viewPatch(orgSlug, uuid) {
4356
+ const data = await getResponseJson(
4357
+ await createGetRequest(
4358
+ this.#baseUrl,
4359
+ `orgs/${encodeURIComponent(orgSlug)}/patches/view/${encodeURIComponent(uuid)}`,
4360
+ { ...this.#reqOptions, hooks: this.#hooks }
4361
+ )
4362
+ );
4363
+ return data;
4364
+ }
4124
4365
  };
4125
4366
  if ((0, import_debug2.isDebugNs)("heap")) {
4126
4367
  const used = process.memoryUsage();