@socketsecurity/sdk
Advanced tools
Comparing version
@@ -278,2 +278,17 @@ import events from 'node:events'; | ||
} | ||
function queryToSearchParams(init) { | ||
const params = new URLSearchParams(init ?? ''); | ||
const normalized = {}; | ||
for (const entry of params.entries()) { | ||
let key = entry[0]; | ||
if (key === 'defaultBranch') { | ||
key = 'default_branch'; | ||
} | ||
else if (key === 'perPage') { | ||
key = 'per_page'; | ||
} | ||
normalized[key] = entry[1]; | ||
} | ||
return new URLSearchParams(normalized); | ||
} | ||
function resolveAbsPaths(filepaths, pathsRelativeTo) { | ||
@@ -329,3 +344,3 @@ const basePath = resolveBasePath(pathsRelativeTo); | ||
const req = getHttpModule(this.#baseUrl) | ||
.request(`${this.#baseUrl}purl?${new URLSearchParams(queryParams ?? '')}`, { | ||
.request(`${this.#baseUrl}purl?${queryToSearchParams(queryParams)}`, { | ||
method: 'POST', | ||
@@ -496,7 +511,7 @@ ...this.#reqOptions | ||
} | ||
async createDependenciesSnapshot(params, filepaths, pathsRelativeTo = '.') { | ||
async createDependenciesSnapshot(queryParams, filepaths, pathsRelativeTo = '.') { | ||
const basePath = resolveBasePath(pathsRelativeTo); | ||
const absFilepaths = resolveAbsPaths(filepaths, basePath); | ||
try { | ||
const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `dependencies/upload?${new URLSearchParams(params)}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions)); | ||
const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `dependencies/upload?${queryToSearchParams(queryParams)}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -512,3 +527,3 @@ } | ||
try { | ||
const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${new URLSearchParams(queryParams ?? '')}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions)); | ||
const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(queryParams)}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -520,5 +535,5 @@ } | ||
} | ||
async createOrgRepo(orgSlug, params) { | ||
async createOrgRepo(orgSlug, queryParams) { | ||
try { | ||
const data = await getResponseJson(await createPostRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos`, params, this.#reqOptions)); | ||
const data = await getResponseJson(await createPostRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos`, queryParams, this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -569,3 +584,3 @@ } | ||
try { | ||
const data = await getResponseJson(await createGetRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/audit-log?${new URLSearchParams(queryParams ?? '')}`, this.#reqOptions)); | ||
const data = await getResponseJson(await createGetRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/audit-log?${queryToSearchParams(queryParams)}`, this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -627,3 +642,3 @@ } | ||
try { | ||
const data = await getResponseJson(await createGetRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${new URLSearchParams(queryParams ?? '')}`, this.#reqOptions)); | ||
const data = await getResponseJson(await createGetRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(queryParams)}`, this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -666,3 +681,3 @@ } | ||
try { | ||
const data = await getResponseJson(await createGetRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos?${new URLSearchParams(queryParams ?? '')}`, this.#reqOptions)); | ||
const data = await getResponseJson(await createGetRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos?${queryToSearchParams(queryParams)}`, this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -746,5 +761,5 @@ } | ||
} | ||
async searchDependencies(params) { | ||
async searchDependencies(queryParams) { | ||
try { | ||
const data = await getResponseJson(await createPostRequest(this.#baseUrl, 'dependencies/search', params, this.#reqOptions)); | ||
const data = await getResponseJson(await createPostRequest(this.#baseUrl, 'dependencies/search', queryParams, this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -756,5 +771,5 @@ } | ||
} | ||
async updateOrgRepo(orgSlug, repoSlug, params) { | ||
async updateOrgRepo(orgSlug, repoSlug, queryParams) { | ||
try { | ||
const data = await getResponseJson(await createPostRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`, params, this.#reqOptions)); | ||
const data = await getResponseJson(await createPostRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos/${encodeURIComponent(repoSlug)}`, queryParams, this.#reqOptions)); | ||
return this.#handleApiSuccess(data); | ||
@@ -761,0 +776,0 @@ } |
{ | ||
"name": "@socketsecurity/sdk", | ||
"version": "1.4.60", | ||
"version": "1.4.61", | ||
"license": "MIT", | ||
@@ -94,3 +94,3 @@ "description": "SDK for the Socket API client", | ||
"@types/node": "24.0.15", | ||
"@typescript-eslint/parser": "8.37.0", | ||
"@typescript-eslint/parser": "8.38.0", | ||
"@vitest/coverage-v8": "3.2.4", | ||
@@ -116,3 +116,3 @@ "del-cli": "6.0.0", | ||
"typescript": "~5.8.3", | ||
"typescript-eslint": "8.37.0", | ||
"typescript-eslint": "8.38.0", | ||
"vitest": "3.2.4" | ||
@@ -119,0 +119,0 @@ }, |
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
630174
0.28%15028
0.2%