@socketsecurity/sdk 1.10.0 → 1.11.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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [1.11.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.11.0) - 2025-10-04
8
+
9
+ ### Added
10
+ - Optional TTL caching for API responses with configurable cache duration
11
+ - New `cache` option (default: false) to enable response caching
12
+ - New `cacheTtl` option (default: 5 minutes) to customize cache duration
13
+
14
+ ## [1.10.1](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.10.1) - 2025-10-04
15
+
16
+ ### Added
17
+ - Automatic retry with exponential backoff to all HTTP API calls for improved reliability on transient failures
18
+
7
19
  ## [1.10.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.10.0) - 2025-10-04
8
20
 
9
21
  ### Added
package/README.md CHANGED
@@ -20,8 +20,8 @@ pnpm add @socketsecurity/sdk
20
20
  import { SocketSdk } from '@socketsecurity/sdk'
21
21
 
22
22
  const client = new SocketSdk('yourApiKeyHere', {
23
- retries: 3, // Retry failed requests up to 3 times (default: 3)
24
- retryDelay: 1000, // Start with 1s delay, exponential backoff (default: 1000ms)
23
+ retries: 3, // Retry failed requests up to 3 times (default: 0, disabled)
24
+ retryDelay: 1000, // Start with 1s delay, exponential backoff (default: 100ms)
25
25
  timeout: 30000, // Request timeout in milliseconds (optional)
26
26
  })
27
27
 
@@ -41,18 +41,19 @@ The SDK constructor accepts the following options:
41
41
  interface SocketSdkOptions {
42
42
  baseUrl?: string // API base URL (default: 'https://api.socket.dev/v0/')
43
43
  timeout?: number // Request timeout in milliseconds
44
- retries?: number // Number of retry attempts for failed requests (default: 3)
45
- retryDelay?: number // Initial retry delay in ms, with exponential backoff (default: 1000)
44
+ retries?: number // Number of retry attempts for failed requests (default: 0, disabled)
45
+ retryDelay?: number // Initial retry delay in ms, with exponential backoff (default: 100)
46
46
  userAgent?: string // Custom user agent string
47
47
  agent?: Agent // Custom HTTP agent for advanced networking
48
48
  }
49
49
  ```
50
50
 
51
51
  **Retry Logic:**
52
- - Automatically retries transient network errors and 5xx server responses
53
- - Uses exponential backoff: 1s, 2s, 4s, 8s... (configurable via `retryDelay`)
52
+ - **Disabled by default** (opt-in pattern following Node.js fs.rm() convention)
53
+ - Set `retries: 3` (recommended for production) to enable automatic retries
54
+ - Retries transient network errors and 5xx server responses
55
+ - Uses exponential backoff: 100ms, 200ms, 400ms, 800ms... (configurable via `retryDelay`)
54
56
  - Does NOT retry 401/403 authentication errors (immediate failure)
55
- - Set `retries: 0` to disable retry logic entirely
56
57
 
57
58
  ### Quota Management Example
58
59
 
@@ -81,8 +81,8 @@ export declare function reshapeArtifactForPublicPolicy<T extends Record<string,
81
81
  * Wraps any async HTTP function and retries on failure.
82
82
  *
83
83
  * @param fn - Async function to retry
84
- * @param retries - Number of retry attempts (default: 3)
85
- * @param retryDelay - Initial delay in ms (default: 1000)
84
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
85
+ * @param retryDelay - Initial delay in ms (default: 100)
86
86
  * @returns Result of the function call
87
87
  * @throws {Error} Last error if all retries exhausted
88
88
  */
@@ -91,23 +91,23 @@ export declare function withRetry<T>(fn: () => Promise<T>, retries?: number, ret
91
91
  * Create GET request with automatic retry logic.
92
92
  * Retries on network errors and 5xx responses.
93
93
  *
94
- * @param retries - Number of retry attempts (default: 3)
95
- * @param retryDelay - Initial delay in ms (default: 1000)
94
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
95
+ * @param retryDelay - Initial delay in ms (default: 100)
96
96
  */
97
97
  export declare function createGetRequestWithRetry(baseUrl: string, urlPath: string, options: RequestOptions, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
98
98
  /**
99
99
  * Create DELETE request with automatic retry logic.
100
100
  * Retries on network errors and 5xx responses.
101
101
  *
102
- * @param retries - Number of retry attempts (default: 3)
103
- * @param retryDelay - Initial delay in ms (default: 1000)
102
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
103
+ * @param retryDelay - Initial delay in ms (default: 100)
104
104
  */
105
105
  export declare function createDeleteRequestWithRetry(baseUrl: string, urlPath: string, options: RequestOptions, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
106
106
  /**
107
107
  * Create request with JSON payload and automatic retry logic.
108
108
  * Retries on network errors and 5xx responses.
109
109
  *
110
- * @param retries - Number of retry attempts (default: 3)
111
- * @param retryDelay - Initial delay in ms (default: 1000)
110
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
111
+ * @param retryDelay - Initial delay in ms (default: 100)
112
112
  */
113
113
  export declare function createRequestWithJsonAndRetry(method: SendMethod, baseUrl: string, urlPath: string, json: unknown, options: RequestOptions, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
@@ -273,12 +273,12 @@ function reshapeArtifactForPublicPolicy(data, isAuthenticated, actions) {
273
273
  * Wraps any async HTTP function and retries on failure.
274
274
  *
275
275
  * @param fn - Async function to retry
276
- * @param retries - Number of retry attempts (default: 3)
277
- * @param retryDelay - Initial delay in ms (default: 1000)
276
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
277
+ * @param retryDelay - Initial delay in ms (default: 100)
278
278
  * @returns Result of the function call
279
279
  * @throws {Error} Last error if all retries exhausted
280
280
  */
281
- async function withRetry(fn, retries = 3, retryDelay = 1000) {
281
+ async function withRetry(fn, retries = 0, retryDelay = 100) {
282
282
  let lastError;
283
283
  for (let attempt = 0; attempt <= retries; attempt++) {
284
284
  try {
@@ -319,29 +319,29 @@ async function withRetry(fn, retries = 3, retryDelay = 1000) {
319
319
  * Create GET request with automatic retry logic.
320
320
  * Retries on network errors and 5xx responses.
321
321
  *
322
- * @param retries - Number of retry attempts (default: 3)
323
- * @param retryDelay - Initial delay in ms (default: 1000)
322
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
323
+ * @param retryDelay - Initial delay in ms (default: 100)
324
324
  */
325
- async function createGetRequestWithRetry(baseUrl, urlPath, options, retries = 3, retryDelay = 1000) {
325
+ async function createGetRequestWithRetry(baseUrl, urlPath, options, retries = 0, retryDelay = 100) {
326
326
  return await withRetry(() => createGetRequest(baseUrl, urlPath, options), retries, retryDelay);
327
327
  }
328
328
  /**
329
329
  * Create DELETE request with automatic retry logic.
330
330
  * Retries on network errors and 5xx responses.
331
331
  *
332
- * @param retries - Number of retry attempts (default: 3)
333
- * @param retryDelay - Initial delay in ms (default: 1000)
332
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
333
+ * @param retryDelay - Initial delay in ms (default: 100)
334
334
  */
335
- async function createDeleteRequestWithRetry(baseUrl, urlPath, options, retries = 3, retryDelay = 1000) {
335
+ async function createDeleteRequestWithRetry(baseUrl, urlPath, options, retries = 0, retryDelay = 100) {
336
336
  return await withRetry(() => createDeleteRequest(baseUrl, urlPath, options), retries, retryDelay);
337
337
  }
338
338
  /**
339
339
  * Create request with JSON payload and automatic retry logic.
340
340
  * Retries on network errors and 5xx responses.
341
341
  *
342
- * @param retries - Number of retry attempts (default: 3)
343
- * @param retryDelay - Initial delay in ms (default: 1000)
342
+ * @param retries - Number of retry attempts (default: 0, retries disabled)
343
+ * @param retryDelay - Initial delay in ms (default: 100)
344
344
  */
345
- async function createRequestWithJsonAndRetry(method, baseUrl, urlPath, json, options, retries = 3, retryDelay = 1000) {
345
+ async function createRequestWithJsonAndRetry(method, baseUrl, urlPath, json, options, retries = 0, retryDelay = 100) {
346
346
  return await withRetry(() => createRequestWithJson(method, baseUrl, urlPath, json, options), retries, retryDelay);
347
347
  }
@@ -8,7 +8,7 @@ export declare class SocketSdk {
8
8
  #private;
9
9
  /**
10
10
  * Initialize Socket SDK with API token and configuration options.
11
- * Sets up authentication, base URL, HTTP client options, and retry behavior.
11
+ * Sets up authentication, base URL, HTTP client options, retry behavior, and caching.
12
12
  */
13
13
  constructor(apiToken: string, options?: SocketSdkOptions | undefined);
14
14
  /**
@@ -11,6 +11,7 @@ exports.SocketSdk = void 0;
11
11
  const node_events_1 = __importDefault(require("node:events"));
12
12
  const node_fs_1 = require("node:fs");
13
13
  const node_readline_1 = __importDefault(require("node:readline"));
14
+ const cache_with_ttl_1 = require("@socketsecurity/registry/lib/cache-with-ttl");
14
15
  const SOCKET_PUBLIC_API_TOKEN_1 = __importDefault(require("@socketsecurity/registry/lib/constants/SOCKET_PUBLIC_API_TOKEN"));
15
16
  const UNKNOWN_ERROR_1 = __importDefault(require("@socketsecurity/registry/lib/constants/UNKNOWN_ERROR"));
16
17
  const abort_signal_1 = __importDefault(require("@socketsecurity/registry/lib/constants/abort-signal"));
@@ -30,15 +31,16 @@ const utils_1 = require("./utils");
30
31
  class SocketSdk {
31
32
  #apiToken;
32
33
  #baseUrl;
34
+ #cache;
33
35
  #reqOptions;
34
36
  #retries;
35
37
  #retryDelay;
36
38
  /**
37
39
  * Initialize Socket SDK with API token and configuration options.
38
- * Sets up authentication, base URL, HTTP client options, and retry behavior.
40
+ * Sets up authentication, base URL, HTTP client options, retry behavior, and caching.
39
41
  */
40
42
  constructor(apiToken, options) {
41
- const { agent: agentOrObj, baseUrl = 'https://api.socket.dev/v0/', retries = 3, retryDelay = 1000, timeout, userAgent, } = { __proto__: null, ...options };
43
+ const { agent: agentOrObj, baseUrl = 'https://api.socket.dev/v0/', cache = false, cacheTtl = 5 * 60 * 1000, retries = 0, retryDelay = 100, timeout, userAgent, } = { __proto__: null, ...options };
42
44
  const agentKeys = agentOrObj ? Object.keys(agentOrObj) : [];
43
45
  const agentAsGotOptions = agentOrObj;
44
46
  const agent = (agentKeys.length && agentKeys.every(k => constants_1.httpAgentNames.has(k))
@@ -49,6 +51,13 @@ class SocketSdk {
49
51
  : agentOrObj);
50
52
  this.#apiToken = apiToken;
51
53
  this.#baseUrl = (0, utils_1.normalizeBaseUrl)(baseUrl);
54
+ this.#cache = cache
55
+ ? (0, cache_with_ttl_1.createTtlCache)({
56
+ memoize: true,
57
+ prefix: 'socket-sdk',
58
+ ttl: cacheTtl,
59
+ })
60
+ : undefined;
52
61
  this.#retries = retries;
53
62
  this.#retryDelay = retryDelay;
54
63
  this.#reqOptions = {
@@ -88,6 +97,20 @@ class SocketSdk {
88
97
  }
89
98
  return result;
90
99
  }
100
+ /**
101
+ * Execute a GET request with optional caching.
102
+ * Internal method for handling cached GET requests with retry logic.
103
+ */
104
+ async #getCached(cacheKey, fetcher) {
105
+ // If caching is disabled, just execute the request.
106
+ if (!this.#cache) {
107
+ return await this.#executeWithRetry(fetcher);
108
+ }
109
+ // Use cache with retry logic.
110
+ return await this.#cache.getOrFetch(cacheKey, async () => {
111
+ return await this.#executeWithRetry(fetcher);
112
+ });
113
+ }
91
114
  /**
92
115
  * Create async generator for streaming batch package URL processing.
93
116
  * Internal method for handling chunked PURL responses with error handling.
@@ -448,7 +471,7 @@ class SocketSdk {
448
471
  */
449
472
  async createOrgDiffScanFromIds(orgSlug, queryParams) {
450
473
  try {
451
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans?${(0, utils_1.queryToSearchParams)(queryParams)}`, {}, this.#reqOptions));
474
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans?${(0, utils_1.queryToSearchParams)(queryParams)}`, {}, this.#reqOptions)));
452
475
  return this.#handleApiSuccess(data);
453
476
  }
454
477
  catch (e) {
@@ -469,7 +492,7 @@ class SocketSdk {
469
492
  const basePath = (0, utils_1.resolveBasePath)(pathsRelativeTo);
470
493
  const absFilepaths = (0, utils_1.resolveAbsPaths)(filepaths, basePath);
471
494
  try {
472
- const data = await (0, http_client_1.getResponseJson)(await (0, file_upload_1.createUploadRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${(0, utils_1.queryToSearchParams)(queryParams)}`, (0, file_upload_1.createRequestBodyForFilepaths)(absFilepaths, basePath), this.#reqOptions));
495
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, file_upload_1.createUploadRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${(0, utils_1.queryToSearchParams)(queryParams)}`, (0, file_upload_1.createRequestBodyForFilepaths)(absFilepaths, basePath), this.#reqOptions)));
473
496
  return this.#handleApiSuccess(data);
474
497
  }
475
498
  catch (e) {
@@ -484,7 +507,7 @@ class SocketSdk {
484
507
  */
485
508
  async createOrgRepo(orgSlug, queryParams) {
486
509
  try {
487
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos`, queryParams, this.#reqOptions));
510
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos`, queryParams, this.#reqOptions)));
488
511
  return this.#handleApiSuccess(data);
489
512
  }
490
513
  catch (e) {
@@ -499,7 +522,7 @@ class SocketSdk {
499
522
  */
500
523
  async createOrgRepoLabel(orgSlug, repoSlug, labelData) {
501
524
  try {
502
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels`, labelData, this.#reqOptions));
525
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels`, labelData, this.#reqOptions)));
503
526
  return this.#handleApiSuccess(data);
504
527
  }
505
528
  catch (e) {
@@ -520,7 +543,7 @@ class SocketSdk {
520
543
  const basePath = (0, utils_1.resolveBasePath)(pathsRelativeTo);
521
544
  const absFilepaths = (0, utils_1.resolveAbsPaths)(filepaths, basePath);
522
545
  try {
523
- const data = await (0, http_client_1.getResponseJson)(await (0, file_upload_1.createUploadRequest)(this.#baseUrl, 'report/upload', [
546
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, file_upload_1.createUploadRequest)(this.#baseUrl, 'report/upload', [
524
547
  ...(0, file_upload_1.createRequestBodyForFilepaths)(absFilepaths, basePath),
525
548
  /* c8 ignore next 3 - Optional issueRules parameter edge case. */
526
549
  ...(issueRules
@@ -531,7 +554,7 @@ class SocketSdk {
531
554
  method: 'PUT',
532
555
  })
533
556
  /* c8 ignore next 3 - Success path return statement requires complex file upload mocking with authentication. */
534
- );
557
+ ));
535
558
  return this.#handleApiSuccess(data);
536
559
  }
537
560
  catch (e) {
@@ -546,7 +569,7 @@ class SocketSdk {
546
569
  */
547
570
  async deleteOrgDiffScan(orgSlug, diffScanId) {
548
571
  try {
549
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}`, this.#reqOptions));
572
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}`, this.#reqOptions)));
550
573
  return this.#handleApiSuccess(data);
551
574
  }
552
575
  catch (e) {
@@ -561,7 +584,7 @@ class SocketSdk {
561
584
  */
562
585
  async deleteOrgFullScan(orgSlug, fullScanId) {
563
586
  try {
564
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}`, this.#reqOptions));
587
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}`, this.#reqOptions)));
565
588
  return this.#handleApiSuccess(data);
566
589
  }
567
590
  catch (e) {
@@ -576,7 +599,7 @@ class SocketSdk {
576
599
  */
577
600
  async deleteOrgRepo(orgSlug, repoSlug) {
578
601
  try {
579
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`, this.#reqOptions));
602
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`, this.#reqOptions)));
580
603
  return this.#handleApiSuccess(data);
581
604
  }
582
605
  catch (e) {
@@ -591,7 +614,7 @@ class SocketSdk {
591
614
  */
592
615
  async deleteOrgRepoLabel(orgSlug, repoSlug, labelSlug) {
593
616
  try {
594
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels/${encodeURIComponent(labelSlug)}`, this.#reqOptions));
617
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels/${encodeURIComponent(labelSlug)}`, this.#reqOptions)));
595
618
  return this.#handleApiSuccess(data);
596
619
  }
597
620
  catch (e) {
@@ -606,7 +629,7 @@ class SocketSdk {
606
629
  */
607
630
  async deleteReport(reportId) {
608
631
  try {
609
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `report/delete/${encodeURIComponent(reportId)}`, this.#reqOptions));
632
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createDeleteRequest)(this.#baseUrl, `report/delete/${encodeURIComponent(reportId)}`, this.#reqOptions)));
610
633
  return this.#handleApiSuccess(data);
611
634
  }
612
635
  catch (e) {
@@ -621,7 +644,7 @@ class SocketSdk {
621
644
  */
622
645
  async exportCDX(orgSlug, fullScanId) {
623
646
  try {
624
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/sbom/export/cdx`, this.#reqOptions));
647
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/sbom/export/cdx`, this.#reqOptions)));
625
648
  return this.#handleApiSuccess(data);
626
649
  }
627
650
  catch (e) {
@@ -636,7 +659,7 @@ class SocketSdk {
636
659
  */
637
660
  async exportSPDX(orgSlug, fullScanId) {
638
661
  try {
639
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/sbom/export/spdx`, this.#reqOptions));
662
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/sbom/export/spdx`, this.#reqOptions)));
640
663
  return this.#handleApiSuccess(data);
641
664
  }
642
665
  catch (e) {
@@ -713,7 +736,7 @@ class SocketSdk {
713
736
  */
714
737
  async getAPITokens(orgSlug) {
715
738
  try {
716
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens`, this.#reqOptions));
739
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens`, this.#reqOptions)));
717
740
  return this.#handleApiSuccess(data);
718
741
  }
719
742
  catch (e) {
@@ -728,7 +751,7 @@ class SocketSdk {
728
751
  */
729
752
  async getAuditLogEvents(orgSlug, queryParams) {
730
753
  try {
731
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/audit-log?${(0, utils_1.queryToSearchParams)(queryParams)}`, this.#reqOptions));
754
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/audit-log?${(0, utils_1.queryToSearchParams)(queryParams)}`, this.#reqOptions)));
732
755
  return this.#handleApiSuccess(data);
733
756
  }
734
757
  catch (e) {
@@ -743,7 +766,7 @@ class SocketSdk {
743
766
  */
744
767
  async getDiffScanById(orgSlug, diffScanId) {
745
768
  try {
746
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}`, this.#reqOptions));
769
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}`, this.#reqOptions)));
747
770
  return this.#handleApiSuccess(data);
748
771
  }
749
772
  catch (e) {
@@ -757,7 +780,7 @@ class SocketSdk {
757
780
  * Products that the organization has access to use.
758
781
  */
759
782
  async getEnabledEntitlements(orgSlug) {
760
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/entitlements`, this.#reqOptions));
783
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/entitlements`, this.#reqOptions)));
761
784
  // Extract enabled products from the response.
762
785
  const items = data?.items || [];
763
786
  return items
@@ -771,7 +794,7 @@ class SocketSdk {
771
794
  * an organization, returning the complete list with their status.
772
795
  */
773
796
  async getEntitlements(orgSlug) {
774
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/entitlements`, this.#reqOptions));
797
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/entitlements`, this.#reqOptions)));
775
798
  return data?.items || [];
776
799
  }
777
800
  /**
@@ -782,7 +805,7 @@ class SocketSdk {
782
805
  */
783
806
  async getIssuesByNpmPackage(pkgName, version) {
784
807
  try {
785
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/issues`, this.#reqOptions));
808
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/issues`, this.#reqOptions)));
786
809
  return this.#handleApiSuccess(data);
787
810
  }
788
811
  catch (e) {
@@ -797,7 +820,7 @@ class SocketSdk {
797
820
  */
798
821
  async getOrgAnalytics(time) {
799
822
  try {
800
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `analytics/org/${encodeURIComponent(time)}`, this.#reqOptions));
823
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `analytics/org/${encodeURIComponent(time)}`, this.#reqOptions)));
801
824
  return this.#handleApiSuccess(data);
802
825
  }
803
826
  catch (e) {
@@ -812,7 +835,7 @@ class SocketSdk {
812
835
  */
813
836
  async getOrganizations() {
814
837
  try {
815
- const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'organizations', this.#reqOptions)));
838
+ const data = await this.#getCached('organizations', async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'organizations', this.#reqOptions)));
816
839
  return this.#handleApiSuccess(data);
817
840
  }
818
841
  catch (e) {
@@ -827,7 +850,7 @@ class SocketSdk {
827
850
  */
828
851
  async getOrgFullScanBuffered(orgSlug, fullScanId) {
829
852
  try {
830
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}`, this.#reqOptions));
853
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}`, this.#reqOptions)));
831
854
  return this.#handleApiSuccess(data);
832
855
  }
833
856
  catch (e) {
@@ -842,7 +865,7 @@ class SocketSdk {
842
865
  */
843
866
  async getOrgFullScanList(orgSlug, queryParams) {
844
867
  try {
845
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${(0, utils_1.queryToSearchParams)(queryParams)}`, this.#reqOptions));
868
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${(0, utils_1.queryToSearchParams)(queryParams)}`, this.#reqOptions)));
846
869
  return this.#handleApiSuccess(data);
847
870
  }
848
871
  catch (e) {
@@ -857,7 +880,7 @@ class SocketSdk {
857
880
  */
858
881
  async getOrgFullScanMetadata(orgSlug, fullScanId) {
859
882
  try {
860
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/metadata`, this.#reqOptions));
883
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/metadata`, this.#reqOptions)));
861
884
  return this.#handleApiSuccess(data);
862
885
  }
863
886
  catch (e) {
@@ -871,7 +894,7 @@ class SocketSdk {
871
894
  */
872
895
  async getOrgLicensePolicy(orgSlug) {
873
896
  try {
874
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy`, this.#reqOptions));
897
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy`, this.#reqOptions)));
875
898
  return this.#handleApiSuccess(data);
876
899
  }
877
900
  catch (e) {
@@ -888,7 +911,7 @@ class SocketSdk {
888
911
  const orgSlugParam = encodeURIComponent(orgSlug);
889
912
  const repoSlugParam = encodeURIComponent(repoSlug);
890
913
  try {
891
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${orgSlugParam}/repos/${repoSlugParam}`, this.#reqOptions));
914
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${orgSlugParam}/repos/${repoSlugParam}`, this.#reqOptions)));
892
915
  return this.#handleApiSuccess(data);
893
916
  }
894
917
  catch (e) {
@@ -903,7 +926,7 @@ class SocketSdk {
903
926
  */
904
927
  async getOrgRepoLabel(orgSlug, repoSlug, labelSlug) {
905
928
  try {
906
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels/${encodeURIComponent(labelSlug)}`, this.#reqOptions));
929
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels/${encodeURIComponent(labelSlug)}`, this.#reqOptions)));
907
930
  return this.#handleApiSuccess(data);
908
931
  }
909
932
  catch (e) {
@@ -918,7 +941,7 @@ class SocketSdk {
918
941
  */
919
942
  async getOrgRepoLabelList(orgSlug, repoSlug) {
920
943
  try {
921
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels`, this.#reqOptions));
944
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels`, this.#reqOptions)));
922
945
  return this.#handleApiSuccess(data);
923
946
  }
924
947
  catch (e) {
@@ -933,7 +956,7 @@ class SocketSdk {
933
956
  */
934
957
  async getOrgRepoList(orgSlug, queryParams) {
935
958
  try {
936
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos?${(0, utils_1.queryToSearchParams)(queryParams)}`, this.#reqOptions));
959
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos?${(0, utils_1.queryToSearchParams)(queryParams)}`, this.#reqOptions)));
937
960
  return this.#handleApiSuccess(data);
938
961
  }
939
962
  catch (e) {
@@ -947,7 +970,7 @@ class SocketSdk {
947
970
  */
948
971
  async getOrgSecurityPolicy(orgSlug) {
949
972
  try {
950
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`, this.#reqOptions));
973
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`, this.#reqOptions)));
951
974
  return this.#handleApiSuccess(data);
952
975
  }
953
976
  catch (e) {
@@ -962,7 +985,7 @@ class SocketSdk {
962
985
  */
963
986
  async getOrgTriage(orgSlug) {
964
987
  try {
965
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/triage`, this.#reqOptions));
988
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/triage`, this.#reqOptions)));
966
989
  return this.#handleApiSuccess(data);
967
990
  }
968
991
  catch (e) {
@@ -977,7 +1000,7 @@ class SocketSdk {
977
1000
  */
978
1001
  async getQuota() {
979
1002
  try {
980
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'quota', this.#reqOptions));
1003
+ const data = await this.#getCached('quota', async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'quota', this.#reqOptions)));
981
1004
  return this.#handleApiSuccess(data);
982
1005
  }
983
1006
  catch (e) {
@@ -992,7 +1015,7 @@ class SocketSdk {
992
1015
  */
993
1016
  async getRepoAnalytics(repo, time) {
994
1017
  try {
995
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `analytics/repo/${encodeURIComponent(repo)}/${encodeURIComponent(time)}`, this.#reqOptions));
1018
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `analytics/repo/${encodeURIComponent(repo)}/${encodeURIComponent(time)}`, this.#reqOptions)));
996
1019
  return this.#handleApiSuccess(data);
997
1020
  }
998
1021
  catch (e) {
@@ -1007,7 +1030,7 @@ class SocketSdk {
1007
1030
  */
1008
1031
  async getScan(id) {
1009
1032
  try {
1010
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `report/view/${encodeURIComponent(id)}`, this.#reqOptions));
1033
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `report/view/${encodeURIComponent(id)}`, this.#reqOptions)));
1011
1034
  return this.#handleApiSuccess(data);
1012
1035
  }
1013
1036
  catch (e) {
@@ -1022,7 +1045,7 @@ class SocketSdk {
1022
1045
  */
1023
1046
  async getScanList() {
1024
1047
  try {
1025
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'report/list', this.#reqOptions), 'GET');
1048
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'report/list', this.#reqOptions), 'GET'));
1026
1049
  return this.#handleApiSuccess(data);
1027
1050
  }
1028
1051
  catch (e) {
@@ -1037,7 +1060,7 @@ class SocketSdk {
1037
1060
  */
1038
1061
  async getScoreByNpmPackage(pkgName, version) {
1039
1062
  try {
1040
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`, this.#reqOptions));
1063
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`, this.#reqOptions)));
1041
1064
  return this.#handleApiSuccess(data);
1042
1065
  }
1043
1066
  catch (e) {
@@ -1052,7 +1075,7 @@ class SocketSdk {
1052
1075
  */
1053
1076
  async getSupportedScanFiles() {
1054
1077
  try {
1055
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'report/supported', this.#reqOptions));
1078
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, 'report/supported', this.#reqOptions)));
1056
1079
  return this.#handleApiSuccess(data);
1057
1080
  }
1058
1081
  catch (e) {
@@ -1067,7 +1090,7 @@ class SocketSdk {
1067
1090
  */
1068
1091
  async listOrgDiffScans(orgSlug) {
1069
1092
  try {
1070
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans`, this.#reqOptions));
1093
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/diff-scans`, this.#reqOptions)));
1071
1094
  return this.#handleApiSuccess(data);
1072
1095
  }
1073
1096
  catch (e) {
@@ -1082,7 +1105,7 @@ class SocketSdk {
1082
1105
  */
1083
1106
  async postAPIToken(orgSlug, tokenData) {
1084
1107
  try {
1085
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens`, tokenData, this.#reqOptions));
1108
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens`, tokenData, this.#reqOptions)));
1086
1109
  return this.#handleApiSuccess(data);
1087
1110
  }
1088
1111
  catch (e) {
@@ -1097,7 +1120,7 @@ class SocketSdk {
1097
1120
  */
1098
1121
  async postAPITokensRevoke(orgSlug, tokenId) {
1099
1122
  try {
1100
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/revoke`, {}, this.#reqOptions));
1123
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/revoke`, {}, this.#reqOptions)));
1101
1124
  return this.#handleApiSuccess(data);
1102
1125
  }
1103
1126
  catch (e) {
@@ -1112,7 +1135,7 @@ class SocketSdk {
1112
1135
  */
1113
1136
  async postAPITokensRotate(orgSlug, tokenId) {
1114
1137
  try {
1115
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/rotate`, {}, this.#reqOptions));
1138
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/rotate`, {}, this.#reqOptions)));
1116
1139
  return this.#handleApiSuccess(data);
1117
1140
  }
1118
1141
  catch (e) {
@@ -1127,7 +1150,7 @@ class SocketSdk {
1127
1150
  */
1128
1151
  async postAPITokenUpdate(orgSlug, tokenId, updateData) {
1129
1152
  try {
1130
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/update`, updateData, this.#reqOptions));
1153
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/tokens/${encodeURIComponent(tokenId)}/update`, updateData, this.#reqOptions)));
1131
1154
  return this.#handleApiSuccess(data);
1132
1155
  }
1133
1156
  catch (e) {
@@ -1142,7 +1165,7 @@ class SocketSdk {
1142
1165
  */
1143
1166
  async postSettings(selectors) {
1144
1167
  try {
1145
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, 'settings', { json: selectors }, this.#reqOptions));
1168
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, 'settings', { json: selectors }, this.#reqOptions)));
1146
1169
  return this.#handleApiSuccess(data);
1147
1170
  }
1148
1171
  catch (e) {
@@ -1157,7 +1180,7 @@ class SocketSdk {
1157
1180
  */
1158
1181
  async searchDependencies(queryParams) {
1159
1182
  try {
1160
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, 'dependencies/search', queryParams, this.#reqOptions));
1183
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, 'dependencies/search', queryParams, this.#reqOptions)));
1161
1184
  return this.#handleApiSuccess(data);
1162
1185
  }
1163
1186
  catch (e) {
@@ -1277,7 +1300,7 @@ class SocketSdk {
1277
1300
  * Note: This method returns a ReadableStream for processing large datasets.
1278
1301
  */
1279
1302
  async streamPatchesFromScan(orgSlug, scanId) {
1280
- const response = await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/patches/scan/${encodeURIComponent(scanId)}`, this.#reqOptions);
1303
+ const response = await this.#executeWithRetry(async () => await (0, http_client_1.createGetRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/patches/scan/${encodeURIComponent(scanId)}`, this.#reqOptions));
1281
1304
  // Check for HTTP error status codes.
1282
1305
  if (!(0, http_client_1.isResponseOk)(response)) {
1283
1306
  throw new http_client_1.ResponseError(response, 'GET Request failed');
@@ -1321,7 +1344,7 @@ class SocketSdk {
1321
1344
  */
1322
1345
  async updateOrgAlertTriage(orgSlug, alertId, triageData) {
1323
1346
  try {
1324
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('PUT', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/triage/${encodeURIComponent(alertId)}`, triageData, this.#reqOptions));
1347
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('PUT', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/triage/${encodeURIComponent(alertId)}`, triageData, this.#reqOptions)));
1325
1348
  return this.#handleApiSuccess(data);
1326
1349
  }
1327
1350
  catch (e) {
@@ -1335,7 +1358,7 @@ class SocketSdk {
1335
1358
  */
1336
1359
  async updateOrgLicensePolicy(orgSlug, policyData, queryParams) {
1337
1360
  try {
1338
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy?${(0, utils_1.queryToSearchParams)(queryParams)}`, policyData, this.#reqOptions));
1361
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/license-policy?${(0, utils_1.queryToSearchParams)(queryParams)}`, policyData, this.#reqOptions)));
1339
1362
  return this.#handleApiSuccess(data);
1340
1363
  }
1341
1364
  catch (e) {
@@ -1350,7 +1373,7 @@ class SocketSdk {
1350
1373
  */
1351
1374
  async updateOrgRepo(orgSlug, repoSlug, queryParams) {
1352
1375
  try {
1353
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`, queryParams, this.#reqOptions));
1376
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`, queryParams, this.#reqOptions)));
1354
1377
  return this.#handleApiSuccess(data);
1355
1378
  }
1356
1379
  catch (e) {
@@ -1365,7 +1388,7 @@ class SocketSdk {
1365
1388
  */
1366
1389
  async updateOrgRepoLabel(orgSlug, repoSlug, labelSlug, labelData) {
1367
1390
  try {
1368
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('PUT', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels/${encodeURIComponent(labelSlug)}`, labelData, this.#reqOptions));
1391
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('PUT', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}/labels/${encodeURIComponent(labelSlug)}`, labelData, this.#reqOptions)));
1369
1392
  return this.#handleApiSuccess(data);
1370
1393
  }
1371
1394
  catch (e) {
@@ -1379,7 +1402,7 @@ class SocketSdk {
1379
1402
  */
1380
1403
  async updateOrgSecurityPolicy(orgSlug, policyData) {
1381
1404
  try {
1382
- const data = await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`, policyData, this.#reqOptions));
1405
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, http_client_1.createRequestWithJson)('POST', this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/settings/security-policy`, policyData, this.#reqOptions)));
1383
1406
  return this.#handleApiSuccess(data);
1384
1407
  }
1385
1408
  catch (e) {
@@ -1400,7 +1423,7 @@ class SocketSdk {
1400
1423
  const basePath = (0, utils_1.resolveBasePath)(pathsRelativeTo);
1401
1424
  const absFilepaths = (0, utils_1.resolveAbsPaths)(filepaths, basePath);
1402
1425
  try {
1403
- const data = await (0, http_client_1.getResponseJson)(await (0, file_upload_1.createUploadRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`, (0, file_upload_1.createRequestBodyForFilepaths)(absFilepaths, basePath), this.#reqOptions));
1426
+ const data = await this.#executeWithRetry(async () => await (0, http_client_1.getResponseJson)(await (0, file_upload_1.createUploadRequest)(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`, (0, file_upload_1.createRequestBodyForFilepaths)(absFilepaths, basePath), this.#reqOptions)));
1404
1427
  return this.#handleApiSuccess(data);
1405
1428
  }
1406
1429
  catch (e) {
package/dist/types.d.ts CHANGED
@@ -129,12 +129,38 @@ export type SocketSdkGenericResult<T> = {
129
129
  status: number;
130
130
  success: false;
131
131
  };
132
+ /**
133
+ * Configuration options for SocketSdk.
134
+ */
132
135
  export interface SocketSdkOptions {
136
+ /** HTTP agent for connection pooling and proxy support */
133
137
  agent?: Agent | GotOptions | undefined;
138
+ /** Base URL for Socket API (default: 'https://api.socket.dev/v0/') */
134
139
  baseUrl?: string | undefined;
140
+ /**
141
+ * Enable TTL caching for API responses (default: false).
142
+ * When enabled, GET requests are cached with a 5-minute TTL.
143
+ */
144
+ cache?: boolean | undefined;
145
+ /**
146
+ * Cache TTL in milliseconds (default: 300000 = 5 minutes).
147
+ * Only used when cache is enabled.
148
+ */
149
+ cacheTtl?: number | undefined;
150
+ /**
151
+ * Number of retry attempts on failure (default: 0, retries disabled).
152
+ * Retries are opt-in following Node.js fs.rm() pattern.
153
+ * Recommended: 3 for production, 0 for testing.
154
+ */
135
155
  retries?: number | undefined;
156
+ /**
157
+ * Initial delay in milliseconds between retries (default: 100).
158
+ * Uses exponential backoff: 100ms, 200ms, 400ms, etc.
159
+ */
136
160
  retryDelay?: number | undefined;
161
+ /** Request timeout in milliseconds */
137
162
  timeout?: number | undefined;
163
+ /** Custom User-Agent header */
138
164
  userAgent?: string | undefined;
139
165
  }
140
166
  export type UploadManifestFilesResponse = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/sdk",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "license": "MIT",
5
5
  "description": "SDK for the Socket API client",
6
6
  "author": {
@@ -75,7 +75,7 @@
75
75
  "update:socket": "pnpm -r update '@socketsecurity/*' --latest"
76
76
  },
77
77
  "dependencies": {
78
- "@socketsecurity/registry": "1.4.0"
78
+ "@socketsecurity/registry": "1.4.2"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@biomejs/biome": "2.2.4",