@socketsecurity/sdk 3.2.0 → 3.3.1
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 +32 -2
- package/README.md +2 -15
- package/data/api-method-quota-and-permissions.json +20 -0
- package/dist/constants.d.ts +1 -1
- package/dist/http-client.d.ts +24 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1572 -1163
- package/dist/promise-queue.d.ts +9 -9
- package/dist/socket-sdk-class.d.ts +655 -402
- package/dist/testing.d.ts +9 -9
- package/dist/types-strict.d.ts +225 -144
- package/dist/types.d.ts +20 -19
- package/dist/utils.d.ts +42 -42
- package/package.json +7 -6
- package/types/api.d.ts +2352 -574
package/dist/utils.d.ts
CHANGED
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
import type { QueryParams } from './types';
|
|
2
2
|
export { createUserAgentFromPkgJson } from './user-agent';
|
|
3
|
-
/**
|
|
4
|
-
* Normalize base URL by ensuring it ends with a trailing slash.
|
|
5
|
-
* Required for proper URL joining with relative paths.
|
|
6
|
-
* Memoized for performance since base URLs are typically reused.
|
|
7
|
-
*/
|
|
8
|
-
export declare const normalizeBaseUrl: (baseUrl: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* Create a promise with externally accessible resolve/reject functions.
|
|
11
|
-
* Polyfill for Promise.withResolvers() on older Node.js versions.
|
|
12
|
-
*/
|
|
13
|
-
export declare function promiseWithResolvers<T>(): ReturnType<typeof Promise.withResolvers<T>>;
|
|
14
|
-
/**
|
|
15
|
-
* Convert query parameters to URLSearchParams with API-compatible key normalization.
|
|
16
|
-
* Transforms camelCase keys to snake_case and filters out empty values.
|
|
17
|
-
*/
|
|
18
|
-
export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams;
|
|
19
|
-
/**
|
|
20
|
-
* Convert relative file paths to absolute paths.
|
|
21
|
-
* Resolves paths relative to specified base directory or current working directory.
|
|
22
|
-
*/
|
|
23
|
-
export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: string | undefined): string[];
|
|
24
|
-
/**
|
|
25
|
-
* Resolve base path to an absolute directory path.
|
|
26
|
-
* Converts relative paths to absolute using current working directory as reference.
|
|
27
|
-
*/
|
|
28
|
-
export declare function resolveBasePath(pathsRelativeTo?: string): string;
|
|
29
3
|
/**
|
|
30
4
|
* Calculate Jaccard similarity coefficient between two strings based on word sets.
|
|
31
5
|
* Returns a value between 0 (no overlap) and 1 (identical word sets).
|
|
@@ -44,22 +18,6 @@ export declare function resolveBasePath(pathsRelativeTo?: string): string;
|
|
|
44
18
|
* ```
|
|
45
19
|
*/
|
|
46
20
|
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
21
|
/**
|
|
64
22
|
* Filter error cause based on similarity to error message.
|
|
65
23
|
* Returns undefined if the cause should be omitted due to redundancy.
|
|
@@ -87,3 +45,45 @@ export declare function shouldOmitReason(errorMessage: string, reason: string |
|
|
|
87
45
|
* ```
|
|
88
46
|
*/
|
|
89
47
|
export declare function filterRedundantCause(errorMessage: string, errorCause: string | undefined, threshold?: number): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Normalize base URL by ensuring it ends with a trailing slash.
|
|
50
|
+
* Required for proper URL joining with relative paths.
|
|
51
|
+
* Memoized for performance since base URLs are typically reused.
|
|
52
|
+
*/
|
|
53
|
+
export declare const normalizeBaseUrl: (baseUrl: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Create a promise with externally accessible resolve/reject functions.
|
|
56
|
+
* Polyfill for Promise.withResolvers() on older Node.js versions.
|
|
57
|
+
*/
|
|
58
|
+
export declare function promiseWithResolvers<T>(): ReturnType<typeof Promise.withResolvers<T>>;
|
|
59
|
+
/**
|
|
60
|
+
* Convert query parameters to URLSearchParams with API-compatible key normalization.
|
|
61
|
+
* Transforms camelCase keys to snake_case and filters out empty values.
|
|
62
|
+
*/
|
|
63
|
+
export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams;
|
|
64
|
+
/**
|
|
65
|
+
* Convert relative file paths to absolute paths.
|
|
66
|
+
* Resolves paths relative to specified base directory or current working directory.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: string | undefined): string[];
|
|
69
|
+
/**
|
|
70
|
+
* Resolve base path to an absolute directory path.
|
|
71
|
+
* Converts relative paths to absolute using current working directory as reference.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveBasePath(pathsRelativeTo?: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Determine if a "reason" string should be omitted due to high similarity with error message.
|
|
76
|
+
* Uses Jaccard similarity to detect redundant phrasing.
|
|
77
|
+
*
|
|
78
|
+
* @param errorMessage - Main error message
|
|
79
|
+
* @param reason - Detailed reason/cause string
|
|
80
|
+
* @param threshold - Similarity threshold (0-1), defaults to 0.6
|
|
81
|
+
* @returns true if reason should be omitted (too similar)
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* shouldOmitReason('Invalid token', 'The token is invalid') // true (high overlap)
|
|
86
|
+
* shouldOmitReason('Request failed', 'Rate limit exceeded') // false (low overlap)
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function shouldOmitReason(errorMessage: string, reason: string | undefined, threshold?: number): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/sdk",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"packageManager": "pnpm@10.
|
|
3
|
+
"version": "3.3.1",
|
|
4
|
+
"packageManager": "pnpm@10.30.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "SDK for the Socket API client",
|
|
7
7
|
"author": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@socketregistry/packageurl-js": "1.3.5",
|
|
60
|
-
"@socketsecurity/lib": "5.
|
|
60
|
+
"@socketsecurity/lib": "5.7.0",
|
|
61
61
|
"form-data": "4.0.5"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
@@ -66,13 +66,15 @@
|
|
|
66
66
|
"@babel/traverse": "7.26.4",
|
|
67
67
|
"@babel/types": "7.26.3",
|
|
68
68
|
"@biomejs/biome": "2.2.4",
|
|
69
|
-
"@dotenvx/dotenvx": "^1.
|
|
69
|
+
"@dotenvx/dotenvx": "^1.52.0",
|
|
70
70
|
"@eslint/compat": "1.3.2",
|
|
71
71
|
"@eslint/js": "9.35.0",
|
|
72
|
+
"@sveltejs/acorn-typescript": "1.0.8",
|
|
72
73
|
"@types/babel__traverse": "7.28.0",
|
|
73
74
|
"@types/node": "24.9.2",
|
|
74
75
|
"@typescript/native-preview": "7.0.0-dev.20250926.1",
|
|
75
76
|
"@vitest/coverage-v8": "4.0.3",
|
|
77
|
+
"acorn": "8.15.0",
|
|
76
78
|
"del": "8.0.1",
|
|
77
79
|
"dev-null-cli": "2.0.0",
|
|
78
80
|
"esbuild": "0.25.11",
|
|
@@ -94,8 +96,7 @@
|
|
|
94
96
|
"taze": "19.9.2",
|
|
95
97
|
"type-coverage": "2.29.7",
|
|
96
98
|
"typescript-eslint": "8.44.1",
|
|
97
|
-
"vitest": "4.0.3"
|
|
98
|
-
"yoctocolors-cjs": "2.1.3"
|
|
99
|
+
"vitest": "4.0.3"
|
|
99
100
|
},
|
|
100
101
|
"pnpm": {
|
|
101
102
|
"ignoredBuiltDependencies": [
|