brakit 0.7.2 → 0.7.3

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.2";
1621
+ var VERSION = "0.7.3";
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.2";
696
+ var VERSION = "0.7.3";
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.2";
3672
+ VERSION = "0.7.3";
3673
3673
  }
3674
3674
  });
3675
3675
 
@@ -6281,6 +6281,7 @@ var init_guard = __esm({
6281
6281
  });
6282
6282
 
6283
6283
  // src/runtime/capture.ts
6284
+ import { gunzipSync, brotliDecompressSync, inflateSync } from "zlib";
6284
6285
  function outgoingToIncoming(headers) {
6285
6286
  const result = {};
6286
6287
  for (const [key, value] of Object.entries(headers)) {
@@ -6293,6 +6294,15 @@ function outgoingToIncoming(headers) {
6293
6294
  }
6294
6295
  return result;
6295
6296
  }
6297
+ function decompress(body, encoding) {
6298
+ try {
6299
+ if (encoding === "gzip") return gunzipSync(body);
6300
+ if (encoding === "br") return brotliDecompressSync(body);
6301
+ if (encoding === "deflate") return inflateSync(body);
6302
+ } catch {
6303
+ }
6304
+ return body;
6305
+ }
6296
6306
  function captureInProcess(req, res, requestId) {
6297
6307
  const startTime = performance.now();
6298
6308
  const method = req.method ?? "GET";
@@ -6323,6 +6333,11 @@ function captureInProcess(req, res, requestId) {
6323
6333
  }
6324
6334
  const result = originalEnd.apply(this, args);
6325
6335
  try {
6336
+ const encoding = String(res.getHeader("content-encoding") ?? "").toLowerCase();
6337
+ let body = resChunks.length > 0 ? Buffer.concat(resChunks) : null;
6338
+ if (body && encoding) {
6339
+ body = decompress(body, encoding);
6340
+ }
6326
6341
  defaultStore.capture({
6327
6342
  requestId,
6328
6343
  method,
@@ -6331,7 +6346,7 @@ function captureInProcess(req, res, requestId) {
6331
6346
  requestBody: null,
6332
6347
  statusCode: res.statusCode,
6333
6348
  responseHeaders: outgoingToIncoming(res.getHeaders()),
6334
- responseBody: resChunks.length > 0 ? Buffer.concat(resChunks) : null,
6349
+ responseBody: body,
6335
6350
  responseContentType: String(res.getHeader("content-type") ?? ""),
6336
6351
  startTime,
6337
6352
  config: { maxBodyCapture: DEFAULT_MAX_BODY_CAPTURE }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brakit",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
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": {