@socketsecurity/sdk 1.9.1 → 1.10.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 +29 -0
- package/README.md +29 -5
- package/dist/constants.js +0 -3
- package/dist/file-upload.js +2 -2
- package/dist/http-client.d.ts +37 -2
- package/dist/http-client.js +86 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -13
- package/dist/promise-queue.d.ts +35 -0
- package/dist/promise-queue.js +91 -0
- package/dist/quota-utils.d.ts +20 -20
- package/dist/quota-utils.js +63 -60
- package/dist/socket-sdk-class.d.ts +148 -148
- package/dist/socket-sdk-class.js +574 -510
- package/dist/types.d.ts +32 -10
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -2
- package/package.json +13 -12
- package/requirements.json +232 -0
- package/types/api.d.ts +871 -767
package/dist/types.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export type EntitlementsResponse = {
|
|
|
19
19
|
items: Entitlement[];
|
|
20
20
|
};
|
|
21
21
|
export type PatchFile = {
|
|
22
|
-
afterHash?: string;
|
|
23
|
-
beforeHash?: string;
|
|
22
|
+
afterHash?: string | undefined;
|
|
23
|
+
beforeHash?: string | undefined;
|
|
24
24
|
socketBlob?: string | null;
|
|
25
25
|
};
|
|
26
26
|
export type Vulnerability = {
|
|
@@ -65,7 +65,7 @@ export type CompactSocketArtifact = Remap<Omit<SocketArtifact, 'alerts' | 'alert
|
|
|
65
65
|
}>;
|
|
66
66
|
export type CustomResponseType = 'response' | 'text' | 'json';
|
|
67
67
|
export type GetOptions = {
|
|
68
|
-
responseType?: CustomResponseType;
|
|
68
|
+
responseType?: CustomResponseType | undefined;
|
|
69
69
|
throws?: boolean | undefined;
|
|
70
70
|
};
|
|
71
71
|
export type GotOptions = {
|
|
@@ -73,19 +73,21 @@ export type GotOptions = {
|
|
|
73
73
|
http?: HttpAgent | undefined;
|
|
74
74
|
https?: HttpsAgent | undefined;
|
|
75
75
|
};
|
|
76
|
-
export type QueryParams = Record<string,
|
|
76
|
+
export type QueryParams = Record<string, unknown>;
|
|
77
77
|
export type HeadersRecord = Record<string, string | string[]> | undefined;
|
|
78
|
+
export type SocketMetricSchema = components['schemas']['SocketMetricSchema'];
|
|
79
|
+
export type SocketId = components['schemas']['SocketId'];
|
|
78
80
|
export type SocketArtifactWithExtras = SocketArtifact & {
|
|
79
|
-
scorecards?:
|
|
80
|
-
supplyChainRisk?:
|
|
81
|
-
topLevelAncestors?:
|
|
81
|
+
scorecards?: unknown | undefined;
|
|
82
|
+
supplyChainRisk?: SocketMetricSchema | undefined;
|
|
83
|
+
topLevelAncestors?: SocketId[] | undefined;
|
|
82
84
|
};
|
|
83
85
|
export type RequestOptions = ((HttpsRequestOptions & {
|
|
84
|
-
headers?: HeadersRecord;
|
|
86
|
+
headers?: HeadersRecord | undefined;
|
|
85
87
|
}) | (HttpRequestOptions & {
|
|
86
|
-
headers?: HeadersRecord;
|
|
88
|
+
headers?: HeadersRecord | undefined;
|
|
87
89
|
}) | (ClientSessionRequestOptions & {
|
|
88
|
-
headers?: HeadersRecord;
|
|
90
|
+
headers?: HeadersRecord | undefined;
|
|
89
91
|
})) & {
|
|
90
92
|
timeout?: number | undefined;
|
|
91
93
|
};
|
|
@@ -130,6 +132,8 @@ export type SocketSdkGenericResult<T> = {
|
|
|
130
132
|
export interface SocketSdkOptions {
|
|
131
133
|
agent?: Agent | GotOptions | undefined;
|
|
132
134
|
baseUrl?: string | undefined;
|
|
135
|
+
retries?: number | undefined;
|
|
136
|
+
retryDelay?: number | undefined;
|
|
133
137
|
timeout?: number | undefined;
|
|
134
138
|
userAgent?: string | undefined;
|
|
135
139
|
}
|
|
@@ -157,3 +161,21 @@ export type BatchPackageStreamOptions = {
|
|
|
157
161
|
concurrencyLimit?: number | undefined;
|
|
158
162
|
queryParams?: QueryParams | undefined;
|
|
159
163
|
};
|
|
164
|
+
export type CreateDependenciesSnapshotOptions = {
|
|
165
|
+
pathsRelativeTo?: string | undefined;
|
|
166
|
+
queryParams?: QueryParams | undefined;
|
|
167
|
+
};
|
|
168
|
+
export type CreateOrgFullScanOptions = {
|
|
169
|
+
pathsRelativeTo?: string | undefined;
|
|
170
|
+
queryParams?: QueryParams | undefined;
|
|
171
|
+
};
|
|
172
|
+
export type CreateScanFromFilepathsOptions = {
|
|
173
|
+
issueRules?: Record<string, boolean> | undefined;
|
|
174
|
+
pathsRelativeTo?: string | undefined;
|
|
175
|
+
};
|
|
176
|
+
export type StreamOrgFullScanOptions = {
|
|
177
|
+
output?: boolean | string | undefined;
|
|
178
|
+
};
|
|
179
|
+
export type UploadManifestFilesOptions = {
|
|
180
|
+
pathsRelativeTo?: string | undefined;
|
|
181
|
+
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function promiseWithResolvers<T>(): ReturnType<typeof Promise.wit
|
|
|
14
14
|
* Convert query parameters to URLSearchParams with API-compatible key normalization.
|
|
15
15
|
* Transforms camelCase keys to snake_case and filters out empty values.
|
|
16
16
|
*/
|
|
17
|
-
export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string,
|
|
17
|
+
export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams;
|
|
18
18
|
/**
|
|
19
19
|
* Convert relative file paths to absolute paths.
|
|
20
20
|
* Resolves paths relative to specified base directory or current working directory.
|
package/dist/utils.js
CHANGED
|
@@ -47,8 +47,8 @@ function promiseWithResolvers() {
|
|
|
47
47
|
* Transforms camelCase keys to snake_case and filters out empty values.
|
|
48
48
|
*/
|
|
49
49
|
function queryToSearchParams(init) {
|
|
50
|
-
const params = new URLSearchParams(init
|
|
51
|
-
const normalized =
|
|
50
|
+
const params = new URLSearchParams(init);
|
|
51
|
+
const normalized = Object.create(null);
|
|
52
52
|
const entries = params.entries();
|
|
53
53
|
for (const entry of entries) {
|
|
54
54
|
let key = entry[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "SDK for the Socket API client",
|
|
6
6
|
"author": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "pnpm run clean:dist && tsgo --build",
|
|
31
|
+
"build": "pnpm run clean:dist && tsgo --build .config/tsconfig.json",
|
|
32
32
|
"check": "run-p -c --aggregate-output check:*",
|
|
33
|
-
"check:lint": "eslint --report-unused-disable-directives .",
|
|
33
|
+
"check:lint": "eslint --config .config/eslint.config.mjs --report-unused-disable-directives .",
|
|
34
34
|
"check:lint:fix": "pnpm run check:lint -- --fix",
|
|
35
|
-
"check:tsc": "tsgo --noEmit -p tsconfig.check.json",
|
|
35
|
+
"check:tsc": "tsgo --noEmit -p .config/tsconfig.check.json",
|
|
36
36
|
"lint-ci": "pnpm run check:lint",
|
|
37
37
|
"coverage": "run-s coverage:*",
|
|
38
38
|
"coverage:test": "run-s pretest:unit test:unit:coverage",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"clean": "run-s -c clean:*",
|
|
43
43
|
"clean:cache": "del-cli '**/.cache'",
|
|
44
44
|
"clean:coverage": "del-cli '.type-coverage' 'coverage'",
|
|
45
|
-
"clean:dist": "del-cli 'dist' '**/*.tsbuildinfo'",
|
|
45
|
+
"clean:dist": "del-cli 'dist' '**/*.tsbuildinfo' '.config/*.tsbuildinfo'",
|
|
46
46
|
"clean:declarations": "del-cli '*.d.ts' '!api*.d.ts'",
|
|
47
47
|
"clean:node_modules": "del-cli '**/node_modules'",
|
|
48
48
|
"fix": "run-s lint:fix",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"generate-sdk:03-clean-api": "pnpm run fix && pnpm run fix",
|
|
53
53
|
"knip:dependencies": "knip --dependencies",
|
|
54
54
|
"knip:exports": "knip --include exports,duplicates",
|
|
55
|
-
"lint": "oxlint -c=.oxlintrc.json --ignore-path=.oxlintignore --tsconfig
|
|
55
|
+
"lint": "oxlint -c=.config/.oxlintrc.json --ignore-path=.config/.oxlintignore --tsconfig=.config/tsconfig.json .",
|
|
56
56
|
"lint:fix": "run-s -c lint:fix:*",
|
|
57
|
-
"lint:fix:oxlint": "oxlint -c=.oxlintrc.json --ignore-path=.oxlintignore --tsconfig
|
|
57
|
+
"lint:fix:oxlint": "oxlint -c=.config/.oxlintrc.json --ignore-path=.config/.oxlintignore --tsconfig=.config/tsconfig.json --quiet --fix . | dev-null",
|
|
58
58
|
"lint:fix:biome": "biome format --log-level=none --fix . | dev-null",
|
|
59
|
-
"lint:fix:eslint": "eslint --report-unused-disable-directives --fix . | dev-null",
|
|
59
|
+
"lint:fix:eslint": "eslint --config .config/eslint.config.mjs --report-unused-disable-directives --fix . | dev-null",
|
|
60
60
|
"lint-staged": "lint-staged",
|
|
61
61
|
"precommit": "lint-staged",
|
|
62
62
|
"prepare": "husky",
|
|
63
63
|
"prepublishOnly": "echo 'ERROR: Use GitHub Actions workflow for publishing' && exit 1",
|
|
64
|
-
"pretest:unit": "
|
|
64
|
+
"pretest:unit": "pnpm run build",
|
|
65
65
|
"test": "run-s check test:*",
|
|
66
66
|
"test:run": "node scripts/test.mjs",
|
|
67
67
|
"test:unit": "dotenvx -q run -f .env.test -- vitest --run",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"update:socket": "pnpm -r update '@socketsecurity/*' --latest"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@socketsecurity/registry": "1.
|
|
78
|
+
"@socketsecurity/registry": "1.4.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@biomejs/biome": "2.2.4",
|
|
@@ -126,7 +126,8 @@
|
|
|
126
126
|
"files": [
|
|
127
127
|
"dist/**",
|
|
128
128
|
"types/**",
|
|
129
|
-
"CHANGELOG.md"
|
|
129
|
+
"CHANGELOG.md",
|
|
130
|
+
"requirements.json"
|
|
130
131
|
],
|
|
131
132
|
"lint-staged": {
|
|
132
133
|
"*.{cjs,js,json,md,mjs,mts,ts}": [
|
|
@@ -136,7 +137,7 @@
|
|
|
136
137
|
},
|
|
137
138
|
"typeCoverage": {
|
|
138
139
|
"cache": true,
|
|
139
|
-
"atLeast":
|
|
140
|
+
"atLeast": 99.6,
|
|
140
141
|
"ignoreAsAssertion": true,
|
|
141
142
|
"ignoreCatch": true,
|
|
142
143
|
"ignoreEmptyType": true,
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"batchPackageFetch": {
|
|
4
|
+
"quota": 100,
|
|
5
|
+
"permissions": ["packages:list"]
|
|
6
|
+
},
|
|
7
|
+
"batchPackageStream": {
|
|
8
|
+
"quota": 100,
|
|
9
|
+
"permissions": ["packages:list"]
|
|
10
|
+
},
|
|
11
|
+
"createDependenciesSnapshot": {
|
|
12
|
+
"quota": 100,
|
|
13
|
+
"permissions": ["report:write"]
|
|
14
|
+
},
|
|
15
|
+
"createOrgFullScan": {
|
|
16
|
+
"quota": 0,
|
|
17
|
+
"permissions": ["full-scans:create"]
|
|
18
|
+
},
|
|
19
|
+
"createOrgRepo": {
|
|
20
|
+
"quota": 0,
|
|
21
|
+
"permissions": ["repo:create"]
|
|
22
|
+
},
|
|
23
|
+
"createScanFromFilepaths": {
|
|
24
|
+
"quota": 100,
|
|
25
|
+
"permissions": ["report:write"]
|
|
26
|
+
},
|
|
27
|
+
"deleteOrgFullScan": {
|
|
28
|
+
"quota": 0,
|
|
29
|
+
"permissions": ["full-scans:delete"]
|
|
30
|
+
},
|
|
31
|
+
"deleteOrgRepo": {
|
|
32
|
+
"quota": 0,
|
|
33
|
+
"permissions": ["repo:delete"]
|
|
34
|
+
},
|
|
35
|
+
"getAuditLogEvents": {
|
|
36
|
+
"quota": 10,
|
|
37
|
+
"permissions": ["audit-log:list"]
|
|
38
|
+
},
|
|
39
|
+
"getEnabledEntitlements": {
|
|
40
|
+
"quota": 0,
|
|
41
|
+
"permissions": []
|
|
42
|
+
},
|
|
43
|
+
"getEntitlements": {
|
|
44
|
+
"quota": 0,
|
|
45
|
+
"permissions": []
|
|
46
|
+
},
|
|
47
|
+
"getIssuesByNpmPackage": {
|
|
48
|
+
"quota": 10,
|
|
49
|
+
"permissions": []
|
|
50
|
+
},
|
|
51
|
+
"getOrgAnalytics": {
|
|
52
|
+
"quota": 10,
|
|
53
|
+
"permissions": ["analytics:read"]
|
|
54
|
+
},
|
|
55
|
+
"getOrganizations": {
|
|
56
|
+
"quota": 0,
|
|
57
|
+
"permissions": []
|
|
58
|
+
},
|
|
59
|
+
"streamOrgFullScan": {
|
|
60
|
+
"quota": 0,
|
|
61
|
+
"permissions": ["full-scans:list"]
|
|
62
|
+
},
|
|
63
|
+
"streamPatchesFromScan": {
|
|
64
|
+
"quota": 0,
|
|
65
|
+
"permissions": ["patches:list"]
|
|
66
|
+
},
|
|
67
|
+
"getOrgFullScanBuffered": {
|
|
68
|
+
"quota": 0,
|
|
69
|
+
"permissions": ["full-scans:list"]
|
|
70
|
+
},
|
|
71
|
+
"getOrgFullScanList": {
|
|
72
|
+
"quota": 0,
|
|
73
|
+
"permissions": ["full-scans:list"]
|
|
74
|
+
},
|
|
75
|
+
"getOrgFullScanMetadata": {
|
|
76
|
+
"quota": 0,
|
|
77
|
+
"permissions": ["full-scans:list"]
|
|
78
|
+
},
|
|
79
|
+
"getOrgLicensePolicy": {
|
|
80
|
+
"quota": 0,
|
|
81
|
+
"permissions": ["settings:read"]
|
|
82
|
+
},
|
|
83
|
+
"getOrgRepo": {
|
|
84
|
+
"quota": 0,
|
|
85
|
+
"permissions": ["repo:list"]
|
|
86
|
+
},
|
|
87
|
+
"getOrgRepoList": {
|
|
88
|
+
"quota": 0,
|
|
89
|
+
"permissions": ["repo:list"]
|
|
90
|
+
},
|
|
91
|
+
"getOrgSecurityPolicy": {
|
|
92
|
+
"quota": 0,
|
|
93
|
+
"permissions": ["settings:read"]
|
|
94
|
+
},
|
|
95
|
+
"getQuota": {
|
|
96
|
+
"quota": 0,
|
|
97
|
+
"permissions": []
|
|
98
|
+
},
|
|
99
|
+
"getRepoAnalytics": {
|
|
100
|
+
"quota": 10,
|
|
101
|
+
"permissions": ["analytics:read"]
|
|
102
|
+
},
|
|
103
|
+
"getScan": {
|
|
104
|
+
"quota": 0,
|
|
105
|
+
"permissions": ["report:read"]
|
|
106
|
+
},
|
|
107
|
+
"getScanList": {
|
|
108
|
+
"quota": 0,
|
|
109
|
+
"permissions": ["report:read"]
|
|
110
|
+
},
|
|
111
|
+
"getSupportedScanFiles": {
|
|
112
|
+
"quota": 0,
|
|
113
|
+
"permissions": ["report:read"]
|
|
114
|
+
},
|
|
115
|
+
"getScoreByNpmPackage": {
|
|
116
|
+
"quota": 10,
|
|
117
|
+
"permissions": []
|
|
118
|
+
},
|
|
119
|
+
"postSettings": {
|
|
120
|
+
"quota": 0,
|
|
121
|
+
"permissions": []
|
|
122
|
+
},
|
|
123
|
+
"searchDependencies": {
|
|
124
|
+
"quota": 100,
|
|
125
|
+
"permissions": []
|
|
126
|
+
},
|
|
127
|
+
"updateOrgRepo": {
|
|
128
|
+
"quota": 0,
|
|
129
|
+
"permissions": ["repo:update"]
|
|
130
|
+
},
|
|
131
|
+
"uploadManifestFiles": {
|
|
132
|
+
"quota": 100,
|
|
133
|
+
"permissions": ["packages:upload"]
|
|
134
|
+
},
|
|
135
|
+
"viewPatch": {
|
|
136
|
+
"quota": 0,
|
|
137
|
+
"permissions": ["patches:view"]
|
|
138
|
+
},
|
|
139
|
+
"deleteReport": {
|
|
140
|
+
"quota": 0,
|
|
141
|
+
"permissions": ["report:delete"]
|
|
142
|
+
},
|
|
143
|
+
"exportCDX": {
|
|
144
|
+
"quota": 0,
|
|
145
|
+
"permissions": ["report:read"]
|
|
146
|
+
},
|
|
147
|
+
"exportSPDX": {
|
|
148
|
+
"quota": 0,
|
|
149
|
+
"permissions": ["report:read"]
|
|
150
|
+
},
|
|
151
|
+
"getAPITokens": {
|
|
152
|
+
"quota": 10,
|
|
153
|
+
"permissions": ["api-token:list"]
|
|
154
|
+
},
|
|
155
|
+
"postAPIToken": {
|
|
156
|
+
"quota": 10,
|
|
157
|
+
"permissions": ["api-token:create"]
|
|
158
|
+
},
|
|
159
|
+
"postAPITokenUpdate": {
|
|
160
|
+
"quota": 10,
|
|
161
|
+
"permissions": ["api-token:update"]
|
|
162
|
+
},
|
|
163
|
+
"postAPITokensRotate": {
|
|
164
|
+
"quota": 10,
|
|
165
|
+
"permissions": ["api-token:rotate"]
|
|
166
|
+
},
|
|
167
|
+
"postAPITokensRevoke": {
|
|
168
|
+
"quota": 10,
|
|
169
|
+
"permissions": ["api-token:revoke"]
|
|
170
|
+
},
|
|
171
|
+
"updateOrgSecurityPolicy": {
|
|
172
|
+
"quota": 0,
|
|
173
|
+
"permissions": ["settings:write"]
|
|
174
|
+
},
|
|
175
|
+
"updateOrgLicensePolicy": {
|
|
176
|
+
"quota": 0,
|
|
177
|
+
"permissions": ["settings:write"]
|
|
178
|
+
},
|
|
179
|
+
"getOrgTriage": {
|
|
180
|
+
"quota": 0,
|
|
181
|
+
"permissions": ["triage:alerts-list"]
|
|
182
|
+
},
|
|
183
|
+
"updateOrgAlertTriage": {
|
|
184
|
+
"quota": 0,
|
|
185
|
+
"permissions": ["triage:alerts-update"]
|
|
186
|
+
},
|
|
187
|
+
"getOrgRepoLabelList": {
|
|
188
|
+
"quota": 0,
|
|
189
|
+
"permissions": ["repo-label:list"]
|
|
190
|
+
},
|
|
191
|
+
"createOrgRepoLabel": {
|
|
192
|
+
"quota": 0,
|
|
193
|
+
"permissions": ["repo-label:create"]
|
|
194
|
+
},
|
|
195
|
+
"getOrgRepoLabel": {
|
|
196
|
+
"quota": 0,
|
|
197
|
+
"permissions": ["repo-label:list"]
|
|
198
|
+
},
|
|
199
|
+
"updateOrgRepoLabel": {
|
|
200
|
+
"quota": 0,
|
|
201
|
+
"permissions": ["repo-label:update"]
|
|
202
|
+
},
|
|
203
|
+
"deleteOrgRepoLabel": {
|
|
204
|
+
"quota": 0,
|
|
205
|
+
"permissions": ["repo-label:delete"]
|
|
206
|
+
},
|
|
207
|
+
"getDiffScanById": {
|
|
208
|
+
"quota": 0,
|
|
209
|
+
"permissions": ["diff-scans:list"]
|
|
210
|
+
},
|
|
211
|
+
"createOrgDiffScanFromIds": {
|
|
212
|
+
"quota": 0,
|
|
213
|
+
"permissions": ["diff-scans:create"]
|
|
214
|
+
},
|
|
215
|
+
"listOrgDiffScans": {
|
|
216
|
+
"quota": 0,
|
|
217
|
+
"permissions": ["diff-scans:list"]
|
|
218
|
+
},
|
|
219
|
+
"deleteOrgDiffScan": {
|
|
220
|
+
"quota": 0,
|
|
221
|
+
"permissions": ["diff-scans:delete"]
|
|
222
|
+
},
|
|
223
|
+
"getApi": {
|
|
224
|
+
"quota": 0,
|
|
225
|
+
"permissions": []
|
|
226
|
+
},
|
|
227
|
+
"sendApi": {
|
|
228
|
+
"quota": 0,
|
|
229
|
+
"permissions": []
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|