infront-logger 1.1.24 → 1.1.25

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/index.es.js CHANGED
@@ -366,7 +366,7 @@ function requireBuffer_list() {
366
366
  if (typeof res !== "object") return res;
367
367
  throw new TypeError("@@toPrimitive must return a primitive value.");
368
368
  }
369
- return String(input);
369
+ return (hint === "string" ? String : Number)(input);
370
370
  }
371
371
  var _require2 = require$$2, Buffer2 = _require2.Buffer;
372
372
  var _require22 = require$$0$1, inspect2 = _require22.inspect;
@@ -2681,7 +2681,7 @@ const TOKEN_STRING_RE = /"(access_token|refresh_token|id_token|bearer|authorizat
2681
2681
  function redactString(str) {
2682
2682
  return str.replace(JWT_RE, "*****").replace(TOKEN_STRING_RE, (_, key) => `"${key}":"*****"`);
2683
2683
  }
2684
- function toSerializable(value) {
2684
+ function toSerializable$1(value) {
2685
2685
  if (typeof value.toJSON !== "function") return value;
2686
2686
  try {
2687
2687
  return value.toJSON();
@@ -2697,7 +2697,7 @@ function redact$3(value, seen = /* @__PURE__ */ new WeakSet()) {
2697
2697
  if (seen.has(value)) return "[Circular]";
2698
2698
  seen.add(value);
2699
2699
  let out;
2700
- const serializable = toSerializable(value);
2700
+ const serializable = toSerializable$1(value);
2701
2701
  if (serializable !== value) {
2702
2702
  out = redact$3(serializable, seen);
2703
2703
  } else if (Array.isArray(value)) {
@@ -2976,26 +2976,44 @@ class Logger {
2976
2976
  loggerCache.set(cacheKey, this.logger);
2977
2977
  }
2978
2978
  }
2979
+ const toSerializable = (value) => {
2980
+ if (typeof value.toJSON !== "function") return value;
2981
+ try {
2982
+ return value.toJSON();
2983
+ } catch (err) {
2984
+ return value;
2985
+ }
2986
+ };
2979
2987
  const redact$2 = (data, ...sensitiveKeysList) => {
2980
- var _a, _b;
2981
- if (typeof data === "object" && data !== null && !((_b = (_a = data == null ? void 0 : data.constructor) == null ? void 0 : _a.name) == null ? void 0 : _b.startsWith("model"))) {
2982
- if (Array.isArray(data)) {
2983
- return data.map((item) => redact$2(item, ...sensitiveKeysList));
2984
- }
2985
- const redactedData = {};
2986
- for (const key in data) {
2987
- if (Object.prototype.hasOwnProperty.call(data, key)) {
2988
- if (sensitiveKeysList.includes(key)) {
2989
- redactedData[key] = "*****";
2990
- } else {
2991
- redactedData[key] = redact$2(data[key], ...sensitiveKeysList);
2988
+ const walk = (value, seen) => {
2989
+ var _a, _b;
2990
+ if (typeof value !== "object" || value === null || ((_b = (_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name) == null ? void 0 : _b.startsWith("model"))) {
2991
+ return value;
2992
+ }
2993
+ if (seen.has(value)) return "[Circular]";
2994
+ seen.add(value);
2995
+ let redactedData;
2996
+ const serializable = toSerializable(value);
2997
+ if (serializable !== value) {
2998
+ redactedData = walk(serializable, seen);
2999
+ } else if (Array.isArray(value)) {
3000
+ redactedData = Array.from(value, (item) => walk(item, seen));
3001
+ } else {
3002
+ redactedData = {};
3003
+ for (const key in value) {
3004
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
3005
+ if (sensitiveKeysList.includes(key)) {
3006
+ redactedData[key] = "*****";
3007
+ } else {
3008
+ redactedData[key] = walk(value[key], seen);
3009
+ }
2992
3010
  }
2993
3011
  }
2994
3012
  }
3013
+ seen.delete(value);
2995
3014
  return redactedData;
2996
- } else {
2997
- return data;
2998
- }
3015
+ };
3016
+ return walk(data, /* @__PURE__ */ new WeakSet());
2999
3017
  };
3000
3018
  const trim$2 = (data, length) => {
3001
3019
  try {
package/dist/index.umd.js CHANGED
@@ -367,7 +367,7 @@
367
367
  if (typeof res !== "object") return res;
368
368
  throw new TypeError("@@toPrimitive must return a primitive value.");
369
369
  }
370
- return String(input);
370
+ return (hint === "string" ? String : Number)(input);
371
371
  }
372
372
  var _require2 = require$$2, Buffer2 = _require2.Buffer;
373
373
  var _require22 = require$$0$1, inspect2 = _require22.inspect;
@@ -2682,7 +2682,7 @@
2682
2682
  function redactString(str) {
2683
2683
  return str.replace(JWT_RE, "*****").replace(TOKEN_STRING_RE, (_, key) => `"${key}":"*****"`);
2684
2684
  }
2685
- function toSerializable(value) {
2685
+ function toSerializable$1(value) {
2686
2686
  if (typeof value.toJSON !== "function") return value;
2687
2687
  try {
2688
2688
  return value.toJSON();
@@ -2698,7 +2698,7 @@
2698
2698
  if (seen.has(value)) return "[Circular]";
2699
2699
  seen.add(value);
2700
2700
  let out;
2701
- const serializable = toSerializable(value);
2701
+ const serializable = toSerializable$1(value);
2702
2702
  if (serializable !== value) {
2703
2703
  out = redact$3(serializable, seen);
2704
2704
  } else if (Array.isArray(value)) {
@@ -2977,26 +2977,44 @@
2977
2977
  loggerCache.set(cacheKey, this.logger);
2978
2978
  }
2979
2979
  }
2980
+ const toSerializable = (value) => {
2981
+ if (typeof value.toJSON !== "function") return value;
2982
+ try {
2983
+ return value.toJSON();
2984
+ } catch (err) {
2985
+ return value;
2986
+ }
2987
+ };
2980
2988
  const redact$2 = (data, ...sensitiveKeysList) => {
2981
- var _a, _b;
2982
- if (typeof data === "object" && data !== null && !((_b = (_a = data == null ? void 0 : data.constructor) == null ? void 0 : _a.name) == null ? void 0 : _b.startsWith("model"))) {
2983
- if (Array.isArray(data)) {
2984
- return data.map((item) => redact$2(item, ...sensitiveKeysList));
2985
- }
2986
- const redactedData = {};
2987
- for (const key in data) {
2988
- if (Object.prototype.hasOwnProperty.call(data, key)) {
2989
- if (sensitiveKeysList.includes(key)) {
2990
- redactedData[key] = "*****";
2991
- } else {
2992
- redactedData[key] = redact$2(data[key], ...sensitiveKeysList);
2989
+ const walk = (value, seen) => {
2990
+ var _a, _b;
2991
+ if (typeof value !== "object" || value === null || ((_b = (_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name) == null ? void 0 : _b.startsWith("model"))) {
2992
+ return value;
2993
+ }
2994
+ if (seen.has(value)) return "[Circular]";
2995
+ seen.add(value);
2996
+ let redactedData;
2997
+ const serializable = toSerializable(value);
2998
+ if (serializable !== value) {
2999
+ redactedData = walk(serializable, seen);
3000
+ } else if (Array.isArray(value)) {
3001
+ redactedData = Array.from(value, (item) => walk(item, seen));
3002
+ } else {
3003
+ redactedData = {};
3004
+ for (const key in value) {
3005
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
3006
+ if (sensitiveKeysList.includes(key)) {
3007
+ redactedData[key] = "*****";
3008
+ } else {
3009
+ redactedData[key] = walk(value[key], seen);
3010
+ }
2993
3011
  }
2994
3012
  }
2995
3013
  }
3014
+ seen.delete(value);
2996
3015
  return redactedData;
2997
- } else {
2998
- return data;
2999
- }
3016
+ };
3017
+ return walk(data, /* @__PURE__ */ new WeakSet());
3000
3018
  };
3001
3019
  const trim$2 = (data, length) => {
3002
3020
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infront-logger",
3
- "version": "1.1.24",
3
+ "version": "1.1.25",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"