@socketsecurity/sdk
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -52,2 +52,12 @@ export type SocketSdkOperations = keyof import('./types/api').operations; | ||
}): Promise<SocketSdkResultType<'updateOrgRepo'>>; | ||
batchPackageFetch(queryParams: { | ||
[key: string]: string; | ||
}, components: { | ||
components: { | ||
purl: string; | ||
}[]; | ||
}): Promise<SocketSdkResultType<'batchPackageFetch'>>; | ||
searchDependencies(params: { | ||
[key: string]: number; | ||
}): Promise<SocketSdkResultType<'searchDependencies'>>; | ||
postSettings(selectors: Array<{ | ||
@@ -54,0 +64,0 @@ organization?: string; |
37
index.js
@@ -496,2 +496,39 @@ 'use strict' | ||
/** | ||
* @param {{[key: string]: string }} queryParams | ||
* @param {{components: {purl: string}[] }} components | ||
* @returns {Promise<SocketSdkResultType<'batchPackageFetch'>>} | ||
*/ | ||
async batchPackageFetch (queryParams, components) { | ||
const formattedQueryParam = new URLSearchParams(queryParams) | ||
try { | ||
const client = await this.#getClient() | ||
const data = await client.post(`purl?${formattedQueryParam}`, { json: components }) | ||
// Parse the ndjson response | ||
const /** @type {{[key: string]: any}[]} */ resp_json = [] | ||
const ndjson = data.body.split('\n') | ||
ndjson.map(o => o && resp_json.push(JSON.parse(o))) | ||
return { success: true, status: 200, data: resp_json } | ||
} catch (err) { | ||
return /** @type {SocketSdkErrorType<'batchPackageFetch'>} */ (this.#handleApiError(err)) | ||
} | ||
} | ||
/** | ||
* @param {{[key: string]: number }} params | ||
* @returns {Promise<SocketSdkResultType<'searchDependencies'>>} | ||
*/ | ||
async searchDependencies (params) { | ||
try { | ||
const client = await this.#getClient() | ||
const data = await client.post('dependencies/search', { json: params }).json() | ||
return { success: true, status: 200, data } | ||
} catch (err) { | ||
return /** @type {SocketSdkErrorType<'searchDependencies'>} */ (this.#handleApiError(err)) | ||
} | ||
} | ||
/** | ||
* @param {Array<{ organization?: string }>} selectors | ||
@@ -498,0 +535,0 @@ * @returns {Promise<SocketSdkResultType<'postSettings'>>} |
{ | ||
"name": "@socketsecurity/sdk", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "SDK for the Socket API client", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145297
4196