@socketsecurity/sdk 3.1.3 → 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/CHANGELOG.md CHANGED
@@ -4,6 +4,54 @@ 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
+ ## [3.3.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.3.0) - 2026-01-25
8
+
9
+ ### Added
10
+
11
+ - New SDK convenience methods for OpenAPI v3.3.0 endpoints:
12
+ - `batchOrgPackageFetch(orgSlug, components, options)` - Organization-scoped PURL batch lookup with security policy label support
13
+ - `exportOpenVEX(orgSlug, id, options)` - Export vulnerability exploitability data as OpenVEX v0.2.0 documents (includes patch data and reachability analysis)
14
+ - `getOrgAlertFullScans(orgSlug, options)` - List full scans associated with specific alerts
15
+ - `rescanFullScan(orgSlug, fullScanId, options)` - Rescan existing full scans with shallow (policy reapplication) or deep (dependency resolution rerun) modes
16
+ - Repository endpoints now support optional `workspace` parameter for workspace-scoped operations:
17
+ - `createRepository(orgSlug, params, { workspace })`
18
+ - `deleteRepository(orgSlug, repoSlug, { workspace })`
19
+ - `getRepository(orgSlug, repoSlug, { workspace })`
20
+ - `updateRepository(orgSlug, repoSlug, params, { workspace })`
21
+
22
+ ### Changed
23
+
24
+ - Updated `@socketsecurity/lib` to v5.5.3
25
+ - TypeScript: Auto-generated strict types from OpenAPI schema for improved type safety
26
+ - TypeScript: All optional properties now explicitly include `| undefined` for better null checking
27
+ - Synced OpenAPI type definitions with latest API specification
28
+
29
+ ## [3.2.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.2.0) - 2025-12-08
30
+
31
+ ### Added
32
+
33
+ - New API methods:
34
+ - `getOrgTelemetryConfig()` - Get organization telemetry configuration
35
+ - `updateOrgTelemetryConfig()` - Update organization telemetry configuration
36
+ - `getOrgWebhooksList()` - List organization webhooks
37
+ - `createOrgWebhook()` - Create organization webhook
38
+ - `getOrgWebhook()` - Get organization webhook details
39
+ - `updateOrgWebhook()` - Update organization webhook
40
+ - `deleteOrgWebhook()` - Delete organization webhook
41
+ - `getOrgAlertsList()` - List organization alerts
42
+ - `getOrgFixes()` - Get available vulnerability fixes for repositories or scans
43
+ - `createOrgFullScanFromArchive()` - Create full scan from archive file (.tar, .tar.gz/.tgz, or .zip)
44
+ - `downloadOrgFullScanFilesAsTar()` - Download full scan files as tarball to local filesystem
45
+ - Per-endpoint TTL configuration: `cacheTtl` option accepts object with endpoint-specific TTL values (e.g., `{ default: 300_000, getIssues: 600_000 }`)
46
+ - Request/response logging: `hooks` option with `onRequest(info)` and `onResponse(info)` callbacks for debugging and monitoring
47
+ - PURL batch processing: `cachedResultsOnly` query parameter (return only cached results, skip new scans) and `summary` query parameter (include summary with counts of malformed, resolved, and not found PURLs) in `batchPackageFetch()` and `batchPackageStream()`
48
+ - UTF-8 filename support: `uploadManifestFiles()`, `createFullScan()`, `createDependenciesSnapshot()`, and `createOrgFullScanFromArchive()` automatically handle international filenames (Japanese, Cyrillic, emoji, and other UTF-8 characters)
49
+
50
+ ### Changed
51
+
52
+ - Updated `@socketsecurity/lib` to v5.0.0
53
+ - Synced with OpenAPI definition
54
+
7
55
  ## [3.1.3](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.1.3) - 2025-11-04
8
56
 
9
57
  ### Fixed
@@ -455,9 +503,9 @@ To migrate from v1.x to v2.0:
455
503
 
456
504
  ### Changed
457
505
  - Synced with OpenAPI definition
458
- - Added new `/openapi.json` endpoint for retrieving API specification in JSON format
459
- - Updated repo label filter descriptions to document empty string ("") usage for repositories with no labels
460
- - Added 'dual' threat category type
506
+ - Added new `/openapi.json` endpoint for retrieving API specification in JSON format
507
+ - Updated repo label filter descriptions to document empty string ("") usage for repositories with no labels
508
+ - Added 'dual' threat category type
461
509
 
462
510
  ## [1.8.4](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.8.4) - 2025-10-01
463
511
 
package/README.md CHANGED
@@ -2,42 +2,20 @@
2
2
 
3
3
  [![Socket Badge](https://socket.dev/api/badge/npm/package/@socketsecurity/sdk)](https://socket.dev/npm/package/@socketsecurity/sdk)
4
4
  [![CI](https://github.com/SocketDev/socket-sdk-js/actions/workflows/ci.yml/badge.svg)](https://github.com/SocketDev/socket-sdk-js/actions/workflows/ci.yml)
5
+ ![Coverage](https://img.shields.io/badge/coverage-80%25-brightgreen)
5
6
 
6
7
  [![Follow @SocketSecurity](https://img.shields.io/twitter/follow/SocketSecurity?style=social)](https://twitter.com/SocketSecurity)
7
8
  [![Follow @socket.dev on Bluesky](https://img.shields.io/badge/Follow-@socket.dev-1DA1F2?style=social&logo=bluesky)](https://bsky.app/profile/socket.dev)
8
9
 
9
- JavaScript SDK for [Socket.dev](https://socket.dev/) API - Security analysis, vulnerability scanning, and compliance monitoring for software supply chains.
10
+ JavaScript SDK for [Socket.dev](https://socket.dev/) API.
10
11
 
11
- ## Table of Contents
12
-
13
- - [Installation](#installation)
14
- - [Quick Start](#quick-start)
15
- - [API Methods](#api-methods) - [Full API Reference](./docs/api-reference.md)
16
- - [Documentation](#documentation)
17
- - [Examples](#examples)
18
-
19
- ## At a Glance
20
-
21
- | Feature | Description |
22
- |---------|-------------|
23
- | **Package Analysis** | Quick security checks for npm packages |
24
- | **Full Scans** | Deep analysis with SBOM support |
25
- | **Batch Operations** | Analyze multiple packages efficiently |
26
- | **Policy Management** | Configure security & license rules |
27
- | **Quota Utilities** | Cost calculation & planning helpers |
28
- | **TypeScript** | Full type safety with auto-generated types |
29
-
30
- **Requirements:** Node.js 18+ ·ESM only (v2.0+)
31
-
32
- ## Installation
12
+ ## Install
33
13
 
34
14
  ```bash
35
15
  pnpm add @socketsecurity/sdk
36
16
  ```
37
17
 
38
- **Note:** Version 2.0+ is ESM-only. For CommonJS support, use version 1.x.
39
-
40
- ## Quick Start
18
+ ## Usage
41
19
 
42
20
  ```typescript
43
21
  import { SocketSdk } from '@socketsecurity/sdk'
@@ -69,107 +47,13 @@ const batchResult = await client.batchPackageFetch({
69
47
  })
70
48
  ```
71
49
 
72
- **[→ Configuration](./docs/api-reference.md#configuration)**
73
-
74
- ## API Methods
75
-
76
- ### Package Analysis
77
-
78
- Quick security checks: `batchPackageFetch()` ·`batchPackageStream()` ·`getIssuesByNpmPackage()` ·`getScoreByNpmPackage()`
79
-
80
- [→ Documentation](./docs/api-reference.md#package-analysis)
81
-
82
- ### Scanning & Analysis
83
-
84
- Project scanning: `createDependenciesSnapshot()` ·`createOrgFullScan()` ·`createScanFromFilepaths()` ·`getScan()` ·`getScanList()` ·`getSupportedScanFiles()`
85
-
86
- [→ Documentation](./docs/api-reference.md#scanning--analysis)
87
-
88
- ### Organization Management
89
-
90
- Organizations and repositories: `getOrganizations()` ·`createOrgRepo()` ·`getOrgRepo()` ·`getOrgRepoList()` ·`updateOrgRepo()` ·`deleteOrgRepo()`
91
-
92
- [→ Documentation](./docs/api-reference.md#organization-management)
93
-
94
- ### Policy & Settings
95
-
96
- Security configuration: `getOrgSecurityPolicy()` ·`updateOrgSecurityPolicy()` ·`getOrgLicensePolicy()` ·`updateOrgLicensePolicy()` ·`postSettings()`
97
-
98
- [→ Documentation](./docs/api-reference.md#policy--settings)
99
-
100
- ### Full Scan Management
101
-
102
- Deep analysis: `getOrgFullScanList()` ·`getOrgFullScanMetadata()` ·`getOrgFullScanBuffered()` ·`streamOrgFullScan()` ·`deleteOrgFullScan()`
103
-
104
- [→ Documentation](./docs/api-reference.md#full-scan-management)
105
-
106
- ### Diff Scans
107
-
108
- Scan comparison: `createOrgDiffScanFromIds()` ·`getDiffScanById()` ·`listOrgDiffScans()` ·`deleteOrgDiffScan()`
109
-
110
- [→ Documentation](./docs/api-reference.md#diff-scans)
111
-
112
- ### Patches & Vulnerabilities
113
-
114
- Security fixes: `streamPatchesFromScan()` ·`viewPatch()`
115
-
116
- [→ Documentation](./docs/api-reference.md#patches--vulnerabilities)
117
-
118
- ### Alert & Triage
119
-
120
- Alert management: `getOrgTriage()` ·`updateOrgAlertTriage()`
121
-
122
- [→ Documentation](./docs/api-reference.md#alert--triage)
123
-
124
- ### Export & Integration
125
-
126
- SBOM export: `exportCDX()` ·`exportSPDX()` ·`searchDependencies()` ·`uploadManifestFiles()`
127
-
128
- [→ Documentation](./docs/api-reference.md#export--integration)
129
-
130
- ### Repository Labels
131
-
132
- Categorization: `createOrgRepoLabel()` ·`getOrgRepoLabel()` ·`getOrgRepoLabelList()` ·`updateOrgRepoLabel()` ·`deleteOrgRepoLabel()`
133
-
134
- [→ Documentation](./docs/api-reference.md#repository-labels)
135
-
136
- ### Analytics & Monitoring
137
-
138
- Usage metrics: `getQuota()` ·`getOrgAnalytics()` ·`getRepoAnalytics()` ·`getAuditLogEvents()`
139
-
140
- [→ Documentation](./docs/api-reference.md#analytics--monitoring)
141
-
142
- ### Authentication & Access
143
-
144
- API tokens: `getAPITokens()` ·`postAPIToken()` ·`postAPITokensRotate()` ·`postAPITokensRevoke()` ·`postAPITokenUpdate()`
145
-
146
- [→ Documentation](./docs/api-reference.md#authentication--access)
147
-
148
- ### Entitlements
149
-
150
- Feature access: `getEnabledEntitlements()` ·`getEntitlements()`
151
-
152
- [→ Documentation](./docs/api-reference.md#entitlements)
153
-
154
- ### Quota Utilities
155
-
156
- Cost helpers: `getQuotaCost()` ·`getRequiredPermissions()` ·`calculateTotalQuotaCost()` ·`hasQuotaForMethods()` ·`getMethodsByQuotaCost()` ·`getMethodsByPermissions()` ·`getQuotaUsageSummary()` ·`getAllMethodRequirements()`
157
-
158
- [→ Documentation](./docs/quota-management.md)
159
-
160
- ### Advanced Query Methods
161
-
162
- Raw API access: `getApi()` ·`sendApi()`
163
-
164
- [→ Documentation](./docs/api-reference.md#advanced-query-methods)
165
-
166
50
  ## Documentation
167
51
 
168
52
  | Guide | Description |
169
53
  |-------|-------------|
54
+ | **[Getting Started](./docs/getting-started.md)** | Quick start for contributors (5 min setup) |
170
55
  | **[API Reference](./docs/api-reference.md)** | Complete API method documentation |
171
56
  | **[Usage Examples](./docs/usage-examples.md)** | Real-world patterns and code samples |
172
- | **[Getting Started](./docs/getting-started.md)** | Development setup and workflow |
173
57
  | **[Quota Management](./docs/quota-management.md)** | Cost tiers (0/10/100) and utilities |
174
58
  | **[Testing Guide](./docs/dev/testing.md)** | Test helpers, fixtures, and patterns |
175
59
  | **[Method Reference](./docs/when-to-use-what.md)** | Quick method selection guide |
@@ -183,14 +67,6 @@ See **[usage-examples.md](./docs/usage-examples.md)** for complete examples incl
183
67
  - Policy management
184
68
  - Quota planning
185
69
 
186
- ## Related Projects
187
-
188
- | Project | Description |
189
- |---------|-------------|
190
- | [Socket.dev API](https://docs.socket.dev/reference) | Official REST API documentation |
191
- | [Socket CLI](https://github.com/SocketDev/socket-cli) | Command-line interface |
192
- | [Socket GitHub App](https://github.com/apps/socket-security) | Automated GitHub integration |
193
-
194
70
  ## License
195
71
 
196
72
  MIT
@@ -4,10 +4,13 @@ export declare const DEFAULT_USER_AGENT: string;
4
4
  export declare const DEFAULT_HTTP_TIMEOUT = 30000;
5
5
  export declare const DEFAULT_RETRIES = 3;
6
6
  export declare const DEFAULT_RETRY_DELAY = 1000;
7
+ export declare const DEFAULT_CACHE_TTL: number;
8
+ export declare const RECOMMENDED_CACHE_TTL_ORGANIZATIONS: number;
9
+ export declare const RECOMMENDED_CACHE_TTL_QUOTA: number;
7
10
  export declare const MAX_HTTP_TIMEOUT: number;
8
11
  export declare const MIN_HTTP_TIMEOUT = 5000;
9
12
  export declare const MAX_RESPONSE_SIZE: number;
10
13
  export declare const MAX_STREAM_SIZE: number;
11
14
  export declare const SOCKET_PUBLIC_BLOB_STORE_URL = "https://socketusercontent.com";
12
15
  export declare const httpAgentNames: Set<string>;
13
- export declare const publicPolicy: Map<"ambiguousClassifier" | "badEncoding" | "badSemver" | "badSemverDependency" | "bidi" | "binScriptConfusion" | "chromeContentScript" | "chromeHostPermission" | "chromePermission" | "chromeWildcardHostPermission" | "chronoAnomaly" | "compromisedSSHKey" | "copyleftLicense" | "criticalCVE" | "cve" | "debugAccess" | "deprecated" | "deprecatedException" | "deprecatedLicense" | "didYouMean" | "dynamicRequire" | "emptyPackage" | "envVars" | "explicitlyUnlicensedItem" | "extraneousDependency" | "fileDependency" | "filesystemAccess" | "floatingDependency" | "generic" | "ghaArgToEnv" | "ghaArgToOutput" | "ghaArgToSink" | "ghaContextToEnv" | "ghaContextToOutput" | "ghaContextToSink" | "ghaEnvToSink" | "gitDependency" | "gitHubDependency" | "gptAnomaly" | "gptDidYouMean" | "gptMalware" | "gptSecurity" | "hasNativeCode" | "highEntropyStrings" | "homoglyphs" | "httpDependency" | "installScripts" | "invalidPackageJSON" | "invisibleChars" | "licenseChange" | "licenseException" | "licenseSpdxDisj" | "longStrings" | "majorRefactor" | "malware" | "manifestConfusion" | "mediumCVE" | "mildCVE" | "minifiedFile" | "miscLicenseIssues" | "missingAuthor" | "missingDependency" | "missingLicense" | "missingTarball" | "mixedLicense" | "modifiedException" | "modifiedLicense" | "networkAccess" | "newAuthor" | "noAuthorData" | "noBugTracker" | "noLicenseFound" | "noREADME" | "noRepository" | "noTests" | "noV1" | "noWebsite" | "nonOSILicense" | "nonSPDXLicense" | "nonpermissiveLicense" | "notice" | "obfuscatedFile" | "obfuscatedRequire" | "peerDependency" | "potentialVulnerability" | "semverAnomaly" | "shellAccess" | "shellScriptOverride" | "shrinkwrap" | "socketUpgradeAvailable" | "suspiciousStarActivity" | "suspiciousString" | "telemetry" | "trivialPackage" | "troll" | "typeModuleCompatibility" | "uncaughtOptionalDependency" | "unclearLicense" | "unidentifiedLicense" | "unmaintained" | "unpopularPackage" | "unpublished" | "unresolvedRequire" | "unsafeCopyright" | "unstableOwnership" | "unusedDependency" | "urlStrings" | "usesEval" | "vsxActivationWildcard" | "vsxDebuggerContribution" | "vsxExtensionDependency" | "vsxExtensionPack" | "vsxProposedApiUsage" | "vsxUntrustedWorkspaceSupported" | "vsxVirtualWorkspaceSupported" | "vsxWebviewContribution" | "vsxWorkspaceContainsActivation" | "zeroWidth", ALERT_ACTION>;
16
+ export declare const publicPolicy: Map<"ambiguousClassifier" | "badEncoding" | "badSemver" | "badSemverDependency" | "bidi" | "binScriptConfusion" | "chromeContentScript" | "chromeHostPermission" | "chromePermission" | "chromeWildcardHostPermission" | "chronoAnomaly" | "compromisedSSHKey" | "copyleftLicense" | "criticalCVE" | "cve" | "debugAccess" | "deprecated" | "deprecatedException" | "deprecatedLicense" | "didYouMean" | "dynamicRequire" | "emptyPackage" | "envVars" | "explicitlyUnlicensedItem" | "extraneousDependency" | "fileDependency" | "filesystemAccess" | "floatingDependency" | "generic" | "ghaArgToEnv" | "ghaArgToOutput" | "ghaArgToSink" | "ghaContextToEnv" | "ghaContextToOutput" | "ghaContextToSink" | "ghaEnvToSink" | "gitDependency" | "gitHubDependency" | "gptAnomaly" | "gptDidYouMean" | "gptMalware" | "gptSecurity" | "hasNativeCode" | "highEntropyStrings" | "homoglyphs" | "httpDependency" | "installScripts" | "invalidPackageJSON" | "invisibleChars" | "licenseChange" | "licenseException" | "licenseSpdxDisj" | "longStrings" | "majorRefactor" | "malware" | "manifestConfusion" | "mediumCVE" | "mildCVE" | "minifiedFile" | "miscLicenseIssues" | "missingAuthor" | "missingDependency" | "missingLicense" | "missingTarball" | "mixedLicense" | "modifiedException" | "modifiedLicense" | "networkAccess" | "newAuthor" | "noAuthorData" | "noBugTracker" | "noLicenseFound" | "noREADME" | "noRepository" | "noTests" | "noV1" | "noWebsite" | "nonOSILicense" | "nonSPDXLicense" | "nonpermissiveLicense" | "notice" | "obfuscatedFile" | "obfuscatedRequire" | "peerDependency" | "potentialVulnerability" | "recentlyPublished" | "semverAnomaly" | "shellAccess" | "shellScriptOverride" | "shrinkwrap" | "socketUpgradeAvailable" | "suspiciousStarActivity" | "suspiciousString" | "telemetry" | "tooManyFiles" | "trivialPackage" | "troll" | "typeModuleCompatibility" | "uncaughtOptionalDependency" | "unclearLicense" | "unidentifiedLicense" | "unmaintained" | "unpopularPackage" | "unpublished" | "unresolvedRequire" | "unsafeCopyright" | "unstableOwnership" | "unusedDependency" | "urlStrings" | "usesEval" | "vsxActivationWildcard" | "vsxDebuggerContribution" | "vsxExtensionDependency" | "vsxExtensionPack" | "vsxProposedApiUsage" | "vsxUntrustedWorkspaceSupported" | "vsxVirtualWorkspaceSupported" | "vsxWebviewContribution" | "vsxWorkspaceContainsActivation" | "zeroWidth", ALERT_ACTION>;
@@ -1,6 +1,5 @@
1
- import { Readable } from 'node:stream';
2
- import type { RequestOptions } from './types';
3
- import type { ReadStream } from 'node:fs';
1
+ import FormData from 'form-data';
2
+ import type { RequestOptionsWithHooks } from './types';
4
3
  import type { IncomingMessage } from 'node:http';
5
4
  /**
6
5
  * Create multipart form-data body parts for file uploads.
@@ -8,16 +7,16 @@ import type { IncomingMessage } from 'node:http';
8
7
  *
9
8
  * @throws {Error} When file cannot be read (ENOENT, EACCES, EISDIR, etc.)
10
9
  */
11
- export declare function createRequestBodyForFilepaths(filepaths: string[], basePath: string): Array<Array<string | ReadStream>>;
10
+ export declare function createRequestBodyForFilepaths(filepaths: string[], basePath: string): FormData;
12
11
  /**
13
12
  * Create multipart form-data body part for JSON data.
14
13
  * Converts JSON object to readable stream with appropriate headers.
15
14
  */
16
- export declare function createRequestBodyForJson(jsonData: unknown, basename?: string): Array<string | Readable>;
15
+ export declare function createRequestBodyForJson(jsonData: unknown, basename?: string): FormData;
17
16
  /**
18
- * Create and execute a multipart/form-data upload request.
19
- * Streams large files efficiently with backpressure handling and early server validation.
17
+ * Create and execute a multipart/form-data upload request using form-data library.
18
+ * Streams large files efficiently with automatic backpressure handling and early server validation.
20
19
  *
21
20
  * @throws {Error} When network errors occur or stream processing fails
22
21
  */
23
- export declare function createUploadRequest(baseUrl: string, urlPath: string, requestBodyNoBoundaries: Array<string | Readable | Array<string | Readable>>, options: RequestOptions): Promise<IncomingMessage>;
22
+ export declare function createUploadRequest(baseUrl: string, urlPath: string, form: FormData, options?: RequestOptionsWithHooks | undefined): Promise<IncomingMessage>;
@@ -4,8 +4,12 @@
4
4
  */
5
5
  import http from 'node:http';
6
6
  import https from 'node:https';
7
- import type { RequestOptions, SendMethod } from './types';
7
+ import type { RequestOptionsWithHooks, SendMethod } from './types';
8
+ import type { JsonValue } from '@socketsecurity/lib/json/types';
8
9
  import type { ClientRequest, IncomingMessage } from 'node:http';
10
+ /**
11
+ * Array of sensitive header names that should be redacted in logs
12
+ */
9
13
  /**
10
14
  * HTTP response error for Socket API requests.
11
15
  * Extends Error with response details for debugging failed API calls.
@@ -24,7 +28,7 @@ export declare class ResponseError extends Error {
24
28
  *
25
29
  * @throws {Error} When network or timeout errors occur
26
30
  */
27
- export declare function createDeleteRequest(baseUrl: string, urlPath: string, options: RequestOptions): Promise<IncomingMessage>;
31
+ export declare function createDeleteRequest(baseUrl: string, urlPath: string, options?: RequestOptionsWithHooks | undefined): Promise<IncomingMessage>;
28
32
  /**
29
33
  * Create and execute an HTTP GET request.
30
34
  * Returns the response stream for further processing.
@@ -32,7 +36,7 @@ export declare function createDeleteRequest(baseUrl: string, urlPath: string, op
32
36
  *
33
37
  * @throws {Error} When network or timeout errors occur
34
38
  */
35
- export declare function createGetRequest(baseUrl: string, urlPath: string, options: RequestOptions): Promise<IncomingMessage>;
39
+ export declare function createGetRequest(baseUrl: string, urlPath: string, options?: RequestOptionsWithHooks | undefined): Promise<IncomingMessage>;
36
40
  /**
37
41
  * Create and execute an HTTP request with JSON payload.
38
42
  * Automatically sets appropriate content headers and serializes the body.
@@ -40,7 +44,7 @@ export declare function createGetRequest(baseUrl: string, urlPath: string, optio
40
44
  *
41
45
  * @throws {Error} When network or timeout errors occur
42
46
  */
43
- export declare function createRequestWithJson(method: SendMethod, baseUrl: string, urlPath: string, json: unknown, options: RequestOptions): Promise<IncomingMessage>;
47
+ export declare function createRequestWithJson(method: SendMethod, baseUrl: string, urlPath: string, json: unknown, options?: RequestOptionsWithHooks | undefined): Promise<IncomingMessage>;
44
48
  /**
45
49
  * Read the response body from an HTTP error response.
46
50
  * Accumulates all chunks into a complete string for error handling.
@@ -70,28 +74,15 @@ export declare function getResponse(req: ClientRequest): Promise<IncomingMessage
70
74
  * @throws {ResponseError} When response has non-2xx status code
71
75
  * @throws {SyntaxError} When response body contains invalid JSON
72
76
  */
73
- export declare function getResponseJson(response: IncomingMessage, method?: string | undefined): Promise<import("@socketsecurity/lib/json").JsonValue | undefined>;
74
- /**
75
- * Check if HTTP response has a successful status code (2xx range).
76
- * Returns true for status codes between 200-299, false otherwise.
77
- */
78
- export declare function isResponseOk(response: IncomingMessage): boolean;
79
- /**
80
- * Transform artifact data based on authentication status.
81
- * Filters and compacts response data for public/free-tier users.
82
- */
83
- export declare function reshapeArtifactForPublicPolicy<T extends Record<string, unknown>>(data: T, isAuthenticated: boolean, actions?: string | undefined): T;
77
+ export declare function getResponseJson(response: IncomingMessage, method?: string | undefined): Promise<JsonValue | undefined>;
84
78
  /**
85
- * Retry helper for HTTP requests with exponential backoff.
86
- * Wraps any async HTTP function and retries on failure.
79
+ * Create DELETE request with automatic retry logic.
80
+ * Retries on network errors and 5xx responses.
87
81
  *
88
- * @param fn - Async function to retry
89
82
  * @param retries - Number of retry attempts (default: 0, retries disabled)
90
83
  * @param retryDelay - Initial delay in ms (default: 100)
91
- * @returns Result of the function call
92
- * @throws {Error} Last error if all retries exhausted
93
84
  */
94
- export declare function withRetry<T>(fn: () => Promise<T>, retries?: number, retryDelay?: number): Promise<T>;
85
+ export declare function createDeleteRequestWithRetry(baseUrl: string, urlPath: string, options?: RequestOptionsWithHooks | undefined, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
95
86
  /**
96
87
  * Create GET request with automatic retry logic.
97
88
  * Retries on network errors and 5xx responses.
@@ -99,20 +90,33 @@ export declare function withRetry<T>(fn: () => Promise<T>, retries?: number, ret
99
90
  * @param retries - Number of retry attempts (default: 0, retries disabled)
100
91
  * @param retryDelay - Initial delay in ms (default: 100)
101
92
  */
102
- export declare function createGetRequestWithRetry(baseUrl: string, urlPath: string, options: RequestOptions, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
93
+ export declare function createGetRequestWithRetry(baseUrl: string, urlPath: string, options?: RequestOptionsWithHooks | undefined, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
103
94
  /**
104
- * Create DELETE request with automatic retry logic.
95
+ * Create request with JSON payload and automatic retry logic.
105
96
  * Retries on network errors and 5xx responses.
106
97
  *
107
98
  * @param retries - Number of retry attempts (default: 0, retries disabled)
108
99
  * @param retryDelay - Initial delay in ms (default: 100)
109
100
  */
110
- export declare function createDeleteRequestWithRetry(baseUrl: string, urlPath: string, options: RequestOptions, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
101
+ export declare function createRequestWithJsonAndRetry(method: SendMethod, baseUrl: string, urlPath: string, json: unknown, options?: RequestOptionsWithHooks | undefined, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
111
102
  /**
112
- * Create request with JSON payload and automatic retry logic.
113
- * Retries on network errors and 5xx responses.
103
+ * Check if HTTP response has a successful status code (2xx range).
104
+ * Returns true for status codes between 200-299, false otherwise.
105
+ */
106
+ export declare function isResponseOk(response: IncomingMessage): boolean;
107
+ /**
108
+ * Transform artifact data based on authentication status.
109
+ * Filters and compacts response data for public/free-tier users.
110
+ */
111
+ export declare function reshapeArtifactForPublicPolicy<T extends Record<string, unknown>>(data: T, isAuthenticated: boolean, actions?: string | undefined): T;
112
+ /**
113
+ * Retry helper for HTTP requests with exponential backoff.
114
+ * Wraps any async HTTP function and retries on failure.
114
115
  *
116
+ * @param fn - Async function to retry
115
117
  * @param retries - Number of retry attempts (default: 0, retries disabled)
116
118
  * @param retryDelay - Initial delay in ms (default: 100)
119
+ * @returns Result of the function call
120
+ * @throws {Error} Last error if all retries exhausted
117
121
  */
118
- export declare function createRequestWithJsonAndRetry(method: SendMethod, baseUrl: string, urlPath: string, json: unknown, options: RequestOptions, retries?: number, retryDelay?: number): Promise<IncomingMessage>;
122
+ export declare function withRetry<T>(fn: () => Promise<T>, retries?: number, retryDelay?: number): Promise<T>;
package/dist/index.d.ts CHANGED
@@ -3,13 +3,13 @@
3
3
  * Provides the SocketSdk class and utility functions for Socket security analysis API interactions.
4
4
  */
5
5
  import { DEFAULT_USER_AGENT, httpAgentNames, publicPolicy } from './constants';
6
- import { normalizeBaseUrl, promiseWithResolvers, queryToSearchParams, resolveAbsPaths, resolveBasePath } from './utils';
6
+ import { calculateWordSetSimilarity, filterRedundantCause, normalizeBaseUrl, promiseWithResolvers, queryToSearchParams, resolveAbsPaths, resolveBasePath, shouldOmitReason } from './utils';
7
7
  export { createRequestBodyForFilepaths, createRequestBodyForJson, createUploadRequest, } from './file-upload';
8
8
  export { createDeleteRequest, createGetRequest, createRequestWithJson, getErrorResponseBody, getHttpModule, getResponse, getResponseJson, isResponseOk, ResponseError, reshapeArtifactForPublicPolicy, } from './http-client';
9
9
  export { calculateTotalQuotaCost, getAllMethodRequirements, getMethodRequirements, getMethodsByPermissions, getMethodsByQuotaCost, getQuotaCost, getQuotaUsageSummary, getRequiredPermissions, hasQuotaForMethods, } from './quota-utils';
10
10
  export { SocketSdk } from './socket-sdk-class';
11
- export type { ALERT_ACTION, ALERT_TYPE, Agent, ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CompactSocketArtifact, CompactSocketArtifactAlert, CreateDependenciesSnapshotOptions, CreateOrgFullScanOptions, CreateScanFromFilepathsOptions, CustomResponseType, Entitlement, EntitlementsResponse, FileValidationCallback, FileValidationResult, GetOptions, GotOptions, HeadersRecord, PatchFile, PatchRecord, PatchViewResponse, QueryParams, RequestOptions, SecurityAlert, SendMethod, SendOptions, SocketArtifact, SocketArtifactAlert, SocketArtifactWithExtras, SocketId, SocketMetricSchema, SocketSdkArrayElement, SocketSdkData, SocketSdkErrorResult, SocketSdkGenericResult, SocketSdkOperations, SocketSdkOptions, SocketSdkResult, SocketSdkSuccessResult, StreamOrgFullScanOptions, UploadManifestFilesError, UploadManifestFilesOptions, UploadManifestFilesResponse, UploadManifestFilesReturnType, Vulnerability, } from './types';
12
- export type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanItem, FullScanListData, FullScanListResult, FullScanResult, ListFullScansOptions, ListRepositoriesOptions, OrganizationItem, OrganizationsResult, RepositoriesListData, RepositoriesListResult, RepositoryItem, RepositoryLabelItem, RepositoryLabelResult, RepositoryLabelsListData, RepositoryLabelsListResult, RepositoryResult, StreamFullScanOptions, StrictErrorResult, StrictResult, } from './types-strict';
11
+ export type { ALERT_ACTION, ALERT_TYPE, Agent, ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CompactSocketArtifact, CompactSocketArtifactAlert, CreateDependenciesSnapshotOptions, CreateOrgFullScanOptions, CreateScanFromFilepathsOptions, CustomResponseType, Entitlement, EntitlementsResponse, FileValidationCallback, FileValidationResult, GetOptions, GotOptions, HeadersRecord, PatchFile, PatchRecord, PatchViewResponse, TelemetryConfig, PostOrgTelemetryPayload, PostOrgTelemetryResponse, QueryParams, RequestInfo, RequestOptions, RequestOptionsWithHooks, ResponseInfo, SecurityAlert, SendMethod, SendOptions, SocketArtifact, SocketArtifactAlert, SocketArtifactWithExtras, SocketId, SocketMetricSchema, SocketSdkArrayElement, SocketSdkData, SocketSdkErrorResult, SocketSdkGenericResult, SocketSdkOperations, SocketSdkOptions, SocketSdkResult, SocketSdkSuccessResult, StreamOrgFullScanOptions, UploadManifestFilesError, UploadManifestFilesOptions, UploadManifestFilesResponse, UploadManifestFilesReturnType, Vulnerability, } from './types';
12
+ export type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanItem, FullScanListData, FullScanListResult, FullScanResult, GetRepositoryOptions, ListFullScansOptions, ListRepositoriesOptions, OrganizationItem, OrganizationsResult, RepositoriesListData, RepositoriesListResult, RepositoryItem, RepositoryLabelItem, RepositoryLabelResult, RepositoryLabelsListData, RepositoryLabelsListResult, RepositoryResult, StreamFullScanOptions, StrictErrorResult, StrictResult, } from './types-strict';
13
13
  export { createUserAgentFromPkgJson } from './user-agent';
14
- export { normalizeBaseUrl, promiseWithResolvers, queryToSearchParams, resolveAbsPaths, resolveBasePath, };
14
+ export { calculateWordSetSimilarity, filterRedundantCause, normalizeBaseUrl, promiseWithResolvers, queryToSearchParams, resolveAbsPaths, resolveBasePath, shouldOmitReason, };
15
15
  export { DEFAULT_USER_AGENT, httpAgentNames, publicPolicy };