@socketsecurity/cli-with-sentry 1.1.25 → 1.1.26

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/dist/vendor.js CHANGED
@@ -27712,7 +27712,7 @@ var isInteractiveExports = /*@__PURE__*/ requireIsInteractive();
27712
27712
  var dist$e = {};
27713
27713
 
27714
27714
  var name$4 = "@socketsecurity/sdk";
27715
- var version$8 = "1.4.93";
27715
+ var version$8 = "1.4.94";
27716
27716
  var license = "MIT";
27717
27717
  var description = "SDK for the Socket API client";
27718
27718
  var author = {
@@ -27761,7 +27761,7 @@ var scripts = {
27761
27761
  "build:esm": "dotenvx -q run -f .env.local -- tsc -p tsconfig.esm.json",
27762
27762
  "build:clean:cjs": "dotenvx -q run -f .env.local -- node scripts/rename-dist-cjs-files.mjs",
27763
27763
  "build:clean:esm": "dotenvx -q run -f .env.local -- node scripts/rename-dist-esm-files.mjs",
27764
- check: "run-p -c --aggregate-output check:*",
27764
+ check: "node scripts/check.mjs",
27765
27765
  "check:lint": "dotenvx -q run -f .env.local -- eslint --report-unused-disable-directives .",
27766
27766
  "check:lint:fix": "npm run check:lint -- --fix",
27767
27767
  "check:tsc": "dotenvx -q run -f .env.local -- tsc",
@@ -27778,7 +27778,7 @@ var scripts = {
27778
27778
  "generate-sdk:03-clean-api": "npm run fix && npm run fix",
27779
27779
  "knip:dependencies": "knip --dependencies",
27780
27780
  "knip:exports": "knip --include exports,duplicates",
27781
- lint: "dotenvx -q run -f .env.local -- oxlint -c=.oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json .",
27781
+ lint: "node scripts/lint.mjs",
27782
27782
  "lint:fix": "run-s -c lint:fix:*",
27783
27783
  "lint:fix:oxlint": "dotenvx -q run -f .env.local -- oxlint -c=.oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json --quiet --fix . | dev-null",
27784
27784
  "lint:fix:biome": "dotenvx -q run -f .env.local -- biome format --log-level=none --fix . | dev-null",
@@ -27787,7 +27787,8 @@ var scripts = {
27787
27787
  precommit: "lint-staged",
27788
27788
  prepare: "dotenvx -q run -f .env.local -- husky",
27789
27789
  prepublishOnly: "run-s build",
27790
- test: "run-s check test:*",
27790
+ "publish:ci": "node scripts/publish.mjs --skip-checks",
27791
+ test: "node scripts/test.mjs",
27791
27792
  "test:prepare": "dotenvx -q run -f .env.test -- npm run build",
27792
27793
  "test:unit": "dotenvx -q run -f .env.test -- vitest --run",
27793
27794
  "test:unit:update": "dotenvx -q run -f .env.test -- vitest --run --update",
@@ -28014,6 +28015,42 @@ function requireDist$e () {
28014
28015
  ['usesEval', 'ignore'],
28015
28016
  ['zeroWidth', 'ignore']
28016
28017
  ]);
28018
+ /**
28019
+ * Array of sensitive header names that should be redacted in logs
28020
+ */
28021
+ const SENSITIVE_HEADERS = [
28022
+ 'authorization',
28023
+ 'cookie',
28024
+ 'set-cookie',
28025
+ 'proxy-authorization',
28026
+ 'www-authenticate',
28027
+ 'proxy-authenticate',
28028
+ ];
28029
+ /**
28030
+ * Sanitize headers for logging by redacting sensitive values.
28031
+ */
28032
+ function sanitizeHeaders(headers) {
28033
+ if (!headers) {
28034
+ return undefined;
28035
+ }
28036
+ // Handle readonly string[] case - this shouldn't normally happen for headers
28037
+ if (Array.isArray(headers)) {
28038
+ return { headers: headers.join(', ') };
28039
+ }
28040
+ const sanitized = {};
28041
+ // Plain object iteration works for both HeadersRecord and IncomingHttpHeaders
28042
+ for (const [key, value] of Object.entries(headers)) {
28043
+ const keyLower = key.toLowerCase();
28044
+ if (SENSITIVE_HEADERS.includes(keyLower)) {
28045
+ sanitized[key] = '[REDACTED]';
28046
+ }
28047
+ else {
28048
+ // Handle both string and string[] values
28049
+ sanitized[key] = Array.isArray(value) ? value.join(', ') : String(value);
28050
+ }
28051
+ }
28052
+ return sanitized;
28053
+ }
28017
28054
  class ResponseError extends Error {
28018
28055
  response;
28019
28056
  constructor(response, message = '') {
@@ -28025,32 +28062,114 @@ function requireDist$e () {
28025
28062
  Error.captureStackTrace(this, ResponseError);
28026
28063
  }
28027
28064
  }
28028
- async function createDeleteRequest(baseUrl, urlPath, options) {
28029
- const req = getHttpModule(baseUrl)
28030
- .request(`${baseUrl}${urlPath}`, {
28031
- method: 'DELETE',
28032
- ...options
28033
- })
28034
- .end();
28035
- return await getResponse(req);
28065
+ async function createDeleteRequest(baseUrl, urlPath, options, hooks) {
28066
+ const startTime = Date.now();
28067
+ const url = `${baseUrl}${urlPath}`;
28068
+ const method = 'DELETE';
28069
+ try {
28070
+ const req = getHttpModule(baseUrl)
28071
+ .request(url, {
28072
+ method,
28073
+ ...options
28074
+ })
28075
+ .end();
28076
+ const response = await getResponse(req);
28077
+ hooks?.onResponse?.({
28078
+ method,
28079
+ url,
28080
+ duration: Date.now() - startTime,
28081
+ status: response.statusCode,
28082
+ statusText: response.statusMessage,
28083
+ headers: sanitizeHeaders(response.headers),
28084
+ });
28085
+ return response;
28086
+ }
28087
+ catch (error) {
28088
+ throw error;
28089
+ }
28036
28090
  }
28037
- async function createGetRequest(baseUrl, urlPath, options) {
28038
- const req = getHttpModule(baseUrl)
28039
- .request(`${baseUrl}${urlPath}`, {
28040
- method: 'GET',
28041
- ...options
28042
- })
28043
- .end();
28044
- return await getResponse(req);
28091
+ async function createGetRequest(baseUrl, urlPath, options, hooks) {
28092
+ const startTime = Date.now();
28093
+ const url = `${baseUrl}${urlPath}`;
28094
+ const method = 'GET';
28095
+ hooks?.onRequest?.({
28096
+ method,
28097
+ url,
28098
+ headers: sanitizeHeaders(options.headers),
28099
+ timeout: options.timeout,
28100
+ });
28101
+ try {
28102
+ const req = getHttpModule(baseUrl)
28103
+ .request(url, {
28104
+ method,
28105
+ ...options
28106
+ })
28107
+ .end();
28108
+ const response = await getResponse(req);
28109
+ hooks?.onResponse?.({
28110
+ method,
28111
+ url,
28112
+ duration: Date.now() - startTime,
28113
+ status: response.statusCode,
28114
+ statusText: response.statusMessage,
28115
+ headers: sanitizeHeaders(response.headers),
28116
+ });
28117
+ return response;
28118
+ }
28119
+ catch (error) {
28120
+ hooks?.onResponse?.({
28121
+ method,
28122
+ url,
28123
+ duration: Date.now() - startTime,
28124
+ error: error,
28125
+ });
28126
+ throw error;
28127
+ }
28045
28128
  }
28046
- async function createPostRequest(baseUrl, urlPath, postJson, options) {
28047
- const req = getHttpModule(baseUrl)
28048
- .request(`${baseUrl}${urlPath}`, {
28049
- method: 'POST',
28050
- ...options
28051
- })
28052
- .end(JSON.stringify(postJson));
28053
- return await getResponse(req);
28129
+ async function createPostRequest(baseUrl, urlPath, postJson, options, hooks) {
28130
+ const startTime = Date.now();
28131
+ const url = `${baseUrl}${urlPath}`;
28132
+ const method = 'POST';
28133
+ const body = JSON.stringify(postJson);
28134
+ const headers = {
28135
+ ...options?.headers,
28136
+ 'Content-Length': Buffer.byteLength(body, 'utf8'),
28137
+ 'Content-Type': 'application/json',
28138
+ };
28139
+ hooks?.onRequest?.({
28140
+ method,
28141
+ url,
28142
+ headers: sanitizeHeaders(headers),
28143
+ timeout: options.timeout,
28144
+ });
28145
+ try {
28146
+ const req = getHttpModule(baseUrl).request(url, {
28147
+ method,
28148
+ ...options,
28149
+ headers,
28150
+ });
28151
+ req.write(body);
28152
+ req.end();
28153
+ const response = await getResponse(req);
28154
+ hooks?.onResponse?.({
28155
+ method,
28156
+ url,
28157
+ duration: Date.now() - startTime,
28158
+ status: response.statusCode,
28159
+ statusText: response.statusMessage,
28160
+ headers: sanitizeHeaders(response.headers),
28161
+ });
28162
+ return response;
28163
+ }
28164
+ catch (error) {
28165
+ hooks?.onResponse?.({
28166
+ method,
28167
+ url,
28168
+ duration: Date.now() - startTime,
28169
+ error: error,
28170
+ });
28171
+ throw error;
28172
+ }
28054
28173
  }
28055
28174
  function createRequestBodyForFilepaths(filepaths, basePath) {
28056
28175
  const requestBody = [];
@@ -28075,7 +28194,7 @@ function requireDist$e () {
28075
28194
  '\r\n'
28076
28195
  ];
28077
28196
  }
28078
- async function createUploadRequest(baseUrl, urlPath, requestBodyNoBoundaries, options) {
28197
+ async function createUploadRequest(baseUrl, urlPath, requestBodyNoBoundaries, options, hooks) {
28079
28198
  // This function constructs and sends a multipart/form-data HTTP POST request
28080
28199
  // where each part is streamed to the server. It supports string payloads
28081
28200
  // and readable streams (e.g., large file uploads).
@@ -28102,18 +28221,45 @@ function requireDist$e () {
28102
28221
  finalBoundary
28103
28222
  ];
28104
28223
  const url = new URL(urlPath, baseUrl);
28224
+ const method = 'POST';
28225
+ const headers = {
28226
+ ...options?.headers,
28227
+ 'Content-Type': `multipart/form-data; boundary=${boundary}`,
28228
+ };
28229
+ const startTime = Date.now();
28105
28230
  const req = getHttpModule(baseUrl).request(url, {
28106
- method: 'POST',
28231
+ method,
28107
28232
  ...options,
28108
- headers: {
28109
- ...options?.headers,
28110
- 'Content-Type': `multipart/form-data; boundary=${boundary}`
28111
- }
28233
+ headers,
28234
+ });
28235
+ hooks?.onRequest?.({
28236
+ method,
28237
+ url: url.toString(),
28238
+ headers: sanitizeHeaders(headers),
28239
+ timeout: options.timeout,
28112
28240
  });
28113
28241
  // Send headers early to prompt server validation (auth, URL, quota, etc.).
28114
28242
  req.flushHeaders();
28115
28243
  // Concurrently wait for response while we stream body.
28116
- getResponse(req).then(pass, fail);
28244
+ getResponse(req).then(response => {
28245
+ hooks?.onResponse?.({
28246
+ method,
28247
+ url: url.toString(),
28248
+ duration: Date.now() - startTime,
28249
+ status: response.statusCode,
28250
+ statusText: response.statusMessage,
28251
+ headers: sanitizeHeaders(response.headers),
28252
+ });
28253
+ pass(response);
28254
+ }, error => {
28255
+ hooks?.onResponse?.({
28256
+ method,
28257
+ url: url.toString(),
28258
+ duration: Date.now() - startTime,
28259
+ error: error,
28260
+ });
28261
+ fail(error);
28262
+ });
28117
28263
  let aborted = false;
28118
28264
  req.on('error', () => (aborted = true));
28119
28265
  req.on('close', () => (aborted = true));
@@ -28354,9 +28500,10 @@ function requireDist$e () {
28354
28500
  class SocketSdk {
28355
28501
  #apiToken;
28356
28502
  #baseUrl;
28503
+ #hooks;
28357
28504
  #reqOptions;
28358
28505
  constructor(apiToken, options) {
28359
- const { agent: agentOrObj, baseUrl = 'https://api.socket.dev/v0/', timeout, userAgent } = { __proto__: null, ...options };
28506
+ const { agent: agentOrObj, baseUrl = 'https://api.socket.dev/v0/', hooks, timeout, userAgent } = { __proto__: null, ...options };
28360
28507
  const agentKeys = agentOrObj ? Object.keys(agentOrObj) : [];
28361
28508
  const agentAsGotOptions = agentOrObj;
28362
28509
  const agent = (agentKeys.length && agentKeys.every(k => agentNames.has(k))
@@ -28366,6 +28513,7 @@ function requireDist$e () {
28366
28513
  : agentOrObj);
28367
28514
  this.#apiToken = apiToken;
28368
28515
  this.#baseUrl = baseUrl;
28516
+ this.#hooks = hooks;
28369
28517
  this.#reqOptions = {
28370
28518
  ...(agent ? { agent } : {}),
28371
28519
  headers: {
@@ -28594,7 +28742,7 @@ function requireDist$e () {
28594
28742
  const basePath = resolveBasePath(pathsRelativeTo);
28595
28743
  const absFilepaths = resolveAbsPaths(filepaths, basePath);
28596
28744
  try {
28597
- const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `dependencies/upload?${queryToSearchParams(queryParams)}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions));
28745
+ const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `dependencies/upload?${queryToSearchParams(queryParams)}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions, this.#hooks));
28598
28746
  return this.#handleApiSuccess(data);
28599
28747
  }
28600
28748
  catch (e) {
@@ -28614,7 +28762,7 @@ function requireDist$e () {
28614
28762
  const basePath = resolveBasePath(pathsRelativeTo);
28615
28763
  const absFilepaths = resolveAbsPaths(filepaths, basePath);
28616
28764
  try {
28617
- const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(queryParams)}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions));
28765
+ const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/full-scans?${queryToSearchParams(queryParams)}`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions, this.#hooks));
28618
28766
  return this.#handleApiSuccess(data);
28619
28767
  }
28620
28768
  catch (e) {
@@ -28623,7 +28771,7 @@ function requireDist$e () {
28623
28771
  }
28624
28772
  async createOrgRepo(orgSlug, queryParams) {
28625
28773
  try {
28626
- const data = await getResponseJson(await createPostRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos`, queryParams, this.#reqOptions));
28774
+ const data = await getResponseJson(await createPostRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/repos`, queryParams, this.#reqOptions, this.#hooks));
28627
28775
  return this.#handleApiSuccess(data);
28628
28776
  }
28629
28777
  catch (e) {
@@ -28642,7 +28790,7 @@ function requireDist$e () {
28642
28790
  ], {
28643
28791
  ...this.#reqOptions,
28644
28792
  method: 'PUT'
28645
- });
28793
+ }, this.#hooks);
28646
28794
  return this.#handleApiSuccess(data);
28647
28795
  }
28648
28796
  catch (e) {
@@ -28782,7 +28930,7 @@ function requireDist$e () {
28782
28930
  }
28783
28931
  async getQuota() {
28784
28932
  try {
28785
- const data = await getResponseJson(await createGetRequest(this.#baseUrl, 'quota', this.#reqOptions));
28933
+ const data = await getResponseJson(await createGetRequest(this.#baseUrl, 'quota', this.#reqOptions, this.#hooks));
28786
28934
  return this.#handleApiSuccess(data);
28787
28935
  }
28788
28936
  catch (e) {
@@ -28865,7 +29013,7 @@ function requireDist$e () {
28865
29013
  const basePath = resolveBasePath(pathsRelativeTo);
28866
29014
  const absFilepaths = resolveAbsPaths(filepaths, basePath);
28867
29015
  try {
28868
- const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions));
29016
+ const data = await getResponseJson(await createUploadRequest(this.#baseUrl, `orgs/${encodeURIComponent(orgSlug)}/upload-manifest-files`, createRequestBodyForFilepaths(absFilepaths, basePath), this.#reqOptions, this.#hooks));
28869
29017
  return this.#handleApiSuccess(data);
28870
29018
  }
28871
29019
  catch (e) {
@@ -162070,5 +162218,5 @@ exports.terminalLinkExports = terminalLinkExports;
162070
162218
  exports.updater = updater$1;
162071
162219
  exports.yargsParser = yargsParser;
162072
162220
  exports.yoctocolorsCjsExports = yoctocolorsCjsExports;
162073
- //# debugId=9a6302b5-f211-4b16-8677-590380a490f0
162221
+ //# debugId=3d614f77-809d-4117-9e22-04bd010c12f2
162074
162222
  //# sourceMappingURL=vendor.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/cli-with-sentry",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "CLI for Socket.dev, includes Sentry error handling, otherwise identical to the regular `socket` package",
5
5
  "homepage": "https://github.com/SocketDev/socket-cli",
6
6
  "license": "MIT AND OFL-1.1",
@@ -122,7 +122,7 @@
122
122
  "@socketregistry/packageurl-js": "1.0.9",
123
123
  "@socketsecurity/config": "3.0.1",
124
124
  "@socketsecurity/registry": "1.1.17",
125
- "@socketsecurity/sdk": "1.4.93",
125
+ "@socketsecurity/sdk": "1.4.94",
126
126
  "@types/blessed": "0.1.25",
127
127
  "@types/cmd-shim": "5.0.2",
128
128
  "@types/js-yaml": "4.0.9",
@@ -290,6 +290,6 @@
290
290
  "strict": true
291
291
  },
292
292
  "dependencies": {
293
- "@sentry/node": "10.19.0"
293
+ "@sentry/node": "10.23.0"
294
294
  }
295
295
  }