@middy/input-output-logger 4.6.1 → 4.6.2

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.
Files changed (3) hide show
  1. package/index.cjs +8 -2
  2. package/index.js +8 -2
  3. package/package.json +4 -4
package/index.cjs CHANGED
@@ -32,7 +32,8 @@ const inputOutputLoggerMiddleware = (opts = {})=>{
32
32
  if (awsContext) {
33
33
  message.context = pick(request.context, awsContextKeys);
34
34
  }
35
- const cloneMessage = (0, _util.jsonSafeParse)((0, _util.jsonSafeStringify)(message, replacer));
35
+ const cloneMessage = (0, _util.jsonSafeParse)((0, _util.jsonSafeStringify)(message, replacer)) // Full clone to prevent nested mutations
36
+ ;
36
37
  omit(cloneMessage, {
37
38
  [param]: omitPathTree[param]
38
39
  });
@@ -69,6 +70,7 @@ const inputOutputLoggerMiddleware = (opts = {})=>{
69
70
  onError: inputOutputLoggerMiddlewareOnError
70
71
  };
71
72
  };
73
+ // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html
72
74
  const awsContextKeys = [
73
75
  'functionName',
74
76
  'functionVersion',
@@ -81,9 +83,11 @@ const awsContextKeys = [
81
83
  'clientContext',
82
84
  'callbackWaitsForEmptyEventLoop'
83
85
  ];
86
+ // move to util, if ever used elsewhere
84
87
  const pick = (originalObject = {}, keysToPick = [])=>{
85
88
  const newObject = {};
86
89
  for (const path of keysToPick){
90
+ // only supports first level
87
91
  if (originalObject[path] !== undefined) {
88
92
  newObject[path] = originalObject[path];
89
93
  }
@@ -93,9 +97,11 @@ const pick = (originalObject = {}, keysToPick = [])=>{
93
97
  const buildPathTree = (paths)=>{
94
98
  const tree = {};
95
99
  for (let path of paths.sort().reverse()){
100
+ // reverse to ensure conflicting paths don't cause issues
96
101
  if (!Array.isArray(path)) path = path.split('.');
97
102
  if (path.includes('__proto__')) continue;
98
- path.slice(0).reduce((a, b, idx)=>{
103
+ path.slice(0) // clone
104
+ .reduce((a, b, idx)=>{
99
105
  if (idx < path.length - 1) {
100
106
  a[b] ??= {};
101
107
  return a[b];
package/index.js CHANGED
@@ -22,7 +22,8 @@ const inputOutputLoggerMiddleware = (opts = {})=>{
22
22
  if (awsContext) {
23
23
  message.context = pick(request.context, awsContextKeys);
24
24
  }
25
- const cloneMessage = jsonSafeParse(jsonSafeStringify(message, replacer));
25
+ const cloneMessage = jsonSafeParse(jsonSafeStringify(message, replacer)) // Full clone to prevent nested mutations
26
+ ;
26
27
  omit(cloneMessage, {
27
28
  [param]: omitPathTree[param]
28
29
  });
@@ -59,6 +60,7 @@ const inputOutputLoggerMiddleware = (opts = {})=>{
59
60
  onError: inputOutputLoggerMiddlewareOnError
60
61
  };
61
62
  };
63
+ // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html
62
64
  const awsContextKeys = [
63
65
  'functionName',
64
66
  'functionVersion',
@@ -71,9 +73,11 @@ const awsContextKeys = [
71
73
  'clientContext',
72
74
  'callbackWaitsForEmptyEventLoop'
73
75
  ];
76
+ // move to util, if ever used elsewhere
74
77
  const pick = (originalObject = {}, keysToPick = [])=>{
75
78
  const newObject = {};
76
79
  for (const path of keysToPick){
80
+ // only supports first level
77
81
  if (originalObject[path] !== undefined) {
78
82
  newObject[path] = originalObject[path];
79
83
  }
@@ -83,9 +87,11 @@ const pick = (originalObject = {}, keysToPick = [])=>{
83
87
  const buildPathTree = (paths)=>{
84
88
  const tree = {};
85
89
  for (let path of paths.sort().reverse()){
90
+ // reverse to ensure conflicting paths don't cause issues
86
91
  if (!Array.isArray(path)) path = path.split('.');
87
92
  if (path.includes('__proto__')) continue;
88
- path.slice(0).reduce((a, b, idx)=>{
93
+ path.slice(0) // clone
94
+ .reduce((a, b, idx)=>{
89
95
  if (idx < path.length - 1) {
90
96
  a[b] ??= {};
91
97
  return a[b];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/input-output-logger",
3
- "version": "4.6.1",
3
+ "version": "4.6.2",
4
4
  "description": "Input and output logger middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -66,11 +66,11 @@
66
66
  "url": "https://github.com/sponsors/willfarrell"
67
67
  },
68
68
  "dependencies": {
69
- "@middy/util": "4.6.1"
69
+ "@middy/util": "4.6.2"
70
70
  },
71
71
  "devDependencies": {
72
- "@middy/core": "4.6.1",
72
+ "@middy/core": "4.6.2",
73
73
  "@types/node": "^20.0.0"
74
74
  },
75
- "gitHead": "253ed0e4ca95623decbade03938a07d837a1eba2"
75
+ "gitHead": "8b03a01abf5a9c08231ec5ced775e87f8be8f67d"
76
76
  }