@socketsecurity/sdk 3.0.26 → 3.0.28
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 +12 -0
- package/README.md +48 -13
- package/dist/index.mjs +3530 -57
- package/dist/testing.mjs +250 -1
- package/package.json +4 -4
- package/types/api.d.ts +31 -1
package/dist/testing.mjs
CHANGED
|
@@ -1,2 +1,251 @@
|
|
|
1
1
|
/* Socket SDK ESM - Built with esbuild */
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// src/testing.ts
|
|
4
|
+
function mockSuccessResponse(data, status = 200) {
|
|
5
|
+
return {
|
|
6
|
+
cause: void 0,
|
|
7
|
+
data,
|
|
8
|
+
error: void 0,
|
|
9
|
+
status,
|
|
10
|
+
success: true
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function mockErrorResponse(error, status = 500, cause) {
|
|
14
|
+
return {
|
|
15
|
+
cause,
|
|
16
|
+
data: void 0,
|
|
17
|
+
error,
|
|
18
|
+
status,
|
|
19
|
+
success: false
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function mockApiErrorBody(message, details) {
|
|
23
|
+
return {
|
|
24
|
+
error: {
|
|
25
|
+
message,
|
|
26
|
+
...details ? { details } : {}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var organizationFixtures = {
|
|
31
|
+
/**
|
|
32
|
+
* Basic organization with minimal data.
|
|
33
|
+
*/
|
|
34
|
+
basic: {
|
|
35
|
+
id: "org_123",
|
|
36
|
+
name: "test-org",
|
|
37
|
+
plan: "free"
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Organization with full details.
|
|
41
|
+
*/
|
|
42
|
+
full: {
|
|
43
|
+
id: "org_123",
|
|
44
|
+
name: "test-org",
|
|
45
|
+
plan: "enterprise",
|
|
46
|
+
created_at: "2024-01-01T00:00:00Z",
|
|
47
|
+
updated_at: "2024-01-02T00:00:00Z"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var repositoryFixtures = {
|
|
51
|
+
/**
|
|
52
|
+
* Basic repository with minimal data.
|
|
53
|
+
*/
|
|
54
|
+
basic: {
|
|
55
|
+
id: "repo_123",
|
|
56
|
+
name: "test-repo",
|
|
57
|
+
archived: false,
|
|
58
|
+
default_branch: "main"
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Archived repository.
|
|
62
|
+
*/
|
|
63
|
+
archived: {
|
|
64
|
+
id: "repo_456",
|
|
65
|
+
name: "old-repo",
|
|
66
|
+
archived: true,
|
|
67
|
+
default_branch: "master"
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Repository with full details.
|
|
71
|
+
*/
|
|
72
|
+
full: {
|
|
73
|
+
id: "repo_123",
|
|
74
|
+
name: "test-repo",
|
|
75
|
+
archived: false,
|
|
76
|
+
default_branch: "main",
|
|
77
|
+
homepage: "https://example.com",
|
|
78
|
+
visibility: "public",
|
|
79
|
+
created_at: "2024-01-01T00:00:00Z",
|
|
80
|
+
updated_at: "2024-01-02T00:00:00Z"
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var scanFixtures = {
|
|
84
|
+
/**
|
|
85
|
+
* Pending scan.
|
|
86
|
+
*/
|
|
87
|
+
pending: {
|
|
88
|
+
id: "scan_pending",
|
|
89
|
+
status: "pending",
|
|
90
|
+
created_at: "2024-01-01T00:00:00Z"
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Completed scan with no issues.
|
|
94
|
+
*/
|
|
95
|
+
completed: {
|
|
96
|
+
id: "scan_completed",
|
|
97
|
+
status: "completed",
|
|
98
|
+
created_at: "2024-01-01T00:00:00Z",
|
|
99
|
+
completed_at: "2024-01-01T00:01:00Z",
|
|
100
|
+
issues_found: 0
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Completed scan with issues.
|
|
104
|
+
*/
|
|
105
|
+
withIssues: {
|
|
106
|
+
id: "scan_with_issues",
|
|
107
|
+
status: "completed",
|
|
108
|
+
created_at: "2024-01-01T00:00:00Z",
|
|
109
|
+
completed_at: "2024-01-01T00:01:00Z",
|
|
110
|
+
issues_found: 3
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Failed scan.
|
|
114
|
+
*/
|
|
115
|
+
failed: {
|
|
116
|
+
id: "scan_failed",
|
|
117
|
+
status: "failed",
|
|
118
|
+
created_at: "2024-01-01T00:00:00Z",
|
|
119
|
+
error: "Scan timeout"
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var packageFixtures = {
|
|
123
|
+
/**
|
|
124
|
+
* Safe package with high score.
|
|
125
|
+
*/
|
|
126
|
+
safe: {
|
|
127
|
+
id: "pkg_safe",
|
|
128
|
+
name: "safe-package",
|
|
129
|
+
version: "1.0.0",
|
|
130
|
+
score: 95
|
|
131
|
+
},
|
|
132
|
+
/**
|
|
133
|
+
* Package with vulnerabilities.
|
|
134
|
+
*/
|
|
135
|
+
vulnerable: {
|
|
136
|
+
id: "pkg_vuln",
|
|
137
|
+
name: "vulnerable-package",
|
|
138
|
+
version: "2.0.0",
|
|
139
|
+
score: 45,
|
|
140
|
+
issues: ["vulnerability"]
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Package with malware alert.
|
|
144
|
+
*/
|
|
145
|
+
malware: {
|
|
146
|
+
id: "pkg_malware",
|
|
147
|
+
name: "malware-package",
|
|
148
|
+
version: "3.0.0",
|
|
149
|
+
score: 0,
|
|
150
|
+
issues: ["malware"]
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var issueFixtures = {
|
|
154
|
+
/**
|
|
155
|
+
* Vulnerability issue.
|
|
156
|
+
*/
|
|
157
|
+
vulnerability: {
|
|
158
|
+
type: "vulnerability",
|
|
159
|
+
severity: "high",
|
|
160
|
+
key: "CVE-2024-1234",
|
|
161
|
+
description: "SQL Injection vulnerability"
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* Malware issue.
|
|
165
|
+
*/
|
|
166
|
+
malware: {
|
|
167
|
+
type: "malware",
|
|
168
|
+
severity: "critical",
|
|
169
|
+
key: "malware-detected",
|
|
170
|
+
description: "Malicious code detected"
|
|
171
|
+
},
|
|
172
|
+
/**
|
|
173
|
+
* License issue.
|
|
174
|
+
*/
|
|
175
|
+
license: {
|
|
176
|
+
type: "license",
|
|
177
|
+
severity: "medium",
|
|
178
|
+
key: "license-incompatible",
|
|
179
|
+
description: "License incompatible with project"
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var fixtures = {
|
|
183
|
+
issues: issueFixtures,
|
|
184
|
+
organizations: organizationFixtures,
|
|
185
|
+
packages: packageFixtures,
|
|
186
|
+
repositories: repositoryFixtures,
|
|
187
|
+
scans: scanFixtures
|
|
188
|
+
};
|
|
189
|
+
function mockSdkResult(success, dataOrError, status = success ? 200 : 500, cause) {
|
|
190
|
+
if (success) {
|
|
191
|
+
return {
|
|
192
|
+
cause: void 0,
|
|
193
|
+
data: dataOrError,
|
|
194
|
+
error: void 0,
|
|
195
|
+
status,
|
|
196
|
+
success: true
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
cause,
|
|
201
|
+
data: void 0,
|
|
202
|
+
error: dataOrError,
|
|
203
|
+
status,
|
|
204
|
+
success: false
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function mockSdkError(type, options = {}) {
|
|
208
|
+
const statusMap = {
|
|
209
|
+
FORBIDDEN: 403,
|
|
210
|
+
NOT_FOUND: 404,
|
|
211
|
+
SERVER_ERROR: 500,
|
|
212
|
+
TIMEOUT: 408,
|
|
213
|
+
UNAUTHORIZED: 401
|
|
214
|
+
};
|
|
215
|
+
const messageMap = {
|
|
216
|
+
FORBIDDEN: "Access forbidden",
|
|
217
|
+
NOT_FOUND: "Resource not found",
|
|
218
|
+
SERVER_ERROR: "Internal server error",
|
|
219
|
+
TIMEOUT: "Request timeout",
|
|
220
|
+
UNAUTHORIZED: "Unauthorized"
|
|
221
|
+
};
|
|
222
|
+
const status = options.status ?? statusMap[type];
|
|
223
|
+
const message = options.message ?? messageMap[type];
|
|
224
|
+
const error = new Error(message);
|
|
225
|
+
error.status = status;
|
|
226
|
+
if (options.cause) {
|
|
227
|
+
error.cause = options.cause;
|
|
228
|
+
}
|
|
229
|
+
return error;
|
|
230
|
+
}
|
|
231
|
+
function isSuccessResult(result) {
|
|
232
|
+
return result.success === true;
|
|
233
|
+
}
|
|
234
|
+
function isErrorResult(result) {
|
|
235
|
+
return result.success === false;
|
|
236
|
+
}
|
|
237
|
+
export {
|
|
238
|
+
fixtures,
|
|
239
|
+
isErrorResult,
|
|
240
|
+
isSuccessResult,
|
|
241
|
+
issueFixtures,
|
|
242
|
+
mockApiErrorBody,
|
|
243
|
+
mockErrorResponse,
|
|
244
|
+
mockSdkError,
|
|
245
|
+
mockSdkResult,
|
|
246
|
+
mockSuccessResponse,
|
|
247
|
+
organizationFixtures,
|
|
248
|
+
packageFixtures,
|
|
249
|
+
repositoryFixtures,
|
|
250
|
+
scanFixtures
|
|
251
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/sdk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.28",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "SDK for the Socket API client",
|
|
6
6
|
"author": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"update": "node scripts/update.mjs"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@socketsecurity/lib": "
|
|
57
|
+
"@socketsecurity/lib": "3.0.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@babel/parser": "7.26.3",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"@dotenvx/dotenvx": "1.49.0",
|
|
65
65
|
"@eslint/compat": "1.3.2",
|
|
66
66
|
"@eslint/js": "9.35.0",
|
|
67
|
-
"@types/node": "24.
|
|
67
|
+
"@types/node": "24.9.2",
|
|
68
68
|
"@typescript/native-preview": "7.0.0-dev.20250926.1",
|
|
69
69
|
"@vitest/coverage-v8": "4.0.3",
|
|
70
70
|
"del": "8.0.1",
|
|
71
71
|
"dev-null-cli": "2.0.0",
|
|
72
|
-
"esbuild": "0.25.
|
|
72
|
+
"esbuild": "0.25.11",
|
|
73
73
|
"eslint": "9.35.0",
|
|
74
74
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
75
75
|
"eslint-plugin-import-x": "4.16.1",
|
package/types/api.d.ts
CHANGED
|
@@ -12530,6 +12530,10 @@ export interface operations {
|
|
|
12530
12530
|
'filters.repoSlug'?: string
|
|
12531
12531
|
/** @description Comma-separated list of repo slugs that should be excluded */
|
|
12532
12532
|
'filters.repoSlug.notIn'?: string
|
|
12533
|
+
/** @description Comma-separated list of repo full names that should be included */
|
|
12534
|
+
'filters.repoFullName'?: string
|
|
12535
|
+
/** @description Comma-separated list of repo full names that should be excluded */
|
|
12536
|
+
'filters.repoFullName.notIn'?: string
|
|
12533
12537
|
/** @description Comma-separated list of repo labels that should be included. Use "" to filter for repositories with no labels. */
|
|
12534
12538
|
'filters.repoLabels'?: string
|
|
12535
12539
|
/** @description Comma-separated list of repo labels that should be excluded. Use "" to filter for repositories with no labels. */
|
|
@@ -12582,6 +12586,10 @@ export interface operations {
|
|
|
12582
12586
|
'filters.alertReachabilityType'?: string
|
|
12583
12587
|
/** @description Comma-separated list of alert CVE reachability types ("direct_dependency", "error", "maybe_reachable", "missing_support", "pending", "reachable", "undeterminable_reachability", "unknown", or "unreachable") that should be excluded */
|
|
12584
12588
|
'filters.alertReachabilityType.notIn'?: string
|
|
12589
|
+
/** @description Comma-separated list of alert CVE reachability analysis types ("full-scan" or "precomputed") that should be included */
|
|
12590
|
+
'filters.alertReachabilityAnalysisType'?: string
|
|
12591
|
+
/** @description Comma-separated list of alert CVE reachability analysis types ("full-scan" or "precomputed") that should be excluded */
|
|
12592
|
+
'filters.alertReachabilityAnalysisType.notIn'?: string
|
|
12585
12593
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12586
12594
|
'filters.alertPriority'?: string
|
|
12587
12595
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
@@ -12620,6 +12628,8 @@ export interface operations {
|
|
|
12620
12628
|
/** @default */
|
|
12621
12629
|
endCursor: string | null
|
|
12622
12630
|
items: Array<{
|
|
12631
|
+
/** @default */
|
|
12632
|
+
repoFullName: string
|
|
12623
12633
|
/** @default */
|
|
12624
12634
|
repoId: string | null
|
|
12625
12635
|
/** @default */
|
|
@@ -12717,6 +12727,8 @@ export interface operations {
|
|
|
12717
12727
|
alertSeverity?: string[]
|
|
12718
12728
|
/** @description Comma-separated list of repo slugs that should be excluded */
|
|
12719
12729
|
repoSlug?: string[]
|
|
12730
|
+
/** @description Comma-separated list of repo full names that should be excluded */
|
|
12731
|
+
repoFullName?: string[]
|
|
12720
12732
|
/** @description Comma-separated list of repo labels that should be excluded. Use "" to filter for repositories with no labels. */
|
|
12721
12733
|
repoLabels?: string[]
|
|
12722
12734
|
/** @description Comma-separated list of alert types (e.g. "usesEval", "unmaintained", etc.) that should be excluded */
|
|
@@ -12743,6 +12755,8 @@ export interface operations {
|
|
|
12743
12755
|
alertCweName?: string[]
|
|
12744
12756
|
/** @description Comma-separated list of alert CVE reachability types ("direct_dependency", "error", "maybe_reachable", "missing_support", "pending", "reachable", "undeterminable_reachability", "unknown", or "unreachable") that should be excluded */
|
|
12745
12757
|
alertReachabilityType?: string[]
|
|
12758
|
+
/** @description Comma-separated list of alert CVE reachability analysis types ("full-scan" or "precomputed") that should be excluded */
|
|
12759
|
+
alertReachabilityAnalysisType?: string[]
|
|
12746
12760
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12747
12761
|
alertPriority?: string[]
|
|
12748
12762
|
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
@@ -12782,7 +12796,7 @@ export interface operations {
|
|
|
12782
12796
|
date?: string
|
|
12783
12797
|
/** @description The number of days of data to fetch as an offset from input date */
|
|
12784
12798
|
range?: string
|
|
12785
|
-
/** @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) */
|
|
12799
|
+
/** @description Comma-separated list of fields that should be used for count aggregation (allowed: alertSeverity,repoSlug,repoFullName,repoLabels,alertType,artifactType,alertAction,alertActionSourceType,alertFixType,alertCategory,alertCveId,alertCveTitle,alertCweId,alertCweName,alertReachabilityType,alertReachabilityAnalysisType,alertPriority,alertKEV,alertEPSS,dependencyDirect,dependencyDev,dependencyDead) */
|
|
12786
12800
|
'aggregation.fields'?: string
|
|
12787
12801
|
/** @description Comma-separated list of alert severities ("low", "medium", "high", or "critical") that should be included */
|
|
12788
12802
|
'filters.alertSeverity'?: string
|
|
@@ -12792,6 +12806,10 @@ export interface operations {
|
|
|
12792
12806
|
'filters.repoSlug'?: string
|
|
12793
12807
|
/** @description Comma-separated list of repo slugs that should be excluded */
|
|
12794
12808
|
'filters.repoSlug.notIn'?: string
|
|
12809
|
+
/** @description Comma-separated list of repo full names that should be included */
|
|
12810
|
+
'filters.repoFullName'?: string
|
|
12811
|
+
/** @description Comma-separated list of repo full names that should be excluded */
|
|
12812
|
+
'filters.repoFullName.notIn'?: string
|
|
12795
12813
|
/** @description Comma-separated list of repo labels that should be included. Use "" to filter for repositories with no labels. */
|
|
12796
12814
|
'filters.repoLabels'?: string
|
|
12797
12815
|
/** @description Comma-separated list of repo labels that should be excluded. Use "" to filter for repositories with no labels. */
|
|
@@ -12844,6 +12862,10 @@ export interface operations {
|
|
|
12844
12862
|
'filters.alertReachabilityType'?: string
|
|
12845
12863
|
/** @description Comma-separated list of alert CVE reachability types ("direct_dependency", "error", "maybe_reachable", "missing_support", "pending", "reachable", "undeterminable_reachability", "unknown", or "unreachable") that should be excluded */
|
|
12846
12864
|
'filters.alertReachabilityType.notIn'?: string
|
|
12865
|
+
/** @description Comma-separated list of alert CVE reachability analysis types ("full-scan" or "precomputed") that should be included */
|
|
12866
|
+
'filters.alertReachabilityAnalysisType'?: string
|
|
12867
|
+
/** @description Comma-separated list of alert CVE reachability analysis types ("full-scan" or "precomputed") that should be excluded */
|
|
12868
|
+
'filters.alertReachabilityAnalysisType.notIn'?: string
|
|
12847
12869
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12848
12870
|
'filters.alertPriority'?: string
|
|
12849
12871
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
@@ -12897,6 +12919,8 @@ export interface operations {
|
|
|
12897
12919
|
alertSeverity?: string[]
|
|
12898
12920
|
/** @description Comma-separated list of repo slugs that should be excluded */
|
|
12899
12921
|
repoSlug?: string[]
|
|
12922
|
+
/** @description Comma-separated list of repo full names that should be excluded */
|
|
12923
|
+
repoFullName?: string[]
|
|
12900
12924
|
/** @description Comma-separated list of repo labels that should be excluded. Use "" to filter for repositories with no labels. */
|
|
12901
12925
|
repoLabels?: string[]
|
|
12902
12926
|
/** @description Comma-separated list of alert types (e.g. "usesEval", "unmaintained", etc.) that should be excluded */
|
|
@@ -12923,6 +12947,8 @@ export interface operations {
|
|
|
12923
12947
|
alertCweName?: string[]
|
|
12924
12948
|
/** @description Comma-separated list of alert CVE reachability types ("direct_dependency", "error", "maybe_reachable", "missing_support", "pending", "reachable", "undeterminable_reachability", "unknown", or "unreachable") that should be excluded */
|
|
12925
12949
|
alertReachabilityType?: string[]
|
|
12950
|
+
/** @description Comma-separated list of alert CVE reachability analysis types ("full-scan" or "precomputed") that should be excluded */
|
|
12951
|
+
alertReachabilityAnalysisType?: string[]
|
|
12926
12952
|
/** @description Alert priority ("low", "medium", "high", or "critical") */
|
|
12927
12953
|
alertPriority?: string[]
|
|
12928
12954
|
/** @description Alert KEV (Known Exploited Vulnerability) filter flag */
|
|
@@ -12975,6 +13001,8 @@ export interface operations {
|
|
|
12975
13001
|
date?: string
|
|
12976
13002
|
/** @description The number of days of data to fetch as an offset from input date */
|
|
12977
13003
|
range?: string
|
|
13004
|
+
/** @description Comma-separated list of repo full names that should be included */
|
|
13005
|
+
repoFullName?: string
|
|
12978
13006
|
/** @description Comma-separated list of repo slugs that should be included */
|
|
12979
13007
|
repoSlug?: string
|
|
12980
13008
|
/** @description Comma-separated list of repo labels that should be included */
|
|
@@ -13012,6 +13040,8 @@ export interface operations {
|
|
|
13012
13040
|
groups: string[][]
|
|
13013
13041
|
}
|
|
13014
13042
|
filters: {
|
|
13043
|
+
/** @description Comma-separated list of repo full names that should be included */
|
|
13044
|
+
repoFullName?: string[]
|
|
13015
13045
|
/** @description Comma-separated list of repo slugs that should be included */
|
|
13016
13046
|
repoSlug?: string[]
|
|
13017
13047
|
/** @description Comma-separated list of repo labels that should be included */
|