@bymax-one/nest-logger 1.4.29 → 1.4.31

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.
@@ -87,10 +87,36 @@ var GROUP_KEYS = {
87
87
  };
88
88
  var GROUP_NAMES = Object.keys(GROUP_KEYS);
89
89
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
90
+ var MAX_PROTOTYPE_HOPS = 256;
91
+ function rootHolding(source, key) {
92
+ let hops = 0;
93
+ for (let at = source; at !== null; at = Object.getPrototypeOf(at)) {
94
+ if (hops++ > MAX_PROTOTYPE_HOPS) {
95
+ refuse(
96
+ `[BymaxLoggerModule] options.${key} holds more than ${String(MAX_PROTOTYPE_HOPS)} prototypes`
97
+ );
98
+ }
99
+ if (Object.hasOwn(at, key)) {
100
+ return at !== source && Object.getPrototypeOf(at) === null ? at : void 0;
101
+ }
102
+ }
103
+ return void 0;
104
+ }
90
105
  function readSet(source, keys) {
91
- const set = {};
106
+ const set = /* @__PURE__ */ Object.create(null);
92
107
  for (const key of keys) {
108
+ const root = rootHolding(source, key);
109
+ const planted = root && Object.getOwnPropertyDescriptor(root, key);
110
+ const accessor = planted !== void 0 && Object.hasOwn(planted, "get") && planted.get !== void 0;
111
+ if (accessor) {
112
+ if (types.isProxy(source))
113
+ refuse(
114
+ `[BymaxLoggerModule] options.${key} is read through a Proxy while an accessor of that name is planted on Object.prototype`
115
+ );
116
+ continue;
117
+ }
93
118
  const value = Reflect.get(source, key);
119
+ if (planted && Object.hasOwn(planted, "value") && Object.is(value, planted.value)) continue;
94
120
  if (value !== void 0 && value !== null) Reflect.set(set, key, value);
95
121
  }
96
122
  return set;
@@ -127,7 +153,8 @@ function dropUnsetOptions(options) {
127
153
  Reflect.set(set, group, readSet(value, Object.keys(Reflect.get(GROUP_KEYS, group))));
128
154
  }
129
155
  const service = Reflect.get(set, "service");
130
- if (isRecord(service)) Reflect.set(set, "service", { ...service });
156
+ if (isRecord(service))
157
+ Reflect.set(set, "service", Object.assign(/* @__PURE__ */ Object.create(null), service));
131
158
  const serializers = Reflect.get(set, "serializers");
132
159
  if (isRecord(serializers)) Reflect.set(set, "serializers", { ...serializers });
133
160
  copyLists(set, LIST_OPTIONS, "");
@@ -192,7 +219,9 @@ function applyDefaults(given) {
192
219
  options.otel
193
220
  );
194
221
  const merged = {
195
- service: Object.freeze({ ...options.service }),
222
+ service: Object.freeze(
223
+ Object.assign(/* @__PURE__ */ Object.create(null), options.service)
224
+ ),
196
225
  level: options.level ?? (isProduction ? "info" : "debug"),
197
226
  isGlobal: options.isGlobal ?? true,
198
227
  shouldUseAsNestLogger: options.shouldUseAsNestLogger ?? true,
@@ -298,6 +327,7 @@ function checkGroup(path2, value) {
298
327
  if (!isRecord2(value)) reject(path2, "must be an object", value);
299
328
  return value;
300
329
  }
330
+ var MAX_REDACT_PATH_LENGTH = 256;
301
331
  var MAX_TIMER_MS = 2147483647;
302
332
  function checkTimerMs(path2, value) {
303
333
  if (value === void 0) return;
@@ -412,6 +442,13 @@ function validateCustomization(options) {
412
442
  if (!isNonEmptyString(entry)) {
413
443
  reject(`redactPaths[${String(index)}]`, "must be a non-empty string", entry, true);
414
444
  }
445
+ if (entry.length > MAX_REDACT_PATH_LENGTH) {
446
+ reject(
447
+ `redactPaths[${String(index)}]`,
448
+ `must be at most ${String(MAX_REDACT_PATH_LENGTH)} characters`,
449
+ entry
450
+ );
451
+ }
415
452
  });
416
453
  }
417
454
  const serializers = options.serializers;
@@ -528,8 +565,131 @@ function validateOptions(given) {
528
565
  validateOtel(options);
529
566
  }
530
567
 
568
+ // src/server/utils/bare-descriptor.util.ts
569
+ var assign = Object.assign;
570
+ function bareDescriptor(descriptor) {
571
+ return assign(/* @__PURE__ */ Object.create(null), descriptor);
572
+ }
573
+
574
+ // src/server/utils/captured-builtins.util.ts
575
+ var call = Function.prototype.call;
576
+ var defineProperty = Object.defineProperty;
577
+ var setHas = call.bind(Set.prototype.has);
578
+ var setAdd = call.bind(Set.prototype.add);
579
+ var lowerCase = call.bind(String.prototype.toLowerCase);
580
+ var indexOfText = call.bind(String.prototype.indexOf);
581
+ var sliceText = call.bind(String.prototype.slice);
582
+ function replaceAllText(text, search, replacement) {
583
+ if (search === "") return text;
584
+ let result = "";
585
+ let from = 0;
586
+ for (let at = indexOfText(text, search, 0); at !== -1; at = indexOfText(text, search, from)) {
587
+ result += sliceText(text, from, at) + replacement;
588
+ from = at + search.length;
589
+ }
590
+ return result + sliceText(text, from);
591
+ }
592
+ var normalizeText = call.bind(String.prototype.normalize);
593
+ var regExpExec = call.bind(RegExp.prototype.exec);
594
+ var regExpReplace = call.bind(RegExp.prototype[Symbol.replace]);
595
+ function matchesPattern(pattern, text) {
596
+ return regExpExec(pattern, text) !== null;
597
+ }
598
+ function allMatches(pattern, text) {
599
+ const found = [];
600
+ pattern.lastIndex = 0;
601
+ for (let match = regExpExec(pattern, text); match !== null; match = regExpExec(pattern, text)) {
602
+ if (match[0] === "") break;
603
+ found[found.length] = match;
604
+ }
605
+ pattern.lastIndex = 0;
606
+ return found;
607
+ }
608
+ function replacer(pattern) {
609
+ defineProperty(
610
+ pattern,
611
+ "exec",
612
+ bareDescriptor({ value: (text) => regExpExec(pattern, text) })
613
+ );
614
+ return (text, replacement) => regExpReplace(pattern, text, replacement);
615
+ }
616
+ function capturedSet(values = []) {
617
+ const set = /* @__PURE__ */ new Set();
618
+ const has = (value) => setHas(set, value);
619
+ const add = (value) => {
620
+ setAdd(set, value);
621
+ return set;
622
+ };
623
+ defineProperty(set, "has", bareDescriptor({ value: has }));
624
+ defineProperty(set, "add", bareDescriptor({ value: add }));
625
+ if (Array.isArray(values)) for (let at = 0; at < values.length; at++) add(values[at]);
626
+ else for (const value of values) add(value);
627
+ return set;
628
+ }
629
+ function nextOf(iterator) {
630
+ return Object.getPrototypeOf(iterator);
631
+ }
632
+ var GUARDED_BUILTINS = [
633
+ [Array, ["from", "isArray"]],
634
+ [ArrayBuffer, ["isView"]],
635
+ [Buffer, ["byteLength", "from"]],
636
+ [Buffer.prototype, ["readUInt8", "subarray"]],
637
+ [
638
+ Array.prototype,
639
+ ["at", "filter", "flatMap", "forEach", "join", "map", "push", "reduce", "shift", "some", "sort"]
640
+ ],
641
+ [Array.prototype, [Symbol.iterator]],
642
+ [String, ["fromCodePoint"]],
643
+ [
644
+ String.prototype,
645
+ ["includes", "indexOf", "lastIndexOf", "normalize", "replace", "search", "slice", "split"]
646
+ ],
647
+ [String.prototype, ["charCodeAt", "startsWith", "toLowerCase", Symbol.iterator, Symbol.replace]],
648
+ [Map.prototype, ["clear", "get", "has", "set", Symbol.iterator]],
649
+ [Set.prototype, ["add", "delete", "has", "values", Symbol.iterator]],
650
+ [RegExp.prototype, ["exec", "test", Symbol.replace]],
651
+ [
652
+ Object,
653
+ ["assign", "create", "defineProperty", "entries", "fromEntries", "getOwnPropertyDescriptor"]
654
+ ],
655
+ [Function.prototype, ["call"]],
656
+ [Object, ["getOwnPropertyDescriptors", "getPrototypeOf", "hasOwn", "keys"]],
657
+ [
658
+ Reflect,
659
+ ["defineProperty", "deleteProperty", "get", "getOwnPropertyDescriptor", "ownKeys", "set"]
660
+ ],
661
+ [Math, ["max", "min"]],
662
+ [Number, ["isInteger"]],
663
+ [nextOf([][Symbol.iterator]()), ["next"]],
664
+ [nextOf(""[Symbol.iterator]()), ["next"]],
665
+ [nextOf((/* @__PURE__ */ new Map())[Symbol.iterator]()), ["next"]],
666
+ [nextOf((/* @__PURE__ */ new Set())[Symbol.iterator]()), ["next"]],
667
+ [nextOf(/(?:)/[Symbol.matchAll]("")), ["next"]]
668
+ ];
669
+ var guardedHolders = [];
670
+ var guardedMembers = [];
671
+ var guardedValues = [];
672
+ for (let at = 0; at < GUARDED_BUILTINS.length; at++) {
673
+ const entry = GUARDED_BUILTINS[at];
674
+ for (let member = 0; member < entry[1].length; member++) {
675
+ const name = entry[1][member];
676
+ guardedHolders[guardedHolders.length] = entry[0];
677
+ guardedMembers[guardedMembers.length] = name;
678
+ guardedValues[guardedValues.length] = entry[0][name];
679
+ }
680
+ }
681
+ function pinoBuiltinsIntact() {
682
+ for (let at = 0; at < guardedHolders.length; at++) {
683
+ if (guardedHolders[at][guardedMembers[at]] !== guardedValues[at]) {
684
+ return false;
685
+ }
686
+ }
687
+ return true;
688
+ }
689
+
531
690
  // src/server/config/resolve-options.ts
532
691
  function resolveOptions(given) {
692
+ if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
533
693
  return guardOptions(() => {
534
694
  const snapshot = dropUnsetOptions(given);
535
695
  validateOptions(snapshot);
@@ -583,7 +743,7 @@ var RESERVED_LOG_KEYS_NOT_EMITTED = Object.freeze({
583
743
  });
584
744
 
585
745
  // src/server/constants/prototype-polluting-keys.constants.ts
586
- var PROTOTYPE_POLLUTING_KEYS = /* @__PURE__ */ new Set([
746
+ var PROTOTYPE_POLLUTING_KEYS = capturedSet([
587
747
  "__proto__",
588
748
  "constructor",
589
749
  "prototype"
@@ -635,33 +795,35 @@ function createEntryTextFinisher(redact, limit, onCut) {
635
795
  };
636
796
  }
637
797
 
638
- // src/server/utils/escape-log-text.util.ts
639
- var LINE_TERMINATORS = /* @__PURE__ */ new Set(["\r", "\n", "\x85", "\u2028", "\u2029"]);
640
- var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
641
- var UNSAFE_IN_MULTILINE = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
642
- function toEscapeSequence(char) {
643
- return `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
644
- }
645
- function toSingleLineMessage(text) {
646
- return text.replace(
647
- UNSAFE_IN_SINGLE_LINE,
648
- (char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
649
- );
650
- }
651
- function toBoundedMessage(text) {
652
- return cutText(toSingleLineMessage(text));
653
- }
654
- function escapeControlCharacters(text) {
655
- return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
656
- }
798
+ // src/server/utils/glyph-letters.generated.ts
799
+ var GLYPH_LETTER_RUNS = [
800
+ [127312, "abcdefghijklmnopqrstuvwxyz"],
801
+ [127344, "abcdefghijklmnopqrstuvwxyzp"],
802
+ [127397, "d"],
803
+ [127462, "abcdefghijklmnopqrstuvwxyz"]
804
+ ];
657
805
 
658
806
  // src/server/utils/fold-key.util.ts
659
- var NOT_NAME = /[^\p{L}\p{N}]|[\u115f\u1160\u3164\uffa0]/gu;
660
- var INVISIBLE = /[\s\p{Cc}\p{Cf}\p{M}\u115f\u1160\u2800\u3164\uffa0]/gu;
661
- var DOTS = /[\u3002\u0701\u06d4\u22c5\u00b7\ufe12]/gu;
807
+ var dropNotName = replacer(/[^\p{L}\p{N}]|[\u115f\u1160\u3164\uffa0]/gu);
808
+ var SYMBOL_STAND_IN = "\uFFFC";
809
+ var standInSymbols = replacer(/(?=[^\0-\x7f])[\p{So}\p{Sm}\p{Sk}]/gu);
810
+ var dropNotNameStrict = replacer(/[^\p{L}\p{N}\ufffc]|[\u115f\u1160\u3164\uffa0]/gu);
811
+ var GLYPH_LETTERS = new Map(
812
+ GLYPH_LETTER_RUNS.flatMap(
813
+ ([first, letters]) => [...letters].map((letter, index) => [
814
+ String.fromCodePoint(first + index),
815
+ letter
816
+ ])
817
+ )
818
+ );
819
+ function readGlyphs(text) {
820
+ return Array.from(text, (glyph) => GLYPH_LETTERS.get(glyph) ?? glyph).join("");
821
+ }
822
+ var dropInvisible = replacer(/[\s\p{Cc}\p{Cf}\p{M}\u115f\u1160\u2800\u3164\uffa0]/gu);
823
+ var readDots = replacer(/[\u3002\u0701\u06d4\u22c5\u00b7\ufe12]/gu);
662
824
  var PLAIN = /^[\x21-\x7e]*$/;
663
825
  var NON_ASCII = /[^\x20-\x7e]/;
664
- var NOT_ASCII_NAME = /[^A-Za-z0-9]/g;
826
+ var dropNotAscii = replacer(/[^A-Za-z0-9]/g);
665
827
  var LOOKALIKES = new Map(
666
828
  Object.entries({
667
829
  a: "\u0430\u03B1\u1D00",
@@ -691,40 +853,57 @@ var LOOKALIKES = new Map(
691
853
  z: "\u1D22"
692
854
  }).flatMap(([latin, letters]) => [...letters].map((letter) => [letter, latin]))
693
855
  );
856
+ var LOOKALIKE_PAIRS = Array.from(LOOKALIKES);
694
857
  var I_LIKE = new Map(
695
858
  [..."\u0456\u03B9\u0131\u026A\u0269"].map((letter) => [letter, "i"])
696
859
  );
860
+ var I_LIKE_PAIRS = Array.from(I_LIKE);
697
861
  function foldKey(key, keepSeparators = false) {
698
862
  if (keepSeparators) {
699
- if (PLAIN.test(key)) return key.toLowerCase();
700
- return withLookalikes(
701
- key.normalize("NFKD").toLowerCase().replace(DOTS, ".").replace(INVISIBLE, ""),
863
+ return matchesPattern(PLAIN, key) ? lowerCase(key) : withLookalikes(
864
+ dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
702
865
  true
703
866
  );
704
867
  }
705
- if (PLAIN.test(key)) return key.replace(NOT_ASCII_NAME, "").toLowerCase();
706
- return withLookalikes(key.normalize("NFKD").toLowerCase().replace(NOT_NAME, ""), true);
868
+ return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
707
869
  }
708
870
  function foldStrict(key) {
709
- if (PLAIN.test(key)) return key.replace(NOT_ASCII_NAME, "").toLowerCase();
710
- return withLookalikes(key.normalize("NFKD").toLowerCase().replace(NOT_NAME, ""), false);
871
+ return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(
872
+ dropNotNameStrict(
873
+ standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
874
+ ""
875
+ ),
876
+ false
877
+ );
711
878
  }
712
879
  function withLookalikes(folded, all) {
713
880
  let read = folded;
714
- for (const [letter, latin] of LOOKALIKES) read = read.replaceAll(letter, latin);
715
- if (all) for (const [letter, latin] of I_LIKE) read = read.replaceAll(letter, latin);
881
+ for (let at = 0; at < LOOKALIKE_PAIRS.length; at++) {
882
+ const [letter, latin] = LOOKALIKE_PAIRS[at];
883
+ read = replaceAllText(read, letter, latin);
884
+ }
885
+ if (all) {
886
+ for (let at = 0; at < I_LIKE_PAIRS.length; at++) {
887
+ const [letter, latin] = I_LIKE_PAIRS[at];
888
+ read = replaceAllText(read, letter, latin);
889
+ }
890
+ }
716
891
  return read;
717
892
  }
718
893
  var ALNUM = /^[A-Za-z0-9]*$/;
719
894
  function formOf(key) {
720
- return ALNUM.test(key) ? key.toLowerCase() : foldStrict(key);
895
+ return matchesPattern(ALNUM, key) ? lowerCase(key) : foldStrict(key);
721
896
  }
722
897
  var answers = /* @__PURE__ */ new WeakMap();
723
898
  function foldName(key) {
724
899
  return formOf(key);
725
900
  }
726
901
  function foldedNames(names) {
727
- return new Set(Array.from(names, foldName).filter((name) => name !== ""));
902
+ return capturedSet(
903
+ Array.from(names, (name) => replaceAllText(foldName(name), SYMBOL_STAND_IN, "")).filter(
904
+ (name) => name !== ""
905
+ )
906
+ );
728
907
  }
729
908
  var MAX_CANDIDATES = 64;
730
909
  var grouped = /* @__PURE__ */ new WeakMap();
@@ -747,34 +926,46 @@ function groupsOf(names) {
747
926
  }
748
927
  function matchesFolded(names, folded) {
749
928
  if (names.has(folded)) return true;
750
- if (!NON_ASCII.test(folded)) return false;
929
+ if (!matchesPattern(NON_ASCII, folded)) return false;
751
930
  const letters = [...folded];
752
931
  const wide = letters.filter((letter) => !isAscii(letter)).length;
932
+ const stands = letters.filter((letter) => letter === SYMBOL_STAND_IN).length;
753
933
  const { byLength, longest } = groupsOf(names);
754
- if (letters.length > longest) return false;
934
+ if (longest === 0) return false;
935
+ if (stands > longest) return true;
936
+ const shortest = letters.length - stands;
937
+ const reach = longest - shortest;
755
938
  const lengths = Array.from(
756
- { length: wide + 1 },
757
- (_, extra) => byLength.get(letters.length + extra) ?? []
939
+ { length: Math.min(wide + stands + 1, reach + 1) },
940
+ (_, extra) => byLength.get(shortest + extra) ?? []
758
941
  );
759
942
  if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
760
943
  return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
761
944
  }
762
945
  var isAscii = (letter) => letter < "\x80";
763
946
  function matchesName(letters, name) {
764
- let at = /* @__PURE__ */ new Set([0]);
947
+ const initial = /* @__PURE__ */ new Set();
948
+ setAdd(initial, 0);
949
+ let at = initial;
765
950
  for (const letter of letters) {
766
951
  const next = /* @__PURE__ */ new Set();
767
952
  for (const position of at) {
953
+ if (letter === SYMBOL_STAND_IN) {
954
+ setAdd(next, position);
955
+ setAdd(next, position + 1);
956
+ setAdd(next, position + 2);
957
+ continue;
958
+ }
768
959
  if (isAscii(letter)) {
769
- if (name[position] === letter) next.add(position + 1);
960
+ if (name[position] === letter) setAdd(next, position + 1);
770
961
  continue;
771
962
  }
772
- next.add(position + 1);
773
- next.add(position + 2);
963
+ setAdd(next, position + 1);
964
+ setAdd(next, position + 2);
774
965
  }
775
966
  at = next;
776
967
  }
777
- return at.has(name.length);
968
+ return setHas(at, name.length);
778
969
  }
779
970
  function matchesKey(names, key) {
780
971
  const seen = answers.get(names) ?? /* @__PURE__ */ new Map();
@@ -793,7 +984,8 @@ function matchesKey(names, key) {
793
984
  // src/server/utils/hide-message-in-stack.util.ts
794
985
  function failureTable(message) {
795
986
  const table = new Int32Array(message.length);
796
- for (let i = 1, matched = 0; i < message.length; i += 1) {
987
+ const end = Math.max(1, message.length);
988
+ for (let i = 1, matched = 0; i !== end; i += 1) {
797
989
  while (matched > 0 && message[i] !== message[matched]) matched = table[matched - 1];
798
990
  if (message[i] === message[matched]) matched += 1;
799
991
  table[i] = matched;
@@ -801,14 +993,17 @@ function failureTable(message) {
801
993
  return table;
802
994
  }
803
995
  function occurrences(stack, message) {
804
- if (message.length > stack.length) return [];
805
- const table = failureTable(message);
996
+ const searched = message.slice(0, stack.length + 1);
997
+ const table = failureTable(searched);
806
998
  const spans = [];
807
- for (let i = 0, matched = 0; i < stack.length; i += 1) {
808
- while (matched > 0 && stack[i] !== message[matched]) matched = table[matched - 1];
809
- if (stack[i] === message[matched]) matched += 1;
810
- if (matched === message.length) {
811
- spans.push([i + 1 - message.length, i + 1]);
999
+ for (let i = 0, matched = 0; i !== stack.length; i += 1) {
1000
+ while (matched > 0 && stack[i] !== searched[matched]) matched = table[matched - 1];
1001
+ if (stack[i] === searched[matched]) matched += 1;
1002
+ if (matched === searched.length) {
1003
+ const start = i + 1 - searched.length;
1004
+ const last = spans[spans.length - 1];
1005
+ if (last !== void 0 && start < last[1]) last[1] = i + 1;
1006
+ else spans.push([start, i + 1]);
812
1007
  }
813
1008
  }
814
1009
  return spans;
@@ -831,19 +1026,6 @@ function hideMessagesInStack(stack, messages, replacement, limit) {
831
1026
  }
832
1027
  return result + stack.slice(from, Math.max(end, from));
833
1028
  }
834
- function hideMessageInStack(stack, message, replacement) {
835
- return hideMessagesInStack(stack, [message], replacement, stack.length);
836
- }
837
-
838
- // src/server/utils/is-plain-record.util.ts
839
- function isPlainRecord(node) {
840
- try {
841
- const prototype = Object.getPrototypeOf(node);
842
- return prototype === Object.prototype || prototype === null;
843
- } catch {
844
- return false;
845
- }
846
- }
847
1029
 
848
1030
  // src/server/utils/censor-stack-header.util.ts
849
1031
  var NAME_SEPARATOR = ": ";
@@ -863,6 +1045,26 @@ function splitCensoredHeader(stack, name, message, censored) {
863
1045
  if (endsHeader(stack, message, 0)) return [censored, stack.slice(message.length)];
864
1046
  return [name === "" ? censored : name + NAME_SEPARATOR + censored, ""];
865
1047
  }
1048
+
1049
+ // src/server/utils/escape-log-text.util.ts
1050
+ var LINE_TERMINATORS = capturedSet(["\r", "\n", "\x85", "\u2028", "\u2029"]);
1051
+ var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
1052
+ var UNSAFE_IN_MULTILINE = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
1053
+ function toEscapeSequence(char) {
1054
+ return `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
1055
+ }
1056
+ function toSingleLineMessage(text) {
1057
+ return text.replace(
1058
+ UNSAFE_IN_SINGLE_LINE,
1059
+ (char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
1060
+ );
1061
+ }
1062
+ function toBoundedMessage(text) {
1063
+ return cutText(toSingleLineMessage(text));
1064
+ }
1065
+ function escapeControlCharacters(text) {
1066
+ return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
1067
+ }
866
1068
  function isError(value) {
867
1069
  try {
868
1070
  return types.isNativeError(value) || value instanceof Error;
@@ -886,17 +1088,17 @@ var DEFAULT_SAFE_ERROR_FIELDS = [
886
1088
  "schema",
887
1089
  "routine"
888
1090
  ];
889
- var DERIVED_ERROR_FIELDS = /* @__PURE__ */ new Set([
1091
+ var DERIVED_ERROR_FIELDS = capturedSet([
890
1092
  "name",
891
1093
  "message",
892
1094
  "stack",
893
1095
  "cause",
894
1096
  "errors"
895
1097
  ]);
896
- var ALL_OWN_FIELDS = { safe: false, names: /* @__PURE__ */ new Set() };
1098
+ var ALL_OWN_FIELDS = { safe: false, names: capturedSet() };
897
1099
  function createOwnFieldPolicy(mode, extraNames) {
898
1100
  if (mode === "all") return ALL_OWN_FIELDS;
899
- return { safe: true, names: /* @__PURE__ */ new Set([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
1101
+ return { safe: true, names: capturedSet([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
900
1102
  }
901
1103
  function allowsOwnField(policy, key) {
902
1104
  return !policy.safe || DERIVED_ERROR_FIELDS.has(key) || key === "_errorFieldsIncomplete" || policy.names.has(key);
@@ -993,26 +1195,30 @@ function toSanitizedError(value, seen, depth2, walk2) {
993
1195
  return { name: "SanitizeFailed", message: "Failed to sanitize the thrown value" };
994
1196
  }
995
1197
  }
996
- var ARGUMENT_FIELDS = /* @__PURE__ */ new Set(["args", "parameters"]);
997
- var DATABASE_VALUE_FIELDS = /* @__PURE__ */ new Set(["detail", "where", "internalQuery"]);
1198
+ var ARGUMENT_FIELDS = capturedSet(["args", "parameters"]);
1199
+ var DATABASE_VALUE_FIELDS = capturedSet(["detail", "where", "internalQuery"]);
998
1200
  var SQLSTATE = /^[0-9A-DF-Z][0-9A-Z]{4}$/;
999
1201
  var OMIT_OWN_FIELD = /* @__PURE__ */ Symbol("omit-own-field");
1202
+ function ownDataValue(source, key) {
1203
+ const descriptor = Object.getOwnPropertyDescriptor(source, key);
1204
+ return descriptor !== void 0 && Object.hasOwn(descriptor, "value") ? descriptor.value : void 0;
1205
+ }
1000
1206
  function isDatabaseError(source) {
1001
- const code = Object.getOwnPropertyDescriptor(source, "code")?.value;
1002
- return typeof code === "string" && SQLSTATE.test(code);
1207
+ const code = ownDataValue(source, "code");
1208
+ return typeof code === "string" && matchesPattern(SQLSTATE, code);
1003
1209
  }
1004
1210
  function ownFieldForLog(source, key, value, policy = ALL_OWN_FIELDS) {
1005
1211
  if (!allowsOwnField(policy, key)) return OMIT_OWN_FIELD;
1006
- if (ARGUMENT_FIELDS.has(key.toLowerCase())) return OMIT_OWN_FIELD;
1212
+ if (ARGUMENT_FIELDS.has(lowerCase(key))) return OMIT_OWN_FIELD;
1007
1213
  if (DATABASE_VALUE_FIELDS.has(key) && isDatabaseError(source)) return OMIT_OWN_FIELD;
1008
1214
  if (key !== "command" || typeof value !== "object" || value === null) {
1009
1215
  return withBinaryAsSize(value);
1010
1216
  }
1011
- const name = Object.getOwnPropertyDescriptor(value, "name")?.value;
1217
+ const name = ownDataValue(value, "name");
1012
1218
  return typeof name === "string" ? { name } : OMIT_OWN_FIELD;
1013
1219
  }
1014
1220
  function defineErrorField(target, key, value) {
1015
- Object.defineProperty(target, key, { value, enumerable: true });
1221
+ Object.defineProperty(target, key, bareDescriptor({ value, enumerable: true }));
1016
1222
  }
1017
1223
  function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
1018
1224
  try {
@@ -1029,7 +1235,11 @@ function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
1029
1235
  }
1030
1236
  }
1031
1237
  function markIncomplete(target) {
1032
- Reflect.defineProperty(target, "_errorFieldsIncomplete", { value: true, enumerable: true });
1238
+ Reflect.defineProperty(
1239
+ target,
1240
+ "_errorFieldsIncomplete",
1241
+ bareDescriptor({ value: true, enumerable: true })
1242
+ );
1033
1243
  }
1034
1244
  function readOptional(read, node) {
1035
1245
  try {
@@ -1040,7 +1250,7 @@ function readOptional(read, node) {
1040
1250
  }
1041
1251
  }
1042
1252
  function toSanitizedChild(value, seen, depth2, walk2) {
1043
- if (isObject(value) && seen.has(value)) {
1253
+ if (seen.has(value)) {
1044
1254
  return CIRCULAR_SENTINEL;
1045
1255
  }
1046
1256
  return toSanitizedError(value, seen, depth2, walk2);
@@ -1064,7 +1274,7 @@ var MAX_PLAIN_NAME = 64;
1064
1274
  var PLAIN_NAME = /^[A-Za-z_$][\w$.-]*$/;
1065
1275
  function censorName(name, censorMessage) {
1066
1276
  if (censorMessage === void 0 || name === "") return name;
1067
- if (name.length <= MAX_PLAIN_NAME && PLAIN_NAME.test(name)) return name;
1277
+ if (name.length <= MAX_PLAIN_NAME && matchesPattern(PLAIN_NAME, name)) return name;
1068
1278
  try {
1069
1279
  return censorMessage(name);
1070
1280
  } catch {
@@ -1105,9 +1315,6 @@ function scrubStack(stack, header, wasLonger = false) {
1105
1315
  );
1106
1316
  return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
1107
1317
  }
1108
- function isObject(value) {
1109
- return typeof value === "object" && value !== null;
1110
- }
1111
1318
  function createDepthMarker() {
1112
1319
  return { _truncated: true, _reason: "cause-depth-exceeded" };
1113
1320
  }
@@ -1115,6 +1322,178 @@ function createWidthMarker(omitted) {
1115
1322
  return { _truncated: true, _reason: "aggregate-width-exceeded", _omitted: omitted };
1116
1323
  }
1117
1324
 
1325
+ // src/server/utils/redact-error-parts.util.ts
1326
+ function defineOwn(target, key, value) {
1327
+ Reflect.defineProperty(target, key, bareDescriptor({ value, enumerable: true, writable: true }));
1328
+ }
1329
+ var linkDepths = /* @__PURE__ */ new WeakMap();
1330
+ var ERROR_TEXT_FIELDS = capturedSet(["name", "message", "stack"]);
1331
+ var INCOMPLETE_KEY = "_errorFieldsIncomplete";
1332
+ var widthMarkers = /* @__PURE__ */ new WeakSet();
1333
+ function capErrors(errors, host) {
1334
+ if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
1335
+ if (host.hasToJson(errors)) return errors;
1336
+ const kept = [];
1337
+ for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
1338
+ const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
1339
+ widthMarkers.add(marker);
1340
+ kept.push(marker);
1341
+ return kept;
1342
+ }
1343
+ function linkTargets(value) {
1344
+ const targets = [];
1345
+ const take = (link) => {
1346
+ if (typeof link === "object" && link !== null) targets.push(link);
1347
+ };
1348
+ if (!Array.isArray(value)) take(value);
1349
+ else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
1350
+ return targets;
1351
+ }
1352
+ function walkChainPart(value, level, host, depth2) {
1353
+ const targets = linkTargets(value);
1354
+ if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
1355
+ if (Array.isArray(value) && host.nameKey === "name") {
1356
+ return Array.from({ length: value.length }, (_member, index) => {
1357
+ const member = Reflect.get(value, index);
1358
+ return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
1359
+ });
1360
+ }
1361
+ return createDepthMarker();
1362
+ }
1363
+ const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
1364
+ for (const target of targets) linkDepths.set(target, level + 1);
1365
+ try {
1366
+ return host.walk(value, depth2 + 1);
1367
+ } finally {
1368
+ before.forEach((earlier, target) => {
1369
+ if (earlier === void 0) linkDepths.delete(target);
1370
+ else linkDepths.set(target, earlier);
1371
+ });
1372
+ }
1373
+ }
1374
+ function cutOrWalk(value, level, host, depth2) {
1375
+ return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
1376
+ }
1377
+ function writeName(value, level, host, depth2) {
1378
+ const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
1379
+ return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
1380
+ }
1381
+ function addErrorParts(copy, error, ownKeys, host, depth2) {
1382
+ const taken = capturedSet(ownKeys);
1383
+ const level = linkDepths.get(error) ?? 0;
1384
+ let incomplete = false;
1385
+ const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
1386
+ if (taken.has(key)) return;
1387
+ try {
1388
+ const written = write(read());
1389
+ if (written === void 0) return;
1390
+ const covered = covers.some((name) => host.sensitive.has(name));
1391
+ defineOwn(copy, key, covered ? host.censor : written);
1392
+ } catch {
1393
+ incomplete = true;
1394
+ }
1395
+ };
1396
+ add(
1397
+ host.nameKey,
1398
+ [host.nameKey, "name"],
1399
+ () => error.name,
1400
+ (name) => writeName(name, level, host, depth2)
1401
+ );
1402
+ add(
1403
+ "message",
1404
+ ["message"],
1405
+ () => error.message,
1406
+ (message) => cutOrWalk(message, level, host, depth2)
1407
+ );
1408
+ add(
1409
+ "stack",
1410
+ ["stack", "name", "message"],
1411
+ () => error.stack,
1412
+ (stack) => typeof stack === "string" ? scrubStack(stack) : void 0
1413
+ );
1414
+ add("cause", ["cause"], () => error.cause);
1415
+ add("errors", ["errors"], () => capErrors(error.errors, host));
1416
+ if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
1417
+ }
1418
+
1419
+ // src/server/utils/error-text-exemption.util.ts
1420
+ var ERROR_TEXT_KEYS = capturedSet(["message"]);
1421
+ function leavesErrorText(rules, key, value, honorToJson) {
1422
+ return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
1423
+ }
1424
+ function rulesBelow(rules, key, value, honorToJson) {
1425
+ if (leavesErrorText(rules, key, value, honorToJson)) {
1426
+ return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
1427
+ }
1428
+ return { ...rules, exemptKeys: void 0, headerKept: void 0 };
1429
+ }
1430
+ function isCensored(rules, key, value) {
1431
+ return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
1432
+ }
1433
+ function messageCensor(rules) {
1434
+ return (text) => rules.sensitive.has("message") ? rules.censor : text;
1435
+ }
1436
+ var isStackKey = (key) => matchesKey(STACK_NAMES, key);
1437
+ var STACK_NAMES = capturedSet(["stack"]);
1438
+ var MESSAGE_NAMES = capturedSet(["message"]);
1439
+ var MAX_STACK_ALIASES = 8;
1440
+ var NO_STACK = { texts: /* @__PURE__ */ new Map(), stackKeys: capturedSet(), overflow: false };
1441
+ function headerMessage(rules, source, keys, isError2) {
1442
+ const keysOf = (names) => keys.filter((candidate) => matchesKey(names, candidate));
1443
+ const stacks = keysOf(STACK_NAMES);
1444
+ if (stacks.length === 0) return isError2 ? void 0 : NO_STACK;
1445
+ const hides = rules.sensitive.has("message") && (isError2 || rules.exemptKeys?.has("message") !== true && rules.headerKept !== true);
1446
+ const texts = /* @__PURE__ */ new Map();
1447
+ if (hides) {
1448
+ for (const key of keysOf(MESSAGE_NAMES)) {
1449
+ const text = Reflect.get(source, key);
1450
+ if (typeof text === "string") texts.set(key, text);
1451
+ }
1452
+ const named = keys.includes("message") ? void 0 : Reflect.get(source, "message");
1453
+ if (typeof named === "string") texts.set("message", named);
1454
+ }
1455
+ const overflow = stacks.length > MAX_STACK_ALIASES || capturedSet(texts.values()).size > MAX_STACK_ALIASES || [...texts.values()].some((text) => text.length > MAX_TEXT_LENGTH);
1456
+ return { texts, stackKeys: capturedSet(stacks), overflow };
1457
+ }
1458
+ function readField(source, key, header) {
1459
+ return header?.texts.get(key) ?? Reflect.get(source, key);
1460
+ }
1461
+ function censorAnyName(rules, name) {
1462
+ if (typeof name === "string") return censorName(name, messageCensor(rules));
1463
+ const holder = typeof name === "object" && name !== null || typeof name === "function";
1464
+ return holder && rules.sensitive.has("message") ? rules.censor : name;
1465
+ }
1466
+ function scrubPlainStack(rules, stack, header) {
1467
+ const texts = [...capturedSet(header?.texts.values())];
1468
+ const longest = texts.reduce((most, text) => Math.max(most, text.length), 0);
1469
+ const hidden = hideMessagesInStack(
1470
+ stack.slice(0, MAX_STACK_SCAN + longest),
1471
+ texts,
1472
+ rules.censor,
1473
+ MAX_STACK_SCAN
1474
+ );
1475
+ return scrubStack(hidden, void 0, stack.length > MAX_STACK_SCAN);
1476
+ }
1477
+ function errorTextField(rules, key, value, isError2, header) {
1478
+ const isStack = typeof value === "string" && (header === void 0 ? !isError2 && matchesKey(STACK_NAMES, key) : header.stackKeys.has(key));
1479
+ if (isStack) {
1480
+ return header?.overflow === true ? rules.censor : scrubPlainStack(rules, value, header);
1481
+ }
1482
+ if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
1483
+ const cut = cutIfText(value);
1484
+ return key === "name" ? censorAnyName(rules, cut) : cut;
1485
+ }
1486
+
1487
+ // src/server/utils/is-plain-record.util.ts
1488
+ function isPlainRecord(node) {
1489
+ try {
1490
+ const prototype = Object.getPrototypeOf(node);
1491
+ return prototype === Object.prototype || prototype === null;
1492
+ } catch {
1493
+ return false;
1494
+ }
1495
+ }
1496
+
1118
1497
  // src/server/services/pino-logger.service.ts
1119
1498
  var OWNED_PAYLOAD_KEYS = ["logKey", "userId", "context"];
1120
1499
  var ENTRY_STRUCTURE_KEYS = ["level", "time", "msg", "service", "deployment"];
@@ -1125,17 +1504,17 @@ var RESOURCE_KEYS = [
1125
1504
  "service.instance.id",
1126
1505
  "deployment.environment.name"
1127
1506
  ];
1128
- var OWNED_KEY_SPELLINGS = new Set(
1507
+ var OWNED_KEY_SPELLINGS = capturedSet(
1129
1508
  [...OWNED_PAYLOAD_KEYS, ...ENTRY_STRUCTURE_KEYS, ...RESOURCE_KEYS].map((key) => foldKey(key))
1130
1509
  );
1131
- var DERIVED_KEYS = /* @__PURE__ */ new Set([
1510
+ var DERIVED_KEYS = capturedSet([
1132
1511
  "exception.type",
1133
1512
  "exception.message",
1134
1513
  "exception.stacktrace",
1135
1514
  "error.type"
1136
1515
  ]);
1137
1516
  var isOwnedKey = (key) => {
1138
- const lower = key.toLowerCase();
1517
+ const lower = lowerCase(key);
1139
1518
  return OWNED_KEY_SPELLINGS.has(foldKey(key)) || DERIVED_KEYS.has(foldKey(key, true)) || lower.startsWith("service.") || lower.startsWith("deployment.");
1140
1519
  };
1141
1520
  function withoutOwnedKeys(metadata, omit) {
@@ -1174,12 +1553,27 @@ function objectMessageText(fields) {
1174
1553
  }
1175
1554
  return void 0;
1176
1555
  }
1177
- function hideStackMessage(payload, text, censor) {
1178
- const stack = Reflect.get(payload, "stack");
1179
- if (text?.key !== "message" || typeof stack !== "string") return;
1556
+ function hideStackMessage(payload, text, censor, positional) {
1557
+ const kept = positional === void 0 ? void 0 : cutText(positional);
1558
+ if (text?.key !== "message") return kept;
1180
1559
  const censored = censor(text.text);
1181
- if (censored === text.text) return;
1182
- Reflect.set(payload, "stack", hideMessageInStack(stack, text.text, censored));
1560
+ if (censored === text.text) return kept;
1561
+ const keys = Object.keys(payload).filter(isStackKey);
1562
+ const overflow = keys.length + (positional === void 0 ? 0 : 1) > MAX_STACK_ALIASES || text.text.length > MAX_TEXT_LENGTH;
1563
+ const hide = (stack) => overflow ? censored : cutText(
1564
+ hideMessagesInStack(
1565
+ stack.slice(0, MAX_TEXT_LENGTH + text.text.length),
1566
+ [text.text],
1567
+ censored,
1568
+ MAX_TEXT_LENGTH
1569
+ ),
1570
+ stack.length > MAX_TEXT_LENGTH
1571
+ );
1572
+ for (const key of keys) {
1573
+ const stack = Reflect.get(payload, key);
1574
+ if (typeof stack === "string") Reflect.set(payload, key, hide(stack));
1575
+ }
1576
+ return positional === void 0 ? void 0 : hide(positional);
1183
1577
  }
1184
1578
  function readObjectMessage(message) {
1185
1579
  const fields = isPlainRecord(message) && !isErrorLike(message) ? message : void 0;
@@ -1200,9 +1594,12 @@ function findErrorParam(optionalParams) {
1200
1594
  }
1201
1595
  function assignIfDefined(payload, key, value) {
1202
1596
  if (value !== void 0) {
1203
- Reflect.defineProperty(payload, key, { value, enumerable: true });
1597
+ Reflect.defineProperty(payload, key, bareDescriptor({ value, enumerable: true }));
1204
1598
  }
1205
1599
  }
1600
+ function emitRecord(pino2, level, payload, msg) {
1601
+ if (pinoBuiltinsIntact()) pino2[level](payload, msg);
1602
+ }
1206
1603
  var PinoLoggerService = class {
1207
1604
  /**
1208
1605
  * **A hand-built instance is NOT this library's behaviour.** Constructing
@@ -1257,17 +1654,27 @@ var PinoLoggerService = class {
1257
1654
  if (isErrorLike(message)) {
1258
1655
  const payload2 = { err: message };
1259
1656
  assignIfDefined(payload2, "context", this.resolveContext(optionalParams));
1260
- this.pino.error(payload2, this.errorText(message));
1657
+ emitRecord(this.pino, "error", payload2, this.errorText(message));
1261
1658
  return;
1262
1659
  }
1263
1660
  const stack = typeof optionalParams[0] === "string" ? optionalParams[0] : void 0;
1264
1661
  const context = typeof optionalParams[1] === "string" ? optionalParams[1] : this.context;
1265
1662
  const { fields, text, payload } = readObjectMessage(message);
1266
- hideStackMessage(payload, text, (message2) => this.censorText({ key: "message", text: message2 }));
1663
+ const positional = hideStackMessage(
1664
+ payload,
1665
+ text,
1666
+ (message2) => this.censorText({ key: "message", text: message2 }),
1667
+ stack
1668
+ );
1267
1669
  assignIfDefined(payload, "context", context);
1268
- assignIfDefined(payload, "stack", stack === void 0 ? stack : cutText(stack));
1670
+ assignIfDefined(payload, "stack", positional);
1269
1671
  assignIfDefined(payload, "err", findErrorParam(optionalParams));
1270
- this.pino.error(payload, this.nestStyleMessage("error", void 0, fields, text, message));
1672
+ emitRecord(
1673
+ this.pino,
1674
+ "error",
1675
+ payload,
1676
+ this.nestStyleMessage("error", void 0, fields, text, message)
1677
+ );
1271
1678
  }
1272
1679
  /**
1273
1680
  * NestJS `warn` (warn level).
@@ -1353,7 +1760,7 @@ var PinoLoggerService = class {
1353
1760
  };
1354
1761
  assignIfDefined(payload, "userId", userId);
1355
1762
  assignIfDefined(payload, "context", this.context);
1356
- this.pino.error(payload, this.errorText(error));
1763
+ emitRecord(this.pino, "error", payload, this.errorText(error));
1357
1764
  }
1358
1765
  // ─── Helpers / escape hatches ─────────────────────────────────────────────
1359
1766
  /**
@@ -1413,9 +1820,9 @@ var PinoLoggerService = class {
1413
1820
  assignIfDefined(payload, "context", this.context);
1414
1821
  const line = toBoundedMessage(message);
1415
1822
  if (level === "info") {
1416
- this.pino.info(payload, line);
1823
+ emitRecord(this.pino, "info", payload, line);
1417
1824
  } else {
1418
- this.pino.warn(payload, line);
1825
+ emitRecord(this.pino, "warn", payload, line);
1419
1826
  }
1420
1827
  }
1421
1828
  /** Emit a NestJS-style variadic log, dispatching by level without computed indexing. */
@@ -1471,23 +1878,7 @@ var PinoLoggerService = class {
1471
1878
  const leading = isErrorLike(message) ? message : void 0;
1472
1879
  assignIfDefined(payload, "err", leading ?? findErrorParam(optionalParams));
1473
1880
  const msg = this.nestStyleMessage(level, leading, fields, text, message);
1474
- switch (level) {
1475
- case "info":
1476
- this.pino.info(payload, msg);
1477
- break;
1478
- case "warn":
1479
- this.pino.warn(payload, msg);
1480
- break;
1481
- case "debug":
1482
- this.pino.debug(payload, msg);
1483
- break;
1484
- case "trace":
1485
- this.pino.trace(payload, msg);
1486
- break;
1487
- case "fatal":
1488
- this.pino.fatal(payload, msg);
1489
- break;
1490
- }
1881
+ emitRecord(this.pino, level, payload, msg);
1491
1882
  }
1492
1883
  };
1493
1884
  PinoLoggerService = __decorateClass([
@@ -1681,6 +2072,7 @@ var NANOID_REGEX = /\/[A-Za-z0-9_-]{21}(?![A-Za-z0-9_-])/g;
1681
2072
  var NUMERIC_ID_REGEX = /\/\d+/g;
1682
2073
  var ID_PLACEHOLDER = "/:id";
1683
2074
  var SECRET_PLACEHOLDER = ":redacted";
2075
+ var WHOLE_PATH_PLACEHOLDER = `/${SECRET_PLACEHOLDER}`;
1684
2076
  var HEX_SECRET_REGEX = /^[0-9a-f]{32,}$/i;
1685
2077
  var JWT_SECRET_REGEX = /^eyJ[\w-]*\.[\w-]+\.[\w-]*$/;
1686
2078
  var TOKEN_SECRET_REGEX = /^[A-Za-z0-9_+/-]{32,}={0,2}$/;
@@ -1705,13 +2097,13 @@ function hasTokenPart(segment) {
1705
2097
  }
1706
2098
  function withoutExtension(segment) {
1707
2099
  const dot = segment.lastIndexOf(".");
1708
- const dotAfterStart = dot > 0;
1709
- return dotAfterStart && segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
2100
+ return segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
1710
2101
  }
1711
2102
  function looksLikeToken(value) {
1712
2103
  return HEX_SECRET_REGEX.test(value) || HEX_RUN_REGEX.test(value) || JWT_SECRET_REGEX.test(value) || TOKEN_SECRET_REGEX.test(value) && !SLUG_REGEX.test(value) && !UUID_SEGMENT_REGEX.test(value);
1713
2104
  }
1714
2105
  function secretPathSegments(url, extra = []) {
2106
+ if (!pinoBuiltinsIntact()) return [url];
1715
2107
  const found = /* @__PURE__ */ new Set();
1716
2108
  for (const segment of stripQueryString(url).split("/")) {
1717
2109
  if (isSecretSegment(segment, extra)) found.add(segment);
@@ -1719,6 +2111,7 @@ function secretPathSegments(url, extra = []) {
1719
2111
  return [...found];
1720
2112
  }
1721
2113
  function scrubSecretSegments(path2, extra = []) {
2114
+ if (!pinoBuiltinsIntact()) return WHOLE_PATH_PLACEHOLDER;
1722
2115
  return path2.split("/").map((segment) => isSecretSegment(segment, extra) ? SECRET_PLACEHOLDER : segment).join("/");
1723
2116
  }
1724
2117
  function normalizeUrl(url, extra = []) {
@@ -1729,6 +2122,7 @@ function stripQueryString(url) {
1729
2122
  return queryStart === -1 ? url : url.slice(0, queryStart);
1730
2123
  }
1731
2124
  function withoutRequestSecrets(text, extra, ...urls) {
2125
+ if (!pinoBuiltinsIntact()) return SECRET_PLACEHOLDER;
1732
2126
  let result = text;
1733
2127
  const segments = /* @__PURE__ */ new Set();
1734
2128
  for (const url of urls) {
@@ -2228,13 +2622,128 @@ var LogContextService = class {
2228
2622
  LogContextService = __decorateClass([
2229
2623
  Injectable()
2230
2624
  ], LogContextService);
2625
+ var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
2626
+ var hasOwn = Object.hasOwn;
2627
+ var isNativePromise = types.isPromise;
2628
+ var define = Object.defineProperty;
2629
+ var remove = Reflect.deleteProperty;
2630
+ var ownDescriptor = Reflect.getOwnPropertyDescriptor;
2631
+ var nativeThen = Function.prototype.call.bind(IntrinsicPromise.prototype.then);
2632
+ var promisePrototype = IntrinsicPromise.prototype;
2633
+ var speciesGetter = ownSpeciesGetter();
2634
+ var objectRoot = Object.prototype;
2635
+ var arrayRoot = Array.prototype;
2636
+ var functionRoot = Function.prototype;
2637
+ function ownSpeciesGetter() {
2638
+ const descriptor = ownDescriptor(IntrinsicPromise, Symbol.species);
2639
+ return descriptor !== void 0 && hasOwn(descriptor, "get") ? descriptor.get : void 0;
2640
+ }
2641
+ var PromiseTamperedError = class extends Error {
2642
+ constructor() {
2643
+ super(
2644
+ "the promise baseline does not hold: the constructor of the promise prototype was replaced, a then was planted on a prototype root, or the promise awaited carries its own constructor or then"
2645
+ );
2646
+ }
2647
+ };
2648
+ if (speciesGetter === void 0) throw new PromiseTamperedError();
2649
+ function promiseIntact() {
2650
+ const own = ownDescriptor(promisePrototype, "constructor");
2651
+ if (own === void 0 || !hasOwn(own, "value") || own.value !== IntrinsicPromise) return false;
2652
+ if (ownSpeciesGetter() !== speciesGetter) return false;
2653
+ return !hasOwn(objectRoot, "then") && !hasOwn(arrayRoot, "then") && !hasOwn(functionRoot, "then");
2654
+ }
2655
+ function intactOr(pending) {
2656
+ if (!promiseIntact()) throw new PromiseTamperedError();
2657
+ return pending;
2658
+ }
2659
+ function absorb(pending) {
2660
+ const drop = () => void 0;
2661
+ const pinned = pin(pending);
2662
+ try {
2663
+ try {
2664
+ nativeThen(pending, drop, drop);
2665
+ return;
2666
+ } catch {
2667
+ }
2668
+ void (async () => {
2669
+ try {
2670
+ await pending;
2671
+ } catch {
2672
+ }
2673
+ })();
2674
+ } finally {
2675
+ if (pinned) unpin(pending);
2676
+ }
2677
+ }
2678
+ function tag(promise) {
2679
+ setOwnConstructor(promise, false);
2680
+ return promise;
2681
+ }
2682
+ function setOwnConstructor(target, temporary) {
2683
+ try {
2684
+ define(target, "constructor", {
2685
+ __proto__: null,
2686
+ value: IntrinsicPromise,
2687
+ writable: temporary,
2688
+ configurable: temporary
2689
+ });
2690
+ return true;
2691
+ } catch {
2692
+ return false;
2693
+ }
2694
+ }
2695
+ function pin(target) {
2696
+ if (!isNativePromise(target) || hasOwn(target, "constructor")) return false;
2697
+ return setOwnConstructor(target, true);
2698
+ }
2699
+ function unpin(target) {
2700
+ try {
2701
+ remove(target, "constructor");
2702
+ } catch {
2703
+ }
2704
+ }
2705
+ function hold(value) {
2706
+ if (!isNativePromise(value)) return value;
2707
+ if (hasOwn(value, "constructor") || hasOwn(value, "then") || !setOwnConstructor(value, true)) {
2708
+ throw new PromiseTamperedError();
2709
+ }
2710
+ try {
2711
+ return (async () => {
2712
+ await value;
2713
+ })();
2714
+ } finally {
2715
+ unpin(value);
2716
+ }
2717
+ }
2718
+ function awaitOutcome(work, finish, held) {
2719
+ absorb(run(work, finish, held));
2720
+ }
2721
+ async function run(work, finish, held) {
2722
+ if (!promiseIntact()) {
2723
+ absorb(held);
2724
+ return finish({ __proto__: null, ok: false, cause: new PromiseTamperedError() });
2725
+ }
2726
+ let pending;
2727
+ try {
2728
+ pending = work();
2729
+ } catch (cause) {
2730
+ return finish({ __proto__: null, ok: false, cause });
2731
+ }
2732
+ try {
2733
+ await hold(intactOr(pending));
2734
+ } catch (cause) {
2735
+ if (cause instanceof PromiseTamperedError) absorb(pending);
2736
+ return finish({ __proto__: null, ok: false, cause });
2737
+ }
2738
+ finish({ __proto__: null, ok: true, cause: void 0 });
2739
+ }
2231
2740
 
2232
2741
  // src/server/middlewares/request-id.middleware.ts
2233
2742
  var REQUEST_ID_HEADER = "x-request-id";
2234
2743
  var MAX_CORRELATION_ID_LENGTH = 256;
2235
2744
  var CORRELATION_ID_CHARSET = /^[A-Za-z0-9._:/+=-]+$/;
2236
2745
  function settleLate(answer) {
2237
- Promise.resolve(answer).catch(() => void 0);
2746
+ absorb(answer);
2238
2747
  }
2239
2748
  var INHERITABLE_CONTEXT_KEYS = ["requestId", "tenantId"];
2240
2749
  function isAcceptableHeaderValue(value) {
@@ -2664,9 +3173,7 @@ function createTraceContextMixin(logContext, opts) {
2664
3173
  return function mixin(_mergeObject, _level, _logger) {
2665
3174
  const merged = {};
2666
3175
  const store = logContext.getStore();
2667
- if (store) {
2668
- Object.assign(merged, store);
2669
- }
3176
+ Object.assign(merged, store);
2670
3177
  if (traceApi) {
2671
3178
  try {
2672
3179
  const span = traceApi.getActiveSpan();
@@ -2692,7 +3199,7 @@ function createTraceContextMixin(logContext, opts) {
2692
3199
  // src/server/utils/compile-redact-paths.util.ts
2693
3200
  function compileRedactPaths(extraPaths, shouldSkipDefaults) {
2694
3201
  const sources = shouldSkipDefaults ? [extraPaths] : [DEFAULT_REDACT_PATHS, extraPaths];
2695
- return Array.from(new Set(sources.flat()));
3202
+ return Array.from(capturedSet(sources.flat()));
2696
3203
  }
2697
3204
 
2698
3205
  // src/server/utils/cut-strings.util.ts
@@ -2741,8 +3248,7 @@ function rescueToStdout(payload) {
2741
3248
  function ownQueuedBytes(destination) {
2742
3249
  try {
2743
3250
  const bytes = destination.queuedBytes?.() ?? 0;
2744
- const positive = Number.isFinite(bytes) && bytes > 0;
2745
- return positive ? bytes : 0;
3251
+ return Number.isFinite(bytes) ? Math.max(0, bytes) : 0;
2746
3252
  } catch {
2747
3253
  return 0;
2748
3254
  }
@@ -2814,7 +3320,6 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
2814
3320
  // Keep string chunks as strings (Node's default re-encodes them to Buffers
2815
3321
  // before `_write`): the common Pino path emits NDJSON strings, so this skips
2816
3322
  // a string→Buffer→string round-trip on the hot logging path.
2817
- // Stryker disable next-line BooleanLiteral: equivalent for every chunk this stream receives — with `true`, Node encodes the string to a Buffer and `write()` below decodes it back with `toString('utf-8')`. Pino writes UTF-8 NDJSON strings at the default encoding, so the round-trip returns the identical string. It is NOT equivalent in general: a `write(chunk, 'latin1')` would round-trip through UTF-8 and change non-ASCII bytes, which is unreachable here because nothing writes to this stream but Pino. The flag stays because it skips the round-trip on the hot logging path.
2818
3323
  decodeStrings: false,
2819
3324
  write(chunk, _encoding, settled) {
2820
3325
  const bytes = Buffer.byteLength(chunk);
@@ -2840,15 +3345,14 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
2840
3345
  callback();
2841
3346
  } else {
2842
3347
  health.markWritePending(destination);
2843
- Promise.resolve(result).then(
2844
- () => {
3348
+ awaitOutcome(
3349
+ () => result,
3350
+ (outcome) => {
2845
3351
  health.markWriteSettled(destination);
2846
- callback();
3352
+ if (outcome.ok) callback();
3353
+ else onFailure(outcome.cause);
2847
3354
  },
2848
- (cause) => {
2849
- health.markWriteSettled(destination);
2850
- onFailure(cause);
2851
- }
3355
+ result
2852
3356
  );
2853
3357
  }
2854
3358
  } catch (cause) {
@@ -2867,11 +3371,11 @@ function mergeMixinSafely(mergeObject, mixinObject) {
2867
3371
  const merged = {};
2868
3372
  const written = /* @__PURE__ */ new Set();
2869
3373
  for (const [key, value] of Object.entries(mixinObject)) {
2870
- if (value !== void 0) written.add(foldKey(key));
3374
+ if (value !== void 0) setAdd(written, foldKey(key));
2871
3375
  }
2872
3376
  for (const key of Object.keys(mergeObject)) {
2873
3377
  if (key === PROTOTYPE_KEY) continue;
2874
- if (key !== EXPLICIT_USER_KEY && written.has(foldKey(key))) continue;
3378
+ if (key !== EXPLICIT_USER_KEY && setHas(written, foldKey(key))) continue;
2875
3379
  Reflect.set(merged, key, Reflect.get(mergeObject, key));
2876
3380
  }
2877
3381
  for (const [key, value] of Object.entries(mixinObject)) {
@@ -2897,225 +3401,79 @@ function censorRawHeaders(raw, sensitive, censor) {
2897
3401
  });
2898
3402
  }
2899
3403
 
2900
- // src/server/utils/redact-error-parts.util.ts
2901
- function defineOwn(target, key, value) {
2902
- Reflect.defineProperty(target, key, { value, enumerable: true, writable: true });
2903
- }
2904
- var linkDepths = /* @__PURE__ */ new WeakMap();
2905
- var ERROR_TEXT_FIELDS = /* @__PURE__ */ new Set(["name", "message", "stack"]);
2906
- var INCOMPLETE_KEY = "_errorFieldsIncomplete";
2907
- var widthMarkers = /* @__PURE__ */ new WeakSet();
2908
- function capErrors(errors, host) {
2909
- if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
2910
- if (host.hasToJson(errors)) return errors;
2911
- const kept = [];
2912
- for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
2913
- const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
2914
- widthMarkers.add(marker);
2915
- kept.push(marker);
2916
- return kept;
2917
- }
2918
- function linkTargets(value) {
2919
- const targets = [];
2920
- const take = (link) => {
2921
- if (typeof link === "object" && link !== null) targets.push(link);
2922
- };
2923
- if (!Array.isArray(value)) take(value);
2924
- else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
2925
- return targets;
2926
- }
2927
- function walkChainPart(value, level, host, depth2) {
2928
- const targets = linkTargets(value);
2929
- if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
2930
- if (Array.isArray(value) && host.nameKey === "name") {
2931
- return Array.from({ length: value.length }, (_member, index) => {
2932
- const member = Reflect.get(value, index);
2933
- return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
2934
- });
2935
- }
2936
- return createDepthMarker();
2937
- }
2938
- const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
2939
- for (const target of targets) linkDepths.set(target, level + 1);
2940
- try {
2941
- return host.walk(value, depth2 + 1);
2942
- } finally {
2943
- before.forEach((earlier, target) => {
2944
- if (earlier === void 0) linkDepths.delete(target);
2945
- else linkDepths.set(target, earlier);
2946
- });
2947
- }
2948
- }
2949
- function cutOrWalk(value, level, host, depth2) {
2950
- return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
2951
- }
2952
- function writeName(value, level, host, depth2) {
2953
- const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
2954
- return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
2955
- }
2956
- function addErrorParts(copy, error, ownKeys, host, depth2) {
2957
- const taken = new Set(ownKeys);
2958
- const level = linkDepths.get(error) ?? 0;
2959
- let incomplete = false;
2960
- const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
2961
- if (taken.has(key)) return;
2962
- try {
2963
- const written = write(read());
2964
- if (written === void 0) return;
2965
- const covered = covers.some((name) => host.sensitive.has(name));
2966
- defineOwn(copy, key, covered ? host.censor : written);
2967
- } catch {
2968
- incomplete = true;
2969
- }
2970
- };
2971
- add(
2972
- host.nameKey,
2973
- [host.nameKey, "name"],
2974
- () => error.name,
2975
- (name) => writeName(name, level, host, depth2)
2976
- );
2977
- add(
2978
- "message",
2979
- ["message"],
2980
- () => error.message,
2981
- (message) => cutOrWalk(message, level, host, depth2)
2982
- );
2983
- add(
2984
- "stack",
2985
- ["stack", "name", "message"],
2986
- () => error.stack,
2987
- (stack) => typeof stack === "string" ? scrubStack(stack) : void 0
2988
- );
2989
- add("cause", ["cause"], () => error.cause);
2990
- add("errors", ["errors"], () => capErrors(error.errors, host));
2991
- if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
2992
- }
2993
-
2994
- // src/server/utils/error-text-exemption.util.ts
2995
- var ERROR_TEXT_KEYS = /* @__PURE__ */ new Set(["message"]);
2996
- function leavesErrorText(rules, key, value, honorToJson) {
2997
- return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
2998
- }
2999
- function rulesBelow(rules, key, value, honorToJson) {
3000
- if (leavesErrorText(rules, key, value, honorToJson)) {
3001
- return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
3002
- }
3003
- return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
3004
- }
3005
- function isCensored(rules, key, value) {
3006
- return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
3007
- }
3008
- function messageCensor(rules) {
3009
- return (text) => rules.sensitive.has("message") ? rules.censor : text;
3010
- }
3011
- var STACK_NAMES = /* @__PURE__ */ new Set(["stack"]);
3012
- var MESSAGE_NAMES = /* @__PURE__ */ new Set(["message"]);
3013
- var MAX_STACK_ALIASES = 8;
3014
- var NO_STACK = { texts: /* @__PURE__ */ new Map(), stackKeys: /* @__PURE__ */ new Set(), overflow: false };
3015
- function headerMessage(rules, source, keys, isError2) {
3016
- if (isError2) return void 0;
3017
- const keysOf = (names) => keys.filter((candidate) => matchesKey(names, candidate));
3018
- const stacks = keysOf(STACK_NAMES);
3019
- if (stacks.length === 0) return NO_STACK;
3020
- const hides = rules.sensitive.has("message") && rules.exemptKeys?.has("message") !== true && rules.headerKept !== true;
3021
- const texts = /* @__PURE__ */ new Map();
3022
- if (hides) {
3023
- for (const key of keysOf(MESSAGE_NAMES)) {
3024
- const text = Reflect.get(source, key);
3025
- if (typeof text === "string") texts.set(key, text);
3026
- }
3027
- const named = keys.includes("message") ? void 0 : Reflect.get(source, "message");
3028
- if (typeof named === "string") texts.set("message", named);
3029
- }
3030
- const overflow = stacks.length > MAX_STACK_ALIASES || new Set(texts.values()).size > MAX_STACK_ALIASES;
3031
- return { texts, stackKeys: new Set(stacks), overflow };
3032
- }
3033
- function readField(source, key, header) {
3034
- return header?.texts.get(key) ?? Reflect.get(source, key);
3035
- }
3036
- function censorAnyName(rules, name) {
3037
- if (typeof name === "string") return censorName(name, messageCensor(rules));
3038
- const holder = typeof name === "object" && name !== null || typeof name === "function";
3039
- return holder && rules.sensitive.has("message") ? rules.censor : name;
3040
- }
3041
- function scrubPlainStack(rules, stack, header) {
3042
- const texts = [...new Set(header?.texts.values())];
3043
- const longest = texts.reduce((most, text) => Math.max(most, text.length), 0);
3044
- const hidden = hideMessagesInStack(
3045
- // Stryker disable next-line MethodExpression: equivalent in output: an occurrence that starts before the bound ends inside the window, and one that starts after it is not read, so a longer text gives the same result; the slice only bounds the search.
3046
- stack.slice(0, MAX_STACK_SCAN + longest),
3047
- texts,
3048
- rules.censor,
3049
- MAX_STACK_SCAN
3050
- );
3051
- return scrubStack(hidden, void 0, stack.length > MAX_STACK_SCAN);
3052
- }
3053
- function errorTextField(rules, key, value, isError2, header) {
3054
- const isStack = !isError2 && typeof value === "string" && (header === void 0 ? matchesKey(STACK_NAMES, key) : header.stackKeys.has(key));
3055
- if (isStack) {
3056
- return header?.overflow === true ? rules.censor : scrubPlainStack(rules, value, header);
3057
- }
3058
- if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
3059
- const cut = cutIfText(value);
3060
- return key === "name" ? censorAnyName(rules, cut) : cut;
3061
- }
3062
-
3063
3404
  // src/server/utils/redact-error-clone.util.ts
3064
3405
  function shadowHook(target) {
3065
- Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
3406
+ Reflect.defineProperty(target, "toJSON", bareDescriptor({ value: void 0, configurable: true }));
3066
3407
  }
3067
3408
  function withoutEnumerableKeys(clone) {
3068
3409
  for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
3069
3410
  }
3070
3411
  function discardWrite() {
3071
3412
  }
3072
- function cloneError(error) {
3073
- const descriptors = Object.getOwnPropertyDescriptors(error);
3074
- for (const descriptor of Object.values(descriptors)) {
3413
+ function relaxedDescriptors(descriptors) {
3414
+ const relaxed = /* @__PURE__ */ Object.create(null);
3415
+ for (const key of Reflect.ownKeys(descriptors)) {
3416
+ const descriptor = bareDescriptor(Reflect.get(descriptors, key));
3075
3417
  descriptor.configurable = true;
3076
- if ("value" in descriptor) descriptor.writable = true;
3418
+ if (Object.hasOwn(descriptor, "value")) descriptor.writable = true;
3077
3419
  else descriptor.set ??= discardWrite;
3420
+ Reflect.set(relaxed, key, descriptor);
3078
3421
  }
3079
- const clone = Object.create(Object.getPrototypeOf(error), descriptors);
3422
+ return relaxed;
3423
+ }
3424
+ function cloneError(error) {
3425
+ const clone = Object.create(
3426
+ Object.getPrototypeOf(error),
3427
+ relaxedDescriptors(Object.getOwnPropertyDescriptors(error))
3428
+ );
3080
3429
  const { stack } = error;
3081
3430
  if (typeof stack === "string") {
3082
- Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
3431
+ Reflect.defineProperty(
3432
+ clone,
3433
+ "stack",
3434
+ bareDescriptor({ value: stack, enumerable: false, writable: true })
3435
+ );
3083
3436
  }
3084
3437
  withoutEnumerableKeys(clone);
3085
3438
  shadowHook(clone);
3086
3439
  return clone;
3087
3440
  }
3088
-
3089
- // src/server/utils/redact-by-name.util.ts
3090
- var RAW_HEADER_KEYS = /* @__PURE__ */ new Set(["rawheaders", "rawtrailers"]);
3091
- function censorHeaderArray(key, walked, rules) {
3092
- return matchesKey(RAW_HEADER_KEYS, key) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
3093
- }
3094
- var REDACT_MAX_TRAVERSAL_DEPTH = 100;
3095
- var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
3096
- var REDACT_MAX_VISITS = 2e5;
3097
- var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
3098
- var REDACT_CIRCULAR = "[Circular]";
3441
+ var MAX_PROTOTYPE_HOPS2 = 256;
3099
3442
  function resolveToJson(value, viaGet = false) {
3100
3443
  let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
3101
3444
  let accessor = false;
3102
3445
  let proxied = false;
3103
3446
  let current = viaGet ? null : value;
3104
- while (current !== null) {
3447
+ for (let hops = 0; current !== null; hops++) {
3448
+ if (hops > MAX_PROTOTYPE_HOPS2) return { method: void 0, volatile: true, hostile: true };
3105
3449
  proxied = proxied || types.isProxy(current);
3106
3450
  const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
3107
3451
  if (descriptor !== void 0) {
3108
- accessor = descriptor.get !== void 0;
3109
- candidate = descriptor.get === void 0 ? descriptor.value : descriptor.get.call(value);
3452
+ const getter = Object.hasOwn(descriptor, "get") ? descriptor.get : void 0;
3453
+ accessor = getter !== void 0;
3454
+ if (getter !== void 0) candidate = getter.call(value);
3455
+ else if (Object.hasOwn(descriptor, "value")) candidate = descriptor.value;
3110
3456
  break;
3111
3457
  }
3112
- current = Object.getPrototypeOf(current);
3458
+ const next = Object.getPrototypeOf(current);
3459
+ current = typeof next === "object" ? next : null;
3113
3460
  }
3114
3461
  return {
3115
3462
  method: typeof candidate === "function" ? candidate : void 0,
3116
3463
  volatile: accessor || proxied
3117
3464
  };
3118
3465
  }
3466
+
3467
+ // src/server/utils/redact-by-name.util.ts
3468
+ var RAW_HEADER_KEYS = capturedSet(["rawheaders", "rawtrailers"]);
3469
+ function censorHeaderArray(key, walked, rules) {
3470
+ return matchesKey(RAW_HEADER_KEYS, key) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
3471
+ }
3472
+ var REDACT_MAX_TRAVERSAL_DEPTH = 100;
3473
+ var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
3474
+ var REDACT_MAX_VISITS = 2e5;
3475
+ var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
3476
+ var REDACT_CIRCULAR = "[Circular]";
3119
3477
  function rulesInside(rules, names, visits) {
3120
3478
  return names === void 0 ? void 0 : { ...rules, sensitive: names, visits, insideErrors: void 0 };
3121
3479
  }
@@ -3152,7 +3510,7 @@ function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false
3152
3510
  if (++rules.visits.count > rules.maxVisits) {
3153
3511
  return REDACT_BUDGET_EXCEEDED;
3154
3512
  }
3155
- if (ancestors.has(value)) {
3513
+ if (setHas(ancestors, value)) {
3156
3514
  return REDACT_CIRCULAR;
3157
3515
  }
3158
3516
  if (isError(value)) {
@@ -3180,7 +3538,8 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
3180
3538
  return withBinaryAsSize(value);
3181
3539
  }
3182
3540
  const resolved = resolveToJson(value, rules.ownFields.safe);
3183
- ancestors.add(value);
3541
+ if (resolved.hostile) return rules.censor;
3542
+ setAdd(ancestors, value);
3184
3543
  try {
3185
3544
  return walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSerialized);
3186
3545
  } finally {
@@ -3220,7 +3579,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
3220
3579
  const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
3221
3580
  const hook = honorToJson && key === "toJSON" && typeof current === "function";
3222
3581
  if (current === OMIT_OWN_FIELD || hook) {
3223
- omitted.add(key);
3582
+ setAdd(omitted, key);
3224
3583
  continue;
3225
3584
  }
3226
3585
  Reflect.deleteProperty(copy, key);
@@ -3248,7 +3607,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
3248
3607
  return copy;
3249
3608
  }
3250
3609
  function without(keys, omitted) {
3251
- return keys.filter((key) => !omitted.has(key));
3610
+ return keys.filter((key) => !setHas(omitted, key));
3252
3611
  }
3253
3612
  function startCopy(value, asData) {
3254
3613
  const clone = isError(value) ? cloneError(value) : void 0;
@@ -3273,7 +3632,7 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
3273
3632
  sensitive: foldedNames(fieldNames),
3274
3633
  headerNames: foldedNames(headerNames ?? fieldNames),
3275
3634
  censor,
3276
- serializedKeys: new Set(serializedKeys),
3635
+ serializedKeys: capturedSet(serializedKeys),
3277
3636
  errorsAsData: serializedKeys !== void 0,
3278
3637
  errorTextToSerializer,
3279
3638
  maxVisits,
@@ -3283,13 +3642,13 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
3283
3642
  return (value, isRecordRoot = false) => {
3284
3643
  try {
3285
3644
  const visits = { count: 0 };
3286
- const call = {
3645
+ const call2 = {
3287
3646
  ...rules,
3288
3647
  headerKept: typeof value === "object" && value !== null && errorOutputs.has(value),
3289
3648
  visits,
3290
3649
  insideErrors: rulesInside(rules, insideNames, visits)
3291
3650
  };
3292
- return walk(value, call, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
3651
+ return walk(value, call2, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
3293
3652
  } catch {
3294
3653
  return {
3295
3654
  _redactionFailed: true,
@@ -3326,7 +3685,11 @@ function parseResourceAttributes(raw) {
3326
3685
  } catch {
3327
3686
  value = rawValue;
3328
3687
  }
3329
- Object.defineProperty(parsed, key, { value, enumerable: true, configurable: true });
3688
+ Object.defineProperty(
3689
+ parsed,
3690
+ key,
3691
+ bareDescriptor({ value, enumerable: true, configurable: true })
3692
+ );
3330
3693
  }
3331
3694
  return parsed;
3332
3695
  }
@@ -3403,7 +3766,7 @@ function buildResourceBindings(resolved, format, extras = {}) {
3403
3766
  }
3404
3767
  return bindings;
3405
3768
  }
3406
- var OWNED_SERVICE_KEYS = /* @__PURE__ */ new Set([
3769
+ var OWNED_SERVICE_KEYS = capturedSet([
3407
3770
  "name",
3408
3771
  "version",
3409
3772
  "namespace",
@@ -3464,16 +3827,16 @@ function withSemconvException(record, format, maxBytes = Number.POSITIVE_INFINIT
3464
3827
  }
3465
3828
 
3466
3829
  // src/server/utils/serialize-request.util.ts
3467
- function isObject2(value) {
3830
+ function isObject(value) {
3468
3831
  return typeof value === "object" && value !== null;
3469
3832
  }
3470
3833
  function isRequest(value) {
3471
- if (!isObject2(value)) return false;
3834
+ if (!isObject(value)) return false;
3472
3835
  const { rawHeaders, method, socket } = value;
3473
- return Array.isArray(rawHeaders) || typeof method === "string" && isObject2(socket);
3836
+ return Array.isArray(rawHeaders) || typeof method === "string" && isObject(socket);
3474
3837
  }
3475
3838
  function copyHeaders(headers) {
3476
- return isObject2(headers) ? { ...headers } : {};
3839
+ return isObject(headers) ? { ...headers } : {};
3477
3840
  }
3478
3841
  function serializeRequestValue(input, secretSegments = []) {
3479
3842
  try {
@@ -3550,9 +3913,9 @@ var PATH_SEGMENT = /\[\s*['"]([^'"]+)['"]\s*\]|([^.[\]]+)/g;
3550
3913
  var INDEX_SEGMENT = /^\d+$/;
3551
3914
  function leafNameOf(path2) {
3552
3915
  let leaf;
3553
- for (const match of path2.matchAll(PATH_SEGMENT)) {
3916
+ for (const match of allMatches(PATH_SEGMENT, path2)) {
3554
3917
  const quoted = match[1];
3555
- const name = quoted ?? (match[2] !== void 0 && INDEX_SEGMENT.test(match[2]) ? void 0 : match[2]);
3918
+ const name = quoted ?? (match[2] !== void 0 && matchesPattern(INDEX_SEGMENT, match[2]) ? void 0 : match[2]);
3556
3919
  if (name !== void 0 && name !== "*") {
3557
3920
  leaf = name;
3558
3921
  }
@@ -3579,7 +3942,7 @@ function serializeErrorValue(value_, ownFields = ALL_OWN_FIELDS, censorMessage)
3579
3942
  return serialized;
3580
3943
  }
3581
3944
  function toEventName(logKey) {
3582
- return logKey.toLowerCase().replaceAll("_", ".");
3945
+ return replaceAllText(lowerCase(logKey), "_", ".");
3583
3946
  }
3584
3947
  function withEventName(record, field) {
3585
3948
  if (field === false) {
@@ -3604,7 +3967,7 @@ function resolveRecordRedactor(options) {
3604
3967
  );
3605
3968
  }
3606
3969
  function wholeRootKeys(options) {
3607
- return /* @__PURE__ */ new Set(["logKey", "err", ...Object.keys(options.serializers)]);
3970
+ return capturedSet(["logKey", "err", ...Object.keys(options.serializers)]);
3608
3971
  }
3609
3972
  function ownFieldPolicyOf(options) {
3610
3973
  return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
@@ -3643,7 +4006,7 @@ function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = tr
3643
4006
  );
3644
4007
  }
3645
4008
  function resolveRedactOption(options) {
3646
- const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...new Set(options.redactPaths)];
4009
+ const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...capturedSet(options.redactPaths)];
3647
4010
  if (paths.length === 0) {
3648
4011
  return void 0;
3649
4012
  }
@@ -3686,6 +4049,10 @@ function buildTraceMixin(logContext, options) {
3686
4049
  censorMessage: buildMessageCensor(options)
3687
4050
  });
3688
4051
  }
4052
+ var UNSET_ENTRY_NAMES = {
4053
+ levelVal: void 0,
4054
+ write: void 0
4055
+ };
3689
4056
  function buildStreams(options, destinations, health) {
3690
4057
  const censorMessage = buildMessageCensor(options);
3691
4058
  return destinations.map((destination) => {
@@ -3697,6 +4064,7 @@ function buildStreams(options, destinations, health) {
3697
4064
  );
3698
4065
  health.registerStream(destination, stream);
3699
4066
  return {
4067
+ ...UNSET_ENTRY_NAMES,
3700
4068
  // Guarded: this runs at provider construction, BEFORE any lifecycle hook, so a
3701
4069
  // consumer implementing `minLevel` as a throwing getter would fail the factory
3702
4070
  // and the application would never start — earlier than any fail-soft path can
@@ -3753,10 +4121,24 @@ function buildFormatters(options, redactRecord, redactBindings, onTruncate) {
3753
4121
  log: buildRecordFormatter(options, redactRecord, onTruncate)
3754
4122
  };
3755
4123
  }
3756
- function buildPinoInstance(options, logContext, destinations, health) {
4124
+ var UNSET_PINO_NAMES = {
4125
+ transport: void 0,
4126
+ crlf: false,
4127
+ msgPrefix: void 0,
4128
+ name: void 0,
4129
+ writable: false,
4130
+ _writableState: void 0,
4131
+ prettyPrint: void 0,
4132
+ onChild: void 0
4133
+ };
4134
+ function refuseUnsafeOptions(options) {
4135
+ if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
3757
4136
  if (options.maxStringLength !== void 0) {
3758
4137
  refuseCensorBeyondLimit(options.redactCensor, options.maxStringLength);
3759
4138
  }
4139
+ }
4140
+ function buildPinoInstance(options, logContext, destinations, health) {
4141
+ refuseUnsafeOptions(options);
3760
4142
  const redactRecord = resolveRecordRedactor(options);
3761
4143
  const redactSerialized = buildNameRedactor(options);
3762
4144
  const ownFields = ownFieldPolicyOf(options);
@@ -3764,10 +4146,10 @@ function buildPinoInstance(options, logContext, destinations, health) {
3764
4146
  const onTruncate = (reason) => health.recordTruncation(reason);
3765
4147
  const pinoOptions = {
3766
4148
  level: options.level,
3767
- ...redactOption === void 0 ? {} : { redact: redactOption },
3768
- // Resource identity, resolved ONCE here rather than per entry: Pino
3769
- // pre-serializes `base` into the instance's chindings, so the cost of the
3770
- // extra attributes is one string built at construction, not work per log.
4149
+ ...redactOption === void 0 ? {} : { redact: { ...redactOption, remove: false } },
4150
+ ...UNSET_PINO_NAMES,
4151
+ // Resource identity, resolved ONCE here rather than per entry: Pino pre-serializes `base` into
4152
+ // the instance's chindings, so the extra attributes cost one string at construction.
3771
4153
  base: buildResourceBindings(
3772
4154
  resolveServiceMetadata(options.service),
3773
4155
  options.resourceFormat,
@@ -3806,7 +4188,7 @@ var DestinationHealth = class {
3806
4188
  this.entrySizeTruncations = 0;
3807
4189
  this.stringLengthTruncations = 0;
3808
4190
  /** Destinations whose `onInit()` rejected. Identity-keyed, not name-keyed. */
3809
- this.failed = /* @__PURE__ */ new Set();
4191
+ this.failed = capturedSet();
3810
4192
  /**
3811
4193
  * Destinations that initialized, each with its effective level as an index into
3812
4194
  * {@link LOG_LEVEL_PRIORITY}.
@@ -3832,7 +4214,7 @@ var DestinationHealth = class {
3832
4214
  * for the whole window — coarser than per-entry tracking, and wrong only in the
3833
4215
  * direction that duplicates rather than loses.
3834
4216
  */
3835
- this.writeFailed = /* @__PURE__ */ new Set();
4217
+ this.writeFailed = capturedSet();
3836
4218
  /**
3837
4219
  * In-flight asynchronous writes per destination.
3838
4220
  *
@@ -4088,20 +4470,21 @@ var HookTimeoutError = class extends Error {
4088
4470
  }
4089
4471
  };
4090
4472
  function withTimeout(work, ms) {
4091
- return new Promise((resolve, reject2) => {
4473
+ const wait = new IntrinsicPromise((resolve, reject2) => {
4092
4474
  const timer = setTimeout(() => {
4093
4475
  reject2(new HookTimeoutError(ms));
4094
4476
  }, ms);
4095
- const settle = (done) => (...args) => {
4096
- clearTimeout(timer);
4097
- done(...args);
4098
- };
4099
- try {
4100
- Promise.resolve(work()).then(settle(resolve), settle(reject2));
4101
- } catch (cause) {
4102
- settle(reject2)(cause);
4103
- }
4477
+ awaitOutcome(work, (outcome) => {
4478
+ if (outcome.ok) resolve();
4479
+ else reject2(outcome.cause);
4480
+ try {
4481
+ clearTimeout(timer);
4482
+ } catch {
4483
+ }
4484
+ });
4104
4485
  });
4486
+ absorb(wait);
4487
+ return tag(wait);
4105
4488
  }
4106
4489
 
4107
4490
  // src/server/services/destination-registry.service.ts
@@ -4151,7 +4534,9 @@ var DestinationRegistry = class {
4151
4534
  async onModuleInit() {
4152
4535
  for (const destination of this.registered) {
4153
4536
  try {
4154
- await withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs);
4537
+ await intactOr(
4538
+ withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs)
4539
+ );
4155
4540
  this.active.push(destination);
4156
4541
  this.health.markHealthy(destination, this.effectiveLevelOf(destination));
4157
4542
  } catch (cause) {
@@ -4183,14 +4568,16 @@ var DestinationRegistry = class {
4183
4568
  async notifyRegistryReady() {
4184
4569
  for (const destination of this.registered) {
4185
4570
  try {
4186
- await withTimeout(
4187
- () => destination.onRegistryReady?.({
4188
- heldEntriesDeliveredElsewhere: this.health.deliveredByHealthySink(
4189
- destination,
4190
- this.effectiveLevelOf(destination)
4191
- )
4192
- }),
4193
- this.options.destinationHookTimeoutMs
4571
+ await intactOr(
4572
+ withTimeout(
4573
+ () => destination.onRegistryReady?.({
4574
+ heldEntriesDeliveredElsewhere: this.health.deliveredByHealthySink(
4575
+ destination,
4576
+ this.effectiveLevelOf(destination)
4577
+ )
4578
+ }),
4579
+ this.options.destinationHookTimeoutMs
4580
+ )
4194
4581
  );
4195
4582
  } catch (cause) {
4196
4583
  this.reportHookFailure(destination, cause);
@@ -4218,7 +4605,9 @@ var DestinationRegistry = class {
4218
4605
  if (configured === void 0) {
4219
4606
  return this.options.level;
4220
4607
  }
4221
- return LOG_LEVEL_PRIORITY.indexOf(configured) > LOG_LEVEL_PRIORITY.indexOf(this.options.level) ? configured : this.options.level;
4608
+ return LOG_LEVEL_PRIORITY.slice(LOG_LEVEL_PRIORITY.indexOf(this.options.level)).includes(
4609
+ configured
4610
+ ) ? configured : this.options.level;
4222
4611
  }
4223
4612
  /**
4224
4613
  * Report one destination init failure as a structured
@@ -4332,7 +4721,7 @@ var DestinationRegistry = class {
4332
4721
  continue;
4333
4722
  }
4334
4723
  try {
4335
- await withTimeout(() => destination.onShutdown?.(), remaining);
4724
+ await intactOr(withTimeout(() => destination.onShutdown?.(), remaining));
4336
4725
  } catch (cause) {
4337
4726
  this.reportShutdownFailure(destination, cause);
4338
4727
  }
@@ -4711,7 +5100,7 @@ function productionRefusal() {
4711
5100
  );
4712
5101
  }
4713
5102
  async function buildTransform(view) {
4714
- const { build } = await import('pino-pretty');
5103
+ const { build } = await tag(import('pino-pretty'));
4715
5104
  return build({
4716
5105
  ...DEFAULT_VIEW,
4717
5106
  ...view,
@@ -4788,7 +5177,7 @@ var PrettyDevDestination = class {
4788
5177
  throw productionRefusal();
4789
5178
  }
4790
5179
  try {
4791
- this.stream = await buildTransform(this.view);
5180
+ this.stream = await tag(buildTransform(this.view));
4792
5181
  } catch (cause) {
4793
5182
  this.initFailed = true;
4794
5183
  throw initFailure(cause);
@@ -5148,8 +5537,8 @@ function isRecord3(value) {
5148
5537
  }
5149
5538
  function exceptionFields(error) {
5150
5539
  try {
5151
- if (!isRecord3(error) || typeof error["getResponse"] !== "function") return {};
5152
- const response = error["getResponse"]();
5540
+ if (!isRecord3(error)) return {};
5541
+ const response = error["getResponse"]?.();
5153
5542
  if (!isRecord3(response)) return {};
5154
5543
  const nested = response["error"];
5155
5544
  const carrier = isRecord3(nested) && typeof nested["code"] === "string" ? nested : response;