@socketsecurity/sdk 3.1.2 → 3.2.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 +39 -3
- package/README.md +5 -129
- package/dist/constants.d.ts +3 -0
- package/dist/file-upload.d.ts +7 -8
- package/dist/http-client.d.ts +12 -8
- package/dist/index.d.ts +3 -3
- package/dist/index.js +901 -21025
- package/dist/socket-sdk-class.d.ts +237 -1
- package/dist/testing.js +0 -1
- package/dist/types.d.ts +61 -2
- package/dist/utils.d.ts +61 -0
- package/package.json +12 -7
- package/types/api.d.ts +2089 -267
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CreateDependenciesSnapshotOptions, Entitlement, GetOptions, PatchViewResponse, QueryParams, SendOptions, SocketSdkGenericResult, SocketSdkOptions, SocketSdkResult, StreamOrgFullScanOptions, UploadManifestFilesError, UploadManifestFilesOptions, UploadManifestFilesReturnType } from './types';
|
|
1
|
+
import type { ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CreateDependenciesSnapshotOptions, Entitlement, GetOptions, PatchViewResponse, PostOrgTelemetryPayload, PostOrgTelemetryResponse, QueryParams, SendOptions, SocketSdkGenericResult, SocketSdkOptions, SocketSdkResult, StreamOrgFullScanOptions, UploadManifestFilesError, UploadManifestFilesOptions, UploadManifestFilesReturnType } from './types';
|
|
2
2
|
import type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanListResult, FullScanResult, ListFullScansOptions, ListRepositoriesOptions, OrganizationsResult, RepositoriesListResult, RepositoryLabelResult, RepositoryLabelsListResult, RepositoryResult, StrictErrorResult } from './types-strict';
|
|
3
3
|
import type { IncomingMessage } from 'node:http';
|
|
4
4
|
/**
|
|
@@ -140,6 +140,32 @@ export declare class SocketSdk {
|
|
|
140
140
|
* @throws {Error} When server returns 5xx status codes
|
|
141
141
|
*/
|
|
142
142
|
createRepositoryLabel(orgSlug: string, labelData: QueryParams): Promise<RepositoryLabelResult | StrictErrorResult>;
|
|
143
|
+
/**
|
|
144
|
+
* Create a full scan from an archive file (.tar, .tar.gz/.tgz, or .zip).
|
|
145
|
+
* Uploads and scans a compressed archive of project files.
|
|
146
|
+
*
|
|
147
|
+
* @param orgSlug - Organization identifier
|
|
148
|
+
* @param archivePath - Path to the archive file to upload
|
|
149
|
+
* @param options - Scan configuration options including repo, branch, and metadata
|
|
150
|
+
* @returns Created full scan details with scan ID and status
|
|
151
|
+
*
|
|
152
|
+
* @throws {Error} When server returns 5xx status codes or file cannot be read
|
|
153
|
+
*/
|
|
154
|
+
createOrgFullScanFromArchive(orgSlug: string, archivePath: string, options: {
|
|
155
|
+
branch?: string | undefined;
|
|
156
|
+
commit_hash?: string | undefined;
|
|
157
|
+
commit_message?: string | undefined;
|
|
158
|
+
committers?: string | undefined;
|
|
159
|
+
integration_org_slug?: string | undefined;
|
|
160
|
+
integration_type?: 'api' | 'azure' | 'bitbucket' | 'github' | 'gitlab' | 'web' | undefined;
|
|
161
|
+
make_default_branch?: boolean | undefined;
|
|
162
|
+
pull_request?: number | undefined;
|
|
163
|
+
repo: string;
|
|
164
|
+
scan_type?: string | undefined;
|
|
165
|
+
set_as_pending_head?: boolean | undefined;
|
|
166
|
+
tmp?: boolean | undefined;
|
|
167
|
+
workspace?: string | undefined;
|
|
168
|
+
}): Promise<SocketSdkResult<'CreateOrgFullScanArchive'>>;
|
|
143
169
|
/**
|
|
144
170
|
* Delete a diff scan from an organization.
|
|
145
171
|
* Permanently removes diff scan data and results.
|
|
@@ -288,6 +314,59 @@ export declare class SocketSdk {
|
|
|
288
314
|
* @throws {Error} When server returns 5xx status codes
|
|
289
315
|
*/
|
|
290
316
|
getIssuesByNpmPackage(pkgName: string, version: string): Promise<SocketSdkResult<'getIssuesByNPMPackage'>>;
|
|
317
|
+
/**
|
|
318
|
+
* List latest alerts for an organization (Beta).
|
|
319
|
+
* Returns paginated alerts with comprehensive filtering options.
|
|
320
|
+
*
|
|
321
|
+
* @param orgSlug - Organization identifier
|
|
322
|
+
* @param options - Optional query parameters for pagination and filtering
|
|
323
|
+
* @returns Paginated list of alerts with cursor-based pagination
|
|
324
|
+
*
|
|
325
|
+
* @throws {Error} When server returns 5xx status codes
|
|
326
|
+
*/
|
|
327
|
+
getOrgAlertsList(orgSlug: string, options?: {
|
|
328
|
+
'filters.alertAction'?: string | undefined;
|
|
329
|
+
'filters.alertAction.notIn'?: string | undefined;
|
|
330
|
+
'filters.alertCategory'?: string | undefined;
|
|
331
|
+
'filters.alertCategory.notIn'?: string | undefined;
|
|
332
|
+
'filters.alertCveId'?: string | undefined;
|
|
333
|
+
'filters.alertCveId.notIn'?: string | undefined;
|
|
334
|
+
'filters.alertCveTitle'?: string | undefined;
|
|
335
|
+
'filters.alertCveTitle.notIn'?: string | undefined;
|
|
336
|
+
'filters.alertCweId'?: string | undefined;
|
|
337
|
+
'filters.alertCweId.notIn'?: string | undefined;
|
|
338
|
+
'filters.alertCweName'?: string | undefined;
|
|
339
|
+
'filters.alertCweName.notIn'?: string | undefined;
|
|
340
|
+
'filters.alertEPSS'?: string | undefined;
|
|
341
|
+
'filters.alertEPSS.notIn'?: string | undefined;
|
|
342
|
+
'filters.alertFixType'?: string | undefined;
|
|
343
|
+
'filters.alertFixType.notIn'?: string | undefined;
|
|
344
|
+
'filters.alertKEV'?: boolean | undefined;
|
|
345
|
+
'filters.alertKEV.notIn'?: boolean | undefined;
|
|
346
|
+
'filters.alertPriority'?: string | undefined;
|
|
347
|
+
'filters.alertPriority.notIn'?: string | undefined;
|
|
348
|
+
'filters.alertReachabilityType'?: string | undefined;
|
|
349
|
+
'filters.alertReachabilityType.notIn'?: string | undefined;
|
|
350
|
+
'filters.alertSeverity'?: string | undefined;
|
|
351
|
+
'filters.alertSeverity.notIn'?: string | undefined;
|
|
352
|
+
'filters.alertStatus'?: string | undefined;
|
|
353
|
+
'filters.alertStatus.notIn'?: string | undefined;
|
|
354
|
+
'filters.alertType'?: string | undefined;
|
|
355
|
+
'filters.alertType.notIn'?: string | undefined;
|
|
356
|
+
'filters.alertUpdatedAt.eq'?: string | undefined;
|
|
357
|
+
'filters.alertUpdatedAt.gt'?: string | undefined;
|
|
358
|
+
'filters.alertUpdatedAt.gte'?: string | undefined;
|
|
359
|
+
'filters.alertUpdatedAt.lt'?: string | undefined;
|
|
360
|
+
'filters.alertUpdatedAt.lte'?: string | undefined;
|
|
361
|
+
'filters.repoFullName'?: string | undefined;
|
|
362
|
+
'filters.repoFullName.notIn'?: string | undefined;
|
|
363
|
+
'filters.repoLabels'?: string | undefined;
|
|
364
|
+
'filters.repoLabels.notIn'?: string | undefined;
|
|
365
|
+
'filters.repoSlug'?: string | undefined;
|
|
366
|
+
'filters.repoSlug.notIn'?: string | undefined;
|
|
367
|
+
per_page?: number | undefined;
|
|
368
|
+
startAfterCursor?: string | undefined;
|
|
369
|
+
}): Promise<SocketSdkResult<'alertsList'>>;
|
|
291
370
|
/**
|
|
292
371
|
* Get analytics data for organization usage patterns and security metrics.
|
|
293
372
|
* Returns statistical analysis for specified time period.
|
|
@@ -405,6 +484,25 @@ export declare class SocketSdk {
|
|
|
405
484
|
* @throws {Error} When server returns 5xx status codes
|
|
406
485
|
*/
|
|
407
486
|
getFullScanMetadata(orgSlug: string, scanId: string): Promise<FullScanResult | StrictErrorResult>;
|
|
487
|
+
/**
|
|
488
|
+
* Fetch available fixes for vulnerabilities in a repository or scan.
|
|
489
|
+
* Returns fix recommendations including version upgrades and update types.
|
|
490
|
+
*
|
|
491
|
+
* @param orgSlug - Organization identifier
|
|
492
|
+
* @param options - Fix query options including repo_slug or full_scan_id, vulnerability IDs, and preferences
|
|
493
|
+
* @returns Fix details for requested vulnerabilities with upgrade recommendations
|
|
494
|
+
*
|
|
495
|
+
* @throws {Error} When server returns 5xx status codes
|
|
496
|
+
*/
|
|
497
|
+
getOrgFixes(orgSlug: string, options: {
|
|
498
|
+
allow_major_updates: boolean;
|
|
499
|
+
full_scan_id?: string | undefined;
|
|
500
|
+
include_details?: boolean | undefined;
|
|
501
|
+
include_responsible_direct_dependencies?: boolean | undefined;
|
|
502
|
+
minimum_release_age?: string | undefined;
|
|
503
|
+
repo_slug?: string | undefined;
|
|
504
|
+
vulnerability_ids: string;
|
|
505
|
+
}): Promise<SocketSdkResult<'fetch-fixes'>>;
|
|
408
506
|
/**
|
|
409
507
|
* Get organization's license policy configuration.* Returns allowed, restricted, and monitored license types.
|
|
410
508
|
*
|
|
@@ -781,7 +879,145 @@ export declare class SocketSdk {
|
|
|
781
879
|
* const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
|
|
782
880
|
* ```
|
|
783
881
|
*/
|
|
882
|
+
downloadOrgFullScanFilesAsTar(orgSlug: string, fullScanId: string, outputPath: string): Promise<SocketSdkResult<'downloadOrgFullScanFilesAsTar'>>;
|
|
883
|
+
/**
|
|
884
|
+
* Download patch file content from Socket blob storage.
|
|
885
|
+
* Retrieves patched file contents using SSRI hash or hex hash.
|
|
886
|
+
*
|
|
887
|
+
* This is a low-level utility method - you'll typically use this after calling
|
|
888
|
+
* `viewPatch()` to get patch metadata, then download individual patched files.
|
|
889
|
+
*
|
|
890
|
+
* @param hash - The blob hash in SSRI (sha256-base64) or hex format
|
|
891
|
+
* @param options - Optional configuration
|
|
892
|
+
* @param options.baseUrl - Override blob store URL (for testing)
|
|
893
|
+
* @returns Promise<string> - The patch file content as UTF-8 string
|
|
894
|
+
* @throws Error if blob not found (404) or download fails
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```typescript
|
|
898
|
+
* const sdk = new SocketSdk('your-api-token')
|
|
899
|
+
* // First get patch metadata
|
|
900
|
+
* const patch = await sdk.viewPatch('my-org', 'patch-uuid')
|
|
901
|
+
* // Then download the actual patched file
|
|
902
|
+
* const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
784
905
|
downloadPatch(hash: string, options?: {
|
|
785
906
|
baseUrl?: string;
|
|
786
907
|
}): Promise<string>;
|
|
908
|
+
/**
|
|
909
|
+
* Update organization's telemetry configuration.
|
|
910
|
+
* Enables or disables telemetry for the organization.
|
|
911
|
+
*
|
|
912
|
+
* @param orgSlug - Organization identifier
|
|
913
|
+
* @param telemetryData - Telemetry configuration with enabled flag
|
|
914
|
+
* @returns Updated telemetry configuration
|
|
915
|
+
*
|
|
916
|
+
* @throws {Error} When server returns 5xx status codes
|
|
917
|
+
*/
|
|
918
|
+
updateOrgTelemetryConfig(orgSlug: string, telemetryData: {
|
|
919
|
+
enabled?: boolean | undefined;
|
|
920
|
+
}): Promise<SocketSdkResult<'updateOrgTelemetryConfig'>>;
|
|
921
|
+
/**
|
|
922
|
+
* Get organization's telemetry configuration.
|
|
923
|
+
* Returns whether telemetry is enabled for the organization.
|
|
924
|
+
*
|
|
925
|
+
* @param orgSlug - Organization identifier
|
|
926
|
+
* @returns Telemetry configuration with enabled status
|
|
927
|
+
*
|
|
928
|
+
* @throws {Error} When server returns 5xx status codes
|
|
929
|
+
*/
|
|
930
|
+
getOrgTelemetryConfig(orgSlug: string): Promise<SocketSdkResult<'getOrgTelemetryConfig'>>;
|
|
931
|
+
/**
|
|
932
|
+
* Post telemetry data for an organization.
|
|
933
|
+
* Sends telemetry events and analytics data for monitoring and analysis.
|
|
934
|
+
*
|
|
935
|
+
* @param orgSlug - Organization identifier
|
|
936
|
+
* @param telemetryData - Telemetry payload containing events and metrics
|
|
937
|
+
* @returns Empty object on successful submission
|
|
938
|
+
*
|
|
939
|
+
* @throws {Error} When server returns 5xx status codes
|
|
940
|
+
*/
|
|
941
|
+
postOrgTelemetry(orgSlug: string, telemetryData: PostOrgTelemetryPayload): Promise<SocketSdkGenericResult<PostOrgTelemetryResponse>>;
|
|
942
|
+
/**
|
|
943
|
+
* Create a new webhook for an organization.
|
|
944
|
+
* Webhooks allow you to receive HTTP POST notifications when specific events occur.
|
|
945
|
+
*
|
|
946
|
+
* @param orgSlug - Organization identifier
|
|
947
|
+
* @param webhookData - Webhook configuration including name, URL, secret, and events
|
|
948
|
+
* @returns Created webhook details including webhook ID
|
|
949
|
+
*
|
|
950
|
+
* @throws {Error} When server returns 5xx status codes
|
|
951
|
+
*/
|
|
952
|
+
createOrgWebhook(orgSlug: string, webhookData: {
|
|
953
|
+
description?: null | string | undefined;
|
|
954
|
+
events: string[];
|
|
955
|
+
filters?: {
|
|
956
|
+
repositoryIds: null | string[];
|
|
957
|
+
} | null | undefined;
|
|
958
|
+
headers?: null | Record<string, unknown> | undefined;
|
|
959
|
+
name: string;
|
|
960
|
+
secret: string;
|
|
961
|
+
url: string;
|
|
962
|
+
}): Promise<SocketSdkResult<'createOrgWebhook'>>;
|
|
963
|
+
/**
|
|
964
|
+
* Delete a webhook from an organization.
|
|
965
|
+
* This will stop all future webhook deliveries to the webhook URL.
|
|
966
|
+
*
|
|
967
|
+
* @param orgSlug - Organization identifier
|
|
968
|
+
* @param webhookId - Webhook ID to delete
|
|
969
|
+
* @returns Success status
|
|
970
|
+
*
|
|
971
|
+
* @throws {Error} When server returns 5xx status codes
|
|
972
|
+
*/
|
|
973
|
+
deleteOrgWebhook(orgSlug: string, webhookId: string): Promise<SocketSdkResult<'deleteOrgWebhook'>>;
|
|
974
|
+
/**
|
|
975
|
+
* Get details of a specific webhook.
|
|
976
|
+
* Returns webhook configuration including events, URL, and filters.
|
|
977
|
+
*
|
|
978
|
+
* @param orgSlug - Organization identifier
|
|
979
|
+
* @param webhookId - Webhook ID to retrieve
|
|
980
|
+
* @returns Webhook details
|
|
981
|
+
*
|
|
982
|
+
* @throws {Error} When server returns 5xx status codes
|
|
983
|
+
*/
|
|
984
|
+
getOrgWebhook(orgSlug: string, webhookId: string): Promise<SocketSdkResult<'getOrgWebhook'>>;
|
|
985
|
+
/**
|
|
986
|
+
* List all webhooks for an organization.
|
|
987
|
+
* Supports pagination and sorting options.
|
|
988
|
+
*
|
|
989
|
+
* @param orgSlug - Organization identifier
|
|
990
|
+
* @param options - Optional query parameters for pagination and sorting
|
|
991
|
+
* @returns List of webhooks with pagination info
|
|
992
|
+
*
|
|
993
|
+
* @throws {Error} When server returns 5xx status codes
|
|
994
|
+
*/
|
|
995
|
+
getOrgWebhooksList(orgSlug: string, options?: {
|
|
996
|
+
direction?: string | undefined;
|
|
997
|
+
page?: number | undefined;
|
|
998
|
+
per_page?: number | undefined;
|
|
999
|
+
sort?: string | undefined;
|
|
1000
|
+
}): Promise<SocketSdkResult<'getOrgWebhooksList'>>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Update an existing webhook's configuration.
|
|
1003
|
+
* All fields are optional - only provided fields will be updated.
|
|
1004
|
+
*
|
|
1005
|
+
* @param orgSlug - Organization identifier
|
|
1006
|
+
* @param webhookId - Webhook ID to update
|
|
1007
|
+
* @param webhookData - Updated webhook configuration
|
|
1008
|
+
* @returns Updated webhook details
|
|
1009
|
+
*
|
|
1010
|
+
* @throws {Error} When server returns 5xx status codes
|
|
1011
|
+
*/
|
|
1012
|
+
updateOrgWebhook(orgSlug: string, webhookId: string, webhookData: {
|
|
1013
|
+
description?: null | string | undefined;
|
|
1014
|
+
events?: string[] | undefined;
|
|
1015
|
+
filters?: {
|
|
1016
|
+
repositoryIds: null | string[];
|
|
1017
|
+
} | null | undefined;
|
|
1018
|
+
headers?: null | Record<string, unknown> | undefined;
|
|
1019
|
+
name?: string | undefined;
|
|
1020
|
+
secret?: null | string | undefined;
|
|
1021
|
+
url?: string | undefined;
|
|
1022
|
+
}): Promise<SocketSdkResult<'updateOrgWebhook'>>;
|
|
787
1023
|
}
|
package/dist/testing.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -59,6 +59,21 @@ export type ArtifactPatches = {
|
|
|
59
59
|
patches: PatchRecord[];
|
|
60
60
|
};
|
|
61
61
|
export type Agent = HttpsAgent | HttpAgent | ClientHttp2Session;
|
|
62
|
+
export interface RequestInfo {
|
|
63
|
+
method: string;
|
|
64
|
+
url: string;
|
|
65
|
+
headers?: Record<string, string> | undefined;
|
|
66
|
+
timeout?: number | undefined;
|
|
67
|
+
}
|
|
68
|
+
export interface ResponseInfo {
|
|
69
|
+
method: string;
|
|
70
|
+
url: string;
|
|
71
|
+
duration: number;
|
|
72
|
+
status?: number | undefined;
|
|
73
|
+
statusText?: string | undefined;
|
|
74
|
+
headers?: Record<string, string> | undefined;
|
|
75
|
+
error?: Error | undefined;
|
|
76
|
+
}
|
|
62
77
|
export type CompactSocketArtifactAlert = Remap<Omit<SocketArtifactAlert, 'actionSource' | 'category' | 'end' | 'file' | 'start'>>;
|
|
63
78
|
export type CompactSocketArtifact = Remap<Omit<SocketArtifact, 'alerts' | 'alertKeysToReachabilitySummaries' | 'alertKeysToReachabilityTypes' | 'artifact' | 'batchIndex' | 'dead' | 'dependencies' | 'dev' | 'direct' | 'inputPurl' | 'manifestFiles' | 'score' | 'size' | 'topLevelAncestors'> & {
|
|
64
79
|
alerts: CompactSocketArtifactAlert[];
|
|
@@ -91,6 +106,12 @@ export type RequestOptions = ((HttpsRequestOptions & {
|
|
|
91
106
|
})) & {
|
|
92
107
|
timeout?: number | undefined;
|
|
93
108
|
};
|
|
109
|
+
export type RequestOptionsWithHooks = RequestOptions & {
|
|
110
|
+
hooks?: {
|
|
111
|
+
onRequest?: (info: RequestInfo) => void;
|
|
112
|
+
onResponse?: (info: ResponseInfo) => void;
|
|
113
|
+
} | undefined;
|
|
114
|
+
};
|
|
94
115
|
export type SendMethod = 'POST' | 'PUT';
|
|
95
116
|
export type SendOptions = {
|
|
96
117
|
body?: unknown | undefined;
|
|
@@ -196,14 +217,36 @@ export interface SocketSdkOptions {
|
|
|
196
217
|
baseUrl?: string | undefined;
|
|
197
218
|
/**
|
|
198
219
|
* Enable TTL caching for API responses (default: false).
|
|
199
|
-
* When enabled, GET requests are cached with
|
|
220
|
+
* When enabled, GET requests are cached with configurable TTLs.
|
|
221
|
+
* Only applies to listOrganizations() and getQuota() methods.
|
|
200
222
|
*/
|
|
201
223
|
cache?: boolean | undefined;
|
|
202
224
|
/**
|
|
203
225
|
* Cache TTL in milliseconds (default: 300_000 = 5 minutes).
|
|
204
226
|
* Only used when cache is enabled.
|
|
227
|
+
* Can be a single number for all endpoints or an object for per-endpoint TTLs.
|
|
228
|
+
*
|
|
229
|
+
* Recommended TTLs by endpoint:
|
|
230
|
+
* - organizations: 30 minutes (rarely changes)
|
|
231
|
+
* - quota: 10 minutes (changes incrementally)
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* // Single TTL for all endpoints.
|
|
235
|
+
* cacheTtl: 15 * 60 * 1000 // 15 minutes
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* // Per-endpoint TTLs with recommended values.
|
|
239
|
+
* cacheTtl: {
|
|
240
|
+
* default: 5 * 60 * 1000, // 5 minutes default
|
|
241
|
+
* organizations: 30 * 60 * 1000, // 30 minutes (recommended)
|
|
242
|
+
* quota: 10 * 60 * 1000 // 10 minutes (recommended)
|
|
243
|
+
* }
|
|
205
244
|
*/
|
|
206
|
-
cacheTtl?: number |
|
|
245
|
+
cacheTtl?: number | {
|
|
246
|
+
default?: number | undefined;
|
|
247
|
+
organizations?: number | undefined;
|
|
248
|
+
quota?: number | undefined;
|
|
249
|
+
} | undefined;
|
|
207
250
|
/**
|
|
208
251
|
* Callback for file validation events.
|
|
209
252
|
* Called when any file-upload method detects unreadable files:
|
|
@@ -219,6 +262,11 @@ export interface SocketSdkOptions {
|
|
|
219
262
|
* @since v3.0.0
|
|
220
263
|
*/
|
|
221
264
|
onFileValidation?: FileValidationCallback | undefined;
|
|
265
|
+
/** Request/response logging hooks */
|
|
266
|
+
hooks?: {
|
|
267
|
+
onRequest?: (info: RequestInfo) => void;
|
|
268
|
+
onResponse?: (info: ResponseInfo) => void;
|
|
269
|
+
} | undefined;
|
|
222
270
|
/**
|
|
223
271
|
* Number of retry attempts on failure (default: 0, retries disabled).
|
|
224
272
|
* Retries are opt-in following Node.js fs.rm() pattern.
|
|
@@ -274,6 +322,17 @@ export type CreateScanFromFilepathsOptions = {
|
|
|
274
322
|
export type StreamOrgFullScanOptions = {
|
|
275
323
|
output?: boolean | string | undefined;
|
|
276
324
|
};
|
|
325
|
+
export type PostOrgTelemetryPayload = Record<string, unknown>;
|
|
326
|
+
export type PostOrgTelemetryResponse = Record<string, never>;
|
|
327
|
+
/**
|
|
328
|
+
* Configuration for telemetry collection.
|
|
329
|
+
* Controls whether telemetry is enabled and how events are collected.
|
|
330
|
+
*/
|
|
331
|
+
export interface TelemetryConfig {
|
|
332
|
+
telemetry: {
|
|
333
|
+
enabled: boolean;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
277
336
|
export type UploadManifestFilesOptions = {
|
|
278
337
|
pathsRelativeTo?: string | undefined;
|
|
279
338
|
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -26,3 +26,64 @@ export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: s
|
|
|
26
26
|
* Converts relative paths to absolute using current working directory as reference.
|
|
27
27
|
*/
|
|
28
28
|
export declare function resolveBasePath(pathsRelativeTo?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate Jaccard similarity coefficient between two strings based on word sets.
|
|
31
|
+
* Returns a value between 0 (no overlap) and 1 (identical word sets).
|
|
32
|
+
*
|
|
33
|
+
* Formula: |A ∩ B| / |A ∪ B|
|
|
34
|
+
*
|
|
35
|
+
* @param str1 - First string to compare
|
|
36
|
+
* @param str2 - Second string to compare
|
|
37
|
+
* @returns Similarity coefficient (0-1)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* calculateWordSetSimilarity('hello world', 'world hello') // 1.0 (same words)
|
|
42
|
+
* calculateWordSetSimilarity('hello world', 'goodbye world') // 0.33 (1/3 overlap)
|
|
43
|
+
* calculateWordSetSimilarity('hello', 'goodbye') // 0 (no overlap)
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function calculateWordSetSimilarity(str1: string, str2: string): number;
|
|
47
|
+
/**
|
|
48
|
+
* Determine if a "reason" string should be omitted due to high similarity with error message.
|
|
49
|
+
* Uses Jaccard similarity to detect redundant phrasing.
|
|
50
|
+
*
|
|
51
|
+
* @param errorMessage - Main error message
|
|
52
|
+
* @param reason - Detailed reason/cause string
|
|
53
|
+
* @param threshold - Similarity threshold (0-1), defaults to 0.6
|
|
54
|
+
* @returns true if reason should be omitted (too similar)
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* shouldOmitReason('Invalid token', 'The token is invalid') // true (high overlap)
|
|
59
|
+
* shouldOmitReason('Request failed', 'Rate limit exceeded') // false (low overlap)
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function shouldOmitReason(errorMessage: string, reason: string | undefined, threshold?: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Filter error cause based on similarity to error message.
|
|
65
|
+
* Returns undefined if the cause should be omitted due to redundancy.
|
|
66
|
+
*
|
|
67
|
+
* Intelligently handles common error message patterns by:
|
|
68
|
+
* - Comparing full messages
|
|
69
|
+
* - Splitting on colons and comparing each part
|
|
70
|
+
* - Finding the highest similarity among all parts
|
|
71
|
+
*
|
|
72
|
+
* Examples:
|
|
73
|
+
* - "Socket API Request failed (400): Bad Request" vs "Bad Request"
|
|
74
|
+
* - "Error: Authentication: Token expired" vs "Token expired"
|
|
75
|
+
*
|
|
76
|
+
* @param errorMessage - Main error message
|
|
77
|
+
* @param errorCause - Detailed error cause/reason
|
|
78
|
+
* @param threshold - Similarity threshold (0-1), defaults to 0.6
|
|
79
|
+
* @returns The error cause if it should be kept, undefined otherwise
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* filterRedundantCause('Invalid token', 'The token is invalid') // undefined
|
|
84
|
+
* filterRedundantCause('Request failed', 'Rate limit exceeded') // 'Rate limit exceeded'
|
|
85
|
+
* filterRedundantCause('API Request failed (400): Bad Request', 'Bad Request') // undefined
|
|
86
|
+
* filterRedundantCause('Error: Auth: Token expired', 'Token expired') // undefined
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function filterRedundantCause(errorMessage: string, errorCause: string | undefined, threshold?: number): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"packageManager": "pnpm@10.25.0",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"description": "SDK for the Socket API client",
|
|
6
7
|
"author": {
|
|
@@ -45,24 +46,29 @@
|
|
|
45
46
|
"lint": "node scripts/lint.mjs",
|
|
46
47
|
"precommit": "pnpm run check --lint --staged",
|
|
47
48
|
"prepare": "husky",
|
|
49
|
+
"ci:validate": "node scripts/ci-validate.mjs",
|
|
48
50
|
"prepublishOnly": "echo 'ERROR: Use GitHub Actions workflow for publishing' && exit 1",
|
|
49
51
|
"publish": "node scripts/publish.mjs",
|
|
52
|
+
"publish:ci": "node scripts/publish.mjs --skip-git --skip-build --tag ${DIST_TAG:-latest}",
|
|
50
53
|
"claude": "node scripts/claude.mjs",
|
|
51
54
|
"test": "node scripts/test.mjs",
|
|
52
55
|
"type": "tsgo --noEmit -p .config/tsconfig.check.json",
|
|
53
56
|
"update": "node scripts/update.mjs"
|
|
54
57
|
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@socketregistry/packageurl-js": "1.3.5",
|
|
60
|
+
"@socketsecurity/lib": "5.0.0",
|
|
61
|
+
"form-data": "4.0.5"
|
|
62
|
+
},
|
|
55
63
|
"devDependencies": {
|
|
56
64
|
"@babel/generator": "7.28.5",
|
|
57
65
|
"@babel/parser": "7.26.3",
|
|
58
66
|
"@babel/traverse": "7.26.4",
|
|
59
67
|
"@babel/types": "7.26.3",
|
|
60
68
|
"@biomejs/biome": "2.2.4",
|
|
61
|
-
"@dotenvx/dotenvx": "1.
|
|
69
|
+
"@dotenvx/dotenvx": "^1.51.1",
|
|
62
70
|
"@eslint/compat": "1.3.2",
|
|
63
71
|
"@eslint/js": "9.35.0",
|
|
64
|
-
"@socketregistry/packageurl-js": "1.3.5",
|
|
65
|
-
"@socketsecurity/lib": "3.1.3",
|
|
66
72
|
"@types/babel__traverse": "7.28.0",
|
|
67
73
|
"@types/node": "24.9.2",
|
|
68
74
|
"@typescript/native-preview": "7.0.0-dev.20250926.1",
|
|
@@ -83,10 +89,9 @@
|
|
|
83
89
|
"husky": "9.1.7",
|
|
84
90
|
"magic-string": "0.30.14",
|
|
85
91
|
"nock": "14.0.10",
|
|
86
|
-
"npm-run-all2": "8.0.4",
|
|
87
92
|
"openapi-typescript": "6.7.6",
|
|
88
93
|
"semver": "7.7.2",
|
|
89
|
-
"taze": "19.
|
|
94
|
+
"taze": "19.9.2",
|
|
90
95
|
"type-coverage": "2.29.7",
|
|
91
96
|
"typescript-eslint": "8.44.1",
|
|
92
97
|
"vitest": "4.0.3",
|
|
@@ -103,7 +108,7 @@
|
|
|
103
108
|
},
|
|
104
109
|
"engines": {
|
|
105
110
|
"node": ">=18",
|
|
106
|
-
"pnpm": ">=10.
|
|
111
|
+
"pnpm": ">=10.25.0"
|
|
107
112
|
},
|
|
108
113
|
"files": [
|
|
109
114
|
"CHANGELOG.md",
|