@socketsecurity/sdk 1.7.0 → 1.8.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 +15 -0
- package/README.md +42 -1
- package/package.json +24 -23
- package/types/api.d.ts +137 -111
- package/dist/constants.d.ts +0 -8
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -128
- package/dist/constants.js.map +0 -1
- package/dist/file-upload.d.ts +0 -22
- package/dist/file-upload.d.ts.map +0 -1
- package/dist/file-upload.js +0 -152
- package/dist/file-upload.js.map +0 -1
- package/dist/http-client.d.ts +0 -79
- package/dist/http-client.d.ts.map +0 -1
- package/dist/http-client.js +0 -262
- package/dist/http-client.js.map +0 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -42
- package/dist/index.js.map +0 -1
- package/dist/socket-sdk-class.d.ts +0 -422
- package/dist/socket-sdk-class.d.ts.map +0 -1
- package/dist/socket-sdk-class.js +0 -1342
- package/dist/socket-sdk-class.js.map +0 -1
- package/dist/types.d.ts +0 -155
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -4
- package/dist/types.js.map +0 -1
- package/dist/user-agent.d.ts +0 -14
- package/dist/user-agent.d.ts.map +0 -1
- package/dist/user-agent.js +0 -18
- package/dist/user-agent.js.map +0 -1
- package/dist/utils.d.ts +0 -29
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -94
- package/dist/utils.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
|
|
7
|
+
## [1.8.1](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.8.1) - 2025-09-29
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Update test infrastructure and build configuration
|
|
11
|
+
|
|
12
|
+
## [1.8.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.8.0) - 2025-09-27
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Quota utility functions for API cost management in `quota-utils.ts`
|
|
16
|
+
- New exported functions: `checkQuota`, `formatQuotaReport`, `getEstimatedCost`, `getMethodCost`, `getQuotaSummary`, `isWithinQuota`
|
|
17
|
+
- Example files demonstrating quota usage patterns
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Improved error handling for quota utilities
|
|
21
|
+
|
|
7
22
|
## [1.7.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.7.0) - 2025-09-26
|
|
8
23
|
|
|
9
24
|
### Added
|
package/README.md
CHANGED
|
@@ -30,6 +30,36 @@ if (res.success) {
|
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
### Quota Management Example
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
import {
|
|
37
|
+
SocketSdk,
|
|
38
|
+
getQuotaCost,
|
|
39
|
+
calculateTotalQuotaCost,
|
|
40
|
+
hasQuotaForMethods
|
|
41
|
+
} from '@socketsecurity/sdk'
|
|
42
|
+
|
|
43
|
+
const client = new SocketSdk('your-api-key')
|
|
44
|
+
|
|
45
|
+
// Check quota cost before making API calls
|
|
46
|
+
const batchCost = getQuotaCost('batchPackageFetch') // Returns: 100
|
|
47
|
+
const analyticsCost = getQuotaCost('getOrgAnalytics') // Returns: 10
|
|
48
|
+
|
|
49
|
+
// Calculate total cost for multiple operations
|
|
50
|
+
const operations = ['batchPackageFetch', 'getOrgAnalytics', 'uploadManifestFiles']
|
|
51
|
+
const totalCost = calculateTotalQuotaCost(operations) // Returns: 210
|
|
52
|
+
|
|
53
|
+
// Check if you have sufficient quota
|
|
54
|
+
const quotaRes = await client.getQuota()
|
|
55
|
+
if (quotaRes.success && hasQuotaForMethods(quotaRes.data.quota, operations)) {
|
|
56
|
+
// Proceed with API calls
|
|
57
|
+
console.log(`Sufficient quota available: ${quotaRes.data.quota} units`)
|
|
58
|
+
} else {
|
|
59
|
+
console.log('Insufficient quota - consider using free alternatives')
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
33
63
|
### CommonJS
|
|
34
64
|
|
|
35
65
|
```javascript
|
|
@@ -70,7 +100,8 @@ The Socket SDK provides programmatic access to Socket.dev's security analysis pl
|
|
|
70
100
|
### Authentication & Access
|
|
71
101
|
- **API Tokens**: Create, rotate, update, and revoke organization API tokens
|
|
72
102
|
- **Entitlements**: View enabled Socket products and features
|
|
73
|
-
- **Quota Management**: Monitor API usage limits and
|
|
103
|
+
- **Quota Management**: Monitor API usage limits, quotas, and plan method calls
|
|
104
|
+
- **Quota Utilities**: Pre-calculate costs, check permissions, and optimize API usage
|
|
74
105
|
|
|
75
106
|
### Advanced Features
|
|
76
107
|
- **Patches**: View and stream security patches for vulnerabilities
|
|
@@ -154,6 +185,16 @@ The Socket SDK provides programmatic access to Socket.dev's security analysis pl
|
|
|
154
185
|
* Returns statistical analysis for specified time period
|
|
155
186
|
* `getQuota()` - Get current API quota usage
|
|
156
187
|
* Returns remaining requests, rate limits, and quota reset times
|
|
188
|
+
|
|
189
|
+
### Quota Utility Functions
|
|
190
|
+
* `getQuotaCost(methodName)` - Get quota cost for any SDK method
|
|
191
|
+
* `getRequiredPermissions(methodName)` - Get required permissions for SDK method
|
|
192
|
+
* `calculateTotalQuotaCost(methodNames[])` - Calculate total cost for multiple methods
|
|
193
|
+
* `hasQuotaForMethods(availableQuota, methodNames[])` - Check if quota is sufficient
|
|
194
|
+
* `getMethodsByQuotaCost(cost)` - Find methods by quota cost (0, 10, 100 units)
|
|
195
|
+
* `getMethodsByPermissions(permissions[])` - Find methods requiring specific permissions
|
|
196
|
+
* `getQuotaUsageSummary()` - Get summary of all methods grouped by quota cost
|
|
197
|
+
* `getAllMethodRequirements()` - Get complete mapping of methods to costs and permissions
|
|
157
198
|
* `getRepoAnalytics(repo, time)` - Get repository analytics
|
|
158
199
|
* Returns security metrics, dependency trends, and vulnerability statistics
|
|
159
200
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "SDK for the Socket API client",
|
|
6
6
|
"author": {
|
|
@@ -28,41 +28,41 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "pnpm run clean:dist &&
|
|
31
|
+
"build": "pnpm run clean:dist && tsgo --build",
|
|
32
32
|
"check": "run-p -c --aggregate-output check:*",
|
|
33
|
-
"check:lint": "
|
|
33
|
+
"check:lint": "eslint --report-unused-disable-directives .",
|
|
34
34
|
"check:lint:fix": "pnpm run check:lint -- --fix",
|
|
35
|
-
"check:tsc": "
|
|
35
|
+
"check:tsc": "pnpm run build && tsgo --noEmit -p tsconfig.check.json",
|
|
36
36
|
"check-ci": "pnpm run check:lint",
|
|
37
37
|
"coverage": "run-s coverage:*",
|
|
38
|
-
"coverage:test": "run-s
|
|
39
|
-
"coverage:type": "
|
|
40
|
-
"coverage:type:verbose": "
|
|
38
|
+
"coverage:test": "run-s pretest:unit test:unit:coverage",
|
|
39
|
+
"coverage:type": "type-coverage",
|
|
40
|
+
"coverage:type:verbose": "type-coverage --detail",
|
|
41
41
|
"coverage:percent": "node scripts/get-coverage-percentage.mjs",
|
|
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'",
|
|
45
|
+
"clean:dist": "del-cli 'dist' '**/*.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",
|
|
49
49
|
"generate-sdk": "run-s generate-sdk:*",
|
|
50
|
-
"generate-sdk:01-prettify": "
|
|
51
|
-
"generate-sdk:02-generate": "
|
|
50
|
+
"generate-sdk:01-prettify": "node scripts/prettify-base-json.mjs",
|
|
51
|
+
"generate-sdk:02-generate": "node scripts/generate-types.mjs > types/api.d.ts",
|
|
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": "
|
|
55
|
+
"lint": "oxlint -c=.oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json .",
|
|
56
56
|
"lint:fix": "run-s -c lint:fix:*",
|
|
57
|
-
"lint:fix:oxlint": "
|
|
58
|
-
"lint:fix:biome": "
|
|
59
|
-
"lint:fix:eslint": "
|
|
60
|
-
"lint-staged": "
|
|
57
|
+
"lint:fix:oxlint": "oxlint -c=.oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json --quiet --fix . | dev-null",
|
|
58
|
+
"lint:fix:biome": "biome format --log-level=none --fix . | dev-null",
|
|
59
|
+
"lint:fix:eslint": "eslint --report-unused-disable-directives --fix . | dev-null",
|
|
60
|
+
"lint-staged": "lint-staged",
|
|
61
61
|
"precommit": "lint-staged",
|
|
62
|
-
"prepare": "
|
|
63
|
-
"prepublishOnly": "run
|
|
62
|
+
"prepare": "husky",
|
|
63
|
+
"prepublishOnly": "pnpm run build",
|
|
64
|
+
"pretest:unit": "dotenvx -q run -f .env.test -- pnpm run build",
|
|
64
65
|
"test": "run-s check test:*",
|
|
65
|
-
"test:prepare": "dotenvx -q run -f .env.test -- pnpm run build",
|
|
66
66
|
"test:unit": "dotenvx -q run -f .env.test -- vitest --run",
|
|
67
67
|
"test:unit:update": "dotenvx -q run -f .env.test -- vitest --run --update",
|
|
68
68
|
"test:unit:coverage": "dotenvx -q run -f .env.test -- vitest run --coverage",
|
|
@@ -80,9 +80,10 @@
|
|
|
80
80
|
"@dotenvx/dotenvx": "1.49.0",
|
|
81
81
|
"@eslint/compat": "1.3.2",
|
|
82
82
|
"@eslint/js": "9.35.0",
|
|
83
|
-
"@types/node": "24.
|
|
84
|
-
"@typescript-eslint/
|
|
85
|
-
"@typescript/
|
|
83
|
+
"@types/node": "24.5.2",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "8.44.1",
|
|
85
|
+
"@typescript-eslint/parser": "8.44.1",
|
|
86
|
+
"@typescript/native-preview": "7.0.0-dev.20250926.1",
|
|
86
87
|
"@vitest/coverage-v8": "3.2.4",
|
|
87
88
|
"del-cli": "6.0.0",
|
|
88
89
|
"dev-null-cli": "2.0.0",
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
91
92
|
"eslint-plugin-import-x": "4.16.1",
|
|
92
93
|
"eslint-plugin-jsdoc": "57.0.8",
|
|
93
|
-
"eslint-plugin-n": "17.
|
|
94
|
+
"eslint-plugin-n": "17.23.1",
|
|
94
95
|
"eslint-plugin-sort-destructure-keys": "2.0.0",
|
|
95
96
|
"eslint-plugin-unicorn": "56.0.1",
|
|
96
97
|
"globals": "16.4.0",
|
|
@@ -105,7 +106,7 @@
|
|
|
105
106
|
"taze": "19.6.0",
|
|
106
107
|
"trash": "10.0.0",
|
|
107
108
|
"type-coverage": "2.29.7",
|
|
108
|
-
"typescript-eslint": "8.
|
|
109
|
+
"typescript-eslint": "8.44.1",
|
|
109
110
|
"vitest": "3.2.4",
|
|
110
111
|
"yargs-parser": "22.0.0",
|
|
111
112
|
"yoctocolors": "2.1.2"
|