@jaypie/express 1.2.14 → 1.2.16

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.
@@ -1512,6 +1512,11 @@ const decorateResponse = (res, { handler = "", version = process.env.PROJECT_VER
1512
1512
  // about the environment's secret parameters, the special adapter,
1513
1513
  // HTTP, etc. There must be a better way to organize this
1514
1514
 
1515
+ //
1516
+ //
1517
+ // Constants
1518
+ //
1519
+ const SENSITIVE_HEADERS = new Set(["authorization", "cookie", "set-cookie"]);
1515
1520
  //
1516
1521
  //
1517
1522
  // Function Definition
@@ -1522,10 +1527,19 @@ function summarizeRequest(req) {
1522
1527
  if (Buffer.isBuffer(body)) {
1523
1528
  body = body.toString();
1524
1529
  }
1530
+ // Redact sensitive headers
1531
+ const headers = {
1532
+ ...req.headers,
1533
+ };
1534
+ for (const key of Object.keys(headers)) {
1535
+ if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
1536
+ headers[key] = logger$2.redactAuth(headers[key]);
1537
+ }
1538
+ }
1525
1539
  return {
1526
1540
  baseUrl: req.baseUrl,
1527
1541
  body,
1528
- headers: req.headers,
1542
+ headers,
1529
1543
  method: req.method,
1530
1544
  query: req.query,
1531
1545
  url: req.url,
@@ -1795,14 +1809,18 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
1795
1809
  //
1796
1810
  // Preprocess
1797
1811
  //
1812
+ // Build a request-local setup list to avoid mutating the shared array
1813
+ const requestSetup = [];
1798
1814
  // Load secrets into process.env if configured
1799
1815
  if (secrets && secrets.length > 0) {
1800
1816
  const secretsToLoad = secrets;
1801
1817
  const secretsSetup = async () => {
1802
1818
  await aws.loadEnvSecrets(...secretsToLoad);
1803
1819
  };
1804
- setup.unshift(secretsSetup);
1820
+ requestSetup.push(secretsSetup);
1805
1821
  }
1822
+ // Add shared setup functions
1823
+ requestSetup.push(...setup);
1806
1824
  if (locals) {
1807
1825
  // Locals
1808
1826
  const keys = Object.keys(locals);
@@ -1821,7 +1839,7 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
1821
1839
  }
1822
1840
  }
1823
1841
  };
1824
- setup.push(localsSetup);
1842
+ requestSetup.push(localsSetup);
1825
1843
  }
1826
1844
  }
1827
1845
  let response;
@@ -1832,7 +1850,7 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
1832
1850
  jaypieFunction = kit.jaypieHandler(handler, {
1833
1851
  chaos,
1834
1852
  name,
1835
- setup,
1853
+ setup: requestSetup,
1836
1854
  teardown,
1837
1855
  unavailable,
1838
1856
  validate,
@@ -2143,14 +2161,18 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
2143
2161
  //
2144
2162
  // Preprocess
2145
2163
  //
2164
+ // Build a request-local setup list to avoid mutating the shared array
2165
+ const requestSetup = [];
2146
2166
  // Load secrets into process.env if configured
2147
2167
  if (secrets && secrets.length > 0) {
2148
2168
  const secretsToLoad = secrets;
2149
2169
  const secretsSetup = async () => {
2150
2170
  await aws.loadEnvSecrets(...secretsToLoad);
2151
2171
  };
2152
- setup.unshift(secretsSetup);
2172
+ requestSetup.push(secretsSetup);
2153
2173
  }
2174
+ // Add shared setup functions
2175
+ requestSetup.push(...setup);
2154
2176
  if (locals) {
2155
2177
  const keys = Object.keys(locals);
2156
2178
  if (keys.length > 0) {
@@ -2168,7 +2190,7 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
2168
2190
  }
2169
2191
  }
2170
2192
  };
2171
- setup.push(localsSetup);
2193
+ requestSetup.push(localsSetup);
2172
2194
  }
2173
2195
  }
2174
2196
  try {
@@ -2176,7 +2198,7 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
2176
2198
  jaypieFunction = kit.jaypieHandler(handler, {
2177
2199
  chaos,
2178
2200
  name,
2179
- setup,
2201
+ setup: requestSetup,
2180
2202
  teardown,
2181
2203
  unavailable,
2182
2204
  validate,