@socketsecurity/sdk 3.0.27 → 3.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/testing.mjs CHANGED
@@ -1,2 +1,251 @@
1
1
  /* Socket SDK ESM - Built with esbuild */
2
- function p(e,s=200){return{cause:void 0,data:e,error:void 0,status:s,success:!0}}function k(e,s=500,t){return{cause:t,data:void 0,error:e,status:s,success:!1}}function S(e,s){return{error:{message:e,...s?{details:s}:{}}}}var o={basic:{id:"org_123",name:"test-org",plan:"free"},full:{id:"org_123",name:"test-org",plan:"enterprise",created_at:"2024-01-01T00:00:00Z",updated_at:"2024-01-02T00:00:00Z"}},i={basic:{id:"repo_123",name:"test-repo",archived:!1,default_branch:"main"},archived:{id:"repo_456",name:"old-repo",archived:!0,default_branch:"master"},full:{id:"repo_123",name:"test-repo",archived:!1,default_branch:"main",homepage:"https://example.com",visibility:"public",created_at:"2024-01-01T00:00:00Z",updated_at:"2024-01-02T00:00:00Z"}},u={pending:{id:"scan_pending",status:"pending",created_at:"2024-01-01T00:00:00Z"},completed:{id:"scan_completed",status:"completed",created_at:"2024-01-01T00:00:00Z",completed_at:"2024-01-01T00:01:00Z",issues_found:0},withIssues:{id:"scan_with_issues",status:"completed",created_at:"2024-01-01T00:00:00Z",completed_at:"2024-01-01T00:01:00Z",issues_found:3},failed:{id:"scan_failed",status:"failed",created_at:"2024-01-01T00:00:00Z",error:"Scan timeout"}},d={safe:{id:"pkg_safe",name:"safe-package",version:"1.0.0",score:95},vulnerable:{id:"pkg_vuln",name:"vulnerable-package",version:"2.0.0",score:45,issues:["vulnerability"]},malware:{id:"pkg_malware",name:"malware-package",version:"3.0.0",score:0,issues:["malware"]}},l={vulnerability:{type:"vulnerability",severity:"high",key:"CVE-2024-1234",description:"SQL Injection vulnerability"},malware:{type:"malware",severity:"critical",key:"malware-detected",description:"Malicious code detected"},license:{type:"license",severity:"medium",key:"license-incompatible",description:"License incompatible with project"}},m={issues:l,organizations:o,packages:d,repositories:i,scans:u};function R(e,s,t=e?200:500,r){return e?{cause:void 0,data:s,error:void 0,status:t,success:!0}:{cause:r,data:void 0,error:s,status:t,success:!1}}function f(e,s={}){let t={FORBIDDEN:403,NOT_FOUND:404,SERVER_ERROR:500,TIMEOUT:408,UNAUTHORIZED:401},r={FORBIDDEN:"Access forbidden",NOT_FOUND:"Resource not found",SERVER_ERROR:"Internal server error",TIMEOUT:"Request timeout",UNAUTHORIZED:"Unauthorized"},n=s.status??t[e],a=s.message??r[e],c=new Error(a);return c.status=n,s.cause&&(c.cause=s.cause),c}function T(e){return e.success===!0}function g(e){return e.success===!1}export{m as fixtures,g as isErrorResult,T as isSuccessResult,l as issueFixtures,S as mockApiErrorBody,k as mockErrorResponse,f as mockSdkError,R as mockSdkResult,p as mockSuccessResponse,o as organizationFixtures,d as packageFixtures,i as repositoryFixtures,u as scanFixtures};
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.27",
3
+ "version": "3.0.29",
4
4
  "license": "MIT",
5
5
  "description": "SDK for the Socket API client",
6
6
  "author": {
@@ -53,9 +53,6 @@
53
53
  "type": "tsgo --noEmit -p .config/tsconfig.check.json",
54
54
  "update": "node scripts/update.mjs"
55
55
  },
56
- "dependencies": {
57
- "@socketsecurity/lib": "2.10.4"
58
- },
59
56
  "devDependencies": {
60
57
  "@babel/parser": "7.26.3",
61
58
  "@babel/traverse": "7.26.4",
@@ -64,6 +61,8 @@
64
61
  "@dotenvx/dotenvx": "1.49.0",
65
62
  "@eslint/compat": "1.3.2",
66
63
  "@eslint/js": "9.35.0",
64
+ "@socketregistry/packageurl-js": "1.3.2",
65
+ "@socketsecurity/lib": "3.0.3",
67
66
  "@types/node": "24.9.2",
68
67
  "@typescript/native-preview": "7.0.0-dev.20250926.1",
69
68
  "@vitest/coverage-v8": "4.0.3",