@socketsecurity/sdk 3.3.0 → 3.4.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 +100 -4
- package/README.md +10 -23
- package/data/api-method-quota-and-permissions.json +20 -0
- package/dist/constants.d.ts +1 -1
- package/dist/http-client.d.ts +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +340 -179
- package/dist/socket-sdk-class.d.ts +130 -25
- package/dist/types-strict.d.ts +48 -2
- package/dist/types.d.ts +6 -5
- package/package.json +36 -44
- package/types/api.d.ts +1257 -105
package/dist/index.js
CHANGED
|
@@ -71,20 +71,26 @@ module.exports = __toCommonJS(index_exports);
|
|
|
71
71
|
// package.json
|
|
72
72
|
var package_default = {
|
|
73
73
|
name: "@socketsecurity/sdk",
|
|
74
|
-
version: "3.
|
|
75
|
-
packageManager: "pnpm@10.28.1",
|
|
76
|
-
license: "MIT",
|
|
74
|
+
version: "3.4.0",
|
|
77
75
|
description: "SDK for the Socket API client",
|
|
76
|
+
homepage: "https://github.com/SocketDev/socket-sdk-js",
|
|
77
|
+
license: "MIT",
|
|
78
78
|
author: {
|
|
79
79
|
name: "Socket Inc",
|
|
80
80
|
email: "eng@socket.dev",
|
|
81
81
|
url: "https://socket.dev"
|
|
82
82
|
},
|
|
83
|
-
homepage: "https://github.com/SocketDev/socket-sdk-js",
|
|
84
83
|
repository: {
|
|
85
84
|
type: "git",
|
|
86
85
|
url: "git://github.com/SocketDev/socket-sdk-js.git"
|
|
87
86
|
},
|
|
87
|
+
files: [
|
|
88
|
+
"CHANGELOG.md",
|
|
89
|
+
"data/*.json",
|
|
90
|
+
"dist/*.d.ts",
|
|
91
|
+
"dist/*.js",
|
|
92
|
+
"types/*.d.ts"
|
|
93
|
+
],
|
|
88
94
|
main: "./dist/index.js",
|
|
89
95
|
types: "./dist/index.d.ts",
|
|
90
96
|
exports: {
|
|
@@ -113,6 +119,8 @@ var package_default = {
|
|
|
113
119
|
clean: "node scripts/clean.mjs",
|
|
114
120
|
cover: "node scripts/cover.mjs",
|
|
115
121
|
fix: "node scripts/lint.mjs --fix",
|
|
122
|
+
format: "oxfmt .",
|
|
123
|
+
"format:check": "oxfmt --check .",
|
|
116
124
|
"generate-sdk": "node scripts/generate-sdk.mjs",
|
|
117
125
|
lint: "node scripts/lint.mjs",
|
|
118
126
|
precommit: "pnpm run check --lint --staged",
|
|
@@ -120,7 +128,7 @@ var package_default = {
|
|
|
120
128
|
"ci:validate": "node scripts/ci-validate.mjs",
|
|
121
129
|
prepublishOnly: "echo 'ERROR: Use GitHub Actions workflow for publishing' && exit 1",
|
|
122
130
|
publish: "node scripts/publish.mjs",
|
|
123
|
-
"publish:ci": "node scripts/publish.mjs --
|
|
131
|
+
"publish:ci": "node scripts/publish.mjs --tag ${DIST_TAG:-latest}",
|
|
124
132
|
claude: "node scripts/claude.mjs",
|
|
125
133
|
test: "node scripts/test.mjs",
|
|
126
134
|
type: "tsgo --noEmit -p .config/tsconfig.check.json",
|
|
@@ -128,7 +136,7 @@ var package_default = {
|
|
|
128
136
|
},
|
|
129
137
|
dependencies: {
|
|
130
138
|
"@socketregistry/packageurl-js": "1.3.5",
|
|
131
|
-
"@socketsecurity/lib": "5.
|
|
139
|
+
"@socketsecurity/lib": "5.8.0",
|
|
132
140
|
"form-data": "4.0.5"
|
|
133
141
|
},
|
|
134
142
|
devDependencies: {
|
|
@@ -136,40 +144,46 @@ var package_default = {
|
|
|
136
144
|
"@babel/parser": "7.26.3",
|
|
137
145
|
"@babel/traverse": "7.26.4",
|
|
138
146
|
"@babel/types": "7.26.3",
|
|
139
|
-
"@
|
|
140
|
-
"@
|
|
141
|
-
"@
|
|
142
|
-
"@eslint/js": "9.35.0",
|
|
147
|
+
"@dotenvx/dotenvx": "1.54.1",
|
|
148
|
+
"@oxlint/migrate": "1.52.0",
|
|
149
|
+
"@sveltejs/acorn-typescript": "1.0.8",
|
|
143
150
|
"@types/babel__traverse": "7.28.0",
|
|
144
151
|
"@types/node": "24.9.2",
|
|
145
152
|
"@typescript/native-preview": "7.0.0-dev.20250926.1",
|
|
146
153
|
"@vitest/coverage-v8": "4.0.3",
|
|
147
|
-
"@sveltejs/acorn-typescript": "1.0.8",
|
|
148
154
|
acorn: "8.15.0",
|
|
149
155
|
del: "8.0.1",
|
|
150
156
|
"dev-null-cli": "2.0.0",
|
|
151
157
|
esbuild: "0.25.11",
|
|
152
|
-
eslint: "9.35.0",
|
|
153
|
-
"eslint-import-resolver-typescript": "4.4.4",
|
|
154
|
-
"eslint-plugin-import-x": "4.16.1",
|
|
155
|
-
"eslint-plugin-jsdoc": "57.0.8",
|
|
156
|
-
"eslint-plugin-n": "17.23.1",
|
|
157
|
-
"eslint-plugin-sort-destructure-keys": "2.0.0",
|
|
158
|
-
"eslint-plugin-unicorn": "56.0.1",
|
|
159
158
|
"fast-glob": "3.3.3",
|
|
160
|
-
globals: "16.4.0",
|
|
161
159
|
"http2-wrapper": "2.2.1",
|
|
162
160
|
husky: "9.1.7",
|
|
163
161
|
"magic-string": "0.30.14",
|
|
164
162
|
nock: "14.0.10",
|
|
165
163
|
"openapi-typescript": "6.7.6",
|
|
164
|
+
oxfmt: "0.37.0",
|
|
165
|
+
oxlint: "1.52.0",
|
|
166
166
|
semver: "7.7.2",
|
|
167
167
|
taze: "19.9.2",
|
|
168
168
|
"type-coverage": "2.29.7",
|
|
169
|
-
|
|
170
|
-
vitest: "4.0.3",
|
|
171
|
-
"yoctocolors-cjs": "2.1.3"
|
|
169
|
+
vitest: "4.0.3"
|
|
172
170
|
},
|
|
171
|
+
typeCoverage: {
|
|
172
|
+
atLeast: 99,
|
|
173
|
+
cache: true,
|
|
174
|
+
"ignore-files": "test/*",
|
|
175
|
+
"ignore-non-null-assertion": true,
|
|
176
|
+
"ignore-type-assertion": true,
|
|
177
|
+
ignoreAsAssertion: true,
|
|
178
|
+
ignoreCatch: true,
|
|
179
|
+
ignoreEmptyType: true,
|
|
180
|
+
strict: true
|
|
181
|
+
},
|
|
182
|
+
engines: {
|
|
183
|
+
node: ">=18",
|
|
184
|
+
pnpm: ">=10.25.0"
|
|
185
|
+
},
|
|
186
|
+
packageManager: "pnpm@10.32.1",
|
|
173
187
|
pnpm: {
|
|
174
188
|
ignoredBuiltDependencies: [
|
|
175
189
|
"esbuild",
|
|
@@ -178,28 +192,6 @@ var package_default = {
|
|
|
178
192
|
overrides: {
|
|
179
193
|
vite: "7.1.12"
|
|
180
194
|
}
|
|
181
|
-
},
|
|
182
|
-
engines: {
|
|
183
|
-
node: ">=18",
|
|
184
|
-
pnpm: ">=10.25.0"
|
|
185
|
-
},
|
|
186
|
-
files: [
|
|
187
|
-
"CHANGELOG.md",
|
|
188
|
-
"data/*.json",
|
|
189
|
-
"dist/*.d.ts",
|
|
190
|
-
"dist/*.js",
|
|
191
|
-
"types/*.d.ts"
|
|
192
|
-
],
|
|
193
|
-
typeCoverage: {
|
|
194
|
-
cache: true,
|
|
195
|
-
atLeast: 99,
|
|
196
|
-
ignoreAsAssertion: true,
|
|
197
|
-
ignoreCatch: true,
|
|
198
|
-
ignoreEmptyType: true,
|
|
199
|
-
"ignore-non-null-assertion": true,
|
|
200
|
-
"ignore-type-assertion": true,
|
|
201
|
-
"ignore-files": "test/*",
|
|
202
|
-
strict: true
|
|
203
195
|
}
|
|
204
196
|
};
|
|
205
197
|
|
|
@@ -468,11 +460,12 @@ function sanitizeHeaders(headers) {
|
|
|
468
460
|
// src/http-client.ts
|
|
469
461
|
var ResponseError = class _ResponseError extends Error {
|
|
470
462
|
response;
|
|
463
|
+
url;
|
|
471
464
|
/**
|
|
472
465
|
* Create a new ResponseError from an HTTP response.
|
|
473
466
|
* Automatically formats error message with status code and message.
|
|
474
467
|
*/
|
|
475
|
-
constructor(response, message = "") {
|
|
468
|
+
constructor(response, message = "", url) {
|
|
476
469
|
const statusCode = response.statusCode ?? "unknown";
|
|
477
470
|
const statusMessage = response.statusMessage ?? "No status message";
|
|
478
471
|
super(
|
|
@@ -481,6 +474,7 @@ var ResponseError = class _ResponseError extends Error {
|
|
|
481
474
|
);
|
|
482
475
|
this.name = "ResponseError";
|
|
483
476
|
this.response = response;
|
|
477
|
+
this.url = url;
|
|
484
478
|
Error.captureStackTrace(this, _ResponseError);
|
|
485
479
|
}
|
|
486
480
|
};
|
|
@@ -627,10 +621,10 @@ async function getErrorResponseBody(response) {
|
|
|
627
621
|
response.setEncoding("utf8");
|
|
628
622
|
response.on("data", (chunk) => {
|
|
629
623
|
const chunkBytes = Buffer.byteLength(chunk, "utf8");
|
|
630
|
-
totalBytes
|
|
631
|
-
if (totalBytes > MAX_RESPONSE_SIZE) {
|
|
624
|
+
if (totalBytes + chunkBytes > MAX_RESPONSE_SIZE) {
|
|
632
625
|
response.destroy();
|
|
633
|
-
const
|
|
626
|
+
const projectedSize = totalBytes + chunkBytes;
|
|
627
|
+
const sizeMB = (projectedSize / (1024 * 1024)).toFixed(2);
|
|
634
628
|
const maxMB = (MAX_RESPONSE_SIZE / (1024 * 1024)).toFixed(2);
|
|
635
629
|
const message = [
|
|
636
630
|
`Response exceeds maximum size limit (${sizeMB}MB > ${maxMB}MB)`,
|
|
@@ -642,6 +636,7 @@ async function getErrorResponseBody(response) {
|
|
|
642
636
|
reject(new Error(message));
|
|
643
637
|
return;
|
|
644
638
|
}
|
|
639
|
+
totalBytes += chunkBytes;
|
|
645
640
|
body += chunk;
|
|
646
641
|
});
|
|
647
642
|
response.on("end", () => resolve(body));
|
|
@@ -731,13 +726,14 @@ async function getResponse(req) {
|
|
|
731
726
|
});
|
|
732
727
|
});
|
|
733
728
|
}
|
|
734
|
-
async function getResponseJson(response, method) {
|
|
729
|
+
async function getResponseJson(response, method, url) {
|
|
735
730
|
const stopTimer = (0, import_performance.perfTimer)("http:parse-json");
|
|
736
731
|
try {
|
|
737
732
|
if (!isResponseOk(response)) {
|
|
738
733
|
throw new ResponseError(
|
|
739
734
|
response,
|
|
740
|
-
method ? `${method} Request failed` : void 0
|
|
735
|
+
method ? `${method} Request failed` : void 0,
|
|
736
|
+
url
|
|
741
737
|
);
|
|
742
738
|
}
|
|
743
739
|
const responseBody = await getErrorResponseBody(response);
|
|
@@ -809,7 +805,7 @@ function isResponseOk(response) {
|
|
|
809
805
|
}
|
|
810
806
|
function reshapeArtifactForPublicPolicy(data, isAuthenticated, actions) {
|
|
811
807
|
if (!isAuthenticated) {
|
|
812
|
-
const allowedActions = actions ? actions.split(",") : void 0;
|
|
808
|
+
const allowedActions = actions?.trim() ? actions.split(",") : void 0;
|
|
813
809
|
const reshapeArtifact = (artifact) => ({
|
|
814
810
|
name: artifact.name,
|
|
815
811
|
version: artifact.version,
|
|
@@ -923,7 +919,7 @@ async function createUploadRequest(baseUrl, urlPath, form, options) {
|
|
|
923
919
|
timeout: opts.timeout
|
|
924
920
|
});
|
|
925
921
|
req.flushHeaders();
|
|
926
|
-
getResponse(req).then(
|
|
922
|
+
void getResponse(req).then(
|
|
927
923
|
(response) => {
|
|
928
924
|
hooks?.onResponse?.({
|
|
929
925
|
method,
|
|
@@ -947,7 +943,6 @@ async function createUploadRequest(baseUrl, urlPath, form, options) {
|
|
|
947
943
|
);
|
|
948
944
|
form.pipe(req);
|
|
949
945
|
form.on("error", fail);
|
|
950
|
-
req.on("error", fail);
|
|
951
946
|
});
|
|
952
947
|
}
|
|
953
948
|
|
|
@@ -1124,7 +1119,7 @@ var SocketSdk = class {
|
|
|
1124
1119
|
userAgent
|
|
1125
1120
|
} = { __proto__: null, ...options };
|
|
1126
1121
|
if (timeout !== void 0) {
|
|
1127
|
-
if (typeof timeout !== "number" || timeout < MIN_HTTP_TIMEOUT || timeout > MAX_HTTP_TIMEOUT) {
|
|
1122
|
+
if (typeof timeout !== "number" || Number.isNaN(timeout) || timeout < MIN_HTTP_TIMEOUT || timeout > MAX_HTTP_TIMEOUT) {
|
|
1128
1123
|
throw new TypeError(
|
|
1129
1124
|
`"timeout" must be a number between ${MIN_HTTP_TIMEOUT} and ${MAX_HTTP_TIMEOUT} milliseconds`
|
|
1130
1125
|
);
|
|
@@ -1187,22 +1182,26 @@ var SocketSdk = class {
|
|
|
1187
1182
|
signal: abortSignal
|
|
1188
1183
|
});
|
|
1189
1184
|
const isPublicToken = this.#apiToken === import_socket2.SOCKET_PUBLIC_API_TOKEN;
|
|
1190
|
-
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
if ((0, import_objects.isObjectObject)(artifact)) {
|
|
1197
|
-
yield this.#handleApiSuccess(
|
|
1198
|
-
/* c8 ignore next 7 - Public token artifact reshaping branch for policy compliance. */
|
|
1199
|
-
isPublicToken ? reshapeArtifactForPublicPolicy(
|
|
1200
|
-
artifact,
|
|
1201
|
-
false,
|
|
1202
|
-
queryParams?.["actions"]
|
|
1203
|
-
) : artifact
|
|
1185
|
+
try {
|
|
1186
|
+
for await (const line of rli) {
|
|
1187
|
+
const trimmed = line.trim();
|
|
1188
|
+
const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
|
|
1189
|
+
/* c8 ignore next - Empty line handling in batch streaming response parsing. */
|
|
1190
|
+
null
|
|
1204
1191
|
);
|
|
1192
|
+
if ((0, import_objects.isObjectObject)(artifact)) {
|
|
1193
|
+
yield this.#handleApiSuccess(
|
|
1194
|
+
/* c8 ignore next 7 - Public token artifact reshaping branch for policy compliance. */
|
|
1195
|
+
isPublicToken ? reshapeArtifactForPublicPolicy(
|
|
1196
|
+
artifact,
|
|
1197
|
+
false,
|
|
1198
|
+
queryParams?.["actions"]
|
|
1199
|
+
) : artifact
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1205
1202
|
}
|
|
1203
|
+
} finally {
|
|
1204
|
+
rli.close();
|
|
1206
1205
|
}
|
|
1207
1206
|
}
|
|
1208
1207
|
/**
|
|
@@ -1210,13 +1209,14 @@ var SocketSdk = class {
|
|
|
1210
1209
|
* Internal method for handling PURL batch API calls with retry logic.
|
|
1211
1210
|
*/
|
|
1212
1211
|
async #createBatchPurlRequest(componentsObj, queryParams) {
|
|
1213
|
-
const
|
|
1212
|
+
const url = `${this.#baseUrl}purl?${queryToSearchParams(queryParams)}`;
|
|
1213
|
+
const req = getHttpModule(this.#baseUrl).request(url, {
|
|
1214
1214
|
method: "POST",
|
|
1215
1215
|
...this.#reqOptions
|
|
1216
1216
|
}).end(JSON.stringify(componentsObj));
|
|
1217
1217
|
const response = await getResponse(req);
|
|
1218
1218
|
if (!isResponseOk(response)) {
|
|
1219
|
-
throw new ResponseError(response);
|
|
1219
|
+
throw new ResponseError(response, "", url);
|
|
1220
1220
|
}
|
|
1221
1221
|
return response;
|
|
1222
1222
|
}
|
|
@@ -1450,7 +1450,8 @@ var SocketSdk = class {
|
|
|
1450
1450
|
error: errorMessage,
|
|
1451
1451
|
/* c8 ignore next - fallback for missing status code in edge cases. */
|
|
1452
1452
|
status: statusCode ?? 0,
|
|
1453
|
-
success: false
|
|
1453
|
+
success: false,
|
|
1454
|
+
url: error.url
|
|
1454
1455
|
};
|
|
1455
1456
|
}
|
|
1456
1457
|
/**
|
|
@@ -1543,18 +1544,16 @@ var SocketSdk = class {
|
|
|
1543
1544
|
* @throws {Error} When server returns 5xx status codes
|
|
1544
1545
|
*/
|
|
1545
1546
|
async batchOrgPackageFetch(orgSlug, componentsObj, queryParams) {
|
|
1547
|
+
const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/purl?${queryToSearchParams(queryParams)}`;
|
|
1546
1548
|
let res;
|
|
1547
1549
|
try {
|
|
1548
|
-
const req = getHttpModule(this.#baseUrl).request(
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
...this.#reqOptions
|
|
1553
|
-
}
|
|
1554
|
-
).end(JSON.stringify(componentsObj));
|
|
1550
|
+
const req = getHttpModule(this.#baseUrl).request(url, {
|
|
1551
|
+
method: "POST",
|
|
1552
|
+
...this.#reqOptions
|
|
1553
|
+
}).end(JSON.stringify(componentsObj));
|
|
1555
1554
|
res = await getResponse(req);
|
|
1556
1555
|
if (!isResponseOk(res)) {
|
|
1557
|
-
throw new ResponseError(res);
|
|
1556
|
+
throw new ResponseError(res, "", url);
|
|
1558
1557
|
}
|
|
1559
1558
|
} catch (e) {
|
|
1560
1559
|
return await this.#handleApiError(e);
|
|
@@ -1568,15 +1567,19 @@ var SocketSdk = class {
|
|
|
1568
1567
|
signal: abortSignal
|
|
1569
1568
|
});
|
|
1570
1569
|
const results = [];
|
|
1571
|
-
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1570
|
+
try {
|
|
1571
|
+
for await (const line of rli) {
|
|
1572
|
+
const trimmed = line.trim();
|
|
1573
|
+
const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
|
|
1574
|
+
/* c8 ignore next - Empty line handling in batch parsing. */
|
|
1575
|
+
null
|
|
1576
|
+
);
|
|
1577
|
+
if ((0, import_objects.isObjectObject)(artifact)) {
|
|
1578
|
+
results.push(artifact);
|
|
1579
|
+
}
|
|
1579
1580
|
}
|
|
1581
|
+
} finally {
|
|
1582
|
+
rli.close();
|
|
1580
1583
|
}
|
|
1581
1584
|
const compact = (0, import_url.urlSearchParamAsBoolean)(
|
|
1582
1585
|
(0, import_objects.getOwn)(queryParams, "compact")
|
|
@@ -1608,22 +1611,26 @@ var SocketSdk = class {
|
|
|
1608
1611
|
});
|
|
1609
1612
|
const isPublicToken = this.#apiToken === import_socket2.SOCKET_PUBLIC_API_TOKEN;
|
|
1610
1613
|
const results = [];
|
|
1611
|
-
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
if ((0, import_objects.isObjectObject)(artifact)) {
|
|
1618
|
-
results.push(
|
|
1619
|
-
/* c8 ignore next 7 - Public token artifact reshaping for policy compliance. */
|
|
1620
|
-
isPublicToken ? reshapeArtifactForPublicPolicy(
|
|
1621
|
-
artifact,
|
|
1622
|
-
false,
|
|
1623
|
-
queryParams?.["actions"]
|
|
1624
|
-
) : artifact
|
|
1614
|
+
try {
|
|
1615
|
+
for await (const line of rli) {
|
|
1616
|
+
const trimmed = line.trim();
|
|
1617
|
+
const artifact = trimmed ? (0, import_parse2.jsonParse)(line, { throws: false }) : (
|
|
1618
|
+
/* c8 ignore next - Empty line handling in batch parsing. */
|
|
1619
|
+
null
|
|
1625
1620
|
);
|
|
1621
|
+
if ((0, import_objects.isObjectObject)(artifact)) {
|
|
1622
|
+
results.push(
|
|
1623
|
+
/* c8 ignore next 7 - Public token artifact reshaping for policy compliance. */
|
|
1624
|
+
isPublicToken ? reshapeArtifactForPublicPolicy(
|
|
1625
|
+
artifact,
|
|
1626
|
+
false,
|
|
1627
|
+
queryParams?.["actions"]
|
|
1628
|
+
) : artifact
|
|
1629
|
+
);
|
|
1630
|
+
}
|
|
1626
1631
|
}
|
|
1632
|
+
} finally {
|
|
1633
|
+
rli.close();
|
|
1627
1634
|
}
|
|
1628
1635
|
const compact = (0, import_url.urlSearchParamAsBoolean)(
|
|
1629
1636
|
(0, import_objects.getOwn)(queryParams, "compact")
|
|
@@ -1689,11 +1696,13 @@ var SocketSdk = class {
|
|
|
1689
1696
|
const { generator, iteratorResult } = await Promise.race(
|
|
1690
1697
|
running.map((entry) => entry.promise)
|
|
1691
1698
|
);
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1699
|
+
const runningIndex = running.findIndex(
|
|
1700
|
+
(entry) => entry.generator === generator
|
|
1701
|
+
);
|
|
1702
|
+
if (runningIndex === -1) {
|
|
1694
1703
|
continue;
|
|
1695
1704
|
}
|
|
1696
|
-
running.splice(
|
|
1705
|
+
running.splice(runningIndex, 1);
|
|
1697
1706
|
if (iteratorResult.value) {
|
|
1698
1707
|
yield iteratorResult.value;
|
|
1699
1708
|
}
|
|
@@ -1819,7 +1828,7 @@ var SocketSdk = class {
|
|
|
1819
1828
|
*
|
|
1820
1829
|
* @see https://docs.socket.dev/reference/createorgfullscan
|
|
1821
1830
|
* @apiEndpoint POST /orgs/{org_slug}/full-scans
|
|
1822
|
-
* @quota
|
|
1831
|
+
* @quota 0 units
|
|
1823
1832
|
* @scopes full-scans:create
|
|
1824
1833
|
* @throws {Error} When server returns 5xx status codes
|
|
1825
1834
|
*/
|
|
@@ -1918,16 +1927,43 @@ var SocketSdk = class {
|
|
|
1918
1927
|
* Create a diff scan from two full scan IDs.
|
|
1919
1928
|
* Compares two existing full scans to identify changes.
|
|
1920
1929
|
*
|
|
1930
|
+
* @param orgSlug - Organization identifier
|
|
1931
|
+
* @param options - Diff scan creation options
|
|
1932
|
+
* @param options.after - ID of the after/head full scan (newer)
|
|
1933
|
+
* @param options.before - ID of the before/base full scan (older)
|
|
1934
|
+
* @param options.description - Description of the diff scan
|
|
1935
|
+
* @param options.external_href - External URL to associate with the diff scan
|
|
1936
|
+
* @param options.merge - Set true for merged commits, false for open PR diffs
|
|
1937
|
+
* @returns Diff scan details
|
|
1938
|
+
*
|
|
1939
|
+
* @example
|
|
1940
|
+
* ```typescript
|
|
1941
|
+
* const result = await sdk.createOrgDiffScanFromIds('my-org', {
|
|
1942
|
+
* before: 'scan-id-1',
|
|
1943
|
+
* after: 'scan-id-2',
|
|
1944
|
+
* description: 'Compare versions',
|
|
1945
|
+
* merge: false
|
|
1946
|
+
* })
|
|
1947
|
+
*
|
|
1948
|
+
* if (result.success) {
|
|
1949
|
+
* console.log('Diff scan created:', result.data.diff_scan.id)
|
|
1950
|
+
* }
|
|
1951
|
+
* ```
|
|
1952
|
+
*
|
|
1953
|
+
* @see https://docs.socket.dev/reference/createorgdiffscanfromids
|
|
1954
|
+
* @apiEndpoint POST /orgs/{org_slug}/diff-scans/from-ids
|
|
1955
|
+
* @quota 0 units
|
|
1956
|
+
* @scopes diff-scans:create, full-scans:list
|
|
1921
1957
|
* @throws {Error} When server returns 5xx status codes
|
|
1922
1958
|
*/
|
|
1923
|
-
async createOrgDiffScanFromIds(orgSlug,
|
|
1959
|
+
async createOrgDiffScanFromIds(orgSlug, options) {
|
|
1924
1960
|
try {
|
|
1925
1961
|
const data = await this.#executeWithRetry(
|
|
1926
1962
|
async () => await getResponseJson(
|
|
1927
1963
|
await createRequestWithJson(
|
|
1928
1964
|
"POST",
|
|
1929
1965
|
this.#baseUrl,
|
|
1930
|
-
`orgs/${encodeURIComponent(orgSlug)}/diff-scans?${queryToSearchParams(
|
|
1966
|
+
`orgs/${encodeURIComponent(orgSlug)}/diff-scans/from-ids?${queryToSearchParams(options)}`,
|
|
1931
1967
|
{},
|
|
1932
1968
|
{ ...this.#reqOptions, hooks: this.#hooks }
|
|
1933
1969
|
)
|
|
@@ -2001,15 +2037,22 @@ var SocketSdk = class {
|
|
|
2001
2037
|
* Registers a repository for monitoring and security scanning.
|
|
2002
2038
|
*
|
|
2003
2039
|
* @param orgSlug - Organization identifier
|
|
2004
|
-
* @param
|
|
2040
|
+
* @param repoSlug - Repository name/slug
|
|
2041
|
+
* @param params - Additional repository configuration
|
|
2042
|
+
* @param params.archived - Whether the repository is archived
|
|
2043
|
+
* @param params.default_branch - Default branch of the repository
|
|
2044
|
+
* @param params.description - Description of the repository
|
|
2045
|
+
* @param params.homepage - Homepage URL of the repository
|
|
2046
|
+
* @param params.visibility - Visibility setting ('public' or 'private')
|
|
2047
|
+
* @param params.workspace - Workspace of the repository
|
|
2005
2048
|
* @returns Created repository details
|
|
2006
2049
|
*
|
|
2007
2050
|
* @example
|
|
2008
2051
|
* ```typescript
|
|
2009
|
-
* const result = await sdk.createRepository('my-org', {
|
|
2010
|
-
* name: 'my-repo',
|
|
2052
|
+
* const result = await sdk.createRepository('my-org', 'my-repo', {
|
|
2011
2053
|
* description: 'My project repository',
|
|
2012
|
-
* homepage: 'https://example.com'
|
|
2054
|
+
* homepage: 'https://example.com',
|
|
2055
|
+
* visibility: 'private'
|
|
2013
2056
|
* })
|
|
2014
2057
|
*
|
|
2015
2058
|
* if (result.success) {
|
|
@@ -2019,11 +2062,11 @@ var SocketSdk = class {
|
|
|
2019
2062
|
*
|
|
2020
2063
|
* @see https://docs.socket.dev/reference/createorgrepo
|
|
2021
2064
|
* @apiEndpoint POST /orgs/{org_slug}/repos
|
|
2022
|
-
* @quota
|
|
2065
|
+
* @quota 0 units
|
|
2023
2066
|
* @scopes repo:write
|
|
2024
2067
|
* @throws {Error} When server returns 5xx status codes
|
|
2025
2068
|
*/
|
|
2026
|
-
async createRepository(orgSlug, params) {
|
|
2069
|
+
async createRepository(orgSlug, repoSlug, params) {
|
|
2027
2070
|
try {
|
|
2028
2071
|
const data = await this.#executeWithRetry(
|
|
2029
2072
|
async () => await getResponseJson(
|
|
@@ -2031,7 +2074,7 @@ var SocketSdk = class {
|
|
|
2031
2074
|
"POST",
|
|
2032
2075
|
this.#baseUrl,
|
|
2033
2076
|
`orgs/${encodeURIComponent(orgSlug)}/repos`,
|
|
2034
|
-
params,
|
|
2077
|
+
{ ...params, name: repoSlug },
|
|
2035
2078
|
{ ...this.#reqOptions, hooks: this.#hooks }
|
|
2036
2079
|
)
|
|
2037
2080
|
)
|
|
@@ -2075,7 +2118,7 @@ var SocketSdk = class {
|
|
|
2075
2118
|
*
|
|
2076
2119
|
* @see https://docs.socket.dev/reference/createorgrepolabel
|
|
2077
2120
|
* @apiEndpoint POST /orgs/{org_slug}/repos/labels
|
|
2078
|
-
* @quota
|
|
2121
|
+
* @quota 0 units
|
|
2079
2122
|
* @scopes repo-label:create
|
|
2080
2123
|
* @throws {Error} When server returns 5xx status codes
|
|
2081
2124
|
*/
|
|
@@ -2130,7 +2173,7 @@ var SocketSdk = class {
|
|
|
2130
2173
|
*
|
|
2131
2174
|
* @see https://docs.socket.dev/reference/deleteorgfullscan
|
|
2132
2175
|
* @apiEndpoint DELETE /orgs/{org_slug}/full-scans/{full_scan_id}
|
|
2133
|
-
* @quota
|
|
2176
|
+
* @quota 0 units
|
|
2134
2177
|
* @scopes full-scans:delete
|
|
2135
2178
|
* @throws {Error} When server returns 5xx status codes
|
|
2136
2179
|
*/
|
|
@@ -2232,7 +2275,7 @@ var SocketSdk = class {
|
|
|
2232
2275
|
*
|
|
2233
2276
|
* @see https://docs.socket.dev/reference/deleteorgrepo
|
|
2234
2277
|
* @apiEndpoint DELETE /orgs/{org_slug}/repos/{repo_slug}
|
|
2235
|
-
* @quota
|
|
2278
|
+
* @quota 0 units
|
|
2236
2279
|
* @scopes repo:write
|
|
2237
2280
|
* @throws {Error} When server returns 5xx status codes
|
|
2238
2281
|
*/
|
|
@@ -2290,7 +2333,7 @@ var SocketSdk = class {
|
|
|
2290
2333
|
*
|
|
2291
2334
|
* @see https://docs.socket.dev/reference/deleteorgrepolabel
|
|
2292
2335
|
* @apiEndpoint DELETE /orgs/{org_slug}/repos/labels/{label_id}
|
|
2293
|
-
* @quota
|
|
2336
|
+
* @quota 0 units
|
|
2294
2337
|
* @scopes repo-label:delete
|
|
2295
2338
|
* @throws {Error} When server returns 5xx status codes
|
|
2296
2339
|
*/
|
|
@@ -2349,35 +2392,33 @@ var SocketSdk = class {
|
|
|
2349
2392
|
* ```
|
|
2350
2393
|
*/
|
|
2351
2394
|
async downloadOrgFullScanFilesAsTar(orgSlug, fullScanId, outputPath) {
|
|
2395
|
+
const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(fullScanId)}/files.tar`;
|
|
2352
2396
|
try {
|
|
2353
|
-
const req = getHttpModule(this.#baseUrl).request(
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
...this.#reqOptions
|
|
2358
|
-
}
|
|
2359
|
-
).end();
|
|
2397
|
+
const req = getHttpModule(this.#baseUrl).request(url, {
|
|
2398
|
+
method: "GET",
|
|
2399
|
+
...this.#reqOptions
|
|
2400
|
+
}).end();
|
|
2360
2401
|
const res = await getResponse(req);
|
|
2361
2402
|
if (!isResponseOk(res)) {
|
|
2362
|
-
throw new ResponseError(res);
|
|
2403
|
+
throw new ResponseError(res, "", url);
|
|
2363
2404
|
}
|
|
2364
2405
|
const writeStream = (0, import_node_fs3.createWriteStream)(outputPath);
|
|
2365
2406
|
let bytesWritten = 0;
|
|
2366
2407
|
res.on("data", (chunk) => {
|
|
2367
|
-
bytesWritten
|
|
2368
|
-
|
|
2369
|
-
res.destroy();
|
|
2370
|
-
writeStream.destroy();
|
|
2371
|
-
throw new Error(
|
|
2408
|
+
if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
|
|
2409
|
+
const error = new Error(
|
|
2372
2410
|
`Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
|
|
2373
2411
|
);
|
|
2412
|
+
res.destroy(error);
|
|
2413
|
+
writeStream.destroy(error);
|
|
2414
|
+
return;
|
|
2374
2415
|
}
|
|
2416
|
+
bytesWritten += chunk.length;
|
|
2375
2417
|
});
|
|
2376
2418
|
res.pipe(writeStream);
|
|
2377
2419
|
writeStream.on("error", (error) => {
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
});
|
|
2420
|
+
res.destroy();
|
|
2421
|
+
writeStream.destroy(error);
|
|
2381
2422
|
});
|
|
2382
2423
|
await import_node_events.default.once(writeStream, "finish");
|
|
2383
2424
|
return this.#handleApiSuccess(res);
|
|
@@ -2440,8 +2481,23 @@ var SocketSdk = class {
|
|
|
2440
2481
|
return;
|
|
2441
2482
|
}
|
|
2442
2483
|
let data = "";
|
|
2484
|
+
let bytesRead = 0;
|
|
2485
|
+
const MAX_PATCH_SIZE = 50 * 1024 * 1024;
|
|
2443
2486
|
res.on("data", (chunk) => {
|
|
2444
|
-
|
|
2487
|
+
if (bytesRead + chunk.length > MAX_PATCH_SIZE) {
|
|
2488
|
+
const error = new Error(
|
|
2489
|
+
[
|
|
2490
|
+
`Patch file exceeds maximum size of ${MAX_PATCH_SIZE} bytes`,
|
|
2491
|
+
`\u2192 Current size: ${bytesRead + chunk.length} bytes`,
|
|
2492
|
+
"\u2192 This may indicate an incorrect hash or corrupted blob."
|
|
2493
|
+
].join("\n")
|
|
2494
|
+
);
|
|
2495
|
+
res.destroy(error);
|
|
2496
|
+
reject(error);
|
|
2497
|
+
return;
|
|
2498
|
+
}
|
|
2499
|
+
bytesRead += chunk.length;
|
|
2500
|
+
data += chunk.toString("utf8");
|
|
2445
2501
|
});
|
|
2446
2502
|
res.on("end", () => {
|
|
2447
2503
|
resolve(data);
|
|
@@ -2524,7 +2580,7 @@ var SocketSdk = class {
|
|
|
2524
2580
|
*
|
|
2525
2581
|
* @see https://docs.socket.dev/reference/exportopenvex
|
|
2526
2582
|
* @apiEndpoint GET /orgs/{org_slug}/export/openvex/{id}
|
|
2527
|
-
* @quota
|
|
2583
|
+
* @quota 0 units
|
|
2528
2584
|
* @scopes report:read
|
|
2529
2585
|
* @throws {Error} When server returns 5xx status codes
|
|
2530
2586
|
*/
|
|
@@ -2579,6 +2635,7 @@ var SocketSdk = class {
|
|
|
2579
2635
|
__proto__: null,
|
|
2580
2636
|
...options
|
|
2581
2637
|
};
|
|
2638
|
+
const url = `${this.#baseUrl}${urlPath}`;
|
|
2582
2639
|
try {
|
|
2583
2640
|
const response = await createGetRequest(this.#baseUrl, urlPath, {
|
|
2584
2641
|
...this.#reqOptions,
|
|
@@ -2586,17 +2643,18 @@ var SocketSdk = class {
|
|
|
2586
2643
|
});
|
|
2587
2644
|
if (!isResponseOk(response)) {
|
|
2588
2645
|
if (throws) {
|
|
2589
|
-
throw new ResponseError(response);
|
|
2646
|
+
throw new ResponseError(response, "", url);
|
|
2590
2647
|
}
|
|
2591
2648
|
const errorResult = await this.#handleApiError(
|
|
2592
|
-
new ResponseError(response)
|
|
2649
|
+
new ResponseError(response, "", url)
|
|
2593
2650
|
);
|
|
2594
2651
|
return {
|
|
2595
2652
|
cause: errorResult.cause,
|
|
2596
2653
|
data: void 0,
|
|
2597
2654
|
error: errorResult.error,
|
|
2598
2655
|
status: errorResult.status,
|
|
2599
|
-
success: false
|
|
2656
|
+
success: false,
|
|
2657
|
+
url: errorResult.url
|
|
2600
2658
|
};
|
|
2601
2659
|
}
|
|
2602
2660
|
const data = await this.#handleQueryResponseData(
|
|
@@ -2697,6 +2755,48 @@ var SocketSdk = class {
|
|
|
2697
2755
|
return await this.#handleApiError(e);
|
|
2698
2756
|
}
|
|
2699
2757
|
}
|
|
2758
|
+
/**
|
|
2759
|
+
* Get GitHub-flavored markdown comments for a diff scan.
|
|
2760
|
+
* Returns dependency overview and alert comments suitable for pull requests.
|
|
2761
|
+
*
|
|
2762
|
+
* @param orgSlug - Organization identifier
|
|
2763
|
+
* @param diffScanId - Diff scan identifier
|
|
2764
|
+
* @param options - Optional query parameters
|
|
2765
|
+
* @param options.github_installation_id - GitHub installation ID for settings
|
|
2766
|
+
* @returns Diff scan metadata with formatted markdown comments
|
|
2767
|
+
*
|
|
2768
|
+
* @example
|
|
2769
|
+
* ```typescript
|
|
2770
|
+
* const result = await sdk.getDiffScanGfm('my-org', 'diff-scan-id')
|
|
2771
|
+
*
|
|
2772
|
+
* if (result.success) {
|
|
2773
|
+
* console.log(result.data.dependency_overview_comment)
|
|
2774
|
+
* console.log(result.data.dependency_alert_comment)
|
|
2775
|
+
* }
|
|
2776
|
+
* ```
|
|
2777
|
+
*
|
|
2778
|
+
* @see https://docs.socket.dev/reference/getdiffscangfm
|
|
2779
|
+
* @apiEndpoint GET /orgs/{org_slug}/diff-scans/{diff_scan_id}/gfm
|
|
2780
|
+
* @quota 0 units
|
|
2781
|
+
* @scopes diff-scans:list
|
|
2782
|
+
* @throws {Error} When server returns 5xx status codes
|
|
2783
|
+
*/
|
|
2784
|
+
async getDiffScanGfm(orgSlug, diffScanId, options) {
|
|
2785
|
+
try {
|
|
2786
|
+
const data = await this.#executeWithRetry(
|
|
2787
|
+
async () => await getResponseJson(
|
|
2788
|
+
await createGetRequest(
|
|
2789
|
+
this.#baseUrl,
|
|
2790
|
+
`orgs/${encodeURIComponent(orgSlug)}/diff-scans/${encodeURIComponent(diffScanId)}/gfm${options ? `?${queryToSearchParams(options)}` : ""}`,
|
|
2791
|
+
{ ...this.#reqOptions, hooks: this.#hooks }
|
|
2792
|
+
)
|
|
2793
|
+
)
|
|
2794
|
+
);
|
|
2795
|
+
return this.#handleApiSuccess(data);
|
|
2796
|
+
} catch (e) {
|
|
2797
|
+
return await this.#handleApiError(e);
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2700
2800
|
/**
|
|
2701
2801
|
* Retrieve the enabled entitlements for an organization.
|
|
2702
2802
|
*
|
|
@@ -2756,7 +2856,7 @@ var SocketSdk = class {
|
|
|
2756
2856
|
*
|
|
2757
2857
|
* @see https://docs.socket.dev/reference/getorgfullscan
|
|
2758
2858
|
* @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
|
|
2759
|
-
* @quota
|
|
2859
|
+
* @quota 0 units
|
|
2760
2860
|
* @scopes full-scans:list
|
|
2761
2861
|
* @throws {Error} When server returns 5xx status codes
|
|
2762
2862
|
*/
|
|
@@ -2811,7 +2911,7 @@ var SocketSdk = class {
|
|
|
2811
2911
|
*
|
|
2812
2912
|
* @see https://docs.socket.dev/reference/getorgfullscanmetadata
|
|
2813
2913
|
* @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}/metadata
|
|
2814
|
-
* @quota
|
|
2914
|
+
* @quota 0 units
|
|
2815
2915
|
* @scopes full-scans:list
|
|
2816
2916
|
* @throws {Error} When server returns 5xx status codes
|
|
2817
2917
|
*/
|
|
@@ -3198,7 +3298,7 @@ var SocketSdk = class {
|
|
|
3198
3298
|
*
|
|
3199
3299
|
* @see https://docs.socket.dev/reference/getorgrepo
|
|
3200
3300
|
* @apiEndpoint GET /orgs/{org_slug}/repos/{repo_slug}
|
|
3201
|
-
* @quota
|
|
3301
|
+
* @quota 0 units
|
|
3202
3302
|
* @scopes repo:read
|
|
3203
3303
|
* @throws {Error} When server returns 5xx status codes
|
|
3204
3304
|
*/
|
|
@@ -3260,7 +3360,7 @@ var SocketSdk = class {
|
|
|
3260
3360
|
*
|
|
3261
3361
|
* @see https://docs.socket.dev/reference/getorgrepolabel
|
|
3262
3362
|
* @apiEndpoint GET /orgs/{org_slug}/repos/labels/{label_id}
|
|
3263
|
-
* @quota
|
|
3363
|
+
* @quota 0 units
|
|
3264
3364
|
* @scopes repo-label:list
|
|
3265
3365
|
* @throws {Error} When server returns 5xx status codes
|
|
3266
3366
|
*/
|
|
@@ -3315,10 +3415,57 @@ var SocketSdk = class {
|
|
|
3315
3415
|
return await this.#handleApiError(e);
|
|
3316
3416
|
}
|
|
3317
3417
|
}
|
|
3418
|
+
/**
|
|
3419
|
+
* Get list of supported file types for full scan generation.
|
|
3420
|
+
* Returns glob patterns for supported manifest files, lockfiles, and configuration formats.
|
|
3421
|
+
*
|
|
3422
|
+
* Files whose names match the patterns returned by this endpoint can be uploaded
|
|
3423
|
+
* for report generation. Examples include `package.json`, `package-lock.json`, and `yarn.lock`.
|
|
3424
|
+
*
|
|
3425
|
+
* @param orgSlug - Organization identifier
|
|
3426
|
+
* @returns Nested object with environment and file type patterns
|
|
3427
|
+
*
|
|
3428
|
+
* @example
|
|
3429
|
+
* ```typescript
|
|
3430
|
+
* const result = await sdk.getSupportedFiles('my-org')
|
|
3431
|
+
*
|
|
3432
|
+
* if (result.success) {
|
|
3433
|
+
* console.log('NPM patterns:', result.data.NPM)
|
|
3434
|
+
* console.log('PyPI patterns:', result.data.PyPI)
|
|
3435
|
+
* }
|
|
3436
|
+
* ```
|
|
3437
|
+
*
|
|
3438
|
+
* @see https://docs.socket.dev/reference/getsupportedfiles
|
|
3439
|
+
* @apiEndpoint GET /orgs/{org_slug}/supported-files
|
|
3440
|
+
* @quota 0 units
|
|
3441
|
+
* @scopes No scopes required, but authentication is required
|
|
3442
|
+
* @throws {Error} When server returns 5xx status codes
|
|
3443
|
+
*/
|
|
3444
|
+
async getSupportedFiles(orgSlug) {
|
|
3445
|
+
try {
|
|
3446
|
+
const data = await this.#executeWithRetry(
|
|
3447
|
+
async () => await getResponseJson(
|
|
3448
|
+
await createGetRequest(
|
|
3449
|
+
this.#baseUrl,
|
|
3450
|
+
`orgs/${encodeURIComponent(orgSlug)}/supported-files`,
|
|
3451
|
+
{
|
|
3452
|
+
...this.#reqOptions,
|
|
3453
|
+
hooks: this.#hooks
|
|
3454
|
+
}
|
|
3455
|
+
)
|
|
3456
|
+
)
|
|
3457
|
+
);
|
|
3458
|
+
return this.#handleApiSuccess(data);
|
|
3459
|
+
} catch (e) {
|
|
3460
|
+
return await this.#handleApiError(e);
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3318
3463
|
/**
|
|
3319
3464
|
* Get list of file types and formats supported for scanning.
|
|
3320
3465
|
* Returns supported manifest files, lockfiles, and configuration formats.
|
|
3321
3466
|
*
|
|
3467
|
+
* @deprecated Use getSupportedFiles() instead. This endpoint has been deprecated
|
|
3468
|
+
* since 2023-01-15 and now uses the /report/supported endpoint.
|
|
3322
3469
|
* @throws {Error} When server returns 5xx status codes
|
|
3323
3470
|
*/
|
|
3324
3471
|
async getSupportedScanFiles() {
|
|
@@ -3363,7 +3510,7 @@ var SocketSdk = class {
|
|
|
3363
3510
|
*
|
|
3364
3511
|
* @see https://docs.socket.dev/reference/getorgfullscanlist
|
|
3365
3512
|
* @apiEndpoint GET /orgs/{org_slug}/full-scans
|
|
3366
|
-
* @quota
|
|
3513
|
+
* @quota 0 units
|
|
3367
3514
|
* @scopes full-scans:list
|
|
3368
3515
|
* @throws {Error} When server returns 5xx status codes
|
|
3369
3516
|
*/
|
|
@@ -3416,7 +3563,7 @@ var SocketSdk = class {
|
|
|
3416
3563
|
*
|
|
3417
3564
|
* @see https://docs.socket.dev/reference/getorganizations
|
|
3418
3565
|
* @apiEndpoint GET /organizations
|
|
3419
|
-
* @quota
|
|
3566
|
+
* @quota 0 units
|
|
3420
3567
|
* @throws {Error} When server returns 5xx status codes
|
|
3421
3568
|
*/
|
|
3422
3569
|
async listOrganizations() {
|
|
@@ -3497,7 +3644,7 @@ var SocketSdk = class {
|
|
|
3497
3644
|
*
|
|
3498
3645
|
* @see https://docs.socket.dev/reference/getorgrepolist
|
|
3499
3646
|
* @apiEndpoint GET /orgs/{org_slug}/repos
|
|
3500
|
-
* @quota
|
|
3647
|
+
* @quota 0 units
|
|
3501
3648
|
* @scopes repo:list
|
|
3502
3649
|
* @throws {Error} When server returns 5xx status codes
|
|
3503
3650
|
*/
|
|
@@ -3553,7 +3700,7 @@ var SocketSdk = class {
|
|
|
3553
3700
|
*
|
|
3554
3701
|
* @see https://docs.socket.dev/reference/getorgrepolabellist
|
|
3555
3702
|
* @apiEndpoint GET /orgs/{org_slug}/repos/labels
|
|
3556
|
-
* @quota
|
|
3703
|
+
* @quota 0 units
|
|
3557
3704
|
* @scopes repo-label:list
|
|
3558
3705
|
* @throws {Error} When server returns 5xx status codes
|
|
3559
3706
|
*/
|
|
@@ -3769,7 +3916,7 @@ var SocketSdk = class {
|
|
|
3769
3916
|
*
|
|
3770
3917
|
* @see https://docs.socket.dev/reference/rescanorgfullscan
|
|
3771
3918
|
* @apiEndpoint POST /orgs/{org_slug}/full-scans/{full_scan_id}/rescan
|
|
3772
|
-
* @quota
|
|
3919
|
+
* @quota 0 units
|
|
3773
3920
|
* @scopes full-scans:create
|
|
3774
3921
|
* @throws {Error} When server returns 5xx status codes
|
|
3775
3922
|
*/
|
|
@@ -3903,7 +4050,7 @@ var SocketSdk = class {
|
|
|
3903
4050
|
*
|
|
3904
4051
|
* @see https://docs.socket.dev/reference/getorgfullscan
|
|
3905
4052
|
* @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}
|
|
3906
|
-
* @quota
|
|
4053
|
+
* @quota 0 units
|
|
3907
4054
|
* @scopes full-scans:list
|
|
3908
4055
|
* @throws {Error} When server returns 5xx status codes
|
|
3909
4056
|
*/
|
|
@@ -3912,51 +4059,59 @@ var SocketSdk = class {
|
|
|
3912
4059
|
__proto__: null,
|
|
3913
4060
|
...options
|
|
3914
4061
|
};
|
|
4062
|
+
const url = `${this.#baseUrl}orgs/${encodeURIComponent(orgSlug)}/full-scans/${encodeURIComponent(scanId)}`;
|
|
3915
4063
|
try {
|
|
3916
|
-
const req = getHttpModule(this.#baseUrl).request(
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
...this.#reqOptions
|
|
3921
|
-
}
|
|
3922
|
-
).end();
|
|
4064
|
+
const req = getHttpModule(this.#baseUrl).request(url, {
|
|
4065
|
+
method: "GET",
|
|
4066
|
+
...this.#reqOptions
|
|
4067
|
+
}).end();
|
|
3923
4068
|
const res = await getResponse(req);
|
|
3924
4069
|
if (!isResponseOk(res)) {
|
|
3925
|
-
throw new ResponseError(res);
|
|
4070
|
+
throw new ResponseError(res, "", url);
|
|
3926
4071
|
}
|
|
3927
4072
|
if (typeof output === "string") {
|
|
3928
4073
|
const writeStream = (0, import_node_fs3.createWriteStream)(output);
|
|
3929
4074
|
let bytesWritten = 0;
|
|
3930
4075
|
res.on("data", (chunk) => {
|
|
3931
|
-
bytesWritten
|
|
3932
|
-
|
|
3933
|
-
res.destroy();
|
|
3934
|
-
writeStream.destroy();
|
|
3935
|
-
throw new Error(
|
|
4076
|
+
if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
|
|
4077
|
+
const error = new Error(
|
|
3936
4078
|
`Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
|
|
3937
4079
|
);
|
|
4080
|
+
res.destroy(error);
|
|
4081
|
+
writeStream.destroy(error);
|
|
4082
|
+
return;
|
|
3938
4083
|
}
|
|
4084
|
+
bytesWritten += chunk.length;
|
|
3939
4085
|
});
|
|
3940
4086
|
res.pipe(writeStream);
|
|
3941
4087
|
writeStream.on("error", (error) => {
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
});
|
|
4088
|
+
res.destroy();
|
|
4089
|
+
writeStream.destroy(error);
|
|
3945
4090
|
});
|
|
4091
|
+
await import_node_events.default.once(writeStream, "finish");
|
|
3946
4092
|
} else if (output === true) {
|
|
3947
4093
|
let bytesWritten = 0;
|
|
3948
4094
|
res.on("data", (chunk) => {
|
|
3949
|
-
bytesWritten
|
|
3950
|
-
|
|
3951
|
-
res.destroy();
|
|
3952
|
-
throw new Error(
|
|
4095
|
+
if (bytesWritten + chunk.length > MAX_STREAM_SIZE) {
|
|
4096
|
+
const error = new Error(
|
|
3953
4097
|
`Response exceeds maximum stream size of ${MAX_STREAM_SIZE} bytes`
|
|
3954
4098
|
);
|
|
4099
|
+
res.destroy(error);
|
|
4100
|
+
return;
|
|
3955
4101
|
}
|
|
4102
|
+
bytesWritten += chunk.length;
|
|
3956
4103
|
});
|
|
4104
|
+
const stdoutErrorHandler = (_error) => {
|
|
4105
|
+
res.destroy();
|
|
4106
|
+
process.stdout.removeListener("error", stdoutErrorHandler);
|
|
4107
|
+
};
|
|
4108
|
+
process.stdout.on("error", stdoutErrorHandler);
|
|
3957
4109
|
res.pipe(process.stdout);
|
|
3958
|
-
|
|
3959
|
-
|
|
4110
|
+
res.on("end", () => {
|
|
4111
|
+
process.stdout.removeListener("error", stdoutErrorHandler);
|
|
4112
|
+
});
|
|
4113
|
+
res.on("error", () => {
|
|
4114
|
+
process.stdout.removeListener("error", stdoutErrorHandler);
|
|
3960
4115
|
});
|
|
3961
4116
|
}
|
|
3962
4117
|
return this.#handleApiSuccess(res);
|
|
@@ -3973,15 +4128,16 @@ var SocketSdk = class {
|
|
|
3973
4128
|
* Note: This method returns a ReadableStream for processing large datasets.
|
|
3974
4129
|
*/
|
|
3975
4130
|
async streamPatchesFromScan(orgSlug, scanId) {
|
|
4131
|
+
const urlPath = `orgs/${encodeURIComponent(orgSlug)}/patches/scan?scan_id=${encodeURIComponent(scanId)}`;
|
|
4132
|
+
const url = `${this.#baseUrl}${urlPath}`;
|
|
3976
4133
|
const response = await this.#executeWithRetry(
|
|
3977
|
-
async () => await createGetRequest(
|
|
3978
|
-
this.#
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
)
|
|
4134
|
+
async () => await createGetRequest(this.#baseUrl, urlPath, {
|
|
4135
|
+
...this.#reqOptions,
|
|
4136
|
+
hooks: this.#hooks
|
|
4137
|
+
})
|
|
3982
4138
|
);
|
|
3983
4139
|
if (!isResponseOk(response)) {
|
|
3984
|
-
throw new ResponseError(response, "GET Request failed");
|
|
4140
|
+
throw new ResponseError(response, "GET Request failed", url);
|
|
3985
4141
|
}
|
|
3986
4142
|
const rli = import_node_readline.default.createInterface({
|
|
3987
4143
|
input: response,
|
|
@@ -4005,8 +4161,13 @@ var SocketSdk = class {
|
|
|
4005
4161
|
} catch (error) {
|
|
4006
4162
|
controller.error(error);
|
|
4007
4163
|
} finally {
|
|
4164
|
+
rli.close();
|
|
4008
4165
|
controller.close();
|
|
4009
4166
|
}
|
|
4167
|
+
},
|
|
4168
|
+
/* c8 ignore next 3 - Stream cancellation cleanup, difficult to test reliably. */
|
|
4169
|
+
cancel() {
|
|
4170
|
+
rli.close();
|
|
4010
4171
|
}
|
|
4011
4172
|
});
|
|
4012
4173
|
}
|
|
@@ -4162,7 +4323,7 @@ var SocketSdk = class {
|
|
|
4162
4323
|
*
|
|
4163
4324
|
* @see https://docs.socket.dev/reference/updateorgrepo
|
|
4164
4325
|
* @apiEndpoint POST /orgs/{org_slug}/repos/{repo_slug}
|
|
4165
|
-
* @quota
|
|
4326
|
+
* @quota 0 units
|
|
4166
4327
|
* @scopes repo:write
|
|
4167
4328
|
* @throws {Error} When server returns 5xx status codes
|
|
4168
4329
|
*/
|
|
@@ -4224,7 +4385,7 @@ var SocketSdk = class {
|
|
|
4224
4385
|
*
|
|
4225
4386
|
* @see https://docs.socket.dev/reference/updateorgrepolabel
|
|
4226
4387
|
* @apiEndpoint PUT /orgs/{org_slug}/repos/labels/{label_id}
|
|
4227
|
-
* @quota
|
|
4388
|
+
* @quota 0 units
|
|
4228
4389
|
* @scopes repo-label:update
|
|
4229
4390
|
* @throws {Error} When server returns 5xx status codes
|
|
4230
4391
|
*/
|