@socketsecurity/sdk 2.0.6 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/dist/index.d.ts +2 -1
- package/dist/socket-sdk-class.d.ts +398 -58
- package/dist/types-strict.d.ts +260 -0
- package/dist/types.d.ts +53 -0
- package/package.json +3 -3
- package/types/api.d.ts +31 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,64 @@ 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.0.1](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.0.1) - 2025-10-23
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Export `FileValidationCallback` and `FileValidationResult` types for consumers implementing file validation callbacks
|
|
12
|
+
|
|
13
|
+
## [3.0.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.0.0) - 2025-10-23
|
|
14
|
+
|
|
15
|
+
### ⚠️ BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
#### Removed Deprecated Methods
|
|
18
|
+
|
|
19
|
+
The following methods mapped to deprecated `/report/*` backend endpoints and have been removed:
|
|
20
|
+
|
|
21
|
+
- **`createScan()`** - Use `createFullScan()` instead
|
|
22
|
+
- **`deleteScan()`** - Use `deleteFullScan()` instead
|
|
23
|
+
- **`getScan()`** - Use `getFullScan()` instead
|
|
24
|
+
- **`listScans()`** - Use `listFullScans()` instead
|
|
25
|
+
|
|
26
|
+
#### Method Renames (Following REST Conventions)
|
|
27
|
+
|
|
28
|
+
**Full Scans (Modern API):**
|
|
29
|
+
- `getOrgFullScanList()` → `listFullScans()` with `ListFullScansOptions`
|
|
30
|
+
- `createOrgFullScan()` → `createFullScan()` with `CreateFullScanOptions`
|
|
31
|
+
- `getOrgFullScanBuffered()` → `getFullScan()`
|
|
32
|
+
- `deleteOrgFullScan()` → `deleteFullScan()`
|
|
33
|
+
- `streamOrgFullScan()` → `streamFullScan()` with `StreamFullScanOptions`
|
|
34
|
+
- `getOrgFullScanMetadata()` → `getFullScanMetadata()`
|
|
35
|
+
|
|
36
|
+
**Organizations:**
|
|
37
|
+
- `getOrganizations()` → `listOrganizations()`
|
|
38
|
+
|
|
39
|
+
**Repositories:**
|
|
40
|
+
- `getOrgRepoList()` → `listRepositories()` with `ListRepositoriesOptions`
|
|
41
|
+
- `getOrgRepo()` → `getRepository()`
|
|
42
|
+
- `createOrgRepo()` → `createRepository()`
|
|
43
|
+
- `updateOrgRepo()` → `updateRepository()`
|
|
44
|
+
- `deleteOrgRepo()` → `deleteRepository()`
|
|
45
|
+
|
|
46
|
+
#### Type System Improvements
|
|
47
|
+
|
|
48
|
+
Strict types now mark guaranteed API fields as required instead of optional, improving IntelliSense autocomplete.
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- **File Validation Callback:** New `onFileValidation` option in `SocketSdkOptions` allows customizing error handling when unreadable files are detected. File-upload methods (`uploadManifestFiles()`, `createFullScan()`, `createDependenciesSnapshot()`) now automatically validate file readability, preventing ENOENT errors from Yarn Berry PnP virtual filesystems and pnpm symlink issues.
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
|
|
56
|
+
- File-upload methods automatically skip unreadable files with warnings instead of failing
|
|
57
|
+
|
|
58
|
+
See [docs/migration-v3.md](./docs/migration-v3.md) and [docs/when-to-use-what.md](./docs/when-to-use-what.md) for migration guidance.
|
|
59
|
+
|
|
60
|
+
## [2.0.7](https://github.com/SocketDev/socket-sdk-js/releases/tag/v2.0.7) - 2025-10-22
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
- Sync with openapi definition
|
|
64
|
+
|
|
7
65
|
## [2.0.6](https://github.com/SocketDev/socket-sdk-js/releases/tag/v2.0.6) - 2025-10-22
|
|
8
66
|
|
|
9
67
|
### Fixed
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export { createRequestBodyForFilepaths, createRequestBodyForJson, createUploadRe
|
|
|
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, 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';
|
|
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';
|
|
12
13
|
export { createUserAgentFromPkgJson } from './user-agent';
|
|
13
14
|
export { normalizeBaseUrl, promiseWithResolvers, queryToSearchParams, resolveAbsPaths, resolveBasePath, };
|
|
14
15
|
export { DEFAULT_USER_AGENT, httpAgentNames, publicPolicy };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CreateDependenciesSnapshotOptions,
|
|
1
|
+
import type { ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CreateDependenciesSnapshotOptions, Entitlement, GetOptions, PatchViewResponse, QueryParams, SendOptions, SocketSdkGenericResult, SocketSdkOptions, SocketSdkResult, StreamOrgFullScanOptions, UploadManifestFilesError, UploadManifestFilesOptions, UploadManifestFilesReturnType } from './types';
|
|
2
|
+
import type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanListResult, FullScanResult, ListFullScansOptions, ListRepositoriesOptions, OrganizationsResult, RepositoriesListResult, RepositoryLabelResult, RepositoryLabelsListResult, RepositoryResult, StrictErrorResult } from './types-strict';
|
|
2
3
|
import type { IncomingMessage } from 'node:http';
|
|
3
4
|
/**
|
|
4
5
|
* Socket SDK for programmatic access to Socket.dev security analysis APIs.
|
|
@@ -48,33 +49,97 @@ export declare class SocketSdk {
|
|
|
48
49
|
*/
|
|
49
50
|
createOrgDiffScanFromIds(orgSlug: string, queryParams?: QueryParams | undefined): Promise<SocketSdkResult<'createOrgDiffScanFromIds'>>;
|
|
50
51
|
/**
|
|
51
|
-
* Create a
|
|
52
|
-
* Uploads project files and initiates full security analysis.
|
|
52
|
+
* Create a full security scan for an organization.
|
|
53
53
|
*
|
|
54
|
+
* Uploads project manifest files and initiates full security analysis.
|
|
55
|
+
* Returns scan metadata with guaranteed required fields.
|
|
56
|
+
*
|
|
57
|
+
* @param orgSlug - Organization identifier
|
|
58
|
+
* @param filepaths - Array of file paths to upload (package.json, package-lock.json, etc.)
|
|
59
|
+
* @param options - Scan configuration including repository, branch, and commit details
|
|
60
|
+
* @returns Full scan metadata including ID and URLs
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const result = await sdk.createFullScan('my-org',
|
|
65
|
+
* ['package.json', 'package-lock.json'],
|
|
66
|
+
* {
|
|
67
|
+
* repo: 'my-repo',
|
|
68
|
+
* branch: 'main',
|
|
69
|
+
* commit_message: 'Update dependencies',
|
|
70
|
+
* commit_hash: 'abc123',
|
|
71
|
+
* pathsRelativeTo: './my-project'
|
|
72
|
+
* }
|
|
73
|
+
* )
|
|
74
|
+
*
|
|
75
|
+
* if (result.success) {
|
|
76
|
+
* console.log('Scan ID:', result.data.id)
|
|
77
|
+
* console.log('Report URL:', result.data.html_report_url)
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @see https://docs.socket.dev/reference/createorgfullscan
|
|
82
|
+
* @apiEndpoint POST /orgs/{org_slug}/full-scans
|
|
83
|
+
* @quota 1 unit
|
|
84
|
+
* @scopes full-scans:create
|
|
54
85
|
* @throws {Error} When server returns 5xx status codes
|
|
55
86
|
*/
|
|
56
|
-
|
|
87
|
+
createFullScan(orgSlug: string, filepaths: string[], options: CreateFullScanOptions): Promise<FullScanResult | StrictErrorResult>;
|
|
57
88
|
/**
|
|
58
89
|
* Create a new repository in an organization.
|
|
90
|
+
*
|
|
59
91
|
* Registers a repository for monitoring and security scanning.
|
|
60
92
|
*
|
|
93
|
+
* @param orgSlug - Organization identifier
|
|
94
|
+
* @param params - Repository configuration (name, description, homepage, etc.)
|
|
95
|
+
* @returns Created repository details
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const result = await sdk.createRepository('my-org', {
|
|
100
|
+
* name: 'my-repo',
|
|
101
|
+
* description: 'My project repository',
|
|
102
|
+
* homepage: 'https://example.com'
|
|
103
|
+
* })
|
|
104
|
+
*
|
|
105
|
+
* if (result.success) {
|
|
106
|
+
* console.log('Repository created:', result.data.id)
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @see https://docs.socket.dev/reference/createorgrepo
|
|
111
|
+
* @apiEndpoint POST /orgs/{org_slug}/repos
|
|
112
|
+
* @quota 1 unit
|
|
113
|
+
* @scopes repo:write
|
|
61
114
|
* @throws {Error} When server returns 5xx status codes
|
|
62
115
|
*/
|
|
63
|
-
|
|
116
|
+
createRepository(orgSlug: string, params?: QueryParams | undefined): Promise<RepositoryResult | StrictErrorResult>;
|
|
64
117
|
/**
|
|
65
118
|
* Create a new repository label for an organization.
|
|
66
|
-
* Adds label for repository categorization and management.
|
|
67
119
|
*
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
* Analyzes uploaded files for security vulnerabilities and policy violations.
|
|
120
|
+
* Labels can be used to group and organize repositories and apply security/license policies.
|
|
121
|
+
*
|
|
122
|
+
* @param orgSlug - Organization identifier
|
|
123
|
+
* @param labelData - Label configuration (must include name property)
|
|
124
|
+
* @returns Created label with guaranteed id and name fields
|
|
74
125
|
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const result = await sdk.createRepositoryLabel('my-org', { name: 'production' })
|
|
129
|
+
*
|
|
130
|
+
* if (result.success) {
|
|
131
|
+
* console.log('Label created:', result.data.id)
|
|
132
|
+
* console.log('Label name:', result.data.name)
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @see https://docs.socket.dev/reference/createorgrepolabel
|
|
137
|
+
* @apiEndpoint POST /orgs/{org_slug}/repos/labels
|
|
138
|
+
* @quota 1 unit
|
|
139
|
+
* @scopes repo-label:create
|
|
75
140
|
* @throws {Error} When server returns 5xx status codes
|
|
76
141
|
*/
|
|
77
|
-
|
|
142
|
+
createRepositoryLabel(orgSlug: string, labelData: QueryParams): Promise<RepositoryLabelResult | StrictErrorResult>;
|
|
78
143
|
/**
|
|
79
144
|
* Delete a diff scan from an organization.
|
|
80
145
|
* Permanently removes diff scan data and results.
|
|
@@ -84,32 +149,81 @@ export declare class SocketSdk {
|
|
|
84
149
|
deleteOrgDiffScan(orgSlug: string, diffScanId: string): Promise<SocketSdkResult<'deleteOrgDiffScan'>>;
|
|
85
150
|
/**
|
|
86
151
|
* Delete a full scan from an organization.
|
|
152
|
+
*
|
|
87
153
|
* Permanently removes scan data and results.
|
|
88
154
|
*
|
|
155
|
+
* @param orgSlug - Organization identifier
|
|
156
|
+
* @param scanId - Full scan identifier to delete
|
|
157
|
+
* @returns Success confirmation
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const result = await sdk.deleteFullScan('my-org', 'scan_123')
|
|
162
|
+
*
|
|
163
|
+
* if (result.success) {
|
|
164
|
+
* console.log('Scan deleted successfully')
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @see https://docs.socket.dev/reference/deleteorgfullscan
|
|
169
|
+
* @apiEndpoint DELETE /orgs/{org_slug}/full-scans/{full_scan_id}
|
|
170
|
+
* @quota 1 unit
|
|
171
|
+
* @scopes full-scans:delete
|
|
89
172
|
* @throws {Error} When server returns 5xx status codes
|
|
90
173
|
*/
|
|
91
|
-
|
|
174
|
+
deleteFullScan(orgSlug: string, scanId: string): Promise<DeleteResult | StrictErrorResult>;
|
|
92
175
|
/**
|
|
93
176
|
* Delete a repository from an organization.
|
|
177
|
+
*
|
|
94
178
|
* Removes repository monitoring and associated scan data.
|
|
95
179
|
*
|
|
180
|
+
* @param orgSlug - Organization identifier
|
|
181
|
+
* @param repoSlug - Repository slug/name to delete
|
|
182
|
+
* @returns Success confirmation
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* const result = await sdk.deleteRepository('my-org', 'old-repo')
|
|
187
|
+
*
|
|
188
|
+
* if (result.success) {
|
|
189
|
+
* console.log('Repository deleted')
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @see https://docs.socket.dev/reference/deleteorgrepo
|
|
194
|
+
* @apiEndpoint DELETE /orgs/{org_slug}/repos/{repo_slug}
|
|
195
|
+
* @quota 1 unit
|
|
196
|
+
* @scopes repo:write
|
|
96
197
|
* @throws {Error} When server returns 5xx status codes
|
|
97
198
|
*/
|
|
98
|
-
|
|
199
|
+
deleteRepository(orgSlug: string, repoSlug: string): Promise<DeleteResult | StrictErrorResult>;
|
|
99
200
|
/**
|
|
100
201
|
* Delete a repository label from an organization.
|
|
101
|
-
* Removes label and associated configuration.
|
|
102
202
|
*
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
*
|
|
108
|
-
* Removes scan data and analysis results from the system.
|
|
203
|
+
* Removes label and all its associations (repositories, security policy, license policy, etc.).
|
|
204
|
+
*
|
|
205
|
+
* @param orgSlug - Organization identifier
|
|
206
|
+
* @param labelId - Label identifier
|
|
207
|
+
* @returns Deletion confirmation
|
|
109
208
|
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const result = await sdk.deleteRepositoryLabel('my-org', 'label-id-123')
|
|
212
|
+
*
|
|
213
|
+
* if (result.success) {
|
|
214
|
+
* console.log('Label deleted:', result.data.status)
|
|
215
|
+
* }
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @see https://docs.socket.dev/reference/deleteorgrepolabel
|
|
219
|
+
* @apiEndpoint DELETE /orgs/{org_slug}/repos/labels/{label_id}
|
|
220
|
+
* @quota 1 unit
|
|
221
|
+
* @scopes repo-label:delete
|
|
110
222
|
* @throws {Error} When server returns 5xx status codes
|
|
111
223
|
*/
|
|
112
|
-
|
|
224
|
+
deleteRepositoryLabel(orgSlug: string, labelId: string): Promise<DeleteRepositoryLabelResult | StrictErrorResult>;
|
|
225
|
+
/**
|
|
226
|
+
* Delete a legacy scan report permanently.
|
|
113
227
|
/**
|
|
114
228
|
* Export scan results in CycloneDX SBOM format.
|
|
115
229
|
* Returns Software Bill of Materials compliant with CycloneDX standard.
|
|
@@ -183,32 +297,114 @@ export declare class SocketSdk {
|
|
|
183
297
|
getOrgAnalytics(time: string): Promise<SocketSdkResult<'getOrgAnalytics'>>;
|
|
184
298
|
/**
|
|
185
299
|
* List all organizations accessible to the current user.
|
|
186
|
-
* Returns organization details and access permissions.
|
|
187
300
|
*
|
|
301
|
+
* Returns organization details and access permissions with guaranteed required fields.
|
|
302
|
+
*
|
|
303
|
+
* @returns List of organizations with metadata
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const result = await sdk.listOrganizations()
|
|
308
|
+
*
|
|
309
|
+
* if (result.success) {
|
|
310
|
+
* result.data.organizations.forEach(org => {
|
|
311
|
+
* console.log(org.name, org.slug) // Guaranteed fields
|
|
312
|
+
* })
|
|
313
|
+
* }
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @see https://docs.socket.dev/reference/getorganizations
|
|
317
|
+
* @apiEndpoint GET /organizations
|
|
318
|
+
* @quota 1 unit
|
|
188
319
|
* @throws {Error} When server returns 5xx status codes
|
|
189
320
|
*/
|
|
190
|
-
|
|
321
|
+
listOrganizations(): Promise<OrganizationsResult | StrictErrorResult>;
|
|
191
322
|
/**
|
|
192
|
-
* Get complete full scan results in memory.
|
|
323
|
+
* Get complete full scan results buffered in memory.
|
|
324
|
+
*
|
|
193
325
|
* Returns entire scan data as JSON for programmatic processing.
|
|
326
|
+
* For large scans, consider using streamFullScan() instead.
|
|
194
327
|
*
|
|
328
|
+
* @param orgSlug - Organization identifier
|
|
329
|
+
* @param scanId - Full scan identifier
|
|
330
|
+
* @returns Complete full scan data including all artifacts
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* const result = await sdk.getFullScan('my-org', 'scan_123')
|
|
335
|
+
*
|
|
336
|
+
* if (result.success) {
|
|
337
|
+
* console.log('Scan status:', result.data.scan_state)
|
|
338
|
+
* console.log('Repository:', result.data.repository_slug)
|
|
339
|
+
* }
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* @see https://docs.socket.dev/reference/getorgfullscan
|
|
343
|
+
* @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
|
|
344
|
+
* @quota 1 unit
|
|
345
|
+
* @scopes full-scans:list
|
|
195
346
|
* @throws {Error} When server returns 5xx status codes
|
|
196
347
|
*/
|
|
197
|
-
|
|
348
|
+
getFullScan(orgSlug: string, scanId: string): Promise<FullScanResult | StrictErrorResult>;
|
|
198
349
|
/**
|
|
199
350
|
* List all full scans for an organization.
|
|
200
|
-
* Returns paginated list of scan metadata and status.
|
|
201
351
|
*
|
|
352
|
+
* Returns paginated list of full scan metadata with guaranteed required fields
|
|
353
|
+
* for improved TypeScript autocomplete.
|
|
354
|
+
*
|
|
355
|
+
* @param orgSlug - Organization identifier
|
|
356
|
+
* @param options - Filtering and pagination options
|
|
357
|
+
* @returns List of full scans with metadata
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```typescript
|
|
361
|
+
* const result = await sdk.listFullScans('my-org', {
|
|
362
|
+
* branch: 'main',
|
|
363
|
+
* per_page: 50,
|
|
364
|
+
* use_cursor: true
|
|
365
|
+
* })
|
|
366
|
+
*
|
|
367
|
+
* if (result.success) {
|
|
368
|
+
* result.data.results.forEach(scan => {
|
|
369
|
+
* console.log(scan.id, scan.created_at) // Guaranteed fields
|
|
370
|
+
* })
|
|
371
|
+
* }
|
|
372
|
+
* ```
|
|
373
|
+
*
|
|
374
|
+
* @see https://docs.socket.dev/reference/getorgfullscanlist
|
|
375
|
+
* @apiEndpoint GET /orgs/{org_slug}/full-scans
|
|
376
|
+
* @quota 1 unit
|
|
377
|
+
* @scopes full-scans:list
|
|
202
378
|
* @throws {Error} When server returns 5xx status codes
|
|
203
379
|
*/
|
|
204
|
-
|
|
380
|
+
listFullScans(orgSlug: string, options?: ListFullScansOptions | undefined): Promise<FullScanListResult | StrictErrorResult>;
|
|
205
381
|
/**
|
|
206
382
|
* Get metadata for a specific full scan.
|
|
207
|
-
* Returns scan configuration, status, and summary information.
|
|
208
383
|
*
|
|
384
|
+
* Returns scan configuration, status, and summary information without full artifact data.
|
|
385
|
+
* Useful for checking scan status without downloading complete results.
|
|
386
|
+
*
|
|
387
|
+
* @param orgSlug - Organization identifier
|
|
388
|
+
* @param scanId - Full scan identifier
|
|
389
|
+
* @returns Scan metadata including status and configuration
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const result = await sdk.getFullScanMetadata('my-org', 'scan_123')
|
|
394
|
+
*
|
|
395
|
+
* if (result.success) {
|
|
396
|
+
* console.log('Scan state:', result.data.scan_state)
|
|
397
|
+
* console.log('Branch:', result.data.branch)
|
|
398
|
+
* }
|
|
399
|
+
* ```
|
|
400
|
+
*
|
|
401
|
+
* @see https://docs.socket.dev/reference/getorgfullscanmetadata
|
|
402
|
+
* @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}/metadata
|
|
403
|
+
* @quota 1 unit
|
|
404
|
+
* @scopes full-scans:list
|
|
209
405
|
* @throws {Error} When server returns 5xx status codes
|
|
210
406
|
*/
|
|
211
|
-
|
|
407
|
+
getFullScanMetadata(orgSlug: string, scanId: string): Promise<FullScanResult | StrictErrorResult>;
|
|
212
408
|
/**
|
|
213
409
|
* Get organization's license policy configuration.* Returns allowed, restricted, and monitored license types.
|
|
214
410
|
*
|
|
@@ -216,33 +412,118 @@ export declare class SocketSdk {
|
|
|
216
412
|
*/
|
|
217
413
|
getOrgLicensePolicy(orgSlug: string): Promise<SocketSdkResult<'getOrgLicensePolicy'>>;
|
|
218
414
|
/**
|
|
219
|
-
* Get details for a specific
|
|
415
|
+
* Get details for a specific repository.
|
|
416
|
+
*
|
|
220
417
|
* Returns repository configuration, monitoring status, and metadata.
|
|
221
418
|
*
|
|
419
|
+
* @param orgSlug - Organization identifier
|
|
420
|
+
* @param repoSlug - Repository slug/name
|
|
421
|
+
* @returns Repository details with configuration
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```typescript
|
|
425
|
+
* const result = await sdk.getRepository('my-org', 'my-repo')
|
|
426
|
+
*
|
|
427
|
+
* if (result.success) {
|
|
428
|
+
* console.log('Repository:', result.data.name)
|
|
429
|
+
* console.log('Visibility:', result.data.visibility)
|
|
430
|
+
* console.log('Default branch:', result.data.default_branch)
|
|
431
|
+
* }
|
|
432
|
+
* ```
|
|
433
|
+
*
|
|
434
|
+
* @see https://docs.socket.dev/reference/getorgrepo
|
|
435
|
+
* @apiEndpoint GET /orgs/{org_slug}/repos/{repo_slug}
|
|
436
|
+
* @quota 1 unit
|
|
437
|
+
* @scopes repo:read
|
|
222
438
|
* @throws {Error} When server returns 5xx status codes
|
|
223
439
|
*/
|
|
224
|
-
|
|
440
|
+
getRepository(orgSlug: string, repoSlug: string): Promise<RepositoryResult | StrictErrorResult>;
|
|
225
441
|
/**
|
|
226
442
|
* Get details for a specific repository label.
|
|
227
|
-
* Returns label configuration and metadata.
|
|
228
443
|
*
|
|
444
|
+
* Returns label configuration, associated repositories, and policy settings.
|
|
445
|
+
*
|
|
446
|
+
* @param orgSlug - Organization identifier
|
|
447
|
+
* @param labelId - Label identifier
|
|
448
|
+
* @returns Label details with guaranteed id and name fields
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* const result = await sdk.getRepositoryLabel('my-org', 'label-id-123')
|
|
453
|
+
*
|
|
454
|
+
* if (result.success) {
|
|
455
|
+
* console.log('Label name:', result.data.name)
|
|
456
|
+
* console.log('Associated repos:', result.data.repository_ids)
|
|
457
|
+
* console.log('Has security policy:', result.data.has_security_policy)
|
|
458
|
+
* }
|
|
459
|
+
* ```
|
|
460
|
+
*
|
|
461
|
+
* @see https://docs.socket.dev/reference/getorgrepolabel
|
|
462
|
+
* @apiEndpoint GET /orgs/{org_slug}/repos/labels/{label_id}
|
|
463
|
+
* @quota 1 unit
|
|
464
|
+
* @scopes repo-label:list
|
|
229
465
|
* @throws {Error} When server returns 5xx status codes
|
|
230
466
|
*/
|
|
231
|
-
|
|
467
|
+
getRepositoryLabel(orgSlug: string, labelId: string): Promise<RepositoryLabelResult | StrictErrorResult>;
|
|
232
468
|
/**
|
|
233
|
-
*
|
|
234
|
-
* Returns all labels configured for repository management.
|
|
469
|
+
* List all repository labels for an organization.
|
|
235
470
|
*
|
|
471
|
+
* Returns paginated list of labels configured for repository organization and policy management.
|
|
472
|
+
*
|
|
473
|
+
* @param orgSlug - Organization identifier
|
|
474
|
+
* @param options - Pagination options
|
|
475
|
+
* @returns List of labels with guaranteed id and name fields
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```typescript
|
|
479
|
+
* const result = await sdk.listRepositoryLabels('my-org', { per_page: 50, page: 1 })
|
|
480
|
+
*
|
|
481
|
+
* if (result.success) {
|
|
482
|
+
* result.data.results.forEach(label => {
|
|
483
|
+
* console.log('Label:', label.name)
|
|
484
|
+
* console.log('Associated repos:', label.repository_ids?.length || 0)
|
|
485
|
+
* })
|
|
486
|
+
* }
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* @see https://docs.socket.dev/reference/getorgrepolabellist
|
|
490
|
+
* @apiEndpoint GET /orgs/{org_slug}/repos/labels
|
|
491
|
+
* @quota 1 unit
|
|
492
|
+
* @scopes repo-label:list
|
|
236
493
|
* @throws {Error} When server returns 5xx status codes
|
|
237
494
|
*/
|
|
238
|
-
|
|
495
|
+
listRepositoryLabels(orgSlug: string, options?: QueryParams | undefined): Promise<RepositoryLabelsListResult | StrictErrorResult>;
|
|
239
496
|
/**
|
|
240
497
|
* List all repositories in an organization.
|
|
241
|
-
* Returns paginated list of repository metadata and status.
|
|
242
498
|
*
|
|
499
|
+
* Returns paginated list of repository metadata with guaranteed required fields.
|
|
500
|
+
*
|
|
501
|
+
* @param orgSlug - Organization identifier
|
|
502
|
+
* @param options - Pagination and filtering options
|
|
503
|
+
* @returns List of repositories with metadata
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```typescript
|
|
507
|
+
* const result = await sdk.listRepositories('my-org', {
|
|
508
|
+
* per_page: 50,
|
|
509
|
+
* sort: 'name',
|
|
510
|
+
* direction: 'asc'
|
|
511
|
+
* })
|
|
512
|
+
*
|
|
513
|
+
* if (result.success) {
|
|
514
|
+
* result.data.results.forEach(repo => {
|
|
515
|
+
* console.log(repo.name, repo.visibility)
|
|
516
|
+
* })
|
|
517
|
+
* }
|
|
518
|
+
* ```
|
|
519
|
+
*
|
|
520
|
+
* @see https://docs.socket.dev/reference/getorgrepolist
|
|
521
|
+
* @apiEndpoint GET /orgs/{org_slug}/repos
|
|
522
|
+
* @quota 1 unit
|
|
523
|
+
* @scopes repo:list
|
|
243
524
|
* @throws {Error} When server returns 5xx status codes
|
|
244
525
|
*/
|
|
245
|
-
|
|
526
|
+
listRepositories(orgSlug: string, options?: ListRepositoriesOptions | undefined): Promise<RepositoriesListResult | StrictErrorResult>;
|
|
246
527
|
/**
|
|
247
528
|
* Get organization's security policy configuration.* Returns alert rules, severity thresholds, and enforcement settings.
|
|
248
529
|
*
|
|
@@ -271,19 +552,8 @@ export declare class SocketSdk {
|
|
|
271
552
|
*/
|
|
272
553
|
getRepoAnalytics(repo: string, time: string): Promise<SocketSdkResult<'getRepoAnalytics'>>;
|
|
273
554
|
/**
|
|
274
|
-
* Get detailed results for a
|
|
275
|
-
* Returns complete scan analysis including vulnerabilities and alerts.
|
|
276
|
-
*
|
|
277
|
-
* @throws {Error} When server returns 5xx status codes
|
|
278
|
-
*/
|
|
279
|
-
getScan(id: string): Promise<SocketSdkResult<'getReport'>>;
|
|
555
|
+
* Get detailed results for a legacy scan report.
|
|
280
556
|
/**
|
|
281
|
-
* List all scans accessible to the current user.
|
|
282
|
-
* Returns paginated list of scan metadata and status.
|
|
283
|
-
*
|
|
284
|
-
* @throws {Error} When server returns 5xx status codes
|
|
285
|
-
*/
|
|
286
|
-
getScanList(): Promise<SocketSdkResult<'getReportList'>>;
|
|
287
557
|
/**
|
|
288
558
|
* Get security score for a specific npm package and version.
|
|
289
559
|
* Returns numerical security rating and scoring breakdown.
|
|
@@ -358,11 +628,39 @@ export declare class SocketSdk {
|
|
|
358
628
|
*/
|
|
359
629
|
sendApi<T>(urlPath: string, options?: SendOptions | undefined): Promise<T | SocketSdkGenericResult<T>>;
|
|
360
630
|
/**
|
|
361
|
-
* Stream a full scan's results to file or stdout
|
|
631
|
+
* Stream a full scan's results to file or stdout.
|
|
632
|
+
*
|
|
633
|
+
* Provides efficient streaming for large scan datasets without loading
|
|
634
|
+
* entire response into memory. Useful for processing large SBOMs.
|
|
635
|
+
*
|
|
636
|
+
* @param orgSlug - Organization identifier
|
|
637
|
+
* @param scanId - Full scan identifier
|
|
638
|
+
* @param options - Streaming options (output file path, stdout, or buffered)
|
|
639
|
+
* @returns Scan result with streaming response
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```typescript
|
|
643
|
+
* // Stream to file
|
|
644
|
+
* await sdk.streamFullScan('my-org', 'scan_123', {
|
|
645
|
+
* output: './scan-results.json'
|
|
646
|
+
* })
|
|
647
|
+
*
|
|
648
|
+
* // Stream to stdout
|
|
649
|
+
* await sdk.streamFullScan('my-org', 'scan_123', {
|
|
650
|
+
* output: true
|
|
651
|
+
* })
|
|
652
|
+
*
|
|
653
|
+
* // Get buffered response
|
|
654
|
+
* const result = await sdk.streamFullScan('my-org', 'scan_123')
|
|
655
|
+
* ```
|
|
362
656
|
*
|
|
657
|
+
* @see https://docs.socket.dev/reference/getorgfullscan
|
|
658
|
+
* @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
|
|
659
|
+
* @quota 1 unit
|
|
660
|
+
* @scopes full-scans:list
|
|
363
661
|
* @throws {Error} When server returns 5xx status codes
|
|
364
662
|
*/
|
|
365
|
-
|
|
663
|
+
streamFullScan(orgSlug: string, scanId: string, options?: StreamOrgFullScanOptions | undefined): Promise<SocketSdkResult<'getOrgFullScan'>>;
|
|
366
664
|
/**
|
|
367
665
|
* Stream patches for artifacts in a scan report.
|
|
368
666
|
*
|
|
@@ -386,19 +684,61 @@ export declare class SocketSdk {
|
|
|
386
684
|
*/
|
|
387
685
|
updateOrgLicensePolicy(orgSlug: string, policyData: QueryParams, queryParams?: QueryParams | undefined): Promise<SocketSdkResult<'updateOrgLicensePolicy'>>;
|
|
388
686
|
/**
|
|
389
|
-
* Update configuration for
|
|
687
|
+
* Update configuration for a repository.
|
|
688
|
+
*
|
|
390
689
|
* Modifies monitoring settings, branch configuration, and scan preferences.
|
|
391
690
|
*
|
|
691
|
+
* @param orgSlug - Organization identifier
|
|
692
|
+
* @param repoSlug - Repository slug/name
|
|
693
|
+
* @param params - Configuration updates (description, homepage, default_branch, etc.)
|
|
694
|
+
* @returns Updated repository details
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* ```typescript
|
|
698
|
+
* const result = await sdk.updateRepository('my-org', 'my-repo', {
|
|
699
|
+
* description: 'Updated description',
|
|
700
|
+
* default_branch: 'develop'
|
|
701
|
+
* })
|
|
702
|
+
*
|
|
703
|
+
* if (result.success) {
|
|
704
|
+
* console.log('Repository updated:', result.data.name)
|
|
705
|
+
* }
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* @see https://docs.socket.dev/reference/updateorgrepo
|
|
709
|
+
* @apiEndpoint POST /orgs/{org_slug}/repos/{repo_slug}
|
|
710
|
+
* @quota 1 unit
|
|
711
|
+
* @scopes repo:write
|
|
392
712
|
* @throws {Error} When server returns 5xx status codes
|
|
393
713
|
*/
|
|
394
|
-
|
|
714
|
+
updateRepository(orgSlug: string, repoSlug: string, params?: QueryParams | undefined): Promise<RepositoryResult | StrictErrorResult>;
|
|
395
715
|
/**
|
|
396
716
|
* Update a repository label for an organization.
|
|
397
|
-
* Modifies label properties and configuration.
|
|
398
717
|
*
|
|
718
|
+
* Modifies label properties like name. Label names must be non-empty and less than 1000 characters.
|
|
719
|
+
*
|
|
720
|
+
* @param orgSlug - Organization identifier
|
|
721
|
+
* @param labelId - Label identifier
|
|
722
|
+
* @param labelData - Label updates (typically name property)
|
|
723
|
+
* @returns Updated label with guaranteed id and name fields
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* const result = await sdk.updateRepositoryLabel('my-org', 'label-id-123', { name: 'staging' })
|
|
728
|
+
*
|
|
729
|
+
* if (result.success) {
|
|
730
|
+
* console.log('Label updated:', result.data.name)
|
|
731
|
+
* console.log('Label ID:', result.data.id)
|
|
732
|
+
* }
|
|
733
|
+
* ```
|
|
734
|
+
*
|
|
735
|
+
* @see https://docs.socket.dev/reference/updateorgrepolabel
|
|
736
|
+
* @apiEndpoint PUT /orgs/{org_slug}/repos/labels/{label_id}
|
|
737
|
+
* @quota 1 unit
|
|
738
|
+
* @scopes repo-label:update
|
|
399
739
|
* @throws {Error} When server returns 5xx status codes
|
|
400
740
|
*/
|
|
401
|
-
|
|
741
|
+
updateRepositoryLabel(orgSlug: string, labelId: string, labelData: QueryParams): Promise<RepositoryLabelResult | StrictErrorResult>;
|
|
402
742
|
/**
|
|
403
743
|
* Update organization's security policy configuration.* Modifies alert rules, severity thresholds, and enforcement settings.
|
|
404
744
|
*
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Strict type definitions for Socket SDK v3.
|
|
3
|
+
* These types provide better TypeScript DX by marking guaranteed fields as required
|
|
4
|
+
* and only keeping truly optional fields as optional. This improves IntelliSense autocomplete.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Strict type for full scan metadata item.
|
|
8
|
+
* Represents a single full scan with guaranteed fields marked as required.
|
|
9
|
+
*/
|
|
10
|
+
export type FullScanItem = {
|
|
11
|
+
id: string;
|
|
12
|
+
created_at: string;
|
|
13
|
+
updated_at: string;
|
|
14
|
+
organization_id: string;
|
|
15
|
+
organization_slug: string;
|
|
16
|
+
repository_id: string;
|
|
17
|
+
repository_slug: string;
|
|
18
|
+
repo: string;
|
|
19
|
+
html_report_url: string;
|
|
20
|
+
api_url: string;
|
|
21
|
+
integration_type: string;
|
|
22
|
+
integration_repo_url: string;
|
|
23
|
+
branch: string | null;
|
|
24
|
+
commit_message: string | null;
|
|
25
|
+
commit_hash: string | null;
|
|
26
|
+
pull_request: number | null;
|
|
27
|
+
committers: string[];
|
|
28
|
+
html_url: string | null;
|
|
29
|
+
integration_branch_url: string | null;
|
|
30
|
+
integration_commit_url: string | null;
|
|
31
|
+
integration_pull_request_url: string | null;
|
|
32
|
+
scan_state: 'pending' | 'precrawl' | 'resolve' | 'scan' | null;
|
|
33
|
+
unmatchedFiles?: string[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Strict type for full scan list response.
|
|
37
|
+
*/
|
|
38
|
+
export type FullScanListData = {
|
|
39
|
+
results: FullScanItem[];
|
|
40
|
+
nextPageCursor: string | null;
|
|
41
|
+
nextPage: number | null;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Strict type for full scan list result.
|
|
45
|
+
*/
|
|
46
|
+
export type FullScanListResult = {
|
|
47
|
+
cause?: undefined;
|
|
48
|
+
data: FullScanListData;
|
|
49
|
+
error?: undefined;
|
|
50
|
+
status: number;
|
|
51
|
+
success: true;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Strict type for single full scan result.
|
|
55
|
+
*/
|
|
56
|
+
export type FullScanResult = {
|
|
57
|
+
cause?: undefined;
|
|
58
|
+
data: FullScanItem;
|
|
59
|
+
error?: undefined;
|
|
60
|
+
status: number;
|
|
61
|
+
success: true;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Options for listing full scans.
|
|
65
|
+
*/
|
|
66
|
+
export type ListFullScansOptions = {
|
|
67
|
+
sort?: 'name' | 'created_at';
|
|
68
|
+
direction?: 'asc' | 'desc';
|
|
69
|
+
per_page?: number;
|
|
70
|
+
page?: number;
|
|
71
|
+
startAfterCursor?: string;
|
|
72
|
+
use_cursor?: boolean;
|
|
73
|
+
from?: string;
|
|
74
|
+
repo?: string;
|
|
75
|
+
branch?: string;
|
|
76
|
+
pull_request?: string;
|
|
77
|
+
commit_hash?: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Options for creating a full scan.
|
|
81
|
+
*/
|
|
82
|
+
export type CreateFullScanOptions = {
|
|
83
|
+
pathsRelativeTo?: string;
|
|
84
|
+
repo: string;
|
|
85
|
+
branch?: string;
|
|
86
|
+
commit_message?: string;
|
|
87
|
+
commit_hash?: string;
|
|
88
|
+
pull_request?: number;
|
|
89
|
+
committers?: string;
|
|
90
|
+
integration_type?: 'api' | 'github' | 'gitlab' | 'bitbucket' | 'azure';
|
|
91
|
+
integration_org_slug?: string;
|
|
92
|
+
make_default_branch?: boolean;
|
|
93
|
+
set_as_pending_head?: boolean;
|
|
94
|
+
tmp?: boolean;
|
|
95
|
+
scan_type?: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Options for streaming a full scan.
|
|
99
|
+
*/
|
|
100
|
+
export type StreamFullScanOptions = {
|
|
101
|
+
output?: boolean | string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Error result type for all SDK operations.
|
|
105
|
+
*/
|
|
106
|
+
export type StrictErrorResult = {
|
|
107
|
+
cause?: string | undefined;
|
|
108
|
+
data?: undefined;
|
|
109
|
+
error: string;
|
|
110
|
+
status: number;
|
|
111
|
+
success: false;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Generic strict result type combining success and error.
|
|
115
|
+
*/
|
|
116
|
+
export type StrictResult<T> = {
|
|
117
|
+
cause?: undefined;
|
|
118
|
+
data: T;
|
|
119
|
+
error?: undefined;
|
|
120
|
+
status: number;
|
|
121
|
+
success: true;
|
|
122
|
+
} | StrictErrorResult;
|
|
123
|
+
/**
|
|
124
|
+
* Strict type for organization item.
|
|
125
|
+
*/
|
|
126
|
+
export type OrganizationItem = {
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
slug: string;
|
|
130
|
+
created_at: string;
|
|
131
|
+
updated_at: string;
|
|
132
|
+
plan: string;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Strict type for organizations list result.
|
|
136
|
+
*/
|
|
137
|
+
export type OrganizationsResult = {
|
|
138
|
+
cause?: undefined;
|
|
139
|
+
data: {
|
|
140
|
+
organizations: OrganizationItem[];
|
|
141
|
+
};
|
|
142
|
+
error?: undefined;
|
|
143
|
+
status: number;
|
|
144
|
+
success: true;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Strict type for repository item.
|
|
148
|
+
*/
|
|
149
|
+
export type RepositoryItem = {
|
|
150
|
+
id: string;
|
|
151
|
+
created_at: string;
|
|
152
|
+
updated_at: string;
|
|
153
|
+
name: string;
|
|
154
|
+
organization_id: string;
|
|
155
|
+
organization_slug: string;
|
|
156
|
+
default_branch: string | null;
|
|
157
|
+
homepage: string | null;
|
|
158
|
+
archived: boolean;
|
|
159
|
+
visibility: 'public' | 'private' | 'internal';
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Strict type for repositories list data.
|
|
163
|
+
*/
|
|
164
|
+
export type RepositoriesListData = {
|
|
165
|
+
results: RepositoryItem[];
|
|
166
|
+
nextPageCursor: string | null;
|
|
167
|
+
nextPage: number | null;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Strict type for repositories list result.
|
|
171
|
+
*/
|
|
172
|
+
export type RepositoriesListResult = {
|
|
173
|
+
cause?: undefined;
|
|
174
|
+
data: RepositoriesListData;
|
|
175
|
+
error?: undefined;
|
|
176
|
+
status: number;
|
|
177
|
+
success: true;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Options for listing repositories.
|
|
181
|
+
*/
|
|
182
|
+
export type ListRepositoriesOptions = {
|
|
183
|
+
sort?: 'name' | 'created_at';
|
|
184
|
+
direction?: 'asc' | 'desc';
|
|
185
|
+
per_page?: number;
|
|
186
|
+
page?: number;
|
|
187
|
+
startAfterCursor?: string;
|
|
188
|
+
use_cursor?: boolean;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Strict type for delete operation result.
|
|
192
|
+
*/
|
|
193
|
+
export type DeleteResult = {
|
|
194
|
+
cause?: undefined;
|
|
195
|
+
data: {
|
|
196
|
+
success: boolean;
|
|
197
|
+
};
|
|
198
|
+
error?: undefined;
|
|
199
|
+
status: number;
|
|
200
|
+
success: true;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Strict type for single repository result.
|
|
204
|
+
*/
|
|
205
|
+
export type RepositoryResult = {
|
|
206
|
+
cause?: undefined;
|
|
207
|
+
data: RepositoryItem;
|
|
208
|
+
error?: undefined;
|
|
209
|
+
status: number;
|
|
210
|
+
success: true;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Strict type for repository label item.
|
|
214
|
+
*/
|
|
215
|
+
export type RepositoryLabelItem = {
|
|
216
|
+
id: string;
|
|
217
|
+
name: string;
|
|
218
|
+
repository_ids?: string[];
|
|
219
|
+
has_security_policy?: boolean;
|
|
220
|
+
has_license_policy?: boolean;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Strict type for repository labels list data.
|
|
224
|
+
*/
|
|
225
|
+
export type RepositoryLabelsListData = {
|
|
226
|
+
results: RepositoryLabelItem[];
|
|
227
|
+
nextPage: number | null;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Strict type for repository labels list result.
|
|
231
|
+
*/
|
|
232
|
+
export type RepositoryLabelsListResult = {
|
|
233
|
+
cause?: undefined;
|
|
234
|
+
data: RepositoryLabelsListData;
|
|
235
|
+
error?: undefined;
|
|
236
|
+
status: number;
|
|
237
|
+
success: true;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Strict type for single repository label result.
|
|
241
|
+
*/
|
|
242
|
+
export type RepositoryLabelResult = {
|
|
243
|
+
cause?: undefined;
|
|
244
|
+
data: RepositoryLabelItem;
|
|
245
|
+
error?: undefined;
|
|
246
|
+
status: number;
|
|
247
|
+
success: true;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Strict type for delete repository label result.
|
|
251
|
+
*/
|
|
252
|
+
export type DeleteRepositoryLabelResult = {
|
|
253
|
+
cause?: undefined;
|
|
254
|
+
data: {
|
|
255
|
+
status: string;
|
|
256
|
+
};
|
|
257
|
+
error?: undefined;
|
|
258
|
+
status: number;
|
|
259
|
+
success: true;
|
|
260
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -148,6 +148,44 @@ export type SocketSdkGenericResult<T> = {
|
|
|
148
148
|
status: number;
|
|
149
149
|
success: false;
|
|
150
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Result from file validation callback.
|
|
153
|
+
* Allows consumers to customize error handling and logging.
|
|
154
|
+
*
|
|
155
|
+
* @since v3.0.0
|
|
156
|
+
*/
|
|
157
|
+
export interface FileValidationResult {
|
|
158
|
+
/**
|
|
159
|
+
* Whether to continue with the operation using valid files.
|
|
160
|
+
* If false, the SDK operation will fail with the provided error message.
|
|
161
|
+
*/
|
|
162
|
+
shouldContinue: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Optional custom error message if shouldContinue is false.
|
|
165
|
+
* If not provided, SDK will use default error message.
|
|
166
|
+
*/
|
|
167
|
+
errorMessage?: string | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Optional cause/reason for the error.
|
|
170
|
+
*/
|
|
171
|
+
errorCause?: string | undefined;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Callback invoked when file validation detects unreadable files.
|
|
175
|
+
* Gives consumers control over error messages and logging.
|
|
176
|
+
*
|
|
177
|
+
* @param validPaths - Files that passed validation (readable)
|
|
178
|
+
* @param invalidPaths - Files that failed validation (unreadable)
|
|
179
|
+
* @param context - Context about the operation (method name, orgSlug, etc.)
|
|
180
|
+
* @returns Decision on whether to continue and optional custom error messages
|
|
181
|
+
*
|
|
182
|
+
* @since v3.0.0
|
|
183
|
+
*/
|
|
184
|
+
export type FileValidationCallback = (validPaths: string[], invalidPaths: string[], context: {
|
|
185
|
+
operation: 'createDependenciesSnapshot' | 'createOrgFullScan' | 'uploadManifestFiles';
|
|
186
|
+
orgSlug?: string | undefined;
|
|
187
|
+
[key: string]: unknown;
|
|
188
|
+
}) => FileValidationResult | Promise<FileValidationResult>;
|
|
151
189
|
/**
|
|
152
190
|
* Configuration options for SocketSdk.
|
|
153
191
|
*/
|
|
@@ -166,6 +204,21 @@ export interface SocketSdkOptions {
|
|
|
166
204
|
* Only used when cache is enabled.
|
|
167
205
|
*/
|
|
168
206
|
cacheTtl?: number | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Callback for file validation events.
|
|
209
|
+
* Called when any file-upload method detects unreadable files:
|
|
210
|
+
* - createDependenciesSnapshot
|
|
211
|
+
* - createFullScan (formerly createOrgFullScan)
|
|
212
|
+
* - uploadManifestFiles
|
|
213
|
+
*
|
|
214
|
+
* Default behavior (if not provided):
|
|
215
|
+
* - Warns about invalid files (console.warn)
|
|
216
|
+
* - Continues with valid files if any exist
|
|
217
|
+
* - Throws error if all files are invalid
|
|
218
|
+
*
|
|
219
|
+
* @since v3.0.0
|
|
220
|
+
*/
|
|
221
|
+
onFileValidation?: FileValidationCallback | undefined;
|
|
169
222
|
/**
|
|
170
223
|
* Number of retry attempts on failure (default: 0, retries disabled).
|
|
171
224
|
* Retries are opt-in following Node.js fs.rm() pattern.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "SDK for the Socket API client",
|
|
6
6
|
"author": {
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"@dotenvx/dotenvx": "1.49.0",
|
|
66
66
|
"@eslint/compat": "1.3.2",
|
|
67
67
|
"@eslint/js": "9.35.0",
|
|
68
|
-
"@socketsecurity/lib": "1.0
|
|
68
|
+
"@socketsecurity/lib": "1.3.0",
|
|
69
69
|
"@socketsecurity/registry": "1.5.3",
|
|
70
70
|
"@types/node": "24.6.2",
|
|
71
71
|
"@typescript/native-preview": "7.0.0-dev.20250926.1",
|
|
72
72
|
"@vitest/coverage-v8": "3.2.4",
|
|
73
|
-
"del": "
|
|
73
|
+
"del": "8.0.1",
|
|
74
74
|
"dev-null-cli": "2.0.0",
|
|
75
75
|
"esbuild": "0.25.10",
|
|
76
76
|
"eslint": "9.35.0",
|
package/types/api.d.ts
CHANGED
|
@@ -5399,6 +5399,8 @@ export interface operations {
|
|
|
5399
5399
|
after: string
|
|
5400
5400
|
/** @description The base full scan ID (older) */
|
|
5401
5401
|
before: string
|
|
5402
|
+
/** @description The ID of the GitHub installation. This will be used to get the GitHub installation settings. If not provided, the default GitHub installation settings will be used. */
|
|
5403
|
+
github_installation_id?: string
|
|
5402
5404
|
}
|
|
5403
5405
|
path: {
|
|
5404
5406
|
/** @description The slug of the organization */
|
|
@@ -5863,6 +5865,10 @@ export interface operations {
|
|
|
5863
5865
|
*/
|
|
5864
5866
|
GetDiffScanGfm: {
|
|
5865
5867
|
parameters: {
|
|
5868
|
+
query?: {
|
|
5869
|
+
/** @description The ID of the GitHub installation. This will be used to get the GitHub installation settings. If not provided, the default GitHub installation settings will be used. */
|
|
5870
|
+
github_installation_id?: string
|
|
5871
|
+
}
|
|
5866
5872
|
path: {
|
|
5867
5873
|
/** @description The slug of the organization */
|
|
5868
5874
|
org_slug: string
|
|
@@ -12526,6 +12532,14 @@ export interface operations {
|
|
|
12526
12532
|
'filters.alertPriority'?: string
|
|
12527
12533
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12528
12534
|
'filters.alertPriority.notIn'?: string
|
|
12535
|
+
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
12536
|
+
'filters.alertKEV'?: boolean
|
|
12537
|
+
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
12538
|
+
'filters.alertKEV.notIn'?: boolean
|
|
12539
|
+
/** @description Alert EPSS ("low", "medium", "high", "critical") */
|
|
12540
|
+
'filters.alertEPSS'?: string
|
|
12541
|
+
/** @description Alert EPSS ("low", "medium", "high", "critical") */
|
|
12542
|
+
'filters.alertEPSS.notIn'?: string
|
|
12529
12543
|
/** @description Direct/transitive dependency filter flag */
|
|
12530
12544
|
'filters.dependencyDirect'?: boolean
|
|
12531
12545
|
/** @description Direct/transitive dependency filter flag */
|
|
@@ -12677,6 +12691,10 @@ export interface operations {
|
|
|
12677
12691
|
alertReachabilityType?: string[]
|
|
12678
12692
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12679
12693
|
alertPriority?: string[]
|
|
12694
|
+
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
12695
|
+
alertKEV?: boolean[]
|
|
12696
|
+
/** @description Alert EPSS ("low", "medium", "high", "critical") */
|
|
12697
|
+
alertEPSS?: string[]
|
|
12680
12698
|
/** @description Direct/transitive dependency filter flag */
|
|
12681
12699
|
dependencyDirect?: boolean[]
|
|
12682
12700
|
/** @description Development/production dependency filter flag */
|
|
@@ -12710,7 +12728,7 @@ export interface operations {
|
|
|
12710
12728
|
date?: string
|
|
12711
12729
|
/** @description The number of days of data to fetch as an offset from input date */
|
|
12712
12730
|
range?: string
|
|
12713
|
-
/** @description Comma-separated list of fields that should be used for count aggregation (allowed: alertSeverity,repoSlug,repoLabels,alertType,artifactType,alertAction,alertActionSourceType,alertFixType,alertCategory,alertCveId,alertCveTitle,alertCweId,alertCweName,alertReachabilityType,alertPriority,dependencyDirect,dependencyDev,dependencyDead) */
|
|
12731
|
+
/** @description Comma-separated list of fields that should be used for count aggregation (allowed: alertSeverity,repoSlug,repoLabels,alertType,artifactType,alertAction,alertActionSourceType,alertFixType,alertCategory,alertCveId,alertCveTitle,alertCweId,alertCweName,alertReachabilityType,alertPriority,alertKEV,alertEPSS,dependencyDirect,dependencyDev,dependencyDead) */
|
|
12714
12732
|
'aggregation.fields'?: string
|
|
12715
12733
|
/** @description Comma-separated list of alert severities ("low", "medium", "high", or "critical") that should be included */
|
|
12716
12734
|
'filters.alertSeverity'?: string
|
|
@@ -12776,6 +12794,14 @@ export interface operations {
|
|
|
12776
12794
|
'filters.alertPriority'?: string
|
|
12777
12795
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12778
12796
|
'filters.alertPriority.notIn'?: string
|
|
12797
|
+
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
12798
|
+
'filters.alertKEV'?: boolean
|
|
12799
|
+
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
12800
|
+
'filters.alertKEV.notIn'?: boolean
|
|
12801
|
+
/** @description Alert EPSS ("low", "medium", "high", "critical") */
|
|
12802
|
+
'filters.alertEPSS'?: string
|
|
12803
|
+
/** @description Alert EPSS ("low", "medium", "high", "critical") */
|
|
12804
|
+
'filters.alertEPSS.notIn'?: string
|
|
12779
12805
|
/** @description Direct/transitive dependency filter flag */
|
|
12780
12806
|
'filters.dependencyDirect'?: boolean
|
|
12781
12807
|
/** @description Direct/transitive dependency filter flag */
|
|
@@ -12845,6 +12871,10 @@ export interface operations {
|
|
|
12845
12871
|
alertReachabilityType?: string[]
|
|
12846
12872
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12847
12873
|
alertPriority?: string[]
|
|
12874
|
+
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
12875
|
+
alertKEV?: boolean[]
|
|
12876
|
+
/** @description Alert EPSS ("low", "medium", "high", "critical") */
|
|
12877
|
+
alertEPSS?: string[]
|
|
12848
12878
|
/** @description Direct/transitive dependency filter flag */
|
|
12849
12879
|
dependencyDirect?: boolean[]
|
|
12850
12880
|
/** @description Development/production dependency filter flag */
|