@socketsecurity/sdk 1.11.2 → 2.0.2
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 +42 -0
- package/README.md +53 -81
- package/dist/constants.d.ts +9 -1
- package/dist/http-client.d.ts +3 -1
- package/dist/socket-sdk-class.d.ts +25 -0
- package/dist/types.d.ts +10 -4
- package/package.json +48 -85
- package/types/api-helpers.d.ts +61 -53
- package/types/api.d.ts +1584 -926
- package/dist/constants.js +0 -30
- package/dist/file-upload.js +0 -142
- package/dist/http-client.js +0 -405
- package/dist/index.js +0 -47
- package/dist/package.json.js +0 -207
- package/dist/quota-utils.js +0 -175
- package/dist/socket-sdk-class.js +0 -1511
- package/dist/testing.js +0 -387
- package/dist/user-agent.js +0 -21
- package/dist/utils.js +0 -101
- /package/{requirements.json → data/api-method-quota-and-permissions.json} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,48 @@ 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
|
+
## [2.0.2](https://github.com/SocketDev/socket-sdk-js/releases/tag/v2.0.2) - 2025-10-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- Ensured expected dist/ files are produced and refined package.json exports
|
|
11
|
+
|
|
12
|
+
## [2.0.1](https://github.com/SocketDev/socket-sdk-js/releases/tag/v2.0.1) - 2025-10-21
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Use `@socketsecurity/lib` under the hood
|
|
16
|
+
- Synced OpenAPI type definitions with latest API specification
|
|
17
|
+
- Added documentation for `scan_type` query parameter on manifest upload endpoint (used for categorizing multiple SBOM heads per repository branch)
|
|
18
|
+
- Improved TypeScript helper types (`OpReturnType`, `OpErrorType`) for better type inference and error handling
|
|
19
|
+
|
|
20
|
+
## [2.0.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v2.0.0) - 2025-10-10
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- **BREAKING**: Migrated to ESM-only module format
|
|
24
|
+
- Package is now ESM-only (`"type": "module"` in package.json)
|
|
25
|
+
- All output files use `.mjs` extension for JavaScript
|
|
26
|
+
- TypeScript declaration files use `.d.mts` extension
|
|
27
|
+
- CommonJS (`require()`) is no longer supported
|
|
28
|
+
- Simplified build process for ESM-only output
|
|
29
|
+
- Updated TypeScript configuration to use ESM module resolution
|
|
30
|
+
- Improved code splitting for better tree-shaking with ESM
|
|
31
|
+
|
|
32
|
+
### Removed
|
|
33
|
+
- **BREAKING**: Removed CommonJS support and exports
|
|
34
|
+
- Removed CommonJS-specific build configurations
|
|
35
|
+
|
|
36
|
+
### Migration Guide
|
|
37
|
+
To migrate from v1.x to v2.0:
|
|
38
|
+
1. Ensure your project supports ESM modules (Node.js 14+ with `"type": "module"` or `.mjs` extensions)
|
|
39
|
+
2. Update imports from CommonJS `require()` to ESM `import` statements:
|
|
40
|
+
```javascript
|
|
41
|
+
// Before (v1.x)
|
|
42
|
+
const { SocketSdk } = require('@socketsecurity/sdk');
|
|
43
|
+
|
|
44
|
+
// After (v2.0)
|
|
45
|
+
import { SocketSdk } from '@socketsecurity/sdk';
|
|
46
|
+
```
|
|
47
|
+
3. If your project still requires CommonJS, consider staying on v1.x or using a transpiler
|
|
48
|
+
|
|
7
49
|
## [1.11.2](https://github.com/SocketDev/socket-sdk-js/releases/tag/v1.11.2) - 2025-10-07
|
|
8
50
|
|
|
9
51
|
### Fixed
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://twitter.com/SocketSecurity)
|
|
7
7
|
[](https://bsky.app/profile/socket.dev)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
JavaScript SDK for [Socket.dev](https://socket.dev/) API - Security analysis, vulnerability scanning, and compliance monitoring for software supply chains.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -14,6 +14,8 @@ Official SDK for [Socket.dev](https://socket.dev/) - Programmatic access to secu
|
|
|
14
14
|
pnpm add @socketsecurity/sdk
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
**Note:** Version 2.0+ is ESM-only. For CommonJS support, use version 1.x.
|
|
18
|
+
|
|
17
19
|
## Quick Start
|
|
18
20
|
|
|
19
21
|
```typescript
|
|
@@ -46,137 +48,107 @@ const batchResult = await client.batchPackageFetch({
|
|
|
46
48
|
})
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
**[→ Configuration
|
|
51
|
+
**[→ Configuration](./docs/guides/api-reference.md#configuration)**
|
|
50
52
|
|
|
51
53
|
## API Methods
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
<summary><strong>Package Analysis</strong> - Quick security checks</summary>
|
|
55
|
+
### Package Analysis
|
|
55
56
|
|
|
56
|
-
`batchPackageFetch()` • `batchPackageStream()` • `getIssuesByNpmPackage()` • `getScoreByNpmPackage()`
|
|
57
|
+
Quick security checks: `batchPackageFetch()` • `batchPackageStream()` • `getIssuesByNpmPackage()` • `getScoreByNpmPackage()`
|
|
57
58
|
|
|
58
|
-
[→ Documentation](./docs/
|
|
59
|
-
</details>
|
|
59
|
+
[→ Documentation](./docs/guides/api-reference.md#package-analysis)
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
<summary><strong>Scanning & Analysis</strong> - Project scanning</summary>
|
|
61
|
+
### Scanning & Analysis
|
|
63
62
|
|
|
64
|
-
`createDependenciesSnapshot()` • `createOrgFullScan()` • `createScanFromFilepaths()` • `getScan()` • `getScanList()` • `getSupportedScanFiles()`
|
|
63
|
+
Project scanning: `createDependenciesSnapshot()` • `createOrgFullScan()` • `createScanFromFilepaths()` • `getScan()` • `getScanList()` • `getSupportedScanFiles()`
|
|
65
64
|
|
|
66
|
-
[→ Documentation](./docs/
|
|
67
|
-
</details>
|
|
65
|
+
[→ Documentation](./docs/guides/api-reference.md#scanning--analysis)
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
<summary><strong>Organization Management</strong> - Orgs and repos</summary>
|
|
67
|
+
### Organization Management
|
|
71
68
|
|
|
72
|
-
`getOrganizations()` • `createOrgRepo()` • `getOrgRepo()` • `getOrgRepoList()` • `updateOrgRepo()` • `deleteOrgRepo()`
|
|
69
|
+
Organizations and repositories: `getOrganizations()` • `createOrgRepo()` • `getOrgRepo()` • `getOrgRepoList()` • `updateOrgRepo()` • `deleteOrgRepo()`
|
|
73
70
|
|
|
74
|
-
[→ Documentation](./docs/
|
|
75
|
-
</details>
|
|
71
|
+
[→ Documentation](./docs/guides/api-reference.md#organization-management)
|
|
76
72
|
|
|
77
|
-
|
|
78
|
-
<summary><strong>Policy & Settings</strong> - Security configuration</summary>
|
|
73
|
+
### Policy & Settings
|
|
79
74
|
|
|
80
|
-
`getOrgSecurityPolicy()` • `updateOrgSecurityPolicy()` • `getOrgLicensePolicy()` • `updateOrgLicensePolicy()` • `postSettings()`
|
|
75
|
+
Security configuration: `getOrgSecurityPolicy()` • `updateOrgSecurityPolicy()` • `getOrgLicensePolicy()` • `updateOrgLicensePolicy()` • `postSettings()`
|
|
81
76
|
|
|
82
|
-
[→ Documentation](./docs/
|
|
83
|
-
</details>
|
|
77
|
+
[→ Documentation](./docs/guides/api-reference.md#policy--settings)
|
|
84
78
|
|
|
85
|
-
|
|
86
|
-
<summary><strong>Full Scan Management</strong> - Deep analysis</summary>
|
|
79
|
+
### Full Scan Management
|
|
87
80
|
|
|
88
|
-
`getOrgFullScanList()` • `getOrgFullScanMetadata()` • `getOrgFullScanBuffered()` • `streamOrgFullScan()` • `deleteOrgFullScan()`
|
|
81
|
+
Deep analysis: `getOrgFullScanList()` • `getOrgFullScanMetadata()` • `getOrgFullScanBuffered()` • `streamOrgFullScan()` • `deleteOrgFullScan()`
|
|
89
82
|
|
|
90
|
-
[→ Documentation](./docs/
|
|
91
|
-
</details>
|
|
83
|
+
[→ Documentation](./docs/guides/api-reference.md#full-scan-management)
|
|
92
84
|
|
|
93
|
-
|
|
94
|
-
<summary><strong>Diff Scans</strong> - Compare scans</summary>
|
|
85
|
+
### Diff Scans
|
|
95
86
|
|
|
96
|
-
`createOrgDiffScanFromIds()` • `getDiffScanById()` • `listOrgDiffScans()` • `deleteOrgDiffScan()`
|
|
87
|
+
Scan comparison: `createOrgDiffScanFromIds()` • `getDiffScanById()` • `listOrgDiffScans()` • `deleteOrgDiffScan()`
|
|
97
88
|
|
|
98
|
-
[→ Documentation](./docs/
|
|
99
|
-
</details>
|
|
89
|
+
[→ Documentation](./docs/guides/api-reference.md#diff-scans)
|
|
100
90
|
|
|
101
|
-
|
|
102
|
-
<summary><strong>Patches & Vulnerabilities</strong> - Security fixes</summary>
|
|
91
|
+
### Patches & Vulnerabilities
|
|
103
92
|
|
|
104
|
-
`streamPatchesFromScan()` • `viewPatch()`
|
|
93
|
+
Security fixes: `streamPatchesFromScan()` • `viewPatch()`
|
|
105
94
|
|
|
106
|
-
[→ Documentation](./docs/
|
|
107
|
-
</details>
|
|
95
|
+
[→ Documentation](./docs/guides/api-reference.md#patches--vulnerabilities)
|
|
108
96
|
|
|
109
|
-
|
|
110
|
-
<summary><strong>Alert & Triage</strong> - Alert management</summary>
|
|
97
|
+
### Alert & Triage
|
|
111
98
|
|
|
112
|
-
`getOrgTriage()` • `updateOrgAlertTriage()`
|
|
99
|
+
Alert management: `getOrgTriage()` • `updateOrgAlertTriage()`
|
|
113
100
|
|
|
114
|
-
[→ Documentation](./docs/
|
|
115
|
-
</details>
|
|
101
|
+
[→ Documentation](./docs/guides/api-reference.md#alert--triage)
|
|
116
102
|
|
|
117
|
-
|
|
118
|
-
<summary><strong>Export & Integration</strong> - SBOM export</summary>
|
|
103
|
+
### Export & Integration
|
|
119
104
|
|
|
120
|
-
`exportCDX()` • `exportSPDX()` • `searchDependencies()` • `uploadManifestFiles()`
|
|
105
|
+
SBOM export: `exportCDX()` • `exportSPDX()` • `searchDependencies()` • `uploadManifestFiles()`
|
|
121
106
|
|
|
122
|
-
[→ Documentation](./docs/
|
|
123
|
-
</details>
|
|
107
|
+
[→ Documentation](./docs/guides/api-reference.md#export--integration)
|
|
124
108
|
|
|
125
|
-
|
|
126
|
-
<summary><strong>Repository Labels</strong> - Categorization</summary>
|
|
109
|
+
### Repository Labels
|
|
127
110
|
|
|
128
|
-
`createOrgRepoLabel()` • `getOrgRepoLabel()` • `getOrgRepoLabelList()` • `updateOrgRepoLabel()` • `deleteOrgRepoLabel()`
|
|
111
|
+
Categorization: `createOrgRepoLabel()` • `getOrgRepoLabel()` • `getOrgRepoLabelList()` • `updateOrgRepoLabel()` • `deleteOrgRepoLabel()`
|
|
129
112
|
|
|
130
|
-
[→ Documentation](./docs/
|
|
131
|
-
</details>
|
|
113
|
+
[→ Documentation](./docs/guides/api-reference.md#repository-labels)
|
|
132
114
|
|
|
133
|
-
|
|
134
|
-
<summary><strong>Analytics & Monitoring</strong> - Usage metrics</summary>
|
|
115
|
+
### Analytics & Monitoring
|
|
135
116
|
|
|
136
|
-
`getQuota()` • `getOrgAnalytics()` • `getRepoAnalytics()` • `getAuditLogEvents()`
|
|
117
|
+
Usage metrics: `getQuota()` • `getOrgAnalytics()` • `getRepoAnalytics()` • `getAuditLogEvents()`
|
|
137
118
|
|
|
138
|
-
[→ Documentation](./docs/
|
|
139
|
-
</details>
|
|
119
|
+
[→ Documentation](./docs/guides/api-reference.md#analytics--monitoring)
|
|
140
120
|
|
|
141
|
-
|
|
142
|
-
<summary><strong>Authentication & Access</strong> - API tokens</summary>
|
|
121
|
+
### Authentication & Access
|
|
143
122
|
|
|
144
|
-
`getAPITokens()` • `postAPIToken()` • `postAPITokensRotate()` • `postAPITokensRevoke()` • `postAPITokenUpdate()`
|
|
123
|
+
API tokens: `getAPITokens()` • `postAPIToken()` • `postAPITokensRotate()` • `postAPITokensRevoke()` • `postAPITokenUpdate()`
|
|
145
124
|
|
|
146
|
-
[→ Documentation](./docs/
|
|
147
|
-
</details>
|
|
125
|
+
[→ Documentation](./docs/guides/api-reference.md#authentication--access)
|
|
148
126
|
|
|
149
|
-
|
|
150
|
-
<summary><strong>Entitlements</strong> - Feature access</summary>
|
|
127
|
+
### Entitlements
|
|
151
128
|
|
|
152
|
-
`getEnabledEntitlements()` • `getEntitlements()`
|
|
129
|
+
Feature access: `getEnabledEntitlements()` • `getEntitlements()`
|
|
153
130
|
|
|
154
|
-
[→ Documentation](./docs/
|
|
155
|
-
</details>
|
|
131
|
+
[→ Documentation](./docs/guides/api-reference.md#entitlements)
|
|
156
132
|
|
|
157
|
-
|
|
158
|
-
<summary><strong>Quota Utilities</strong> - Cost helpers</summary>
|
|
133
|
+
### Quota Utilities
|
|
159
134
|
|
|
160
|
-
`getQuotaCost()` • `getRequiredPermissions()` • `calculateTotalQuotaCost()` • `hasQuotaForMethods()` • `getMethodsByQuotaCost()` • `getMethodsByPermissions()` • `getQuotaUsageSummary()` • `getAllMethodRequirements()`
|
|
135
|
+
Cost helpers: `getQuotaCost()` • `getRequiredPermissions()` • `calculateTotalQuotaCost()` • `hasQuotaForMethods()` • `getMethodsByQuotaCost()` • `getMethodsByPermissions()` • `getQuotaUsageSummary()` • `getAllMethodRequirements()`
|
|
161
136
|
|
|
162
|
-
[→ Documentation](./docs/
|
|
163
|
-
</details>
|
|
137
|
+
[→ Documentation](./docs/guides/quota-management.md)
|
|
164
138
|
|
|
165
|
-
|
|
166
|
-
<summary><strong>Advanced Query Methods</strong> - Raw API</summary>
|
|
139
|
+
### Advanced Query Methods
|
|
167
140
|
|
|
168
|
-
`getApi()` • `sendApi()`
|
|
141
|
+
Raw API access: `getApi()` • `sendApi()`
|
|
169
142
|
|
|
170
|
-
[→ Documentation](./docs/
|
|
171
|
-
</details>
|
|
143
|
+
[→ Documentation](./docs/guides/api-reference.md#advanced-query-methods)
|
|
172
144
|
|
|
173
|
-
**[→
|
|
145
|
+
**[→ API Reference](./docs/guides/api-reference.md)**
|
|
174
146
|
|
|
175
|
-
**[→
|
|
147
|
+
**[→ Examples](./docs/guides/usage-examples.md)**
|
|
176
148
|
|
|
177
|
-
**[→ Quota Management](./docs/
|
|
149
|
+
**[→ Quota Management](./docs/guides/quota-management.md)** - Cost tiers: 0 (free), 10 (standard), 100 (batch/uploads)
|
|
178
150
|
|
|
179
|
-
**[→ Testing Utilities](./docs/
|
|
151
|
+
**[→ Testing Utilities](./docs/guides/dev/testing.md)** - Mock factories, fixtures, type guards
|
|
180
152
|
|
|
181
153
|
## See Also
|
|
182
154
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { ALERT_ACTION } from './types';
|
|
2
2
|
export declare const DEFAULT_USER_AGENT: string;
|
|
3
|
+
export declare const DEFAULT_HTTP_TIMEOUT = 30000;
|
|
4
|
+
export declare const DEFAULT_RETRIES = 3;
|
|
5
|
+
export declare const DEFAULT_RETRY_DELAY = 1000;
|
|
6
|
+
export declare const MAX_HTTP_TIMEOUT: number;
|
|
7
|
+
export declare const MIN_HTTP_TIMEOUT = 5000;
|
|
8
|
+
export declare const MAX_RESPONSE_SIZE: number;
|
|
9
|
+
export declare const MAX_STREAM_SIZE: number;
|
|
10
|
+
export declare const SOCKET_PUBLIC_BLOB_STORE_URL = "https://socketusercontent.com";
|
|
3
11
|
export declare const httpAgentNames: Set<string>;
|
|
4
|
-
export declare const publicPolicy: Map<"ambiguousClassifier" | "badEncoding" | "badSemver" | "badSemverDependency" | "bidi" | "binScriptConfusion" | "chromeContentScript" | "chromeHostPermission" | "chromePermission" | "chromeWildcardHostPermission" | "chronoAnomaly" | "compromisedSSHKey" | "copyleftLicense" | "criticalCVE" | "cve" | "debugAccess" | "deprecated" | "deprecatedException" | "deprecatedLicense" | "didYouMean" | "dynamicRequire" | "emptyPackage" | "envVars" | "explicitlyUnlicensedItem" | "extraneousDependency" | "fileDependency" | "filesystemAccess" | "floatingDependency" | "generic" | "gitDependency" | "gitHubDependency" | "gptAnomaly" | "gptDidYouMean" | "gptMalware" | "gptSecurity" | "hasNativeCode" | "highEntropyStrings" | "homoglyphs" | "httpDependency" | "installScripts" | "invalidPackageJSON" | "invisibleChars" | "licenseChange" | "licenseException" | "licenseSpdxDisj" | "longStrings" | "majorRefactor" | "malware" | "manifestConfusion" | "mediumCVE" | "mildCVE" | "minifiedFile" | "miscLicenseIssues" | "missingAuthor" | "missingDependency" | "missingLicense" | "missingTarball" | "mixedLicense" | "modifiedException" | "modifiedLicense" | "networkAccess" | "newAuthor" | "noAuthorData" | "noBugTracker" | "noLicenseFound" | "noREADME" | "noRepository" | "noTests" | "noV1" | "noWebsite" | "nonOSILicense" | "nonSPDXLicense" | "nonpermissiveLicense" | "notice" | "obfuscatedFile" | "obfuscatedRequire" | "peerDependency" | "potentialVulnerability" | "semverAnomaly" | "shellAccess" | "shellScriptOverride" | "shrinkwrap" | "socketUpgradeAvailable" | "suspiciousStarActivity" | "suspiciousString" | "telemetry" | "trivialPackage" | "troll" | "typeModuleCompatibility" | "uncaughtOptionalDependency" | "unclearLicense" | "unidentifiedLicense" | "unmaintained" | "unpopularPackage" | "unpublished" | "unresolvedRequire" | "unsafeCopyright" | "unstableOwnership" | "unusedDependency" | "urlStrings" | "usesEval" | "vsxActivationWildcard" | "vsxDebuggerContribution" | "vsxExtensionDependency" | "vsxExtensionPack" | "vsxProposedApiUsage" | "vsxUntrustedWorkspaceSupported" | "vsxVirtualWorkspaceSupported" | "vsxWebviewContribution" | "vsxWorkspaceContainsActivation" | "zeroWidth", ALERT_ACTION>;
|
|
12
|
+
export declare const publicPolicy: Map<"ambiguousClassifier" | "badEncoding" | "badSemver" | "badSemverDependency" | "bidi" | "binScriptConfusion" | "chromeContentScript" | "chromeHostPermission" | "chromePermission" | "chromeWildcardHostPermission" | "chronoAnomaly" | "compromisedSSHKey" | "copyleftLicense" | "criticalCVE" | "cve" | "debugAccess" | "deprecated" | "deprecatedException" | "deprecatedLicense" | "didYouMean" | "dynamicRequire" | "emptyPackage" | "envVars" | "explicitlyUnlicensedItem" | "extraneousDependency" | "fileDependency" | "filesystemAccess" | "floatingDependency" | "generic" | "ghaArgToEnv" | "ghaArgToOutput" | "ghaArgToSink" | "ghaContextToEnv" | "ghaContextToOutput" | "ghaContextToSink" | "ghaEnvToSink" | "gitDependency" | "gitHubDependency" | "gptAnomaly" | "gptDidYouMean" | "gptMalware" | "gptSecurity" | "hasNativeCode" | "highEntropyStrings" | "homoglyphs" | "httpDependency" | "installScripts" | "invalidPackageJSON" | "invisibleChars" | "licenseChange" | "licenseException" | "licenseSpdxDisj" | "longStrings" | "majorRefactor" | "malware" | "manifestConfusion" | "mediumCVE" | "mildCVE" | "minifiedFile" | "miscLicenseIssues" | "missingAuthor" | "missingDependency" | "missingLicense" | "missingTarball" | "mixedLicense" | "modifiedException" | "modifiedLicense" | "networkAccess" | "newAuthor" | "noAuthorData" | "noBugTracker" | "noLicenseFound" | "noREADME" | "noRepository" | "noTests" | "noV1" | "noWebsite" | "nonOSILicense" | "nonSPDXLicense" | "nonpermissiveLicense" | "notice" | "obfuscatedFile" | "obfuscatedRequire" | "peerDependency" | "potentialVulnerability" | "semverAnomaly" | "shellAccess" | "shellScriptOverride" | "shrinkwrap" | "socketUpgradeAvailable" | "suspiciousStarActivity" | "suspiciousString" | "telemetry" | "trivialPackage" | "troll" | "typeModuleCompatibility" | "uncaughtOptionalDependency" | "unclearLicense" | "unidentifiedLicense" | "unmaintained" | "unpopularPackage" | "unpublished" | "unresolvedRequire" | "unsafeCopyright" | "unstableOwnership" | "unusedDependency" | "urlStrings" | "usesEval" | "vsxActivationWildcard" | "vsxDebuggerContribution" | "vsxExtensionDependency" | "vsxExtensionPack" | "vsxProposedApiUsage" | "vsxUntrustedWorkspaceSupported" | "vsxVirtualWorkspaceSupported" | "vsxWebviewContribution" | "vsxWorkspaceContainsActivation" | "zeroWidth", ALERT_ACTION>;
|
package/dist/http-client.d.ts
CHANGED
|
@@ -44,8 +44,10 @@ export declare function createRequestWithJson(method: SendMethod, baseUrl: strin
|
|
|
44
44
|
/**
|
|
45
45
|
* Read the response body from an HTTP error response.
|
|
46
46
|
* Accumulates all chunks into a complete string for error handling.
|
|
47
|
+
* Enforces maximum response size to prevent memory exhaustion.
|
|
47
48
|
*
|
|
48
49
|
* @throws {Error} When stream errors occur during reading
|
|
50
|
+
* @throws {Error} When response exceeds maximum size limit
|
|
49
51
|
*/
|
|
50
52
|
export declare function getErrorResponseBody(response: IncomingMessage): Promise<string>;
|
|
51
53
|
/**
|
|
@@ -68,7 +70,7 @@ export declare function getResponse(req: ClientRequest): Promise<IncomingMessage
|
|
|
68
70
|
* @throws {ResponseError} When response has non-2xx status code
|
|
69
71
|
* @throws {SyntaxError} When response body contains invalid JSON
|
|
70
72
|
*/
|
|
71
|
-
export declare function getResponseJson(response: IncomingMessage, method?: string | undefined): Promise<import("@socketsecurity/
|
|
73
|
+
export declare function getResponseJson(response: IncomingMessage, method?: string | undefined): Promise<import("@socketsecurity/lib/json").JsonValue | undefined>;
|
|
72
74
|
/**
|
|
73
75
|
* Check if HTTP response has a successful status code (2xx range).
|
|
74
76
|
* Returns true for status codes between 200-299, false otherwise.
|
|
@@ -419,4 +419,29 @@ export declare class SocketSdk {
|
|
|
419
419
|
* vulnerabilities, description, license, and tier information.
|
|
420
420
|
*/
|
|
421
421
|
viewPatch(orgSlug: string, uuid: string): Promise<PatchViewResponse>;
|
|
422
|
+
/**
|
|
423
|
+
* Download patch file content by hash.
|
|
424
|
+
*
|
|
425
|
+
* Downloads the actual patched file content from the public Socket blob store.
|
|
426
|
+
* This is used after calling viewPatch() to get the patch metadata.
|
|
427
|
+
* No authentication is required as patch blobs are publicly accessible.
|
|
428
|
+
*
|
|
429
|
+
* @param hash - The blob hash in SSRI (sha256-base64) or hex format
|
|
430
|
+
* @param options - Optional configuration
|
|
431
|
+
* @param options.baseUrl - Override blob store URL (for testing)
|
|
432
|
+
* @returns Promise<string> - The patch file content as UTF-8 string
|
|
433
|
+
* @throws Error if blob not found (404) or download fails
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```typescript
|
|
437
|
+
* const sdk = new SocketSdk('your-api-token')
|
|
438
|
+
* // First get patch metadata
|
|
439
|
+
* const patch = await sdk.viewPatch('my-org', 'patch-uuid')
|
|
440
|
+
* // Then download the actual patched file
|
|
441
|
+
* const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob)
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
downloadPatch(hash: string, options?: {
|
|
445
|
+
baseUrl?: string;
|
|
446
|
+
}): Promise<string>;
|
|
422
447
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Provides TypeScript types for API requests, responses, and internal SDK functionality.
|
|
4
4
|
*/
|
|
5
5
|
import type { components, operations } from '../types/api';
|
|
6
|
-
import type {
|
|
7
|
-
import type { Remap } from '@socketsecurity/
|
|
6
|
+
import type { OpReturnType } from '../types/api-helpers';
|
|
7
|
+
import type { Remap } from '@socketsecurity/lib/objects';
|
|
8
8
|
import type { ClientHttp2Session } from 'http2-wrapper';
|
|
9
9
|
import type { Agent as HttpAgent, RequestOptions as HttpRequestOptions } from 'node:http';
|
|
10
10
|
import type { ClientSessionRequestOptions } from 'node:http2';
|
|
@@ -106,14 +106,20 @@ export type SocketArtifactAlert = Remap<Omit<components['schemas']['SocketAlert'
|
|
|
106
106
|
props?: Record<string, unknown> | undefined;
|
|
107
107
|
}>;
|
|
108
108
|
export type SocketSdkOperations = keyof operations;
|
|
109
|
-
export type SocketSdkSuccessResult<T extends SocketSdkOperations> =
|
|
109
|
+
export type SocketSdkSuccessResult<T extends SocketSdkOperations> = {
|
|
110
110
|
cause?: undefined;
|
|
111
|
+
data: OpReturnType<operations[T]>;
|
|
111
112
|
error?: undefined;
|
|
113
|
+
status: number;
|
|
114
|
+
success: true;
|
|
112
115
|
};
|
|
113
|
-
export type SocketSdkErrorResult<T extends SocketSdkOperations> =
|
|
116
|
+
export type SocketSdkErrorResult<T extends SocketSdkOperations> = {
|
|
114
117
|
cause?: string | undefined;
|
|
115
118
|
data?: undefined;
|
|
116
119
|
error: string;
|
|
120
|
+
status: number;
|
|
121
|
+
success: false;
|
|
122
|
+
_operation?: T;
|
|
117
123
|
};
|
|
118
124
|
export type SocketSdkResult<T extends SocketSdkOperations> = SocketSdkSuccessResult<T> | SocketSdkErrorResult<T>;
|
|
119
125
|
export type SocketSdkGenericResult<T> = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "SDK for the Socket API client",
|
|
6
6
|
"author": {
|
|
@@ -13,93 +13,66 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git://github.com/SocketDev/socket-sdk-js.git"
|
|
15
15
|
},
|
|
16
|
-
"type": "
|
|
17
|
-
"main": "./dist/index.
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.mjs",
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
|
-
"default": "./dist/index.
|
|
22
|
+
"default": "./dist/index.mjs"
|
|
23
23
|
},
|
|
24
|
+
"./package.json": "./package.json",
|
|
24
25
|
"./testing": {
|
|
25
26
|
"types": "./dist/testing.d.ts",
|
|
26
|
-
"default": "./dist/testing.
|
|
27
|
+
"default": "./dist/testing.mjs"
|
|
27
28
|
},
|
|
28
|
-
"./types/api
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"./
|
|
29
|
+
"./types/api": {
|
|
30
|
+
"types": "./types/api.d.ts",
|
|
31
|
+
"default": "./types/api.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./types/api-helpers": {
|
|
34
|
+
"types": "./types/api-helpers.d.ts",
|
|
35
|
+
"default": "./types/api-helpers.d.ts"
|
|
36
|
+
}
|
|
33
37
|
},
|
|
34
38
|
"scripts": {
|
|
35
39
|
"build": "node scripts/build.mjs",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"check": "node scripts/check.mjs",
|
|
40
|
-
"check:lint": "eslint --config .config/eslint.config.mjs --report-unused-disable-directives .",
|
|
41
|
-
"check:lint:fix": "pnpm run check:lint -- --fix",
|
|
42
|
-
"check:tsc": "tsgo --noEmit -p .config/tsconfig.check.json",
|
|
43
|
-
"lint-ci": "pnpm run check:lint",
|
|
44
|
-
"coverage": "node scripts/coverage.mjs",
|
|
45
|
-
"coverage:test": "node scripts/coverage.mjs --code-only",
|
|
46
|
-
"coverage:type": "type-coverage",
|
|
47
|
-
"coverage:type:verbose": "type-coverage --detail",
|
|
48
|
-
"coverage:percent": "node scripts/coverage.mjs --percent",
|
|
40
|
+
"bump": "bash scripts/node-with-loader.sh scripts/bump.mjs",
|
|
41
|
+
"check": "bash scripts/node-with-loader.sh scripts/check.mjs",
|
|
42
|
+
"check-ci": "pnpm run check --all",
|
|
49
43
|
"clean": "node scripts/clean.mjs",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"fix": "node scripts/lint-fix.mjs",
|
|
57
|
-
"generate-sdk": "node scripts/generate-sdk.mjs",
|
|
58
|
-
"generate-sdk:01-prettify": "node scripts/prettify-base-json.mjs",
|
|
59
|
-
"generate-sdk:02-generate": "node scripts/generate-types.mjs > types/api.d.ts",
|
|
60
|
-
"generate-sdk:03-clean-api": "pnpm run fix && pnpm run fix",
|
|
61
|
-
"knip:dependencies": "knip --dependencies",
|
|
62
|
-
"knip:exports": "knip --include exports,duplicates",
|
|
63
|
-
"lint": "oxlint -c=.config/.oxlintrc.json --ignore-path=.config/.oxlintignore --tsconfig=.config/tsconfig.json .",
|
|
64
|
-
"lint:fix": "node scripts/lint-fix.mjs",
|
|
65
|
-
"lint-staged": "lint-staged",
|
|
66
|
-
"precommit": "lint-staged",
|
|
44
|
+
"cover": "bash scripts/node-with-loader.sh scripts/cover.mjs",
|
|
45
|
+
"fix": "node scripts/lint.mjs --fix",
|
|
46
|
+
"generate-sdk": "bash scripts/node-with-loader.sh scripts/generate-sdk.mjs",
|
|
47
|
+
"lint": "node scripts/lint.mjs",
|
|
48
|
+
"lint-ci": "pnpm run lint --all",
|
|
49
|
+
"precommit": "pnpm run check --lint --staged",
|
|
67
50
|
"prepare": "husky",
|
|
68
51
|
"prepublishOnly": "echo 'ERROR: Use GitHub Actions workflow for publishing' && exit 1",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"test
|
|
72
|
-
"test
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"type-ci": "pnpm run check:tsc",
|
|
77
|
-
"test-pre-commit": "dotenvx -q run -f .env.precommit -- node scripts/test-with-build.mjs",
|
|
78
|
-
"update": "run-p --aggregate-output update:*",
|
|
79
|
-
"update:deps": "node scripts/taze.mjs",
|
|
80
|
-
"update:socket": "pnpm -r update '@socketsecurity/*' --latest"
|
|
81
|
-
},
|
|
82
|
-
"dependencies": {
|
|
83
|
-
"@socketsecurity/registry": "1.5.3"
|
|
52
|
+
"publish": "bash scripts/node-with-loader.sh scripts/publish.mjs",
|
|
53
|
+
"claude": "bash scripts/node-with-loader.sh scripts/claude.mjs",
|
|
54
|
+
"test": "node scripts/test.mjs",
|
|
55
|
+
"test-ci": "pnpm run test --all",
|
|
56
|
+
"type": "tsgo --noEmit -p .config/tsconfig.check.json",
|
|
57
|
+
"type-ci": "pnpm run type",
|
|
58
|
+
"update": "bash scripts/node-with-loader.sh scripts/update.mjs"
|
|
84
59
|
},
|
|
85
60
|
"devDependencies": {
|
|
86
|
-
"@babel/
|
|
87
|
-
"@babel/
|
|
88
|
-
"@babel/
|
|
89
|
-
"@babel/runtime": "7.28.4",
|
|
61
|
+
"@babel/parser": "7.26.3",
|
|
62
|
+
"@babel/traverse": "7.26.4",
|
|
63
|
+
"@babel/types": "7.26.3",
|
|
90
64
|
"@biomejs/biome": "2.2.4",
|
|
91
65
|
"@dotenvx/dotenvx": "1.49.0",
|
|
92
66
|
"@eslint/compat": "1.3.2",
|
|
93
67
|
"@eslint/js": "9.35.0",
|
|
94
|
-
"@
|
|
95
|
-
"@
|
|
96
|
-
"@rollup/plugin-json": "6.1.0",
|
|
97
|
-
"@rollup/plugin-node-resolve": "16.0.1",
|
|
68
|
+
"@socketsecurity/lib": "1.0.4",
|
|
69
|
+
"@socketsecurity/registry": "1.5.3",
|
|
98
70
|
"@types/node": "24.6.2",
|
|
99
71
|
"@typescript/native-preview": "7.0.0-dev.20250926.1",
|
|
100
72
|
"@vitest/coverage-v8": "3.2.4",
|
|
101
|
-
"del
|
|
73
|
+
"del": "^8.0.1",
|
|
102
74
|
"dev-null-cli": "2.0.0",
|
|
75
|
+
"esbuild": "0.25.10",
|
|
103
76
|
"eslint": "9.35.0",
|
|
104
77
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
105
78
|
"eslint-plugin-import-x": "4.16.1",
|
|
@@ -111,49 +84,39 @@
|
|
|
111
84
|
"globals": "16.4.0",
|
|
112
85
|
"http2-wrapper": "2.2.1",
|
|
113
86
|
"husky": "9.1.7",
|
|
114
|
-
"
|
|
115
|
-
"lint-staged": "16.1.6",
|
|
87
|
+
"magic-string": "0.30.14",
|
|
116
88
|
"nock": "14.0.10",
|
|
117
89
|
"npm-run-all2": "8.0.4",
|
|
118
90
|
"openapi-typescript": "6.7.6",
|
|
119
|
-
"
|
|
120
|
-
"rollup": "4.50.1",
|
|
91
|
+
"semver": "7.7.2",
|
|
121
92
|
"taze": "19.6.0",
|
|
122
|
-
"trash": "10.0.0",
|
|
123
93
|
"type-coverage": "2.29.7",
|
|
124
94
|
"typescript-eslint": "8.44.1",
|
|
125
95
|
"vitest": "3.2.4",
|
|
126
|
-
"yargs-parser": "22.0.0",
|
|
127
96
|
"yoctocolors-cjs": "2.1.3"
|
|
128
97
|
},
|
|
129
98
|
"pnpm": {
|
|
130
|
-
"overrides": {
|
|
131
|
-
"vite": "7.1.7"
|
|
132
|
-
},
|
|
133
99
|
"ignoredBuiltDependencies": [
|
|
134
100
|
"esbuild",
|
|
135
101
|
"unrs-resolver"
|
|
136
|
-
]
|
|
102
|
+
],
|
|
103
|
+
"overrides": {
|
|
104
|
+
"vite": "7.1.11"
|
|
105
|
+
}
|
|
137
106
|
},
|
|
138
107
|
"engines": {
|
|
139
108
|
"node": ">=18",
|
|
140
109
|
"pnpm": ">=10.16.0"
|
|
141
110
|
},
|
|
142
111
|
"files": [
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
112
|
+
"data/*.json",
|
|
113
|
+
"dist/*{.js,.d.ts}",
|
|
114
|
+
"types/*.d.ts",
|
|
115
|
+
"CHANGELOG.md"
|
|
147
116
|
],
|
|
148
|
-
"lint-staged": {
|
|
149
|
-
"*.{cjs,js,json,md,mjs,mts,ts}": [
|
|
150
|
-
"oxlint -c=.config/.oxlintrc.json --ignore-path=.config/.oxlintignore --tsconfig=.config/tsconfig.json --quiet --fix",
|
|
151
|
-
"biome format --log-level=none --fix --no-errors-on-unmatched --files-ignore-unknown=true --colors=off"
|
|
152
|
-
]
|
|
153
|
-
},
|
|
154
117
|
"typeCoverage": {
|
|
155
118
|
"cache": true,
|
|
156
|
-
"atLeast": 99
|
|
119
|
+
"atLeast": 99,
|
|
157
120
|
"ignoreAsAssertion": true,
|
|
158
121
|
"ignoreCatch": true,
|
|
159
122
|
"ignoreEmptyType": true,
|