@jaypie/express 1.2.14 → 1.2.15

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.
@@ -2,7 +2,7 @@ import type { Request } from "express";
2
2
  export interface RequestSummary {
3
3
  baseUrl: string;
4
4
  body: unknown;
5
- headers: Request["headers"];
5
+ headers: Record<string, string | string[] | undefined>;
6
6
  method: string;
7
7
  query: Request["query"];
8
8
  url: string;
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { CorsError, BadRequestError, UnhandledError, GatewayTimeoutError, Unavai
4
4
  import { force, envBoolean, JAYPIE, HTTP, getHeaderFrom, jaypieHandler } from '@jaypie/kit';
5
5
  import expressCors from 'cors';
6
6
  import { loadEnvSecrets, getContentTypeForFormat, formatStreamError } from '@jaypie/aws';
7
- import { log } from '@jaypie/logger';
7
+ import { log, redactAuth } from '@jaypie/logger';
8
8
  import { hasDatadogEnv, submitMetric, DATADOG } from '@jaypie/datadog';
9
9
 
10
10
  //
@@ -1510,6 +1510,11 @@ const decorateResponse = (res, { handler = "", version = process.env.PROJECT_VER
1510
1510
  // about the environment's secret parameters, the special adapter,
1511
1511
  // HTTP, etc. There must be a better way to organize this
1512
1512
 
1513
+ //
1514
+ //
1515
+ // Constants
1516
+ //
1517
+ const SENSITIVE_HEADERS = new Set(["authorization", "cookie", "set-cookie"]);
1513
1518
  //
1514
1519
  //
1515
1520
  // Function Definition
@@ -1520,10 +1525,19 @@ function summarizeRequest(req) {
1520
1525
  if (Buffer.isBuffer(body)) {
1521
1526
  body = body.toString();
1522
1527
  }
1528
+ // Redact sensitive headers
1529
+ const headers = {
1530
+ ...req.headers,
1531
+ };
1532
+ for (const key of Object.keys(headers)) {
1533
+ if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
1534
+ headers[key] = redactAuth(headers[key]);
1535
+ }
1536
+ }
1523
1537
  return {
1524
1538
  baseUrl: req.baseUrl,
1525
1539
  body,
1526
- headers: req.headers,
1540
+ headers,
1527
1541
  method: req.method,
1528
1542
  query: req.query,
1529
1543
  url: req.url,