@socketsecurity/sdk 3.1.3 → 3.3.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/dist/utils.d.ts CHANGED
@@ -1,5 +1,50 @@
1
1
  import type { QueryParams } from './types';
2
2
  export { createUserAgentFromPkgJson } from './user-agent';
3
+ /**
4
+ * Calculate Jaccard similarity coefficient between two strings based on word sets.
5
+ * Returns a value between 0 (no overlap) and 1 (identical word sets).
6
+ *
7
+ * Formula: |A ∩ B| / |A ∪ B|
8
+ *
9
+ * @param str1 - First string to compare
10
+ * @param str2 - Second string to compare
11
+ * @returns Similarity coefficient (0-1)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * calculateWordSetSimilarity('hello world', 'world hello') // 1.0 (same words)
16
+ * calculateWordSetSimilarity('hello world', 'goodbye world') // 0.33 (1/3 overlap)
17
+ * calculateWordSetSimilarity('hello', 'goodbye') // 0 (no overlap)
18
+ * ```
19
+ */
20
+ export declare function calculateWordSetSimilarity(str1: string, str2: string): number;
21
+ /**
22
+ * Filter error cause based on similarity to error message.
23
+ * Returns undefined if the cause should be omitted due to redundancy.
24
+ *
25
+ * Intelligently handles common error message patterns by:
26
+ * - Comparing full messages
27
+ * - Splitting on colons and comparing each part
28
+ * - Finding the highest similarity among all parts
29
+ *
30
+ * Examples:
31
+ * - "Socket API Request failed (400): Bad Request" vs "Bad Request"
32
+ * - "Error: Authentication: Token expired" vs "Token expired"
33
+ *
34
+ * @param errorMessage - Main error message
35
+ * @param errorCause - Detailed error cause/reason
36
+ * @param threshold - Similarity threshold (0-1), defaults to 0.6
37
+ * @returns The error cause if it should be kept, undefined otherwise
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * filterRedundantCause('Invalid token', 'The token is invalid') // undefined
42
+ * filterRedundantCause('Request failed', 'Rate limit exceeded') // 'Rate limit exceeded'
43
+ * filterRedundantCause('API Request failed (400): Bad Request', 'Bad Request') // undefined
44
+ * filterRedundantCause('Error: Auth: Token expired', 'Token expired') // undefined
45
+ * ```
46
+ */
47
+ export declare function filterRedundantCause(errorMessage: string, errorCause: string | undefined, threshold?: number): string | undefined;
3
48
  /**
4
49
  * Normalize base URL by ensuring it ends with a trailing slash.
5
50
  * Required for proper URL joining with relative paths.
@@ -26,3 +71,19 @@ export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: s
26
71
  * Converts relative paths to absolute using current working directory as reference.
27
72
  */
28
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,6 +1,7 @@
1
1
  {
2
2
  "name": "@socketsecurity/sdk",
3
- "version": "3.1.3",
3
+ "version": "3.3.0",
4
+ "packageManager": "pnpm@10.28.1",
4
5
  "license": "MIT",
5
6
  "description": "SDK for the Socket API client",
6
7
  "author": {
@@ -45,27 +46,35 @@
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.5.3",
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",
69
+ "@dotenvx/dotenvx": "^1.51.4",
61
70
  "@eslint/compat": "1.3.2",
62
71
  "@eslint/js": "9.35.0",
63
- "@socketregistry/packageurl-js": "1.3.5",
64
- "@socketsecurity/lib": "3.2.4",
65
72
  "@types/babel__traverse": "7.28.0",
66
73
  "@types/node": "24.9.2",
67
74
  "@typescript/native-preview": "7.0.0-dev.20250926.1",
68
75
  "@vitest/coverage-v8": "4.0.3",
76
+ "@sveltejs/acorn-typescript": "1.0.8",
77
+ "acorn": "8.15.0",
69
78
  "del": "8.0.1",
70
79
  "dev-null-cli": "2.0.0",
71
80
  "esbuild": "0.25.11",
@@ -84,7 +93,7 @@
84
93
  "nock": "14.0.10",
85
94
  "openapi-typescript": "6.7.6",
86
95
  "semver": "7.7.2",
87
- "taze": "19.6.0",
96
+ "taze": "19.9.2",
88
97
  "type-coverage": "2.29.7",
89
98
  "typescript-eslint": "8.44.1",
90
99
  "vitest": "4.0.3",
@@ -101,7 +110,7 @@
101
110
  },
102
111
  "engines": {
103
112
  "node": ">=18",
104
- "pnpm": ">=10.16.0"
113
+ "pnpm": ">=10.25.0"
105
114
  },
106
115
  "files": [
107
116
  "CHANGELOG.md",