brakit 0.7.3 → 0.7.4

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/api.js CHANGED
@@ -1618,7 +1618,7 @@ var AnalysisEngine = class {
1618
1618
  };
1619
1619
 
1620
1620
  // src/index.ts
1621
- var VERSION = "0.7.3";
1621
+ var VERSION = "0.7.4";
1622
1622
  export {
1623
1623
  AdapterRegistry,
1624
1624
  AnalysisEngine,
@@ -693,7 +693,7 @@ import { resolve as resolve2 } from "path";
693
693
  import { randomUUID as randomUUID3 } from "crypto";
694
694
 
695
695
  // src/index.ts
696
- var VERSION = "0.7.3";
696
+ var VERSION = "0.7.4";
697
697
 
698
698
  // src/cli/commands/install.ts
699
699
  var IMPORT_LINE = `import "brakit";`;
@@ -3669,7 +3669,7 @@ var init_src = __esm({
3669
3669
  init_rules();
3670
3670
  init_engine();
3671
3671
  init_insights2();
3672
- VERSION = "0.7.3";
3672
+ VERSION = "0.7.4";
3673
3673
  }
3674
3674
  });
3675
3675
 
@@ -6303,6 +6303,12 @@ function decompress(body, encoding) {
6303
6303
  }
6304
6304
  return body;
6305
6305
  }
6306
+ function toBuffer(chunk) {
6307
+ if (Buffer.isBuffer(chunk)) return chunk;
6308
+ if (chunk instanceof Uint8Array) return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
6309
+ if (typeof chunk === "string") return Buffer.from(chunk);
6310
+ return null;
6311
+ }
6306
6312
  function captureInProcess(req, res, requestId) {
6307
6313
  const startTime = performance.now();
6308
6314
  const method = req.method ?? "GET";
@@ -6314,9 +6320,11 @@ function captureInProcess(req, res, requestId) {
6314
6320
  try {
6315
6321
  const chunk = args[0];
6316
6322
  if (chunk != null && typeof chunk !== "function" && resSize < DEFAULT_MAX_BODY_CAPTURE) {
6317
- const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
6318
- resChunks.push(buf);
6319
- resSize += buf.length;
6323
+ const buf = toBuffer(chunk);
6324
+ if (buf) {
6325
+ resChunks.push(buf);
6326
+ resSize += buf.length;
6327
+ }
6320
6328
  }
6321
6329
  } catch {
6322
6330
  }
@@ -6326,8 +6334,10 @@ function captureInProcess(req, res, requestId) {
6326
6334
  try {
6327
6335
  const chunk = typeof args[0] !== "function" ? args[0] : void 0;
6328
6336
  if (chunk != null && resSize < DEFAULT_MAX_BODY_CAPTURE) {
6329
- const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
6330
- resChunks.push(buf);
6337
+ const buf = toBuffer(chunk);
6338
+ if (buf) {
6339
+ resChunks.push(buf);
6340
+ }
6331
6341
  }
6332
6342
  } catch {
6333
6343
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brakit",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "See what your API is really doing. Security scanning, N+1 detection, duplicate calls, DB queries — one command, zero config.",
5
5
  "type": "module",
6
6
  "bin": {