@socketsecurity/sdk
Advanced tools
Comparing version
@@ -208,2 +208,10 @@ import events from 'node:events'; | ||
} | ||
function desc(value) { | ||
return { | ||
__proto__: null, | ||
configurable: true, | ||
value, | ||
writable: true | ||
}; | ||
} | ||
function getHttpModule(baseUrl) { | ||
@@ -258,2 +266,15 @@ const { protocol } = new URL(baseUrl); | ||
} | ||
function promiseWithResolvers() { | ||
if (Promise.withResolvers) { | ||
return Promise.withResolvers(); | ||
} | ||
// This is what the above does but it's not available in node 20 (it is in node 22) | ||
// @ts-ignore -- sigh. | ||
const obj = {}; | ||
obj.promise = new Promise((resolver, reject) => { | ||
obj.resolve = resolver; | ||
obj.reject = reject; | ||
}); | ||
return obj; | ||
} | ||
function resolveAbsPaths(filepaths, pathsRelativeTo) { | ||
@@ -506,3 +527,3 @@ const basePath = resolveBasePath(pathsRelativeTo); | ||
} | ||
async createReportFromFilepaths(filepaths, pathsRelativeTo = '.', issueRules) { | ||
async createScanFromFilepaths(filepaths, pathsRelativeTo = '.', issueRules) { | ||
const basePath = resolveBasePath(pathsRelativeTo); | ||
@@ -526,6 +547,2 @@ const absFilepaths = resolveAbsPaths(filepaths, basePath); | ||
} | ||
// Alias to preserve backwards compatibility. | ||
async createReportFromFilePaths(filepaths, pathsRelativeTo = '.', issueRules) { | ||
return await this.createReportFromFilepaths(filepaths, pathsRelativeTo, issueRules); | ||
} | ||
async deleteOrgFullScan(orgSlug, fullScanId) { | ||
@@ -680,3 +697,3 @@ try { | ||
} | ||
async getReport(id) { | ||
async getScan(id) { | ||
try { | ||
@@ -690,3 +707,3 @@ const data = await getResponseJson(await createGetRequest(this.#baseUrl, `report/view/${encodeURIComponent(id)}`, this.#reqOptions)); | ||
} | ||
async getReportList() { | ||
async getScanList() { | ||
try { | ||
@@ -700,3 +717,3 @@ const data = await getResponseJson(await createGetRequest(this.#baseUrl, 'report/list', this.#reqOptions)); | ||
} | ||
async getReportSupportedFiles() { | ||
async getSupportedScanFiles() { | ||
try { | ||
@@ -710,3 +727,3 @@ const data = await getResponseJson(await createGetRequest(this.#baseUrl, 'report/supported', this.#reqOptions)); | ||
} | ||
async getScoreByNPMPackage(pkgName, version) { | ||
async getScoreByNpmPackage(pkgName, version) { | ||
try { | ||
@@ -747,16 +764,23 @@ const data = await getResponseJson(await createGetRequest(this.#baseUrl, `npm/${encodeURIComponent(pkgName)}/${encodeURIComponent(version)}/score`, this.#reqOptions)); | ||
} | ||
} | ||
function promiseWithResolvers() { | ||
if (Promise.withResolvers) { | ||
return Promise.withResolvers(); | ||
async uploadManifestFiles(orgSlug, filepaths, pathsRelativeTo = '.') { | ||
const basePath = resolveBasePath(pathsRelativeTo); | ||
const absFilepaths = resolveAbsPaths(filepaths, basePath); | ||
try { | ||
const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
} | ||
catch (e) { | ||
return (await this.#handleApiError(e)); | ||
} | ||
} | ||
// This is what the above does but it's not available in node 20 (it is in node 22) | ||
// @ts-ignore -- sigh. | ||
const obj = {}; | ||
obj.promise = new Promise((resolver, reject) => { | ||
obj.resolve = resolver; | ||
obj.reject = reject; | ||
}); | ||
return obj; | ||
} | ||
// Add aliases. | ||
Object.defineProperties(SocketSdk.prototype, { | ||
createReportFromFilepaths: desc(SocketSdk.prototype.createScanFromFilepaths), | ||
createReportFromFilePaths: desc(SocketSdk.prototype.createScanFromFilepaths), | ||
getReport: desc(SocketSdk.prototype.getScan), | ||
getReportList: desc(SocketSdk.prototype.getScanList), | ||
getReportSupportedFiles: desc(SocketSdk.prototype.getSupportedScanFiles), | ||
getScoreByNPMPackage: desc(SocketSdk.prototype.getScoreByNpmPackage) | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@socketsecurity/sdk", | ||
"version": "1.4.57", | ||
"version": "1.4.58", | ||
"license": "MIT", | ||
@@ -86,10 +86,10 @@ "description": "SDK for the Socket API client", | ||
"dependencies": { | ||
"@socketsecurity/registry": "1.0.239" | ||
"@socketsecurity/registry": "1.0.243" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "2.1.2", | ||
"@dotenvx/dotenvx": "1.48.0", | ||
"@dotenvx/dotenvx": "1.48.2", | ||
"@eslint/compat": "1.3.1", | ||
"@eslint/js": "9.31.0", | ||
"@types/node": "24.0.14", | ||
"@types/node": "24.0.15", | ||
"@typescript-eslint/parser": "8.37.0", | ||
@@ -108,5 +108,5 @@ "@vitest/coverage-v8": "3.2.4", | ||
"husky": "9.1.7", | ||
"knip": "5.61.3", | ||
"knip": "5.62.0", | ||
"lint-staged": "16.1.2", | ||
"nock": "14.0.5", | ||
"nock": "14.0.6", | ||
"npm-run-all2": "8.0.4", | ||
@@ -113,0 +113,0 @@ "openapi-typescript": "6.7.6", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
627245
0.82%14995
0.32%+ Added
- Removed